mike ward content follows

Archive for the 'ruby' Category

command line tweeting

Posted in twitter, ruby on April 1st, 2009

Lots of folks tweet from the command line and I know why. Because you can customize your tweeting to suit your tastes. I tweet to several twitter accounts, so I need something that’ll let me specify which account to tweet to. My solution was to use the rest-client gem and to keep the account info in a YAML file. My tweet.rb script follows:

To use it be sure to create a .twitter directory, and place your tweetlist.yml file in there, formatted like so:

Sinatra is super

Posted in ruby, sinatra on March 27th, 2009

Well my first sinatra app and it took one day to write. It’s trivial and useless, but was just a joy to write nevertheless. If rails is an armored tank then sinatra is a dirt bike. Good watching: screencast by @bmizerany covering some of the main topics.

Anyway to share some joy, let me say I love that there are no controllers, no helpers, no routes file, etc. Rails has so much stuff I always feel like I’m spending a lot of time jumping around between files. Actually a lot of that is due to my trying to learn the latest edge rails feature, try a new plugin, install some new gem, refactor a bit of awfulness from last month, and oh yeah, actually try to add some new feature. So here it’s all straightforward and so there’s nothing to do but write code, no distractions. I learned a couple neat things, like using “pass” to mimic rails’ before_filter functionality.

I also decided to give HAML a try on this experiment as well, and it gets a rave review too. Drop dead easy to learn the basics in 5 minutes, and it puts out such clean markup compared to erb that I’m gonna use it in other projects. Who knew templating could be this good?