digital Utopia

Apologies

Published by . Filed under Life, Work. Total of no comments in the discussion.

My apologies for lack of updates. A project I am on is currently sinking for a multitude of reasons, some of which I want to write about, but not when I am doing 10 hour days to regain the missing weeks of time.

Object of desire

Published by . Filed under Life, Misc. Total of no comments in the discussion.

This post and the one that came previously, were written on my HTC Desire.

The WordPress app will allow me to write posts as and when they occur to me instead of what happens now which is they occur to me but are forgotten as I am not near a keyboard at the time.

A big hurrah for modern technology!

KeySonic escaped!

Published by . Filed under Leisure, Life. Total of no comments in the discussion.

One of the most used keys on my htpc keyboard is the escape key.

It’s there, easy to find in the dark and is generally handy to wake the keyboard when it is slumbering.

Unfortunately it seems I have to find a new key as the escape key escaped and one of the three clips that hold the key on has broken off, which is disappointing to say the least.

Hard to say why it broke off but could be a mixture of wear & tear, cat spillage (where a cat jumps on a pile of objects and said pile slide off where it has been sat for eternity through wind, rain and shine) and general clutziness.

C++ and Maven sitting in a tree

Published by . Filed under C++, Life, Programming, Work. Total of no comments in the discussion.

…but they definitely were not K-I-S-S-I-N-G. In fact they weren’t even holding hands.

As a test at work for a new project I was asked to look at using Maven, which is currently being used to great effect by the Java programmers, with C++. A new project has arisen that requires proof that there is 100% code coverage, has various code metrics and need to be presented at the end of it.

As usual the first thing I did was canvas the ‘Net for other peoples experiences. There is no point in reinventing the wheel if you can help it. Unfortunately peoples experiences weren’t good. On the plus side they weren’t recent.

So I set off looking at the Mojo Native Plugin. One of the first things that concerned me was the lack of direct Unit Testing support. I had noticed that several other language plugins had direct support for unit testing. However I can work around that. The other major concern was running the code metric tools that were being evaluated concurrently.

Eventually, after nearly whole frustrating week, I gave up with the Mojo tool. It was simply unworkable. Didn’t help that I am not use to paying the angle bracket tax. I then shifted my focus to the Jade Native Plugins. This is actually a fork of the Maven plugin but has moved along and supports unit testing and static analysers.

This on the face of it seems like a good thing but was again unworkable, but this is probably me more than them – I am not used to editing the pom.xml and getting the relevant info from provided examples is not easy especially when the underlying code seemingly doesn’t work with the examples.

Feeling increasingly like a failure, I turned to Hudson which several posts had pointed to. This was a breeze in comparison. A massive relief as I had a build up and running quickly and a couple of days later after overcoming a few niggardly problems I had a build that had unit tests and code coverage.

I presented my findings and guess what we picked? Option C: Maven2 execing batch files. Did I mention the PM is/was a Java programmer?

Creating directories

Published by . Filed under C++, Life, Work. Total of no comments in the discussion.

I recently had a problem at work where an application failed if the user tried to use UNC paths in a application that was ran as a service.

This service was written in C# that called into C DLL. Not only that, but the DLL was written in VC6.

So after confirming I could recreate the bug I removed the service and installed the debug version. I tested again and it was still there. I then added System.Diagnostics.Debugger.Break to the code and stepped in and through until I got to the calls to the DLL. The call stepped straight over. Hmm.

  • Debug build of the DLL: Check.
  • PDB file: Check.
  • Step into unmanaged code: Checked.
  • Debugging option: Mixed.

So what next. Maybe it wasn’t picking up the debug DLL.  So I went around and deleted every other version of the DLL. Didn’t fix it and broke most of the support apps.  Maybe it was a weird VS2K5/VC6 interaction.  So I rebuilt the library in Visual Studio but it still failed.

I could see the problematic code, but I couldn’t step in to see what the parameters were when it was there. So I created a small console app and transplanted in the problem code and called it. Worked as expected. Which brought up the idea that something was changing the parameters – but why, where and again why?! So the simple console app was extended to call the dll with every single call from the service in it with the same parameters, finally ending where the problem happened.

However it didn’t happen where I expected it to – the breakpoint I placed was never hit.  I thought that it wasn’t debugging properly still but it broke successfully if I placed a breakpoint at the start of the code. But if the code wasn’t being reached where it called CreateDirectory how comes there is a directory in the root of C:\ with the name of unc machine?

It turns out that it called a function earlier in the code than expected that uses mkdir – and the code that uses CreateDirectory never gets used due to the parameter tests that are done.

I looked at this code and thought about fixing it but there was over a hundred lines of strcat, strcpy, strtok and moving pointers around.  I decided that it was horribly broken and rewrite was in order.  So I looked on the net because this is a good case of reinventing the wheel.  Most sites, including my beloved StackOverflow, suggest using Boost.FileSystem which in my case is a non-starter. So I had a think about it and this is what I came up with after one false start:

BOOL CreateDirectories(char* path)
{
	BOOL status = TRUE;
	char* p;
	char temp_path[256];
	strcpy(temp_path, path);
	do {
		p = strrchr(temp_path, '\\');
		*p = '\0';
	} while (!SetCurrentDirectory(temp_path));
	do {
		p = strchr(temp_path, '\0');
		*p = '\\';
		status = CreateDirectory(temp_path);// do not check because this will fail on 'too\\many_slashes'
	} while (strlen(temp_path) < strlen(path));
	return status;
}

Now you can get away with removing the temp_path but I copied the original string to be safe, and I should of used MAX_PATH instead of hard-coding 256 but I think the code is quite elegant (though the WordPress formatting doesn’t really do it justice).

There’s a warning there – not to compare against the status in the while clause as having two slashes instead of one will prematurely cause the function to exit. Ignore the error that the function returns (ERROR_ALREADY_EXISTS) and the following time through it will continue to create the directories.

Aching shoulders

Published by . Filed under Leisure, Life. Total of no comments in the discussion.

I’m currently feeling it now.  Went Karting with work last night to F1K in Newcastle. Being an indoor arena I didn’t hold out much hope: My experience of indoor tracks are usually narrow with under performing karts. This is different.  The track width is about the same as that as an outdoor track, and while it is shorter than an outdoor track the karts are quick. If you are good you will be able to get under 30 sec per lap (I managed 30.8).

Final result: 2nd place and I had lapped everyone except the eventual winner who lapped me. Twice.

HTPC Keyboard

Published by . Filed under Leisure, Life. Total of no comments in the discussion.

Got myself a small wireless laptop like keyboard for my htpc as a remote control doesn’t always cut it.  I’ve been using it for a better part of a week now and here are my thought’s on it.

Firstly it is a KeySonic ACK-540 RF from Amazon.  At £30 it is hard to go wrong.  So what is like?

Lets start with the good: Firstly it is plug and play, and it doesn’t come with any CD’s. In and away you go. The trackpad is sensitive. It’s light and you can easily hold it in your left hand while operating it with your right.

The bad: The trackpad could of done with a little ridge between the scrolly pad and the actual motion pad just so you know where you are. The wake up time between it going to sleep and it responding is way too long for my liking.

I can’t comment on battery life as the 4-AAA batteries have lasted a week so far.