Ahh night runs , how I love to hate them. I have generally not had the best of luck when it comes to night runs, so it was a welcomed experiance to make it to the end of the FitCal Country Club Night Trail Run (try saying that three times fast) without any serious injuries and only a smattering of annoyances. Before the race I managed to lose my headlamp (I still have no idea what happened to it since I use it almost weekly) and it felt like somone dropped a small lake on the area during the day, which makes trail running a trickier for me (I was also considering ditching when it didnt seem the rain would stop). I had also encountered issues with the original sign up process where I never recieved the confirmation email from the site, considering this seemed to be their first event and their response was fairly prompt I wasn’t overly worried about pitching up and being turned away. It was also a little odd that they didnt handle the payment on registration for the race, rather it happened on the day of the race.

Organization and generic issues

I hate to admit this but the organization left me a little wanting. While directions were provided online it would have helped to have a sign post or two to ensure people were directed easily. The payment for the race was a little weird as well, signups were handled by providing your name/surname and you were handed your race number (which is all good), but after this you chose to pay by card or cash, except no one seemed to be monitoring this and it seemed that it was totally up to the honesty of the runner to pay.


Overall the event was as good as I could have hoped for, having set a personal best time (even though none of the non champion chip users times were recorded), I am happy that my recent training has paid off. This was also one of the few races where it was small enough that it felt as if you could chat to just about everyone and generally felt more relaxed than many other races I have attended. In closing, I do wish that I could run the course in the day, but I imagine that might cause issues for the people that use the course to actually play golf.

