Analyzing Traffic

When I first started this site a couple months ago, I signed up for Google Analytics.  I have to say, it's been one of the most interesting things to watch.  It tells you just about everything about the traffic coming in to your site.  Here's some of the stats I've found:

  • 48% of vistors use IE, while 44% use Firefox... pretty close race there.
  • Only 2% of vistors have a screen resolution of 800x600 or lower.
  • 73% of my traffic comes from Google searches (which surprised me!).
  • 33% of those Google referrals came from people searching for "wiimote tricks", which has proven to be my most popular post yet.
I could keep on going, but I don't want to bore everyone... maybe I'll post some new data in a couple months to what has changed.  Anyways, if you have a web site, I would highly recommend signing up for this.  It's easy and it's free!

Custom Sorting In C#

As most of you know, my day job is developing software.  So every once in a while I'll be posting about some interesting things that I run into when programming... and here's one of them.

One of my applications grabs a list of a large number of files (sometimes 300+), and most of the time I'm looking for files that were created within the past 3 days.  I've been using the standard DirectoryInfo.GetFiles() method, but the problem I ran into was that it sorts the array by file name and not by creation date.  To sort it by creation date, I had to create my own class that implements the IComparer interface.  This gave me the functionality to sort by whatever I wanted (in my case, I needed creation date).

internal class CustomCompare : IComparer<FileInfo> {
   public int Compare(FileInfo x, FileInfo y) {
      return DateTime.Compare(
         x.CreationTime, y.CreationTime);
   }
}

Note: By using the generic IComparer interface, I was able to save from doing unnecessary casting from the object type to the FileInfo type.

Now to use this new class, I just need to call the Array.Sort() method and use the custom class:

// Builds an array of all the files
DirectoryInfo di = new DirectoryInfo(@"C:\Directory");
FileInfo[] fi = di.GetFiles();

// Sorts the FileInfo[] array
Array.Sort(fi, new CustomCompare());

It's as easy as that!  Now I have a list of files that are sorted by creation date instead of by file name.

Cool Wiimote Tricks

If anyone has a Wii (or even just a Wiimote), here are some cool things you can do with it:

http://www.cs.cmu.edu/~johnny/projects/wii

We successfully got the Wiimote Whiteboard working at my work, and it's awesome.  It turns pretty much any surface into a touchscreen.  You can download the code (all written in C#) for each of the projects, or just run his sample applications.  Check out some of his other projects while you're on his site, he's got some very innovative ones.

Cloverfield

Christy and I went to see Cloverfield with some friends on Friday night.  I've been wanting to see this film for a while now, mostly because it's produced by J.J. Abrams (who produces/directs/writes Lost), and written by Drew Goddard (who writes for Lost).  This movie lived up to all the hype surrounding it, and even broke a box office record!  The characters were interesting, the writing was good, and the directing was... well.... good?  Haha.  But that's once of the things I loved about Cloverfield, the handheld camera made it feel that much more intense.

Now I just have to wait another 10 days for the season 4 premiere of Lost!