almost_geek, girl

Fixed bugs for fun. Rails BugMash

dira, August 14

Last weekend I took part in Rails BugMash – a ‘bug squashing’ event organized by RailsBridge.

From the beginning I found some ActiveRecord issues that seemed very interesting. What I learned is that digging through ActiveRecord is a lot easier in concept than through source code. Therefore, I managed to produce only a partial patch. The bright side is that it was a lot easier with tests, so I was more productive on this side.

Even if it didn’t add many points on my scorecard, the “ActiveRecord adventure” was indeed very interesting. Here are some useful tips for ActiveRecord testing:

  • recreate the tables after changing the schema: you have to do it yourself if running a single ActiveRecord test
  • looking for the SQL generated during a test? activerecord/debug.log
  • verify if an associated object is loaded? The way to do it depends on the realation type:
  • adding an ActiveRecord test? it’s preferred to reuse the existing models rather than create new ones. Even if some models look a bit abused after so much use :), I guess it’s better than having a couple of new models for every patch

I was impressed by the energy and collaboration in the (virtual) room: issue creation, verification, testing & patching seemed to flow from person to person. This meant that I got feedback fast on my contributions, which was great.

Big Kudos to RailsBridge for organizing the event and easing the ‘contributing to Rails learning curve’. It allowed me to use my Ruby & Rails skills to the max, even if it was the first time I contributed.

Back from Euruko 2009

dira, May 12

Euruko – the European Ruby conference – was in Barcelona this year. It was a blend of enthusiastic community and interesting talks, in two intense days, facilitated by wonderful organization.

This year, besides language/programming-oriented talks, there was an abundance of presentations about what you can do with ruby in various fields: games programming, image processing, system configuration automation, voip, mobile apps, music.

The lightning talks sessions were very popular – the 5 minutes format (and the terrifying gong sound) was ‘fast & furious’ – and the information overload was appreciated.

IMG_5048foto by Emili Parreño

I had a lightning talk about vimmish – presented what it can do and what I am working on now: generating random vim command strings, based on the grammar.

When I got to the part about parsing the vimmish grammar itself using treetop’s meta-grammar half of the audience was giving me facial hints that I did not explain that well enough (well, I had 5 minutes for all the talk.. :) ). But everyone understood what I meant when I got to the examples – randomly generated metal band names and manager speeches from the crazy italian site polygen.

Some people told me it was the geekiest lightning talk of the first day – not sure whether it was the topic, the fact that I delivered the presentation as a sequence tabs in firefox (don’t ever do that, you’ll mess the ctrl-tab under the merciless spotlights. twice.) or the polygen examples, or their effect combined :).

Next year, Euruko will be in Kraków, Poland – there were more than 20 polish developers this year and they were very enthusiastic about the conference. So, see everybody again next year, in Poland!

vimmish - vim translator

dira, May 07

Vimmish is a translator from VIM cryptic commands to human-readable explanations. I built it using a parsing expression grammar and the wonderful Treetop library.

The example:

So you can feed vimmish with a sequence of commands that you got from a cryptic guru, and it will tell you what it means. Here’s an example:

Input:
Output:

Cool! Now all that gibberish makes sense!

small-print disclaimer: while vimmish doesn’t cover (yet) all the possible commands, it is fairly powerful as it understands a lot of them (and combinations).

And what about these grammars..

If you’re new to grammars, you can think of them as regular expressions taken to the next level. That is, with power to express more things.

For example, with a regular expression you could search for all lines in a file that end with “;”:

.*;$

But you cannot build a regular expression that will tell you if a sequence of text is formed from parenthesis that are closed correctly (no one missing, no one extra, no one closed if there was not a corresponding opening one.. you get the idea). But you could do that with a grammar:

grammar OnlyParenthesis
  rule parenthesis_sequence
    ''
    /
    '(' parenthesis_sequence ')'
  end
end

The ‘/’ operator means “or”. So a parenthesis_sequence is either an empty string or a pair of parenthesis that contains another parenthesis_sequence.  This recursion is, of course, one of the key powers of grammars.

So according to this grammar, ” is correct, so is ‘()’, and so is ‘(())’ – it has a pair of parenthesis () that contain a string that matches the rule. But ‘())’ is not correct as the outer parenthesis do not contain a correct sequence.

Having a grammar that defines acceptable texts – that is, a language – you can build a parser that verifies whether a given string belongs to that language or not. This is exactly what the Treetop library offers.

And.. what are grammars _really_ useful for? Defining & parsing complex languages – think DSLs. Or, parsing vim commands :D – see the grammar.

Archive

  • Fixed bugs for fun. Rails BugMash
  • Back from Euruko 2009
  • vimmish - vim translator
  • Deploying a non-trivial app on Heroku
  • GMaps stub released
  • New friends, new enemies
  • Friendly URLs - reverberations