聚會時間公告: Kalug 8月份休會一次

七月 14, 2008
» [tips] rewrite debian/ubuntu 's lighttpd conf script from perl to python

Today I want to port lighttpd on another platform which basically a debian sarge system but without perl and dpkg package system on it. Since it's a debian based platform so I start from porting debian's binary lighttpd package, however I've found there're some perl script lays in /usr/share/lighttpd which are used when lighttpd startup.

While I can easily dump the result of perl script into a textfile,
and then startup my lighttpd correctly, I thought "maybe port it to python is not a bad idea." (since my target platform has python!), so here is the effort:
create-mime.assign.py

#!/usr/bin/python
#
# This script directly translate from debian's lighttpd perl script:
# create-mime.assign.pl
#
# Author: timchen119.at.nospam.gmail.com
# License: Public Domain
#
import sys

try:
f = open("/etc/mime.types",'r')
extensions = {}
print "mimetype.assign = ("
for line in f:
line = line.strip()
if line.startswith('#'): continue
if line != "":
splitlist = line.split()
if len(splitlist) < 2: continue
mime = splitlist[0]
for ext in splitlist[1:]:
if ext in extensions.keys(): continue
extensions[ext] = 1
print '".%s" => "%s",' % (ext,mime)
f.close()
print ")"
except Exception,e:
print e
sys.exit(1)


include-conf-enabled.py
#!/usr/bin/python
#
# This script directly translate from debian's lighttpd perl script:
# include-conf-enabled.pl
#
# Author: timchen119.at.nospam.gmail.com
# License: Public Domain
#

import os,glob

confdir = "/etc/lighttpd/"
enabled = "conf-enabled/*.conf"

os.chdir(confdir)

for file in sorted(glob.glob(enabled)):
print 'include "%s"' % file

use-ipv6.py
#!/usr/bin/python
#
# This script directly translate from ubuntu's lighttpd perl script:
# use-ipv6.pl
#
# Author: timchen119.at.nospam.gmail.com
# License: Public Domain
#

import socket

##this sometimes not accurate. (like in vserver mode)
#if socket.has_ipv6:
#

try:
if socket.socket(socket.AF_INET6,socket.SOCK_STREAM,0):
print 'server.use-ipv6 = "enable"'
except:
pass

All of these files can be found in http://kalug.linux.org.tw/~tim/lighttpd-debian-python-script/
Well something quite interesting happened when I port the debian's create-mime.assign.pl into python, It's that my python script's final result is not equivalent to perl one and has more mime types than its :
--- perlmime.txt    2008-07-14 15:29:23.000000000 +0800
+++ pymime.txt 2008-07-14 15:29:33.000000000 +0800
@@ -114,6 +114,11 @@
".dvi" => "application/x-dvi",
".rhtml" => "application/x-httpd-eruby",
".flac" => "application/x-flac",
+".pfa" => "application/x-font",
+".pfb" => "application/x-font",
+".gsf" => "application/x-font",
+".pcf" => "application/x-font",
+".pcf.Z" => "application/x-font",
".mm" => "application/x-freemind",
".gnumeric" => "application/x-gnumeric",
".sgf" => "application/x-go-sgf",
@@ -193,6 +198,11 @@
".pk" => "application/x-tex-pk",
".texinfo" => "application/x-texinfo",
".texi" => "application/x-texinfo",
+".~" => "application/x-trash",
+".%" => "application/x-trash",
+".bak" => "application/x-trash",
+".old" => "application/x-trash",
+".sik" => "application/x-trash",
".t" => "application/x-troff",
".tr" => "application/x-troff",
".roff" => "application/x-troff",
@@ -282,6 +292,7 @@
".tgf" => "chemical/x-mdl-tgf",
".mcif" => "chemical/x-mmcif",
".mol2" => "chemical/x-mol2",
+".b" => "chemical/x-molconn-Z",
".gpt" => "chemical/x-mopac-graph",
".mop" => "chemical/x-mopac-input",
".mopcrt" => "chemical/x-mopac-input",

