Lachlan B's Blog

An android app for Timor Leste

For the past couple of weeks I have been developing a mobile app for Livru Timor in association with Rhok Australia.

The basic problem that we are trying to solve is translating some childrens books into a bunch of different languages. Sounds simple right? Well the main issue is that we don't really know what these languages are! We don't know what a lot of their words are, and we don't really know where they are spoken. In 2015.

So why don't we have a simple android app where you can go to a local village and ask a bunch of people what their words are for things? We could even record them saying their words. Then we could collate the data and send it back to a server in Melbourne and figure it all out... and translate a bunch of these childrens books to their native languages and the kids will have a much higher chance of learning how to read and write! Cool huh?

Oh and BTW, the android phones that they have in Timor Leste are basic. Very basic. Most of them don't even have data. You need to be able to store all of that information offline, and then at some stage be able to upload it to a server once we've on a (somewhat) more reliable wifi network :)
...
Read More ->

What programming concepts I should master to have a deep understanding of my craft?

So you’ve been working as a programmer for a couple of years, and you want to become a good programmer. But not just a good programmer, you want to be a GREAT programmer. You want to paint with ALL the colors. Hell, you want to paint with all the dimensions. You want to be the GURU of programming – not just some nerd that’s stuck in corner that knows every namespace in the .NET API and can punch out a website in a day – you want to be a Michelangelo. A Picasso. Programming isn’t a science, it’s an art. You want to be respected.

Boy that’s a big ask.

So how do you get started?

By now you’ve hopefully realized that what makes good programmers great isn’t necessarily their technical skills. Your technical skills can be AWESOME, but if you don’t know what your customer wants, they amount to diddly squat. Of course if you know what your customer wants but don’t have the technical skills to back it up, you’re also up the creek. So what are the technical things you want to learn?

* How to write “DRY” code. DRY stands for “Don’t Repeat Yourself”. Copy and paste coders are not real coders. If you find yourself writing the same (or similar enough) lines of code more than once, it needs to be cleaned up so that you don’t have duplicate code all over the place. This will actually keep your codebase smaller, easier to maintain and reduce your bug count. People call this refactoring and it’s a daily part of ou...
Read More ->

