Twenty Fifteen

Dec 30, 2015

Let’s make this a quick one. I’m a busy dad, you know.

First of all, nothing come close to the friendship I’ve developed with my wee little girl this year. She’s two and a half now, and becoming ever more switched on. She embraced the recent house move admirably. She also has a sneaky sense of humour, and will make a great fighter one day. (Coming from a civilised man, this means intellectual fighting, like the ones you encounter in a court room. Naturally.)

Did I mention a new house? Yes, I did. It’s great. Right next to an Ofsted outstanding (for 20 years running) school. And a park in the back. This means no-one overlooks us. Which is great. I’m earmarking the garage as a dual study slash workshop. Stay tuned.

A quick word on tech. I’ve mostly been at Conde Nast this year, heading up the API team. Our remit is ever expanding, so soon we’ll re-incorporate to something more “platform team” -like. My immediate team uses JavaScript, but we’ll be doing more Clojure/ClojureScript soon, and have been getting our hands dirty with a lot of ops involving Kubernetes, Docker, etc.

Personally, I’ve been doing a lot of stuff in Racket this year. Mostly personal projects still under wraps.

OK, so my wife is calling me from upstairs now. Talking of which. She is great. This blog post is dedicated to her. You are a strong, beautiful woman in the face of all the hiccups you’ve encountered through-out your life (including me!). I love you.

Add logging to PostgresQL on Docker

Jun 17, 2015

Normally, in docker-compose.yml I would just configure a database like this:

  image: postgres:9.4

However, to customise the image, we use our own Dockerfile:

FROM postgres:9.4
ADD /docker-entrypoint-initdb.d/

The contents of

perl -pi -e "s/#log_statement = 'none'/log_statement = 'all'/g" \

And docker-compose.yml now becomes:

  build: location/of/new/docker/file

Link your app, launch the stack, and start seeing log statements on STDIN:

db_1         | LOG:  statement: BEGIN
db_1         | LOG:  statement: SELECT etc etc

A tale of two money transfers

Jun 14, 2015

I use GBP, and my contractor in Italy uses EUR, but we “talk” USD. The first payment came up, and I was recommended TransferWise by my friends in the trenches. I go online to TransferWise and select USD from the dropdown, and go through all the steps. Finally, TransferWise tells me to send them money in Estonia from my Internet banking account, which I do.

But — weird — I thought. Weren’t they supposed to make all this easier for me?

I open up a TransferWise chat with Jorgen in support and ask them if I had done something wrong. Yes, of course — I had to select GBP from the dropdown.

A bit of confusion ensues and my transaction on TransferWise gets cancelled, when instead I meant for them to decline anything coming into their Estonian account from my Barclays UK bank account. I then loose my connection, and end up with another agent called Monica whom I end up repeating the entire story to, and she says she’ll make a note with the payments team to decline my money.

Hang on, I think — why don’t I just phone Barclays and ask them to cancel the international transfer. It’s Sunday, after all. Nothing would’ve gone through yet.

“I don’t see anything, sir.” says Paul, the telephone support guy. Me neither. I little light goes off in my head: I must’ve forgotten the “Confirm” button on the last screen of the transfer. I always do this — pay myself my salary then wonder why it didn’t reach my personal account. (Thank goodness I’m the only employee!)

The problem is resolved. Bless the Barclays phone operator Paul, and bless TransferWise’s Jorgen and Monica.

It was all completely my fault, but still feel that in this day and age of modern online services like Barclays Internet banking and TransferWise, user experience issues should be fully addressed.

“We see you’re using USD. Is the source funds also USD?”. Or have a separate 3-way calculator.

Also, Barclays: that last confirm button is a major call-to-action, and should be high viz.

Now, I just have to remember to pay my contractor :-)

UPDATE 2015-06-16

Oh, bloody hell. An email from TransferWise. Thanks for nothing, Paul@Barclays!

Hi Juan,

Hope this email finds you well.

We have still received a deposit for 500 USD from you.
Please confirm if you wish us to proceed with the payment
#0123456 or we’ll refund it back to you to the originating
bank account.

But please be advised, that if we will issue a refund it will be
through a SWIFT payment, this involve extra cost so you will not
get exactly 500 USD back to the originating account.

