mbg notes

Massive Brain Games developers notes

Unit tests on Google App Engine with JRuby

Posted by Ivan Schneider on April 17, 2009 at 10:03 PM

The App Engine totally fuels my blogging motivation ! In my last post I described how I set up my Sinatra app so I could deploy it on the GAE dev server and make changes without the need to restart it. That's fine for testing, but obviously you can't consider that refreshing your browser is testing. In other words, my next quest was to figure out how to write unit tests for my GAE/JRuby application.

Post continues, click to read more...

Writing Sinatra apps for Google App Engine, the productive way

Posted by Ivan Schneider on April 15, 2009 at 10:49 PM

Samuel Goebert did a great job at detailing how to deploy a basic Sinatra app on Google App Engine. I followed each of the steps and it worked like a charm. It naturally prompted me to go further and develop a real application on GAE with JRuby and Sinatra.

However the said blog post is just a proof of concept and once you start developing for real you have to face the fact that the setup described just won't do for efficient development. I couldn't imagine developing an entire app warbling and restarting the GAE dev server between each modification on any file. There has to be a better way, and indeed there is. I guess I'm not the first one to figure it out, since this is far from rocket science, however I haven't read it anywhere yet, so I thought I could take some time to describe the setup I came up with.

Post continues, click to read more...

Deploying a Rails app on a whale named JOnAS ?

Posted by Ivan Schneider on February 04, 2009 at 01:32 PM

Until then we've been working on Rails for our own projects that we are self hosting, happily switching from one deployment method to another. But everything has an end and in a few days we will have to work for a client who happens to have quite a strict production environment. This environment is thoroughly documented (37 pages to be precise) but the bottom line is that the application will have to run on JOnAS with a MySQL database.

Does this mean we're gonna have to code in Java or is there a chance we could call JRuby to the rescue ? I took a few minutes to check (alright maybe an hour from beginning to end) and as a matter fact deploying a Ruby on Rails application with JRuby on JOnAS is a quite straightforward process. I thought I'd take a few minutes to write down the steps to show Google and thus the whole world how trivial this is.

Post continues, click to read more...

A DB admin interface written in Rails

Posted by Ivan Schneider on October 21, 2008 at 08:44 PM

The Rails Rumble 2008 took place last week end and we took this contest as an opportunity to bootstrap a project we had in mind for some time. I teamed up with Jessy Bernal, with whom I am developing at Massive Brain Games, and Sylvain Utard, the creator of Live On Bankiz. The said project is a DB interface written in Rails and meant as a replacement for the classic phpMyAdmin. Not an extremely original idea I must confess but we found nonetheless a few reasons that motivated this project.

First of all, it's kind of annoying to install a php application on an otherwise ruby only server. We also find that the phpMyAdmin is quite old and gray, not really up to date with the latest javascript tricks we are all now accustomed to. Finally we thought there was some room for innovation by taking advantage of the different conventions Rails has set up for DB schemas.

With these two days of rush we were able to develop an alpha version of the product. We're fully aware that there are quite a few bugs and that it's far from complete. However it still makes an acceptable proof of concept which demonstrates a bunch of interesting features. You can check out the Rails Rumble deployment or watch the screencast.


rbDB web-based mysql admin with conventions from Jessy Bernal on Vimeo

We named the application rbDB and will soon opensource it. We hope that we'll find people interested in this project and that the first step they will take in supporting us will be to vote for our application on Rails Rumble.

UPDATE: rbDB is on github

Keyboard navigation for TextMate stacktraces

Posted by Ivan Schneider on June 29, 2008 at 11:49 PM

I love the fact that in TextMate almost anything has a keyboard shortcut or can be assigned one. However there is still one action that requires me to resort to the mouse; clicking the links in a stacktrace to get to the incriminating file. This led me to write this JavaScript snippet:

document.addEventListener('keypress', function(e){
    var key = e.keyCode
    if (key != 63233 && key != 63232) return
    links = document.getElementsByTagName('a')
    for (var i = 1; i < links.length; i++)
        if (links[i].title == 'focused') break
    if (i == links.length) i = 0
    links[i].title = null
    if (key == 63233){
        if (i == (links.length - 1)) i = 1
        else i += 1
    }
    if (key == 63232){
        if (i <= 1) i = links.length - 1
        else i -= 1
    }
    links[i].title = 'focused'
    links[i].focus()
})

It allows to navigate through the links of the html output with the up and down arrows and then pressing enter opens the file. I don't need the mouse for that anymore, mission accomplished.

I put this script at the end of /Applications/TextMate.app/Contents/SharedSupport/Support/script/webpreview.js. There might be a cleaner place to put this, but I didn't find it right away so I settled for this though I might have to re-paste it at the next TextMate update.