So I start to dig why this happened, and I've found a strange perl regex filter all these mimetypes out, I believe it's a minor bug in original perl program. (or it does implicitly doing something meaningful? well I can't figure it out.)
--- create-mime.assign.pl    2008-07-14 15:35:58.000000000 +0800
+++ create-mime.assign.pl.new 2008-07-14 15:36:07.000000000 +0800
@@ -7,7 +7,7 @@
chomp;
s/\#.*//;
next if /^\w*$/;
- if(/^([a-z0-9\/+-.]+)\s+((?:[a-z0-9.+-]+[ ]?)+)$/) {
+ if(/^([A-Za-z0-9\/+-.~%]+)\s+((?:[A-Za-z0-9.+-~%]+[ ]?)+)$/) {
foreach(split / /, $2) {
# mime.types can have same extension for different
# mime types

replace this line and this will produce same results as mine.

usage:
just copy these py scripts to /usr/share/lighttpd
and change these lines if you're using debian based system
#### external configuration files
## mimetype mapping
#include_shell "/usr/share/lighttpd/create-mime.assign.pl"
include_shell "/usr/share/lighttpd/create-mime.assign.py"

## load enabled configuration files,
## read /etc/lighttpd/conf-available/README first
#include_shell "/usr/share/lighttpd/include-conf-enabled.pl"
include_shell "/usr/share/lighttpd/include-conf-enabled.py"

七月 3, 2008
» Linux 下 Flash 終於不會蓋掉 CSS/Javascript 選單了…

Linux 底下逛 Flash 的網站有個痛苦的地方。如果那個網站利用 CSS/Javascript製作了下拉式選單,而 flash 動畫恰好又在此選單附近,此時就很有可能選單被 flash 動畫蓋到的情況。但是各位鄉親,昨天釋出的 Flash player 10 beta2 終於解決這個必備又該死的問題!

Screenshot-11.png
比較一下舊版本 flash 9 同樣網頁的情形:
Screenshot-12.png
這個萬年問題終於解決了。另外一個好消息是 flash 也支援了 V4L2 的 webcam,如果你使用了 eeepc,這個支援對你來說也很有用 :) 


[update]
 

Flash player 10 beta2 到此下載: http://labs.adobe.com/downloads/flashplayer10.html

六月 26, 2008
» 【Firefox】Add-ons list @ Ubuntu 8.04

在認養自己的蒼鷺時,預載的 Firefox Edition(版本) 已升級至 Firefox 3 beta 5 了,又得知 Firefox 2 關閉分頁時並不會釋放記憶體,只好先升級起來放,等哪天 Google 大神做好 Toolbar 再去拜他囉。用最新的東西就要有不相容的覺悟啊..

凍仁新養的 Firefox 3 :P


附加元件(Extensions)

  1. Aardvark - 網頁剪輯
    開啟選取資料後按 H 有快捷鍵說明。

  2. Adblock Plus - 廣告阻擋
    跟廣告 Say good-bye ,有了它就不怕瀏覽速度會被拖累囉..

  3. All-in-One Sidebar - 整合側邊列
    將 書籤、瀏覽歷史、擴充套件.. 整合在一起的套件,還可拿來代替 Spilt Browser 的頁面分割呢

  4. Better Gmail 2 - Gmail外掛
    優化 Gmail 並可增加信件瀏覽速度,是 Gmail 重度使用者必備的套件之一

  5. CoLT - 連結複製
    在右鍵選單裡加入【將連結名稱及網址複製成】及【Copy Link Text】是 blogger 的好幫手

  6. Ctrl-Tab - 分頁特效
    不過凍仁只喜歡它在分頁列的列出所有分頁的功能.. 可列出所有分頁的縮圖,感覺就像 Ubuntu 列出所有桌面一樣.. XD

  7. CustomizeGoogle - 搜尋強化
    它可補足 Google 不足之處,例如增加其他搜尋引擎的連結資訊,或是移除不想要的內容(如廣告)

  8. Download Statusbar - 狀態列下載
    取代 Firefox 的下載視窗:將進度、下載速度.. 整合至下方的狀態列裡

  9. DownThemAll!
    續傳套件:凍仁在 Ubuntu 下替代 flashget 用的

  10. Extension List Dumper - 套件列表
    將 Firefox 裡的 plugin 清單一次列出來

  11. Fast Dial - 書籤速撥鍵
    快速瀏覽書籤的好幫手
    → 替代 Speed Dial 套件

  12. FaviconizeTab 分頁增強
    可隱藏分頁文字並簡化,只顯示 Favicon-Icon 讓分頁更簡潔..

  13. FireGestures - 滑鼠手勢
    讓滑鼠可以做更多事情.. 與之前 Firefox 2 的 All-in-One Gestures 雷同

  14. Fission
    像 Mac 那樣可以在網址列跑載入進度的小套件

  15. Flagfox
    顯示當前伺服器位置的國旗

  16. Foxmarks - 書籤同步套件
    Firefox 使用者必備的套件!可將書籤與 Server 同步,再也不必擔心會漏掉書籤XD

  17. FoxSaver - 幻燈片
    除了觀看自家圖片外,還可觀看 Firefox player 票選出人氣較高的圖片

  18. FoxyProxy - 代理者伺服器(強化版)
    可自訂多種 proxy 並自動切換,並支援 Firefox Portable

  19. Gmail Manager - 多重 Gmail 帳號監控、切換
    讓 Firefox 通知是否有新信件且快速切換 Gmail,重點是支援 Ubuntu TW E-mail 的切換(Google APP mail代管)。個人是比較不喜歡 Gmail Notifier

  20. Google Notebook - Google 筆記本
    可不離開瀏覽頁面,直接記下資訊

  21. Google Reader Notifier
    讓 Firefox 監控、快速啟動 Google 閱讀器(RSS訂閱)

  22. Google Toolbar - Google工具列
    在 Firefox 3 正式版推出後 Google 也有了相容的版本了,有需要在裝唄.. 不過現在比較習慣用 Secure Login 就是了XD

  23. GUtil! - Google功能整合按鈕
    有了他就可以快速切換所有 Google 的工具囉。不過 Button(按鈕) + All-in-One Sidebar 使用時會有 Button 重複出現的問題,建議使用 Menu(選單)

  24. Locationbar2 - 網址列改造
    讓連結看的更清楚

  25. Nightly Tester Tools - 版本相容
    在 Firefox 3 正式版推出前多多少少會遇到元件不相容的情形,只不過這也只是治標不致本的法子

  26. NoScript
    可阻擋 JavaScript 專用的套件,避免過多的 Script 載入藉由增進瀏覽速度

  27. Open IT Online
    有它在就可以線上編輯 Office 系列的東西囉

  28. OpenSearchFox
    搜尋引擎帶著走:有了就可在不開啟 yahoo 首頁的情況下查單字了..XD
    → 若不習慣也可改用功能雷同的 Add to Search Bar

  29. Personal Menu - 自訂選單
    讓 Firefox 更面板簡潔,更符合客制化.. 嫌螢幕太小?那就用這多多隱藏唄XD

  30. ReminderFox - 小狐狐提醒幫手
    在 Firefox 嵌入代辦事項,不只可在本機使用,還可透過 ftp server 同步之

  31. Save Session - 瀏覽頁面儲存
    Tab Mix Plus(TMP) 並不是每次都靈光,凍仁還是喜歡這個..

  32. ScribeFire - Blog Editer
    將 IDE 與 Firefox 整合的套件,是blogger 必備的套件之一。

  33. Secure Login - 一鍵登入
    搭配 Firefox 內建的Saved Passwords(密碼儲存)使用,使登入更人性化..

  34. Smart Bookmarks Bar
    縮小書籤工具列的圖示

  35. Stop Autoplay
    擋下網頁內嵌影音的自動播放

  36. Stop-or-Reload Button
    將 Firefox 預設的「重新整理」、「停止」按鈕合併,既可省空間又美觀

  37. QuickDrag - 超級拖放
    如同 Maxthon (myIE2) 的「超級拖放(Super Drag and Drop)」功能,滑鼠拖曳後放開便可達到搜尋、存圖、開啟純文字網址、開新分頁等功能。
    → 替代原本的 Super DragAndGo 套件

  38. Tab Catalog - 電視牆分頁
    Firefox Showcase 雷同擁有列出電視牆分頁,不過凍仁喜歡它的簡潔、快速.. 在加上滑鼠移至 button 上會自動開啟電視牆.. ps:熱鍵為 F8 與 Firefox Showcase 不同,若不習慣請自行修改設定。

  39. Tab Mix Plus - 強化分頁
    自訂鏈結、書籤、網址列、搜尋列是否要強制開啟在新分頁。此為 yuoo2k 製作的社群修改版 可跑 FX3b5 ..

  40. Tongwen - 新同文堂
    繁簡轉化的好工具,有了它就台灣大陸一家親了:P 不過此版雖然兼容 Firefox 3 系列,但卻無自動更新功能,真正有需要在使用唄。


佈景主題(Themes)

  1. Abstract Zune
    黑色與橘色的組合,適合使用 Human GTK 的各位 XD

  2. Aero Fox
    兼具現代感與黑色系列的佈景,另也提供銀白系列 Aero Silver Fox :P

  3. Azerty III
    這是款能與 Ubufox 配合且走可愛路線的佈景,雖說在 mozilla 的分類為現代.. :P

  4. NASA Night Launch
    上圖的 Firefox 3 就是使用此佈景,是一款黑色系為主的佈景,不時還會看見太空梭飛來飛去.. XD

  5. Phoenity Reborn
    兼具簡潔與可愛的佈景主題,且會配合系統色彩 o o"


相關連結:
Firefox 附加元件
Mozilla Taiwan - 社群嚴選的Top 15 套件
電腦玩物 - 小活動:Firefox Extensions List「我的」火狐必裝擴充套件列表,「你的」呢?

六月 16, 2008
» 【Command】各種壓縮與解壓縮指令

.tar
打包:tar cvf FileName.tar DirName
解包: tar xvf FileName.tar

.gz
壓縮:gzip FileName
解壓1:gunzip FileName.gz
解壓2:gzip -d FileName.gz


.tar.gz
壓縮:tar zcvf FileName.tar.gz DirName
解壓:tar zxvf FileName.tar.gz

.bz2
壓縮: bzip2 -z FileName
解壓1:bzip2 -d FileName.bz2
解壓2:bunzip2 FileName.bz2


.tar.bz2
壓縮:tar jcvf FileName.tar.bz2 DirName
解壓:tar jxvf FileName.tar.bz2

.bz
壓縮:unkown
解壓1:bzip2 -d FileName.bz
解壓2:bunzip2 FileName.bz

.tar.bz
壓縮:unkown
解壓:tar jxvf FileName.tar.bz

.Z
壓縮:compress FileName
解壓:uncompress FileName.Z

.tar.Z
壓縮:tar Zcvf FileName.tar.Z DirName
解壓:tar Zxvf FileName.tar.Z

.tgz
壓縮:unkown
解壓:tar zxvf FileName.tgz

.tar.tgz
壓縮:tar zcvf FileName.tar.tgz FileName
解壓:tar zxvf FileName.tar.tgz

.zip
壓縮:zip FileName.zip DirName
解壓:unzip FileName.zip

.rar
壓縮:rar e FileName.rar rar a FileName.rar
解壓:rar a FileName.rar rar e FileName.rar

.lha
壓縮:lha -a FileName.lha FileName
解壓:lha -e FileName.lha

資料來源:
EvoTalk - Unix下常用壓縮格式的壓縮與解壓縮方法

六月 11, 2008
» (GNU/Linux Debian base)pgAdmin3 1.8.4 編譯與快速安裝教學

pgAdmin 3 1.8.4 在不久前發佈了, 但老魚在官方下載站中僅見到 slackware , OSX, Win32 版本, GNU/Linux Debian 與 Ubuntu 未置入新的 Deb 安裝檔, 正好老魚的 Linux 教學進度到了"套件管理與編譯原始碼", 剛好可以互相當教學案例~ 那就製作 2份簡報, 來個 2站文章串接吧 ! 全螢幕觀看: http://docs.google.com/Present?docid=ddgj2m37_557fgxdq7ck&skipauth=true (GNU/Linux Debian base)pgAdmin3 1.8.4 編譯與快速安裝教學 相關連結: (教學簡報分享) L1005 Linux 套件管理及編譯 http://oss-tw.blogspot.com/2008/06/l1005-80.html

六月 10, 2008
» Linux Mint - 更人性化的 Ubuntu

恩。Ubuntu 要加油了。最近看了 Linux Mint 有個功能非常實用,就是可以在應用程式的圖示上按右鍵選擇移除軟體。

easyuninstall

這功能真的很人性化。想起上次用 Mint 的感覺還不錯,只是有一點點慢,但是畫面的美觀程度以及小細節做的倒是不錯。我想是可以作為其他發行版本參考的對象。

對 Linux 人性化有興趣的朋友請繼續閱讀 Linux Mint 的發行公告,我覺得他們安裝/反安裝做的真的很好。

六月 8, 2008
» 【Themes】Hardy Dark

此佈景是凍仁為了配合 Firefox 3 的佈景主題「NASA Night Launch」而拼湊出來.. 這次是以暗色系(dark)及金黃色(gold)為主和 Vista 選單,不過這樣就得放棄可愛的 AWN dock 囉 :(



佈景主題(GTK Themes)Hardy Theme



視窗邊框(Metacity)Dark-Flegma
預設的視窗標題並非為金黃色,這邊得自行至 ~/.themes/Dark-Flegma/metacity-1/metacity-theme-1.xml 修改(若是想走 Mac dark 風格可使用 Gombo Dark Mac)

24 <draw_ops name="title-text-focused">
25   <image filename="titlebar-mid-focused.png" x="0" y="0" width="title_width + 6" height="height"/>
26   <image filename="titlebar-mid-focused.png" x="title_width + 21 `min`  width - object_width" y="0" width="object_width" height="height"/>
27   <clip x="0" y="0" width="title_width + 16 `min` width - 14" height="height"/>
28   <title color="#FFDB57" x="5" y="(height - title_height) / 2"/>
29 </draw_ops>



圖示(Icon)Buuf 1.03



開始選單Vista Start Menu for Gnome Panel



桌布(Wallpaper)Hardy Heron Black



滑鼠指標(Mouse)Pinux's Tux Cursors Theme(這邊凍仁是用 pDebian24)



延伸閱讀:
【Themes】Ubuntu 佈景主題
資料來源:
GNOME-Look.org - Eyecandy for your GNOME-Desktop
Ubuntu-Art.org

六月 5, 2008