tags in git for sane version numbers
The problem
In the svn days, branching was expensive, repositories were centralized ... life was hard. But one thing was easy; each revision had a number and that number went up each time a change was committed to the repository. This made versioning easy: v1, then v2, later v345, finally v1202, anyone can see this and understand.
When switching to git, there is a bit of a learning curve, as each commit is named with an unpronounceable 40 character hexidecimal hash. It's really easy to tell a client, "I just deployed v434, it has all the features we talked about yesterday" Or, "Yeah, you're looking at v57, the new features are in v62" . Its much more difficult to tell a client, "Sorry for the mixup, you are looking at gdac40b3 but the bug is fixed in 616f65bb". I can already see eyes glazing over in confusion.
git has a really handy tags feature. It is perfect for large complicated projects where several commits go into each new release, and the release schedule is on the scale of weeks rather than days. You tag 1.0, then 1.1, 1.1.1 - and so on. These are sane version numbers and are easy to talk about. The problem is that they take work. When you are working on something uncomplicated and the release cycle measures in days or hours, nothing beats the old commit by commit versioning system.
The solution
To get automatic revision numbers in git, we use the native tags, but in a slightly different way. The git describe, command has a handy feature, it can figure out how many commits your repository has after the last tag. What this means is that when you create a tag, say 1.0, 4 commits later git describe will call this "1.0-4-616f65bb". What I propose is to use this feature to our advantage. Rather than tag at the end of a target version, say 1.1.1, we tag at the beginning, and let git to the work. And rather than 1.1.1, we use a meaningful name. So for example, I might use a tag like this:
$ git tag -a 'milestone1' -m 'starting work for milestone 1, due in 2 weeks'
$ git push --tags
From here on out, git will automatically count the commits for us, so we have a sane version number to talk about with clients. If we want to see it, all we need to do is this:
$ git describe
milestone1-34-g4a1e1d4
Which I can then use to tell the client, "Ok, I just deployed milestone1-34, we added the feature to read your thoughts, please check it out and let me know - oh wait ... the software can tell me."
Something that we always do is embed the current revision somewhere into the software so that we know what version the user is seeing. In Rails, I just added this to config/initializers/git_helper.rb
# VERSIONING
git_version_cmd = "git describe"
$revision = `#{git_version_cmd}`
$revision = $revision.strip
puts "starting version: #{$revision}"
I can now put $revision in the footer, or hide it in a comment somewhere on the page. This helps keep everyone in the loop and prevent misunderstandings about what version someone may be looking at.
This is just one way to manage versions in git, we'd love to hear yours!
conflict-when-git-up
When I started to use Git, I felt really pain for it. The problem is that when your team mate told you that he has checked in, and you are willing to see the update right away. So you just 'git up', and then you probably see something like 'you need to commit first before merging'. Oops, but I am just in the middle of modifying something, I am not ready at all to check in.
Well, that's what git up are different from svn up. Here, one tips is:
git stash save # this will save your local changes to a temporary place, and clean up your workspace
git up # here, you could just update to the HEAD of your branch, probably master
git stash pop # then you could get your local change back, and you probably need to fix the conflicts here
Rails on Campus: 华农版 - Session #3

