Tuesday 7 October 2008

Projects

I've only recently started doing some hobby projects recently. I've been a bit burnt out for the past year or so, so I haven't been doing anything of my own for a while. Anyway, most of the things I'm starting now are in C#, but I've also just downloaded the Google Android SDK, so we'll see how that goes.

The main personal project I am currently working on is a flow chart viewer in C#. Later I will make an editor for it too. I'm making it, because the open-source ones I can find are not Generic enough for my requirements. I'll post more on that later.

Thursday 18 September 2008

Stack Overflow

Recently, a new programming Q&A site called Stack Overflow has been released to public beta. I've been using this site for just over a day now, and I have found it to be really useful. I asked a question, and it had several good answers in a very short space of time. I've already discovered several good open source applications, and references on various topics that I may have taken years to find in the cloud by my lonesome.

So, anyway, if you are a programmer, beginner or advanced, and you want good answers to random programming questions, I would definitely suggest that site.

Spam Blogs

Hahaha. I was pleasantly surprised about 1 minute ago, when I logged into this blog in the first time in 2 years to write an entry. My pleasant surprise was that this has been automatically tagged as a spam blog. Why I pleasantly surprised? Because now I can see that Google/Blogger is doing something about all those annoying spam blogs. The fact that this got tagged as one is relatively unimportant, because (hopefully) a human reviewer will reverse that decision.

Wednesday 21 May 2008

System.IO.Ports.SerialPort.Close() Hangs

In the dotNET / .net framework v2 on Windows Vista, I have noticed that every so often a call to SerialPort.Close(); will hang forever (i.e. it has gone into deadlock). I read few posts of people who thought they had solved the problem with the prepending of the line SerialPort.ReadTimeout = 0;. However, I tried doing this, and although it made the occurence of the hang a lot less frequent, it still happened.

So, I thought there was no way to get around the hang, so I decided that I would close the port on a new thread, as well as having the SerialPort object contained in another object, which I would force the death of if I detected a hang. Well, funnily enough, after I did this, it would no longer hang at all. So it appeared that the problem was solved by simply creating a new thread from which to close the serial port. Strange.

In essence, by trying to find a way to handle the problem, the problem ended up going away. I'm not going to bother to find out why, I'll just be happy with that.

Wednesday 31 October 2007

Ignorance

For the past 3 years or so, I have been ignorant of something that I can do in C#. That is, use the a ?? b operator. This doesn't exist in C++ or C, but it is nice if you don't know about it. What is return a if it is not null, otherwise it returns b. Therefore, what was previously

return var == null ? default : var;

can now be written as

return var ?? default;

Which is nice and small. They both could also be written as

if(var == null) return default; return var;

or more verbosely as

if(var == null) {
  return default;
}
return var;

Of course, I should have discovered this 3 years ago, but I didn't, oops. Never mind, that's why, I suppose I should look at open source code, because then I would see things I didn't know about and be forced to learn them, instead of just stumbling across them. Well, I'd still be stumbling across them, just a lot faster than I am now.

Tuesday 30 October 2007

Antivirus, VS2008

Today I have just installed Visual Studio 2008 v9 Beta 2. The first two times I tried installing it it didn't work. Then I realised it was probably not installing because of the new antivirus product I had just switched to, called Comodo Antivirus, so aptly named because it was made by Comodo. Anyway, I just temporarily disabled the "On Access Scanner", and the "HIPS Application Control" and then it installed fine.

I haven't yet played around much with VS8, having just installed it, but I have had a bit of a look at the Comodo antivirus product, and it looks very nice. The user interface for the most part is quite pretty, except for a few things that go away after an initial safe-list making scan. It also asks me if I should allow a programme to run, every time I start one, so it's quite paranoid, which is good. An antivirus product should be paranoid, and so should all computer users.

Anyway, there is a cute software project I made a while back, a few years now, but due to backup incompetence I have lost the original source (as well as the compiled examples). Never mind, I will be making it soon enough. Basically it is a hierarchical view control that behaves like a treeview control, and looks like a family tree. Anyway, the original implementation I made was quite neat. There was also I nice side tab control I made once, which has also disappeared of the face of the Earth.

Thinking down that path, there is also a little photography programme I made, which basically loads in a list of students from a school database, and then divides everything into classes, and allows the names to be added into a caption underneath it. The names are dynamic, and the list of students could be printed as barcodes and scanned in. This is useful, because it means for the most part that the students names are spelt properly (as long as they are in the school database). But now I have to make that again as well. Never mind.

Thursday 10 May 2007

The Mythical 1.44MB floppy

Well, the days of 3 1/2" floppies have long since passed (for most of us), although I'm sure 5 1/4" floppies are still being used... somewhere. Anyway, now is as good a time as any to explain why 1.44MB floppies never have been that size, and never can be.

To start off, a 1.44MB floppy has a capacity of exactly 1,474,560B. Wait a minute! Isn't that 1.47MB? Well, yes, if you use SI units (1 megabyte = 10^6 bytes). Isn't that 1.41MB? Think those of you to whom a megabyte is 2^20 bytes. But hey! Under neither definition of a MB does the 3 1/2" floppy fit!

Why?

Whoever called it the 1.44MB floppy decided that a kB was 1024 bytes, while a MB was 1000kB (1,024,000 Bytes). Multiply by 1.44, and behold! 1,474,560 bytes.

Isn't that crazy?

Monday 7 May 2007

Timezone Information on Windows

I was trying to find out how to grab the current timezone settings from the Windows registry, so I searched on the Internet, and eventually found where it was stored

(HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation)

, but most sites that showed the data structure were wrong. Only with one thing, that was which 16 bit integer represented the day of the week. Most sites said it was the 3rd Integer, but actually, it is the 8th (or last) Integer in the keys "StandardStart" and "DaylightStart". Eventually I found a site that said the right thing, so I'm going to list it here anyway.

 

Path: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation
Keys: StandardStart and DaylightStart
All integers are two byte big endian
Integer IndexRepresents
0Year: 0 = 1900
1Month: 1 = January ... 12 = December
2Week: 1 = First week ... 5 = Last Week
3Hour: 0 = Midnight, 23 = 11pm
4Minute: 0 - 59
5Second: 0 - 59
6Millisecond: 0 - 999
7Day of week: 0 = Sunday ... 6 = Saturday

 

So, there you have it.