We should forget about small efficiencies — Donald Knuth
21 Aug
Mozilla Firefox 2.0b2 Branch builds (20060821)
Sepecial Check-in
Known Issues
Popularity: 11% [?]
21 Aug
Effective Python Programming, from OSCON 2005.
Python’s growing popularity has brought many new developers to the language, often coming from other languages that have very different idioms and restrictions. This can lead to less-than-optimal coding styles.
This tutorial focuses on writing Python in a “Pythonic” way, working through a series of examples.
This is a concentrated exercise in helping people write code in a way that makes the best use of language features. It is of course possible to write bad Python–just as it’s possible to write bad code in any language. However, it is suprisingly easy to write good Python and hopefully this tutorial will help you bootstrap yourself into a better Python programmer.
This tutorial is aimed at people who already know Python, but don’t consider themselves experts. (Python experts will probably know most of the things discussed in this tutorial.)
You can download the presentation file (PDF) (159 slides) here.
Popularity: 16% [?]
21 Aug
Why Doesn’t Linux Need Defragmenting?, from OSNews.
It’s a question that crops up with depressing regularity: Why don’t Linux filesystems need to be defragmented?. Here’s my attempt at answering once and for all.
Rather than simply stumble through lots of dry technical explanations, I’m opting to consider that an ASCII picture is worth a thousand words.
Although oneandoneis2 doesn’t mention either NTFS or ext3, but I think this article gives a simplistic overview of how filesystems writes files.
Popularity: 10% [?]
21 Aug
Buffering in HTTP.SYS, from Windows Core Networking Team’s blog.
故事內容是這樣的. IIS 5.0 之前是用 WinSock 來 implement, 這樣預設會打開 buffering 機制, 到了 Windows 2003 的 IIS 6.0 開始, 則改由 HTTP.SYS 來負責. 這樣反而會遇到 performance 下降的問題.
主要的理由我猜是 Nagle’s Algorithm. 現在的 socket 實作預設都會打開 TCP 的 Nagle’s Algorithm. 這個演算法簡單的說, 就是利用 delay ack 來減少網路上所傳輸 packet 量, 進而增加 TCP 的 performance. 不幸的是, Nagle’s Algorithm 對於小 packet 的幫助比較明顯, 大 packet 反而會有 latency 拉長的反效果. 換句話說, 對於一次傳輸大量資料的網路程式, 應該要 disable Nagle’s Algorithm 會有比較好的 performance.
目前在 Windows 2003 SP1 之後有一個 workaround 的辦法, 就是利用 HTTP_SEND_RESPONSE_FLAG_BUFFER_DATA 這個 flag. 雖然說還有另一個 flag 是 HTTP_SEND_RESPONSE_FLAG_ENABLE_NAGLING, 表示預設應該是 disable Nagle’s Algorithm, 不過我還是很好奇, 為甚麼預設明明 disable Nagle’s Algorithm, performance 沒上去的原因, 和一般網路程式 enable Nagle’s Algorithm 一樣呢?
Popularity: 43% [?]
20 Aug
20 Aug
在看 Gentoo 的 portage log 時, 看到一個還蠻有趣的軟體, 叫做 cryctcat (portage/net-analyzer/cryptcat , ports/net/cryptcat).
雖然整體功能來說, 我覺得還是 socat (portage/net-misc/socat, ports/net/socat) 比較強, 不過就編密這方面, 因為 socat 是利用 OpenSSL 來達成這個效果, 就 netcat 簡而易用的角度, 不如用 cryptcat 所採用的 Twofish 這種 symmetric key block cipher 來的簡單易用了.
原先利用 netcat 來傳檔的方法如下:
MachineA:
nc -l 12345 < file.orig
MachineB:
nc MachineA.IP 12345 > file.sent.by.MachineA
要改成
MachineA:
cryptcat -l -p 12345 < file.orig
MachineB:
cryptcat MachineA.IP 12345 > file.sent.by.MachineA
這樣就會利用預設的密碼 metallica, 透過 Twofish 加密. 當然, 也可以用 -k 這個 option 來改變預設的密碼 ;-)
Popularity: 32% [?]
16 Aug
How To Create a Self-Restartable Application, from CodeProject.
This article describes the way to add restarting support to your Win32 applications. Key pointer is as followings:
Old Instance Create a Mutex and create a new process with command retrieved by GetModuleFileName().
g_RA_hMutexOtherRestarting = ::CreateMutex( NULL, TRUE, RA_MUTEX_OTHER_RESTARTING);
TCHAR szAppPath[MAX_PATH] = {0};
::GetModuleFileName(NULL, szAppPath, MAX_PATH);
CreateProcess(NULL, szAppPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
New Instance wait for this mutex for release which means old instance has been dead.
// Releasing mutex signal that process finished DWORD dwWaitResult = WaitForSingleObject(g_RA_hMutexOtherRestarting, 0); if (dwWaitResult == WAIT_TIMEOUT) ::ReleaseMutex(g_RA_hMutexOtherRestarting); ::CloseHandle(g_RA_hMutexOtherRestarting);
Popularity: 32% [?]