Archive for the ‘Tips’ Category

find then xargs

I like the find + xargs combinaiton so much.

On Mac OS X:

1. sed in several files:

find . -name filename-regex | xargs -I {} sed -i ” ‘s|abc|xyz|’ {}

2. remove several files:

find . -name filename-regex | xargs -I {} rm -rf {}

Read Full Post »

Typical Usage of Git

# get the sources for the first time
git clone git_repo_url

# check out branch
git checkout master ( or your own branch)

# write code
git commit -a -m “try best to make your comments meaningful”

# pull latest changes to avoid massup due to auto merge
git pull –rebase

# Post code review to the reviewboard
post-review –guess-summary –guess-description
post-review –guess-summary –guess-description –revision-range HEAD~3:HEAD

# If code change needed per review comments

## if only commit message change needed
git commit –amend

## if both code and commit message change needed
git reset –soft HEAD~1
modify code
git add /path/to/new_modified_files
git commit -c ORIG_HEAD

# Post another review based on the previous one
post-review -r the_previous_review_num

# Ready to push
git pull –rebase (merge with changes made by others)
git push

Read Full Post »

虚拟机(比如VMWare)的系统时钟会比正常时钟跑得快, 需要同步成标准时间, 否则有些要检查timeout的函数不能正常工作, 比如检查cookie, session是否失效.



1.  sudo vi /etc/crontab

2.  添加下面加粗的行, 成为一个每分钟执行的cron job.

# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
*  * * * * root hwclock –hctosys 2>/dev/null >/dev/null

3.  重启crontab :  sudo service crond restart

Read Full Post »


First install Ruby 1.8.6 or above, then:

gem install rails

gem install mongrel

gem install mongrel_cluster
gem install mongrel_service
cd D:\tools\redmine-0.9.4   (enter home directory of the Rails app)
mongrel_rails cluster::configure -e production -p 3000 -N 3
mongrel_rails service::install -N Redmine -c D:\tools\redmine-0.9.4 -p 3000 -e production
sc config Redmine start= auto
net start Redmine

Read Full Post »

1. Enter into CLI mode thru Terminal or ConnectBot, change to root user, and edit the wpa_supplicant.conf file.

# cd /data/misc/wifi
# vi wpa_supplicant.conf

2. Fill wpa_supplicant.conf with the following content.

  group=CCMP TKIP

3. Then restart the phone to let it take effect.


I learned this from this blog http://huang.yunsong.net/2009/android-wifi-leap.html#comment-1725

Read Full Post »