Tuesday, March 31, 2009

Simple Navigation Plugin for Rails

Over the last two weeks, I've been working on the simple-navigation plugin which you can use to create the main navigation for your rails app.

In the last year, I built several apps and had to repeatedly implement similar code for creating a navigation. Thus, I thought it would be helpful to have a plugin which generates the code for the navigation and can easily be configured.

Please check out the online demo on simple-navigation-demo.andischacke.com or checkout the wiki on github.

I'd appreciate your feedback on any missing features or bugs, just go to the simple navigation discussion group or leave a comment here.

Update: This post is about an old version of the simple navigation plugin. Please see this post for the new version.

Update: The gem is now ruby 1.9.1 compliant (as of version 1.3.1)

Thursday, March 26, 2009

Select the first n lines of a file

On linux, to select the first 1000 lines of a file and write it to another file use

head -n1000 file_name > new_file_name

Remove the first line of a file with sed

If you need to remove the first line of a file use (on linux)

sed 1d file_name > new_file_name

Convert a file to UTF8

On linux, if you want to change the encoding of a file from ISO-8559-1 to UTF8 use

iconv -f ISO-8859-1 -t UTF8 file_name > new_file_name

To get a list of supported encodings use

iconv -l

Tuesday, March 24, 2009

Problem with rcov and ruby 1.8.7

I'm running ruby 1.8.7 and got the following error when running rcov (

usr/local/lib/ruby/1.8/rexml/formatters/pretty.rb:131:in `[]': no implicit conversion from nil to integer (TypeError)

To fix it change the following line in lib/rcov/report.rb of your rcov gem

if RUBY_VERSION == "1.8.6" && defined? REXML::Formatters::Transitive

if ["1.8.7", "1.8.6"].include?(RUBY_VERSION) && defined? REXML::Formatters::Transitive

With that modification rcov runs without problems again.