Monday, September 29, 2008

28th Annual Oyster Run in Anacortes

According to KOMO TV, 30,000 motorcycles visited Anacortes for the Oyster Run yesterday. It's a good thing we were there, or there would've only been 29,998!..kidding.

It was fun though, oh man, riding in with all those bikes. I wonder if the locals just lock themselves up in their houses for the day or actually come downtown to see what's going on. For being a bunch of bikers, it was a pretty tame crowd, but then again, we did leave in the afternoon. Steph and I didn't stick around for it to get dark; we had a long ride home. There were always plenty of bikes on the road, and the ferries were pretty stocked as well.

I forgot my camera, but probably had a better time not worrying about taking pictures.

Friday, September 26, 2008

Acer Aspire One - I can't find you..

Where the heck can I see, in person, an Acer Aspire One? None of the stores around here have them in stock. I've seen videos and it looks impressive, but I also saw videos of the Asus EEE, and in person that thing is mega tiny...can't type on the small keys.

Does anyone know where to find an AAO that I can actually see? I really don't want to order one, check it out, then send it back if it's not what I want.

Virtual PC, VirtualBox, Vista, Ubuntu, XP

I'm seriously gettin' my nerd on today. On my Vista box, I installed Virtual PC. On Virtual PC, I installed Ubuntu Linux. On Ubuntu, I installed VirtualBox. On VirtualBox I installed Windows XP. I won't go any deeper. This is cool enough. :)

Wednesday, September 24, 2008

GridView in UpdatePanel refreshes entire page

I've been seriously banging my head against the desk for a couple of hours now. I've got two pages, each loads a different user control. The user controls have a GridView housed inside an AJAX UpdatePanel. When you sort or change page numbers, the grid should update without refreshing the whole page.

One works, the other doesn't. The settings on the two sets of controls and pages are identical.

I finally traced this down. One page has in it's web.config xhtmlconformance mode="Legacy"and that was the downfall. The Legacy setting mucks with the HTML a bit and the update panel doesn't work. The default is "Transitional" so I set it to that.

All is well with the world...now where's the Excedrin?

Tuesday, September 16, 2008

Dual boot Ubuntu and Vista with Vista already installed

Dual-boot systems have historically, for me anyway, been a pain to set up. Vista and Ubuntu make it pretty easy.

Now, you can use Virtual PC to run Linux, but if you want to see how it directly works (or not) with your hardware you really need to install the OS as a primary system.

So, Vista has a cool feature. It lets you resize your C: drive partition, thus freeing up space with which to install another operating system.
  1. Right-click "My Computer", and choose Manage
  2. Select "Disk Management" under Storage
  3. Right-click the C: partition, and choose Shrink Volume (yeah!)
  4. It will query for "available shrink space" and tell you how much you can get
  5. Click the shrink button when the numbers are what you want them to be
Now, when you boot Ubuntu from a thumbdrive or CD, one of the partitioning options is to "use the largest contiguous space" or something like that. It installs in that partition, then installs Grub in the Master Boot Record so you have your dual-boot.

This is so cool.

Friday, September 12, 2008

Metallica is back!

"Load" was ok, "Reload" was ok, "St. Anger" was surprisingly weird, but Death Magnetic is great! Metallica is BACK!

Thursday, September 11, 2008

Dynamically write the Google Analytics script after the opening body tag in ASP.NET

At work, we have a lot of web pages that report to Google Analytics so we can get stats on page hits, etc. They've recently changed the script and rather than go to every page we have the script on and change them, I wrote a static c# method to inject the script into the page. So, I updated the script to the new one, and redistributed the dll.

Supposedly, you're supposed to put the script at the beginning or the end of the body, outside of any form tags. My method puts it right after the opening body tag.

One method of injecting something to a specific part of the page involves overriding the Page Render method, rendering the HTML, searching for the place in the HTML you want to put the script, inserting it, then writing out the HTML. That works, but it's clunky.

Here's how I do it:
  1. In the OnPreRender event in a page class, after base.OnPreRender(e); I put this: ScriptWriter.WriteGoogleAnalyticsScript(this); I have a class called ScriptWriter and a static method called WriteGoogleAnalyticsScript that takes a System.Web.UI.Page as a parameter.
  2. I've included my code for WriteGoogleAnalyticsScript here.
  3. What the method does is writes my own script to the page using ClientScript.RegisterStartupScript() which writes the script before the closing Form Tag. The script depends on a setting in your web.config called GOOGLE_ANALYTICS_CODE. If the analytics code doesn't exist, it will throw an error telling you that it's missing. You get the actual analytics code from the Google folks using their Google Analytics site.
  4. My Javascript dynamically creates the necessary script nodes for the Google Analytics and inserts them into the DOM right after the opening body tag (where I wanted them).
  5. Using Firebug, you can see the change in the DOM. If you choose View-Source in your browser you will not see the code; you'll only see the HTML that was received from the server.

You'll notice a setTimeout() call in the Javascript before inserting the 2nd script into the DOM. This was needed to make IE happy. Firefox was fine without that.

I had fun figuring this out, and I hope you find it useful.