Carlos the Jekyll

Posted on Nov 20, 2014 programming

I recently decided to shift a bunch of my websites (sharpoblunto.com, junkship.net, matchstickframework.org) over from my ancient home built asp.net based framework to something a bit more reliable and low maintenance. I didn’t really want to put a huge amount of effort in to port the sites over, so that cut out options that would involve learning whole new languages and frameworks. Also after looking over what my requirements were it pretty quickly became apparent that I didn’t really require any dynamic functionality that couldn’t be covered via client side javascript. Because of this it seemed like a static site generator would be the way to go - I already had the front-end html templates from the existing sites, I would just have to adapt them to whatever I chose.

After a quick look around Jekyll emerged as the most suitable solution, helped in part by the fact that one can host Jekyll powered sites for free on GitHub using a custom domain name. Porting over the asp.net MVC view files to Jekyll templates was pretty straightforward (If your curious how it all looks, this sites source is available here on GitHub)

The most time consuming job was transferring the content of my old blog archive database (where all the blog content was stored as html) and converting it to markdown that could be rendered by Jekyll. The first step was to write a bit of c# to dump each database post row into a file. Then I needed to convert the html to markdown; to do this I wrote a Node.js script based on the to-markdown package to convert the html archive which I’ve included below.

var toMarkdown = require('to-markdown').toMarkdown;
var fs = require('fs');

function processFile(file) {
fs.readFile(file,"utf8",function(err,data) {
var md = toMarkdown(data);

fs.writeFile(file,md,function(err) {
console.log('processed '+file);
});
});
}

fs.readdir('.',function(err,files) {
for (var i = 0;i < files.length; ++i) {
if (files[i].indexOf(".markdown") > 0)
processFile(files[i]);
}
});

Its weird how technology sometimes circles back on itself, some of the very first websites I ever built were static html, and now in 2014 I’ve ditched server side code and databases in favour of static html again. I guess it goes to show that sometimes the simplest solutions are often the best.

Getting a tolerable windows command line

Posted on Apr 1, 2014 ramblings programming

After being spoiled with the power of the command line and all the great text based tools on OSX and Linux it can be hard when one comes back to windows to be presented with the default windows cmd prompt in its full archaic glory. The good news though is that with a bit of messing around it is possible to get a halfway decent command line experience on windows. Below is a screenshot of my current command line setup which looks and behaves very similarly to my iterm2 setup on OSX. If you follow the instructions below, this too can be yours.

image

