J Red Note
Friday, April 8, 2011
Tuesday, January 4, 2011
GIT Tips
git是个好同志。
用了这么久的svn,当自己有对服务器端代码的生杀大权时,一切看似没什么问题,慢一点就慢一点吧,需要联网就连吧。最近在做一个open source的项目时,问题来了:像我这样的新手,管理员是万万不会给我commit的权限让我糟蹋源代码的,即使svn有回滚的措施,我一个新手滚回去,千千万万个新手站起来,这管理员必定悲剧。
git确是为了这个而存在的。git是着重于分布式的开发环境的。在这样的环境里,如果你需要回滚一些操作,但是你又没法连接代码服务器的时候,git就很轻车熟路了,因为git把你本地的这个拷贝,同样认定为一个代码服务器。也就是说,如果svn是大教堂式的开发风格(有监工的,大家伙需要听他的,和他打报告的那种),git更像是集市的开发风格(大家伙各干各的,你愿意汇总或者不愿意,由你定)。
注意,我没说git比svn好。svn也是个好同志,但是大家各有所长,互相弥补,一团和气,工作才能搞上去嘛。这确是我最近的心得,所以贴到这里,留作日后参考。关于单独使用git作为版本控制工具的,日后再聊,或者从网上搜一下就有了。
我的开发情况是:代码在googlecode;我没有commit权限;需要和开发人员面对面交流;我有多个工作环境(台式ubuntu和笔记本mac)。
1、Check out from svn server
这第一步是从svn服务器上取代码回来。为了让我这边的local code也成为一个代码服务器,所有的改动都会被当下来。用下面的命令:
git svn clone -s http://your.code.server
因为所有改动历史都需要下载,这个需要运行一段时间。完毕之后,最好用下面这一步把svn服务器忽略的改动也拷贝到本地:
git svn show-ignore > .gitignore
对于Java,我一般排除的包括:build文件夹,class文件以及隐藏文件。所以我会确认.gitignore文件中有如下几行:
# Ignore Java build files and folders
build/
*.class
.*
2、在本机的代码拷贝上建立新的分枝。这个是为了便于以后区分自己的改动和svn服务器端的改动。
git checkout -b labase
这样就建立了名为labase的分枝,我就可以在这个分枝上胡作非为了~
3、获取svn端的更新
我这新手往往起步慢,还在熟悉代码机构的功夫,svn服务器端已经有一堆的改动了。用下面的命令,可以将svn服务器的改动下载到本机上,然后自己的改动会被重新添加到本地拷贝上:
git svn rebase
4、在另外一个工作环境使用自己的代码。在自己的笔记本上建立好本地拷贝,学习一段时间以后,我需要把这些东西都弄到台式机上,毕竟两个大显示器比一个小屏幕爽啊!问题是怎么样把自己已有的改动也弄过来,同时新的代码也能由git来控制管理。我觉得这是git的长处了。在台式机上重复1~3,然后在笔记本上,生成已有的改动的补丁:
git format-patch -2
这里我把最近两个commit打成了两个补丁,你也可以将从你迁出代码以后所有的改动都打在一个补丁里,唯一的改动就是把-2改成那个最早的版本。具体怎么弄,看文档吧!
把这些补丁发到台式机上(推荐使用Dropbox一类的网络存贮来共享),首先检查补丁和代码有没有冲突:
git apply --check /path/to/your/patch
如果有冲突,解决了冲突以后,给代码打上补丁:
git am --signoff < /path/to/your/patch
这里signoff会把补丁所包含的commits的作者信息(我在我的笔记本上)加到台式机的代码库中。
5、commit本地改动到svn服务器
这个我还没有试,因为目前我还没有糟蹋服务器代码的权限。貌似用下面的命令就足够了:
git svn dcommit
其实我比较希望的是,能把所有的改动打到一个svn识别的补丁里,然后拿过去打补丁就可以了。不过貌似现在还没有合适的办法。如果有哪位知道如何做,还请赐教了!
另外比较推荐的几个git的图形界面工具:mac上用gitx,ubuntu里用git-gui。windowns?不好意思,还没经验,先忽略吧。或者高手给补上?
Saturday, October 16, 2010
Clone your VM machine in VM Fusion: network???
It is quite common (to me) to make copies of virtual machines when building virtual clusters (copy the vm file and select "I copied it" when starting up). Hope that the frequent reading and writing during the experiments will not destroy my hard drive, or please try to do that before the expire of Apple Care :)
Today I met a problem on the network configuration. The case is that after copying the machine, the network of the new copy cannot start up. After searching online and seems that the problem is on the old configuration file. I am using Ubuntu Server 10.04, so if you are lucky enough, you can find that in /etc/udev/XX-persistent-net file, you will find that the old mac address is still there with device name "eth0", but the new interface is eth1.
Now here is the solution: delete that configuration file and reboot! The system will try to generate the file by itself again and then it will work smoothly!
Friday, September 24, 2010
Move on from Wikidot
One year ago I was very excited when I found Wikidot. It was quite handy website for personal wiki, and also, it supports math. Although the syntax is a little different from the wikipedia, it is still ok to me. In fact days before I have decided to make a new public wiki for some thoughts on the db research: http://jwdb.wikidot.com/.
Today when I want to edit the page before I log into it, I noticed large advertisements over the main page. The first idea in my mind is that I may forget to configure the ad to be text (it is reasonable to have ad for such a free service). However the next thing I found is that you can not change the configuration of the ad any more, unless you pay the membership.
I think it is really reasonable to have ad on my pages; it is free service and it should have its own way to survive. However now the ad are really changing the style of the traditional clean-and-simple wikidot pages. Small bars or texts are welcomed, but not the huge images blocking the pages... I think I have to move my new site to another place...
Tuesday, September 21, 2010
ACID Parallel Database I - ACID The Origin
This is a blog for my reading of the paper The Problems with ACID, and how to fix them without going NoSQL, moved from jwdb.wikidot.com.
ACID is short for "atomicity, consistency, isolation and durability" on processing database transactions in areliable way.
A transaction in the database system is a single procedure representing a standalone operation on the actual application logic. An example for the transaction is like a deposit/withdraw from a bank account. The basic and also most important characteristic of this concept is that the consequence of any transactions should be application-logically predictable.
Here the logic is specified by the actual application. For most of the applications we are talking about in database area, the logic is the one on the “consistent status of data”. This is much like the First Law of Thermodynamics where the total amount of the energy is balanced duration any transformation but not creation or deletion. In applications of database systems, creation and deletion are allowed, but should be reasonable.
Sometimes it is really hard to define such reasonable transactions when multiple transactions are happened together and different order of execution will lead to different consequences (or ending status). Basically the non-consistant results on different execution order is from the multiple copies of the original data to be used in different transactions, or something called a branch. At the branching point, a data item is copied into the two (or more) branches, and each branch will executed in their own way decided by the transactions. The problem here is that finally we still want to merge these two (or more) branches into a single data item to replace the one before branching, but this is not very easy when no communication can be made between the two (or more) branches (or the communication consequences cannot be deterministic).
A good start for the future
http://research.microsoft.com/en-us/um/cambridge/projects/towards2020science/background_overview.htm