Tag Archives: ruby

Small TextMate tip

Here’s a small TextMate tip I discovered today. Normally, some TextMate functions don’t work too well with Ruby code. Word selection and keyword completion ignore Ruby-specific characters like : or ? or !. For example, if you used somewhere method like blank? and then you type bl and press Esc, TextMate will complete it as blank, ignoring the ? at the end. And don’t even get me started about when you double click blank? and the ? is not selected.

To change it, go to the Preferences (CMD-,) and select Text Editing tab. At the bottom, there’s an editbox labeled Word characters containing a single _ by default. Add characters :?! to this editbox, close the window and you’re done. Enjoy!

There’s one caveat, however. This setting is global and affects word selection and keyword completion in all files. If you edit many other types of files, that could be a problem.

Advertisements

Learn a new programming language

As many of the luminaries of programming say, you should learn a new programming language every new year. That’s what I’ve been doing for several years now. Maybe not that strictly to start on January 1st with a completely new language and lose all interest in it on December 31st, but learning new things (including new languages) is one of my favorite things to do. And since I can probably list more languages that I think I “know” than I have spent years as a professional programmer (whatever that means), I think I’ve been true to above mentioned rule.

Continue reading


Unstubbing methods in Mocha

Recently I needed to ‘unstub’ a method in Mocha. Browsing Mocha documentation and googling yielded no results. Apparently, Mocha doesn’t support a concept of ‘unstubbing’, i.e. recovering original implementation of a method that has been stubbed. After a little hacking, I found out that it’s quite easy (though not necessarily elegant) to call original implementation.

Continue reading


Looping in a no man’s land

…or: how to put class scope to use

The class scope, i.e. the space inside class declaration, but outside method definitions, is a no man’s land in many languages (particularly in Java). By this I mean that you can define methods, variables, and other classes there and you can even execute some code (in variable initializations) but nothing more. Fortunately, in Ruby empty space between method definitions can be filled with all kinds of useful, executable code. Let’s check a few examples.

Continue reading


Way beyond cool: autotest + growl + Doomguy

Here’s something that will amaze your friends to no end. Your male geek friends, that is. Type some code in your editor, save file and… a smiling Doom Marine tells you that all your tests passed. Or, if there were some errors, the Marine is bleeding. The more errors, the more blood. Is it cool or is it cool?

Just look at the screenshots. First: Marine is happy that your tests passed.

The Doom Marine is happy that your tests passed.

Next: there were some failures. The blood starts to flow!

The blood starts to flow.

Even more failures, even more blood.

Even more failures, even more blood.

Oh my, it looks like we killed him, we bastards!

Oh my, it looks like we killed him, we bastards!

How to do this? Read on.
Continue reading