Akamai 買下 Cotendo...

Akaiami 的新聞稿先出來了:「December 22, 2011 - Akamai to Acquire Cotendo」,Cotendo 的只有在 Twitter 上看到官方帳號提到 Akamai 的新聞稿。

併購的金額在:

Under terms of the agreement, Akamai will acquire all of the outstanding equity of Cotendo in exchange for a net cash payment of approximately $268 million

上個月月底的時候就有消息了:「Akamai Reportedly Buying Rival Cotendo For Up To $350 Million」,不過一直都是謠傳而已...

Cotendo 的產品在 Akamai 裡面都有對應的產品,這次併購看起來比較像是減少競爭對手,或是買專利...

把 Google Plus 的數字 icon 藏起來...

那個紅色的數字 icon 還蠻妨礙工作的,到 userscripts.org 上翻一翻,果然有人有寫過了 (雖然是沒幾天前):「Go Away! Google Plus」。

PS:隨便丟字進去測試的時候,發現 "test" 第五名是 tw.yahoo.com,這是怎麼了...?

gitolite 的 hook...

弄了整個週末的 gitolite,總算是把 hook 搞定。

簡單的說,修改完 ~/.gitolite/hooks/common/ 裡的 hook script 後,需要下 gl-setup 指令,這個指令會把現在所有的 git repository 內的 hook script 再 symbolic link 一次。

另外,gitolite 的環境變數可能會影響 git 本身執行 (我是在 git pull -v 更新某個目錄下的 git repository 時失敗),這時可以用 /usr/bin/env -i /usr/local/bin/git 確保 git 執行時不會被環境變數影響...

gitolite 看起來是個好東西,不過光是靠官方的文件要搞定頗累... (週末都在 Stack Overflow 上度過)

如果要自己寫 TOTP 的幾個要看的東西...

整理下來:

有玩過 HMAC 的人,讀這些文件應該不難...

TOTP 在預設的情況下,其實就是 HMAC-SHA-1 後取後面 32bits,然後轉成數字取 100000 的餘數,而 TOTP 文件是架構在 HOTP 的定義上,把時間切齊 (預設 30secs) 變成整數丟進去攪和,然後特地交代要處理 2038 年超過 Int32 的 case XDDD

最後 Google 那份文件是要輸出 QR code 讓手機可以讀的方式,建議不要用網路服務產生 QR code (因為有 secret key 啊),寧可自己抓 library 建一個用...

另外 Google Authenticator 一堆東西都只能用預設值 (Currently, the XXX is ignored by the Google Authenticator implementations.),所以也沒什麼好選的,就拿預設值吧... :o

Server side 的話,至少我在 CPAN 上面看到 Authen-OATH 可以用了,用起來也很簡單 :o

PHP 提供的資料結構...

從「How big are PHP arrays (and values) really? (Hint: BIG!)」這篇看到的。文章本身值得花些時間看過了解,不過對我來說重點在最後面的 SplFixedArray

PHPDatastructures 說明目前 PHP SPL 所支援的 data structure,在記憶體用量以及效率上面都會比自己實作來的小且快。

可以看到很多都支援 Countable、Iterator,以及 ArrayAccess,代表可以用 foreach() 或是對應的方式存取... 如果自己寫 library 的時候應該要善用這些 SPL。

YouTube (Google) 允許環球唱片 (Universal Music Group,UMG) 直接移除非 UMG 所擁有版權的影片

依照環球唱片 (Universal Music Group,UMG) 提供給法院的文件中,YouTube (也就是 Google) 允許 UMG 透過 YouTube 的 CMS (Content Management System) 移除「不屬於 UMG 的影片」:「Google Deal Allegedly Lets UMG Wipe YouTube Videos It Doesn't Own」,文件 (PDF) 在:「gov.uscourts.cand.248875.14.0.pdf」這邊可以下載取得。

重點在於這份文件中第四頁的這段:

