2009-02-10

蚂蚁

在我看来,蚂蚁和狼一样,都是饥饿的动物。
今日春暖花开,阳光明媚,万物复苏。
一群蚂蚁,在家里地板上铺的毯子上,咬出了一个又一个具有对称和不对称之美的坑。

2009-02-09

韩食

今日春暖花开,阳光明媚,万物复苏。
傍晚时分,为了表示对带我去“家居仓储”购买床板的南先生的感谢,我邀请他来到昌西山下的希望韩国餐馆共进晚餐。
席间的辣猪肉,包菜炒牛肉,鱼饼,泡菜及免费汤充满了浓郁的朝鲜半岛风格。我们开怀畅食欲罢不能,最终还是挺着高傲的肚子踏上了回家的路。

2009-02-08

松鼠

在我看来,松鼠和乔治一样,是好奇的动物。
今日春暖花开,阳光明媚,万物复苏。一只对世界充满疑问的跃上窗台的松鼠和不经意间向窗外望去的我的目光发生了激烈碰撞。碰撞的结果是双方都不由得后退了好几步。
惊魂未定的我,像过去我们介绍过的“松鼠太婆”一样,抓了一把我最喜爱的沙炒花生掷向窗外。同样忐忑的松鼠,抓起一颗花生,犹若脱兔一般,向着一棵大树狂奔而去。

2009-02-06

美食

今日是LJ同学新婚大喜的日子。
晚上在他们家中的婚宴,简直可以用琳琅满目丰盛无比来形容。
席间大家觥筹交错,谈笑风生。
让我们共同祝愿这对新人生活温馨,百年好合!

2009-02-02

考试

今天参加了一次考试。考的不是我擅长的科目。
考卷上有两道题,规则是两道题都完美解答出来才有可能通过。考试的时间有两个小时。
第一道题目很简单,大概半个小时就做完了。
这时我有些放松,出去上了趟厕所,回来又喝了些饮料。
第二题想法也比较直接,可当动手写出解答时却发现有很多细节需要考虑。
当考试还有15分钟就要结束时,还在奋笔疾书的我开始有些紧张。
一刻钟的时间一眨眼就过去了。在考试结束时间到来的一瞬间,我感觉我距离一个完美的答案已是如此之近。
当把残缺的的考卷上交之时,我很沮丧。

2009-01-31

历险

今日(事实上已经是昨日了)晚间有一周一度的午夜室内足球活动。
在经历了极富锻炼意义的两个小时之后,在比赛就要临近尾声之时,我那刚刚将门前的足球险情解围后的左腿的迎面骨,在此后的一瞬间被一个意欲大力射门的冒失的小青年狠狠踢上。不知怎的,在那一刻,我在疼痛之余,脑海中却浮现了那许久没有音信的胖子的身影。

2009-01-30

对比

人们都说“蝉噪林愈静,鸟鸣山更幽”。
在多媒体横行网络的今日,我的台式电脑越发显现得举步维艰。

2009-01-28

大雪

都说“瑞雪兆丰年”。我觉得这话还是不错的。
不过连绵不断的大雪还是令屁股多次被摔得生疼的我有时感到战战兢兢。

2009-01-27

帐号

今日接到了鞥先生恩义打来的拜年电话,不知怎的他提到了感觉我好像有好几个电子邮件。刹那间,我的大脑展开了一阵暴风骤雨般的计数运算:我发现,就在此时此刻,我同时拥有5个普度大学各个组织院系的帐号!鞥先生所感觉到的邮件并不在其中。

一时间,我的思绪又回到了那一个人就持有50+个BBS帐号的大学时代。

冬天

用因扎吉的崇拜者也驰的话说“今年冬天太冷了!”

