Insights on Ruby, Git, jQuery, Cappuccino, WordPress, Debian and OS X. Please subscribe if you find something useful!

AppStore Ruby Module

Posted: August 22nd, 2009 | Author: Jerod | Filed under: Ruby | Tags: , | Comments

So I was writing my first iPhone on Rails app when my Google Reader dropped some pretty awful news on me. Somebody pre-empted my release with their (pretty excellent, but poorly named) “Bargain Bin with Push!” app (iTunes link).

The Bad News

“Bargain Bin with Push!” does pretty much exactly what my app was going to do. It provides push notifications when apps you’re interested in drop in price. Instead of raging against the dying of the light, I’ve decided to just user their app and let mine go gently into that good night.

The Good News

All was not lost. I learned a ton along the way and decided to open-source the module I was using to fetch app information out of Apple’s App Store.

The Goods

The code is on GitHub, of course. Clone, fork and branch to your heart’s content. Hopefully somebody will find it useful.


Extending TMail::Mail for HTML and plaintext only

Posted: February 21st, 2009 | Author: Jerod | Filed under: Ruby | Tags: , | Comments

A project I’m working on required a little more from Ruby’s TMail library than it offers out of the box. One of the things that make Ruby great is how you can dynamically extend classes.

TMail can parse a raw email and provide you with the headers, subject, body, etc. But what it doesn’t do is parse the body and pull out the html and/or plaintext from multi-part emails. Well, now it can.

I found a great little piece of code on Google Code called tmail-html-body-extractor. It was written by Fernando Guillen and released under the Apache License 2.0.

Fernando’s code was great, but its intent was returning just the html from the email body. For my current project, I am more interested in just the plaintext from the email body, so I added this functionality.

Thanks to the openness of the Apache License 2.0, I was able to extend his script and re-release it on GitHub with my modifications.

Now its trivial to return just the html from an email body, or just the plaintext:

require "rubygems"
require "action_mailer"
require "tmail_mail_extension"
 
mail = TMail::Mail.parse(raw_email)
 
mail.body_html  # returns just html if available or nil
mail.body_plain # returns just plaintext if available or nil

You can get the source on GitHub!


New GitHub Repo: AWS Ruby Miscellany

Posted: July 14th, 2008 | Author: Jerod | Filed under: Projects | Tags: , , | Comments

I decided to source out a few random Ruby scripts I use to interface with Amazon’s Simple Storage Service (S3) from the command line. Right now there are scripts which allow:

  • Duplicating a local folder in a specified S3 bucket (recursively)
  • Listing all buckets and files stored on an S3 account
  • Uploading a specified file to a specified S3 bucket
  • Downloading a specified file from a specified S3 bucket.

I’m sure the functionality will grow as needs arise. For now, check out the repo on GitHub