Month: January 2012

龙年快乐

Happy Chinese New Year!

今天这边下雪了,到这里之后见到的第一场雪。上午出去走了走,胡乱的拍了几张照片。刚过来这边,每每看到有人在给动物喂食就感觉很有爱,尤其是在这样的大雪天。

IMG_0017

IMG_0016

IMG_0014

IMG_0011

IMG_0013

IMG_0012

就要到龙年了,希望朋友们平安快乐,希望家里一切都好。

vimGdb

又回到了用VIM的状态。刚装起来了vimGdb,vim的各种gdb插件还是这个比较顺手。唯一的不足之处是vimGdb需要给源码打一个Patch。

vim最新的稳定版本是7.3,对应的vimGdb在这里 larrupingpig/vimgdb-for-vim7.3

下面的说明比较清楚了,需要注意的是vim的源码必须是 vim-7.3.tar.bz2 这个包,如果是从最新的库里checkout的代码会和patch不匹配。

比如在~/Temp下有

vim-7.3.tar.bz2 vimgdb-for-vim7.3.tar.gz

解压

$tar xvf ./vim-7.3.tar.bz2
$tar xvf ./vimgdb-for-vim7.3.tar.gz

打patch

$patch -p0 < ./vimgdb-for-vim7.3/vim73.patch

编译

$cd ./vim73
$./configure --enable-gdb
$make
$sudo make install

把./vimgdb-for-vim7.3/vimgdb_runtime/里面的文件拷贝到~/.vim/下
推荐使用Pathogen管理plugin,会比较方便一点

在~/.vimrc里增加一句

source ~/.vim/macros/gdb_mappings.vim

然后就OK了。编译代码的时候用-gstabs+让gcc把调试的信息加上去。
具体请参看vimGBD的文档。这里也行:gdb.txt

P.S.
大神们真无聊啊,居然把vim移植到iOS上去了...Vim iOS

Check out your svn copy through ssh without those annoying password prompts

This is an instruction I wrote to help people in our lab to access codebase on our server. I have removed all the specific information.

Since setting up something on Windows is always such a challenging work, help this one helps.

The background is that, on the server side, you are using ssh to protect your codebase. Instead of setting up another group of users and passwords for the svn repository separately, the server asks user for one’s Windows credential. So, on the client side, user are using commands in the form of “svn co svn+ssh://path/to/repository” to checkout a copy. Please note that the scheme for the url of repository is “svn+ssh” instead of “svn”. It tells the svn to connect to the server by using ssh then checkout the source code.

I may post a tutorial on how to setup the server ON WINDOWS in the future.

Please follow this instruction to check out a sample repository.

1. Install SVN Client “TortoiseSVN”
Open http://tortoisesvn.net/downloads.html in your web-browser, choose “TortoiseSVN 64-Bit”/”TortoiseSVN 32-Bit” to download the installation program. Open it and keep clicking “next” to finish the installation.

2. Have a try
Open your windows explorer, get in a folder such as “C:\Repo”, right click on anywhere blank, choose “SVN Checkout…”.
The URL of repository is “svn+ssh://path/to/your/repository”.
Click “Ok”.
You will be prompted for your username and password for THREE times then you should get the files.

3. I can’t stand this!
Yes it’s quite annoying to repeat filling your credential, remove the folder and we will try to get rid of this.

4. Utilities
If you are on an unix-based machine, google for “ssh key” you get A LOT OF tutorials on this topic, for example http://linuxproblem.org/art_9.html.
If you are on WINDOWS, open this PuTTY Download Page http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
You will need PuTTY.exe, Pageant.exe and PuTTYgen.exe

5. Generate Key Pairs
Launch PUTTY.exe, fill in the Host Name as “Your.Repository.Host.Name”, click “Open”.
Input your credential, note that when you type in your password there will be “no response”, it is ok, just go ahead.
You should meet our Hippo now.
Type in “ssh-keygen.exe”
Keep hitting the “Enter” button.
Type in “cd ~/.ssh”
Type in “mv id_rsa.pub authorized_keys”
Type in “ls” and you should see this:
“authorized_keys id_rsa”
id_rsa is your private key.
Type in “cat id_rsa”
Scroll up and highlight/select lines from “—–BEGIN RSA PRIVATE KEY—–” to “—–END RSA PRIVATE KEY—–“, including these two lines.
Hit “Ctrl+C” to copy them.

6. Make your private key file
Create a new text file in certain folder, e.g. “My Documents”, “Ctrl+V” to paste lines in this file, save it in a name e.g. “ssh_key.txt”.
Launch PUTTYgen.exe, choose “load”, in the dialog change the extension to “All Files” and find your “ssh_key.txt”, click “open”.
Click “Ok” when anything pop out.
Choose “Save Private Key”, get a name for it such as “ssh_key.ppk” and click “save”.

7. Come on, we are almost there
Launch Pageant.exe, nothing happen? Right, it hides in the task bar. Right click on its icon and choose “Add Key”.
Find your “ssh_key.ppk” and choose “Open”.

8. Have another try
Ok, Repeat Step 2, you should be able to get all the files without entering any credential.
Cheers!