This blog has moved to Medium

Subscribe via email


Archive for October 2008

Globalizing DateTime.TryParse()

DateTime.TryParse() is the sane method in .NET to parse date strings (don’t use Date.Parse() – you want to handle bad user input correctly, and throwing exceptions usually isn’t the correct way, especially if all you want is to just skip the bad date field). Well, I’ve just discovered yesterday that the dates it returns are in the local computer time. If you try to parse “31/12/08 23:59:59” and you happen to be in GMT+2, the time you’ll get will be 2 hours off.

To solve, simply run ToUniversal() on the resulting DateTime. I use:

bool TryParseUniversal(string dateString, out DateTime date)
{
  if (!DateTime.TryParse(dateString, out date))
    return false;
 
  date = date.ToUniversal();
  return true;
}

How sorting works

A very cool visual demonstration how various sorting algorithms work on different inputs.

MSBuild FxCopSolution Task

Objective – Automatically run FxCop on our solution

Possible solution – existing FxCop Community Task

Problems with solution:

  1. Only compatible with FxCop 1.32 (hard coded folder path!!!)
  2. Accepts only DLLs as input, not a solution (our solution doesn’t have a single output directory, so the DLLs are scattered)

Solution – writing a custom task called FxCopSolution and tweaking the FxCop task.

For now, I couldn’t get a hold of the lead developer, this is not checked in to the main repository in Tigris. The source code and binaries should be in this zip file.

This zip contains:

  1. Source – The source for the FxCopSolution task
    1. Unfortunately the unit tests are not very useful, beacuse it’s currently impossible to actually run the task from inside the tes.
    2. I included some 3rd party libraries not included in the original MSBuild release, that were needed to compile it (before my changes).
    3. I had to comment out the Source Safe tasks – they required a lib I didn’t find.
  2. Bin – Everything needed to deploy the task
    1. Sample.MSBuild.proj – a sample MSBuild project that uses the task
    2. Build/MSBuildCommunityTasks – a folder containing the binaries
    3. Build/fxcop-summary.xsl – an XSL I found somewhere that translates the output from FxCop to a displayable HTML. It’s not that pretty (suggestions are welcome), but it does the job.

We integrated the task with TeamCity (simply adding another MSBuild build and specifying as artifact Build/Output.html), and now our build displays a huge number of FxCop errors we’ll fix in the following weeks.

If you have any errors using the zip (there are bound to be a few silly ones) and/or questions, feel free to contact me at ron.gross@gmail.com.

A few blogging tools

Since I moved to my own host I played with a few useful tools.

  • I already commented on the wordpress plugins I use. Today I’m adding OneClick – single click plugin installer & updater – it makes it really easy to install a plugin by a URL). It also has a Firefox extension, which I didn’t install. I just revisted Moti’s comment on the above post, and saw this was one of his recommendations. The other recommendation I accepted is FeedBurner FeedSmith, although I already implemented itse functionality with the redirect plugin.
  • A handy tool (depending on your hosting solution) is PHPShell. It uses the provided PHP to give you an easy shell, if your provider doesn’t give you one.
  • Finally, Google’s webmasters’ toolkit is a good tool for analysing your blog/site – recommened.

What tools do you use?

Also, I just saw my old pagerank of 4 is gone now, because I have no direct links to this blog, just to the old Blogger one (well, was to be expected). I’d appreciate it if any of you with incoming blogroll links update to the new website (yeah I know, I should start a blogroll as well … someday).

P.S.

Heroes season 3 appears to be less bad than season 2.

Week in Los Angeles

It appears that despite what I thought before, the migration to my own domain didn’t go smoothly. Although I was sure I changed the feed details at Feedburner, somehow it didn’t stick, so email subscription (or perhaps feed readers as well) didn’t work – I guess most of you missed this post.

Hopefully, they’re working now (let met know if they’re not).

Just so this post will not be totally a meta-post, let me write a bit on what we’ve been doing here this past week.

Music – we heard a jazz concert by Hiromi’s Sonic Boom – I guess they can be classified as jazz, but it’s unlike other jazz you might have heard. Hiromi, on the piano, gives a very emotional show, and the other accomplished members of the band play well together. I can’t really describe the music so I refer you Google her (my web browser here is a shitty KMart browser so I can’t even find a sound sample for technical reasons).

Disneyland – what amazed me about Disneyland is the extreme efficieny it all operates. We’ve been there 9 years ago, and I rmemeber the hours-long lines to the rides. Now, you can get “fast-passes” to the rides – you go to an automated machine, gets a ticket that tells you when to come to the ride (within an hour’s range), you go at that time and hardly stand in line. Also, I think holograms have progressed quite a bit – we saw some convincing ones at the Haunted House ride.

Aquariam – we went to the Aquarium in Long Beach, pretty standard, except for the awsome diving birds (photos will come later), and the fact that you can pet some sea animals there including mantas and sharks! I also like the fact that several of the aquariums have waves, to better simulate some natural habitats. The large shark feeding was disappointing though – no real access to see anything interesting, unlike some other aquariums (The one in Eilat has better access, for example).

Santa Monica Beach – A quick stop at the beach. A lot colder than Israeli beach, bordering on the pacific ocean and not the shielded mediterranean sea. Nice waves – I think psychologically the feeling of bathing in the ocean is different than bathing in the sea, at least for me.

That’s it for now. We’ll probablly not have time for much more activies. We thought about going white-water rafting but it seems it’s several hours drive from here and we don’t really have the time for it.

Wow, I’m Addicted

I’m visited the US with my family for a couple of weeks, and staying with an Aunt, who has a 56Kbps dialup internet connection and an 8 years old laptop (which is usually kept tucked away in some closet). 

Whenever we try to use the internet the response we get is something like “but you already used it yesterday, why do you need it again so early”? Everything takes ages and ages to load up – very painful. Add to that the fact that we’re about 5-6 people who have to share this tiny laptop+internet connection…

We’re now at the mall and I feel much relief – free internet here at several computer stores, we’re leaching computer time from them. The saying is “you don’t know how much you need X until it’s gone” – but when you get it back again (high quality internet here at the Apple Store – Shlomo, you’ll get your keyboard) for a short while, then you really know how much you’re hooked.