Consumer-Driven Contract Tests

The most useful way I’ve seen such contract tests work is that the team that consumes the messages creates and publishes an artifact in their build pipeline for use by the creators of the messages. For this example let’s have it create a tarball with a shell script entry point. The inputs to the shell script can be a URL to the api-server and any other parameters required, like user IDs, oauth tokens, etc....

Building Clouds

I’ve spent this year building networks using Amazon Web Services and teaching people how to do it. So I’d like to share the code that I’ve used as teaching examples and as seeds for the creation of some pretty cool environments. AWS PY was my first published attempt at interacting with AWS in python & Puppet to instantiate, provision and control EC2 instances, as well as the seed for an incredibly cool project at the start of this year....

How to use rsync on OSX

I don’t really want to copy dot files (eg. .DS_Store), and I want to avoid the bug that rsync exhibits with time-capsule where it loops creating multiple ..DS_Store.xxxx files. rsync -vrW --ignore-existing --exclude ".*" --progress ~/Movies/ /Volumes/Backup/Movies/ ...

How to delete all zero length files in a directory tree

find . -type f -size 0 -print0 | xargs -0 rm -f ...

Cross-Site Scripting vulnerability with JavaScript and JQuery

Think you’ve protected your site against Cross-Site scripting attacks by escaping all the content that you’ve rendered? Thought about your javascript? Here’s a neat bug that got us today. This example is contrived to show a point. <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>XSS Example</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> <script> $(function() { $('#users').each(function() { var select = $(this); var option = select.children('option').first(); select.after(option.text()); select.hide(); }); }); </script> </head> <body> <form method="post"> <p> <select id="users" name="users"> <option value="bad">&lt;script&gt;alert(&#x27;xss&#x27;);&lt;/script&gt;</option> </select> </p> </form> </body> </html> See the problem?...

Default HTML-escape using Freemarker

Most java developers have at least heard of Freemarker. FreeMarker is a “template engine”; a generic tool to generate text output (anything from HTML to autogenerated source code) based on templates. It’s a Java package, a class library for Java programmers. It’s not an application for end-users in itself, but something that programmers can embed into their products. It is the “generic” nature of Freemarker that trips up java web developers....

Provision EC2 instance using boto

Sam Newman recently published a very interesting blog entry on using fabric to apply puppet scripts on remote machines. He left the provision_using_boto() method as an exercise to the reader. That just sounded tempting enough to be a challenge since I hadn't gotten around to looking at boto. You can find the result of my attempt on GitHub. To be precise aws.py implements the provisioning using boto and fabfile.py drives fabric and puppet....

Kramdown and Webby

A number of the sites that I manage for fun are simply static web pages. The dynamic nature is handled by javascript classes and plugins. This means that I really don’t need or want an application server to serve these sites, but I do want to still use some of the practices that I apply to web application development. Enter webby - it works by combining the contents of a page with a layout to produce HTML....

RPMs and Effing Package Management

I've been using FPM to build native packages for applications for the last few months and so far I cannot believe just how cool it is. It can create RPMs and DEBs from ruby gems, python modules, node packages and even directories. The last one is very useful for packaging up stand-alone java apps. Check it out, you may like it too....

AWS CloudFront invalidation

It is now possible to invalidate objects (files) in AWS CloudFront distributions. Handy when someone, like me, occasionally publishes files with the wrong content type. Here is how I implement this invalidation in python....