2011年7月1日

在script中移除變數中的換行符號

寫bash script時候, 用grep或awk取出來的值, 裡面還包含了一些non-printable的字; 作字串比對時, 就會一直出錯. 這時可以用 tr 這個指令移除看不到的字(如換行符號):

# echo $VAR_WITH_NON_PRINT | tr -d '/r/n'
這樣就可以移除換行符號
還有更多種選擇:
       \NNN   character with octal value NNN (1 to 3 octal digits)

       \\     backslash

       \a     audible BEL

       \b     backspace

       \f     form feed

       \n     new line

       \r     return

       \t     horizontal tab

       \v     vertical tab

       CHAR1-CHAR2
              all characters from CHAR1 to CHAR2 in ascending order

       [CHAR*]
              in SET2, copies of CHAR until length of SET1

       [CHAR*REPEAT]
              REPEAT copies of CHAR, REPEAT octal if starting with 0

       [:alnum:]
              all letters and digits

       [:alpha:]
              all letters

       [:blank:]
              all horizontal whitespace

       [:cntrl:]
              all control characters

       [:digit:]
              all digits

       [:graph:]
              all printable characters, not including space

       [:lower:]
              all lower case letters

       [:print:]
              all printable characters, including space

       [:punct:]
              all punctuation characters

       [:space:]
              all horizontal or vertical whitespace

       [:upper:]
              all upper case letters

       [:xdigit:]
              all hexadecimal digits

       [=CHAR=]
              all characters which are equivalent to CHAR

2011年5月24日

python on Centos 5

最近幫自己的舊筆電(x24)灌回了Centos 5, 其python還停留在2.4.
為了要能夠用app engine, python要2.5以上.
最後使用的方法是到python.org下載2.7 source code,
confgure
make
make altinstall
就可以並存了, 預設安裝的目錄會跟原本系統內的不同, 於/usr/local/bin/python2.7
接下來需要利用alternatives指令來修改預設的python執行檔-->/usr/bin/python
格式: alternatives  [options]  --install  link  name  path  priority
將原本的2.4和新的2.7都建入alternatives的資料庫中
alternatives --install /usr/bin/python python /usr/bin/python2.4 200
alternatives --install /usr/bin/python python /usr/local/bin/python2.7 400
由於數字大者優先權高, 所以python2.7會被選取囉

2011年5月23日

permisson for sshfs

sshfs, 只要對方的電腦有sshd, 就可以直接將目錄直接mount上來,不像nfs還要做其它設定。
安裝完fuse套件後,記得到/etc/group裡的fuse群組加入自己的帳號, 這樣才可以用自已的帳號, 否則會出現錯誤訊息:fuse: failed to exec fusermount: Permission denied
改完後必需要重新登入才會生效。 

2011年5月6日

Add Apture Highlights to Blogger

Edit your blogger html and add the following javascript to the end of BODY part:
<script id="aptureScript">
(function (){var a=document.createElement("script");a.defer="true";
a.src="http://www.apture.com/js/apture.js?siteToken=vsJttrn";
document.getElementsByTagName("head")[0].appendChild(a);})();
</script> 
 

2011年5月3日

change msys rxvt default font

Edit the msys.bat, find the line calling rxvt:
start %WD%rxvt -backspacekey -sl 2500 -fg %FGCOLOR% -bg %BGCOLOR% -sr -fn Courier-12 -tn msys -geometry 80x25 -e /bin/sh --login -i
Change the default font Courier to other font name.
start %WD%rxvt -backspacekey -sl 2500 -fg %FGCOLOR% -bg %BGCOLOR% -sr -fn Consolas-14 -tn msys -geometry 80x25 -e /bin/bash --login -i

2011年4月27日

解決chrome無法顯示favcon的問題

原本我在網路上查到的語法是這樣寫的:
<link href="ImageShackURL" rel="shortcut icon"/>
後來在網路上面查到原來chrome會因為這種寫法而乎略掉第二個參數, 所以應該要反過來寫:
<link rel="shortcut icon" href="ImageShackURL"/>
參考網址: http://www.google.com.tw/support/forum/p/Chrome/thread?tid=40574c8dcfdfdd33&hl=en&fid=40574c8dcfdfdd3300046ba146ea3741&hltp=2

coap-client 4.3.0 Windows build

coap-client  is a  wget -like tool to generate simple requests for retrieval and modification of resources on a remote server.  Got the sour...