十月 3, 2013
» [tips] [Howto] Support Nvidia Optimus on Ubuntu 12.04 LTS (precise) [No Bumblebee needed]

For laptops which use muxless Nvidia Optimus, there's a new way to support officially on Ubuntu 12.04 LTS.

 #sudo apt-get install nvidia-319-updates nvidia-prime xserver-xorg-lts-raring 

The command will upgrade
 * kernel to 3.8 ,
 * X server RandR to 1.4
 * Install Nvidia driver version 319.

After reboot, it will use nvidia driver by default.
There is no need to upgrade to 13.10 if you prefer 12.04 LTS.

一月 17, 2013
» [tips] g_clear_pointer



因為在tracking一個bug,
所以要backport indicator-power這個package到ubuntu precise.
意外發現了glib在2.33之後支援的一個還滿好用的function:
g_clear_pointer()

簡言之以前的寫法,要把物件刪除再把指標設為NULL:

if (priv->object_path != NULL) {
g_free(priv->object_path);
priv->object_path = NULL;
}
現在只要一行就可以達成了

g_clear_pointer (&priv-;>object_path, g_free);
當然要backport的話作法就是相反~~

二月 17, 2012
» [tips] access gnome-keyring in cron

It seems program execute in your crontab doesn't have the luxury to use the gnome-keyring daemon to get the permission it should had. In order to let your program access gnome-keyring, you need to reuse a environment variable in your desktop session called DBUS_SESSION_BUS_ADDRESS in your cron environment also.The quickest way to do it is to add these line:


