Updates to Marshmallow, the Campfire bot

At work, we’ve been using Campfire, the wonderful web-based group chat application from 37signals for a while now, and have found it essential in our virtual environment.

I recently discovered Marshmallow, the unofficial Campfire API, and setup deploy notifications, and couple other little hacks to keep the virtual office up to speed. However, Marshmallow was missing a critical feature (in my mind): the ability to watch and process others’ messages in the room. So, I spent a couple minutes this morning and added a new watch method:

I also added a new topic method to set the current room’s topic – we use it to match Basecamp project numbers and put the project URL in the topic.

The SVN server for Marshmallow seems to be down, and I can’t seem to get in touch with court3nay, so I figured I’d just let this loose. Without further ado, here’s Marshmallow 0.3.

Example Usage

#!/usr/local/bin/ruby

require 'marshmallow'

bot = Marshmallow.new(:domain => 'yoursubdomain')
bot.login :method => :login, :username => "email@you.com", :password => "secret", :room => "34567"

while(true)
  bot.watch do |m|
    bot.say("Hello, #{m[:person]}") if m[:message].match(/^(hello|hi|hey)$/i)
  end
  sleep 3
end

Ruby and Quicksilver: Executing Ruby one-liners with Quicksilver

To plug Ruby directly into your brain, take three short breaths, mutter a prayer to Matz, and then follow these instructions:

Prerequisites: Mac OS X Panther or greater and Quicksilver

  1. Download this humble Applescript
    using terms from application "Quicksilver"
        on process text t
            do shell script "ruby -00 -e '" & t & "'"
        end process text
    end using terms from
  2. Unzip the script and copy it to ~/Library/Application Support/Quicksilver/Actions/
  3. Restart Quicksilver

Once you’ve plugged in, Ruby is just a blink away:

  1. Invoke Quicksilver (CTRL-Space)
  2. Type a period (.) followed by your one-line stroke of genius, such as:
    [ "in", "me", "plug" ].reverse_each {|x| print x.upcase, " " }
  3. Press TAB
  4. Type until ruby is displayed in the second pane
  5. Press Return

The results of your Ruby one-liner (‘PLUG ME IN’ in this case) are placed back into the first pane of Quicksilver for your digestion.

_Thanks to bsg for the inspiration. _

Rails and Subversion

Woah, I missed the addition of the -c flag to the ./script/generate command. (When did this happen?) From the help:

-c, --svn    Modify files with subversion. (Note: svn must be in path)

Let’s try it:

jnewland@slash trunk $ ./script/generate controller dashboard -c
      exists  app/controllers/
      exists  app/helpers/
      create  app/views/dashboard
A         app/views/dashboard
      exists  test/functional/
      create  app/controllers/dashboard_controller.rb
A         app/controllers/dashboard_controller.rb
      create  test/functional/dashboard_controller_test.rb
A         test/functional/dashboard_controller_test.rb
      create  app/helpers/dashboard_helper.rb
A         app/helpers/dashboard_helper.rb

Whoo! No more need to run svn --force add . or anything else after generating a model, controller, or anything. There hasn’t been a day in months where I haven’t found out something like this in rails – a small touch that saves a big headache on my part. Nice work, guys :).

Learning Ruby on Rails

I just responded to the third e-mail in a week from friends asking me “How do I learn Ruby on Rails?” I’ve amassed a good collection of resources that are invaluable to anyone wanting to get on the proverbial train, and I figured it was wrong not to share it with everyone…...so, here’s your ticket:

NOTE: All of the following links assume some programming knowledge. If you’re new to that too, check out Learn To Program, a wonderful intro to programming with Ruby

  • Step two, buy the book. I bought the PDF, and have gone through two home-printed copies while I’m waiting for the final verision to ship (should get here very soon!). The Depot example application will help you understand the underlying structure of Rails.
  • If you’re new to Ruby as well, check out the pickaxe, a great free Ruby book.
  • Check out the Ruby on Rails Wiki for tons of HowTo guides and community documentation. The search feature is helpful.
  • The API reference is the epitome of technical, but it sure is COMPREHENSIVE. Want to know if ActiveRecord::Base##Find returns an Array or a Hash? This is the place to go.
  • Snippets tagged as rails – Random rails code written by random people showcased on a website that was written on rails in less than 2 days. Lots of great code to steal, or use as inspiration.
  • Check out the source code of typo the weblog engine I’m using on my blog. This is an excellent application, as well as excellent code to use for inspiration.
  • Better yet, get a Textdrive hosting account and setup a Typo blog for yourself! Textdrive is the best webhost for Ruby on Rails. Seriously, $12 a month is cheap, and the support is great.
  • #rubyonrails on irc.freenode.net is a great place to real people about Rails. Have a question that’s been bugging you? Ask one of the developers.
  • Sign up for the Rails mailing list. It’s high traffic, but very good, and people share code on there frequently.

That should keep anyone who’s interested in Ruby on Rails occupied for at least, oh, say, a couple months.

NOTE: If you feel that any links should be added to or removed from this list, post a message in the comments.

Odeo massage

While listening to podcasts on Odeo at work I stumbled across this error massage message:


Odeo’s database servers are taking a quick break to get a massage.

We like to keep our databases happy, and to do so we make sure they get regular rejuvenation breaks. Odeo wants to keep it’s databases happy and we understand that taking a break can’t be run on a strict clock…Our databases will be happy to serve you as soon as they come back online.

Did you know that we’ve named all of servers after streets in the mission district of San Francisco?

Very rarely does an error message make you feel good about a website, but I like Odeo better after seeing that error. It makes me feel all fuzzy inside, is built with Rails, and has Science Friday’s podcast! :)

rails 0.13

The web is about to explode with exciting new apps. There’s a beta gem out for the upcoming version 0.13 of Ruby on Rails , which contains helpers methods for some crazy AJAX stuff developed by script.aculo.us.

For example, you can make an auto complete text field with TWO LINES OF CODE. Further, Drag ‘n Drop shopping carts are trivial. This stuff is absolutely nuts.

If you’re not into Ruby on Rails, take a look right now. I’m involved in 4 Ruby on Rails projects right now (2 personal, 2 for profit) and the small amount of time I invested in learning RoR is generating amazing returns :)

UPDATE: Ruby on Rails 0.13 has been released! Go get it now!

finally on rails!

I gave in – all of the cool kids have textdrive accounts.

This is a development install of typo – an amazing blogging app :)

Older posts: 1 2