Skip to navigation.


Active Shipping

Posted April 21, 2008 —

Active Shipping is now available under an open source license. It’s on GitHub, here. Active Shipping is an extension for Active Merchant which I wrote to let Shopify users provide carrier-calculated shipping rates to their customers. You can easily include Active Shipping in your Rails project as a plugin (or in any other ruby project, for that matter) and start doing things like this:


It’s under active development and more details for contributing to the project can be found in the README.

Modified rss_reader Radiant extension

Posted November 08, 2007 —

Shopify news on www.shopify.com

Part of my work at jaded Pixel a few months ago was development and writing for a new “brochure” site at www.shopify.com. The current site, like the old one, is built with the fantastic Radiant CMS and uses a modified version of the rss_reader extension from BJ Clark, Loren Johnson, and Alessandro Preite Martinez.

We are using it to grab feeds that we publish in other places and re-display them to fit with the design of the site. For example our screenshots page is generated from our blog’s Shop of the Moment feed, and our list of supported methods for accepting payment is fed directly by Shopify itself.

Here is a modified version of the extension, available for your enjoyment and scrutiny:

rss_reader-0.2a-jadedpixelmod.tgz Just unpack with tar xvzf rss_reader-0.2a-jadedpixelmod.tgz in your Radiant app’s root directory and it’ll put the necessary stuff in lib and vendor.

Update: the extension is now on GitHub.

The modifications that I made add a few new features and, thanks to Tobi’s help, improved the robustness of the feed fetching code quite a bit. So for example, now you can order the feed however you want using a syntax similar to SQL’s ORDER BY:


You can also do headers to mark off sections:


This would show the code within the <r:feed:header /> tag if and only if the “creator” attribute of the item is different from the previous item in the list. Thus, it would only make reasonable output if the feed were ordered by creator with the above method. Another more obvious grouping for headers would be the item’s “date” attribute. Yes, the date of a feed item has hours and minutes and seconds, but I made it so that a new header only appears on new days of the month.

You can sort items and group headers by date, title, content, creator, or link (i.e. the URL of the item). There are a few other options for the feed tags that I haven’t mentioned here but which are documented within the code.

Facebook find: father-daughter moment

Posted June 01, 2007 —

A browser history for the command line

Posted May 25, 2007 —

I’m not a shell expert by any means. I’m certainly comfortable enough on the command line and can pipe I/O fairly effectively; however, I know very little about bash scripting, and irb and svn really cover the vast majority of my Terminal usage aside from the ubiquitous ls and cd.

Even humble cd has features which I had not initially fathomed: it was a wonderful moment when I recently saw Tobi use cd - to flip back and forth from the last directory he had visited. I had been vaguely yearning for a way to go back directories for a while, but never got around to figuring it out. This cd - thing wasn’t really what I was looking for, though, because what I wanted was the equivalent of the back and forward buttons in a web browser and cd - doesn’t have a memory of anything more than the last directory you were in, via the environment variable OLDPWD.

So I did some googling and found the necessary components to come up with something that is pretty darn satisfying.

How it works

I added three short functions in ~/.bash_profile:


Instead of its regular behaviour, cd is now mapped to a nifty command called pushd. This command takes a directory path as an argument and changes to that directory, just like cd does, but it also stores the new path in a stack stored in an environment variable.

It outputs the contents of that stack whenever you use pushd, but I don’t want to see it every time I change directory which is why I’ve redirected standard output to oblivion. STDERR is left untouched so if I type a nonexistent directory then I will still find out about it. The "$@" provides pushd with all the arguments I pass to cd separated by spaces, so everything stays the way I typed it; if I were to use "$1" here, then it would choke on directory names with spaces in them.

Now that we are building onto our stack of visited directories every time we cd anywhere, we can use this as a browser history for the shell:


bd is for “back a directory” and fd is for “forward a directory”. We are still just using pushd to manipulate the stack, but now we are using a different kind of argument for it. pushd +n will rotate the stack backwards n steps and change to that directory. We give n a default value of 1 when no arguments are passed to bd, and do pushd +n.

For fd, we rotate the other way. The default for n is now 0 and we decrement the argument by 1 otherwise because pushd -0 refers to the bottom element of the stack. If we go forward before going backward, it doesn’t care and will just rotate back to the first pushed directory (which is probably ~) and continue rotating from there, which is fine by me.

How it plays

So now I can go back and forward with bd and fd on their own, or do bd 8 to go back wherever I was eight directories ago and then maybe a little fd 3 to revise my search.

Each shell gets its own history which just accumulates and accumulates. If I feel like keeping a Terminal window open for a few years then I can do dirs -c to clear the stack. The way I have this set up, cd without any arguments will swap back and forth between the current and last directory as cd - would normally do, because that’s how pushd behaves when you type it by itself. Normally cd by itself would be the equivalent of cd ~, but I never used cd like that in the first place so I’m not missing anything.

There’s obviously room to modify this formula and use this wonderful directory stack in different ways. Here is a straightforward reference for the directory stack commands in bash. There’s also a few tilde expansions that reference the directory stack which some people might find useful.

The powerful Harpy Eagle can easily grab a monkey weighing 5 kg and fly away with it.

Oh and besides monkeys, they also tear apart sloths on a regular basis, for crying out loud. When I ponder what pure evil might be, I think I will now invariably picture one of these bastards.