EC Vies, IPv6 and Savon January 2nd, 2013

I’ve been struggling for the past few hours trying to get the VIES service of the European Union to work with Savon (Ruby SOAP library) in production. It worked in development but timed out in production, and I soon figured out it was only happening when IPv6 was enabled.

The response I would get when requesting the WDSL on IPv6 was a proxy timeout

* About to connect() to port 80 (#0)
*   Trying 2a01:e0b:1:143:62eb:69ff:fe8f:16e6... * Connected to (2a01:e0b:1:143:62eb:69ff:fe8f:16e6) port 80 (#0)
> GET /taxation_customs/vies/checkVatService.wsdl HTTP/1.1
Accept: */*

* HTTP 1.0, assume close after body
< HTTP/1.0 503 Service Unavailable
< Cache-Control: no-cache
< Connection: close
< Content-Type: text/html
< Content-Length: 310
* Excess found in a non pipelined read: excess = 20, size = 310, maxdownload = 310, bytecount = 0
* Expire cleared
* Closing connection #0
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<h1>Erreur 503</h1>
<h2>Erreur proxy ipv6</

Yet, when I would do the same request with the curl command-line tool I got the correct WSDL. The only difference was the User-Agent, and apparently that was the issue! When I added something in the User-Agent header, the request fell trough. So I changed my SOAP setup to this: do
  wsdl.document = ''
  wsdl.namespace = ''

  http.headers['User-Agent'] = 'Factr Soap Client'
  http.open_timeout = 2
  http.read_timeout = 2
tags: , , , , , l 1 comments »

The Big Leap October 15th, 2010

Today was my last day at Openminds!

As some of you know I’ve been working with Openminds, a Belgian hosting and development company, for about 4 years now. I was their first employee, when the business was still vested in a small condo, and I’ve grown with it while the company moved 2 times to bigger locations, and only got bigger and better. I already knew my way around computers, but during my time at Openminds I learned a whole lot more about servers and hosting. I also met Ruby and Rails there, I got to learn it, and I can say I’ve become a professional Ruby programmer now. I’ve also enjoyed working with the colleagues there, who are all the best at what they do.

But now it’s time to take the big leap, and no longer take the safe bet of being an employee. From now on I’m an Entrepreneur! A few months ago my colleague Jens asked me and Tijs to start a new business with him, and after some days I was sure now was the moment!

We’ll be doing what we’re good at:

  • Consultancy in web-applications, from starting a new app to rescuing a dying one and optimizing an existing one.
  • Convert good idea’s into full fledged web applications
  • Give regular web applications an awesome mobile interface.

I will be responsible for the Ruby-department of this story, with Ruby consultancy and Ruby development. I’ll also share my expertise in server-setups with our customers.

The first weeks of this plan we were known as Unnamed BVBA, but as of today we’ll be known as SumoCoders, where we’ll wrestle applications and code like real rikishi (wrestlers, “literally men of power”)

More info (in dutch) on our website

tags: , , l

Make javascript docs googl'able September 27th, 2010

JavaScript JS Documentation: JS Function arity, JavaScript Function arity, JS Function .arity, JavaScript Function .arity

You can make Javascript docs better too!

tags: l

iPad AppStore disillusion August 2nd, 2010

A few weeks ago Apple launched the iPad in 9 more countries, including Belgium. Ever since they first came out and the first reviews appeared I have been wanting one, and I had placed a pre-order from the moment it was possible. So the friday it launched, I got an e-mail from the local Apple Reseller saying they had one in reservation for me. I picked it up and have been happy with it ever since.

First thing I did when I got it was copy over all the applications I use and love on my iPhone. From what I knew from Apple I figured most apps would have been made iPhone and iPad compatible, but to my surprise not a lot of them were. When I looked into it in detail I saw a (to me) shocking trend: Most apps I have bought on the iPhone do have an iPad version, they’re just new apps.

iPhone version

iPhone App

iPad version

iPad App

If you look in the store you’ll find a bunch of these “appName” - “appName HD” pairs. I’d be fine with that if HD versions came with new features, new modes, … But most of the time, it is just a graphic update, changing the resolution from iPhone to iPad size.

I had expected most of the developers to make their applications iPhone and iPad compatible, to give an “as good as it gets” experience to the users, but apparently the developers are going for the easy buck, trying to squeeze some more money out of the same app.

tags: , , l

Inlining CSS in ActionMailer 3 (Rails 3.0) July 8th, 2010

As most of you already know, a bunch of online mail readers (like Hotmail, Gmail, …) don’t handle stylesheets very well, they prefer inline styling (

TamTam is a gem created by Dave Hoover and Brian Tatnall that does all the dirty work for us. Before Rails 3 there was a plugin called inline_css (by the same authors) that used TamTam to automatically inlined all mails sent by ActionMailer. Since Rails 3, however, the ActionMailer internals have changed, and the plugin stopped working.

For my own use I created a module called InlineCss that I include in the mailers I need inlining for. This is the code:

module InlineCss
  def render(*args)
    if (template = args.first[:template]) && template.mime_type.html?
      # Be warned, this code expects a <style> tag in the head of your layout.
      TamTam.inline(:document => super)

This code sees if I am working with a template and if that template has a HTML MIME-type, it inline’s it with TamTam.

In my mailers I just include it. If you want to have this in all mailers, just add an initializer that includes InlineCss in ActionMailer::Base, and it should work

tags: , , , l

Railties Talk May 12th, 2010

Last ArrrrCamp I gave a talk about Railties and Engines.

You can get the PDF with my presenter notes on

tags: , , l

Environment specific files and gitignore March 1st, 2010

I love my Mac for doing development! Textmate and Passenger make it my all-time favorite environment to develop Ruby / Rails in. It does have some very specific “junk” files I don’t want in my git, though.

In the beginning I would include all those files in every project’s .gitignore file. This worked since all my colleagues also work on a Mac with Passenger & TextMate. Recently I’ve come across people with different setups, which made the project’s .gitignore look like this:


After some searching I found you can easily setup a global .gitignore which ignores your environment specific files. Doing so is easy:

# ~/.gitignore

And added this to my global git config

git config --global core.excludesfile ~/.gitignore 

This all makes your .gitignore file much cleaner and more relevant for the project itself.

tags: , , l

Compiling mongodb 'stable' as a debian lenny package January 14th, 2010

Today I had the pleasure of having to install MongoDb on one of our production servers. Pleasure because MongoDb is an awesome document database, and I also like new things.

Most of our production servers run Debian, and we try to keep all installed packages up to date with apt. Since Debian Lenny didn’t have a mongodb package (it does have a lot of other packages Mongolian language packs) I had to make my own. Luckily the mongodb git repository comes with a ‘debian’ folder, so making a .deb package should be easy as pie.

There are quite a few gotchas to get it to build, though. This is what you’ll need to do:

Get last mongodb ‘stable’ source

git clone git://
cd mongo
git checkout r1.2.1

The debian/control file lists all deps including one we can’t fulfill on Lenny, xulrunner-1.9-dev. We only have xulrunner-dev. So change the debian/control file:

# the Build-Depends line
-Build-Depends: debhelper (>= 7), libboost-dev, libpcre3, libpcre3-dev, scons, xulrunner-1.9-dev, libboost-thread-dev, libboost-filesystem-dev, libboost-program-options-dev, libboost-date-time-dev
+Build-Depends: debhelper (>= 7), libboost-dev, libpcre3, libpcre3-dev, scons, xulrunner-dev, libboost-thread-dev, libboost-filesystem-dev, libboost-program-options-dev, libboost-date-time-dev

# the Depends line
-Depends: ${shlibs:Depends}, ${misc:Depends}, xulrunner-1.9-dev
+Depends: ${shlibs:Depends}, ${misc:Depends}, xulrunner-dev

Also, be sure to install all these build-deps

apt-get install debhelper libboost-dev libpcre3 libpcre3-dev scons xulrunner-dev libboost-thread-dev libboost-filesystem-dev libboost-program-options-dev libboost-date-time-dev

Next up, we’ll need to change a script (buildscripts/ which sets old-xulrunner-compatibility. Apparently the bug I encountered was already fixed but didn’t work on my system. I just deleted the condition since I was sure I needed the old-compatability mode.

diff --git a/buildscripts/ b/buildscripts/
index 67c5d78..baebfe6 100644
--- a/buildscripts/
+++ b/buildscripts/
@@ -42,6 +42,5 @@ def foundxulrunner( env , options ):
                            incroot + "unstable/" ] )

     env.Append( CPPDEFINES=[ "XULRUNNER" , "OLDJS" ] )
-    if best.find( "1.9.0" ) >= 0:
-        env.Append( CPPDEFINES=[ "XULRUNNER190" ] )
+    env.Append( CPPDEFINES=[ "XULRUNNER190" ] )
     return True

That’s all changes needed to get it to compile. Next step is running dpkg-buildpackage and installing the package!

dpkg-buildpackage -rfakeroot -b
# <it builds..>
dpkg -i ../mongodb_1.2.1*.deb
tags: , , , l

Ruby and Rails beginner talk October 8th, 2009

Last night I gave a talk for Zeus about Ruby and Rails, talking about Ruby fundamentals and a short intro to the Rails philosophy and MVC.

I don’t know if you’ll be much with the slides without hearing the talk, but you can find them on

If you want to see the entire presentation you should come to ArrrrCamp, where I’ll be giving it again.

tags: , , l

Ruby Hash coolness September 28th, 2009

Don’t shoot me if you already use this every day, but this is new to me.

In the past I’ve often had code like this

@hosts = {}

@accounts.each do |account|
  @hosts[account[:host]] ||= []
  @hosts[account[:host]] << account

But why do this hen you can just add some initializer code to your hash.

@hosts = { |h, k| h[k] = [] }

@accounts.each do |account|
  @hosts[account[:host]] << account

Where Hash automatically invokes the block when an unknown hash key is called. Great!

tags: , , l

Autoload JQuery Plugins August 5th, 2009

Rails has the convenient helper javascript_include_tag where you can give up :default, which automatically loads prototype / effects, or with the jrails plugin adds jquery, jquery-ui and jrails.

But when using jQuery you want to use more than those files, you want to use jQuery plugins, or write your own, all in small .

Loading this can be a pain in the ass. Thats why I wrote this little initializer which adds everything in public/javascripts/jquery/*.js to the defaults.

# config/initializers/add_jquery_to_defaults.rb
Dir[File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR,'jquery','*.js')].each do |js|
  ActionView::Helpers::AssetTagHelper.register_javascript_include_default "jquery/#{File.basename(js)}"
tags: , l

Rack::Cache and Lighttpd+FCGI July 15th, 2009

On some of the Openminds shared hosting servers we run a Lighttpd+FCGI stack for Ruby/Rails applications. This week we got a complaint from a user saying they had a problem with the latest Radiant 0.8. Every page he loaded was the same as the first page he opened since the last server restart.

When digging into the problem it was clear that it was a problem with Rack::Cache, which only created 1 meta-store entry and served that from there on. On investigation always returned Apparently the last part of the key gets created by scriptname and pathinfo:

      parts << @request.script_name
      parts << @request.path_info

When looking at the request it seems Lighttpd+FCGI doesn’t fill in the env[‘PATH_INFO’], which results in always having the same cache key, thus the same page.

To solve this problem I’ve created a small Rack middleware that sets PATHINFO from REQUESTURI (Like Passenger does with Nginx)

module ::Rack
  class LighttpdFix
    def initialize(app)
      @app = app

    def call(env)
      env['PATH_INFO'] = env['REQUEST_URI'].split('?', 2).first

# in production.rb
config.middleware.insert_before ::Rack::Cache, ::Rack::LighttpdFix

# or for Radiant
config.middleware.insert_before ::Radiant::Cache, ::Rack::LighttpdFix

I’ll make a gem out of this tomorrow.I made a gem out of this, you can find it on GitHub and install it using RubyGems.

sudo gem install DefV-rack_lighttpd_fix
tags: , , , , l

MySQL password hashing in Ruby May 12th, 2009

An old database used MySQL’s PASSWORD() hashing functionality for storing user credentials. We’re creating a Ruby app now to interface with that database, and wanted to hash the password in ruby. After looking at the code it looked like they just SHA1 hash the password twice and prepend a *. Implementation in Ruby is easy:

require 'digest/sha1'

def hash_mysql_password pass
  "*" + Digest::SHA1.hexdigest(Digest::SHA1.digest(pass)).upcase

Which gives us in MySQL

mysql> SELECT PASSWORD('foo');
| PASSWORD('foo')                           |
| *F3A2A51A9B0F2BE2468926B4132313728C250DBF | 

And in Ruby

>> hash_mysql_password 'foo'
=> "*F3A2A51A9B0F2BE2468926B4132313728C250DBF"
tags: , , , l

Custom ActiveRecord timestamps April 27th, 2009

Some legacy databases have already defined their own created_at or updated_at fields. They can be easily filled in with ActiveRecord before_save filters, but after implementing this behaviour a few times the urge arose to write something reusable, so I created the custom_timestamps plugin.

With custom_timestamps you can easily define the columns you want to be updated on creation/change

class LegacyModel < ActiveRecord::Base
  set_create_column :creation_time
  set_update_column :change_time

The plugin can be found on github.

tags: , , , l

ArrrrCamp Belgium April 2nd, 2009

We have been talking between ourselves about hosting a Belgian Ruby conference since the last Railsconf Europe, and we have finally decided to proceed with the idea. Colleague Joren put things in motion and today we’re proud to announce Arrrrcamp, which stands for “About Ruby, Rails, Radiant and Rum Camp”.

The event will take place on friday, May 8th, in Ghent, Belgium. The idea is to have a barcamp-like organisation of talks, where everybody is encouraged to participate by either doing talks, taking pictures, do some hacking, … You can read all about the event on the website.

tags: , , , , l