CarFinder - Find your closest carsharing car

I am a big fan of the carsharing concept and I have been using the two largest providers DriveNow and car2go regularly here in Berlin since I discovered them a few months ago.

One thing I don't like about them is their websites. While the iOs and Android apps work quite well for finding a car, the websites were obviously designed not only for already registered users who want to quickly find a car, but also for prospective customers, press, investors etc. They contain a lot of clutter and the DriveNow website does not even make an attempt to determine your current location, so you have to zoom and swipe the map manually every time. Especially irritating since you want to reload the map repeatedly sometimes when on the hunt for the closest car.

After getting annoyed with their websites once too often I decided to do something about it.

Read on

Skimlinks - Access the Skimlinks product database from Ruby

The current project I'm working on, ProductWidgets, lets you add affiliate products to your website effortlessly. It is backed by the Skimlinks product database that lets you access 25 million products from over 4,000 merchants in 54 countries.

Skimlinks offers powerful APIs to access their huge database of products and merchants. I extracted the code I use to access these APIs to a Ruby gem for everyone to use. You can find the code and installation and usage instructions on Github.

Read on

Tries - Solidify your code and retry on petty exceptions

I am always watching out for chunks of code that I seem to reuse in every new project and the "tries" pattern is definitely one of them. So finally I found some time to wrap it up into a gem and even come up with a nifty tagline:

Solidify your code and retry on petty exceptions

Read on

Create a cache key from method argument values

In my project ProductWidgets I'm using caching heavily and I happen to be in love with Redis and use it for everything I can. I also really like the concept of key-based cache expiration that 37signals recently wrote about.

Now, in a couple of situations I had to add a lot of variables to the cache key to make sure it caches the right thing. Have a look at this example:

def search(category, query, locale, page, per_page)
  cache_key = [

  Rails.cache.fetch cache_key do
    # Heavy lifting

It occurred to me that in situations like this, where I basically want to cache the whole method based on the arguments, there must be some automated way of doing this where you don't have to add each argument to the cache key. Imagine some other developer comes along and adds an argument to the method and forgets to add it to the cache key! I do not want to be involved in that bug hunt...

Read on

How to make everything background-processable through Sidekiq

I recently switched from Resque to Sidekiq for background processing in a project I'm working on. Sidekiq has a very slick feel to it and is basically a supercharged version of Resque, using threads instead of processed for its workers.

One thing that has irritated me when using Resque was that one was supposed to create separate worker classes for each job that should be processed in the background. While that makes sense for "real" jobs, e.g. syncing the Mailchimp database with your own or exporting some data into a XML file and mailing it out, often I just wanted to make an existing (class or instance) method processable in the background, e.g. user.perform_async :set_timezone_from_ip, request.remote_ip or Account.perform_async :disable_overdue.

Sidekiq offers the delay and delay_for methods to make class and instance method calls asynchronous, as detailed in their Wiki. It also says the following on that Wiki page, though:

I strongly recommend avoid delaying methods on instances. This stores object state in Redis and which can get out of date, causing stale data problems."

Read on

The road ahead for ShowSpace

I've been working on ShowSpace for more than 1.5 years now. It started off as an idea for a small web application but I quickly realized it had a lot of potential and started working on it more and more and calling it a "startup". It certainly wasn't always easy because I chose to do all development and marketing myself, but I learned a lot along the way!

Over its lifespan, ShowSpace has undergone lots of minor and a few major changes: for example, it was first focused on storefronts instead of widgets. A storefront was basically a store without a checkout, where all the products were affiliate products that linked to the merchants where you could actually buy them (some storefronts are still online). I also experimented with different pricing models, initially focusing on monthly payments before switching to "pay-as-you-go" product packages.

All in all it was an incredible learning experience and I have grown as a developer as well as an entrepreneur. I can certainly much more appreciate the amount of work that goes into launching a product, finding the first few users, and adapting the product over and over as you grow.

Read on

How to install and secure MySQL 5.5 from source with Sprinkle

I recently fell in love with Sprinkle as a way to provision servers for Ruby on Rails applications. I had heard about Chef and Puppet a long time ago and I knew that at some point I would have to start using one of them if I didn't want to do the same repetitive tasks over and over again.

The thing is that I actually enjoy working with a new and fresh server! It's that new car smell and you know you get to set up the latest and greatest everything! Still, after doing it multiple times in the last months, I realized the time had come and I set aside half a day to get down and dirty with Chef.

I picked Chef because I had seen that Ryan Bates of Railscast fame had done an episode on it and I normally trust him and have never been disappointed in his sense of picking the best tool for a job.

Read on

How to upload your Gmvault backups to S3

Gmvault is a great tool by Guillaume Aubert that makes it easy to create a backup of your Gmail emails on your local disk. It is cross-platform (Windows, Mac OS and Linux), supports incremental backups and handles errors that occur during the backup gracefully.

I have been looking for a tool to take automatic backups of my Gmail account for a while and Gmvault fits the bill. What I also wanted was a way to store the backed up files safely on Amazon S3 so I could recover them even if my local disk failed. This functionality is not included in Gmvault but it was quite straight-forward to code.

Read on

How to compile custom Sass stylesheets dynamically during runtime

Update January 15 2016: As someone pointed out in a comment on the gist, this method doesn't seem to work anymore with recent versions of Sprockets.

Update May 29 2013: The name of the stylesheet files was changed slightly (hyphen replaced by underscore) after feedback in the comments.

In any Rails 3.1 (or newer) app where the user can change the style (e.g. layout, colors, dimensions) of certain items you come to the point where you wish you could use all of the sweetness of the Rails asset pipeline to generate custom stylesheets dynamically during runtime.

After a bit of googling I realized what it comes down to is imitating the process Rails performs when precompiling all assets on deploy, only that we want to want to compile Sass code that was generated dynamically, not read from a static file in app/assets/javascripts. After having a look at the assets:precompile Rake task which does the heavy lifting it's clear that Sprockets::StaticCompiler is the main suspect in this case.

Read on