This past weekend I’ve been rather active on the shopping front. First off, I’ve indulged myself and bought myself a new motorbike. I had been thinking about getting a new one for a while now but, being my lazy self, I’ve not been bothered to do anything about it. With my good friend Shane looking at getting a bike (possibly my Bandit 600) I finally got my act together.
When I started looking I was thinking about something like a GSX-R750 (again) or an R6. Instead I’ve swung to the complete opposite end of the motorbike spectrum and have put a deposit on a BMW R1200GS. I wasn’t looking for anything that big but I took one out for a test ride and have fallen in love with it. Whilst it has got an engine twice the size of my Bandit, it is a lot more economical, most reviews seem to suggest it should manage 45mpg, so with a 33 litre tank I should be able to do 300+ miles. That’s nearly double the range of the Bandit! Now I just need to get the finance and insurance sorted out.
The other purchase was for the fish tank. For some time now we have had a Gibbiceps Plec that was far too big for the tank – about 6 inches in a 45 litre tank. So, this weekend we finally took him back to Bishes Fishes. Unfortunately, getting rid of the plec meant that we lost out main algae eater, so we decided to get another smaller plec, although I can for the life of me remember the type. As well as the new plec we also got two freshwater shrimps to help clean up the bottom of the tank. As we were return the Gibbiceps, we got one of the shrimps for free ^_^
I promise this will be the last post for a while to include a QR-Code. If you don’t know what a QR-Code is, go read about it on wikipedia. There are several QR-Code readers out there but I have personally chosen to go with the Kaywa Reader. I also use the Kaywa QR-Code generator.
The reason for this post was to play with an idea I came up with after reading the Wikipedia article on QR-Codes. One of the images they show is of an picture encoded into the code. Whilst I haven’t yet been able to figure out how they encoded the image into the code I have made another discovery. It turns out that QR-Codes contain a lot of redundancy. It is possible to loose up to 30% of the code and still be able to read its content.
I’ve found that it is possible to paste an image over the top of the QR-Code. My experiments so far indicate seem to indicate the image needs to cover less than 30%. I haven’t had to time to find out how the QR-Codes are structured. It may be possible in re-structure the data so that more of it can be lost to the embedded image.
Many, many times in my programming life I have seen people causing themselves all sorts of problems as the try and concatenate paths for file and directories. They’re always trying to work if the path already ends with a directory separator or not. And then there are the cross platform systems that try to workout what the directory separator should be.
With the release of the .Net platform, Microsoft gave developers that need to handle file system operations a wonderful, but underused, utility class: System.IO.Path. One of the methods on this class is Combine(). It take two arguments: path1 (string) and path2 (string), and intelligently combines them.
That’s it! No more messing around with string concatenation or endless if statements or figuring out if it should be a forward or backslash… just Path.Combine().
I’m not sure if this is a well known feature of Visual Studio but it’s something I’ve used in the past and have just had need to use again. When debugging an application in Visual Studio it is possible to use System.Diagnostics.Debug.WriteLine() or System.Diagnostics.Trace.WriteLine() to write messages to the output window in Visual Studio, I’m sure that’s nothing new to most .Net developers.
What you might not be aware of is the fact that if you output the full path to a file, you can then double click on the file name in the output window and it will be opened in Visual Studio. Also, if you output a number in parentheses after the file name, Visual Studio will try to take you to that line number, e.g.:
That’s great, but how could you use this IRL? I’ve just combined this with the System.Diagnostics.StackTrace class. I have a method that gets called many times from many different locations in the code and, under certain circumstances, I’d like to know where the method is being called from. You can use the StackTrace class to find out where the method is being called from, and the Debug.WriteLine() to output this information to the output window:
1: StackTrace myStack = new StackTrace(true);
2: StackFrame lastFrame = myStack.GetFrame(1);
Normally if you are wanting to break out to the source code when you hit the line would probably put a break point, possibly with a condition, but sometimes you might not want to break execution and instead just want to record the fact that you hit that point and how you got to it, in which case this snippet could be useful.