First install Clink (http://mridgers.github.io/clink/). Clink offers bash style rich completion and history and integrates directly into the default windows cmd prompt. This goes a long way toward making the navigation experience easier.

Next Install Conemu (http://code.google.com/p/conemu-maximus5/). Conemu provides tabbed/split pane console windows with customizable color schemes and layouts. In my case I use the solarized theme and choose to hide the default tab bar and status bar for a minimalist view. I also add a little transparency to the windows to help see the contents of windows underneath the command prompt.

Now to get some decent command line tools to use in our shiny new terminal interface. To do this we will Install the chocolatey package manager (http://chocolatey.org/ – Powered by Nuget, its basically apt for windows). Run the following powershell command to install chocolatey

@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin

Now we’re going to install some packages containing some windows ports of some useful Unix tools. Firstly we never want to use notepad.exe again so lets install vim instead. Run the following command to install vim using chocolatey

cinst vim

In order to be able to use the standard Unix command line nomenclature such as ‘ls’ instead of ‘dir’ we are going to have to install some Cygwin packages. To do this we need to install some more chocolatey packages

cinst cyg-get
cyg-get default
cinst wget
cinst curl

You can also install openssh if you don’t want to use PUTTY for ssh into your OSX/Linux machines

cyg-get openssh

Feel free to customize things further to your hearts content. This setup works for me, but I’m sure there’s a multitude of tweaks and tools out there which could make it even better.

The Dukebox of Hazzard, open source at last

Posted on Jul 1, 2013 dotnet dukes programming

The Dukebox of Hazzard (Dukes) is a media player built around the idea of fair and equal access – in particular those situations where there is only one set of speakers in a communal space, and multiple people who want to be able to play their music. Dukes is designed to prevent people cutting other peoples tracks off partway through (by design there’s no way to skip tracks), and ensures that all users get an equal chance to hear their music by running through a round-robin of all the users who have submitted tracks for playing.

I built Dukes about 2 years ago so my colleagues and I could play music in the office without getting into arguments, and it proved to work really well. We still got into terrible arguments over whatever nu-metal/80’s power ballad/drone doom tracks some people were into, but Dukes ensured that no one had the power to shut anyone’s picks off the air.

Dukes consists of a C# application that indexes media on the host machine as well as running a standalone HTTP server that runs the players web UI. All the indexed music metadata is stored in a small SQLite database, the music player uses the FMOD audio library, and the web UI communicates with the Dukes server using a set of JSON API’s.

The only problems with Dukes were that the UI was pretty terrible, and due to the fact that it was a tool used in-house primarily be software developers, it was very much left in a it works on my machine state. I always intended to open source the app, but really wanted to file off some of those rough edges before I did so. So this weekend I did just that, I ripped out the old web UI and replaced it with a shiny minimalist UI based on Bootstrap along with some help from Handlebars.js.

image

I also ripped through the server side c# code and gave everything a good polish, which consisted of fixing a bunch of incorrect concurrency handling, and removing a pile of half baked unnecessary features. I also wrote an NSIS installer script so that people can now easily install Dukes on their own machines.

image

You can get the source for Dukes here on GitHub, or if you want you can download the installer from my projects page.

You might also have noticed that this site looks a little different as well – In addition to polishing up Dukes, I also went Bootstrap crazy and redid the skin for this site. The big plus from doing this is that the site now looks pretty nice on mobile devices without having to go through all the pain and suffering of having to build properly responsive CSS from scratch. Its definitely a simpler, and cleaner design than I had before, and hopefully its not too generically bootstrap’ish looking.

Perhaps the elderly are on to something…

Posted on Jun 22, 2013 ramblings

Recently I had a revelation, I’ve been wasting my life sleeping in and staying up late. Sorry if you were expecting something more earth shattering and soul undermining, but the fact that this is such a common meme actually lends weight to its revelatory qualities. I’ve found that at certain times in my life pieces of otherwise banal wisdom that I have consistently ignored or refused to heed suddenly seem to snap into place.

Ever since my teenage years I have been prone to sleeping late and staying up late, and I think this pattern is pretty common among people my age, particularly in the software and gaming communities which seem to idolize the idea of pulling all nighters and waking up as the sun goes down. However as I’ve got older and busier, I’ve realized that this pattern has made me extremely unproductive when it comes to implementing side projects in addition to my day job.

There are two main problems with after work moonlighting. The main one is that by the time I’ve finished work I’m tired; I’ve put in 8-10 hours solving problems and building software already, and I’m pretty much mentally burned out. The other problem is that this after work time is the main opportunity I have for relaxing and spending time with my wife – so if I’m spending all my time coding after work, that pretty much goes out the window.

What I found was happening was that instead of using these hours in the evening as I had intended, I was extremely easily distracted and unable to really concentrate, which led to a lack of progress, which led to frustration, which led to disillusionment and basically giving up, which led to a growing sense of guilt. This had been a slow process which had been happening for a number of years and recently it occurred to me that I had things around the wrong way.

Instead of hacking in the last few hours before I went to sleep, why wasn’t I getting up hours earlier and doing it in the morning? So for the last month I’ve been getting up at 5.30 instead of 8.30, which so far has worked out fantastically. Flipping the schedule around seems to solve all the main issues I was having, I now have a good 3 hours of project time in which I’m now mentally active and alert for rather than exhausted and I am also able to relax in the evening without feeling guilty.

So I guess I’m one step closer to being a grumpy old man that gets up at the crack of dawn? Perhaps – and I’m pretty happy about it so far.

Panau Island and the Zombie apocalypse

Posted on Nov 26, 2012 ramblings

So the Just Cause 2 Multiplayer project had a 48 hour beta test this weekend which I participated in, and as you can imagine if you’ve ever played Just Cause 2, it’s absolute mayhem. However even though there was typically 500-1000 people online at any one time, as soon as you left the spawn areas and some of the more popular spots (like the ever chaotic airport) the numbers started to thin out and the atmosphere really changed. Unlike the single player game there are no NPC’s so things start to take on a post-apocalyptic feel with empty villages and highways punctuated by the occasional roving gang of road warriors or a lunatic in a fighter jet. This got me thinking, what if I took this idea, and tried playing it like a survival horror game, assuming that all the inhabitants (or most of) had been infected with some horrific zombifying affliction that turned them all into psychotics bent on total destruction (not really far from the truth). So began my epic quest to escape from Panau Island…

I started off on a calm evening in a resort nestled at the base of the Berawan Besar Mountains. My initial plan was to find a fast car and follow the coast northwest, tracking around the mountains before turning south and heading into Panau City to see if there was a way off the island at either the international airport, or the city port. However that plan was dashed the moment I set foot in the car park as I was set upon by an attack helicopter.

Dodging the rockets I commandeered a Civadier 999 Cabriolet and tried to shake the helicopter. I figured If I could get onto a highway I could probably outrun the helicopter, or at least make chasing me a boring enough exercise as to divert his attention elsewhere.

However I hadn’t counted on the Civadier’s terribly twitchy handling which meant that on my first high speed turn I ended up hitting a bump in the road and hurtling off a cliff, narrowly avoiding landing in a river. Luckily this misadventure seemed to satisfy the attack helicopter pilots desire for carnage and he moved off in search of other targets.

That'll buff right out

After swimming across the river, I made my way back to the resort and this time got myself a Titus ZJ cabriolet in British racing green and after hearing the helicopter in the distance patrolling the coast, decided to change my plans and head southwest into the mountains. I figured rather than braving the coastal highways I would encounter less resistance by cutting through the mountains and looping around the southern river delta, before heading north through the Lautan Lama desert and finally crossing Panau Tengah bay to get to Panau City.

I saw a few people in the distance as I made the ascent, but by and large the biggest threat was the mountain roads themselves.

As the afternoon headed toward evening I was approaching the summit. I passed through a couple of deserted alpine villages before finding out why no-one bothered to drive this way through the mountains - I found myself at a ski resort at the top of the mountain with no road down except for the ski slope itself.

After consulting the map it seemed like a high speed burn down a ski slope in a rear wheel drive sports car in failing light might not be such a bad idea after all. It was certainly the most direct route, and it would ensure that I would arrive (assuming I arrived at all) at the base of the ski resort in the dead of night from an unexpected angle, meaning that I would have a better chance of slipping by anyone waiting at the resort complex.

After some masterful driving I found myself near the base of the slope looking down on the ski complex. To my dismay it turns out my paranoia was well founded and there was a faction blockading the road heading out of the ski resort. This situation became somewhat worse when after sitting a little too long on the exposed slope I found out they were the proud owners of a tank and I noticed a barrage of shells heading in my direction. I gunned the Titus down the slope into a high speed slalom to avoid the shells. As I headed toward the village I realized the blockaded road out was to the right of the valley but that it curved across to the left as it snaked its way down. I figured I could go off-road to the left and keep the buildings between me and the tank and meet up with the road at its leftmost edge, bypassing the blockade.

This mostly turned out to be a good plan, except for the part where I flew off an embankment in an uncontrolled spin. After a few mid air somersaults I miraculously landed mostly intact near the road and at such speed that the tank was unable to draw a bead on me before I got back on the tarmac and headed off down the road toward the river valley between the mountains and East Tanah Raya.

It was good to be on flat roads again as I cruised south with the sun rising overhead. Unfortunately this peaceful respite didn’t last long as I soon heard the sound of a distant helicopter closing in. I decided to push my luck, hoping the helicopter would just ignore me and continued my planned course across a narrow bridge that would then allow me to cut across the islands at the southern end of Panau Tengah Bay. The attack helicopter however had other plans, and as soon as I hit the bridge, so did a hail of rockets and gunfire that left my car a slab of flaming wreckage. I managed to leap free and ran into the nearby jungle on the other side of the river. As I sprinted through the jungle the helicopter continued firing, sending trees crashing and exploding around me as I searched for cover. I soon came upon the walls of an abandoned military base, so I scaled the walls and took refuge under the largest building I could find.

As the rockets fell overhead it became apparent that this guy wasn’t going to be satisfied with anything less than a fight to the death, so I began dodging between the buildings and engaging the helicopter with small arms fire. After my counter attack the pilot made a mistake and got too low to the ground trying to get a better shot at me. His tail rotor clipped a tree, which sent the helicopter crashing to the jungle floor. Relieved, I took a moment to get a sense of my surroundings – there were a few military jeeps parked around me, but unfortunately the complex gate was closed meaning I couldn’t take one.

Having no other choice I backtracked my way out of the jungle and made my way back to the river. I didn’t remember seeing any settlements nearby so I hopped in an abandoned fishing boat and continued on my original course.

The next morning, after sheltering the night in a small fishing village, I hiked down the road a couple of miles and found a small airport. Not knowing how to fly a plane (lets keep up the suspension of belief eh?) the light aircraft were not much use to me, so I picked out a Hamaya Cougar 600 road bike and left the area trying not to gain the attention of the locals.

I began heading west toward the river delta at the southern end of the Lautan Lama Desert. I saw the occasional sport scar cartwheeling down the road toward me, and took a couple of tumbles along the narrow jungle roads, but made it to the edge of the desert at the northern end of the Senjakala Islands in one piece.

Seems I'm not the only one who has problems weith the Civadier's handling

Untitled-25

My bike wasn’t exactly in good shape at this point so I stopped at a small town to get a new ride. Unfortunately as I sat on the side of the road checking my map after acquiring a shiny new Mancini Cavallo, I was rammed at high speed by one of the local road warriors which sent my car flying into the nearby river.

Untitled-28

Not satisfied with nearly drowning me he then proceeded to try to run me down in a speedboat before tiring of my continued survival and blasted off down the river. Shaken, I pulled myself from the water and found another car of the same model which had mysteriously appeared in exactly the same location as the one I had just acquired (only this time a different color). This time I had no further encounters as I started my run across the desert.

666 miles per hour

That is until I had an unfortunate high speed impact with a gas station and had to switch to a Titus ZJ hardtop.

Untitled-30

After my last run-in I took great pains to keep my distance from any adversaries, going cross country where necessary until I found myself at the southern end of Panau Tangah bay with the prospect of a scenic night time trip by speed boat north to Panau International airport.

I arrived at the airport early in the morning hopeful that some sort of organized evacuation would be in progress for the non-zombified survivors. Unfortunately what I found was worse than I could have imagined.

All around me planes and helicopters flipped and crashed amid torrents of gunfire. Sports cars power slid across the tarmac and people hung off the wings of planes as they flew into each other. This was definitely not where I wanted to be, which left me with only one more place where I might find escape. The port at Panau City.

Everything will be okay in Panau City - I promise

To be (probably not) continued… Smile

Anyway, I’ve thought for a while that a long distance road trip game combined avoiding enemies who have superior numbers/weapons by using stealth and knowledge of the terrain would make a really interesting experience. This experiment kind of confirmed for me that the overall pacing can be engaging, and I think with the additional depth of some design-your-own-vehicle/have-to-fix-your-vehicle-when-you-wreck-it mechanics would make for a great game.

Added to TODO list

Latest tweet