Ruby

Our thoughts on working professionally with the Ruby programming language to make the world a happier place.

Articles on Ruby

Managing email lists with Mailchimp and MonkeyWrench

Delivering emails is much harder than it sounds in practice. There are all sorts of hassles with being trusted by recipient servers and not being flagged as spam, thankfully Mailchimp help make it easy.

Read more about managing lists in Mailchimp with MonkeyWrench

Filtering the Twitter Streaming API

If you've been using the Twitter Streaming API you've probably noticed you get a lot of data. There's an easy way to limit it to things you care about.

Read more about Filtering the Twitter Stream

Building ruby-debug on Ruby 1.9.x

I've just recently upgraded to ruby 1.9.2-preview3 using RVM and everything is going well, except installing ruby-debug19 (which I'm now dependent on to do any productive development)

Read more about building ruby-debug on Ruby 1.9.x

Consuming the Twitter Stream

In the wake of the recent Twitter developer conference, @Chirp, I thought it was about time I write up my notes on using the Streaming API.

Read more about Consuming the Twitter Stream

JRuby, and why bouncers are assholes

I'm normally not one to use this site as a soap box or an outlet for opinion pieces. But I figured it's easier than being continually baited into replying on all the various blogs/forums/groups out there. There's a whole heap of talk in the ruby community at the moment on JRuby and it's place in the ecosystem. Most of it has been kicked off in response to Charles Nutter's post on JRuby's importance to Ruby. I was fortunate enough to see Charles' presentation at Rails…

Read more about JRuby, and why bouncers are assholes

Ruby Manor Videos Available

For anybody that was unable to attend (like me), or for those that just want a recap then a selection of the Ruby Manor videos are now available for download. Hopefully some more will be posted soon. For any of the bits that are missing you can read through Graham's review of the various sessions. Ruby Manor part 1 and Ruby Manor part 2 …

Read more about Ruby Manor Videos Available

scRUBYt! Gets Plugins!

Yes! You heard right! As you may have gathered, it's been a rather frantic month of development for scRUBYt! and currently this is the addition I'm most proud of. One of the most common requests used to be along the lines of "when do you plan to support xxx format output?". Now, scRUBYt! is oblivious to output formats. That's right, it natively supports nothing, nada, zilch. But to make it useful, we've written a Hash output plugin which we're shipping it with. Firstly, you need to make sure…

Read more about scRUBYt! Gets Plugins!

Web Scraping - The Amazon Example Finale

So yesterday I showed you a fairly contrived example of how to build a web scraper using scRUBYt! to get data from Amazon (they've got an API that would be much easier and more robust if you need access to this info, but that's not the point at the moment). But if you look at the results, they're not the greatest. There is too much noise in some fields, and we probably want to share there data with another system so a ruby based Hash object isn't going to work. For various…

Read more about Web Scraping - The Amazon Example Finale

More web scrapers with the upcoming scRUBYt!

In the previous articles I gave a brief glimpse at the upcoming scRUBYt! release. We learned how to do some basic html scraping, and then followed it up by scraping multiple pages. As promised, in this installment I'll go over how to get more detailed logging output to help you debug your scraper while in development and how to submit and navigate forms. There's been quite a fundamental change to the way scRUBYt! works internally of late. It doesn't manifest itself visually in the way you interface to it, but it does mean logging…

Read more about More web scrapers with the upcoming scRUBYt!

Web Spider Creation with scRUBYt! - Part II

Continuing on from the previous post, Web Spidering and Data Extraction with scRUBYt!, this article will help you delve a little deeper with the scRUBYt! scraping framework both in terms of your understanding of how to use it… and actually delving deeper in your crawl to more pages. So as far as we got last week was to go off to Google, put in a search for the word "ruby", and then list the link text for each of the results. Here's the code we ended up with to get that far: But this is…

Read more about Web Spider Creation with scRUBYt! - Part II

Web Spidering and Data Extraction with scRUBYt!

Some of you may be aware that I work on (time permitting) the scRUBYt! project with Peter Szinek. Hopefully some of you have actually found an excuse to use the tool, I know there are quite a few hundred other satisfied users out there. Well Peter has been furiously working away on polishing up the lastest release, we've also gone back and refactored a lot of the internals and improved the test coverage of library. Given the gnarly levels of recursion in it, at times it was proving difficult to add in the new features we wanted. The…

Read more about Web Spidering and Data Extraction with scRUBYt!

When (ruby) floating just isn't good enough

Hopefully we all know that when talking about numbers "float" means "floating point" and as such the number isn't entirely precise, it's just an approximation. Most of the time it's a good enough approximation to serve our needs, but when it comes to dealing with money it's best to play it safe and have the absolute precision we want. Otherwise all those .000001 of a cents can add up to a large sum. To get around the short-comings of using floating points, a fairly common and trivial…

Read more about When (ruby) floating just isn't good enough

Merbcamp Videos

Update: They are all now available on the merbcamp site. Unfortunately I only managed to capture the stream from day 2. But here are all the videos. I'll be posting them in downloadable formats later this evening. If you want to review my notes I took while watching the presentations, check out notes from merbcamp day 1 and notes from merbcamp day 2 …

Read more about Merbcamp Videos

Merbcamp - Day 2

In case you missed the first installment, click to read day one at merbcamp. This is what happened on day 2: "Your number one priority when building a merb app should be deployment". It's going to make scaling much easier later. As a result, there are some decisions you need to consider very early on in the process. You've got two ways to freeze merb and dependencies into your application folder: But should you freeze or not? And if so, which option should you take? The 3 options you've got are: Once…

Read more about Merbcamp - Day 2

Merbcamp - notes from the edge