How to know you've been coding too long in .NET

  1. Ever called .First() instead of FirstOrDefaut() and had it throw an exception instead of what any sane person would expect and return null?

  2. Ever expected For Each on a null collection to work the same as an empty collection... (I HATE, HATE THIS)

  3. Ever called .Hours() instead of .TotalHours() on a TimeSpan object?

  4. Ever called .Append() or .Sort or .AddHours() or .Replace() .. and it didn't do anything? But then you realise that it RETURNS the value?

  5. Have you ever forgotten to specify the correct app pool in IIS and accidently run against the incorrect framework?

  6. Have you ever developed against IIS Express and discovered the world of difference with your production IIS server?

  7. Stupid, stupid American mm/dd/yyyy format!! Have you ever entered a date of 1/12/2015 and it worked great, then you try 1/13/2015 and it FAILS? (Every single developer in Australia and in the UK hates datetime parsing, because no matter what you do, your server, or your code, or your database server, or your model binding in MVC, or who knows what else... will sometimes decide for no apparent reason that it's going to parse your dates in the (stupid) US format.)

  8. Talking about MVC, did you know that a json object that has a property set to 0 or 1, when bound to a .NET object with a boolean property, using the s...
    Read More ->

An ASP.NET bug from 1973

Today, I was coding an ASP.NET 4.5 REST api using WebApi 2, and was caught out by a problem caused by a technical decision made forty two years ago.

I think I need to repeat that again. FORTY TWO years ago. (Yes, it's spelt f-o-r-t-y, not f-o-u-r-t-y, thanks anonymous pedantic reader!)

1973! The year when Aerosmith released their debut album! The year Elvis Presley's concert in Hawaii had more watchers than the moon landing!

Apparently, in ASP.NET, having a URL end in "AUX" causes it to throw a 404 error.

This might happen if you were building a RESTful web service that validated country codes. For example, you might make a request to this URL

http://myserver.com/ValidateCountryCode/NZ

Which would return "New Zealand".

Or maybe you're testing Australia:

http://myserver.com/ValidateCountryCode/AU

And then of course, you want to test your web service to see what would happen if you passed through invalid country code:

http://myserver.com/ValidateCountryCode/AUx

Which gives you a 404 error, thanks to CP/M, an operating system coded in 1973.

What a conundrum! Do I fix it or apply the patch?

...
Read More ->

Succeeding at every job interview

The HR boss of google, Laszlo Bock, is spruiking his new "Work Rules!" book. As part of the promotion campaign he has written a very popular linkedin post explaining "How to win every interview with these 6 steps".

Now apart from the obvious clickbaity title, which I'm prepared to give a little bit of leeway, I would like to point out just how wrong he is.

Normally I would leave these kind of clickbaity promotional marketing articles alone and treat them with the contempt they deserve, but in this case, it's coming from the HR manager of google, who you assume would know better. I also feel that this type of article rather is also extremely demotivating to the job seeker, and Mr Bock should know better.

So to start with the positive aspects of this article. In general, these tips will probably help differentiate you from some of the competition. Doing your research, having a pre-prepared list of questions and answers are all a smart way to prepare. Rehearsing your answers is a great idea.

But will it help you win every interview?

NO.


You know why?

  • People are unpredictable. They might have gone for you yesterday, but today, they are extra tired. Yesterday they wanted to take a gamble on someone like you, but today, they just aren't feeling up to depending their decision.

  • Interviewers are biased. To put ...
    Read More ->

Generating barcodes with zen barcode generator

Someone asked me on Sunday if it would be possible to generate a PDF that had a barcode in it. I haven't generated a "normal" boring 2D barcode before, so I thought I'd give it a crack. I find a library named Barcode Rendering Framework, downloaded it, looked for the documentation on how to use it... and there isn't any.

I mean, there is literally none. The answer is "look at the code samples". This attitude drives me up the wall. It would seriously take the developer 10 minutes to write a good document explaining how the thing works and how to use it. But can they be bothered? Nope. So after much head scratching and stuffing around I figured it out.

private string getBarcode(int type)
{
	BarcodeSymbology s = BarcodeSymbology.Code39C;
	BarcodeDraw drawObject = BarcodeDrawFactory.GetSymbology(s);
	var metrics = drawObject.GetDefaultMetrics(60);
	metrics.Scale = 2;
	var barcodeImage = drawObject.Draw("1234123132", metrics);

	using (MemoryStream ms = new MemoryStream())
	{
	    barcodeImage.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
	    byte[] imageBytes = ms.ToArray();

	    return Convert.ToBase64String(imageBytes);
	}
}


And then to embed it on the page I just use an image tag:

 <img src="data:image/png;base64,bytearraydatagoeshere" /> 

Which produces th...
Read More ->

Moving from classic ASP to MVC5

So the past few weeks I've been re-writing my website. Previously it was written in Classic ASP (yes, you read that right) and it was running off a Microsoft Access database. Yes, you read that right too.

The code has served me well since I launched in 2006, and can I point out, that was NINE years ago. I have to salute classic ASP for doing a pretty bang up job. The site rarely went down, it was never hacked (apart from a mountain of comment spam) and it was all-in-all, pretty good fun.

But the past couple of years has seen a huge improvement in website coding. It's all so much easier and more fun now, so I figured I might as well rewrite it in ASP.NET and move it to MVC. So here's the full stack of technologies:

  • Bootstrap for the front end - fantastic library once you get your head around it

  • JQuery for the little ajaxed archive box over to the right

  • ASP.NET MVC4 for the back end

  • Entity framework for talking to the DB

  • SQL Server for the DB

The whole thing was coded using Visual Studio community edition and SQL Server express. Half was written on my desktop, and the other half was written on my MacBook air running a windows 7 VM using Parallels - a process that ran surprisingly well. I synced the code between the two machines using Git Gui, another process that...
Read More ->

Top 10 guitar solos of all time

A few days ago I saw this. And I think it's an abomination. I guess I deserve all that I get reading anything from the nme :)

So in an attempt to give a bit more credence to the guitarists who actually, you know, know how to play the guitar, here's the guitar solo's that I think really re-defined the art of the electric guitar.

1. Deep Purple - Lazy

In 1972 Deep Purple decided to record the rock album of all time. Every solo on this album is a killer, and every song is a killer. Deep purple have always been an amazing live band and this really shows up in their chemistry.


2. Eddie Van Halen - Eruption

In 1979 Eddie Van Halen exploded all over his first album and boy was this a stunner. For years nobody could work out how he did it and called him a cheat! But we know the truth.. the guy was a genius!


3. Yngie Malmsteen - Far Beyond the Sun

In 1984 Malmsteen released "Rising Force" and defined a new style of metal - neoclassical. Similar to Van Halen a lot of people thought that his records were sped up - how could anyone play that fast?


4. Joe Satriani - Crushing Day

In 1987 Joe Satriani sat down and recorded the epitome of instrumental rock. The classic "Surfing with the alien". Too many great solo's to choose from, so ...
Read More ->

Shoot Em Ups Album

Remember those cool games in the 80's where you shot everything in sight? Those were the best games. The music was sometimes pretty cool too - and made even better when bought into the present with some MASSIVE GUITARS.

Shoot 'Em Ups


This collection features Doom 2, Commander Keen 4, R-Type, Ghouls and Ghosts, Double Dragon, and two tunes from the obscure Japanese PC only shoot-em-up games named Touhou!

Track listing:

1. Deep Mountain (Touhou #7 Stage 1) - 03:06

This is the first song that I'd recorded in a while. I went for a different approach with contrasting between the clean guitars and then the monstrously heavy 7-string, and then back to the acoustic. Compositionally wise it's pretty simple, just repeating the main melody 3 times, but it's the arrangement that (hopefully) makes it interesting. Ideally I would have liked to expand the heavy section, but in a short burst it leaves you wanting more.





2. Read More ->

Next covers album track 2

Track number 2 is a medley of tunes from R-Type:



It's an epic 6 minuter that syncs up exactly with the original version. Phew!
Read More ->