2013 Year in Review

A pretty landmark year was 2013.

April 6 first of all, as it was the day I got engaged to the spectacular Li atop the almost as spectacular Mt Sturgeon.

Taken atop the nearby Mt William

The other major change was I donned Lycra and took up the sport of cycling. This happened later in the year but I already attempted and completed a ride through the Strathbogie Ranges with Orica-GreenEDGE [GPS record of my ride]. I was majorly stuffed by the end of the ride I can tell you.

Some good friends got married, or engaged, or had babies, there is a lot of that going around at the moment so I don’t think I’m alone in thinking is was a pretty big year.

Some Stats/Favourites/Lists

  • Favourite Book: Leviathan Wakes by James S.A. Corey
  • Books read: 24
  • Favourite Movie: I don’t know! Need to use Goodfilms more.
  • Favourite TV: Game of Thrones, Modern Family, Almost Human.
  • Kilometres cycled: 1,100.2 km (4 months of owning a bicycle)
  • Online courses started: 2
  • Online courses finished: 0
  • Conferences attended: 2 (PyconAU and Yow! Melbourne)
  • Conferences talked at: 0
  • New programming languages learned: 0
  • Favourite programming library: Angularjs
  • Girls of my dreams got engaged to: 1

So 2014?

Well the obvious one that will be dominating the first half of the year is getting married in April and then honeymooning in North Africa and Europe. That will likely consume the first four months of the year.

Beyond that I have some aspirations:

  • Read more books: 26
  • Talk at a conference: PyconAU?
  • Properly learn a pure functional language: Scala? Closure? Haskell? I will leave the term properly vague.
  • Complete a couple of online courses.
  • Finish one of my hobby programming projects.
  • Blog once a week.

The Lost Fleet by Jack Campbell

I don’t think I have read a more cheesy science fiction book since I was a teenager reading early Heinlein novels. The Lost Fleet series is pretty simple, a legendary war hero returns from the dead (found in a escape pod after 100 years) to lead a fleet trapped behind enemy lines.

The setting is well put together, two large human space faring civilisations in a drawn out war where neither side can hold sway. Each book is a series of battles in various solar systems as the fleet fights to escape largely intact.

These fleet actions are some of the best I’ve read, realistic, using believable technology and science. They’re sweeping battles spread across light hours of space employing clever tactics and it makes for some good clean fun.

However these epic battle broken up by some weak intrigue with characters who for the most part a little more than cardboard cut outs. Apart from the main character you never get a feel for the other characters, the few there are and what characterization there is can be stilted and painful at times. It really holds back the series from greatness which it a pity as the kernel is solid and enjoyable.

3/5 stars

Attack on Titan

I haven’t watched much anime lately, Planetes and Death Note were the last two I watched through. However a few friends have been raving about Attack on Titan and one of them posted an AMV trailer which made it look really fun so I gave it a try.

I was both happy and disappointed, first the happiness. It is a beautiful production, the setting is gorgeous, the character design is solid and the art work is world class. The plotting is well paced, able to introduce a lot of characters without my head spinning. However the plot itself doesn’t leave the familiar rut anime has trodden in the whole 20 years I’ve been watching it. It doesn’t stifle my enjoyment but it does make the diamonds in the rough, Planetes I am looking at you, shine just that much brighter.

Board games I’ve played lately

I’ve played a bunch of new games lately that are worth sharing.

Race for the Galaxy

Economic euro game in a space card game disguise. Played a few 2 player games today and I really like it, now I just have to work out how to win a game.

http://boardgamegeek.com/boardgame/28143/race-for-the-galaxy

Small Worlds

Simple territory building game with some neat mechanics. You conquer territory to get victory points as you cycle through randomly generated races to maximise your points.

http://boardgamegeek.com/boardgame/40692/small-world

San Jaun

Another economic euro game very similar in play to Race for the Galaxy but with a renaissance city building theme.

http://boardgamegeek.com/boardgame/8217/san-juan

Dominion: Guilds

The newest of 8 expansions for my favourite board game. The cards centre around little gold pieces you save to spend later.

http://boardgamegeek.com/boardgameexpansion/137166/dominion-guilds

A CP Solution for XKCD NP Complete Restaurant Order

I’ve been messing around with Constraint Programming (CP) the past week. A few people at work have tried it out on some real world problems lately but it didn’t seem to stand up when given a lot of data and variables. This seemed sad as the declarative nature of CP attracts me and it strikes me there must be a set problems that it could be used for and it deserved a look.

The first CP model I wrote by myself is stupidly simple but since my non techie fiance understood the code I figure it is a good example. The problem is as described by XKCD below, select some appetizers from the menu so that the total cost adds up to $15.05.

NP Complete

I modeled the problem in Minizinc, a declarative language for modeling CP problems. I am just learning so if you know Minizinc and I’ve done something dumb don’t judge me too harshly.

Firstly we declare a bunch of variables that the solver needs to find values for. We provide the solver a domain in which the variables must lie, zero to ten for all variables in this case. Each of these variables represents the number of times as part of a solution we buy an item to add up to $15.05.

var 0..10: fruit;
var 0..10: fries;
var 0..10: salad;
var 0..10: wings;
var 0..10: sticks;
var 0..10: sampler;

