2010年7月14日 星期三

packETH - ethernet packet generator



IEEE 802.1Q-in-Q VLAN Tag (QinQ)

The IEEE 802.1Q-in-Q VLAN Tag is purpose to expand the VLAN space by tagging the tagged packets, thus producing a "double-tagged" frame. The expanded VLAN space allows the service provider to provide certain services, such as Internet access on specific VLANs for specific customers, and yet still allows the service provider to provide other types of services for their other customers on other VLANs.

2010年7月5日 星期一

googlecl (Command line tools for the Google Data APIs)

GoogleCL brings Google services to the command line.
We currently support the following Google services:

  • Blogger
  • $ google blogger post --title "foo" "command line posting"
  • Calendar
  • $ google calendar add "Lunch with Jim at noon tomorrow"
  • Contacts
  • $ google contacts list name,email > contacts.csv
  • Docs
  • $ google docs edit --title "Shopping list"
  • Picasa
  • $ google picasa create --title "Cat Photos" ~/photos/cats/*.jpg
  • Youtube
  • $ google youtube post --category Education killer_robots.avi
Check out our ExampleScripts for many more examples of what you can do, or the SystemRequirements for simple install instructions.



LINK:http://www.pcadv.com.tw/posts/2904-googlecl

2010年7月1日 星期四

Subversion, Grep, Diff

習慣用 grep 來找 source code 當中的字串;也很習慣用 diff 來比較兩個 source tree 的差異。如:
grep -r STRING *
diff -ur DIR1 DIR2
這兩個指令很好用。但是遇到 Subversion 的 working copy 時,就會受到 .svn 目錄的干擾。所幸這兩個指令都提供排除非必要目錄的方法:
grep --exclude-dir=.svn -r STRING *
diff -x .svn -ur DIR1 DIR2

老實說,常會忘記這些參數,也常弄混。 因此建議在 .bashrc 當中加上以下設定,這樣以後不管是不是 working copy 都可以安心使用 grep -r 和 diff -r 了:
alias grep='grep --exclude-dir=.svn'
alias diff='diff -x .svn'

from Rupert's blog :http://softsmith.blogspot.com/2009/03/subversion-grep-diff.html

C/C++ Predefined Macros

寫程式經常會用到編譯器預先定義的巨集 (Predefined Macros),例如:__FILE__、__LINE__、__DATE__、__TIME__、__func__ 等。這些巨集有些是標準 C/C++ 語言所定義的,有些則是編譯器自行定義的。使用 GNU C/C++ 的人,可參考以下資料:
Predefined Macros (GNU C/C++)
這份資料所提到的 System-specific Predefined Macros 是指針對不同的系統平台 (arm、mips 等),編譯器所預先定義的特殊巨集。若想直接看看這些預先定義的巨集,可執行以下指令:
echo | gcc -dM -E - | sort

http://softsmith.blogspot.com/2009/07/cc-predefined-macros.html

colordiff



diff 使用很方便, 但是就是要花點眼睛去看差別.
ColorDiff 是隻 perl 的 script, 主要是把差異分不同顏色標示出來, 雖然只是加個顏色, 但是感覺起來還是好看多

http://colordiff.sourceforge.net/

2010年6月30日 星期三

ssh keygen 免輸入密碼

懶得打密碼, 以 key 做認證登錄.
步驟如下:
  • ssh-keygen -t rsa 或 ssh-keygen -d (dsa) => 產生出 id_rsa, id_rsa.pub
  • scp id_rsa.pub server_hostname:~/.ssh/
  • ssh server_hostname
  • cat .ssh/id_rsa.pub >> .ssh/authorized_keys 即可
  • 這樣子就可以 key 認證登入, 不需輸入密碼.
注意: gen 時會問 Enter passphrase (empty for no passphrase): # 此處直接 enter 跳過,下次才不會詢問password
簡單解說一下:
  • id_rsa: private key
  • id_rsa.pub: public key
將 public key(id_rsa.pub) 拷貝到遠端的電腦後, 加到那 user 的 .ssh/authorized_keys 中.
之後連線時, 就會用本機的 private key(id_rsa) 與遠端電腦的 public key(authorized_keys) 做認證, 確認完成就可以直接登入, 不需輸入帳號密碼, 而且也比較安全.

如果你想要瞭解密碼免登入的原理的話,請參考徹底瞭解 SSH 的免密碼登入

http://plog.longwin.com.tw/post/1/293

How to repair and clone disk with ddrescue

  ddrescue  is a tool that can be used to repair and clone disks on a  Linux system . This includes hard drives, partitions, DVD discs, flas...