- our bank will charge a fee (7 EUR) for the transfer
- intermediate banks will take a fee (anywhere between
10-20 USD each, up to 3 banks)
- your USD dominated bank may charge a fee for accepting an
international bank transfer (fee depends on your bank)

You can read more about SWIFT payments here.

Waiting for your reply!

2014 — the year in review

Dec 31, 2014


…let’s get the big news out of the way.

This year I got married. We have a lovely daughter, made a beautiful home together, and a few years of togetherness, and really just wanted to celebrate these blessings with friends and family. Besides, my partner is gorgeous, and I just had to go ball & chain on her :-P

The tech


This year saw me Dockerize all the things. Linux containers is the best thing since diced bacon, and really unleashes servers everywhere.


Loads and loads more Python, especially for APIs. Python is awesome. Especially paired with other awesome tools like PostgresQL, for example: no more “WHERE user = %s” to filter on user data. Let’s just say I devised a clever trick using flask-sqlalchemy, PostgresQL schemas, before_request and search_path to give every user their own database.


Still my tool of choice for interfacing with tried-and-trusted Java libs to build those blazing fast, functional and correct back-end processes.


Can’t get away from this one. But starting to wonder if ClojureScript is the way to go. Besides, I always ALWAYS use lodash (replacing underscore recently).


I’ve been really doubling down on Clojure this year for fun, throw-away side projects. I really want it to replace Scala. And OMG how awesome is it to code a Lisp using Emacs. It reminded me of those early 2000s Scheme days…


So, I’ve always been a Ruby fan, and always wanted to be able to mention Erlang as one of my top few skills, but yuck… Erlang! It’s like trying to do a Shakespeare recital with a mouth full of mud. That didn’t make any sense, but Elixir does. Still a bit fast moving, so I’m not doing anything big in it, but watch this space.

UPDATE 2015-03-13

After working with Erlang a bit more (and reading this), I stand thoroughly corrected, and don’t mind it at all.


My life, that is.


Let’s see… I don’t watch or read any news (be it news news, or tech news). There was one event in the last quarter which my family says changed their perspective on things, which turns out to not affect me. I’m really happy with this arrangement.

I’ll change HNWatcher on occasion to send me alerts for tech I’m following, but I mostly archive those.


7 minute scientific workouts, 3-weekly runs to the local free gym where I break some more sweat, and loads of activities with my daughter.

I had a health check, and all is perfect, and will make it a yearly thing now.

8 hours sleep a day, at least.

Painting and drawing in the evening to clear the mind and splatter watercolours everywhere.


Time is precious and not to be wasted. I’ve little tweaks with which to save a bit of time. E.g. when reading an article, and mind wanders / eyes start blurring, I close the tab or delete the eBook and move on with my life.

My phone now has 2 main apps: Kindle, and Pocket Casts. No more games. In fact, the only games I play are board games with my family.

If I can pay for it to be done, I do just that.

I unsubscribed from everything. E.g., I closed my LinkedIn account, and delete all new messages from them.


It wasn’t a perfect year, after all.

My wife got made redundant.

A client of mine confused the words “contractor” with “employee” and I wrote off a significant amount of money as bad debt in a time when the money would have helped with a problem. I get all my work from my personal network, and agree to things with the shake of the hand, and this particular fella is making me reconsider.

My dad took his own life this year, and I’m especially remembering him tonight.

15 years ago today was the most significant NYE of our generation. I spent it with my dad as my mom had just left us a few days prior. We were sitting on the balcony in total darkness, staring out, with the odd firework illuminating his face. Had my sister been a grownup then, who knows what he would have done, but he chose to be there for us.


Since catching up over eggs and coffee is the new catching up over a beer, let’s have breakfast some time and I’ll tell you my plans.

Meanwhile, live life and don’t take shizzle from see you next Tuesdays.

I made my daughter a book for her first birthday.

Apr 17, 2014

Made? Yes, made – not wrote. See below.

My day is a grab-bag of abstract concepts, data as shapes moving from system to system on pathways built with tools I love dearly. However, every now and then I want to inject some characters and narrative into my life.

A previous, on-ice-yet-ongoing foray into Story Land is when we learnt we were pregnant. My world was shaken, and in a nervous panic I wanted to surround myself with things that will cleanse my mind, prepare my heart, and re-awaken the child in me. All in preparation for the Little Being that was to join us in June 2013.