Boom! I finished my duathlon (DualX #4) on saturday, yay for me. I had to write a few things down because I have a horrible memory, this is mostly a brain dump so don’t expect an easy read :P

Organization and generic issues

Organization for the event was really well handled. I received my race pack about 2 days ahead of time which was a nice point since friends that were taking part in the event had not received their packs for previous events.

I left for the event super early expecting all the usual issues that I experienced from previous races. But getting to the event, there was no traffic , no queues for the bathrooms, plenty of parking and a very central start location. The spacing of the race batches was almost perfect and it was amazing getting to see the elite start their race and try and glean some tips from their actions. Even though it looked like the spacing was great I am pretty sure I encountered people from other batches during my ride. The next time I do one of these events I am going to need to make sure I get a better seeding.

The heat @ 9am is much hotter than what I expected and trained at. I had done my daily training @ around the 3pm mark , which while hot was not nearly as hot as a cloudless 9am Saturday Morning.

The First run

The first run went surprisingly well, I managed to get a front of the pack position, this meant I wasn’t really blocked by anyone during the run.

I had been training @ a 6:10 pace and as expected on the day I went much faster (5:30) without feeling completely exhausted. When I hit the transition zone I was a little worried that I may have pushed to hard.

The terrain on which the run occurred was pretty awesome, the run went through some plantation field which had sprinklers on and there was nothing more awesome than being cooled off by those sprinklers. The terrain was not overly technical and consisted of some nice long flat sections which allowed you to push some speed.

This was also the first race that I had taken part in using my new barefoot shoes. I wont lie, I was a little worried that it might be an issue on the uneven ground, all my previous trail run training was on the spruit which is much smoother terrain than what I encountered on race day. Overall, the barefoot feel was awesome for this run of the race and provided amazign grip on the wetter parts of the run and only picked up minor pieces of junk.

The transition

It should be pretty obvious, but I am not an elite athlete so I wasnt expecting a 30s transition. I had practiced transitioning while training and had it around the the 3-4 minute mark. This involved changing my training type on endomondo, changing pants (I dont have tri shorts :( ), changing shoes, putting on gloves and helmet and get some water/recovery drink. I had trained running with my cycling t-shirt so that I wouldn’t need to change my t shirt and to get used to the feeling of having my phone in the cycling shirts pocket (its bounces a little but its manageable).

While I may not be an elite athlete, it doesn’t mean I treated this as anything other than a race where I wanted to do my very best. Bearing this in mind I changed a few things from my training. I did the first run with my cycling gloves on. I stopped my run on my watch but I didn’t change to the cycle mode (its way to fiddly trying to do this), I had my cycling shoes, cycling pants and helmet setup for minimal time. When the time for the transition actually happened this planning worked out exactly as I wanted with no time spent idle.

Based on some really bad calculations , I took around 1 minute for my transition, this is the time from when I got to my bike stopped my run and started the app for the cycle part. Its not ideal, but until the race organizers release more info its all I have to go.

The cycle

Take more water than you think you need. Tied back to the heat, I had trained needing a specific amount of water which was effectively a full large water bottle. On the day the crazy uphill climbs combined with the heat meant that I consumed much more water than expected. I did have my camelbak in the car but figured I would not have needed it.

In hindsight this was wrong and I am super happy that there was a water station at the transition zone, this meant that I could at least get some water before the run. The problem was mostly out of my control, I hate taking extra water because its a fair amount of weight to lug around. I feel that if the organizers posted a route map I could have been better prepared for this.

In a series of firsts , this was also my first race where I used cycling shoes that require clip in. I have had just under a month of training with them and I was fairly confident using them. They did increase my transition time a little but it feel like it was worth it. My foot placement wasn’t ideal because I felt a bit of pain in my foot early on in the race. This was mostly due to my foot angling down for way too long causing my foot to squeeze into the front of the shoes which is not how I normally position my foot.

The sandy sections on the ride (especially the uphill) were just horrible, the best way to describe it was like riding through deep beach sand. I am mostly used to riding in this kind of sand because we have sections like this on our weekly rides , but the sheer distance meant I just couldn’t sustain through the entire section (it was a good 2-3km’s).

Saw a lady fall during a particularly tricky single track section around the mid point. After that I had a horrible ride because I was constantly worried about falling as well. I also accidently turned of my camera at this point so I lost a ton of video recording between the ladies fall and when I recognized it was off.

There were two river crossing, both which I had to dismount mid way because I wasn’t in the correct position because as usual there were people bunched up at the entrance and exit.

Thanks to the river crossings I had wet socks for the run :(. While I had planned for this and had a second pair of socks at the transition ,I ended up running with the wet socks because of the heat.

I dismounted a bit early possibly on the transition from the bike to the second run because I saw a line on the ground and wasn’t sure if that was the mark of the transition start zone. It should be noted that you have to dismount before entry into the transition zone because you are not allowed to ride in the transition zone.

The Second Run

Transition into the second run went reasonably well, I managed to start the run on my phone and end the cycle session but I couldn’t bother to fiddle with my watch again. I managed to get some water and pepto at the transition table which gave me a bit of a pick up.

Even though the last run was short I didn’t want to push the speed too much because of the heat and the fairly hefty obstacles (they were just mounds to climb and decent), but the combo of the heat and run had already drained me.


Overall the event was as good as I could have hoped for, this only has me more amped to do my triathlon. At the same time I know where I stand fitness wise and can see how much more training I need to handle the increased distances. It should be noted that I did the shorter duathlon which is fairly easy. The full duathlon would have been more of a challenge to me, but because of other commitments there was no way for me to train sufficiently for the full duathlon.

Random thoughts on Hello World Projects

“Hello World”, probably one of the first pieces of text one will output as a developer learning a new language. While it’s admirable that many people are able to get to this point, I have noticed a fair number of demo projects in the .net space that cant seem to get past it.

To be fair, this usually occurs when a new project/framework is being shown off by someone that is not the projects original author. It is this need to get the smallest possible piece of code shown off to the rest of the world that tends to grind my gears and is what led me to tweet :

“Sick of hello world demo’s , do something non trivial”

The basis for this tweet came from trying to find a decent introductory project that demonstrated how OWIN could be implemented non trivially(I had an existing project I wanted to convert). Sadly pretty much every OWIN demo stops after they are able to write “hello world” to the response. I assume that I was probably just looking in the wrong places, but it’s horribly annoying trying to understand the capabilities of a system when the only code you have access to never goes beyond printing two words to the screen. In the end, reading through some documentation that seemed to be a spec of sorts, provided most of the answers I was looking for (which is that you can’t easily run your existing ASP.net project on any of the existing OWIN implementations).

After giving up on my plans to change the world with OWIN and sending out my previously mentioned tweet, I got a reply stating that people tend to gravitate towards hello world projects because they lack ideas for decent green field projects (see : ‘the need’ in the follow up tweet). Personally I feel this is an excuse that devs tend to use when they don’t want to put in the extra effort to build something fully fleshed out.

I say that because I was one of those devs that would constantly complain about never having anything to build. However, that complaint is quite hollow nowadays due to the abundance of possible projects from various sources. Personally, I have found the three options that allow me to build stuff when I don’t have anything in my personal dev queue. First and probably the easiest (though not the most original) is just re-implementing existing projects. Github is filled with tons of open source projects in just about every language, so if you want to show how a new framework works then go ahead and pick one of the projects and re-implement it using the framework you are trying to show off.

This will do two things, firstly you will either be able to re implement the project faster, in which case you show off the current use case as a bonus, or you will have the same issues as the original author of the project you are trying to re-implement. Regardless of which scenario encounter, you will come out of the experience better equipped to demo your project. At the very end if you never finish re-implementing the project, you will at least know where the shortfalls exist in your project and how you could possibly work at fixing them.

So lets assume that you don’t want to start a new project from scratch but you still want to learn a new language/framework. At the point where you would normally write up your hello world and move on, why not look one of the many open source projects that need bugs fixed? To name a few that I like: Bountysource, codetriage and github. These have some really easy to use implementations which already make things easy for you by tagging/grouping projects by difficulty and language. This way, all you need to do is filter to a project that uses a language/framework you want to work with and help them out. To me, this is better than a “hello world” demo because you get to see the issues that people encounter when building usable projects.

Lastly, if you want to learn a new language/framework and don’t want to write any code, then go ahead and review an existing project on any of the sites that I mentioned above. While this is probably the most passive means of learning, you still get to learn how another developer was able to tackle a real world problem, which you could possibly use later. As always this is all my opinion, so feel free to disagree with anything I say.

Random discussions about nullables

Dealing with nullable types in C# is a very common scenario one encounters as a developer. It’s especially common when dealing with data extracted from a database or de-serializing data from JSON

There are various methods that a developer can use to tackle these scenarios, but the progression is usually mirrored below.

A basic approach for dealing with nullabe types will often look something like this:

class NullableExample
	static void Main()
		int? num = null;

		// Is the HasValue property true? 
		if (num.HasValue)
			System.Console.WriteLine("num = " + num.Value);
			System.Console.WriteLine("num = Null");

		// y is set to zero 
		int y = num.GetValueOrDefault();

		// num.Value throws an InvalidOperationException if num.HasValue is false 
			y = num.Value;
		catch (System.InvalidOperationException e)

The code above (taken directly from msdn) shows the basic usage of a nullable type. The section below demonstrates how to create the nullable type, then checked if it is assigned and finally to act accordingly.

    int? num = null;

    // Is the HasValue property true? 
    if (num.HasValue)
        System.Console.WriteLine("num = " + num.Value);
        System.Console.WriteLine("num = Null");

While this code works it could be a bit cleaner:

int? num = null;
string testString = "We have " + num ?? 0 + " Sheep";

The code above introduces a new (new as in new to this example , the operator has been around for ages) operator called the coalescing operator. As we can see in the example above, the coalescing operator vastly simplifies the checking of a nullable type and then using an alternate value if the value is null.

While that is useful it doesnt allow for implicit casting without having to wrap everything in braces. So instead we can use the GetValueOrDefault function.

GetValueOrDefault is an instance method on all nullable types which will return the value that was set for the nullable object or a default value if it is null. Because we are dealing with a single value returned from the function, .net is able to implicity cast most values without any extra work needed from our side. Before going any further I wanted to have a look at the source code of this function to see if it was doing anything special. As expected it works exactly as I expected it to.

public T GetValueOrDefault(T defaultValue) {
	return HasValue ? value : defaultValue;

As in our original example, it simply checks if we have a value then returns that value or returns a default value that we can pass in.

Lastly an example of using this function with implicit casting for string concatanation can be seen below.

int? test = null
string testString = "We have " + test ?? 0 + " Sheep";
(1,14): error CS0019: Operator '??' cannot be applied to operands of type 'string' and 'int'

As expected that was not going to work without more brackets in place to fix the ordering, so to get it working we would need to write it as follows.

int? test = null
string testString = "We have " + (test ?? 0) + " Sheep";

As expected because we are applying the correct ordering, the ?? operator can now correctly get the value we want and cast it to a string implicitly.

To make this work with the GetValueOrDefault is just as easy, if not simpler.

int? test = null
string testString = "We have " + test.GetValueOrDefault() + " Sheep";

The example above shows how the method could be used and also demonstrates the functions ability to return the correct default value if we do not pass one in. In the example above the string will print “We have 0 Sheep” which is what we expect. We could also pass in our own default value to the function as needed.

int? test = null
string testString = "We have " + test.GetValueOrDefault(-1) + " Sheep";

This example above would print “We have -1 Sheep”, (while not really physically possible) it just demonstrates how one could seed the default value for an object type with what ever they want.

In the end all these methods perform the same job and really it just comes down to personal preference about which method you use. The biggest benefit to using the GetValueOrDefault seems to be when working with strings, as you dont need to worry about nesting of brackets. The function is also useful if you do not know what the default value should be for a specific type as the function will return the correct object types default for you.

For further examples on how the function is used have a look at the Newtonsoft.JSON library as well the internals of the microsoft clr (IEnumerable uses it for summing).

ZaCon 5

ZaCon 5 has come and gone leaving all those involved playing catch on sleep and series. One of the highlights for me this year had to be the electronic badges that were given out to all attendees that rsvp’d (and arrived early enough).

While the badges are awesome as they are , one of the things both myself and AndrewMac really wanted to see was people hacking the code and functionality. Now while the ever enthusiastic @Hypn did attempt to do this but has denied because of the time it took for us to get him setup, I am hoping that people will make mods at home and demo them at the 0xcoffee events.

Getting started

So this post is going to assume that you are a complete newbie and have never done any kind of hardware hacking at all. If you have not done so already , go read the blog post written by AndrewMac which gives a great into the board and how to interact with it.

Firstly the board consists of the following parts that you can interact with.

  • Atmega 328
  • 5110 LCD
  • 433mhz TX
  • 433mhz RX

Aside from these parts there are 3 open pins at the top of the badge that you can use to add extra parts to the badge.

The core of the badge is the atmega , its the microcontroller that controls the rest of the badge. The code for the atmega is written in the arduino programming language , which is based on C/C++ while providing a number of helper functions that make interacting with the microcontroller easier.

Before continuing , this article assumes that you have either an existing arduino uno or an avr programmer. With out one of these you cant make changes to the code on the chip in a reasonable manner.

Setup your environment

Before jumping into changing the code its worth setting up your toolchain so that the build process is as easy as possible. The article will assume that you are using windows for your dev environment , so change the paths to suit your operating system if you are using MacOS or Linux.

The first tool you need to download is the Arduino toolkit. The software can be downloaded from here. Once you have downloaded the software, either extract it to common location (e.g. c:\dev\arduino\ or install the application).

This next part is reccomended but its not required. While you can change code using the arduino IDE , it is a pain for anything more than 20 lines of code.

Download visual studio

Download visual micros

clone the repo locally

load the code in visual studio

updating the chip

  • using arduion
  • using icsp

make changes to the existing app

make changes to use each of the components

  • lcd

  • rf

  • led

  • read buttons

  • write eeprom

  • read eeprom

Go be awesome

TODO : Finish this post