Ruby and Rails links, Best of

Monthly collection of Ruby links that I’ll regret forgetting about: My 10 Favorite Things About the Ruby Language � Katz Got Your Tongue?http://dablog.rubypal.com/2009/1/14/10-things-to-be-aware-of-in-moving-to-ruby-1-9http://dablog.rubypal.com/2009/1/16/son-of-10-things-to-be-aware-of-in-ruby-1-9http://www.manning.com/black2/Upgrade to Rails 2.3.4, 2.2.3 (Security Release) Riding Rails: Gem Packaging: Best Practices

   technology, rails, ruby, collection, links

find_each bites

ActiveRecord::Base#find_each is an awesome idiom for batch processing large sets of data. It combines the neat DSL of ActiveRecord and allows you to operate at the level of the individual item. So, imagine my surprise when I debugged my code and discovered that find_each introduces a scope into ActiveRecord calls within the block. Demonstrating by example: Slam.find_each(:conditions => {:value => nil}) do |slam|#….  Slam.find_by_key(slam.key) #Find related key  #However, in effect becomes Slam.

   batch, rails, intent, bug, find_each

Fear the singularity

I found several interesting things this month. Super fast SSD hard disks 21GB pirate bay indexSingularity in thirty years Ok, the last one is really out there, but it points the way. Imagine the whole sum of human creative endeavor (at least the popular ones) indexed in just 21GB. All we need is just some sort of instant hash expansion for that 21GB (and 20 more years of PC power advancement).

   technology, left-field, random

Trying to do the impossible

Someone always asks this question -  how do you check types in Ruby? (*Hint: Ruby use dynamic typing) This typical newbie question would ask this and be answered with various levels of helpfulness - typically none - sadly. However this thread is just beautiful in its helpfulness. http://groups.google.com/group/comp.lang.ruby/msg/eb4b49a511e44be6?hl=en What happended snarkiness, or Slashdot / Youtube style comments? All this helpfulness must come from somewhere. I blame Twitter.

   technology, left-field, ruby, discussion, random

Hackfest at the OpenGovtDataNZ

Hacking for the greater good : the good being helping to free up important government information. A Barcamp and Hackfest was held just this weekend, in the last days of August. I participated in the Hackfest, which was held at the amazing Southern Cross Bar. Great food and nice private room made for a good environment for coding. The Hackfest was a bit more structured than previous events I have been to, but I’ll say this had a positive effect of helping people choose what and who they wanted to work with.

   technology, open source, hackfest, opengovt

Solr, and Sunspot

Update: I have found a nicer way of doing autocomplete. Basically, use the string type with the “starting_with” method. See this ticket comment. Solr is really nice search engine which has the added advantage of being able to return items that you put into the search engine, unlike say, sphinx (which is really fast but only returns the document id). However, Solr is very complex. Thankfully, there is a very neat ruby abstraction for Solr, called Sunspot.

   sunspot, autocomplete, rails, ruby, full-text search, solr

Throw away code

Let’s start simple. Here is a situation I have encountered more than once. We have this big long class or method, and embedded in it are several blocks of code, all commented out. def some_method(a) do_something(a) calc_another # wow # do_do # calc_calc # zcalc(z) end What should I do? Given the code is version controlled, I would happily throw it away. The code is commented out and will have no effect whatsoever on any program or user.

   programming, technique, project

Riding Rails: Community Highlights: IronRuby

Consider this question from Riding Rails: Community Highlights: IronRuby (emphasis mine). Matt: Are there any limitations that our readers should be aware of before starting to develop on IronRuby? Jimmy: The main limitation is that IronRuby does not support any of the C-based Ruby libraries, and only after 1.0 will we consider building an interop layer between the Ruby C API and IronRuby. In the meantime, people have been porting their favorite C-based Ruby libraries over to C# so it can be used from IronRuby, like Hpricot.

   technology, ruby

Git Workshop

I did a Git workshop for Summer of Code NZ students. Here it is: Code Management View more documents from kuahyeow. Full details at the Summer of Code blog: http://blog.summerofcode.co.nz/2009/07/31/code-management-git-workshop/

   technology, summer of code, git, presentation

Rails 3 updates

(Cross-posted from http://blog.projectxtech.com/2009/08/06/rails-3-updates/) Rails 3 is a rewrite / merger with Merb, and includes Yehuda Katz, Merb lead developer working on it full-time. Here are some posts which were published recently: http://yehudakatz.com/2008/12/23/rails-and-merb-merge/ http://weblog.rubyonrails.org/2009/7/30/community-highlights-yehuda-katz http://yehudakatz.com/2009/03/06/alias_method_chain-in-models/ http://www.engineyard.com/blog/2009/6-steps-to-refactoring-rails-for-mere-mortals/ There are lots of lessons and techniques in ruby, rails and general programming to be learnt from these posts. Enjoy!

   ruby, updates. technology, rails3