Then we declare a constraint, something that the solver must meet to solve the problem. And in this case we say that a sum of the cost of the items (converted to cents) multiplied by the number of items in the solution must equal the required 1505 cents (that English version could be taken a couple of ways, the maths below makes better sense).

constraint fruit*215 + fries*275 + salad*335 + wings*355 + sticks*420 + sampler*580 == 1505;

We tell the solver to solve to satisfy.

solve satisfy;

And provide a format in which to output the solution.

output ["fruit=", show(fruit), "\t fries=", show(fries), 
        "\t salad=", show(salad), "\t wings=", show(wings),
        "\t sticks=", show(sticks), "\t sampler=", show(sampler)];

Running the model gives us:

$ minizinc --all-solutions xkcd.mzn
fruit=7     fries=0     salad=0     wings=0     sticks=0     sampler=0
----------
fruit=1     fries=0     salad=0     wings=2     sticks=0     sampler=1
----------
==========

So there we go, all the possible solutions to the poor waiters problem! We know it is all of the solutions because of the “==========” minizinc cryptically places at the end of its output. Of course this problem is easy to brute force with a couple of for loops, there aren’t that many combinations.

But it is a start along what I hope will be a fruitful path.

Update: as people have noted on HN and Reddit I originally screwed up transcribing the price for salad which produced a couple of extra solutions. Fixed that now.

WTForms and Cherrypy 3.1

I have been trialling WTForms, a HTML form input and validation library for Python with a project I am working on. Much to my irritation however WTForms and Cherrypy don’t play nicely in one small area. Using wtforms.FileField with the validator wtforms.validators.Required will always fail.

Cherrypy in 3.1 (but not 3.2 interestingly) uses the Python built in cgi.FieldStorage to handle file uploads. In Python 2.6 and 2.7 at least this is beause the code for cgi.FieldStorage.__nonzero__ [1] only checks self.list and ignores self.file which is where the data is (at least for Cherrypy 3.1). No idea why this is the case, google gives no love on the why of this issue.

There has been an issue raised with the WTForms guys about the same case with Pylons but the long and the short of it is the developers don’t want to add special cases for the various frameworks. Special cases are the bane of a coder’s existence, they bloat otherwise lean and understandable code and cause maintenance nightmares so I do understand.

So what about me? Moving to Cherrypy 3.2 is an option but I don’t want to deal with the worry of that migration right now. An easy fix on my end is to write a custom validator and use it in place of the built in one. But what about the next project and the dozens of other people on my team who have to remember to use the custom validator for file upload? I might need to continue looking at form libraries, at least there is a lot of them!

[1] http://hg.python.org/cpython/file/9f8771e09052/Lib/cgi.py line 602

Cardinal Pell

Status

Poor Cardinal Pell you’re right. Your church is unfairly being singled out for criticism and we should take your word that decades of systemic failures by your organisation have been rectified.

Eclipse

EclFinally, after gathering dust on my shelf for a couple of months I played a game of Eclipse. The epic space 4x strategy game is often described as Twilight Imperium (TI) light, which lets face it isn’t fair as almost anything is lighter than TI’s 8+ hour epic sessions.

It is hard to judge based on a single 2 player game but it seems like Eclipse fullfills the epic space strategy need in me without the pain associated with TI. Each person’s turn is quicker, the choices you make are simpler but contain a similar strategic depth.

And it plays through in 1/2 the time (30 mins per player) once you know what you are doing, the length of a TI game means it is always hard to get a session going.

Looking forward to another game soon with more players.

Chin Chin

Wow, so um wow! A week ago we went to eat at a darling of the Melbourne food scene, Chin Chin. I don’t follow the trends and new hot things in the local scene very closely but had still managed to hear it is a great place, though little else beyond that.

What the place turned out to be was amazing and well deserving of the buzz it has generated. After waiting an hour to get a table* we ordered the “Feed Me” set menu at $66pp where as we discovered they just keep bringing out dishes of wonderful Thai food until you beg for mercy. We definitely got our money’s worth and tried many dishes we probably wouldn’t have picked otherwise but enjoyed heartily.

I cannot recount all the dishes we ate because of this, it is now one big long beautiful blur. However overall the salads were probably the highlight, so wonderfully flavoured many with a well balanced chilli bite. I will certainly be heading back there, probably taking friends from out of town to show off a shining example of what the food scene in Melbourne has to offer.

* They take your mobile number and SMS you when your table is ready.

Github, Rails and Interface Design

All the excitement over the Rails and Github hack reminded me about Scott Meyers (author of Effective C++ et al.) who has talked about the subject of interface design many times (including in the aforementioned book) and his perspective puts the ball squarely in the Rails team’s court.

Let’s make the reasonable assumption that your clients—the people using your interfaces— are trying to do a good job. They’re smart, they’re motivated, they’re conscientious. They’re willing to read some documentation to help them understand the system they’re using. They want things to behave correctly.

That being the case, if they make a mistake when using your interface, it’s your fault. We’re assuming they’re doing their best—they want to succeed. If they fail, it’s because you let them. So, if somebody uses your interface incorrectly, either they’re working hard at it (less likely) or your interface allowed them to do something easy that was not correct (more likely). This puts the shoe on the foot not used to wearing it: it means that responsibility for interface usage errors belongs to the interface designer, not the interface user.

Source: Scott Meyers: The Most Important Design Guideline?