Posts Categorised as: Projects

Using Passenger with RVM and Sinatra

Posted on: Apr 04 2011

After making the move to Linode (finally!) I had some issues with getting the contact pages on this site and Penderry up and running. RVM was throwing an error about the sinatra gem missing. A quick scan of the error message and it was obvious that Passenger wasn't using my gemsets.

A bit of googling turned up this little snippet which, when placed in app/config/, will tell RVM to use the gemset associated with the folder.

if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')  begin    rvm_path     = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))    rvm_lib_path = File.join(rvm_path, 'lib')    $LOAD_PATH.unshift rvm_lib_path    require 'rvm'    RVM.use_from_path! File.dirname(File.dirname(__FILE__))  rescue LoadError    # RVM is unavailable at this point.    raise "RVM ruby lib is currently unavailable."  endend

Jekyll is a fantastic static site generator with a great little community of modifications around it and I've used it for my own blog and Penderry.com. However my biggest problem with it is the lack of a way to deal with a contact form. Of course, this really isn't Jekyll's fault as it's only built to create HTML pages.

Enter Sinatra stage left.

Sinatra is a rad little web framework, well a micro framework really - in fact it's so small the Hello World app is 5 lines long! It's also perfect for creating a contact form.

To combine the two I needed both of them to display the same layout since I didn't want to have to maintain two. The contact page needed the same layout as the portfolio page, so no sidebar. The easiest way to do this is to plug your Sinatra application into Jekyll's layout mocking up any Jekyll specific objects/variables you need to (like page). I did give using a header and footer includes a go but it broke validation, pah.

A New Year, A New Blog

Posted on: Jul 04 2010

One thing I've noticed about coders on the internet is how many of them rebuild their blogs almost as a matter of habit and unsurprisingly I'm no exception. I've build three blogs, I only really have three posts...says it all really doesn't it? So here is my new blog!

This one is built using the static site generator, Jekyll, modified with some useful extras by my good friend RichGuk. A full list of the extras he added can be found on his Github page. The benefit of using Jekyll, for me, is the simplicity the system provides. I can create posts in markdown, haml or even plain HTML, let Jekyll convert it into an HTML page and view it locally using the built in server Jekyll provides. Since the whole thing is tracked in Git I can push new posts to the remote web-server where a hook is setup to run the Jekyll build command, thus automating the whole thing!

Tv Renamr - Finally

Posted on: Aug 03 2009

For the last few years I've always wanted to create a program that renamed the TV files I had into the nice neat format that I seem to spend so much of my spare time doing manually. Well, on my birthday I decided to take the plunge, stop talking about it and get my arse in gear. On that day, 22 years after my mother labouriously gave birth to me Tv Renamr was created in what I have no doubt was a far less spectacular fashion than the miracle of child birth. I started off with a short script in Python with various bits taken de facto from the internet. It sort of worked, as long as your files were in the correct format to begin with, which was a pretty narrow groove for your files to be. Which of course mine weren't.

Fast forward to a few months later and roughly the present day...