September Wrap-Up: Open Source Work!

The month of September has flown by, and I’ve had my hands covered with Ruby work of late. In the process, I’ve needed to tweak some great projects like Starling, Webistrano and xmpp4r-simple. These projects are definitely maturing, and it’s been great to get under the hood to see how they tick, and see where I can help nudge them in the direction I hope to see them move.

Drop me a line and let me know what you’re up to. Better yet, shoot me your github.com profile link, so I can follow you. You can keep track of me on my GitHub profile as well.

Happy Coding!

Extracting CAS configuration into YAML, like database.yml

If you’ve done any enterprise work with Rails, and your shop is using CAS for authentication, chances are you’ve seen rubycas-client. Chances are you’ve also loved how easy it was to get working. There’s usually only one hitch — you’ve got to change the config based on which environment you’re deploying into.

Here’s the standard advice you get from the RDoc:

# in your config/environment.rb
CASClient::Frameworks::Rails::Filter.configure(
  :cas_base_url => "https://cas.example.foo/",
  :proxy_retrieval_url => "https://cas-proxy-callback.example.foo/cas_proxy_callback/retrieve_pgt",
  :proxy_callback_url => "https://cas-proxy-callback.example.foo/cas_proxy_callback/receive_pgt",
  :logger => cas_logger
)

Read more…

Thanks for Mongrel, Zed — don’t let the door hit you…

I’m not sad to see the writer of Mongrel leave. Not one bit. I’m not sure what Dave Thomas was reading earlier today, but I don’t have anything positive to say about it.

I like Mongrel. I’ve read Zed Shaw’s article rant on programmers and statistics, and I liked it quite a bit — though I prefer his Ruby/Odeum vs. Lucene Analysis Part 2 since it lays out a more clear example of his opinion about how to properly use statistics to analyze software (amazing — Zed can make a set of useful points without using the F-word!!).

But as an outsider to whatever caused his Rails rant, he just doesn’t come off as credible when he makes silly pointless wildly exaggerated claims about his skills and situation and then begs dares challenges asks anyone disagreeing with him (except Humility) to start an all out fist fight.

Read more…

How to Setup Google Apps Chat SRV Records For iChat and xmpp4r-simple

I’ve registered several domains using Google Apps. Lately I’ve been fiddling with using Jabber with those domains, and I wanted to have a program be able to interact on IM using an account like tim@example.com. Furthermore, I wanted to have everything Just Work.

The place to start was with DNS. Google has a help page about how to setup your DNS so that your Google Apps accounts can be federated with other non-Google Jabber communities. The problem is that neither xmpp4r-simple nor iChat simply work if I use tim@example.com as my JID. Then I stumbled across this post that connected the dots for me.

Here’s a screenshot of how I setup my SRV records over at eNom:

DNS SRV records for XMPP federation and client setup.

After that, my simple chat listener worked:

require 'rubygems'
require 'xmpp4r-simple'

im = Jabber::Simple.new("tim@example.com", "secret-password")
puts im.connected?
im.accept_subscriptions = true

while true
  sleep(5) unless im.received_messages?

  im.received_messages { |msg| puts msg.body if msg.type == :chat }
end

My little “bot” silently accepted new buddy requests, and printed out recent messages every 5 seconds.

UPDATE: Something’s amiss here, I think. I’ll update when I have more details. Guess not. I tried this out on another domain, and thought that things didn’t work right. But I was mistaken. Everything looks good.

Off To RailsConf 2007

In a couple hours I’ll be catching a plane to Portland to attend RailsConf 2007. I’m stoked to hear the presentations, and talk to others that are using Rails every day. It’s gonna be a great Ruby feast, to be sure.

If you want to meet up, contact me through my website or just look for anyone wearing a CodeSmack t-shirt. Chances are good on the first day that it’s me. We’ll have some for sale, so if you wait until Saturday your chances of finding me solely by the t-shirt will be diminished. :-)

I’ll be updating my RailsConf schedule this afternoon and tonight. I’ll try to keep it current during the conference as well. Hope to see you there!

T-Shirt Tuesdays

CodeSmack: Announcing T-Shirt Tuesdays

1. We will design new shirts and release them on Tuesdays
2. We will sometimes feature existing t-shirt designs
3. We will discount the t-shirts featured on Tuesday until the next Tuesday

Head on over and see this week’s newest designs and featured shirts, including one of my new favorite designs: Ready. Fire. Aim. (Hint: listen to its inspiration from RailsConf 2006) Buy ‘em this week and you’ll get a $2.00 discount over normal prices. Enjoy!

Ready. Fire. Aim.

Rails Page Caching + Mongrel

So you’ve got a great Rails app. You’re setting up page caching for those publicly accessible pages shared by everyone. One of your pages is the :index. It seems like the caching isn’t working when you’re testing it, but the output constantly says:

Cached page: /tag.html (0.00044)

What gives? Try seeing if “/tag” seems to use the cache, but “/tag/” doesn’t.

The mechanism behind the Rails page caching takes your action output and stuffs it all into an HTML file that can easily be found by the web server. Ah! So there’s no voodoo in Rails itself that tries to check for that page. In fact, it’s banking on not being called by pushing that burden off to the web server. In our case, this is Mongrel.

So how does Mongrel decide? Well, the mongrel_rails fires up a RailsHandler which uses the PATH_INFO to check for the existence of a cached file. When you’re requesting “/tag/” it’s looking for tag/.html, but not finding it.