I was going to write a picture book. The poem it’s based on came to me on a train journey to the Cotswolds. It was going to be perfect. But, I had to practice. Doodle, draw, illustrate. Devour colours. Try and not be precious about my Moleskine notebooks. Scribble, then scribble some more. Rip out pages, and throw stuff away.

I started in earnest, but truth be told that a Picture Book is not an overnight endeavour.

Meanwhile, Little One was born. Slow and considered sketches were soon replaced by frantic nightly dashes finding nappies and milk. My fountain pen dried up and clogged sooner than one can say “priority shift”.

A few months ago it dawned on me that she’ll turn one soon. I started to think of her first ever gift. The picture book was still months away from being completed. All along our Little Beloved pointed at “C for Cat” on her alphabet toy, and a light bulb appeared above my head: a cat book!

The birthday is now imminent, and something needed to be sent to the print shop pronto. Inspired by “famous cats” from a pub quiz, I went on to create this. Heavily cribbed and everything stolen from far flung corners of the Interwebs, but hey – it’s not like I’ll be making money off it!

Fun was had, and Father Time once again looks down favourably on my poem-inspired work of art which will soon sit alongside our Little One’s other precious things.

More jq fun

Jan 29, 2014

I’ve written about jq before, but I mention it again here as a very useful tool for parsing JSON on the command line.

I needed to grab some England Bank holidays for a quick hack the other day, and found that the GOV.UK team made web better by allowing you to append .json to any of their links to get to the data.

Hold onto yer hats:

2103 — the year's code and tooling in review

Dec 31, 2013

I saw the #code2013 hashtag on Twitter last night and joined in. It got me thinking about the stuff around the programming languages I use, and my professional skillset in general.

I’ll briefly touch on how a few major events in my life forced me to cut the fat and become more focused.

A few notes, then.

The programming languages


My new, old favourite. My go-to language since 2009. I can’t add much for 2013 apart from that I’m happy to see the community mature around it. We’ve gone from “How we adopted Scala at company X” to “How to go back in time using Akka, Play! and XYZ”. Oh, and then the reactive course was fun too, and highlighted a few holes in my Akka education.


Java still mostly pays the bills, and I’m writing even better Java thanks to Scala. My editor is told to highlight everything in a shade of gray, apart from re-assignables which are red. It all just flows.


I’m a big fan of Pylons and have used Python since 2006-ish for tiny webapps, but this year sees me going down the finance route with SciPy and Pandas thanks to a handful of courses I did recently.


Strangely addictive. I did a data analysis course with the famed Johns Hopkins university earlier this year, and thought I would be “learning” R along the way. If anything, it felt like I already knew R, and the thing that I learned was making a good analysis, writing it perfectly and succintly, and performing an honest peer review. R is perfect for slicing and dicing your data, and it doesn’t get in the way.


The main attraction to Dart for me was the promise of compiling to a better Javascript which you can ever hope to write by hand. The Dart syntax itself is familiar, and then you have the odd goodies like the cascade operator (borrowed from Smalltalk) which lets you chain methods without having to return the instance in your API, and being a Scala guy, I love having rockets (=>) scattered all over my code (Dart’s syntactic sugar for concise getters).


Being a backend programmer by trade, I usually don’t go for frontend gigs, but a client this year said they don’t mind me learning on the job, and I’ve heard good things about AngularJS, so I dove right in. I’ve touched on Javascript a lot in the past, but this year I spent a significant tenth of my professional time fiddling with it.


Yes, I really did spend the tiniest amount of time with Haskell, but enough to mention it here. I downloaded, chopped and changed the XMonad code and the take-away for me was that 2014 will see more Haskell.

Other languages, not-so-much-languages, and tools

My starter Dart project is a game (where do I find the time?), hence WebGL and subsequently GLSL. I’m particularly excited about getting my hands even dirtier with shaders with Mozilla recently announcing live-editing of shaders using Firefox.

I’ve always used Capistrano and Chef for my provisioning and configuration needs, but this year I gave Ansible a shot. I hope Ansible stays the way it is: small, simple, elegant. No agents; just SSH.


2013 was a bumpy ride. We had a beautiful daughter in June, and I quit my job soon after to freelance from home and be 2 flights of stairs away from her. To be able to learn a few new skills and do 4 courses, I had to make some changes. There are the 5AM starts, the highly-condensed exercise routine in the morning, diligently deleting anything which doesn’t contribute to the plan I have for our life (this includes articles, emails, etc), and just generally getting things done.

