Archive for January, 2009

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.

Wii Fit w00t

Thursday, January 15th, 2009

After looking half heartedly for months. I found the amazon fitmob SMS service that lets you know when they have the Fit in stock. They sent me a message 5 min before I could buy it and then I went to the mobile site and bought it.


According to the Fit, I am 24 which isn’t bad I guess, since I am 23 1/2 really.

The balancing games are especially interesting in how they map actions onto a different control mechanism than I am use to. This one isn’t as intuitive as the Wiimote, but is almost as approachable. On the other hand, things that would be trivial to do using a regular controller become more difficult because they use a different set of motor skills.

The interesting thing is that I feel like though the low level mapping is different, the internal model of the game I am using hasn’t really changed–I am just using a, currently, less sophisticated system to drive my interactions than my hands. With practice, my wetware should adapt.
In other words, I should improve my balance using the Wii Fit.

Scanty Blog Development

Tuesday, January 13th, 2009

I am finally getting around to working on customising a little blog app for use on my site. I am still not quite sure what I want to do with everything, but getting a development environment up is the obvious first step.

So, I installed sinatra.
sudo gem install sinatra
and got this
ERROR: does not appear to be a repository
ERROR: could not find gem sinatra locally or in a repository

and went to look for a solution. I set my wireless access point, opened firefox and copied the error into google. A few forum questions later I realised my problem. I hadn’t been connected to the ‘net. Classic mistake. Like working for an hour trying to get a machine to boot and discovering the outlet didn’t work.

Or, more recently, that the problem I was having while trying to fence electric epee was not either of my weapons or my body chord, but the scoring machine( of course I didn’t check this until I had taken off my jacket twice and got all of my gear out of my bag).

So, I tried again and got this

ERROR: Error installing sinatra:
sinatra requires rack (~> 0.4.0, runtime)

I then installed rack
$ sudo gem install rack
Successfully installed rack-0.9.1
1 gem installed
Installing ri documentation for rack-0.9.1...
Installing RDoc documentation for rack-0.9.1...

But, it still gave me that error.

Argh. So, I googled around abit, and tried using
$ sudo gem install sinatra -y --debug
which told me that I was missing rack, which I had just installed, but also told me I was missing the ruby openssl library, so I tried installing that.
--debug gave me fewer errors but suffered the same problem.

So, I changed tactics. I knew where the current version of sinatra resided on github, so I looked up how to get a gem from github. turns out it is really simple:
add github to your sources
gem sources -a
and install the gem.
sudo gem install bmizerany-sinatra

After that, I just had to install sequel and thin and I was good to go(thin needed g++, which was not installed yet–fresh ubuntu install).


Now I just need to put all the pieces together. and use the import script.

Blogging is hard

Sunday, January 11th, 2009

The problem I have is pretty typical, I imagine. You start with the goal of writing something witty and hopefully interesting, and you sit in front of the screen and wait for ideas. The problem with this approach is that there is no context. The solution space is too big and you find yourself stuck, looking at a continuum of possibilities that is truly challenging.

When that happens, I write about writing.

I have never felt that I was particularly good at writing. Except for a brief period around middle school where I wanted to write science fiction. I started a story, wrote something like 11 pages, but I became bored with it, or maybe just felt I was at the point where I needed more structure.

It is always hard to come up with new things to say. It takes time or a spark, but once it starts and you get in the flow, it just comes. Programming works like that for me sometimes too. It is like writers block. I can see the problem, but it is just a cloud–an abstract set of possible needs and uses for the application. And, when the problem space is ill defined, so is the solution space.

Part of the problem is my knowledge of my abilities with regards to building software. I know that I can build almost anything( we build compositions of thought stuff), given time and a good plan. But, being able to build anything is different from building the right thing. I get caught up in the good that it is nigh impossible to build the good enough.

I figure I am not the first to face this issue, after all isn’t that the point of YAGNI, and things like BDD. Divide and Conquer yes, but first and formost start!

