File Naming Conventions

Dilbert - File Naming Conventions

Dilbert - File Naming Conventions

The sad thing is that I have actually been on a “committee” like this in the past where people obsessed over naming conventions.

Meet Ruby

I am very excited to announce that we added a new member to the family today. Meet Ruby:

Ruby

Ruby

Ruby is roughly three years old and some combination of Lab and Beagle according to the shelter we adopted her from.

So far I don’t think we could have hoped for a better choice of dogs. Ruby is sweet, playful, and very social. So social she climbed right up on my chest for an afternoon nap. Unfortunately for me she weighs in at a stout 61 pounds which made breathing a bit of a challenge.

Admittedly our cats are less than thrilled about their new housemate but hopefully in the next few days they will learn to ignore the dog and get back to their normal routine.

Greatest. Comic. Ever.

Dilbert.com

De/serializing MongoDB IDs and Dates with GSON

I recently ran into a need to serialize and deserialize MongoDB Object ID’s and dates due to the manner in which the application I am working on is  using Google’s GSON library to convert data retrieved from MongoDB into POJOs.

If you rely on the built in type adapters the come with the GSON library for serialization the library will convert Object IDs from their JSON representation of {“$oid” : “4c2209f9f3924d31102bd84a”} into a plain old string (i.e. “4c2209f9f3924d31102bd84a”) when what you probably want is to serialize the value as a BSON ObjectId. The GSON library also does a poor job of serializing MongoDB’s “yyyy-MM-dd’T'HH:mm:sss’Z'” date format. Fortunately this behavior can be over ridden through the use of custom serializers and deserializers. Unfortunately I could not find any good examples of how to write custom serialization code for MongoDB online so I spent a good deal of time figuring it out through trial and error (and some help from my boss).

Below is a sample of how to serialize and deserialize the ObjectId:

@Override
public JsonElement serialize(ObjectId id, Type typeOfT,
   JsonSerializationContext context)
{
   JsonObject jo = new JsonObject();
   jo.addProperty("$oid", id.toStringMongod());
   return jo;
}
@Override
public ObjectId deserialize(JsonElement json, Type typeOfT,
   JsonDeserializationContext context) throws JsonParseException
{
   try {return new ObjectId(json.getAsJsonObject()
       .get("$oid").getAsString()); }
   catch (Exception e) { return null; }
}

Note: The full source of the GsonTypeAdapter class can be found here:  GsonTypeAdapter.txt. Please note that this code handles both MongoDB ObjectIDs and dates but it has not been optimized yet. Use it at your own risk and feel free to leave comments/critiques attached to this post.

Note 2: I wrote this code as part of my day job at IKANOW where we are doing some very cool things in the knowledge discovery and analysis space.

American Pickers is the new Antiques Roadshow

American Pickers on the History Channel is just plain awesome television. I started watching the show a couple of weeks ago and I am hooked. In fact I almost dread knowing that show is coming on late in the evening because the temptation to watch vs. sleep is too powerful.

Verdict: American Pickers is must watch reality TV.  I give it two big thumbs up.

P.S. Check out the Antique Archaeology web site while your watching the show. You can by some of the items the show’s stars have picked as well as some cool hats and t-shirt.

My 15″ MacBook Pro Quick Review…

Monday morning I rejoined the world of Mac users for the first time in about 16 years when I fired up a brand new 15″ MacBook Pro issued to me at my new job (more on that later hopefully). Here is my quick review having used the new laptop for almost a week.

Pros:

  • The base model with the 2.0GHz quad-core Intel Core i7  and 4GB of RAM (which is what I have) is more than powerful enough to handle running multiple applications including Eclipse, Flash Builder 4, MongoDB, and Chrome (with lots of open tabs) at the same time without slowing down.
  • Beautiful aluminum and glass chasis. The only laptop chasis I currently find to be nicer is the MacBook air (and the screen size on the 13″  Air model is too small for regular coding duties).
  • The 15.4″ 1440 X 900 screen is bright and beautiful. I happily discovered that stepping down from a higher resolution laptop screen has been easier on the eyes.
  • Battery life is fantastic. I have no problem working for 5 plus hours using the battery and don’t doubt it can go 7 to 8 hours on a charge with reasonable use.
  • The laptop is nearly 100% silent (of course I don’t have the greatest hearing so I am not the best judge of this).
  • The laptop never gets hot (or even lukewarm) making it reasonable to actually use it on your lap for extended periods of time.
  • Keyboard has a great feel for typing.
  • The magnetic MagSafe adapter is very clever and well engineered.

Cons:

  • The MagSafe power cord and brick is white and not nearly as aesthetically pleasing as the laptop.
  • The screen is a tad too glossy for my taste. I wish I had been able to get one of the anti-glare screens.
  • There are a couple of things I would change about the keyboard:
    • I would like to see it be a bit wider and deeper. Seems to me that there is a lot of open space for expansion of the keyboard without destroying the aesthetics of the computer.
    • Make the arrow keys a bit larger.
    • Add dedicated page up/down keys (or at least dual function).
  • No Blu-Ray disc player and there isn’t even an option to add one.

Verdict:

You might have heard the saying, “Once you go Mac you never go back.”  So, is that really true? In my case yes and no. Hardware wise this MacBook Pro is the best laptop I have ever used bar none. It blows away the Dells that I have owned and used for the last several years. Of course at a starting price of $1,799.00 on the Apple site you would expect high quality hardware.

Operating system wise OS X isn’t bad. There isn’t really anything about it though that makes it stand out over Ubuntu 10.10 or Windows 7 other than gestures possibly (which can be both cool and a pain and the butt). Frankly I think this laptop would be awesome with OS X, Ubuntu, or Windows installed on it.

Review: The Man in the White Suit

The Man in the White Suit Book Cover

The Man in the White Suit Book Cover

I just finished reading Ben Collins‘ book The Man in the White Suite: The Stig, Le Mans, the Fast Lane and Me and wanted to jot down some thoughts. As a huge fan of the BBC’s Top Gear I have been looking forward Ben Collins’ book since his  role as The Stig was confirmed last year (due in part to the law suit brought by BBC and the producers of Top Gear to keep Collins and his publisher for selling this book).

Should Collins have written this book? It seems that there is a group of very vocal Top Gear fans out there that are angry at Collins for revealing his role as The Stig and removing the mystery. Personally I don’t find it all upsetting. If I were the producers of Top Gear I would milk this for all it is worth (and they have actually, think The Stig Farm for starters). The book and the incidents around its release make for great publicity for the show.

So what about the book?

First off you should know that Ben Collins, as handy as he might be behind the wheel of a super car, is not not going to be confused for Shakespeare. The Man in the White Suit is not a work of literary art but it is a fairly tight, well paced read. Collins jumps around a fair amount (and some reviewers have complained about the disconnects) however I found the pacing and jumps to be fairly logical and tight.

The book is really aimed at someone who is a fan of Top Gear and high performance automobiles and auto racing. As a fan of all of the above I found Collins’ book to be very interesting. My primary complaint about the book is that I actually want more. I want more stories of his coming up through the auto racing ranks and definitely more behind the scenes stories from the set of Top Gear.

Verdict: If you are a Top Gear fan and don’t hate Collins for revealing that he was The Stig then you should get this book.