2011/08/23

Git get diff file list and diff content from some branch

  1. BRANCH_NAME='dev'
  2. SOURCE_DIR='/home/me/src'
  3. EXPORT_TO='/home/me/out'
  4.  
  5. cd $SOURCE_DIR
  6. git diff --name-only $BRANCH_NAME > $EXPORT_TO/changes.txt
  7. git diff $BRANCH_NAME > $EXPORT_TO/changes.diff
  8.  

2011/08/12

Unix like shell - find_keywords

  1. #!/bin/sh
  2. if [ "xx$2" != "xx" ] && [ -e $2 ]; then
  3.     echo finding $1 in $2
  4.     if [ "xx$WINDIR" != "xx" ]; then
  5.         grep -lr $1 $2 | sed 's~/~\\~g' | sed 's~^\\\(\w\)\\~\U\1:\\~g'
  6.     else
  7.         grep -lr $1 $2
  8.     fi
  9. else
  10.     echo first param must be search string
  11.     echo second param must be full path
  12. fi

2011/08/10

CodeBlocks 中文化

下載mo檔:
codeblocks translation page
www.badongo.com - Click Here to Download codeblocks zh_TW
www.u-file.net - Click Here to Download codeblocks zh_TW

然後建一個目錄 C:\Program Files\CodeBlocks\share\CodeBlocks\locale\zh_TW
其中 C:\Program Files\CodeBlocks 是安裝路徑
然後把mo檔放到裏面去

Settings -> Environment -> View -> Internationalization
勾起來 -> 選 Chinese
然後重開CodeBlocks

搞定...

BTW...中文化以後, syntex highlight好像消失了...
所以還是把勾勾拿掉好了....sigh.....

2011/07/15

Compare a Copy of a Project

Usage:
compare-projects /home/me/project/ /home/me/old/project/ | grep -v OK > /home/me/compare_result 2>&1
Source: compare-projects
  1. #!/usr/bin/sh
  2.  
  3. #
  4. # settings
  5. #
  6.  
  7. md5=~/bin/md5files
  8.  
  9. #
  10. # inputs
  11. # src: main project
  12. # dst: another project
  13. #
  14.  
  15. src=$1
  16. dst=$2
  17.  
  18. #
  19. # limit file size smaller than 1024k (pass to find)
  20. # md5 all files, and then replace the path to destination
  21. # finally compare the md5 "use md5sum -c"
  22. #
  23.  
  24. $md5 $src -size -1024k | sed "s!${src}!${dst}!g" | md5sum -c 2>&1

Get All Files Recursively and Get MD5

  1. #!/usr/bin/sh
  2.  
  3. #
  4. # find all files recursively, and enum them to get md5sum
  5. # args: pass all to find
  6. #
  7.  
  8. for f in $(find $@ -type f);
  9. do
  10.     md5sum $f
  11. done