Twitter Spam Report

Twitter 上遇到 Spam Follower,可以用 direct message 通報給 spam 這個帳號 (不過,你要先 follow 對方,而且對方反過來 follow 你),但手動回報的機制還是太麻煩。

於是有人就在 Greasemonkey 上寫了回報機制:「Twitter Spam Report for Greasemonkey」,裝好後,在每個 Twitter 頁面下面都有 "Report Spam" 的連結...

Update:需要改 code,把:

var twitterspam_user = $("h2").text().replace(/ /g,'');

改成:

var twitterspam_user = $("h2").eq(0).text().replace(/ /g,'');

CherryPy 與 mod_wsgi (apache 2.2)

依照「mod_wsgi 與 .htaccess」的設定設好後,在 index.py 內參考「Integration With CherryPy」這篇文章的範例就會動了,可以用 ab 或是 httperf 測試看看效能如何。

另外 Robert E Brewer 在 PyCon 2009 - Chicago 上講的「Introduction to CherryPy (#90)」(包含影片) 也蠻適合剛碰 CherryPy 的人看。

mod_wsgi 與 .htaccess

mod_wsgiapachePEP-333 的實做軟體,使用 Python 開發 web application 的人不用知道怎麼介接。

既然是 .htaccess,apache 的部份就不講了。

Update:修正 mod_rewrite 的部份。

先從最簡單的「所有 request 都丟給 index.py」開始:

SetHandler wsgi-script
RewriteEngine on
RewriteBase /~gslin/py/
RewriteRule ^index.py$ - [L]
RewriteRule ^(.*)$ index.py/$1 [L]

如果不希望連靜態檔案都透過 index.py 處理 (像是 robots.txt),要做兩件事情。第一件是限制 wsgi-script 的範圍:

<Files *.py>
SetHandler wsgi-script
</Files>

然後修改 mod_rewrite 的條件,只有檔案不存在的 request 才丟給 index.py:

RewriteEngine on
RewriteBase /~gslin/py/
RewriteRule ^index.py$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.py/$1 [L]

不會很難,不過還是寫下來,以後應該會找到自己的文章...

MySQL ALTER TABLE

瑪莉亞的凝望》第三本看到一半,到 Twitter 上看到 Jeremy Zawodny (O'Reilly 出的 High Performance MySQL 第一版與第二版的作者之一) 在喊 MySQL ALTER TABLE 跑了八天了:

I have an ALTER TABLE running for nearly 8 days now... yikes.

結果 Aaron Brazell 居然很機車的這樣問他 XDDD

@jzawodn Removing South Carolina from all Craigslist tables?

如果不清楚 Craigslist 與南卡的新聞,可以參考紐約時報「Under Pressure, Craigslist to Remove ‘Erotic’ Ads」這篇的說明。

Anyway,Jeremy Zawodny 有說明這次的目的是要把舊的 InnoDB 轉成 XtraDB compression 格式:

the big ALTER TABLE is to enable InnoDB/XtraDB compression on ~650M records (old CL postings)

簡單提一下 MySQL 搭配一些 open source solution 的運作方式。

首先是要打開 replication,有 master 與 slave server(s)。寫入都到 master,讀取到 slave。(這邊為了說明方便,暫時不考慮 replication delay)

除了 master/slave 讓前端的 application servers 或 web servers 存取外,另外建立一套 slave server,上面有 snapshot filesystem (像是 Linux 的 LVM,或是效能較好的 Solaris/OpenSolarisZFS),用 cron 定時將 MySQL 暫停並寫入磁碟,產生 snapshot。

在這樣的架構下,當需要 ALTER TABLE 而且已經知道會卡很久時,我們可以從 snapshot 上先複製一份完整的資料,建立一台 MySQL server 並且在上面 ALTER,等到完成後再接回 master server,將 replication delay 的部份補上。如果想確認資料正確性,可以跑 mk-table-checksum 確認。當 replication delay 跟上後,停機時間不用太長就可以將 master 換成這份新的格式。

雖然 Jeremy Zawodny 沒有詳細說明,不過應該是類似的方法。

Update:Jeremy Zawodny 在「The Big ALTER TABLE Test」這篇有提到結果。

無法註冊在博客來的原因

去年年底在「博客來的網站的註冊頁面...」這篇提到無法在 books 註冊的原因終於找到了,因為博客來註冊頁 (也就是 https://db.books.com.tw/newmember.php 這頁) 的「同意」擋 Referer。

當你有裝防毒軟體,並打開隱私權設定 (有一些防毒軟體在安裝完後就是這樣) 就會造成問題。

好久沒看到這種網站了...

FreeBSD ZFSv13 進 RELENG_7

FreeBSD ZFSv13 終於進入 RELENG_7 了:「svn commit: r192498」。

幾個重要的改變:

  • kmem now goes up to 512GB so arc is now limited by physmem (kmem 再度拉高到 512GB)
  • the arc now experiences backpressure from the vm (which can be too much - but this allows ZFS to work without any tunables on amd64) (我不確定這個說明的意思,猜測是指當非 ZFS 需要系統資源時,cache 所使用的記憶體空間會放出來給 kernel 用)

另外 commit log 有個讓人還蠻在意的地方:

Supported by: Barrett Lyon, BitGravity

BitGravity (一家 CDN company) 的 CTO 贊助 XDDDDD