Render an ERB Template from a Hash

I needed to render an ERB template from a hash for external email templates, and found that this is not as straightforward as you might think. I found a blog post on with a way to accomplish this. Basically, the hash needs to be converted into an OpenStruct before passing it to the ERB template.

The important part of the article and the code snippet demonstrating the functionality are below:

“you have to set the binding for ERB by saying opts.instance_eval {binding}. This runs binding in the context of the opts object, so then calls to methods like first_name made by ERB in this context will evaluate to the values of our hash.”

This will of course result in “Hello Martin Brennan.”.

Goodbye RequireJS, Hello Browserify

For a long time now, I’ve been relying on RequireJS for JavaScript dependency and module management and we have it incorporated into our front-end JavaScript workflow at work as well. There are a few things that have always bothered me about it:

1. Third party libraries, if not properly set up to use AMD, are a pain to include and use. Sure there are shims in RequireJS, but I’ve always found the system flaky and hard to understand.
2. Though not always an issue, we’ve found that sometimes modules simply do not load in the correct order, and it is difficult to diagnose the issue or to force them to load in the required order.
3. Dependency management amongst third party modules is often a nightmare, as the location of the modules that the third party libraries require are often not in the same location as where you want them.
4. The require and define syntax can sometimes be laborious, e.g. for libraries that do not need a variable in the function () {} call.
5. I’ve found that require modules are hard to concatenate in the correct order into one file, as well as uglifying at the same time.

These things have had me waiting for a new module system to come along and finally it’s time to say goodbye RequireJS, hello Browserify! (more…)

What makes a bad software developer?

I came across this question on Quora a while ago (see What are the characteristics of a bad software engineer?, and while the answer with the most upvotes is quote comprehensive, it made me think about the question a bit myself.

I would say the biggest indicator of a bad software developer is someone who is unwilling to learn and unwilling to improve themselves, which manifests itself in a lot of different ways. The first of these that springs to mind is Quality. (more…)

Sensible .NET REST APIs with AttributeRouting.NET

I have a lot of problems with the default .NET Web API that Microsoft pushes for people to use. You can only easily have two GETs, and one PUT, POST and DELETE route per controller. There is no easy way to create more complicated nested routes, i.e. GET /v1/person/:id/contact/:id, or routes that deviate from the norm. The routing syntax (not just specific for the Web API but other .NET services too) is horrible and unwieldy, and all routes must be defined in a separate file. Route constraints, precedence and validation are also tricky.

All of this may turn you off of writing an API in .NET, but there is an easy solution to all of these problems in the form of AttributeRouting.NET. This NuGet package allows you to define routes directly on controller methods, with out of the box support for route constraints, prefixes, precedence etc. It is compatible with the Web API and also .NET MVC. (more…)

DocuSign Connect XML Schema

For those of you that have developed for the DocuSign E-Signature platform, you’ll have probably used their DocuSign Connect service to listen for document and recipient events so you don’t have to long-poll their servers, which they strongly discourage. The example XML in their Connect documentation frustratingly does not have all of the possible values and fields that could come through with each request.

I decided to investigate this and came upon this StackOverflow Q&A that had a handy answer, which linked to the complete DocuSign Connect XML Schema as an XSD. You can find the XSD below:

DocuSign Connect XML Schema (XSD)

Print GitHub Markdown Bookmarklet

I was looking for a way to print GitHub markdown documents without all of the GitHub navigation, UI and other extraneous information showing up on the page. Mainly because I like GitHub’s clean markdown styles, and it’s very useful to be able to print documentation for certain projects.

All you need to do is add the following bookmarklet to your browser:

Here is a demonstration of what it does with the intridea/grape repo’s file (before and after):

Print Github Before

Print Github After

Could not successfully convert UCS-2 string to UTF-8

We were performing a massive data migration at work from MSSQL to MySQL using the Migration Wizard in MySQL Workbench. When performing the step that copied the data from one server to the other, we got the following error for some nvarchar columns:

Could not successfully convert UCS-2 string to UTF-8

Or alternatively, we also got Error during charset conversion of wstring: No error. This infuriating error took us an hour and a half to diagnose and work around. I finally stumbled upon this link to a bug on the MySQL bugs website relating to MySQL Workbench

The problem, it turns out, lays with Microsoft’s ODBC Drivers:

This bug is triggered due to improper UCS-2 strings being generated by Microsoft’s ODBC drivers.

And the solution is to select the FreeTDS ODBC Drivers in the first step of the migration wizard of MySQL Workbench. The migration then works perfectly with no further encoding complaints. I hope this helps someone else out with this frustrating problem!

FreeTDS ODBC Drivers

The SMS That Started It All

Today I want to show you the SMS that started it all and began my career as a software developer.


One day in October 2010 my manager and I sat down to discuss a database solution for our company. We had unsuccessfully tried to use another company’s solution for our business needs but found them lacking, and we were already running an Access database for some of our data. At this time I had no experience with databases whatsoever, not even the basics such as tables, columns and primary keys. Jacob wanted to gauge my interest in learning about databasing and Visual Basic so we could develop our own solution. Needless to say I was very keen. (more…)

Failed to build gem native extension on OSX Mavericks

When installing certain gems on Max OSX Mavericks you may run into some issues where either the gem install or bundle install command throws the error “Failed to build gem native extension”, usually in extconf.rb. This has happened specifically to me with the json and mysql2 gems. Some gems may work exactly as expected.

The reason for this odd behaviour is because in the latest release of XCode 5.1, Apple are treating any unknown command line options as errors. The XCode 5.1 release notes read:

“The Apple LLVM compiler in Xcode 5.1 treats unrecognized command-line options as errors. This issue has been seen when building both Python native extensions and Ruby Gems, where some invalid compiler options are currently specified. Projects using invalid compiler options will need to be changed to remove those options. To help ease that transition, the compiler will temporarily accept an option to downgrade the error to a warning: -Wno-error=unused-command-line-argument-hard-error-in-future”

What this means that if any gems use invalid command line arguments in their build or install process, the error “Failed to build gem native extension” will be thrown. As a temporary fix, you can try running either bundle install or gem install with the following argument, which downgrades the error to a warning:

This should clear up most errors. The fix is temporary because Apple have said they will be removing support for the argument in the future, which means any gems with invalid arguments will need to update their build commands.


This fix did not work when installing the mysql2 gem, I got the same error but it required an extra step to fix. I had to run the command brew install mysql. Afterwards I could just run bundle install and the problem was fixed!