So this is a problem I have had with writing for longer than coding, and I deal with it in the same sort of way. Just start. At some point I find that I know enough, or I have the first word(or leaf of a synatx tree as it may be) and I just start working.

This not knowing enough to narrow the options is a problem that stops me from doing as much testing on my code as I would like to. I want to use BDD, etc, but I have a tough time discerning where I should use acceptance tests vs specs. But, I am dealing with this, by reading more docs and by reading more code. I don’t really like the tutorials that I see about testing for the most part because they don’t have any real meat. So, I have been surfing github looking for projects tests and reading them to get a feel for how others use them.

As a side effect, I am reading more code and becoming more familiar with others styles, which is never a bad idea.

What I am reading now

Friday, January 9th, 2009

Tired, and unable to think of anything else for today’s post, I thought I would share what I have been reading over the past few weeks.

  • The Blank Slate — Stephen Pinker I read how the mind works last year and wanted more. It was fun, but whenever he wrote about things he didn’t know much about, there were problems.
  • Godel Escher Bach — Douglas Hofstadter The classic, it covers many concepts important in cs and elsewhere. I am taking my time to read it, because I want to go through the exercises in it and thoroughly grok it.
  • Bill of Wrongs — Molly Ivins and Lou Dubose Makes me feel that most dangerous of emotions, righteous indignation. Molly Ivins will be missed, is actually.
  • Tom Strong — Alan Moore one of the best comic writers creating a science hero who has adventures in styles that span the life of comics itself. Or something like that. Mostly, its fun.
  • Code Generation In Action — Jack Herrington
    I haven’t really learned anything new from this book, but that was more or less true of the Pragmatic Programmers Guide too. Reading about building code generation helps me to see when it might be useful and what its limitations are.
  • And that is a small selection of the dead tree media I have consumed recently. My internet meanderings will have to wait for another day.

Music, Well Learned

Thursday, January 8th, 2009

I got a harmonica for Christmas. The first thing I did, after blowing enthusiastically for a bit, was to try to play some scales. That got me thinking. I first learned about scales probably in preschool when I was in the ‘oh, aren’t they so cute’ chorus. We’d dress up in greens, reds, blacks and whites and make loud noises following Mrs Caroll’s playing the piano. We had fun, made a lot of noise and were not particularly musical.

Later I took piano.

I didn’t really appreciate it at the time, but learing to read music was probably one of the better things my parents made me do. I liked to mess around with my mom’s guitar and the piano we had. But before taking those lessons, my ability to do much more than bang on the keys was rather limited.

I quit piano after, I think, a year or two. I don’t really remember, I didn’t practice enough. I stuck with singing though.

I continued to sing in chorale through high school and College, practicing here and there but mostly relying on my ear and my sense of music to get me by. That is until I started voice lessons. The thing about individual lessons at the University level is that they expect you to practice. And they expect you to get better and will tell you if you aren’t cut out for what you are doing.

So, I practiced everyday and I got better. I spent thirty minutes every afternoon running through my pieces, finding their hard parts practicing them and folding them back into the piece as a whole. Ater discrete math one semester and japanese another I would cross campus to the music building, sit in a practice booth and play my parts.

I intentionally and methodically worked my way through two years of voice and at the end I found that playing piano was easier than it had ever been for me. Becoming good at the piano was a side effect of practicing my voice music everyday.

That sort of relates to my as yet unstated goal for this blog, which is to write a post in it every day. The truth is, I need the practice. And, I wonder what kinds of things I will learn along the way, through writing and publishing something everyday.

Besides, trying to keep my qwerty and dvorak straight of course.

guitar hero, undo, cellular automata

Wednesday, January 7th, 2009

So, I finally broke down and bought guitar hero for my Wii. It is the new one, world tour. It is fun, but I have noticed some problems. It is kind of slow to load new things, like hats, hairdoos guitar knobs etc on the customization pages–er screens.

