Articles

Ruby 1.8.6 Maintenance Transition

It is with great excitement that we want to announce the transition of legacy maintenance duties for Ruby 1.8.6 from the capable hands of Urabe Shyouhei to Engine Yard (and specifically to myself). Going forward, I will be the primary point of contact for bug and security fixes for the 1.8.6 branch of Ruby, and will remain in continual contact with Urabe to ensure the transition is completed smoothly.

Double Shot #457

I’ve got some excess capacity to take on new Rails work again.

Testing gotchas: nested logins don't work

*sigh* after a couple of hours futile hacking about I finally realised that my controller tests were failing because login_as cannot be nested. ie. if you have a context with a login_as @user1 in the setup... then put a context inside it where you login_as @user2... it won't actually do the second login.
So just move that nested context outside. Simples neh?

The random person test

My mother is not a programmer. Ruby lets me easily write code that I could send to her.

I can write:

When to use .nil? in Ruby methods

The problem

Nil? is overused. I find myself deleting it a lot.

I stopped using nil? once I learned that:

When to use self in Rails models

The problem

Self is overused.

When I started with Rails, half the words in my models were self. This wasn’t necessary. Now, when I edit code by other people, I find myself constantly deleting “self” from their code.

For example:

Make .rb files open with Textmate

I’m not an expert at OSX. I’ve used PCs since I was 11… starting with Windows 3.11 and soon after Windows 95. One thing I was frustrated with was that .rb files are automatically associated with XCode. And I tried to right click and select “Always Open with Textmate” but it never seemed to work. Today I got a little mad and went hunting online and found this page:  http://www.tech-recipes.com/rx/2573/os_x_how_to_change_default_application_to_open_file_type/ and it works

Rails Envy Podcast - Episode #072: 03/25/2009

Episode 72.This week we're back with improved audio quality on both sides of the microphone, and all of the great Ruby and Rails news from this week.

Interesting Ruby Tidbits That Don’t Need Separate Posts #24

Fixing Threads in Ruby 1.8: A 2-10x Performance Boost

Joe Damato has been on a roll lately, first with a 6 line EventMachine fix that yielded impressive results, then a configure.in fix to give 30% more performance, and now by getting a 2-10x performance boost with a fix to Ruby 1.8's threading.

Simple Gotcha When Reusing Cucumber Step Definitions

In one of my earlier posts, I showed you how to reuse cucumber step definitions inside other step definitions. Today, I came across a simple “gotcha” that took me a few minutes to debug… so I think it’s something that you should know about if you plan on using that technique.

Here is the faulty code (assume all the reused step definitions exist and don’t contain any errors):

POSIX | Rails Fire

POSIX

In-depth JRuby Q&A: What Makes JRuby Tick in 2010?

JRuby is undoubtedly the most mature of the alternative Ruby implementations. Supporting Ruby 1.8.7 and 1.9.1 (mostly!) and JIT compilation, JRuby is already in use in mission critical Ruby apps and runs scarily fast on the JVM. In this interview with JRuby core member, Charles Nutter, we dig deep into what makes JRuby tick.

State of Ruby VMs: Ruby Renaissance

Ruby is commonly associated with the frameworks (Rails, RSpec, and many others) that it enabled, but it is much more than that. The same ideology and design principles that popularized the language at the start are also the reason why it is being currently ported to a variety of alternative platforms: JVM, Objective-C, Smalltalk VM and Microsoft’s DLR.

Expiring an entire page cache tree atomically

As you’ll all know, Rails has page caching baked right in – the first time an action is hit, it writes a html file of the result to the filesystem. Subsequent hits are served direct from the html file at high speed by the web server without ever involving your Rails app.

Expiring the cache is just a case of deleting the html file. But what if you want to expire an entire tree of cache files? Say you change something in a header or footer, so every single page needs expiring at once.

Ruby 1.9 and file encodings

Just out of curiosity, I took two of my recent Rails applications today and tried them with Ruby 1.9. It was surprisingly easy to make all tests pass without any warnings or errors. Rails 2.3 already has quite good support for Ruby 1.9. The main gotcha however was about file encodings. If you have source files which contain non-ASCII characters, Ruby 1.9 now needs to know which encoding the file was saved with. If you don’t specify the encoding for a file with non-ASCII characters, you’ll get an invalid multibyte char (US-ASCII) error message.

Measuring & Optimizing I/O Performance

Measuring and optimizing IO performance is somewhat of a black art: the tools are there, the resources and discussions are plenty, but it is also incredibly easy to get lost in the forest. I speak from recent experience. Having gone down multiple false starts with filesystem optimization, RAID tweaking, and even app-level changes it really helped to finally step back and revisit the basics.

RailsWayCon

I recently got out the comfort zone to present at a tech conference, RailsWayCon for the first time.Public speaking being somewhat nerve-wracking for most, especially given most developers are borderline autistic, things went relatively smoothly.

Here follows a quick rundown of each talk as well as embedded slides.Source code and slides have also been made available on my Github account.

Syndicate content