Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news.

Author Archives: Peter Cooper

By Peter Cooper / March 23, 2007

I’ve stumbled across several great snippets of Ruby code on the Web in the past few weeks, and rather than bore you with a post on each one, here’s a whole collection at once:

1. RSS Twitter Bot – A short Ruby script that will read an RSS feed and republish it to your Twitter account. This could be useful for livestreaming or getting some sort of commercial presence on there.

2. Check if a number is prime in ONE line of Ruby – A rather mind-boggling technique to detect primes using a regular expression (!)

3. iTunes Database Parser – A short script that reads through your iTunes database and tells you what you like to listen to based on your listening habits. Read More

By Peter Cooper / March 21, 2007

Haml

Back in September 2006, I posted about a new markup language for Rails templates called Haml. For those who missed it, Haml is a high-level, semantic language that makes it rather hard to make HTML markup errors. It relies heavily on indentation, a la Python, for its structure.

Hampton Catlin has now released a significant new version, Haml 1.5. Along with this comes a great new logo (above) and official Web site. A very easy to follow tutorial is also offered to whet your appetite.

Hampton says that a significant improvement in 1.5 is a feature called “Sass”, a new way to define CSS stylesheets in a logical way, along with constants, operations, nesting, and selectors. Read More

By Peter Cooper / March 20, 2007

Trawlr

Ben Smith has just relaunched his Rails-powered online feed reader, Trawlr, after rewriting it using Rails 1.2. It’s significantly slicker than before, and includes a screencast to get you up to speed quickly.

I caught up with Ben and asked him a few questions about Trawlr’s redevelopment and new focus, along with how Trawlr is deployed and his plans for the future.

Ruby Inside: Trawlr’s interface is very clean and easy to use. It also seems quite unique and simple in an area where readers often use similar interfaces. What have been the inspirations behind Trawlr’s design?

Ben Smith: When I started work on trawlr I was aiming to get real-world experience developing my first Rails application and like most programmers I had a specific itch to scratch. Read More

By Peter Cooper / March 20, 2007

Sign

Three weeks ago I mentioned Gregg Pollack and Jason Seifer’s great page caching tutorial. In that short time, and mostly on the back of that article, they’ve gotten 1000 subscribers and thousands of page views. Their tutorials are good!
Not ones to rest on their laurels, they’ve now written and released the second part of their caching tutorial series, focusing on action and fragment caching. They don’t go into insane levels of detail, but cover action and fragment caching reasonably comprehensively and provide lots of illustrative code snippets. And for those developers using Edge Rails, they also take a quick look at ActiveRecord query caching. Read More

By Peter Cooper / March 19, 2007

Railscasts

Railscasts is a new project by Ryan Bates providing regular, free screencasts on topics relating to Ruby on Rails. As opposed to Geoffrey Grosenbach’s wonderfully detailed Peepcode screencasts, Railscasts videos are very short and each is focused on a very small area. Current topics include layouts, with_scope, Symbol#to_proc, caching with instance variables, and dynamic find_by methods.

The screencasts are well produced and to the point, and feature the creepiest opening sequence of any Ruby-related screencast so far.

Note: Make sure to use the “Download” links on the Railscasts site rather than clicking on the video titles as that will result in an error. Read More

By Peter Cooper / March 19, 2007

Evan Weaver had a basic problem to solve:

We need to compute whether a point lies within a polygon. And we need to do it a lot.

Due to MySQL’s lacking geometry features, Evan had to perform location searches using Ruby code to find points within certain polygons. Keen for a speed-up, Evan digs out some C code from 1987 and sets about using RubyInline to speed up the whole process. The end result? A 22x increase of speed.

Of particular interest to RubyInline newbies will be the way Evan had to adjust the C code for it to work directly on Ruby objects. Read More

By Peter Cooper / March 19, 2007

Railsforall

Robert Dempsey has launched Rails For All, Inc., a new non-profit Rails advocacy group. Robert says he’s created the non-profit because he feels that the lack of a major corporation to back Rails has led to a hole in the advocacy and networking area. One of Rails For All’s goals is to act as a hub where Rails professionals and businesses wanting to learn more about Rails can come together.

Rails For All is reliant on all Rails advocates for content contributions, such as case studies and application demos, and is also seeking financial sponsorship. If you have a Rails case study to share, or want to get involved in the group in one way or another, visit the official site. Read More

By Peter Cooper / March 15, 2007

Httperfpeepcode

