September 5th, 2009
Uncategorized
gzip is a blance of speed and compression ratio.
For more compression ratio (but far more slow speed), use lzma/xz.
bzip2 is out-dated. It occupies a bit more space than lzma/xz, but the decompression speed is much slower.
For fastest speed and lowest CPU usage, use lzop. On modern (500MHz+) computers, it most likely that your compression is bounded by your disk I/O! It’s very suitable for backing up a lot of large files.
August 27th, 2009
Uncategorized
8月28日(中國大陸是9月1日)發布的snow leopard只支持Intel Macs了。
附圖一張:被拋棄的蘋果電腦────────────────的包裝袋

August 22nd, 2009
Uncategorized
注意:小弟使用的Mac OS X版本是10.4.11,Yahoo奇摩輸入法版本是1.0.2207。如果各位大大的版本不同的話,情況可能會有所不同哦。
首先需要的就是該輸入法的 cin檔 ,可用google搜尋。沒錯,就是 開放香草 的cin檔,Yahoo奇摩輸入法是基於開放香草的。
那麼如何安裝呢?Yahoo奇摩的網站上只說Windows下直接雙擊cin檔就可以了,沒說Mac OS X下如何操作。摸索一番發現該這麼操作,在終端下運行:
cd /Library/Components/Yahoo\!\ KeyKey.bundle/Contents/SharedSupport/KeyKeyServer.app/Contents/SharedSupport/CinInstallerTiger.app/Contents/MacOS/
./CinInstallerTiger ~/Desktop/cj5.cin
當然用你要安裝的cin檔替換cj5.cin了。(看那CinInstallerTiger.app都為cin檔准備了圖標,應該是要關聯的,但是不知道安裝程序出了什麼問題,沒有關聯。)等到Yahoo奇摩輸入法裡出現你添加的輸入法後,就可以把這個程序 Ctrl-c 掉了。要當心的是如果你是從Finder裡把文件夾拖到終端下(為了少打字),要在“!”號前手工加反斜槓,Mac OS X不會自動加。這也是Mac OS X癡呆的地方。Yahoo也不夠意思,在目錄名裡帶空格也就罷了,畢竟這也算Mac OS X的慣例,還別出心裁地帶上驚歎號,真是Orz。
如果你修改了cin檔,想更新的話,再次運行上面的步驟是沒有用的。必須先到~/Library/Application Support/Yahoo! KeyKey/DataTables/Generic下把cin當移除了。然後再行安裝。
August 19th, 2009
Uncategorized
国外很多书都提供一个网页,放有关勘误信息。比如O’Reilly,每本书都有勘误页面,读者都可以提供勘误信息,很赞。
但是国内的很多书在这方面就差好多。
2年前我在豆瓣建了个勘误维基的小组,想利用wiki来分享读者发现的书中的错误。当时在wikispace上开了个wiki。
2年过去了,我发现wiki上除了我提交了十多本书中的勘误信息外并没有其他任何的编辑。
眼见这个wiki成了事实上的一个私人的记录工具,加上近半年来我开始使用hg管理各种文档,所以我就把它搬到了bitbucket。
http://bitbucket.org/weakish/errata/wiki/
用了hg,我没网上的时候也可以添加自己的勘误笔记,有网的时候fetch和push就可以了。
万一有人来添砖加瓦的话,bitbucket上的wiki,只要有bitbucket的账号或者OpenID就可以编辑。也可以用hg clone:
hg clone https://weakish@bitbucket.org/weakish/errata/wiki/
当然要push的话还是需要找我拿权限的。
August 17th, 2009
Uncategorized
Recently I’ve encountered this strange behavior in Python 2.5. A simplified version of the problem is as follows:
>>> n = 10
>>> [n for n in range(n)]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> [n for n in range(n)]
[0, 1, 2, 3, 4, 5, 6, 7, 8]
There is no big secret under the hood. But it does surprises me at first. The reason is in Python 2.x, list comprehension is simply a for loop.
Therefore, there are several workarounds:
-
Use different variable name:
[n for n in range(m)]
-
Update to Python 3.x, since in Python 3.x, list comprehension is implemented as a function on the hood:
Python 3.0 (r30:67503, Feb 14 2009, 18:56:53)
[GCC 4.0.1 (Apple Computer, Inc. build 5370)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> n = 10
>>> [n for n in range(n)]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> [n for n in range(n)]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
-
Use generator expression:
list(n for n in range(n))