11 Feb 2014
Last year I switched from Windows to Linux Mint as my main operating system and wanted to install a Ruby version manager.
I weighed up the pros and cons of what was available and eventually opted for rbenv as it seemed more lightweight, would let me compile my Rubies myself and (in contrast to RVM) didn’t come with any way of managing gems.
I searched Google and came up with a couple of tutorials to follow, such as this one and this one which described how to install rbenv, but unfortunately they didn’t work for me.
More …
07 Jan 2014
At work, one of the applicants to our programme submitted parts of her application in Russian (despite it being an English speaking programme).
The database could handle this fine, as it stores entries using the UTF-8 character set, but the PDF generation part of our application refused to cooperate (just displaying a bunch of underscores).
We use the Prawn library to generate our PDFs, so I set about finding a way to make Prawn play nice with the Cyrillic characters.
More …
19 Dec 2013
I recently installed the 64 bit version of Ruby 2.0 on my Windows 8 machine.
All of my old projects I tested with it ran just fine and the world was a happy place.
Then I had to install Rails, so that I could make some minor changes to an existing app… and the pain began.
More …
12 Dec 2013
Imagine you have an element which is dynamically added to your web page (an image in a lightbox, for instance) and you want to centre it on the screen both horizontally and vertically.
You could do so with CSS (as this article explains), but if you don’t know the dimensions of the element you want to centre or you need to support older browsers, things can become quite tricky quite quickly.
That’s when you should think about doing the job with JavaScript.
More …
30 Nov 2013
I recently helped someone with a project where they had to select a bunch of records from a database, then on the client side use AJAX to filter those records according to certain criteria.
This was a fun thing to work on and a good opportunity to demonstrate the power of AJAX, so I thought I’d write it all up in the form of a quick tutorial.
For the impatient among you, here’s a demo of what we’ll end up with.
More …
15 Nov 2013
I was recently working on a project and realised that I needed a file that I had long since deleted.
On the one hand, this wasn’t very tragic as I had the project under version control using GIT. However, finding the exact command to restore a single file from a rather old commit proved to be a little more difficult, so I thought I’d make note of it here.
More …
22 Oct 2013
The other day my colleague mentioned that she’d like a simple calendar on the front page of her website. This didn’t sound too difficult, so being a nice chap I said I’d take a look.
Unfortunately, it turned out that my colleague works with this rather rigid content management system and beyond a few pre-defined widgets, she didn’t have the ability to alter much on the page.
On closer inspection however, I found that one of these widgets allowed us to create arbitrary HTML elements, as well as to include script tags. This sounded like a perfect case for a jQuery plugin…
More …
10 Oct 2013
Today I got a phone call from a relative, who was rather annoyed that Yahoo! had upgraded their mail interface.
She complained that she didn’t like the way that conversations were now arranged and that she was generally confused by the changes.
While I quite like the new look myself, I can appreciate that others might not, so I had a look at what can be done.
As it turns out, switching back to the old version isn’t so difficult. Here’s how to do it.
More …
30 Sep 2013
I was recently working on an application, that lets people from all over the world apply for a programme at the place I work.
The application works well and does what it should, but we were seeing quite a lot of double submissions, that is to say, the same person applying multiple times in short succession.
Here’s how I fixed that.
More …
12 Sep 2013
The problem: you have a RESTful resource with default routes. The form to create a new item is located at http://mydomain.com/resource/new/
. When you submit the form with valid input, a new item is created and that works fine.
However, when you submit the form with invalid input, the controller re-renders the form and the URL is changed to http://mydomain.com/resource
. This is potentially confusing for end users.
How can we avoid this?
More …