graham.reeds/

KeySonic escaped!

May 16th, 2010 :: graham.reeds
Categories: Leisure ::Life

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.

0 comments.

C++ and Maven sitting in a tree

May 8th, 2010 :: graham.reeds
Categories: C++ ::Life ::Programming ::Work

…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?

0 comments.

Creating directories

April 8th, 2010 :: graham.reeds
Categories: C++ ::Life ::Work

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.

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, 0);// 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.

0 comments.

Karting

March 31st, 2010 :: graham.reeds
Categories: Leisure ::Life

Myself, 2 colleagues and a former boss have decided to enter the British 24 hour karting race running over the 28th and 29th August. It is our first time but I think we are all pretty excited by it.

0 comments.

Aching shoulders

February 19th, 2010 :: graham.reeds
Categories: Leisure ::Life

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.

0 comments.

HTPC Keyboard

February 14th, 2010 :: graham.reeds
Categories: Leisure ::Life

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.

0 comments.

Lost phone

January 28th, 2010 :: graham.reeds
Categories: Leisure ::Life

…but thankfully it was been found at Carlisle station who were gracious to mail it back to me (after I sent them a SAE for £2).

So if you tried to ring me between Tuesday and today then you will probably got told that the phone was out of service as the first thing I did when I found it was missing was to get orange to lock it for me.

Now it is back alive and waiting for your call!

0 comments.

RIP Damage

January 28th, 2010 :: graham.reeds
Categories: Leisure ::Life

One of Middlesbrough’s more colourful denizens passed away earlier in the week.

You will be missed but never forgotten.

0 comments.

Sorry for the lack of updates

January 28th, 2010 :: graham.reeds
Categories: Leisure ::Life

…but normal service will hopefully resume.

0 comments.

Worst service ever

January 2nd, 2010 :: graham.reeds
Categories: Leisure ::Life ::Restaurants ::Reviews

We went out for a New Year meal with friends. They picked the venue, based on the rave reviews that people gave it. The place was the Happy Valley chinese restaurant in Norton. The service was bad. It was worse than the Akbar Dynasty. We were seated at about 9.00pm at the correct time, which was the only thing they got right all evening. This is a blow by blow account of that evening.

As a table of 9, we were probably the largest table in the restaurant, and we weren’t exactly sat there in silence. But after an hour no one had come to ask if we would like drinks, or even given us menus. So we went up and ordered them ourselves; a couple of bottles of wine, a few beers, bottles, etc. They told us they would bring it to our table. But nothing arrived, we went and asked and they told us they lost the order. We reordered. They bought a bottle and then went around serving every other table before finally bring us the rest of the drinks (as you will see this is action repeated).

At some point in here we got our menus. Essentially there was a choice of 6 main courses. So it was fairly simple, one of each and 3 extra of what seemed to be the most popular. Took about 30 seconds to decide. Pity it took them at least half hour to actually ask us.

So, just to recap: We got there at 9pm and we haven’t had anything to eat till 10:30pm.

First course: Soup. Chicken, ham, peas, mushrooms, and gelatine. Yes big lumps of gloopy jelly at the bottom of the soup bowls.  Not must appetising.  Then there was a massive wait until…

Second course: Prawn Toast, Spring Rolls, Kebabs in Satay Sauce, Salted Chicken and Crispy Seaweed. About as good as what you would get from Iceland.

Third course (Part 1): Strips of cucumber, carrot and spring roll, Hosin sauce and a 10 minute wait.

Third course (Part 2): Crispy fried duck and a 5 minute wait.

Third course (Part 3): Pancakes! By this time Mrs Bear was so hungry she even ate the duck, which still feels guilty about.

Fourth course (Part 1): A plate of pork slices and a 5 minute wait.

Fourth course (Part 2): All the other meals, and the plate that had held the pork was taken away.

Fourth course (Part 3): Two bowls of rice. By this time we had gorged ourselves on the other courses.

As you can see there wasn’t much happiness in the Happy Valley from our table. Seeing tables that we seated a long while after us (even it was just a couple) get served before us was wholly wrong. If they were understaffed, then that is their problem to sort out – they knew how busy it was going to be. The only thing that stopped the evening from being a complete loss was the company we had and we spent most of the night laughing – probably because we got drunk on empty stomachs.

As for midnight, we only realised about 30 seconds to go (or two minutes depending on whose watch you used). No count down or anything from the staff. We did the count down for the entire room.  We did get a bottle of Asda Asti for the table though.

2 comments.

« Previous PageOlder » « NewerNext Page »