Thanks to everyone who attended the gzruby meetup last wednesday night. It was great to get a chance to meet up with our ruby friends and we also met a lot of new people. It‘s exciting to see how the community is growing as we gain new members and introduce more people to the joys of ruby.
The presentations included:
- Launch of http://gems.gzruby.org, the GZRUBY rubygems mirror
- Real Life Rails Scaling, by Seb. Scaling your app, your team ... yourself. (slides)
- method_proxy - some fun with ruby's dynamic programming, by Jev. A look at how we can utilize ruby's meta-programming features to get deep insight into our code. (method_proxy sample code, slides)
- Cloud Service API design, by Chance Jiang
Really looking forward to the next meeting, planned for Jan 18, 2012! See you all next year.
Photo by littlepxy
Last week we had another great Rails on Campus session with the students at South China Agriculture University 华南农业大学. Again, it is really great to see how motivated the students are. We are really impressed with their level of knowledge in web-development and how quickly they can pick up the topics we cover.
上周我们与华南农业大学的同学们度过了一个愉快的周末 -- Rails on Campus 的第二次活动。 非常高兴能够再一次感受到同学们的积极。大家对网页开发的扎实知识以及对新知识的快速吸收能力，给我们留下了深刻的印象。
This week the lesson covered the following topics:
- Review Rails app structure, rails commands to create the DB and start the app
- Basic resources and RESTful routes: index, show, create
- Adding an ActiveRecord association: belongsto, hasmany
- ActionView#form_for and building a nested form
We did this by adding a replies feature to our simple miniblog app. To follow along, you can grab the code at github RoC Lab #2.
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 newer technology, 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和Shaokun Wu 发起的。活动的初衷是为大学Rails的教学积淀一些有价值的学习材料。大学学生接触新技术的机会不十分多，而常常要上到工作岗位才开始学习。希望通过这次活动，可以为同学们带来更多开源的开发框架，以此为将来的好工作更好地准备自己。
Rails on Campus is sponsored by:
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
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的赞助团队有：
时间过得飞快，Rubyist party 又来了，你准备好了吗？ 有主题想分享的同学请踊跃回复啦！
时间：23/11, 7:30 PM
地图：Kudelabs 明月一路59号, 汉苑 西塔601室
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.
For a while, I've been interested in gems that provide access to Abstract Syntax Tree (AST) representation of Ruby code, and potential possibilities they open. Just a couple days ago this interest was triggered again. The question that arose at the moment was:
- say, we're facing somebody else's lengthy, sophisticated and rather unfamiliar code which we're planning to reuse. How do we find out where the code may be cache'ing results in instance variables - therefore, possibly, causing unplanned and undesired side effects?
Perhaps, we could convert the given piece of Ruby code into AST and then list all lines that correspond to instance variable assignment nodes... This felt like an interesting exercise so I ended up writing a little code snippet for that.
A few other possible AST uses, I thought, could be:
- listing all methods defined in a specific file;
- listing all method calls in a given class or method (e.g. to figure out external dependencies for refactoring or unit-testing purposes);
- listing class variable assignments.
So, the initial script evolved into a more generic parsetree_locator.rb utility (note: requires 'ruby-parser' gem; also, only tried it on MRI Ruby 1.9).
Let me present a few examples of how the utility works.
Say, we have the following Ruby code in 'example.rb' file:
module M class C def meth @a = 2 b = 3 end def call_meth meth end def another_meth @n = 95 call_meth end end end
1) List all instance variable assignments - "iasgn" AST nodes:
$ ruby parsetree_locator.rb "iasgn" "example.rb"
Line nr | Module, class, method | Code 4: | module M, class C#meth | @a = 2 13: | module M, class C#another_meth | @n = 95
2) List all defined instance methods - "defn" AST nodes:
$ ruby parsetree_locator.rb "defn" example.rb
Line nr | Module, class, method | Code 3: | module M, class C | def meth 8: | module M, class C | def call_meth 12: | module M, class C | def another_meth
3) List all method calls - "call" nodes:
$ ruby parsetree_locator.rb "call" example.rb
Line nr | Module, class, method | Code 10: | module M, class C#call_meth | end 15: | module M, class C#another_meth | end
-- seems like the line numbers are slightly off in this case. The author of 'ruby_parser' gem mentions that it may happen; the results seem reasonable most of the time, though.
Hope that somebody else finds this utility useful as well, enjoy! parsetree_locator on GitHub
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 :)
hudson is awesome CI(continuous integration) tool.
We want to install it on our ubuntu server to do CI for our rails projects.
Here are the steps of how to make it work:
1. ssh username@servername, to login remotely to your ubutu server.
(After you install a brandly new ubuntu on the server, you will need to sudo apt-get install openssh-server, then you can ssh it from your laptop)
2. install hudson on the ubuntu server, here is the instructions:
(the good news after you finished the installing is, hudson is already so system daemon that will be auto-started when ubuntu reboot.)
(after installed hudson and reboot ubuntu server, open a web browser, access http://serveaddress:8080/, you can see the lovely interface of hudson. Then you need to install several plugins for hudson, like ruby, rake, git etc, this can be easily done through hudson UI)
3. install ruby on the ubuntu server, run the following command
sudo apt-get install ruby
(this will install ruby 1.8.7 as default)
4. after login ubuntu server on your laptop, run this command on the terminal of your laptop to act as the hudson user auto-created by the hudson installation.
sudo -Hiu hudson
(you have to act as hudson user, because the next step is to install rvm, if you install rvm under another account, hudson account will not be able to execute rvm command.)
5. install rvm, here is the instructions:
(make sure you are using hudson account on ubuntu, by this way, the rvm will be installed under hudson directory)
(you will need to create a .bashrc file to $HOME dir, and add a this line to that file
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function)
5. rvm install ruby-1.9.2
6. rvm --default ruby-1.9.2
then we are almost there!
7. How to set Hudson to use smtp.gmail.com to send emails after a build failed?
go to hudson config page
smtp server: smtp.gmail.com
smtp port: 465
8. I run into another problem when trying to check out a project.
We used "externals" feature in svn 1.6, but when I build a project for the 1st time, the code in external is not checked out.
My solution is in the config screen of the project, at the section setting svn urls, press "add" to add a location.
then fill in the svn url of the external codes,
then fill in correct local directory that the external codes should go in.
then this problem is bypassed.
9. set the build part in project:
a. select "execute shell"
b. add the following lines:
# Environment setup
# Use the correct ruby
rvm use 1.9.2@gemsetname
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
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
and comparing this file the
glpk_wrapper.so from system ruby, we find that
library path is wrong in RVM's
glpk_wrapper.so file, the library path is
glpk_wrapper.so file, the library path is
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.
After 2 great sessions of Rails on Campus: 华工版, we'd like to thank everyone who took part in helping to plan and organize this event. We learned a lot from the experience, and we hope the attendees did as well. We plan to take our materials from this first run, refactor, and put on a better program next year!
Before we close out for the year though, I wanted to go over what you can do to continue learning on your own.
http://railsinstaller.org - Download and run the installer. It will install everything you need to get started writing your own Rails apps (ruby, git, rubygems, rails).
Get the demo code
http://github.com/kudelabs/roc-demo2 - Clone the project and get it running on your computer .
git clone git://github.com/kudelabs/roc-demo2.git
Write some code
http://notepad-plus-plus.org/ - You can use any text editor to write code, but its much easier in a real code editor like Notepad++. It's free, give it a try.
http://http://guides.rubyonrails.org/getting_started.html - Take a look at the Rails Guides for more in-depth tutorials
http://asciicasts.com - Another great resource with tons of tips and information
Share with the world
http://heroku.com - A free service to host your amazing Rails app! It works right from the command line and in 5 minutes you have a public site that you can show to anyone.
Just Do It
So now you have no excuse. You have the tools, you have the code, you have the servers. Go write an inspiring app and make us proud!
It’s cool to have different gemset for each project. However, the problem is that you have to install gems, e.g. thin, bundler, etc, that shared among them again and again.
Of course, there is already good way to deal with this:
RVM provides (>= 0.1.8) a @global gemset per interpreter.
Gems that are installed to the per-interpreter @global gemset are available to all other gemsets for that interpreter.
This is a good way to allow all of your projects to share the same installed gem for a specific ruby interpreter installation.
see http://beginrescueend.com/gemsets/global/ for more details
Below shows an example about installing bundler into @global gemset:$ rvm 1.9.2@global
$ gem install bundler —no-ri —no-rdoc
$ rvm use 1.9.2@other_gemset
$ gem list
You should see bundler in other_gemset too. But not that if you switch to other ruby version, e.g. 1.8.7, you have to do it again for 1.8.7@global.