A recap on the presentations from the first day of the very first Merbcamp. If you want to read about day to, check this page Merbcamp - Day 2. Ezra gave a great speech talking about merb, some of the design decisions that are directing it, but the two most interesting points for me were: A really useful drop-in replacement for rubygems. Instead of loading the full gem list into RAM (and into every mongrel instance of your app as a result) minigems loads them as required. The reported saving is around 10-20MB of RAM, depending on how many…

Read more about Merbcamp - notes from the edge

DataMapper Migrations

I've been working on some merb related things of late, and I'm planning on writing a more detailed article on creating a merb application from scratch as so many of the tutorials out there kind of leave you hanging. In the interim though, I'm just going to touch on a little nugget of information that isn't very well publicised regarding DataMapper, one of the ORMs that gets used with merb. That's right, you aren't left having to wrestle with the command line and ALTER TABLE statements just because…

Read more about DataMapper Migrations

Make your own IM bot in Ruby, and interface it with your Rails app

In a super secret project I'm currently working on, I've been looking for ways of making it easier for people to interact with the system without the need to log in to the website. That's included the obvious things like having a RESTful API so they can put their own services and interfaces on top, but that only works for developers or 3rd party application providers. What about your average Joe on the street, how come they get forced into having to log in to the site to update their data, etc.? Why not provide a means…

Read more about Make your own IM bot in Ruby, and interface it with your Rails app

Ruby and Microformats

Heard about microformats ? Want to know how to consume them within your rails app? It's a suprisingly simple task. But why would you bother? Well lets take a somewhat practical example. What if on your site you wanted to include a list of upcoming events that you were either attending or might be of use to your users? Say for example, events in the UK for the next 30 days The first thing you need to do, is go grab mofo And now include it in your ruby/ruby on rails application: Next, find the URL of the page…

Read more about Ruby and Microformats

Monitoring Backgroundrb with God

I mentioned yesterday that I'd elaborate on how to extend our app.god config so that god process monitoring automatically becomes aware of our changes. Well for those that can't wait, Graham who I pair with on the majority of my work beat me to the punch with with his post on Monitoring BackgroundRB with God. And at the end of the day English is his native language, so it's probably an easier read (I speak Australian). …

Read more about Monitoring Backgroundrb with God

Using rspec have_tag

Not everyone realises that that rspec havetag assertion is simply a wrapper for the Test::Unit assertselect. And even if you do, do you really know how powerful a tool it is? I've seen many tests and specs where people jump through a whole heap of hoops to check that the desired element exists, well no more! Fresh for today, a quick run down on some of the most useful and powerful selectors you can use with havetag (and by default, assertselect too). Alright, so the most basic of tests is to see if an element exists: Here…

Read more about Using rspec have_tag

Playing with Merb

So there has been quite a lot of talk of late about merb, the new up and comer vying for the rails crown. It was initially developed by Ezra of EngineYard fame, and it's generally considered that 'They know their stuff'(tm). So what is merb? Is it a viable alternative to rails? How easy/hard is the migration from one to the other? I figured it was long overdue that I take a look. Merb is a Rails-inspired MVC framework for web application development. It's major point of difference with Rails is that it's not…

Read more about Playing with Merb

Testing web services with rspec

So you've come over to testing with rspec and it first the bill on most occasions. There are still a few areas though, like decent integration testing, where you still fall back to Test::Unit. So what about testing web services? Sure, ActionWebService is no longer part of rails core but a number of my clients have legacy systems we need to talk to, or 3rd party applications that have been built around SOAP. And at the end of the day, they're still a damn sight better than many of the other alternatives even if it's not…

Read more about Testing web services with rspec

A handy ruby utility (belt)

Giles Bowkett has created a very handy gem called utility belt. For those that find themselves forever delving into script/console or IRB, this can make life seem oh-so-fantastic. I won't bore you with the syntax and full feature list here, as Giles has already extensively done that. But a quick short list of the ones I've already found useful: Quick, go grab it now while stocks last! …

Read more about A handy ruby utility (belt)

Keynote - Merbcamp '08

Video from Merbcamp '08 Keynote

Read more about the Merbcamp '08 Keynote

Driven Merb: A User Story - Merbcamp '08

Video from Merbcamp '08 Driven Merb: A User Story

Read more about Driven Merb: A User Story

Expanding our idea of the background web with Merb - Merbcamp '08

Video from Merbcamp '08 Expanding our idea of the background web with Merb

Read more about Expanding our idea of the background web with Merb

Q&A Session - Merbcamp '08

Video from Merbcamp '08 Q&A Session

Read more about the Merbcamp '08 Q&A Session

Writing Real Time Web Apps with Orbited and Merb

Video from Merbcamp '08 detailing how to write real time web apps with orbited and merb

Read more about writing web apps with Orbited and Merb

Deploying a Merb app - Merbcamp '08

Video from Merbcamp '08 detailing how to deploy a merb app

Read more about Deploying a Merb App

Writing a Merb plugin 101 - Merbcamp '08

Video from Merbcamp '08 detailing how to write a merb plugin

Read more about writing a merb plugin

Learning from Django - Merbcamp '08

Video from Merbcamp '08 Learning from Django session

Read more about the Merbcamp '08 Learning from Django

Installing Ruby, Rails, and Rubygems

Getting your first ruby on rails stack up and running can be a bit of a chore, here's a quick guide on how to do it on a linux box but the instructions should be equally good for OS X users. Now depending on your OS, you've got a few options on how to get ruby up and running. The easiest way is to use the built-in package management system. This will give you the latest known stable version of ruby for your environment, and hopefully reduce or remove any potential conflicts with other installed…

Read more about Installing Ruby, Rails, and Rubygems