. ~/.dbus/session-bus/*-0
export DBUS_SESSION_BUS_ADDRESS


in your cron script (it assume you logged in under X display 0)

六月 1, 2011
» [link] Nvidia Optimus on linux 的解決方案 : bumblebee 大黃蜂

https://github.com/MrMEEE/bumblebee

四月份的時候買了一台DELL i5二代的筆電,
用起來還算滿意,
但是就是在linux下居然無法使用Nvidia的顯示卡這點讓我不是很滿意。

當初在買筆電的時候,為了相容Linux還特地挑了一個Nvidia的獨顯,
想說一直以來Nvidia的顯示卡在Linux下都支援良好,
所以也沒特別注意相關的消息,
這次買了才發現,,
只要是使用了Nvidia動態切換內顯和獨顯的Optimus技術的筆電,
在Linux下通通沒辦法驅動Nvidia獨顯,
而只能用Intel的內建顯示,
並且Nvidia的顯卡雖然無法運作,
但還是會在背景吃掉相當多的電力,
一個原本是設計來省電的技術反而耗了更多的電,
實在是非常的諷刺。

原本想說應該BIOS就可以直接切換成Nvidia獨顯,
結果研究了一下才知道Nvidia的輸出會經過Intel顯卡,
所以如果沒有內建硬體的Multiplexer,
想關掉Intel顯卡直接使用Nvidia顯卡是不可能的,
當時只好在網路上找了一個acpi的方法把Nvidia的顯卡先關掉,
但是反過來如果只是要把Nvidia的顯示卡打開卻似乎是辦不到,
實在是萬分苦惱。

然後剛剛發現了這個bumblebee(大黃蜂)專案,
提供了ㄧ個簡單的script就讓Linux支援了Nvidia顯示卡且使用官方的3D驅動,
雖然還沒辦法動態切換, 但是可以手動切換也算是不錯了。

安裝的方法真的是很簡單:
先git clone https://github.com/MrMEEE/bumblebee.git
然後執行其中的install.sh 回答幾個只要選default就可以的問題 之後就安裝完成囉!

平常的時候,預設還是會用Intel的顯卡來執行,
要用Nvidia執行的時候, 則要透過optirun來執行該程式~~

#glxgears

304 frames in 5.0 seconds = 60.604 FPS
301 frames in 5.0 seconds = 60.137 FPS
301 frames in 5.0 seconds = 60.136 FPS
301 frames in 5.0 seconds = 60.137 FPS
301 frames in 5.0 seconds = 60.137 FPS

#optirun glxgears
* Starting Bumblebee X server bumblebee Enabling nVidia Card failed (Error: AE_BAD_PARAMETER).
[ OK ]
3015 frames in 5.0 seconds = 602.973 FPS
3312 frames in 5.0 seconds = 662.366 FPS
2908 frames in 5.0 seconds = 581.591 FPS
2798 frames in 5.0 seconds = 559.551 FPS
3409 frames in 5.0 seconds = 681.679 FPS

雖然是有些錯誤訊息不過還是有成功的跑起來了,
另外再跑了lgfxgears也是由2fps到100fps,果然是快了不少.

一月 27, 2010
» Upcoming Django 1.2 & PostgreSQL 9.0

http://docs.djangoproject.com/en/dev/topics/db/multi-db/#topics-db-multi-db
Django 1.2 新功能: Multiple databases

PostgreSQL 9.0 新功能 Hot Standby跟Streaming Replication

http://wiki.postgresql.org/wiki/Streaming_Replication

http://developer.postgresql.org/pgdocs/postgres/hot-standby.html

還沒空試, 不過結合這幾個新功能的話似乎可以有效的分散django資料庫端的read/write, 將write-only database server上的WAL(write-ahead log) 即時streaming到read-only database server上的hot standby database, 感覺好像不錯~~

十二月 29, 2009
» [tips] 續: 設定 Logitech G5 in Linux 補強版

話說兩年前買了一支羅技的G5滑鼠
在工作的linux環境上用到目前仍然非常滿意
之所以會說很滿意 是因為G5其實有一個很好按的大姆指鍵
大家都知道xwindow裡只要選取了文字
就會自動"複製"選到的文字
然後按下中鍵就可以"貼上"
但是目前的滑鼠都有滾輪的設計,
所以這個複製貼上的功能變成了按下滾輪
在linux裡我就用xmodmap這個程式
將這個大姆指鍵取代xwindow中鍵貼上的功能,
因為按下滾輪其實我覺得要用力按,
而複製貼上其實是還滿常用的功能
其實感覺還挺傷手的
另外我也用xbindkey將滾輪向左向右的功能做來切換視窗
而滾輪按下變成剪貼簿裡的貼上,
(即Ctrl+V, 跟xwindow的複製貼上不同)
設定的詳情可以看我2年前的文章
http://timchen119.blogspot.com/2007/12/logitech-g5-in-linuxxwindow.html

前幾天升級系統的時候不小心把滑鼠滾輪向左向右切換視窗的功能給砍了~ 因為兩年沒設定 連自己都得再找一下原本的設定方法
就在找方法的同時
剛好看到一個lomoco的hack可以將g5的硬體dpi按鈕關掉,
改用軟體控制
但是lomoco這個加強羅技滑鼠在linux上支援的程式本身並沒有支援G5, 於是就順手弄了一支python程式g5mouse.py,
可以改用軟體操縱DPI的設定,
這樣我們在G5上還可以多出了兩個按鍵可以自行設定!

廢話不多說,
首先先easy_install g5mouse

localhost tim # easy_install g5mouse
Searching for g5mouse
Reading http://pypi.python.org/simple/g5mouse/
Reading http://code.google.com/p/g5mouse/
Best match: g5mouse 0.1
Downloading http://pypi.python.org/packages/source/g/g5mouse/g5mouse-0.1.tar.gz#md5=d3347dbf261135049cb6e5a6be133355
Processing g5mouse-0.1.tar.gz
Running g5mouse-0.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-oHyJGh/g5mouse-0.1/egg-dist-tmp-6Vn5h_
warning: install_lib: 'build/lib' does not exist -- no Python modules to install
zip_safe flag not set; analyzing archive contents...
Adding g5mouse 0.1 to easy-install.pth file
Installing g5mouse.py script to /usr/bin

Installed /usr/lib/python2.6/site-packages/g5mouse-0.1-py2.6.egg
Processing dependencies for g5mouse
Finished processing dependencies for g5mouse

localhost tim # g5mouse.py  
Usage: g5mouse.py [options] /dev/usb/hiddev0

g5mouse.py control logitech G3,G5,G7 and G9's hardware dpi buttons on linux

Example: g5mouse.py -d 1600 -l 1 /dev/usb/hiddev0

Author: timchen119.at.gmail.com

Options:
-h, --help show this help message and exit
-d DPI, --dpi=DPI set dpi: 400,800,1600,2000
-l LED, --led=LED set led: NONE,1,2,3,ALL
-n, --nodpibuttons disable + and - DPI speed buttons



然後就可以透過g5mouse.py這隻程式軟體設定DPI,
(可以切換到400,800,1600,2000四種DPI 比原先的還多一種
而且也可以自行設定LED燈號)
比如

你要切到DPI 2000並將所有指示DPI的LED設成第一個
就可以下
g5mouse.py -d 2000 -l 1

預設是DPI 1600跟LED全關掉 預設device是/dev/usb/hiddev0
所以你也可以只下g5mouse.py -d 800 就可以將LED全關掉 並將DPI設到800
如果加上-n這個選項 還可以把硬體控制DPI button的功能關掉
這樣我們就會多出兩個button可以自行設定
將這個程式放在你的.xprofile (XDM)或是.xinitrc/rc.local裡
讓他開機自動執行
再來我們就多出了兩個按鈕可以操控囉~

我就用xbindkeys將+號設定成Ctrl+C 而-號設成Ctrl+V
並把原先的滾輪按下的功能給取消以免誤按~

我目前的.xbindkeysrc.scm

(xbindkey '("b:6") "/usr/bin/xvkbd -xsendevent -text '\\[Control_L]\\[Page_Up]'")
(xbindkey '("b:7") "/usr/bin/xvkbd -xsendevent -text '\\[Control_L]\\[Page_Down]'")
(xbindkey '("b:9") "/usr/bin/xvkbd -xsendevent -text '\\[Control_L]\\[V]'")
(xbindkey '("b:10") "/usr/bin/xvkbd -xsendevent -text '\\[Control_L]\\[C]'")
(xbindkey '("b:11") "/usr/bin/xvkbd -xsendevent -text '\\[Control_L]\\[Page_Up]'")
(xbindkey '("b:12") "/usr/bin/xvkbd -xsendevent -text '\\[Control_L]\\[Page_Down]'")


另外這隻程式不止支援G5, G3/G5二代/G7/G9 都可以操縱~

八月 17, 2009
» [tips] sphinx支持中文pdf的方法

目前 python 官方文件使用的sphinx是個不錯的文件產生系統,

可以同時由rst產生html,latex,pdf,ps等文件格式,

不過我目前試的結果似乎預設從latex產生pdf時沒有支援中文,

網路上相關的文件大都寫得很複雜,

但其實只要在文件project裡的source/conf.py加入

latex_preamble = '''\usepackage{CJKutf8}\n\AtBeginDocument{\\begin{CJK}{UTF8}{bsmi}}\n\AtEndDocument{\end{CJK}}'''

其他都不需更改,
以後make latex; cd build/latex; make all-pdf 就都可以產生出正確的
中文pdf檔了

測試環境是Gentoo linux底下的texlive 2008 (cjk) + pdflatex

八月 13, 2009
» [tips] linux裡 emacs23 utf8 中文輸入與SCIM

最近新昇到emacs 23.1

又發現SCIM中文輸入有問題, ctrl+space老是變回mark.

我的locale是zh_TW.UTF-8

其他程式輸入中文都沒啥問題

就emacs23.1無法輸入中文,

試了老半天 (暫時)解決方法如下:

啟動emacs時用 LC_CTYPE="zh_CN" emacs-23

.emacs 加上這行

(prefer-coding-system 'utf-8)

這樣就沒問題了

至於為什麼要如此我也不能理解

如果有高人肯告訴我那就再好不過了,

不過我暫時懶得去追了, 設個alias也就算了.

總之locale裡似乎只有zh_CN跟zh_CN.gbk會動.

btw,我的環境是gentoo linux.

註: 這個問題 基本上只在terminal上使用emacs -nw的使用者應該不會遇到.

五月 22, 2009
» [tips] benq FP222WH + nvidia 達到原生解析度1680x1050的方法

最近辦公室的電腦換了一張nvidia 9400的顯示卡,
可是搭配上benq FP222WH ,
解析度怎麼調最大都只有640x480, (各種方法都試過了)
後來總算讓我查出是EDID的問題,
原本舊版的nvidia driver有一招是在xorg.conf設定
"IgnoreEDID" "true",
不過我新版的180.51 driver根本不適用這個方法,
後來我研究了快一天,
不過最後研究出來的解決方法倒是很簡單,
放在這提供有需要的人參考,
首先我先去抄ATI顯卡列出的EDID,
然後將它做成一個128 byte 的EDID
HEX file, 我已經做好了所以直接抓這個檔案擺在/etc/x11就可以

http://kalug.linux.org.tw/~tim/benq/benq-c.bin

然後在你的xorg.conf裡加上幾行,
(請自行比對xorg.conf的相異處)

Section "Monitor"

Identifier "Monitor0"
VendorName "Monitor Vendor"
ModelName "Monitor Model"
HorizSync 30.0 - 86.0
VertRefresh 60.0

# 1680x1050 @ 60.00 Hz (GTF) hsync: 65.22 kHz; pclk: 147.14 MHz
Modeline "1680x1050_60.00" 147.14 1680 1784 1968 2256 1050 1051 1054 1087 -HSync +Vsync

EndSection

Section "Screen"
Identifier "Screen0"
Device "Card0"
Monitor "Monitor0"

Option "ConnectedMonitor" "DFP"
Option "CustomEDID" "DFP-0:/etc/X11/benq-c.bin"
Option "UseDisplayDevice" "DFP" # DVI out

SubSection "Display"
Viewport 0 0
EndSubSection
EndSection

我的是DVI接頭,
另外一個同事用的是DSUB(VGA) 的,
他說只要DFP改成CRT也可以用,
我們一個是用debian一個是用gentoo,
在預設情形下解析度都是錯誤的,
但是透過這個方法就可以達到原生解析度1680x1050. :)

四月 2, 2009
» [tips] ssh login without password using ssh-copy-id script

應該早點知道有這種懶人script存在的
而且還是裝完openssh就有的
(.ssh/authorized_keys,這是啥難記的檔名 @@)

現在只要

ssh-copy-id -i id_dsa.pub username@host

做完就好了 orz

二月 25, 2009
» Upgrade to KDE 4.2

上次升級4.0.5的KDE其實印象很不好,
不斷的crash之外 另外登入成功後也無法正確logout,
種種的問題又讓我退回使用3.5.x,
不過這次升級到KDE 4.2.0,
使用到目前為止其實還算順暢,
除了少數plasma的applet無法正確啟動外, 使用感覺還算良好.

我的平台是gentoo linux, 大部份套件是穩定版本的,
所以升級還在測試中的KDE4.2 , 其實有遇到幾個小困難:

1. 我原本的gcc版本是在gentoo裡被列為stable的gcc 4.1.2, 但在編譯kde-base/systemsettings時遇到困難, 老是有函式找不到, 最後參考網路上的作法 換至gcc 4.3.3後就一切順利. (真是詭異的作法)

2. plasma老是啟動時crash, 還是只能參考網路上的說法, 將穩定版的 qt 4.4.2換至qt 4.5.0rc1, 就解決了這個問題.

因為遇到這兩個套件需換至測試版本, 另外就是我也很久沒更新了, 所以emerge world居然重編了一千多個套件, 老實講distcc沒有那麼有用(據說我們公司裡有一個distcc陣列 :P 不過還是直接換硬碟到build server上會比較快啊 !), 因為configure的時間其實很長, 最後還是借了一台雙核E8400的電腦來build, 不然實在是太累人了.

KDE 4.2的穩定度大約是4.0左右的水準吧, 用到現在仍然沒有crash, 用起來的感覺也還不錯, 就是可能現在還不是安裝的最佳時機,有些AP用起來也可能還有問題, 如果對KDE的程式有重度需求可以再等等.

七月 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
» [tips] add bzr sftp support when you have no compiler on target platform (pure python )

bzr depends on paramiko to provide sftp support. While paramiko itself is pure python, its dependency pycrypto is not. PyCrypto have lots of C-extenstion and you'll need a compiler to install it. However since we only use part of pycrypto (to have sftp support for bzr), we could just add some stub files to prevent the [deploy] problem.

I have made a modified pure python version pycrypto and packaged it with paramiko 1.7.3, so after you installed bzr (use standard python setup.py or easy_install), you just extract paramiko-1.7.3-bzr-sftp-purepy.tgz
at your python site-package directory (make sure you don't have paramiko and pycrypto already exists, if you do, you don't need to install this package anyway) and happy bzr...!

This also makes bzr only depend on python so you could easily deploy it on a machine which doesn't have c compiler and still have sftp support.

Warning: this pacakage only add bzr sftp support and provides nothing besides this, and these COULD break other python packages which also used paramiko and pycrypto, so don't use it if you don't really need it. And the only tests I've done is on my own (embedded linux) machine, Basically it's just for my own use, I have warned you.

五月 14, 2008
» [tips] 如何讓你的ext2/ext3在神出鬼沒的地雷戰場上存活.

喜歡用自由軟體的人其實應該都滿常遇到地雷,
通常也練就了一身人間即時掃雷機的本事,
但有些時候實在是地雷太小顆 (但是倒炸的很大力),
又發生在想都想不到的地方, 要讓人不嗚呼哀哉也難.
就像開車時你不超車會有別人超車,
你不想用新版會有別人用新版,
軟體相容性的問題往往是會不請自來的.

lloyd大大今天跟我說了一個最近踩到地雷的故事,
他拿了一顆用ext2格式化過的400g硬碟,
拿到他弟弟灌了ext2 driver的windows上執行,
之前好一陣子都能讀取寫入, 操作上都沒問題,
最近卻怎麼格式化都不能用.
(在windows上會問你要不要重新格式化)
換了小一點的硬碟也不行. 最後他深入追查才發現es2fprogs這個最近更新的套件更新了mkfs.ext2這個程式, 預設的inode改變成256 bytes. 所以要用
mkfs.ext2 -I 128 讓預設的inode設成原本的128 bytes.

ok問題解決了, 聽起來只是windows ext2 driver跟e2fsprogs相容性的問題對不對?
但仔細一想問題可能就很大了, 今天你在debian lenny格式化了一顆ext2硬碟, 要放到穩定的重要server上(恰巧是debian sarge),卻不能讀了.
今天如果你沒有"恰巧"讀到這段,


E2fsprogs 1.40.5 (January 27, 2008)

Fix a potential overflow big in e2image if the device name is too long.

Mke2fs will now create new filesystems with 256 byte inodes and the ext_attr feature flag by default.
This allows for much better future compatibity with ext4 and speeds up extended attributes even on ext3 filesystems.

並把他放在心上的話, 你很可能就炸掉了.
(不過事實上可能就算你讀到這段也還是會被炸掉...)

此外/boot通常有人會用ext2而非格式化成xfs或raiser3什麼的(甚至連ext3都不用, 因為穩定),也免不了會踩到這個雷,
這裡"恰巧"就有個血淋淋的例子. (GRUB vs. the Inodes: Who Needs a Bootable System, Anyway? ) 喔, 只是不能開機而已嘛...orz

備註:
e2fsprogs version:
Gentoo-stable: 1.40.8
lenny (next debian stable): 1.40.8
etch (debian stable): 1.39+1.40

重要指令:

mkfs.ext2 -I 128 /dev/???
mkfs.ext3 -I 128 /dev/???

如果你還要向前相容性的話, 從現在開始別忘了mkfs.ext3時加上-I 128 , 否則... 就歡樂的炸吧... XD

感謝lloyd大大更正: 在debian etch (kernel 2.6.18) 上應該還是可以讀取256 bytes inode的格式, sarge是2.4 kernel可能就不行了. (根據mkfs.ext2的man page說法是2.4 kernel會沒辦法mount)

update: fix link.

四月 22, 2008
» [tips] poorman's uudecode

For those who cursed by ash and awk, welcome to 80's !

now you can send everything in ASCII -- hooray!!

#!/bin/sh
#
# uudecode.sh
#
# Author: Ximian, Inc.
#
# Modified: by timchen119 at http://timchen119.blogspot.com from Ximian go-gnome's GPL code
#
# Usage: uudecode.sh encodedfile > decodefile
#
# License: GPL
#
# Download: http://kalug.linux.org.tw/~tim/gpl/uudecode.sh
#
# Ref: http://ftp.cesnet.cz/pub/ximian-gnome/installers/go-gnome
#
# The Ximian Desktop Pre-Installer
#
# Comments to:
# distribution@ximian.com
#
# Copyright 2000-2001, Ximian, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
# USA.
#
#
# This script and its embedded programs are distributed with
# absolutely, positively NO WARRANTY WHATSOEVER, without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. The author and Ximian, Inc. take no responsibility for
# the consequences of running this script.
#
#

CACHEDIR=/tmp
_awk="awk"

# poor man's uudecode
_awkprog="$CACHEDIR/uudecode.awk"
# encoded file
_uudecode_in=$1

#awk-script
cat > ${_awkprog} <<EOF
function x(l, p) {
n="!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_";
return index(n,substr(l,p+1,1));
}
/^begin/ {}
/^[^be]/ {
len = x(\$0, 0);
for (i=1;len>0;i+=4) {
a=x(\$0,i);b=x(\$0,i+1);c=x(\$0,i+2);d=x(\$0,i+3);
printf("%c",a*4+b/16);
if (len>1) {
printf("%c",b*16+c/4);
if (len>2) {
printf("%c",c*64+d);
}
}
len-=3;
}
}
EOF
${_awk} -f ${_awkprog} < ${_uudecode_in}
rm -f ${_awkprog}


get uudecode.sh at here.

四月 15, 2008
» [tips] upgrading to gentoo 2008.0

Well just as usuals, you can upgrades to gentoo 2008.0 quickly. (beta?)

#eselect profile list
Available profile symlink targets:
[1] default-linux/x86/2006.1
[2] default-linux/x86/no-nptl
[3] default-linux/x86/2006.1/desktop
[4] default-linux/x86/2007.0
[5] default-linux/x86/2007.0/desktop
[6] hardened/x86/2.6
[7] selinux/2007.0/x86
[8] selinux/2007.0/x86/hardened
[9] default/linux/x86/2008.0
[10] default/linux/x86/2008.0/desktop *
[11] default/linux/x86/2008.0/developer
[12] default/linux/x86/2008.0/no-nptl
[13] default/linux/x86/2008.0/server
[14] hardened/linux/x86

For my case, just type 'eselect profile set 10'
and emerge world again.

I'm not migrating to OpenRC and baselayout2 yet, however I'm using KDE4.0.3 now, so I think I have enough un-stable-ness to worry about. ;0

二月 6, 2008
» Am I getting old or ....The lenny is coming this year???

根據 http://lwn.net/Articles/267722/的說法,

下一個版本的 debian (lenny) 將在今年9月release.

這可真是出乎我預期的快... etch... 不是去年四月才出的嗎?

**<小孩勿看>** 大便 難道真的落屎了嗎? **< / 小孩勿看>**

然後話說 /bin/sh link to dash 有了ubuntu帶頭衝之後 還真的debian就跟進了.

我的預言(詛咒)成真?! 看來lloyd大又要怨恨了 :P

(話說 難道再下版inittab也是難逃upstart之手了嗎??? ...有待下回茅房分解...)

這一行果然是很難混的啊.... XD

還有python 2.5.X 啥時要給我進default啊... 時間也該到了吧...

七月 22, 2007
» Xen Merged into Linux 2.6.23

http://kerneltrap.org/node/13917, 來自kernel trap的最新消息.

Xen是一個開放原始碼虛擬機監視器,
簡單的說, Xen可以讓一台機器同時跑好幾個作業系統,
而且模擬的速度接近原本cpu速度.
(目前就我所知執行速度是比User mode linux/KVM/kqemu都快的多,
跟qemu/virtualbox/vmware當然更不是同一個檔次的)

前陣子才剛在一台debian etch(dom0)上安裝netbsd跟freebsd的domU,
(DomU 其實就是Xen對guest OS的術語. 而Dom0就是host os.
netbsd是*bsd裡對xen支援最完善的,
目前3.1 release版本就直接支援, 既可以當host OS也可以當guest OS.
如果有人想安裝FreeBSD作guest OS的話, 我建議可以直接參考FreeBSD handbook,21.2.2.1 Setup Xen 3 on Linux dom0,有個不怎麼新的7-current(N個月前的)可以玩,有VT支援的cpu的話應該就比較簡單一點,
也因為我身邊沒半台可以支援VT的cpu(啥怪cpu都有就是沒intel core2duo XD),不然應該可以裝個windows當guest os)
但是說真的, 目前安裝xen還是有點麻煩,
不過我想xen merge進i386的linux之後,
xen應該會越來越得到關愛的眼神才對.
以後搞不好哪天apt-get install xen-netbsd-domU-image就裝好了. (希望啦 XD)

(ps: 差點忘了提最大的重點/亮點:
除去kernel部份 xen大部分的程式碼都是用python寫的!! XDXDXD)

七月 21, 2007
» [tip] django + oracle on debian linux.

目前SVN裡最新版本django已經由官方直接支援oracle資料庫,
也因此我也花了點時間測試一下django跟oracle的配合.
用起來覺得還不錯, 所以跟大家分享一下我的簡易安裝心得.

首先我是直接安裝oracle 10g 的XE版本,
在debian linux上安裝oracle 10g xe其實很簡單, (我是用etch)
因為oracle連apt套件庫都幫你準備好了.

只要在你的sources.list加上這行:


deb http://oss.oracle.com/debian/ unstable main non-free

並安裝:

#wget http://oss.oracle.com/el4/RPM-GPG-KEY-oracle -O- | sudo apt-key add -
#apt-get update;apt-get install orcale-xe-universal

最後跑個/etc/init.d/oracle-xe configure即可作oracle的安裝設定.
如果想測試安裝oracle xe的結果可以連上Web的8080port看管理介面:
http://127.0.0.1:8080/apex/

這個版本的oracle除了有內定最大只能使用4G資料庫大小,1G Memory
跟只會使用單顆CPU的限制外,
並沒有限制其他特別嚴苛的條件, 連商業使用都在可允許的範圍.
而因為這個限制其實很夠用,且高階一點的機器可以跑個vserver還是memcache.
然後你要多跑幾個database也不在限制範圍內,
所以其實我個人覺得就是oracle資料庫大放送, 隨便你用.
再來這個版本又比我印象中的oracle好安裝的太多.
還送你一個web管理介面(而且oracle似乎有心要繼續維護10g XE,我安裝時有根據官網的說明順便升級到了目前最新的apex版本3.0.1),可以說是物超所值.

再來就是安裝python的oracle支援套件cx_oracle,
因為官方網站只有提供windows跟fedora的binary套件, 我就直接抓source回來安裝,

export ORACLE_HOME='/usr/lib/oracle/xe/app/oracle/product/10.2.0/server'
export LD_LIBRARY_PATH=$ORACLE_HOME/lib

python setup.py install


接下來當然就是安裝django的最新svn版本,
這點看官方網站的Installing the development version說明應該就很清楚了,
http://www.djangoproject.com/documentation/install/

安裝完之後其實就跟其他資料庫沒什麼太大的差異了,
就可以寫個小程式測試一下了,
不過我上次測試的時候遇到了一點小問題,
就是我在syncdb時出現了一個
TypeError: descriptor 'upper' requires a 'str' object but received a 'unicode'
的錯誤訊息,
我推測應該是因為oracle這個branch剛好跟unicode這個branch同時進了svn trunk,
所以漏掉了這個,
可以暫時先依照我丟到http://code.djangoproject.com/ticket/4827的patch修正,
不過我想下一版release的django應該就會修正這個問題才對.

總算,oracle成為
django除了mysql,postgresql,sqlite之外的第四個直接支援的database.
也是第一個support的商業database.
雖然我目前用不大到(postgres還是不錯滴), 不過還是可喜可賀. :)

六月 16, 2007
» [rant] Ubuntu果然連這招也學會了...



我好害怕啊.... 咬我啊... :P

biggo.com.tw

A Django site.