wea·sel·ly (adj.)
Resembling or suggestive of a weasel.

Yesterday, Parcelforce called me at work to say they tried to deliver a package for me the day before, but couldn’t because I wasn’t around to sign for it.

I wasn’t expecting anything, but I like getting parcels, and thought maybe it was some long-forgotten internet purchase finally shipped. They wanted to arrange redelivery that afternoon, and asked for a couple of names of people who could sign for it just in case I was out (it was around 11am and I knew I would be stepping out briefly for lunch).

But twenty four hours later nothing has arrived. I think it was actually a recruitment agent, and the colleauges I gave as co-signatures will be getting some annoying calls soon :(

August 10th, 2010 | 2 Comments

Announcement: in just over a fortnight I’ll be packing my bags to go chase the kiwi dream – I’m moving to London!

Provoke has been a wonderful home for the past two years, and I thank all my workmates and clients who made my time there so special. Working here has really been an unforgettable experience, and I hope to take a little bit of that magic onto future jobs and organisations.

So far, my immediate plan for the next few months involves .NET architecture/development work in London, probably on contract basis so I can fit in some travel around Europe between projects. I’m also keen to check out the various developer conferences like QCon and Oredev. But first, I need to start packing!

January 18th, 2010 | 4 Comments

Last week I had to write a little javascript for a form that involved a long list of check boxes. To save time, the application only processes rows where the checkbox value actually changed away from its original state.

For example, if a checkbox was checked to begin with, then the user unchecks it then re-checks it, we don’t have to do anything because although it did change, it ended up back at the same original state.

This is pretty easy to achieve by remembering the original state of the checkbox using jQuery data — library methods for storing arbitrary javascript objects in DOM elements — then comparing against the original value when toggled.

<script type="text/javascript">
	$(document).ready(function() {

		// Set aside the original state of each checkbox.
		$("input.toggle").each(function() {
			$(this).data("originallyChecked", $(this).is(":checked"));
		});

		// Check whether it really changed on click.
		$("input.toggle").change(function() {
			var action = $(this).siblings("span");

			if ($(this).data("originallyChecked") == $(this).is(":checked"))
				action.text("(no change)");
			else
				action.text($(this).is(":checked") ? "added" : "removed");
		});
	});
</script>
<ol>
	<li>Apple <input type="checkbox" class="toggle" /> <span/></li>
	<li>Banana <input type="checkbox" class="toggle" checked /> <span/></li>
	<li>Carrot <input type="checkbox" class="toggle" /> <span/></li>
	<li>Zucchini <input type="checkbox" class="toggle" checked /> <span/></li>
</ol>

The next requirement was adding a select/deselect all button. This proved a little bit more difficult, because of the way jQuery deals with events and the checked attribute. To cut a long story short, I ended up with an event handler that manually sets the checked attribute and then fires the change event on all the checkboxes (I tried the click event first, but it didn’t seem to pick up the new state).

$(document).ready(function() {
	$("input#select-all").click(function() {
		$("input.toggle").attr('checked', this.checked);
		$("input.toggle").change();
	});
});

Altogether, it works very nicely in only a few lines of javascript. You can see the whole thing in action here.

December 6th, 2009 | 2 Comments

Disclaimer: I usually only write about code, and certainly this is not a product review blog, but this is something that really made my day. And their web pages end in .aspx so technically it is .NET related.

Yesterday, I came a forum post alerting ASB customers to check out their new Track My Spending online banking feature:

ASB Track My Money expense tracking (not mine)

The reason I’m so stoked about this feature is because I’ve been looking for a way of tracking where my day-to-day money is spent for a few months now.

I was considering moving banks to somewhere that supported OFX Direct Connect (so I can download my transaction logs automatically and sort them with a tool like GNUCash or Quicken), and I even started writing the foundations of a little WPF app to do it.

Now I can see pie charts and expense breakdowns just below the rest of my internet banking. What’s more is the transaction coding process is almost exactly the same as I had envisaged for my app — categorize one transaction, and it’ll automatically tag all similar transactions with the same label.

Coding transactions

To be honest, I never would’ve expected something like this from ASB — the rest of their online banking interface is pretty clunky and looks exactly the same as it did 6-7 years since I first became a customer. So it was a nice suprise to find this little gem hidden in the junk section of the online banking menus.

I’m not sure if other banks maybe already have features like this (probably even better ones), but I was very impressed anyway. So congratulations ASB, you guys hit the nail on the head and made one very satisfied customer at least!

August 6th, 2009 | 4 Comments

If you’ve ever used Unix, you’ll no doubt be well-aquainted with the commands ps and kill. On Windows, the graphical Task Manager performs these roles pretty well, but if you ever find yourself needing to resort to the command line to kill a process (e.g. for some reason on the Vista machine I am writing this on Task Manager just sits in the system tray flashing instead of opening), the Windows equivalents of ps and kill are tasklist and taskkill:

tasklist /v  - equivalent to ps aux
taskkill /f /im ncover*  - equivalent to kill -9 ncover*
June 18th, 2009 | 2 Comments