2011年1月17日 星期一

Clear Bash History

大家知道history是放在~./bash_history
所以有些朋友就說
要清不是就直接去把這個檔砍掉就好了嗎

不是....

因為你正在使用的session裡頭
還有好多command是還沒存的 (eg. 要等你logout之後才會寫到bash_history)
所以如果想要通殺
有更簡單的指令

history -c

簡單就可以把session裡頭記得command
以及bash_history通通殺光
當然這個也是需要你做exit session之後才會apply

SVN Directory Lock

svn lock只針對檔案,而不能是目錄
這一點讓大家都有點頭痛
ugly and quickly的解法就是....硬下~
find . -type f -exec svn lock '{}' ';'

另一篇參考文章: SVN Directory Lock


更有效率去撈bash history

習慣用bash history的朋友
除了CTRL+R和基本的上下翻查
可以再加上下列這兩行到 ~/.inputrc
可以讓你找尋輸入過的指令更方便

"\e[A": history-search-backward
"\e[B": history-search-forward

簡單說就是可以縮小搜尋範圍
假設你之前輸入過
ls -l /etc
ls -l /bin
有了這個的設定,你可以在輸入ls -l之後按上下鍵
他會自動在/etc和/bin中讓你選擇
而不是總是從每個指令的開頭開始搜尋

2010年12月31日 星期五

取消剛剛的patch動作

有時候...會發生patch錯diff檔的事 :p
patch的雙向動作:

[Do It] patch -p0 < xxx.diff
[Undo] patch -p0 -R < xxx.diff

2010年12月14日 星期二

How to link pre-built kernel module

有些情況下
你會希望額外寫的kernel module會用到另一個pre-built好的ko
可是在原先build procedure裡頭
linux並不知道你事先pre-built好的module symbol
因此它在link之前會發現symbol undefine
WARNING: "abc_xxx_yyy_set" [drivers/net/abc/xxx.ko] undefined!

比較簡單的解決方法如下:
在linux-2.6.x/scripts/Makefile.modpost裡頭
加上
KBUILD_MODPOST_WARN := 1

這樣還是會出現原先那些WARNING
因為在這次的build procedure它的確還是不知道這幾個symbol在哪
但是它可以讓你繼續編過

詳細的部分可以參考linux文件目錄下面的Document/kbuild/kbuild.txt

165 KBUILD_MODPOST_WARN
166 --------------------------------------------------
167 KBUILD_MODPOST_WARN can be set to avoid errors in case of undefined
168 symbols in the final module linking stage. It changes such errors
169 into warnings.
170
171 KBUILD_MODPOST_NOFINAL
172 --------------------------------------------------
173 KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules.
174 This is solely useful to speed up test compiles.
175
176 KBUILD_EXTRA_SYMBOLS
177 --------------------------------------------------
178 For modules that use symbols from other modules.
179 See more details in modules.txt.


2010年12月1日 星期三

header file開頭的#ifndef也要留意

當程式碼越來越多
常常在加加減減和copy and paste的過程中
容易造成新copy的header file開頭的#ifndef忘了跟著改

這個情況常讓工作者抓不著頭緒
在開發工具上看著只是一些簡單的定義明明都有宣告
在相對應的程式碼中也有正確include需要的header path
可是compiler一直抱怨
error: `XXXXX' undeclared (first use in this function)

這個時候應該可以先檢查看看
是不是自己顧著快速copy and paste code卻忘了修改一些定義
常見的就是copy a new header
然後卻忘了改開頭的
#ifndef __MY_HEADER_H__
#define __MY_HEADER_H__
........
#endif /* __MY_HEADER_H__ */

2010年8月20日 星期五

Canon 鏡頭編號

1.第一個字母代表鏡頭的生產工廠︰U=Utsunomiya 日本宇都宮廠房

2.第二個字母代表生產年份︰
A 1986 J 1995 S 2004
B 1987 K 1996 T 2005
C 1988 L 1997 U 2006
D 1989 M 1998 V 2007
E 1990 N 1999 W 2008
F 1991 O 2000 X 2009
G 1992 P 2001 Y 2010
H 1993 Q 2002 Z 2011
I 1994 R 2003

3.後面4位數字:鏡頭生產月份和日期
如果鏡頭編號為UY0601:該鏡頭是日本宇都宮廠房2010年6月份生產的.

=================================================
生產工廠代號︰

O︰大分工廠
K︰大分杵築工廠
U︰宇都宮工廠
F︰福島工廠
T︰台灣工廠
S︰滋賀長 工廠
M︰宮崎

2010年8月6日 星期五

Compare two binary

有時候我們會需要比較兩個binary是否相同
可以用:

hexdump -C xxx.bin > file1
hexdump -C yyy.bin > file2
diff -y file1 file2 | more

2010年7月15日 星期四

remount的意義

Controlling and Querying Mounts

int mount (const char *special_file, const char *dir, const char *fstype, unsigned long int options, const void *data)

For a remount, dir specifies the mount point where the filesystem to be remounted is (and remains) mounted and special_file is ignored. Remounting a filesystem means changing the options that control operations on the filesystem while it is mounted. It does not mean unmounting and mounting again.

Mount, Unmount, Remount

2010年6月7日 星期一

如何修改Firefox Plug-in的語系

有時候找了幾個好用的Plug-in
明明以為是英文語系
但他安裝過程會自動幫你安裝成簡體中文
如果還是習慣看英文介面怎麼辦?

我的方法是,直接去改firefox的config =_=
  1. 在URL欄敲 about:config
  2. 進去後在Filter欄找general.useragent.locale
  3. 把原本的zh-TW改成en-US
  4. restart firefox