The UMG-YouTube agreement grants UMG rights to effect the removal of user-posted videos through YouTube’s Content Management System (“CMS”), based on a number of contractually specified criteria that are not limited to the infringements of copyrights owned or controlled by UMG. Klaus Decl., Ex. 4 (Klaus to Kavanaugh letter, Dec. 14, 2011). Dotcom speculates in his declaration that Universal must have sent a so-called “DMCA notification form,” such as the one he printed and attached at Ex. E to his declaration, to YouTube. Doctcom Decl. ¶ 11. But UMG (which interacts with YouTube) does not use that form when requesting the removal of material pursuant to UMG’s contract with YouTube. UMG uses YouTube’s automated CMS system.

繼續來看後續吧...

同時用 mod_deflate 與 mod_fastcgi 所產生的問題...

今天花了不少時間找到的問題...

問題是使用 mod_fastcgi 以及 mod_deflate 時,Content-Encoding 會是 gzip,但 Content-Length 會是未壓縮的長度。

也就是說,伺服器端在 header 提供的 Content-Length 可能寫 8KB,但實際上只丟出 2KB (壓縮後的大小),於是瀏覽器讀完這 2KB 後會停下來一直等,等到 Keep-Alive timeout 斷線 (在我機器上預設是 5 秒)。

在 timeout 斷線後 browser 會就抓到的資料直接解開執行 (因為這 2KB 都有抓到,於是都正確執行)。如果用瀏覽器這邊的 debugger 觀察,就會發現從 first byte 後 5.00 秒才 document ready。

解法有人在 2008 年給過:「Content-Length header should be set using ap_set_content_length」,不過因為 mod_fastcgi 一直沒出新的正式版,所以大家都還是拿到舊的版本。

所以,與之前修正 multi-threading 的問題一樣,往 ports 本身丟 patch:「Update www/mod_fastcgi to fix mod_deflate issue.」,修正後再測試就正常了。

Squid 3.1 的 forward proxy 設定...

因為打算給 portsnap 用,所以得用 Squid 3.1 架 forward proxy,可以避免大量對外抓同樣的資料...

由於是內部的機器,不需要擋 acl,設定起來超簡單... ports 裝完 www/squid31 後,把 squid.conf 寫成:

#
http_access allow all
#
access_log /home/squid/logs/access.log squid
cache_dir aufs /home/squid/cache1 1024 16 16
cache_effective_group squid
cache_effective_user squid
cache_log /home/squid/logs/cache.log
cache_mem 256 MB
http_port 3128

這樣就「會動」了... (先不管效率) 照 squid 的慣例,第一次必須先跑 /usr/local/sbin/squid -z 讓目錄建立出來,後面就是標準的 /usr/local/etc/rc.d/squid start

BSD make 與 GNU make 的 Makefile...

前陣子看到 fcamel 丟出來的舊文章:「Debugging make」,花了一些時間看裡面關於 BSD make 與 GNU make 的相同處,之後寫 Makefile 的時候應該會相當有幫助。

目前的目標是 FreeBSDUbuntu,文章裡面有提到三個變數在兩個平台是通用的,分別是 $< (The source from which the target is to be made)、$* (The base name of the target (no extensions or directory))、$@ (The full name of the target)。

另外文章後面也有提到不相容的地方... 如果能避免就儘量避免?

把 Ubuntu 11.10 的 Alt-Tab 行為改掉...

參考「Revert Alt-tab behavior changed in 11.10」這篇提到的方法改。

Ubuntu 11.10 的 Alt-Tab 切換視窗的行為與 11.04 不同,會遇到切換兩次是不會切回原來視窗的情況。

我遇到的情況是 Google Chrome 除了 browser 本身以外,還開了一個 Tasky for Google Tasks,於是在系統裡面就會有兩個視窗。當我現在 focus 在 browser window,用 Alt-Tab 切到 terminal 後,再用 Alt-Tab 切回來,focus 變成在 Tasky 上面... 這讓人相當困擾 :o

依照上面那篇文章所提到的方法改系統設定就回到原來 11.04 比較不那麼擾人的切換方式...