Subscribe to

Archive for February, 2007

I’ve recently started to add XML support to a Rails application, meaning that the application provides data in XML format, if the request asks for it, and it understands XML data on create or update. To keep the application as well as myself sane, I’ve written a test that ensures the round trip of getting […]

The gem command is the command line user interface to the RubyGems system for managing Ruby packages. This command has a few sub-commands itself and a long list of options that differ per sub-command. Remembering and typing them can be tedious, but thankfully, if you are using the bash command shell, it can help with […]

Make your layout look good a different screen and font sizes. What it looks like Example 1, Example 2. Here’s what the form example (example 1) is supposed to look like. At 1024 x 768 pixels, the navigation links and Save button are positioned fixed in a column to the left. At 800 x 600 […]

On my continuing quest to become more Web-2.0-ish, I’ve tried my luck tilting at… well, tag clouds. To get an idea what I’m talking about, please have a look. These are the rudimentary basics to create a tag cloud like that. In the controller def tags @popular_tags = Tag.find_most_popular(:limit => 30) end In the view […]

Form Layout

I’ve looked at quite a lot of examples of form layout over the past two years. Invariably the demonstrations looked very pretty and were pretty primitive. Usually, all the input elements are lined up in a single column; labels are either stuck on top of the inputs or prepended to them. This is all well […]

Popular Requests

It was late last night. And the night before, I admit it. I also admit that I don’t know much about what Web 2.0 is all about, but there are two things that I do know: rounded corners are involved and, of course tags and tag clouds. Tagging is work, therefore ipso facto to be […]

Self-conscious Decoration

Variations on the Decorator Design Pattern in Ruby have already been discussed in several places. For my special purpose, none of these approaches works. The common problem with a decorator based on delegation is the lost sense of self. Method calls of the decorated object to itself are not routed through the decorator, therefore remain […]

Rails valid markup testing

Coda Hale has given the intersection of the Rails and web standards communities a very nice plugin for keeping your markup clean. It is aptly, if slightly pretentiously, named Responsible Markup. But let’s be honest, do you really want to spend much time on writing tests for your markup? After all, it’s taking long enough […]

In order to keep multiple versions of a file, I sometimes add a timestamp to the filename. Doing this by hand is tedious and error-prone, but this chore can be automated by a small shell script. /usr/local/bin/timestamp #! /bin/sh for oldname ; do ts=`date +’%Y%m%d%H%M’ –reference=”$oldname”` newname=`echo $oldname | sed -nre “s/^(\\.?)([^\\.]+)(-[[:digit:]]{12})(\\..*)\$/\\1\\2-$ts\\4/p”` if [ -z […]

ActiveRecord Enumerable

Ever wanted to iterate over a huge number of objects and found that find(:all) doesn’t cut it? Then this plugin might be for you. Install it with $ script/plugin install svn:// First, a note of caution. This plugin has not seen much practical use yet, in its current state it is only slightly above a […]

Fork me on GitHub