March 1, 2007 tools

Visual Studio Orcas March 2007 CTP

And the hits they keep on comin’:

Enjoy!

February 19, 2007 tools

Lutz Roeder’s Reflector 5.0

February 14, 2007 tools

Detailed Time Zone Data

A long time ago (2000), I was fascinated with turning a phone number into a time zone so I could tell what time it would be somewhere before I called and woke anyone up (this happened too often : ).

As part of that work, I quickly realized that info in Windows for time zones wasn’t detailed enough, so I began looking elsewhere. I found the Time Zone Map Group, which maintains time zone data for all over the world backward through time. This is an amazing accomplishment, since they have to account for every law change as each tin pot dictator comes to power, e.g. George W.

At the time, they had a custom format for the data (and they probably still do, as far as I know), so I wrote a utility to translate the tz format into XML for easy parsing. I literally haven’t touched the tool since, but with the recent time zone law changes in the US, I thought folks might be interested. Enjoy.

February 8, 2007 fun

Slide your vote in for ScottH’s Podcast

I only listen to one podcast, so casting my vote for Hanselminutes on podcast alley’s list of top podcasts was a no-brainer.

Plus, when I voted, they had a free sample for K-Y Brand Intrigue, which is apparently the longest lasting premium personal lubricant. The opportunity for jokes here is boundless, so let’s start w/ some obvious ones and I’ll send a free copy of Programming WPF to the best one in the comments:

  • I hesitate to think where the folks at podcast alley think we stow our MP3 players…
  • I like Scott, but come on…
  • What kind of gadgets has Scott been reviewing lately?!?

Enjoy. : )

February 4, 2007 tools

.NET: Decompressing zip file entries into memory

I knew that the J# libraries in .NET had zip file support, but I couldn’t find any samples that showed how to decompress the files into memory. The hard part, of course, is that the J# stream objects aren’t the same as the .NET stream objects. If you’re a Java programmer looking for a familiar library, that’s great, but I’m not, so I had to do a little finagling.

The first thing you need to do is to add a reference to the vjslib assembly, which brings in .NET classes in Java namespaces, e.g. java.io. The one we care most about is java.uti.zip, which includes ZipFile and ZipEntry. We also need java.util for the Enumeration class and java.io for the InputStream class. With these in place, we can enumerate a zip file:

using java.util; // all from vjslib assembly
using java.util.zip;
using java.io;

static void Main(string[] args) {
  if( args.Length != 1 ) {
    Console.WriteLine(“Usage: dumpzipfileoftextfiles <file>“);
    return;
  }

  // we’re assuming a zip file full of ASCII text files here
  string filename = args[0];
  ZipFile zip = new ZipFile(filename);

  try {
    // enumerate entries in the zip file
    // NOTE: can’t enum via foreach — Java objects don’t support it
    Enumeration entries = zip.entries();
    while( entries.hasMoreElements() ) {
      ZipEntry entry = (ZipEntry)entries.nextElement();

      // read text bytes into an ASCII string
      byte[] bytes = ReadZipBytes(zip, entry);
      string s = ASCIIEncoding.ASCII.GetString(bytes);

      // do something w/ the text
      string entryname = entry.getName();
      Console.WriteLine(“{0}:\r\n{1}\r\n”, entryname, s);
    }
  }
  finally {
    if( zip != null ) { zip.close(); }
  }
}

Notice the use of the Enumeration object so we can enumerate in the Java style and the use of the ZipFile and ZipEntry types. This is all stuff you could find in readily available online samples (I did). The interesting bit is the ReadZipBytes method:

static byte[] ReadZipBytes(ZipFile zip, ZipEntry entry) {
  // read contents of text stream into bytes
  InputStream instream = zip.getInputStream(entry);
  int size = (int)entry.getSize();
  sbyte[] sbytes = new sbyte[size];

  // read all the bytes into memory
  int offset = 0;
  while( true ) {
    int read = instream.read(sbytes, offset, size - offset);
    if( read == -1 ) { break; }
    offset += read;
  }
  instream.close();

  // this is the magic method for converting signed bytes
  // in unsigned bytes for use with the rest of .NET, e.g.
  // Encoding.GetString(byte[]) or new MemoryStream(byte[])
  return (byte[])(object)sbytes;
}

For those of you familiar with Java, I’m just reading the zip file entry data into an array of signed bytes. However, most .NET APIs like unsigned bytes, e.g. Encoding.GetString(byte[])” or new MemoryStream(byte[])”, which means you’ve got to convert a signed array of bytes in .NET to an unsigned array of bytes. Unfortunately, just casting doesn’t work (the compiler complains). Even more unfortunately, I could find nothing in the Convert or BitConverter classes to perform this feat of magic and the code I wrote was dog slow, so I asked around internally.

Luckily, James Manning, an MS SDE, had the answer: cast the signed byte array to an object first and then to a unsigned byte array. Thank goodness James knew that, because I didn’t find anything on this topic. Hopefully future generations will find this missive.

You can download the sample if you like. Enjoy.

February 3, 2007 fun

Stange But Real Facts

I don’t know how many of these are actually real (my left-handed son was very disappointed to hear that he’d be dying 9 years before his right-handed brother), but they were very fun to read with the kids.

P.S. Can you lick your elbow? Tom claims to have a friend that can lick his. He’s going to be very popular when he grows up…

February 2, 2007

You Can Help Find Jim Gray

From Dan Rosenfeld of Microsoft Research:

As some of you may know, our colleague Jim Gray is currently missing, having failed to return from a sailing trip in Northern California. Here’s a NYT article discussing Jim’s contributions and the efforts to find him.

I learned from the article that there’s an effort on Amazon’s Mechanical Turk site which allows volunteers to search satellite imagery for Jim’s sailboat.

You can help by spending a few minutes on the task at this site.”

Please spent a few minutes. Thank you.

February 2, 2007 tools

Windows Servers for the rest of us

Charlie Kindel of COM fame (he’s wrote the foreword to Don’s seminal work Essential COM) is the Product Unit Manager (softie-speak for butt on the line”) for the new Windows Home Server team. If you haven’t heard about it, Home Server is a Windows server box for the rest of us. I don’t know about you, but I’ve got file, print and media servers all over the house in a confusing mess and I look forward to being able to consolidate it. According to the enthusiastic beta tester I talked to, Windows Home Server is the way to do that.

Yesterday, Charlie announced the Windows Home Server Blog. Enjoy.


← Newer Entries Older Entries →