7 Cool New Ruby Snippets
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.
7. Create Web site thumbnails quickly with Ruby - Another one of my mine I'm afraid, but again, it works well (so far)!