I put together a patch here to address it. Seems to work in my limited testing, but I don’t know what I may have broken. Yeah, usually I make sure to write a test for my patches. This time I didn’t. Perhaps it won’t make it in until I do, but at least I’ve got it written down here to remind me when my cache doesn’t seem to work quite right.

Which RubyGems are you sporting?

Mike Clark is wondering:

Which RubyGems are you sporting?

So my current list is down below. I imagine it will change soon — maybe tomorrow.

gem list | grep "^[a-zA-Z]"
actionmailer (1.3.2, 1.3.1, 1.2.5)
actionpack (1.13.2, 1.13.1, 1.12.5)
actionwebservice (1.2.2, 1.2.1, 1.1.6)
activerecord (1.15.2, 1.15.1, 1.14.4)
activesupport (1.4.1, 1.4.0, 1.3.1)
aws-s3 (0.3.0, 0.2.0)
BlueCloth (1.0.0)
builder (2.0.0)
capistrano (1.4.0, 1.3.0, 1.2.0)
cgi_multipart_eof_fix (2.1)
daemons (1.0.4, 1.0.3)
ezcrypto (0.7)
fastthread (0.6.3)
gem_plugin (0.2.2, 0.2.1)
hoe (1.2.0)
hpricot (0.5, 0.4)
libxml-ruby (0.3.8.4, 0.3.8)
mechanize (0.6.4)
mime-types (1.15)
mongrel (1.0.1, 0.3.13.4)
mongrel_cluster (0.2.1)
needle (1.3.0)
net-sftp (1.1.0)
net-ssh (1.0.10)
rails (1.2.2, 1.2.1, 1.1.6)
rake (0.7.1)
RAliasFile (0.1.0)
rubyforge (0.4.0)
rubyosa (0.2.0, 0.1.0)
sources (0.0.1)
wirble (0.1.2)
xml-simple (1.0.10)
ZenTest (3.4.3)

2007 Shake Up

For 2007, I’ve decided to make a few subtle changes to the way I blog and
podcast.

  1. Less Java, more other stuff.
  2. Less rigor, more direct.
  3. More personal.

Less Java, more other stuff. I don’t find that Java captures my main set
of interests any more. I’m going to talk more broadly in both my blog and
the Zdot podcast.

Less rigor, more direct. Up to this point I’ve typically waited to post most substantial things until I’ve had some longer experience. Bloggers like Matt Raible and Ed Gibbs write more stream-of-conscious style. I like the feel it brings, so we’ll see if it fits me in 2007. So don’t be surprised to see posts that reflect my emotions in the moment.

More personal. I’ve avoided most discussion of the more personal sides of life. I’m gonna dabble with extending that a bit more.

While this may not mean big changes for you, I think it’ll free up a few constraints that I’ve put on myself. So out with the old, and in with the new. I’ll talk to you soon.

–Tim

$100 Contest Winners Announced

Yeah. I’m way behind the times here, but Peter from the Ruby Inside blog announced the $100 Ruby Blogging Contest winners last week. And I got lucky enough to win the $15 second prize. True to his word, a little PayPal message came floating my way not long afterward. Thanks Peter!

I think the real value of this contest, though, is the wealth of great Ruby articles that it generated. Just take a look at all the finalists. Congrats to Duncan Beevers for winning the $100 prize with his article Using Simile Timeline with Ruby on Rails Views.

[Ruby] GroupWise export to iCal

UPDATE: I’ve posted a more complete version of this code in More Ruby Exporting of Groupwise to iCal.

I’ve wanted to export my Groupwise calendar to iCal format for a long time. Every time I try to do it, I ended up running into the same few pages. They sorta worked, but were clumsy.

So I threw this little beauty together in under 10 minutes and 2 google searches. It seems to be a start, though I expect to improve it. Groupwise Object API Docs (PDF format; the web version keeps blinking — arrrgh) from Novell were useful, as was this Ruby gem.

require 'win32ole'
require 'icalendar'

groupwise = WIN32OLE.new("NovellGroupWareSession")
# 2nd arg is not password, so leave blank
account = groupwise.Login("your-username", "")
path_to_host = account.PathToHost
cal = Icalendar::Calendar.new
account.Calendar.Messages.each do |message|
  next unless message.ClassName == "GW.MESSAGE.APPOINTMENT"
  event = cal.event  # This automatically adds the event to the calendar
  event.user_id = "tims@asrs.state.az.us"
  event.timestamp = DateTime.now
  event.summary = message.subject.PlainText
  event.description = message.BodyText.PlainText
  event.start = message.StartDate
  event.end = message.EndDate
end

puts cal.to_ical

Every day I find more reasons to love using Ruby. Enjoy!

Ruby Infiltration

Ruby has been a growing blip on my radar for a while. In this show I describe my first real production Ruby application at work — and it’s small enough to talk about a few details. I cover how we use Ruby to automate some interactions with Subversion and Maven. I’ve done some Rails stuff too, but that’s a whole different topic. Conclusion: Ruby should be something you use to complement Java. If you want a Ruby vs. Java fight, you won’t find it here.

Some great resources metioned in the pocast are Programming Ruby and Agile Web Development with Rails.

Download Ruby Infiltration.

Listen now with the Flash player.