Karl Söderström

KS

Spork and Localizations

After spending way too much time trying to figure out why my localizations didn’t work in a Rails 3 app, I realized that Spork was the culprit. Spork doesn’t automatically reload your localization files, so you need to add this manually to the Spork.each_run block in spec_helper.rb:

I18n.backend.reload!

After do so, changes to the localization yaml files will be picked up on the next run of the tests.

Octopress and Zsh

I decided I would revitalize my old blog to have a place to document things I encounter as a software developer. The natural solution nowadays is of course Octopress. So, after a quick git clone and some config editing, I was ready to create a test post.

~/octopress ⮀ ⭠ master± ⮀ rake new_post["testing"]
zsh: no matches found: new_post[testing]
✘ ⮀ ~/octopress ⮀ ⭠ master± ⮀

After some googling, it seems that [] doesn’t work well in Zsh. Apparently, Zsh has some kind of Filename Generation that allows you to do some pretty interesting searches, for example matching files in subdirectories:

~/octopress ⮀ ⭠ master± ⮀ ls **/*markdown
CHANGELOG.markdown
README.markdown
source/_posts/2013-03-14-octopress-and-zsh.markdown

Or using [] in the normal regex way of matching any of the characters. Finding all .c and .h recursively in all subdirectory is then as easy as ls **/*.[ch]. No need to use find or anything, it’s right there directly in the shell.

The problem with octopress of course remains, but the solution is simple. Either escape the rake task (rake new_post\["testing"\]) or prefix it with noglob (noglob rake new_post["testing"]) to let Zsh know that you don’t want to use the Filename Generation.