Rails on Campus Roundup / Rails on Campus 大聚集
Last Saturday we concluded the Rails on Campus: 华农版 (SCAU) program with session #3. We wish to thank Dean Song, Professor Sun, and all the students who took the time to attend. We really appreciate working with such amazing students, and we were very happy to be able to come to your school.
上周六我们在华农顺利地进行了Rails on Campus 第三期活动。在此非常感谢宋主任,孙教授以及所有到场的学生。 真的很难得可以跟这么多这么优秀的学生一起分享和学习, 我们也很高兴能够来到你们学校。
And special congratulations to 欧振聪 Clarence Au (@onionou) the winner of our coding competition!
同时,我们在这里恭喜欧振聪同学@onionou赢了我们组织的这场代码比赛!
Over the course of 3 sessions, we've introduced the students to the basics of Rails, and hopefully they will be able to keep learning about Rails and ruby. To recap, here's what we've gone over:
通过这三次活动,我们向学生们分享了一些Rails的基本知识,希望他们可以在课余时间继续学习Rails和Ruby。概括一下,我们谈及的有以下方面的话题:
- Getting the Rails environment - RailsInstaller.org, ruby-lang.org, SublimeText
- Basic ruby syntax -
messages.each {|m| puts m},hash = {:key1=>'val1'} - Creating a new Rails app from scratch -
rails new miniblog - Using scaffolding to get started quickly -
rails generate scaffold message body:text - Creating associations between models - message:
has_many :replies, reply:belongs_to :message - Using Rails view helpers to build forms -
form_for [:message, Reply.new] - How to access the Rails session -
session[:user_id] - Writing filters to manage authentication -
before_filter :require_login - Custom routes for easy URLs -
match 'login' => 'sessions#new' - Deploy your app to share with the world - heroku, DotCloud
The result of our work in class should be a working miniblog that you can share with your friends. Anyone can login, post messages, and reply to other users' messages.
在课堂上我们的练习任务是:创建一个miniblog, 通过这个miniblog 你可以跟朋友分享,每个人都可以登录, 发表信息同时也可以回复其他用户的信息。
We'd love to see you continue with your code. Add more features, improve the design, and put it up on heroku! Make sure to let us know via the Rails on Campus Weibo account.
我们非常希望你们可以继续写代码,让你的miniblog变得更好。 增加更多的功能,做更好的设计,然后放上heroku! 在微博上@RailsOnCampus 展示你的成果吧!
We also would appreciate any feedback, so please let us know how we can make the event go more smoothly next time, or if there's anything else we should cover. We hope to take this program to other universities in the area, and perhaps come back to SCAU for a second season next year.
欢迎对我们的活动提出您的宝贵意见! 这对我们很重要,希望我们下一次可以组织得更好,活动开展得更顺利。如果你有感兴趣的话题希望我们可以分享,欢迎给我们来信! 我们希望到广州更多的大学去分享,可以的话也希望明年回到华农分享更多有趣的话题!
Session #3 / 第三届
The third session in our program focused on completing the feature set to make our miniblog a full web application. Of course we needed a way for users to log in, so that we know who says what. To that end, we went over how to track user sessions, and how to use before_filters to manage users and make sure they log in when they need to.
在第三期我们会分享一些关于如何给我们的miniblog添加新功能新应用,使其变成一个更加完整的网络应用。 首先,我们必须想个办法让用户可以登录,这样我们才知道谁说了什么。然后我们也分享了如何去追踪用户及其发表的信息,以及如何使用before_filters 去管理用户,让他们在必要时进行登录。
Links:
- Slides for RoC Session #3
- Sample code from RoC Session #3
- gzruby rubygems - make sure to follow the instructions here if you are in China
Rails on Campus is a program started by Leon Du and Shaokun Wu, 2 ruby developers in Guangzhou, China. The idea is to build a good set of material for introduction courses that can be used to teach Rails on college campuses. College students are often not exposed to the latest development techniques, and are left to learn on the job. The goal of this program is to introduce students to the world of open source development frameworks to help prepare them for a good job.
Rails on Campus是由中国广州两位Ruby 开发者, Leon Du和伍少坤发起的。活动的初衷是为大学Rails的教学积淀一些有价值的学习材料。大学学生接触新技术的机会不十分多,而常常要上到工作岗位才开始学习。希望通过这次活动,可以为同学们带来更多开源的开发框架,以此为将来的好工作更好地准备自己。
Rails on Campus is sponsored by:
Rails on Campus的赞助团队有:
- gzruby - The Guangzhou Ruby Group http://groups.google.com/group/gzruby
- Kudelabs http://kudelabs.com
- Beansmile http://beansmile.com
Rails on Campus: 华农版
Last week we had our first Rails on Campus session at the South China Agriculture University (华南农业大学). We had an excellent turnout of 50 or 60 top-notch students. We were really impressed with their knowledge of web development in general, and their enthusiasm to learn new things.
上周末我们 Rails on Campus的第一次活动在华南农业大学展开了。大家反应热烈,有5,60个学生参加了我们的活动。同学们对知识的渴望给我们留下了深刻的印象,参加的同学基础知识也非常不错。
The first session focused on:
第一部分内容概要:
- Setting up the Rails environment on your computer
- Learning about the origin of Rails and ruby
- Creating a new Rails app from the command line and adding a simple scaffold
We built a working web app as a demo in about 10 minutes, starting from rails new and finishing with a nice looking miniblog.
The only problem was the recent issues we've been having accessing rubygems from China. This made it very difficult for the students to get a Rails environment working on their own laptop. We hope to have a good solution for this problem before the next session.
For our next session, we'll continue to build on the same application by adding a reply feature.
Here are the links from session #1
这里有一些第一部分学习的相关链接:
- Slides from the presentation: "Introduction to Rails"
- The practice code: Rails on Campus Lab #1
---
Rails on Campus is a program started by Leon Du and Shaokun Wu, 2 ruby developers in Guangzhou, China. The idea is to build a good set of material for introduction courses that can be used to teach Rails on college campuses. In Guangzhou, and many other areas around the world, college students are often not exposed to newer technology, and are left to learn on the job. The goal of this program is to introduce students to a new world of open source development frameworks that are quite popular around the world. Not just Rails, but also things like Node.js or Python/Django.
Rails on Campus是由中国广州两位Ruby 开发者, Leon Du和Shaokun Wu 发起的。活动的初衷是为大学Rails的教学积淀一些有价值的学习材料。在广州,以及世界的一些其他的城市,大学学生接触新技术的机会不十分多,而常常要上到工作岗位才开始学习。希望通过这次活动,可以为同学们带来更多热门的开源的开发框架,以此为将来的好工作更好地准备自己。不单单是Rails,以后我们可能还会涉及到像 Node.js 或者 Python/Django 这样话题。
Rails on Campus is sponsored by:
Rails on Campus的赞助团队有:
+ gzruby - The Guangzhou Ruby Group http://gzruby.org/list
+ Kudelabs http://kudelabs.com
+ Beansmile http://beansmile.com
Join Us for the third GZRUBY meetup
大家好!
时间过得飞快,Rubyist party 又来了,你准备好了吗? 有主题想分享的同学请踊跃回复啦!
时间:23/11, 7:30 PM
地图:Kudelabs 明月一路59号, 汉苑 西塔601室
地铁:五羊邨A出口
Dear Rubyists,
How time flies, it's party time again, are you ready?
Anyone want to share something, please reply!
When: 23/11, 7:30 PM
Where: Kudelabs, 明月一路59号, 汉苑 西塔601室
Metro: Exit A Wuyangcun station
So far, we have a few talks planned: @shaokun will talk about Rails Engines. @seb will discuss large scale rails apps and scaling issues, and @adevadeh will talk about solving the rubygems problem.
Join us for the second gzruby meet up!
The second meeting of the gzruby group will be held in the Kudelabs Offices Wed, Sept 21 at 7:30PM.
Anyone in GZ who uses ruby, or is interested in ruby is invited!
For more information, join the mailing list: http://groups.google.com/group/gzruby
大家好!
本周三我们将会在老地方(Kudelabs)迎来又一个Rubyist party,大家准备好了吗? 为了照顾大家出行,避开下班高峰期,我们决定这次聚会稍晚(晚7:30)开始, 以便大家就餐,来到后可以直接进入主题进行讨论。 聚会预计持续1.5小时,出去开场介绍和自由讨论之外,应该有一个小时左右留给大家做发言, 目前我们已经有来自Sooyoung团队的Padrino主题,此外我们团队也将带来一个主题, 分享我们项目开发过程中使用的一些gem/工具,现在还留有时间可以准备1-2个主题, 大家有想来做分享的请踊跃回帖阿!
Hi all dear rubyist in GZ, it's party time again!
We'll have the next rubyist party on Wednesday(21th Sept) this week at 7:30 pm, same place at Kudelabs. To make it more convenient to all of us, we decide to get start a little later, so everyone can have dinner before come to the party, then we can get straight into the topics faster. We planned to have the event last in around 1.5 hrs, endding at around 9:00 pm, before everyone is sleepy ;-) besides the introduction/public discuss section, we should have about 1 hours for topics. We've already had Padrino from Sooyoung's team, our team will share a topic, something like "share our toolbox", so we still have time for 1-2 topics, if you have something to share, please post it here :)
how to solve "libglpk.so.0: cannot open shared object file" when using RVM in red hat
On linux server, we installed glpk library. then we installed rglpk gem under a gem set through RVM.
We try to use rglpk in our soft, but got this error:
libglpk.so.0: cannot open shared object file: No such file or directory -
/home/username/.rvm/gems/ruby-1.9.2-p180@projectname/gems/rglpk-0.2.4/lib/glpk_wrapper.so
If we install the rglpk gem under system ruby paths, (by using sudo gem install rglpk), rglpk will work as expected.
From the error message, we deduce the problom is rglpk can't find the libglpk.so.0 file.
Then we checked the usr/local/lib dir, we find that file is actually there, what's wrong?
readelf -a glpk_wrapper.so
Using this command to check the content in the binary file rglpk-0.2.4/lib/glpk_wrapper.so
and comparing this file the glpk_wrapper.so from system ruby, we find that library path is wrong in RVM's glpk_wrapper.so
In RMV's glpk_wrapper.so file, the library path is ruby/.rvm/gems/..../lib
In system glpk_wrapper.so file, the library path is usr/local/lib
So we make a link from RVM's library path to the correct library path usr/local/lib like this:
ln -s /usr/local/lib/libglpk.so.0 libglpk.so.0
Finally, this solved the issue, and rglpk works again!
So the reason is when we run gem install rglpk under a specific gemset under rvm, the library path indicated in glpk_wrapper.so file is wrongly configured.
GZTechJobs - Job Board for GZ Geeks
Remember the board which is stuck by a lots of want ad near the canteen of campus? Here what is GZTechJobs, we support a board, you can post your want ad on it, no sign up, no confirmation, just one click and post your want ad!
还记得校园饭堂门口白板上面的那些招聘小广告么? GZTechJobs就是为你提供的那块白板, 你可以在上面随意粘贴你的招聘信息, 不需要注册, 不需要我们确认, 只需要写上你的招聘信息, 然后粘贴上去!
GZTechJobs is focus on Guangzhou IT position information, let's go and see the screenshot of GZTechJobs and post your want here!
GZTechJobs 主要针对广州IT职位的招聘信息, 让我们来看看它是如何方便简单地发布你的招聘信息吧!
-
In homepage, you can see the sharp button "Post a Job", right, click it!
在主页上, 你可以看到一个显眼的"发布职位"的按钮, 对, 就是它, 点一下吧!
-
Then in posting page, fill with your want information, click "Submit"
然后填上你的招聘要求, 好了, 提交吧!
-
Now, you can see your post and geeks will find the job here and hope they will email you!
现在, 你就可以在主页上面找到你刚刚发布的招聘信息了, 程序猿们可以在这里找到他们合适的职位, 希望他们给你发邮件吧!
If you have any question about GZTechJobs, just feel free to email us at jobboard@kudelabs.com
如果有任何关于GZTechJobs的疑问, 欢迎随时给我发邮件jobboard@kudelabs.com
Rails on Campus: 华工版 - Session 1
The first Rails on Campus session went very well last saturday, with around 50 budding rubyists in attendance. We went over the history and purpose of Ruby and then Rails, and then did a live demo of: Build your own miniblog in 20 min.
Rails on Campus 上周六的活动开展得非常顺利,大约50名对Ruby感兴趣的同学参加了此次活动。我们对Ruby 和Rails 的历史以及意义都作了简单的阐述,并且现场做了一个迷你演示:怎么样在20分钟内建一个属于你微博。 :)
Since we didn't have wifi at the venue, it was hard to show all the links and make sure students could write them all down, so here's a list of important links:
由于我们现场没有wifi设备,很难向大家展示所有的链接,同时也考虑到可能一些同学也来不及记下来。 大家不妨看看以下关键的链接,可以更好地理解我们分享的内容:
- Ruby: http://ruby-lang.org
- Rails: http://rubyonrails.org
- Rails on Campus - Session 1 - Slides (PDF format)
- Rails on Campus - Session 1 - Demo code (github)
- Rails on Campus - Session 1 - Hosted app (heroku)
- Rails Installer for Windows
Thanks to everyone involved, and to all the attendees. We all look forward to working together again next week!
非常感谢到场的每位同学以及工作人员,让我们一起期待下一次的活动!
Start a new project and push to remote git repo
Like many folks out there, we have been making the switch to git from svn. Although we struggled with git early on, after using both for some time I have come to appreciate the benefits of git. So here is our way of starting new projects with git.
Using gitosis on our server, we create an empty remote repo first. Then, one guy gets the project going and pushes the code into the empty repo. Here are the commands to get that going.
$ cd path/to/new/project
$ git init
$ git add .
$ git commit -m 'initial commit'
$ git remote add origin git@devserver.com:newproject.git
$ git push origin master