今日,在两周前收到了一个邀请的我,参加了在距拉斐特大约60英里以外的印第安纳小镇卡梅尔举行的“科技招聘会”。组织者建议与会的600至800人,每人携带25份个人简历以备所需。费劲千辛万苦驾驶着一丁的得意坐骑“水星”赶到会场的我,被告知本来要来的六家单位有三家取消了预约。愕然之下,我发现在场的三家,有一家是不招工的培训机构,另一家需求有丰富经验的美国公民,还有一家在交谈一分钟之后总算还是不太情愿的收下了我双手递上的简历。至此,时间已经过去了10分钟。

在招工会门口徘徊和作思考状许久的我,不由得沮丧地赶在鹅毛大雪飞降之前的一瞬间,风驰电掣一般,在一个多小时的车程之后,回到了西拉斐特的家。

2009-01-25

N蹲

今日又雪。恰逢西五区除夕之日。
在步行前往学校的路上,我贡献了鼠年的第N个屁蹲。
[caption id="attachment_642" align="alignleft" width="300" caption="Body print"]Body print[/caption]

新春

此时此刻,东八区已进入了新的一个农历年!
端坐案头的我抑制不住激动的心情,祝大家新春愉快,牛年大吉!

2009-01-19

练习

乘马丁路德金小日的东风,今日学校放假。本着消遣娱乐精神度过这一天的我,在这里进行破解密码的游戏活动。第一个和第二个挑战的解答,给人一种晦涩却又似曾相识的感觉。突然间我意识到,原来它们是GRE阅读中出现过的短文章!

免午

都说“世上没有免费的午餐”,但我觉得这句话比较精确的说法是“世上没有天天免费的午餐”。

如果你想建立自己的个人主页却苦于没有廉价、稳定的主机服务,也许Google sites是个不错的选择。但假如你热衷于HTML/CSS编码并且因此对Google sites的wiki平台对用户灵活性的提出的限制深为不满的话,Google App Engine将会是一个美好的解决方案。在享受个人主页编码灵活性的同时,你事实上还将Google App Engine用做了个人的内容传递网络,给你的用户——主页浏览者提供了快速高效的星级服务。

而这一切,根据Google目前的政策,都是免费的!当然,于此同时你的权利也被赋以了一些限制,譬如:你上传的任何文件都必须小于1M,一天允许65万次的最大访问量是和10G的最大下载流量。不过如果你仅仅是想寄居自己的个人主页的话,这一切都已经远远超过了你的需求。

假如你开始对此感兴趣并且决定摩拳擦掌决定牛刀小试一下的话,24ways.org上的这篇文章就是一个完美的“跟我学”教程。

以下就是一个在Google App Engine服务器上寄居的个人主页的例子:http://rmal.info/——配以$1买来的顶极域名,这一切都显得物有所值。

2009-01-15

节日

近日,受xkcd.com上一则漫画启发,我发现Linux下一个叫festival的文字语音转换软件软件在远程登录辅助之下,有着良好的进行恶作剧的用途。

