Saturday, April 3, 2010

Code Snippets in Blogger!

I finally found a way to put code snippets into blogger. Thanks to Carter Cole for his Awesome Syntax Highlighting Made Easy post.

The trick is using a brilliant javascript/css hack by Alex Gorbatchev.

Thanks Guys!

Now if only google would build something like SyntaxHighlighter into blogger, so we don't need to hack blogger just to post code to our blogs!

Stupid Rails Gothcha 00

Ok so, its another of those situations, where I spent way too long trying to track down strange behavior in my code, and I don't want to repeat the process. So I'm writing it down to help myself remember. And maybe just maybe someone else will find this post and save themselves a couple of hours.

So here's the situation I have two very similar views for different models. On one the footer mysteriously shows up in the middle of the page and the other works fine with the footer showing up at the bottom like it should.

It turns out that rails views, at least ".html.erb" ones, cannot handle comments in
<% %>
blocks. I had code like:

<% for @collection.each do |thing| %>
    display thing ...
<% end #each %>

Which caused the footer in the middle issue. When I changed it to:

<% for @collection.each do |thing| %>
    display thing ...
<% end %>

The view was fixed and the day was saved! What the fuck rails, comments should never ever break things! Grrr, anyway live an learn and remember no comments in your views, lest the rails daemons become angry.