Category Archives: Programming

Git 內類似 svn export 的功能

用 git-archive。 預設是輸出成 tar 格式到 stdout,所以可以用下面的指令取出一份 archive: mkdir ../working git archive master | tar -x -C ../working

Posted in Computer, Murmuring, Programming, Software | Tagged , , , | Leave a comment

Python 2 與 Python 3 的相容性

前幾天 Python 2.7 正式釋出 (2010/07/03),預定是 Python 2 最後一個 major release,於是又有人再討論要怎麼寫出 Python 2 與 Python 3 都能夠跑的程式碼,以維持單一 codebase。 在「The real problem with Python 3 – no business case for conversion (was “I strongly dislike Python 3″)」這篇提到了一些語法及模組技巧 (基本上就是用 Python 2 與 Python … Continue reading

Posted in Computer, Murmuring, Programming, Software | Leave a comment

GCC 4.5.0 以及 ClangBSD

GCC 4.5.0 前幾天公告釋出:「GCC 4.5.0 Released」,而另外一邊以 clang 取代 FreeBSD 系統內 GCC 的計畫 ClangBSD 也開始徵求測試者了:「[CFT]: ClangBSD is selfhosting, we need testers now」。 目前 ClangBSD 可以在 i386 以及 amd64 上編譯 bootable-kernel 以及 world (目前的 -CURRENT 版本),平常在用 -CURRENT 的人除了上面那篇 mailing list 上的說明外,在「Building FreeBSD with … Continue reading

Posted in Computer, FreeBSD, Murmuring, OS, Programming, Software | 1 Comment

P3PC (Performance of 3rd Party Content)

Steve Souders 開了一個「Performance of 3rd Party Content」,分析 3rd party script 的效能。目前已經分析了四個 js。 看完四個 js 的分析後,可以看出來一些 pattern: 用 async script。Google 曾經介紹 Google Analytics 可以使用 async script:「Google Analytics Launches Asynchronous Tracking」。 當使用 async script 時無法使用 document.write (會有奇怪的結果),就算不是 async script 也應該儘量避免使用。常見的方法是建立一個帶有 id 的 … Continue reading

Posted in Browser, Computer, Murmuring, Network, Programming, Software, WWW | Leave a comment

改寫 wretch-albumexpander.js (無名小站相簿展開程式)

這次主要是把之前用 jQuery 1.2.6 的需求改寫,改用 getElementsByClassName()、getElementsByTagName() 以及 getElementById() 取得元素,然後用 .innerHTML 直接換掉內容。 由於這次改寫避免使用 unsafeWindow 以及複雜的 GM_* 函式,在 Google Chrome 除了遇到一個小問題之外 (可以寫一段 code workaround),目前跑起來還蠻正常的。 參考:「Wretch Album Expander」以及 GitHub 上的「gslin’s albumexpander」。

Posted in Browser, Computer, Firefox, GoogleChrome, Murmuring, Network, Programming, Software, WWW | Leave a comment

IE 的 Cookie 限制

在 Simon Willison 那邊看到 Eric Lawrence 在 MSDN Blog 上的解釋:「Internet Explorer Cookie Internals (FAQ)」。Simon Willison 的文章在「Internet Explorer Cookie Internals (FAQ)」這篇內。 他們討論到 IE 到目前所有版本的 cookie 都不支援 max-age 參數,所以有個避免 MySQL master/slave replication lag 的技巧在 IE 上沒辦法用的很好:當寫入資料時 (例:使用者發表文章),server 會設定一組 30secs 的 cookie,當 web … Continue reading

Posted in Browser, Computer, IE, Murmuring, Network, Programming, Software, WWW | Leave a comment

Amazon SimpleDB 支援不同程度的 Consistency

在 Amazon CTO Werner Vogels 的 blog 上提到了 AWS SimpleDB 支援不同程度的 consistency:「Choosing Consistency」,在 James Hamilton 也對這件事情發表正面的意見:「I love eventual consistency but…」。正式的技術文件在「Amazon SimpleDB Consistency Enhancements」這邊可以查到。 Eventual consistency 以 CAP theorem 中的 Consistency 妥協,試著解決 scale 問題,但缺點是 stale read (可能會讀到舊資料),對要求比較嚴謹的子系統 (像是遊戲內的各種點數,身上帶的金幣之類的) 會很麻煩,而對於要求更嚴謹的系統 (像是商品搶購時的「剩餘數量」) 幾乎無法直接使用。 … Continue reading

Posted in Computer, Database, Murmuring, Network, Programming, Software | 3 Comments

HipHop for PHP 計畫

由 HipHop for PHP project 的幾位帶領者所說明的會議中解釋了不少東西 (在 USTREAM 有錄影可以觀看:Facebook Technology Tasting – HipHop for PHP)。 前半部份等於是把「HipHop for PHP: Move Fast」重講一次,並且說明他們在不少 case 下可以分析出 variable type,所以不需要用 zval (一般性的變數)。 比較重要的是後半段的 Q&A 部份。 就會場所提到的,他們目前跑在 Apache 1.3 + prefork 上面。有計劃要支援 multithreading,好處是 shared resource 可以共用,像是 database … Continue reading

Posted in Computer, Murmuring, Programming, Software | Leave a comment

Facebook 的 PHP 加速計畫

Facebook 的開發者在「HipHop for PHP: Move Fast」這篇的說明,也就是 HPHPi 計畫。 這個計畫 Facebook 的團隊花了兩年的時間公開,到現在有 90% 的 PHP server 跑在上面,平均起來比起 well-tuned PHP 還快了 50%。但目前還沒看到 code,而且以文章的說明並不清楚到底採用什麼方式,只有看到這樣解釋: When using HPHPi you don’t need to compile your PHP source code before running it. It’s helped us catch … Continue reading

Posted in Computer, Murmuring, Programming, Software | 4 Comments

jQuery 改用 Google Closure Compiler

othree 在 irc 上提到的… 依照「Commit 3fd62eae9df3159fc238a515bb748140a942313d to jquery’s jquery」這個 commit 的說明,jQuery 將使用 Google Closure Compiler,取代 YUICompressor 壓縮 jQuery: Switched from using YUI Compressor to Google Compiler. Minified and Gzipped filesize reduced to 22,839 bytes from 26,169 bytes (13% decrease in … Continue reading

Posted in Computer, Murmuring, Programming, Software | Leave a comment