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

2010年6月4日 星期五

Catching Integer Overflows in C

Integer Overflows are arithmetic errors. Integers have finite ranges in computers, for example a 32-bit unsigned integer goes from 0 to 0xffffffff. If you add one to 0xffffffff, you get 0 again.

Since the addition operation in the CPU is agnostic to whether the integer is signed or unsigned, the same goes for signed integers. For 32-bit signed integers, the minimum value is 0x80000000 (-2147483648) and the maximum value is 0x7fffffff (2147483647). Note that there is no value than can hold 2147483648, so if you negate (int)0x80000000, you get (int)0x80000000 again. That is something to look out for, because it means abs() returns a negative value when fed -2147483648.

原文出處: http://www.fefe.de/intof.html


2010年6月3日 星期四

拍出不再淺景深的食物

拉高ISO + 縮光圈(F4~F6.3)
調成手動模式, 快門速度設在安全快門附近

如果食物太大又不想拍得後方糊掉
相機拿高一點拍俯角試看看 <-- 從側邊拍因為焦平面問題通常都會部分糊

另外的重點是拍時不要離主體太近拍
回去再裁圖處理即可

2010年6月1日 星期二

[HowTo] SVN rollback

網路上看到一段話寫著:

SVN 的設計原則就是鼓勵程序員瘋狂 commit,不用怕 commit 有 bug 的程式碼,SVN 記錄整個專案的變動歷程,而不是單一程式碼的變動,所以他的版次是整個專案在計算的。因此在版次之間的切換很方便,今天改錯了,那就回到先前沒錯的版本就 好。也就是因為這樣,他的 check-in check-out 速度飛快無比。為什麼要瘋狂 commit 呢,

Merge early, Merge often, Merge always…

寫了 code 就 commit,改得越少,Merge 越自動,比兩個人坐在隔壁寫程式還要寫得快。而且可以一起改同一支程式,而不用 Lock 程式。這是 SVN 的基本設計理念。如果要把某個時間點的程式碼狀態記下來,那就做一個標註(Tag) 在某個版號上就可以了。

===================

回到主題,話雖如此,但應該不少朋友沒親自做過version rollback的動作
這邊分享一下,下回可以試試看:

假設新的版本是888,舊的版本是777
可以下 svn merge -r 888:777
就可以rollback到777版本了

有人或許會聯想到,這和svn up -r 777不同的是???

用merge的方式,會連888版本的log history都保留,因為你想做的是commit之後會是889之類
但如果你是直接update成777版本,這個時候你的local copy是777,且log history也是777
這個時候即使你想要commit,server應該也會報錯的喔~

常見的Coding Style

下面列出一些網路上的coding style,有興趣可以參考一下:

Linux Coding Style

Android Code Style Guildlines

C++ Programming/Code/Style Conventions

Mozilla Coding Style

Code Conventions for the Java Programming Language

Object Pascal Style Guide


要記得errno的存在!!

不知道是沒睡醒還是在恍神
compile總是出現warning
直說我的func_xxx不是prototype

突然看到密密麻麻的func param當中出現了一個很閃的字眼 errno
OMG....趕快改掉吧 XD

2010年5月27日 星期四

165反詐騙網站的daily report

不想接某些電話的時候
可以順便search一下是不是已經出現在報表裡頭了

話說這幾天常常被同一支號碼煩
查了一下,竟然是最近被檢舉次數第一名的門號,還真有點準.....

報表網址:http://net165.erufa.com/outtext.php

Roomba Life

這篇主要紀錄著Roomba相關的網路資訊


2010年5月26日 星期三

Test harness/Test stubs/Test instrumentation的區別

* Test harness " a contrived code that executes the test cases which are invented to test the unit under test

* Test stubs " optional functions (or macros) created to replace functions (or macros) called from the unit under test (UUT) to abstract from the actual behaviors of the real functions.

* Test instrumentation " code plugged into the UUT to expose its behaviors normally not visible from the outside and to output "documentable" traces of execution.

參考文章:http://www.embedded.com/design/201805598

=================================================

In software testing, a test harness or automated test framework is a collection of software and test data configured to test a program unit by running it under varying conditions and monitoring its behavior and outputs.

It has two main parts: the Test execution engine and the Test script repository.


DUT, UUT, SUT的區別

DUT: device under test
UUT: unit under test
SUT: system under test

Device under test (DUT), also known as unit under test (UUT), is a term commonly used to refer to a manufactured product undergoing testing.

System under test (SUT) refers to a system that is being tested for correct operation. The term is used mostly in software testing. The term SUT means also a stage of maturity of the software, because a system test is the successor of integration test in the testing cycle.

2010年5月20日 星期四

Word也可以用滑鼠放大縮小頁面比例

剛剛無意中發現
慣用了MAC的滑鼠放大縮小功能
在Word上也可以
很簡單,按著CTRL再滾動滑鼠滾輪就可以了

一個方向是比例放大
另一個方向是縮小,到後來是變成一個螢幕show出多張page
對我來說還蠻方便的