Speaking of slow, sometimes the menus will freeze while they load something without telling you anything about it, until–bam–a number of things have changed. I think this is a problem that most developers who build interactive systems deal with (hopefully successfully) from time to time.

My favorite bad behavior of the slow to respond sort is where all the users actions queue up while the system is thinking and something bad happens. Then you WISH the silly developer had implemented undo.

Back to what I was talking about to begin with: Guitar Hero.
Pretty awesome as is. Rhythm based gaming finally making it big in the states.

I had a weird thought while playing through La Bamba today. I wonder if you could map a cellular automata to an interface like guitar hero’s a rhythm game. Sort of like the musical computations in anathem, only with rock.

strange idea.

Jssh firefox ubuntu 64bit

Tuesday, January 6th, 2009

So, crazy webdev that I am, with my minor ruby obsession and an interest in doing more testing/specing stories etc, I found this interesting thing about using cucumber and firewatir together as a BDD friendly concoction.

So, there I was following the installation instructions for firewatir, when I ran across jssh (the javascript shell interface for firefox). Now, it is pretty cool, but it doesn’t play as well with Linux as it should. I faithfully followed the instructions and blamo — nothing.

So, then I did what any self respecting geek would — I looked it up on Google. There I found several ways of dealing with the problem, most of which involve compiling jssh into firefox from source. It is called minefield for a reason.

The earlier link didn’t work for me. I got a buffer overflow error, which some searching led me to think it might have something to do with using a 64bit os — don’t know why exactly.

So, I did more searching and delved into mozilla’s build docs. Turns out the method for compiling things has changed somewhat — depending.

What Worked for Me

Mostly, I followed the Simple Build instructions.
The main change I made was to use the .mozconfig and the make call from the earlier instructions.
Something like

hg clone -r default
cd mozilla-central
# Configure
cd js/src ; autoconf-2.13 ; cd ../..
make -f build

Still Alive

Monday, January 5th, 2009

Happy new year everybody.

Its been a long time since I last posted on this blog and much has changed.

  • I’ve graduated from the University with my BS in CS and Minor in Japan Studies, etc.
  • I moved to Illinois to live with Sara while she goes through library school and started working at Wolfram Research

That was a much shorter list than I thought. More then that has happened of course, but those are the two big things.

I have adjusted to living here mostly, but it is too flat and though I am about a mile from one of the premier CS campuses in the US I have not gotten to know any new geeky friends besides my coworkers(though there is nothing wrong with them)

My goals for this year (gotta list them, its new years)

I want to become a better Software Developer(who doesn’t)

I have gotten caught in the daily grind too much and let some of the things I should be practicing/learning go for a while. Well, vacation’s over. I had my months of cooling off after the hell that was my senior year(figuratively speaking). Now, I want to something to do for myself.

One of those things is this site, which is currently languishing in a lack of attention from me.
I had this grand plan of writing my own blogging software as an exercise, but having looked down that road afew times and gotten lazy I think I will compromise by moving to something more my style–like scanty.

Get Back in shape

I have put on a bit of weight over the holidays–stopped fencing for a while, stopped biking to work once the air got too cold–and now I need to get my systems back up to par. Better weather will help, but I really need to find more activities that I can do in cold weather.

Play some damn music

I got some good pipes, I like chasing after oral nasal resonance as much as the next man, but lately I have been out of the loop. This happened to me when I was in Japan too. Maybe I need 6 months in a place before I get sick of just being/exploring and want to get back to doing those things I can’t do without.

I play the guitar too.

Become more electronically social

Better living through electronics, and better friend tracking too(is that creepy?). Facebook sucks, but atleast some of the people I know are on it.

For a while I was somewhat active on the ruby usegroups. I learned alot about ruby from that experience. I should do more stuff like that, maybe through stackoverflow.

Twitter. I have less than 100 tweets and I have been on since march, whats up with that?

This blog counts too. I would like to post everyday–need to set up a time.

Through all that, I need to be myself, or atleast a reasonable simulcra thereof.