01.29.08

Book Recommendation: The Rails Way

Posted in Uncategorized at 12:53 pm by JohnB

The Rails Way is a Ruby on Rails reference book that I bought on Josh Susser’s recommendation.  I’ve actually, to my family’s dismay, been reading the darn thing instead of just referring to it like one would a, well, reference book.  A lot of Rails’isms that I had a vague idea about I now understand with much more clarity.  It will definitely come in handy soon when I start my new job writing mostly RoR code!

01.25.08

Using Ubuntu

Posted in Uncategorized at 3:18 pm by JohnB

I’ve heard that dual-booting Ubuntu linux was easy but its really true. I’m now running Ubuntu and it was as easy as various blog posts have said. The longest step in the process was defragmenting the drive before repartitioning with Ubuntu. There are a few issues remaining around using the data on the Windows partition from Linux, but on the whole I’m very happy with the switch.

[Update 1/29/2008: the network is inconsistent.  Upon a boot or un-hibernate it may be completely incapable of finding my router - but then later it is fine. I'll continue trying to track it down... using the Windows OS!] 

01.14.08

Xkcd Titles

Posted in ruby at 1:26 pm by JohnB

I’ve just noticed the geekily hilarious xkcd comic and one of the funniest aspects is that each comic has a ‘title’ attribute (the text that pops up when you hover your mouse over the image) that is often as funny as the comic itself. However, the length of the title often causes it to be truncated in my browser (Firefox 2.x, which probably has an obscure show-entire-title setting). Rather than arduously do a ‘view source’ on each one (or figure out the Firefox setting), I have Ruby do it for me. And for you if you want:

# xkcd.rb
# extract all the titles from xkcd comics since they
# tend to be too long to fully show in the browser

# USAGE: ruby -rubygems -rxkcd.rb -e 'Xkcd.new.show_all'

require 'open-uri'
require 'hpricot'

class Xkcd
  DOMAIN = 'http://xkcd.com/'

  def show id = 343  # 343 is the NSA/RSA one
    begin
      @hp = Hpricot.parse( open( "%s/%d/" % [DOMAIN,id.to_i] ) )
      (@hp / :img).each do |el|
        puts "%4d: %s" % [id.to_i, el[:title]] if el[:title]
      end
    rescue
    end
  end

  def show_all
    0.upto(400) do |i|
      show i
    end
  end
end

01.12.08

Jumping on the Bandwagon

Posted in musings at 3:06 pm by JohnB

I just have to wonder: who were the first two people to have “died in a blogging accident“?