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

7 Cool New Ruby Snippets

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.

4. CSV to XML Converter - Short and sweet.

5. Send and receive SMS text messages with Ruby and a GSM modem - I'll admit.. I wrote this one, but it works. You may need to hack the SerialPort library to support your GSM modem, especially if it's not on a usual port. I had to hack the C a little for OS X using /dev/something-weird-here, etc. Hopefully this will get you going though.

6. to_fraction method for Float

7. Create Web site thumbnails quickly with Ruby - Another one of my mine I'm afraid, but again, it works well (so far)!

Comments

  1. Tyler Roberts says:

    Hey, I can use the SMS script to vote for Sanjaya in American Idol. Go Sanjaya!

  2. Satish Talim says:

    My vote goes to Melinda Doolittle !

  3. Jesse Newland says:

    This could be useful for livestreaming or getting some sort of commercial presence on there.

    That's exactly where this script came from - this was the source to the Woot Twitter-bot when I ran it unofficially. I've since handed it over to Woot - I'm not sure if they're using the same method to run to it or not.

  4. Jon Fullerton says:

    Want to run an XMLRPC Server in Ruby on top of Mongrel? See here:

    http://ttt.ggnore.net/2006/11/15/xmlrpc-with-mongrel-and-ruby-off-rails/

  5. Garth says:

    Website thumbnails look good. I wrote a ruby script that utilized Ruby and gtk on Linux. http://www.remoteisland.co.uk/2007/02/19/taking-a-screenshot-of-a-webpage-using-ruby-and-gtk/

Other Posts to Enjoy

Twitter Mentions