Benchmarking with httperf is a new screencast by Geoffrey Grosenbach in his Peepcode series of Ruby / Rails related videos. It costs $9, but for that you get a bundle of source code and a very high quality video of 53 minutes’ length.

In the video Geoffrey covers a lot of basic theory about statistics (including standard deviation) and shows how to extract useful statistics from Rails log files and httperf, a Web server performance monitoring tool. He demonstrates the actual effects of using the various types of caching available to Rails developers (including what types of caching are faster and by how much) and what effect sessions have on request levels. Read More

By Peter Cooper / March 13, 2007

I’m currently putting together the list of publications that my publisher, Apress, can send and push my book to. Unfortunately Ruby has a rather lacking publishing ecosystem, but I figure I’d try “ruby magazine” in Google none the less.

Rcas
The first relevant result is Ruby Code & Style. This site used to be quite good to read, but about the time that Ruby Inside launched.. it stopped. The last article was published on May 23, 2006. Created by Artima, RC&S had/has an impressive list of names on its advisory board, including DHH, Jamis Buck, James Britt, Hal Fulton, Eric Hodel, matz, and.. Read More

By Peter Cooper / March 13, 2007

SQLDSL, by Jay Fields, is, simply, “a library for creating SQL statements using Ruby code.” Jay posted separately about the pros and cons of SQLDSL on his weblog, although he might be accused of bias with only one con to six pros (compelling as they may be).

Despite being another DSL to learn, SQLDSL follows SQL pretty closely (in contrast to ORM frameworks like ActiveRecord, Sequel, or Og):

Select[:column1].from[:table1].where do
name = person_name
end

And it even affords some clever logical tricks:

Select[:column1].from[:table1, :table2].where do
table1.column1 = table2.table1_id
table1.column2 >= quantity if quantity > 0
end

One major future benefit of SQLDSL is that it provides a programatic abstraction of SQL that’s still pretty close to the database layer, and could allow for easy vendor-specific SQL manipulation in future. Read More

By Peter Cooper / March 11, 2007

Derby

Brian Leonard has put together a fine walkthrough of creating a Rails project in NetBeans 6.0 along with database (powered by Derby). I’m not a Java / Netbeans guy myself, but this is a compelling walkthrough. It looks very slick, especially for an as-yet officially unreleased IDE. Read More

By Peter Cooper / March 9, 2007

Following on from the bumper Ruby interpreter performance tests by Antonio Cangiano two weeks ago, Xue Yong Zhi decided to run the same performance suite on XRuby Ruby to JVM compiler and found that XRuby is faster than the Ruby interpreter in 26 out of 38 tests. It’s interesting to note that the failing tests are the same as those for the official Ruby interpreter on Windows (stack exhaustion?) so in the scope of these performance tests XRuby appears to be more feature complete than interpreters such as Cardinal and Rubinius that fail many of the tests.

While XRuby’s performance is certainly amazing for a project that’s less than 2 years old, and the idea of compiling Ruby directly to Java bytecode is initially appealing, the results for YARV/Rite are still streets ahead in terms of raw performance, and where I’m placing my bets for the next de facto Ruby interpreter. Read More

By Peter Cooper / March 8, 2007

Openid

Decentralized identity system, OpenID, appears to be the latest flavor of kool-aid permeating the Rails universe. OpenID makes it possible for users to identify themselves by using URLs that relate to a site where they have already logged in. Your application can then check this with the remote site and then use that status to tie that confirmed identity to their identity within your system. As much for my own reference as anything else, here are the main bits and pieces floating around regarding Rails and OpenID lately:

1) David Heinemeier Hansson started off by talking about how 37signals are looking at using OpenID. Read More

By Peter Cooper / March 8, 2007

Redmine

redMine is an open source project management and issue tracking Web app, created by Jean Philippe Lang and released under the GPL. There’s a live demo of the system available. Features include multiple user support, SVN and diff browsers, LDAP support, support for several different database systems, and more. Read More

By Peter Cooper / March 6, 2007

On behalf of the whole JRuby team, Thomas Enebo has announced the release of JRuby 0.9.8. Hundreds of minor tweaks, fixes, and features have been added, and now Ruby on Rails is officially supported. The team report a 98% pass rate for Rails 1.2.1′s own unit tests, and if you’ve seen how deep the Rails tests go, that’s pretty good work. It’s pretty clear JRuby isn’t too far from a 1.0 release now from which full compatibility should be available. Read More