os.walk can be surprisingly slow

Yesterday's tracing made one particular bitof DWiki 's page rendering pop out at me; almost 40% of the time forthe page was going just to create the '(Previous | Next)' links at thebottom.

Because DWiki is entirely filesystem based, its 'metadata' is the stateof the filesystem. Thus, creating the previous and next links requireswalking WanderingThoughts ' directory hierarchy to find out the order ofthe entries. Once I saw the times, I immediately started wondering if I


早睡早起精神好

bed

相信很多人都有「睡過頭」的經驗,現代都市人往往夜睡,但又要早起床上班上學,於是就發明了鬧鐘。而因為人們對鬧鐘有不同程度的「適應」,所以又有了不同類型千奇百怪的鬧鐘:

  • 捉迷藏型 — 務求令你要起身才可以關掉:

偶然的旅人


“住院?”

“後天要做乳癌手術。切除右側。整個切除。不過誰也不知道,這樣癌是于是就能夠順利停止蔓延。說是切掉之後才知道。”

他一時說不出話來。手依然放在姊姊肩膀上,沒什麼用意地一一順序眺望著放在房間裡的各

20060303網摘 – 當電影節遇上博客

HK Media


Visualizing dynamic program flow

Someone I know has been talking to me recently about bravely becomingthe first outside user of DWiki . As part of this, I realized he mightlike to have practical documentation about how DWiki templates get used in practice for things like producingthis blog. Which made me realize that I'd forgotten how the templateflow goes.

I could have re-read the templates and traced the execution path, butthen I had a bright idea: why not make the program do this for me? So Iinstrument template processing


The :; shell prompt trick

For years, I've had a somewhat unusual shell prompt. It looks likethis:

: ;

(where is the hostname of the current machine.)

Putting the hostname in your prompt is pretty ordinary, but what'sthe other stuff? These days, a more typical shell prompt is somethinglike ' cks@newman:~$ ', to quote a Debian example. (And manypeople use more elaborate prompts, such as Jamie Zawinksi's .)

The trick


A robots.txt surprise

Because I don't really like banning MSNBot , MSNSearch's web spider, I decided to drop our ban and see if its behaviorhad improved since last September . The process ofdoing this has led me to a little surprise about how at least MSNBotmatches User-Agent lines in robots.txt .

From looking at our logs, I already knew that MSNBot was still visiting;it pulled robots.txt at least once a day. So all I needed to do waschange robots.txt so that


電影與科學

sfmovie

最近在讀一本叫《 電影中有趣的科學 》的科普讀物,相信大家從書名已可以想到本書的內容是甚麼了。本書會說出電影中種種的科學錯誤,如在《Jurassic Park》裏的大部份恐龍其實是生於白堊紀,《Contact》裏的蟲洞之旅的時間概念錯了,


Unicode is not simple

Unicode is very big these days, and there are a lot of people who willtell you that Unicode is simple once you take the effort to understandit and that you're a parochial spud if your new program doesn't supportit. Unfortunately, only simple Unicode is easy.

The simple vision of Unicode is that once you have your data inUnicode, you're just dealing with characters and your program canjust do stuff with them as normal. Okay, case and collation is hard , but there


舊屎啲嘢


童年時代的真正得著是面對現實。

記得有一天,我拿著九十七分的歷史測驗卷到父母跟前,滿以為他們會給我一點獎勵,豈料得到的「獎勵」是一個歷史知識解決不了的問題,父母問:「上次數學測驗三十分都未教訓你,點解你