The Polar Bear who might have eaten Xmas The game I mentioned seems like a distraction, but I feel it’s important that I do it. I’ve been in love with doodling since I was a kid, and really took it up this year. I’m an able musician, and since I can code I thought I’d bring these ingredients together and make something nice. (Those umpteen characters and storylines in my head will finally be unleashed!).

Thanks for reading this far. May you have a great 2014.

I leave you with a doodle I made a few days ago entitled “The Polar Bear who might have eaten Xmas”. (Don’t worry — this isn’t one of my games ideas ;-)

Using single and double pipes in Scala conditionals

Dec 27, 2013

In a nutshell, use a single pipe if you want all the expressions in your conditionals to be evaluated, and a double pipe to conk out as soon as you have true.

scala> def a = { println("a") ; true }
a: Boolean

scala> def b = { println("b") ; true }
b: Boolean

scala> def c = { println("c") ; true }
c: Boolean

scala> if (a || b || c) println("true") else println("false")

scala> if (a | b | c) println("true") else println("false")


Dec 13, 2013

I recently saw a talk by Jack Dorsey where he iterates a list of commandments for this life, and number three is “drink only lemon water and red wine”.

I love red wine, and was intrigued by this lemon water idea. I investigated and it led me to an article which asks how much lemon water is needed. They quote a heuristic:

For those who weigh less than 150 pounds, squeeze half a lemon’s worth of juice into a glass of water. If over 150 pounds, use an entire lemon’s juice.

This is a heuristic, and it is beautiful. It saved the author from quoting an entire “weight in pounds to amount of lemon” table.

The heuristic is one of my favourite concepts of all time. During engineering school in the late nineties it became ever more apparent what a powerful concept it is, e.g. using lookup tables when designing flow systems with complex flow dynamics. It makes applied rocket science a bit easier. Or when solving path finding problems where the brute force method is just not a viable option in terms of time complexity.

Anyhoo, I’ve reached my 10 minute limit for writing ★, and since I can’t do this powerful concept any justice with just a few words, I’ll let the editors of Wikipedia englighten you further.

★ this is my own heuristic (aka “rule of thumb”) for not spending too much time on writing.

Project Euler 18 and 67 in Scala using foldRight, zip and sliding

Nov 28, 2013

I’ve recently applied to Toptal and sucked miserably at the entry exam. My algo chops were blunt and I thought I’d rectify it by revisiting Project Euler. With the startup last year and the baby this year I just haven’t been able to find the time for programming challenges, but that has to change.

Looking at my Project Euler source directory, I saw that I left it at problem 17, so next up will be 18. The problem description, however, mentions that the problem repeats itselt as 67, but with a bigger input that will run 20 billion years if you go the brute force route.

I worked a little on this problem last night, and decided to by-pass the brute force solution completely. It was a bit late, though, and I pulled my eyelids open far enough to make it to bed. I then went on to dream about the damn problem all night. I knew there had to be a simple bottom-up fold-based solution, and the voila moment came for me when I realised I had to seed the fold computation with the base layer in the triangle.

Here you go:

A little explanation

The triangle is represented as a nested list, like so: List(List(1), List(2, 3), List(4, 5, 6)) and so forth.

    / \
   2   3
  / \ / \
 4   5   6    <- this is the "base layer" in my explanation.

Since you need to add the maximum of the two immediate children to the layer above, a foldRight wouldn’t give me all the info I need in the curent iteration. Foldright for me means “the data is coming FROM the right”, i.e. List(4, 5, 6) will be processed first, then List(2, 3) but at no point in the iteration will they be available together so I can do the sum. List(4, 5, 6) would need to come into the iteration with List(2, 3) in another way, and I realised I can use the foldRight’s accumulator for that by seeding the foldRight with the base layer in the triangle (aka the last list List(4, 5, 6)).

The easiest way was to just seed the foldRight with a list of zeros one element larger than the base layer. You then break it up into pairs using sliding(2,1), take the max of the pairs, and sum the max with the corresponding (thanks to zip) element in the layer above.

     / \
    2   3
   / \ / \
  4   5   6
 / \ / \ / \
0   0   0   0    <- this becomes the new "base layer", or "seed"

No mutable state; no recursion; simple to understand. As Erik Meijer would say: “baby code”.