Alexa.com 宣佈將在 2022 年五月退役

Hacker News 上看到的消息,Alexa.com 將在 2022 年五月退役:「We will be retiring Alexa.com on May 1, 2022」,對應的討論在「We will be retiring Alexa.com (alexa.com)」這邊。

討論裡面有提到一些替代方案,大概只有 similarweb 堪用,另外也有提到「Tranco」這個:

A Research-Oriented Top Sites Ranking Hardened Against Manipulation

歷史啊...

產生名次的 SQL

Percona 的「Generating Numeric Sequences in MySQL」這篇在討論產生字串序列,主要是在 MySQL 環境下,裡面看到的技巧「Session Variable Increment Within a SELECT」這組,剛好可以用在要在每個 row 裡面增加名次:

SELECT (@val := @val + 1) - 1 AS value FROM t1, (SELECT @val := 0) AS tt;

另外看到 MariaDBMySQL 8.0 系列因為有多支援各種功能,剛好也可以被拿來用,然後最後也提到了 Percona 自家出的 MySQL 8.0.20-11 將會直接有 SEQUENCE_TABLE() 可以用 (這應該才是 Percona 這篇文章的主要目的,推銷一下自家產品的新功能)。

文章收起來之後遇到可以拿出來參考用...

2018 年矽谷科技公司的薪資

不太意外的,排名起來加州這一區的科技公司的薪資還是最高的 (這邊包括了所有的所得,包括薪資、股票與分紅):「Top Paying Tech Companies of 2018」。

已經先整理出來的前五名分成「Entry-level / 1+ Yrs of Experience」、「Mid-level / 3+ Yrs of Experience」、「Been Around the Block / 5+ Yrs of Experience」三類,可以看到相對於年資的增加,薪資的調整也很快...

不過這邊相同名次的不會佔多個位置,只會佔一名,跟我們平常用的方式不太一樣,所以雖然是前五名但是都有六個公司。

對於按讚數排名的方法

前幾天看到一篇 2009 年的老文章,在討論使用者透過「喜歡」以及「不喜歡」投票後,要怎麼排名的方法:「How Not To Sort By Average Rating」。

基本的概念是當使用者投票數愈多時就會愈準確,透過統計方法可以算一個信賴區間,再用區間的下限來排... 但沒想到公式「看起來」這麼複雜 XDDD

Score = Lower bound of Wilson score confidence interval for a Bernoulli parameter

但實際的運算其實沒那麼複雜,像是 Ruby 的程式碼可以看出大多都是系統內的運算就可以算出來。其中的 z 在大多數的情況下是常數。

require 'statistics2'

def ci_lower_bound(pos, n, confidence)
    if n == 0
        return 0
    end
    z = Statistics2.pnormaldist(1-(1-confidence)/2)
    phat = 1.0*pos/n
    (phat + z*z/(2*n) - z * Math.sqrt((phat*(1-phat)+z*z/(4*n))/n))/(1+z*z/n)
end

The z-score in this function never changes, so if you don't have a statistics package handy or if performance is an issue you can always hard-code a value here for z. (Use 1.96 for a confidence level of 0.95.)

作者後來在 2012 年與 2016 年也分別給了 SQL 以及 Excel 的範例程式碼出來,裡面 hard-code 了 95% 信賴區間的部份:

SELECT widget_id, ((positive + 1.9208) / (positive + negative) - 
                   1.96 * SQRT((positive * negative) / (positive + negative) + 0.9604) / 
                          (positive + negative)) / (1 + 3.8416 / (positive + negative)) 
       AS ci_lower_bound FROM widgets WHERE positive + negative > 0 
       ORDER BY ci_lower_bound DESC;
=IFERROR((([@[Up Votes]] + 1.9208) / ([@[Up Votes]] + [@[Down Votes]]) - 1.96 * 
    SQRT(([@[Up Votes]] *  [@[Down Votes]]) / ([@[Up Votes]] +  [@[Down Votes]]) + 0.9604) / 
    ([@[Up Votes]] +  [@[Down Votes]])) / (1 + 3.8416 / ([@[Up Votes]] +  [@[Down Votes]])),0)

而更多的說明在維基百科的「Binomial proportion confidence interval」可以翻到,裡面也有其他的方法可以用。

Google PageRank 資料將不再公開

Google 將不再對外公開 PageRank 資訊:「Google has confirmed it is removing Toolbar PageRank」與「RIP Google PageRank score: A retrospective on how it ruined the web」。

PageRank 資訊是透過 Google Toolbar 再反向被挖出來的,而 Toolbar 上的資訊將會拿掉,也預期對應的 API 應該也會關閉:

Google has confirmed with Search Engine Land that it is removing Toolbar PageRank. That means that if you are using a tool or a browser that shows you PageRank data from Google, within the next couple weeks it will begin not to show any data at all.

Google 內部還是會用,只是不會公開了...

分析網站流量的工具

在「Find Out How Much Traffic a Website Gets」這邊講到了五個分析網站流量的工具,分別是 AlexaCompeteSimilar WebSEM Rush 以及 Quantcast

由於你不可能知道其他網站的實際流量,這些都是估算值,就只是拿來參考用的,幫助你稍微有個概念而已 :p

IndexTank 的設計

IndexTank 是在 xdite 的個人板上看到的網站,號稱真正 Scalable 的 Search Engine,看了他的架構設計後看起來應該是真的 Scalable。

由於是屬於 SaaS 服務,對於 startup 不想自己做 search engine 的可以直接套上去。而對於技術人員真正有價值的是他的 API 設計文件中的 function definition syntax:「function definition syntax」,雖然故意寫個 coming soon,但實際上可以在 client library 裡看到範例:「Python client」。

先內建一些基本的數學函數,像是四則運算、power、log,並且內建一些很常用到的變數。接下來定義出來的函數可以再重複使用,不斷累積上去,最後在 query 的時候就可以 ORDER BY 某個 score...

IndexTank 告訴你「利用 API 讓前端程式設定 function 以降低 denormalization 的複雜度」時要怎麼設計 API,當你自己建立 search engine 時,新增的 function 還可以在後端用 MapReduce 把資料補上去...。

另外可以再參考「How Hacker News ranking algorithm works」這篇文章。(這篇文章的 comment 裡面有其他的 ranking code 可以看)