Someone linked to http://golf.shinh.org/p.rb?FizzBuzz today and I couldn’t help but have a go. Currently I’m ranked 20 in the C# solutions, but I just can’t seem to shave off those last few characters. [The following code is obviously unminified] class X { static void Main() { for (int i=0; i 0 ? null : “Buzz”; [...]
I was so very tempted to post a response to this question on tabs vs. spaces on SO today. (I did actually write one, but deleted it and voted to close for being too subjective) I thought it would be better to post my response here instead. The question is which is better for formatting [...]
I just started a new job, and as part of the induction we had to do a lot of complete builds, both for an application server and for a pretty substantial database. Needless to say, these took quite a long time. I found myself wishing there was a way for the computer to notify me [...]
I’ve seen a lot of people getting confused about value/reference types, and passing by value/reference, so I thought I’d write a post to explain it. These are two different phenomena with confusingly similar names. Value/reference types are to do with how values are copied when assigning from one variable to another. Passing by value/reference is [...]
Just because a language is Turing Complete, it doesn’t necessarily mean that the execution is. This is because, while languages rarely bother about details like the size of memory, a particular implementation and execution environment place restrictions on things like the amount of memory available. Take, for example, the problem of adding natural numbers in [...]
I meant to write this post sometime last year, in response to some things said by some colleagues on my course but never got around to it. It turns out that they still don’t seem to full understand, so I guess I’ll write it now I decided to split it up a bit, so without [...]
A while back I wrote a post including some Javascript to add what I called “hints” to fields in HTML. Since then, HTML5 has added the same thing, under the name “placeholder text”. All you have to do is add “placeholder=’Some Text’” and ‘Some Text’ will appear as a placeholder, disappearing when you focus the [...]
We all know we shouldn’t optimise prematurely our code or try and guess where code needs optimising. Optimisations should only be done as the result of consideration of performance measurements. But sometimes we can go too far the other way – rarely optimising and instead living with inefficient algorithms and code. If your algorithm iterates [...]
Mono 2.6 has just been released and can be downloaded from their website. I’ve been using Mono for several months now on my MacBook, and it’s been surprisingly useful. Not only is it an implementation of the C# compiler, .NET runtime and Base Class Libraries, they also have a collection of their own utility libraries. [...]
I was reading about permutation algorithms to try and solve a completely unrelated problem when I came across this. It’s an algorithm to generate a random subset of size s from n elements. I’ve needed something like this in the past, and so no doubt I’ll need something like it again in the future. private [...]