Archive for February, 2004

Using the DateTime class

Friday, February 27th, 2004

Good article on MSDN on using the DateTime class, and how not to use it.  It’s really easy to not consider some of the subtle issues. In almost every program I’ve ever written, if a date calculation went wrong during a time zone switch, well, nothing horribly bad would happen, so I usually tend to […]

The Trouble with the Rover

Saturday, February 21st, 2004

An article in EE Times talks about what went wrong.  

Action movies?

Friday, February 20th, 2004

Every Sunday night for years (over 10 years.. I’m not even sure exactly how many) me and some friends have gone to see a movie on Sunday nights.. usually an action movie.. Take a look at the list of movies playing.  It’s been 4 weeks now and there hasn’t been a movie to go see.  […]

Framework limitations

Thursday, February 19th, 2004

It really sucks when you’re working away on something and it’s all going really well, and then you run into a limitation in something you can’t control which throws a wrench in things… As you may have guessed from the uudecode code I posted yesterday, I’m playing with code that grabs articles from Usenet.  I’m […]


Wednesday, February 18th, 2004

public static byte[] uuDecode(string sBuffer) {   // Create an output array  byte[] outBuffer = new byte[(sBuffer.Length-1)/4*3];  int outIdx = 0;  // Get the string as an array of ASCII bytes  byte[] asciiBytes = Encoding.ASCII.GetBytes(sBuffer);  for (int i=0; i<asciiBytes.Length; i++)    asciiBytes[i] = (byte)((asciiBytes[i]-0x20) & 0x3f);   // Convert each block fo 4 input bytes […]

Inferred magic numbers

Sunday, February 15th, 2004

Putting “magic” numbers in source code is supposedly bad.. for example..   char myBuffer[12];  for (int i=0; i<12; i++)    myBuffer[i] = something; Mainly they’re bad because as code evolves, it’s possible that something will come between the declaration of myBuffer and the loop that’s using it.. and perhaps someone will add more code that uses […]

Allegiance Source Code Released

Wednesday, February 11th, 2004

Microsoft released the source to their game, Allegience.  This is a 3D space conquest game that looks pretty complex – there’s a pretty active community around the game, which influenced Microsoft’s decision to post it (at  Microsoft Research strangely enough).  The whole thing – including the source to things like the game server’s performance counter […]

Detecting user idleness

Tuesday, February 10th, 2004

Another Win32 thing that didn’t make it into the framework… sometimes you need to know if the user is idle.  Win32 provides a handy function for this, GetLastInputInfo.  Here’s the stuff you need to call it from C#: [StructLayout(LayoutKind.Sequential)]public struct LASTINPUTINFO {public Int32 cbSize;public Int32 dwTime;}; [DllImport(“USER32.DLL”, SetLastError=true)]private static extern bool GetLastInputInfo(ref LASTINPUTINFO ii); int GetIdleTime(){  […]

IE and authentication info in URLs

Saturday, February 7th, 2004

As Rob Zelt pointed out, the HTTP form of URLs was never actually allowed to have the username and password as part of the URL.  So Microsoft isn’t breaking IE, they’re making it more standards compliant.  Strange, huh?  

C++ Gotchas

Monday, February 2nd, 2004

Raymond Chen mentioned this book, here’s a Safari link.  I just started reading it but so far it’s all good stuff.  Here’s an example: A particularly odious practice is that of inserting change logs as comments at the head or tail of source code files:/* 6/17/02 SCD fixed the gaforniflat bug */ Is this useful […]