2005年4月18日 星期一

忘了一件事

[lang_zh]
二十歲生日那年,決定在每年生日買給自己一本書,不同領域的書。今年那時候好像在忙什麼事,沒去買,得找個時間去找本書。

我想找一本小說,描寫一個人的小說。
[/lang_zh]

[lang_en]
On my 20th birthday, I made my mind to buy me a book as a present in my every birthdays, something different to my field. I was busy at that time on this birthday, so I haven't bought it until now. Hmm... I need to find a book quickly.

I like to find a novel, a novel which depict someone normal.
[/lang_en]

2005年4月12日 星期二

perl blog

寫個 perl 語的 blog !?

MultiViews

[lang_zh]
又寫了一個 Blosxom 3.0 的 plugin Orz MultiViews 是一個可以讓你同時擁有多個語言
的 blog entries 的 plugin。MultiViews 這個詞是從 Apache 的設定來的,它允許不同
的人讀到不同的語言的同一個網頁。

你可以將你的 blog 加上多個語言版本,來看個例子:

我試圖在我的 blog 上同時維護中英兩個版本。今天我寫了一個中文的檔案 XXXX.txt,
跟另一個英文的檔案 XXX.txt.en。這樣已經足夠做到基本的語言選擇。我把我的
default language 設成 "en" 給大多數的人使用,並將設定支援 "zh" 這個語言。這
個設定會透過 HTTP header 裡的 Accept-Language 來實作,也可用參數的方式來指定。

下載 MultiViews.
[/lang_zh]

[lang_en]
Another Blosxom 3.0 plugin! MultiViews let you maintain multi-language entries for Blosxom 3.0. MultiViews refer to Apache's configuration, which allow visitors to read different language of your pages.

You can add multiple-language version of entries to your blog. Let's see an example:

I'm a Taiwanese. I'm trying to keep both Chinese and English version in my blog (http://victor.csie.org/blog/). I wrote XXXX.txt in chinese and XXXX.txt.en in English. I'm going to set my default language to "en" for the most people use English, and people who use Chinese will read the Chinese version if their prefer language Accept-Language in HTTP heder) is "zh", "zh-tw", etc.

Get MultiViews.
[/lang_en]

2005年4月9日 星期六

makecontext(3)

竟然有這種東西 orz

#include

void makecontext(ucontext_t *ucp, void *func(), int argc, ...);
int swapcontext (ucontext_t *oucp, ucontext_t *ucp);

2005年4月4日 星期一

抓到小偷

剛才離開系館,在牽車時,看到一個人在找腳踏車。在我把車牽出來之前,他牽著車(一台淑女車)經過我旁邊,就讓他先過了。我騎了一下子,忽然覺得怪怪的,剛才他好像沒開鎖就牽出來了 @@; 而且還牽往反方向! 猶豫了一下,決定回去看看。

結果,看到他在另一排腳踏車旁邊看來看去。過去問說「這台車是你的嗎」「不是」 orz
操著香港人的口音,說他車被幹了,想幹一台回來用 -_- 念了他一陣子,看他的樣子還滿老實的,就沒再做什麼。後來有到他會經過的路徑看一下,他應該是有看到我,希望別再犯了。

後來想想,我是不是可以很帥地說「你被補了!」現行犯不是人人可逮補嗎 XD 這樣好像滿爽的耶 XD

2005年4月3日 星期日

TIME_WAIT state

[lang_zh]
在寫計網作業時,發現只要有 client 連進來,在 httpd 砍掉之後,沒辦法馬上再 bind 同一個 port。netstat 看到了 TIME_WAIT。

Active close 一個 connection 時,必須在 TIME_WAIT state 等待 2 x MSL (/maximum segment lifetime/) 的時間。RFC 1122 的建議值是 120 秒。但是 Linux 的實作上 follow BSD,把 MSL 設為 30 秒,net/ipv4/tcp_minisocks.c 裡面有這段註解:
[/lang_zh]

[lang_en]
When I wrote my Computer Network's homework, I found that binding to the same port will be failed after a client comes in and stop the httpd. I see TIME_WAIT state when execute netstat.

One should wait in TIME_WAIT state for 2 x MSL (/maximum segment lifetime/) after close one connection. The suggestion time interval in RFC 1122 is 120 seconds. But the implementation of Linux follows BSD, which set MSL to 30 seconds. There's a comment in net/ipv4/tcp_minisocks.c:
[/lang_en]


* [ BTW Linux. following BSD, violates this requirement waiting
* only for 60sec, we should wait at least for 240 secs.
* Well, 240 consumes too much of resources 8)
* ]



[lang_zh]
試了一下時間,真的是一分鐘 Q_Q 本來是在做測試,懶得把 port 寫在參數裡面。看來得辛苦一點點啦 XD

BTW, Unix Network Programming 真是好書呀!!

Update:
用 setsockopt 打開 SO_REUSEADDR 可以解決這個問題
[/lang_zh]

[lang_en]
I observed the time, and it really about 1 minute Q_Q So I should add a port to the argument :/

BTW, Unix Network Programming is really a great book!

Update:
Use setsockopt to enable SO_REUSEADDR will solve this problem.
[/lang_en]

Live Bookmark based on RSS

今天下午想到一個 idea,實作了出來。

很多人有要同時 maintain 多份 Bookmark/Favoriate 的問題,所以我在想是不是能將 RSS feed 餵給 Firefox 的 Live Bookmark,來解決這個問題。因為 Firefox 的 Live Bookmark 跟一般的 bookmark 放在一起,所以能用這種方式產生 bookmark 的效果。當然其他瀏覽器就不一定能用啦,privacy 的問題也先不理他 :P

screenshot


source code (bookmark-*.tar.gz)