Archive for the ‘tech’ Category

RockyMountainRuby 2013

Wednesday, November 6th, 2013

Rocky Mountain Ruby 2013 was at the end of September this year. I taught a workshop on writing external DSLs that was fun and difficult to put together. You can look through my class notes, if you are interested.

I also gave a short lightning talk on Muskox, a small library I’ve been working on. The talk’s up on Confreaks / YouTube now, which is awesome. The TL;DR is that populating input data structures willy-nilly from some generic language like JSON or especially XML can be dangerous, so you should prevent bad data from entering your system during parsing.

Dreamhost Passenger Sinatra or more yak hair

Friday, January 30th, 2009

In my ongoing adventures with Sinatra and shared hosting, I have discovered a number of new ways to shave a yak.

My preblog project warmup has been taking shape over the past week or so as a microapp that scrapes my library account and gives me a convenient way to find out whether I have any books overdue or any holds that are ready for pick up. The actual application was easy. Use scrubyt + modifications(firewatir is not a good dependency on a server) to login, grab my checked out books, etc and store them. Then, serve that info up on a simple web page.

The Problem: dependency hell + funny runtime environments.

Initially, I had bmizerany’s sinatra- vendored, because I wanted to be one of the cool kids and grab things off github. It worked beautifully, ran nicely, specs passed–on my machine. On the server, it kept giving me this error

Exception NameError in Passenger::Rack::ApplicationSpawner (uninitialized constant Rack::MethodOverride)

After some searching, pain etc, I discovered that the problem was that the rack on dreamhost is 0.4 and sinatra0.9.x.x uses rack 0.9+. So, I tried installing the new rack locally and using the GEM_PATH env to pick it up. Unsurprisingly, this failed. I tried a number of different tactics like using the apache setEnv directive and using ruby’s ENV hash. None of it worked.
Eventually, I gave up on getting 0.9.x.x running and replaced my vendored copy with 0.3.3

$ sudo gem install -v 0.3.3 sinatra
$ cd /path/to/app/vendor
$ rm -rf sinatra
$ gem unpack -v 0.3.3 sinatra
$ git add *
$ git commit -a -m 'downgraded sinatra'
cap deploy

I had to change my to be sensical to sinatra as it was, but it worked.

Somehow that doesn’t sound as annoying as I found it. I spent several hours working this out, and now it works more or less perfectly. Passenger can’t run the scraper because scrubyt also requires hoe >=1.5.0 which dreamhost doesn’t have in their shared gems(theirs is 1.2.1). It can’t see my local gems, but I set up a cron job which should run as me and thus be able to see it.