Posts Tagged ‘ruby’

On not knowing _why

Wednesday, August 19th, 2009

Some­time this morn­ing, Why the Lucky Stiff basi­cally erased him­self from the Inter­net. He deleted his Twit­ter & Github accounts, as well as took down the sites at his var­i­ous domains, includ­ing his mas­sively influ­en­tial “Why’s Poignant Guide to Ruby.”

Of course, what you don’t know is why he did it. And nobody could know that unless/until _why him­self decides to come back and tell us, for lack of a bet­ter word, why. Nat­u­rally, that hasn’t stopped folks from guess­ing out loud. At the moment, the pre­vail­ing “wis­dom” in the var­i­ous threads on Hacker News is that _why’s dis­ap­peared him­self as a response to his iden­tity being dis­closed last month. If that’s the case, then I humbly encour­age those respon­si­ble to for­ni­cate them­selves with some­thing rusty. There were no death threats involved, so we’re not at the Kathy Sierra level of offense, but the end result for the web com­mu­nity is the same: some­body who obvi­ously cared a lot about mak­ing the web a bet­ter place for every­one has decided it’s not worth the abuse.

It should be pretty obvi­ous why I don’t feel par­tic­u­larly inclined to link back to any of the trolls out there who, even if they’re not directly respon­si­ble for _why’s deci­sion, are directly respon­si­ble for the web being less of a great place to live and work. That said, I do want to point to John Resig’s “eulogy” for _why, mostly because I wish I could be as pos­i­tive as he is about this whole thing.

Links for June the Second, 2009

Tuesday, June 2nd, 2009
  • 1 line CSS Grid Frame­work — Dis­till­ing a CSS frame­work into one line is an inter­est­ing exper­i­ment, in that it shows essen­tially what all of the other (big­ger than one line) frame­works are doing. Also, if you look at the markup of a site that was built using it, it serves as a pretty good reduc­tio ad absur­dum against CSS frameworks.
  • jQuery Per­for­mance Rules — A use­ful col­lec­tion of best prac­tices that can speed up your jQuery code by non-trivial amounts. I’ll admit that I’m often guilty of stick­ing the bulk of my code inside of $(function(){...}).
  • jQuery: Inline caching for selec­tors — If you’re tak­ing the advice of the arti­cle linked above and caching your jQuery objects, take a look at this tech­nique for keep­ing those cached objects avail­able through­out your app with­out pol­lut­ing the global name­space (hint: it uses closures).
  • Procs And Blocks And Anony­mous Func­tions — Speak­ing of clo­sures, this is a decent run­down of the var­i­ous uses of clo­sures in Ruby.

Install Mongrel & Hpricot Under Ubuntu

Monday, March 24th, 2008

When­ever I do a fresh install of Ubuntu, and I’m set­ting up Ruby, Rails, I always run into the same prob­lem with a hand­ful of gems (such as Mon­grel & Hpri­cot). This is how things usu­ally go down:

matt@thinkpad:~$ sudo gem install hpricot
Building native extensions.  This could take a while...
ERROR:  Error installing hpricot:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb install hpricot
extconf.rb:1:in `require': no such file to load -- mkmf (LoadError)
from extconf.rb:1
Gem files will remain installed in
/usr/lib/ruby/gems/1.8/gems/hpricot-0.6 for inspection.
Results logged to
/usr/lib/ruby/gems/1.8/gems/hpricot-0.6/ext/hpricot_scan/gem_make.out

Now what? The main prob­lem here is that Hpri­cot and Mon­grel both con­tain some C code that needs to be com­piled. In order to fix this, you’ll need to install the Ruby & C devel­op­ment libraries for Ubuntu. To do that, just fire up Ter­mi­nal and enter:

sudo apt-get install ruby1.8-dev linux-libc-dev libc6-dev

You should now be able to install Hpri­cot, Mon­grel, or any other gem that requires you to build some C. It’s that easy!

Stupid Ruby Problem

Wednesday, January 9th, 2008

Like I said, I’m work­ing on get­ting my Ruby chops up to snuff. I thought it might be fun to do that by port­ing all of the code in Joseph Adler’s fan­tas­tic Base­ball Hacks from Perl to Ruby.

I’m com­ing back to this project after let­ting it go for a while, and sure enough, the prob­lem I was hav­ing when I put it down is still vex­ing me.

One script is intended to grab all of the play-by-play data from retrosheet.org. The files all have urls like this:


http://www.retrosheet.org/1957/1957al.zip

http://www.retrosheet.org/1957/1957nl.zip

http://www.retrosheet.org/1957/1957ml.zip

The snip­pet below is a sim­pli­fied ver­sion of the code I’m using to build the urls. It’s intended to print the urls of each zip file for each league from 1957 to 2006:

year = 1957
leagues = ['al', 'nl', 'ml']leagues.each do |league|
  while year <= 2006
    url = "http://www.retrosheet.org/#{year}/#{year}#{league}.zip"
    puts url
    year += 1
  end
end

How­ever, it doesn’t do that. It only gen­er­ates the urls for the AL files, and I can’t get my brain around why.

I’ll be sure to add the solu­tion when I fig­ure it out, but for now I wanted to just doc­u­ment some of the strug­gles of a Ruby n00b.