Hiking in the Snow

Untitled by Craig.Vitter
Untitled, a photo by Craig.Vitter on Flickr.

Yesterday my daughter, dog, and I took a very pleasant walk through the woods and down to the Potomac river at Caledon State Park (http://www.dcr.virginia.gov/state_parks/cal.shtml) in King George, VA. The park was blanketed in roughly two inches of crunchy snow that was beautiful and made a great sound as we walked. Considering we didn’t pass as single other person on the trail I think the snow also kept the hordes away which allowed us to enjoy the pleasant sounds of birds signing, snow crunching, and waves lapping along the beach. I don’t like cold weather very much but hiking in the snow has some definite pluses!

Leesylvania Park in the Fog

Untitled by Craig.Vitter
Untitled, a photo by Craig.Vitter on Flickr.

Note: Wow, I haven’t posted anything to my blog in over a year and I posted this image from my Flickr account just as a test of different ways you can share photos from Flickr. I would never have guessed that so many people would see it much less click on the Like button. Thanks for all of the likes!

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.

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.

Lincoln Memorial at Night

Lincoln Memorial at Night

Lincoln Memorial at Night

Image: Best Photos of 2010 Blog Project

Jim Goldstein’s Best Photos of 2010 Blog Project page went live early this morning with an impressive total of 160 participating photographers. I haven’t gotten very far through the list but so far I have been wowed by the entries. I highly recommend taking some time to persue the entries.

My Best Photos of 2010 Blog Project post can be found here: Image: My Top Ten Photos of 2010.

Bangkok: The Infamous Tuk Tuk

If you are ever fortunate enough to be able to visit Bangkok, Thailand you will probably wonder whether or not you should “risk” a ride in one of ubiquitous auto rickshaws known as tuk tuks. While I was visiting Bangkok in October I spent a good deal of time fending off tuk tuk drivers. Based on my limited experience I think that most of the warnings you will read in tourist guides are at least partly true. These mainly fall into the following two categories:

  • Health and safety – Tuk tuks are open to the elements and are not designed with your health or safety in mind. While riding in a tuk tuk you will be exposed to the elements, pollution as well as being more vulnerable to injury in the event of an accident then if you were in a taxi. Traffic in Bangkok can get pretty crazy.
  • Scams – Tuk tuk drivers picking up tourists are generally running a scam that starts out with offering a really cheap ride to where ever you want to go and then taking a detour to a local store or tourist trap. The tourist traps or markets pay the tuk tuk drivers for luring tourists in.
Where tuk-tuks go to sleep

Where tuk-tuks go to sleep

I broke down and rode in a tuk tuk once during my stay in Bangkok. The choice to hop into the tuk tuk wasn’t an easy one (although being slightly lost in a foreign city helped) but negotiating the fare before jumping helped make the ride come to a successful conclusion roughly where I wanted to end up (since I didn’t actually know exactly where I wanted to go, only a rough area in the city, I ended up “roughly” where I was going).

On the street

On the street

If you are interested in taking a tuk tuk in the city here are my suggestions for getting where you want to go:

  • Don’t get in the tuk tuk until you negotiated the price of the trip and the destination.
  • Make it clear to the driver during the negotiation that you want to go straight to your destination and the side trips are not acceptable.

Most tuk tuk drivers catering to tourists seem to make their money off the side trips and not your fare so they won’t give up easily. They will offer you heavily discounted or even free rides if you agree to the proposed side trips. If you want the ride without the side trips you will need to be insistent. I repeated the phrase, “50 baht no stop” many times before the driver stopped trying to negotiate and agreed to give me a ride to Dusit Park from Wat Saket (The Golden Mount) for 50 baht (about $2).

Was it worth it? Yes. Negotiating the ride was a real pain but the experience of riding through Bangkok in a tuk tuk was actually fun (if not a little scary). Would I do it again? Maybe, however you have to keep in mind that taxis in Bangkok are safer, air conditioned, and use meters. The cost of taking a taxi is also on par with the cost of taking a tuk tuk without the hassle of negotiating the rate.

Note: I would definitely be willing to make an exception for a ride in a royal tuk tuk like the one below on display in Dusit Park.

The King's Tuk Tuk

The King's Tuk Tuk