例子:
~: echo "What's up, dude?" | festival --tts
(或者
Festival Speech Synthesis System 1.96:beta July 2004
Copyright (C) University of Edinburgh, 1996-2004. All rights reserved.
For details type `(festival_warranty)'
festival> (SayText "What's up, dude?")
)

冻伤

一向不大迷信的我今天开始相信确有“冻伤”这么一回事。

由于误掉了公车,我突发奇想,本着衣着不太单薄这一优势,决定从家走到学校。

20分钟的路程一下子就过去了。双手双脚和单脸都似乎失去直觉的我发现,出门前携带的一大杯水,已经被瓶壁内侧的厚厚一层坚冰紧紧包围。

2009-01-14

寒天

有些人喜欢寒冷的天气。

明日,拉斐特将迎来入冬以来的最低气温零下34度。想到这一点,我不禁有些兴奋。

2009-01-13

教程

今天浏览了一个介绍如何用git管理Google Code的教程,觉得很有帮助。

http://quirkygba.blogspot.com/2007/10/using-git-with-google-code-hosting.html
感谢发贴人Quirky并复制粘贴以记之。

Sunday, October 07, 2007



Using Git with Google Code Hosting


The open source hosting at Google Code uses Subversion as its source code management system. The advantages of Subversion are:

  • Easy to use - it is conceptually straight forward

  • Simple UI - commit, diff, ls and so on are all familiar

  • Multi platform clients - svn, TortoiseSVN, Eclipse plugins, etc


The main disadvantages of Subversion are:

  • Merging requires lots of user input

  • Online access required for committing or doing history diffs


These disadvantages can be overcome using git, and in particular git-svn. However, git undoes at least one of subversion's advantages as it is Linux only. There is a Windows port available, but this guide was written with a Linux user in mind and the Windows port is not as stable. Git may also be labelled "difficult to use" but it has a graphical interface that is pretty straight forward and its cross-branch merge options are much better than subversion.

So, here is my guide on using git with Google Code. This assumes two things: first that you are familiar with subversion and its usage, and second that you are not publishing your git repository online. Instead we will use the Google Code hosting service as a kind of back-up for the code base and use git-svn as a subversion client. That means that you will eventually push all your commits to the subversion repository. Despite what Linus said in his talk about SCM I trust Google to make better backups of my code than I do, especially after my hard drive failure.

Checking out the repository and making a change.

You will need to install the latest version of git. I'm using version 1.5.3 - remember to install the man pages too. After installing, we need to create our local repository. Unlike a svn checkout, which is a snapshot of the latest version in the repository, a git "checkout" contains the whole history of the project. This first step therefore takes a while. I'll refer to the repository as $SVNREP - as if I'd done this first:

export SVNREP=https://<project>.googlecode.com/svn
So to create the git repository with the history of our branches and tags you would use this line:
git-svn clone $SVNREP -T trunk -b branches -t tags
For my repository of 350+ commits this took about 10-15 minutes. This creates a directory "svn" (the last path-component of $SVNREP) with the subversion trunk checked out. It's worth noting that git uses master instead of trunk - by default git-svn will checkout your working copy of the master branch, which will probably be the svn trunk. However if the last subversion commit was to a different svn branch then master will point to that branch. To see all the branches available use:
$ git branch -a
* master
release-0.2.1
release-0.3
... etc ...
The * shows which branch you have checked out. (To get the coloured output use git config color.branch auto). Since git works locally, there is no separate workspace and repository - you "check out" to the current directory. This means that unlike subversion where you might have directories for "release-0.3" and "trunk", here you have just one and use:

$ git checkout <branch-name>
to change between them. Okay, so now we have our trunk checked out. This is roughly where we would be had we done this with svn:
svn co $SVNREP/trunk
The branches that map directly to subversion can't be changed, instead we have to make a local branch. For example:

git checkout -b local/release-0.3 release-0.3
This is roughly the equivalent of
svn co $SVNREP/branches/release-0.3
cd release-0.3
If we want to make changes, then just hack away on our files. For example, in one of my projects I would do this:
$ cd bunjalloo
$ vi arm9/Main.cpp
hackity hack..
$ git status
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
#
# modified: bunjalloo/arm9/Main.cpp
no changes added to commit (use "git add" and/or "git commit -a")
Note that the modified file is not relative to where we are (the current working directory) but relative to the top level of our repository. The output of git status is different to svn status. A bit more chatty. This is to remind you that if you commit now, nothing will be committed! For a svn user this sounds odd, but can actually be a really handy feature. You have to either manually add files to be committed, or use commit -a to commit all modified files. Manually adding can even add by hunk - use git add -i - so you can commit only parts of a changed file if you like. Anyway, to commit this change either:
git commit -a
or add the file to the index and commit:
git add arm9/Main.cpp
git commit
Additionally, I use git commit -v which shows the changes in your editor's buffer for the commit message. I used to do this with subversion:
svn diff | less
<open a new terminal>
svn commit
to view the changes of what I was committing, so git's -v flag is a nice bonus.

This commit is only to our local repository remember. In order to push the change into the Google Code svn repository the following step is needed:

git-svn dcommit
In order to see what is uncommitted to svn, use:
$ git-svn dcommit -n
Committing to https://quirkysoft.googlecode.com/svn/trunk ...
diff-tree c531c~1 c531c
... etc ...
The dcommit -n trick also tells us to which svn branch the current git branch pushes its changes. So if I change to a different branch:
$ git-svn dcommit -n
Committing to https://q.gc.com/svn/branches/bunjalloo-0.3-release ...
diff-tree 5ef0~1 5ef0

.. then I can see where it is going to commit the changes. This step is the same as svn commit but git-svn automatically commits to our Google Code repository using the message that we gave in the previous local git commit step.

If someone else makes a change to the svn repository, then to get these changes use:

git-svn rebase --all
Passing the --all flag will also pull any new branches. If you create the branch in git, then it would be completely local. So any changes made would be "lost" if you have a HD failure. One solution is to create the branch with svn, but handle the merges with git. My work flow is to create release branches from the trunk with subversion, then pull these into the git repository using the above command. That way my branches are backed up too. My git local branches are throw-away changes that either go into the trunk or get deleted after a few days.

So a new release would be:
svn cp $SVNREP/trunk $SVNREP/branches/release-0.1
git svn rebase --all
Note that "git-svn" and "git svn" are synonyms, it doesn't matter which we use. Sadly this step takes a while - at least as long as doing a complete "svn co" from the trunk, as the branch copy-from-svn does not appear to be cheap with git-svn. Regular, not-backed-up-on-googlecode branches in git are cheap, of course. Update: This has been fixed in newer (1.5.3.4) versions, now git-svn realises that branches are copies and it takes very little time to create them.

One word of warning - don't use git-merge between your local/release* and master branches. It screws up the mapping of the git branches to svn branches. Merging only local branches is fine, but my advice is don't use git-merge and instead cherry pick the changes across from branch to branch. It is far safer.

For example, if we have $SVNREP/trunk and $SVNREP/branches/release-0.1, then in git we have created our local working branches as follows:
$ git branch -a
* local/release-0.1
master
release-0.1
trunk
To check where we are commiting to subversion, use:

git svn dcommit -n
this will say $SVNREP/branches/release-0.1 at the moment. If we do git merge master then it merges all the changes from master into local/release-0.1 but it also changes our commit branch to $SVNREP/trunk, which is not what we want.

Note that while svn update will pull new changes to your checked out copy even if you have local modifications, git will not allow you to do this. You have to have a "clean tree" as git calls it. If you have local changes, a "dirty tree" in git speak, then you can stash them away, pull the new changes from the subversion repository, then apply your stashed changes again. So to simulate svn update with local changes, use the following:
git stash
git-svn rebase --all
git stash apply
Development and stable branches.

I mentioned cherry picking in the last section. This is where a change set is "picked" from one branch and merged into another. This is perfect for the usual development-stable branch model that most svn projects have. Normally all the changes go to /trunk, then when we make a release, we copy /trunk to /branches/release-NNN. Then carry on hacking on trunk. If someone finds a bug that is easy to fix (a one-liner, localised change, etc.) then we can make the change on the release branch knowing that it won't add all the instability that may exist on the trunk in its current state. Additionally, we merge the change onto the trunk so the next release has the fix too. With svn this is usually achieved as follows:
$ cd working-copy-of-trunk
$ svn merge -c 123 $SVNREP/branches/release-0.1 .
<patch changes from commit number 123 into working copy>
$ svn commit -m"Merged from r123 from branches/release-0.1 to trunk"
That is fine as long as all is well, but "svn merge" is little better than using "patch" - it handles adds and deletes, but if a file moves it just skips the change. Also, there is no way to see which changes have been merged from one branch to another - you have to do it manually or use the "svnmerge" script. Version 1.5 should fix this problem, but it won't fix the moved-file one, which is a common use case when refactoring code. And you need to have a network connection to perform any of this.

The git way is as follows. To see which changes have not been merged to the master (trunk) branch:

git cherry -v master
- sha1 <commit message>
- sha1 <commit message>
+ sha1 <commit message>
The '+' shows that the last commit has not been merged. '-' shows that it has. To merge the change across, use:

git cherry-pick <sha1>
If the file moved, that'll get picked up and the change applied to the new file name/location. One caveat is that git cherry may not pick up on applied patches to moved files, even though the original git cherry-pick patched the change correctly. Trying to cherry-pick again gives a conflict error and the old file name is re-added. Since this is a corner case, and is handled infinitely better than with subversion, I can live with it. EDIT: I couldn't live with it - so this script does pathless cherry checking.

Now, instead of all those command line options it would have been easier to use gitk. But explaining a GUI is tougher. This is what I usually do:

gitk --all
From here I choose the release branch - right click the branch, "Check out this branch". I make my change and test it. Assuming it works I'm ready to merge to the master branch. If I've added a test case, then first I'll cherry pick the test case across to the master branch - a couple of clicks in the GUI. Compile, test case fails. Then I cherry pick the fix across, compile, test case passes. Now I commit all that to subversion with git-svn dcommit and make a bug-fix release.

So summary time - equivalent svn/git commands

svn checkout $SVNREP/trunk ->
git-svn clone $SVNREP -T trunk -b branches -t tags
svn checkout $SVNREP/branches/release-0.3 ->
git checkout -b local/release-0.3 release-0.3
svn commit -> git commit -a, or git add then
git commit followed by git-svn dcommit
svn diff|less, svn commit -> git commit -v
svn merge -> git cherry-pick or use "gitk --all"
svn status -> git status
svn revert, --recursive -> git checkout , git checkout -f
svn diff -> git diff
svn update -> git-svn rebase --all (see also git stash)

There are many more options with git - some of which are less useful when using Google Code and subversion in this way - and I haven't tried to cover everything here. Hopefully everything you need to start using git as an improved svn client is covered and it will at least give you a good start when reading the documentation.

Additional links:
Git crash course for SVN users
Good article, assumes you have used SVK
Posted by Quirky at 4:51 PM

2009-01-11

再蹲

今天又是一个路上结冰的日子。

那多灾多难的屁股,又一次经受了磨炼。

2009-01-06

又蹲

几周前的屁蹲记忆正从我的脑海中渐渐淡去。

今日拉斐特普降冻雨。回家路上一直小心翼翼的我,终于还是不经天算,在距家门250米处的小路上失足,如同一根突然被拦腰截断的甘蔗一般,一屁股重重坐到地上。在跌倒的一瞬间,我的余光就着昏暗的路灯,瞥见一只目睹了全过程的野兔捂着因偷笑而变形的嘴幸灾乐祸地从我身后跃过,渐行渐远,直至最终消失在苍茫的夜色中。

此时此刻的我,屁股生疼,不禁有些沮丧。

2009-01-01

熊跳

今天,是格里高利历2009年的第一天。在这个飘着蒙蒙细雨的日子里,拥有一个参赛名额的尤里卡和理论上不完全具备参赛资格的我,在西雅图华盛顿湖畔的玛格努森公园,参加了"迎新春,立新愿,5公里越野跑暨北极熊跳水"活动。

在热烈而又隆重的气氛中,随着熙熙攘攘的人群,我们跋山涉水,有如闲庭信步一般,气喘吁吁的完成了5000米的征程。在接近终点线的时候,我摒住呼吸,纵身一跃,形同北极熊一样,跳入了冰冷刺骨的华盛顿湖水之中,并采用蛙泳的姿势猛力划水一番。紧接着双腿似乎失去知觉的我浮出水面爬上岸来,完成了剩下的20米赛程。至此,"迎新春,立新愿,5公里越野跑暨北极熊跳水"活动在我们这里得到了胜利结束。

此时此刻,我的心是滚烫的,我的身上似乎也是火热的!

[caption id="attachment_611" align="alignleft" width="300" caption="Resolution Run 5K & Polar Bear Dive "]Resolution Run 5K & Polar Bear Dive [/caption]