跳到主要內容

發表文章

目前顯示的是 2009的文章

將patch完後的code還原回來

patch -p0 -R < path/ your . patch

Windows 系統工具大集合: Sysinternals

Sysinternals 公用程式索引 做這些工具的公司後來被微軟買走了, 應該是做的不錯 目前有在用的有Process Explorer 打包下載 十大熱門下載 Process Explorer Autoruns Process Monitor PsTools PageDefrag RootkitRevealer TcpView BgInfo BlueScreen NewSID

Get file's size in Hex

更新firmware前, 如果遇到比較陽春的bootloader, 有的還要自己手動輸入檔案大小 這時可以先將做出來的大小先算出, 再以script代入就可以了 ls -l FileName | awk '{print $5} ' |  echo " ibase = 10; obase = 16;$$" | bc

在Linux下用native2ascii轉成簡中unicode的方式

在JDK安裝目錄中BIN底下有一個轉碼工具native2ascii.exe 資源文件需要進行Unicode編碼,方法是使用這個jdk提供的工具來轉換native2ascii ascii到unicode方式: native2ascii 原檔名 轉換檔名 因為我用的是繁體中文的環境, 首先, 必需將自己的locale換成zh_CN export LC_ALL=zh_CN.utf8 然後再執行gnome-editor將翻譯成簡中的文字貼上 最後再執行native2ascii即可 範例 aaa.txt文件內容包括:中國 native2ascii aaa.txt bbb.txt 執行後變為: \u4e2d\u56fd aaa.txt文件內容包括: \u4e2d\u56fd native2ascii -reverse aaa.txt bbb.txt 執行後變為:中國

檢查snmp mib 的文法格式工具 -- smilint

SNMP mib 的格式訂義在RFC 1155和2578, 目前有SMIv1和SMIv2. 如果想檢查自己寫的mib格式是否正確, 可以用smilint來檢查. Install: yum install libsmi (libsm-devel) Reference: http://en.wikipedia.org/wiki/Management_information_base  

根據MAC Address找網卡廠牌

網卡前六個值稱為OUI, IEEE有提供網頁供大家察詢 http://standards.ieee.org/regauth/oui/index.shtml 比方說 000E2E開頭的為Edimax這家公司的 00-0E-2E (hex) Edimax Technology Co., Ltd. 000E2E (base 16) Edimax Technology Co., Ltd.    3, Wu-Chuan 3rd Road, Wu-Ku Industrial Park, Taipei Hsien, 248 TAIWAN, REPUBLIC OF CHINA

自訂vim指令縮寫

每次要打printf( ... 很累, 可以利用vim 簡寫輸入的功能 :ab 縮寫 全部的字串 For example: :ab pr printf("%s %n\n", __func__, __LINE__); 然後在insert mode輸入pr 就會自動換成後面的字串了

自動重開機並記錄重開次數的Script

為了要測試重開機幾次會失敗, 寫了一個script來記算. 因為busybox的shell只提供了有限的功能, 不能像bash一樣宣告整數變數, 所以count的處理算比較麻煩. #!/bin/sh FILE = /etc/count timeout = 2 if [ ! -f $FILE ] ; then echo 0 > $FILE fi count = `cat $FILE ` #echo $count echo $ ( ( $count+ 1 ) ) > $FILE echo "================================================" echo "Success reboot times :" `cat $FILE ` echo "Ctrl+C to break" echo "================================================" # setup timeout old_tty_settings = `stty -g ` stty -icanon min 0 time ${timeout} 0 eval read $input stty " $old_tty_settings " echo "reboot" reboot

Initrd

現在的Fedora都有用到initrd來開機, 如果想研究看看裡面的機制, 可以將之解開來看看. cpio format mkdir temp ; cd temp cp /boot/initrd-2.6.14.2.img initrd-2.6.14.2.img.gz gunzip initrd-2.6.14.2.img.gz cpio -i --make-directories < initrd-2.6.14.2.img non-cpio format mkdir temp ; cd temp cp /boot/initrd.img.gz . gunzip initrd.img.gz mount -t ext -o loop initrd.img /mnt/initrd ls -la /mnt/initrd Tools mkinitrd; packagename -- mkinitrd References: http://www-128.ibm.com/developerworks/linux/library/l-initrd.html

Linux 下看硬體規格的工具

lshw is a small tool to extract detailed information on the hardware configuration of the machine. yum install -y lshw 有GUI版 yum install -y lshw-gui 其它相關工具: lspci, lsusb, and lshal