Wednesday, October 27, 2010

Two ZSH conventions for switchers from BASH

When starting to learn UNIX, I enjoyed with the well-designed Debian 3.1 and the bash completions coming with it. At that time the ZSH on Debian wasn't well configured for a newbie having no direction in dark.

Actually, the ZSH was set as a handy tool on recent releases of Debian-like system. For a longtime user of BASH, the default setting of backward-kill-word is confusing: it never stop with DASH, UNDERSCORE, and SLASH, etc. However, it's easy to modify the action through manipulate the $WORDCHARS variable which including all chars treated as alphabet in ZSH. For example,
export WORDCHARS=${WOARCHARS:s/-//}
exclude the dash sign from $OWRDCHARS, or you can just export the $WORDCHARS you want.

The second is ZSH can only auto-completed from first choice to the final by default. Adding bindkey '^[[Z' reverse-menu-complete to ~/.zshrc makes me not being afraid of pressing tab too fast.

References:
[1] stackoverflow.com
[2] zsh mailing list

Saturday, October 23, 2010

Fullscreen Emacs on Mac OS X from tarball

Emacs 23.2 in trunk doesn't support fullscreen on Mac OS X.

Japanese hacker typester do a patch for this.

Following is a quick step-by-step instruction to compile emacs 23.2 supporting fullscreen with this patch.


cd /tmp

wget http://ftp.twaren.net/Unix/GNU/gnu/emacs/emacs-23.2.tar.gz

wget http://github.com/downloads/typester/emacs/feature-fullscreen.patch

tar xzvf emacs-23.2.tar.gz

cd emacs-23.2

patch -p1 < /tmp/feature-fullscreen.patch

./configure --with-ns

make

sudo make install

mv nextstep/Emacs.app ~/Applications



Reference:
[1] Emacs Wiki
[2] sanityinc.com
[3] Citizen428

Thursday, August 5, 2010

practical python trick about static variables

It seems there is no syntax to declare static variables in Python. Fortunately, here is a useful trick to accomplish the goal.

Sunday, April 11, 2010

sudo on OpenLDAP

sudo 官方文件這篇 SOP (on Ubuntu) 算是寫得最實用的文件。

不過呢,還是很多廢話。

這兩篇文章的內容可以總結如下:

1. 準備好可以使用的 OpenLDAP 伺服器,這份文件 寫得比較詳盡。幫他加上 sudo.schema,並用 migration_sudo.pl 轉換並匯入 sudoers。

2. 裝好支援 LDAP 的 sudo。Debian-like System 是 sudo-ldap 這個套件。

3. /etc/nsswitch.conf 加上 sudoer: ldap

4. /etc/ldap/ldap.conf 或是 /etc/sudo-ldap.conf (在 Debian 是同一檔案) 加上 sudoers_base [SUDOers DN]

Saturday, March 27, 2010

Fun Weekend

忙了一整個禮拜,今天又唸了一整天書,於是乎覺得需要休息一下,想起開學時就想去吃看看的鼎泰豐,到現在還不知道在哪,拎起夾克,挾住一本書在腋下就出發來去探探路。

在 GMap 的帶路下,很快就到了信義路上的鼎泰豐




飽餐一頓之後決定輕鬆地走路回宿舍。

沿著金山南路往南走,走過熟悉又陌生的台師大門口。大三時因為擔心研究所筆試臨場反應不好,要是沒考上就得去盡忠報國,所以特別提前一年報了台大光電的筆試來試刀。走過那年的考場,兩年裡準備考試的酸甜苦辣倒也反芻了一遍。

轉了個彎走進師大路,比對著記憶裡的街角,今晚的師大夜市一般的人潮洶湧。不一樣的是路邊的那個小廣場,今晚圍了一群人。湊上去一看,是個有趣的大叔,看起來快到不惑之年,一把小提琴流暢的拉著,一支音響丟在旁邊為他伴奏,不時還擺個花式娛樂大家一下。

老實說看到的時候還滿驚訝的,台北街頭藝人不是沒有,但是大多是吉他或是歌唱表演。小提琴的表演呢,雖說最初就是以類似這樣的表演形式出現在大家面前,我一直以為現在只有法國或是義大利的街頭才看得到這種光景。就像是講起街頭探戈,人們總是想起阿根廷一樣。

師大路小提琴表演一 from Shelling Ford on Vimeo.



我到的時候已經晚了,一曲拉畢,大叔準備回家休息,旁邊有人喊起安可,大叔竟然用台語說:我又不是你阿伯,隨便你叫安可喔,好拉,我就再拉一首比較輕柔一點的,讓各位有好心情,慢慢回家睡個好覺。*XD*

師大路小提琴表演二 from Shelling Ford on Vimeo.



拉完這首大家也就散了,大叔在打包的時候,帶著一個五歲小孩的媽上去問他說:你還會不會在這裡表演。小鬼頭看起來非常想學琴,大叔還跟他拉咧了一下:你長這麼帥,學琴一定很吃香拉。我也是在路上看人家表演就跟著去學了。能不能賺錢是一回事,自己學得很高興比較重要,不過爸媽可能就要拉緊褲帶了。XD

到台北讀書也半年,大部分時候看到的台北,總在不經意的時候留露一點張愛玲式的荒涼,或是白先勇式的寂寞吧。相較起來,台南或許是繁華落盡了,但是敦厚的中國式文化,卻是深植人心的,雖然不若台北資源豐富,但台南給人的感覺是個有氣質的都市,好比美女不需濃妝豔抹,儀態自華。

不過今晚的表演讓我看到不一樣風貌的台北,或許只是一小部份人,但是還有人願意追尋藝術和文化最根本的那種感動,拿著一把小提琴,在街頭和觀眾同樂。這讓人覺得台北或許還是值得居住的城市吧。

Common Abbreviation in LDAP

DC: Domain Country
OU: Organization Unit
CN: Common Name
DN: Distinguish Name
RDN: relative distinguish name
LDIF: LDAP Interchange Format
DIT: Directory Information Tree

Monday, February 1, 2010

FDTD tips

When using BPML, external wall should be treated as PECs for simplicity no matter how many the maximum sigma is. The best way to do that is setting initial field value on external wall to be zero, and then don't update field value of any point on the wall.

That is to say, it could be written as



Saving a few of computing resource.

 

Friday, January 29, 2010

Injecting one module into another in Python

Here is a simple code snippet to do that. Saving it to an individual file and import it in other module to use it.



Using exec statement is also good, but need to pass globals() or locals() dictionary to the function executing exec statement.

Doing dirty things in Python is really not easy...:/

 

Wednesday, December 30, 2009

Assign initial value to a pointer

Today I suddenly got an idea. Most of time when we use pointer, we create a variable, and assign initial value to it, and then take its address become the value of a new pointer for succeeding use. But we create a redundant identifier here.

In fact, we could always create a fundamental type pointer and assign initial value to it through dereference operator like this snippet.



and no redundant variable here.

But when we define a simple struct like this.



We should assign initial value through arrow operator like third and fourth line in below snippet. Using brace to assign value as the same as first snippet is wrong syntax.



With a complex struct definition, this way increases many redundant code. Using brace to assignment initial value without creating redundant identifier could be done like this.



But I consider writing (*aPtr) = { 1, 2 }; may be the most intuitive way and it doesn't conflict with other syntax in C.

 

Friday, November 13, 2009

Library for Numerical Computing

Briefly summarize some numerical library here. It looks there are too many useful tools. Either for parallel computing or for matrix, numerical calculating and plotting.

PLOT:

MatPlotLib: it seems to be the most awesome plotting tool among this list

PGPlot: C library, also have binding in Perl, Python,Ruby

PLPlot: cross-platform plot library, also have binding in Perl

Scientific Python

MRPlot


PARALLEL:

MPI Ruby: MPI Ruby binding

PyMPI: MPI integrated Python interpreter

MPI for Python Python MPI binding

Simple Remote Python : SrPy

Parallel Python


CALCULATION:

Perl Data Language: difficult to be categorized. Including calculating, plotting together. include FFTW, PGPlot, PLPlot, and many data processing tool such as HDF. Awesome Environment!

MPMath: Multi-Precision math functions collection.

RNUM

NArray

LibFFTW, also have binding in Perl, Ruby

Ruby DCL

LAPACK

SciPy

NumPy

GNU Scientific Library: C library, also have bindings in Ruby named Ruby/GSL and Ruby-GSL. and Python

RSRuby: bridge between Ruby and R

ARTICLES:

Ruby for Science