Tuesday, July 24, 2007

I've been battling some crazy ASP.NET 1.1 code the past couple of days. First, I was calling some web services with entirely hand written SOAP protocol management. That's always fun. While tedious and too low of a level to be mucking around, it was the fastest means to an end with a crotchity ol' Apache/AXIS web service. Even though I'm fresh off the WCF training regimen; that new stuff wouldn't have helped me here. Perhaps just having the new stuff in my head pushed me in the right direction to tackle this challenge - a man can dream, can't he?

Then, just to rub it in a little, the HTTPWebRequest object decided to give me a swift kick in the shorts. You see, in .Net 1.1, there's a tiny little unknown (unanswered) bug.

I have two instance methods and each make a single call over HTTP with their own HTTPWebRequest object, there's no sharing here. Every time, the second request would hang and throw a "System.Net.WebException : The operation has timed-out." error. The same code runs great in .Net 2.0 so I figure its a framework bug.

I call one method and return a string which is used as an input argument for the second method. Both calls go to the same top level domain, but call to different end points on the domain.

After much thought, trial and error, as well as reading about the same problem other folks were having, I finally figured out the workaround.

It turns out that calling the Abort() method on the HTTPRequest instance after completing the request is sufficient to break up the clog that is preventing subsequent calls. The following code block shows the working helper method. If I comment out the calll to Abort(), it no worky.

private string ExecuteHttpWebRequest(
   string url, RequestMethod method, string message)
{
   HttpWebRequest request = 
      (HttpWebRequest)HttpWebRequest.Create(url);

   request.Timeout = 30000;
   request.KeepAlive = false;
   request.Headers.Add("Cache-Control", "no-cache");
   request.Headers.Add("Pragma", "no-cache");

   switch( method )
   {
      case RequestMethod.Get :

         request.Method = "GET";

         break;

      case RequestMethod.Post :
         
         request.ContentType 
            = "application/x-www-form-urlencoded";
         request.Method = "POST";
         request.ContentLength = message.Length;

         StreamWriter sw = 
            new StreamWriter(request.GetRequestStream());
         sw.Write(message);
         sw.Flush();

         break;
   }

   string html = null;

   using( HttpWebResponse response 
      = (HttpWebResponse)request.GetResponse() )
   {
      Stream rs = response.GetResponseStream();
      StreamReader sr = new StreamReader(rs);
      html = sr.ReadToEnd();
      response.Close();

      // subsequent calls fail without this abort in .Net v1.1
      request.Abort();
   }

   return html;
}	
Tuesday, July 24, 2007 9:27:37 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Saturday, July 21, 2007

simpsonizer

Bahahahahaa!

This site is an great buzz generator for the upcoming Simpson's film. It built by the charming folks who took over the online advertising for Burger King.

http://www.simpsonizeme.com/

This Flash app takes a photo you submit and turns you into a Simpson character.

fun | movies
Saturday, July 21, 2007 9:37:38 AM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Wednesday, July 18, 2007

I went to the Vet the other day; we got card in the mail informing us that it was vaccination time for poochie. The Wife made an appointment and I ended up taking poochie in — go figure.

So poochie and I zip over to the Vet and wait in the busy waiting room for 20 minutes. Not too bad, they had a lot going on. The worse part was Poochie isn't a friendly dog. Poochie acts friendly to other dogs, and then goes bat-shit crazy - all 80 pounds at once. The Wife and I believe Poochie wasn't socialized very well as a pup, before we adopted Poochie from the pound.

Finally, they call us into see the Doc. The Doc comes into the little room quick enough and starts the standard evaluation procedure. About a minute later, the door opens and a tech requests the Doc's presence elsewhere. Doc makes a graceful exit and leaves me in the room with Poochie. About two minutes later, another tech comes in and explains the Doc had to attend to an emergency and asks if I would like to wait about 10 minutes or just drop off Poochie and come back later. I don't mind waiting so I flip out my Treo 700w and start listening to a podcast in the little examination room with Poochie.

About 10 minutes later, the Doc comes in, a little shaken. She explains that a kitty was really sick and had to be euthanized. That's a tough thing, no matter how objective of a Doc you try to be.

So the Doc restarts the evaluation and goes on and on about Poochie's dry skin and booger-ee eyes. Small potatoes in my book, but whatever. After a litany of product prescriptions and instructions, Doc asks if I have any final questions. It looks like Doc is getting ready to leave.

So, I ask about the vaccination shots.

Doc looks taken a-back.

After some paper shuffling in the file on the table between us, Doc exclaims that yes, Poochie does need shots and somehow that information didn't get passed along. Understandable, Doc just took out a kitty afterall.

So another tech comes in to help hold Poochie in place as two needles full of modern medicine are injected. Poochie doesn't mind too much since Daddy is there. If Daddy is cool, Poochie is cool; unless someone's at the door. Poochie's my dawg, in the literal and figurative sense of the word.

So my advice to you: when your receiving services from someone; no matter what; make casual declarations of your business there or you'll walk home with an armful of dry skin shampoo, fish oil and eye booger medicine.

Wednesday, July 18, 2007 9:21:54 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 

I've been using Google Reader for a while now and I love it. Its very quick to launch with my SlickRun shortcut of "gr" and it manages my current list of 96 RSS subscriptions very well.

In fact, I recently figured out that this application is perhaps one of the worst web applications to use with the mouse. The mouse is such an impediment to reading several posts efficiently. I launch Google Reader several times a day and its common for me to have nearly 50 unread posts from over 30 RSS subscriptions at any given perusal session.

Here are the Google Reader keyboard shortcuts I use on a regular basis.

  1. Click the "Show Updated" hyperlink in the left column to show only the RSS subscriptions with unread posts
  2. Click the first RSS subscription link of the list in the left column (getting in the mood)
  3. Click the first unread post of the list if the right column (tee it up)
  4. Press space bar to traverse multi-page posts and advance to the next unread post for a given RSS subscription
  5. When all the posts are read for a given RSS subscription, press Shift+N to advance the highlight to the next RSS subscription of the list in the left column
  6. Press Shift+O (this is my Oh face) to open the list of the new highlighted RSS subscription
  7. Press the space bar to traverse this new feed like the previous RSS subscription

 

 googlereader

To Summarize:

Space Bar Scroll through a long post, then skip to next post when the last line of current post is visible
Shift + N Highlight the next RSS subscription in the left column
Shift + O Open the list of posts for the highlighted RSS subscription

 There are a bunch of other keyboard shortcuts for Google Reader. These are the ones I use the most.

Wednesday, July 18, 2007 8:57:20 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Thursday, July 12, 2007

The man has cleaned up, packed up and gone. Now, I have a brand spanking new 60 amp sub-panel in my basement. My basement was woefully lacking in power outlets. It's a 1925 house and the current panel has a sticker from 1962. I don't know if that's the date the panel was installed or when some dude came out in April of '62 to service it. Since I know precious little about things like amps, watts, hertz, ohms, and kelvins, I apologize for not being able to elaborate. So, enter photo montage!

I needed some power to run a few toys for "a few days":

workstation

Workstation, obviously

powerhog2

The wall mounted media center

powerhog4 

Subwoofer - the point one of a 5.1 surround sound system

powerhog3

InFocus ceiling mounted projector

powerhog6

And dual tower speakers with a magnets big enough to make your tooth fillings ache - occupying slots #2 and #3 of a 5.1 surround sound system.

How could this be powered, you ask? Well, for a very short term...

walloutlet

The source of all pleasure...

firsthop

leads to a ceiling mounted power strip,

nexthop

which traverses to the next hop,

randomuseofceilinghook

and makes an indiscriminate use of a rogue ceiling hook that finally leads up to the media center on the other side of the basement.

I'm really happy with the new power outlets that were ran every couple of feet with sturdy conduit. The guys from Coho Electric did a great job again on my humble abode. It was about $1,500 to drop in a new sub-panel and run the outlets to all corners of the basement. We pinched some pennies and made room in the budget to do this project. A worthwhile investment indeed!

Time to get back to work!

Thursday, July 12, 2007 9:51:54 AM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Thursday, July 05, 2007
Snippet Compiler

Like many of the three of you who subscribe my blog, I download a bunch of tools & utilities that I read about online and seldom have an opportunity to use on a real project.

Today was my first bona fide use of the Snippet Compiler and it just plain rocked. Its a small client application that can take the place of many throw-away command line programs written just to test out a concept. The application launches fast and I can start writing and executing my code immediately. I don't need to select a project template, name it, or any other of the standard housekeeping items. It even has statement completion!

I was working on an existing ASP.Net v1.1 code base for a quick maintenance project. I gleaned a test order number from the system and quickly realized my specific test required an obfuscated order number from the following "simple" and "natural" function:

//=====================================================================
/// <summary>
///    This method performs exactly the opposite action as
///    EncodeOrderId(), and is meant as the natual companion to that
///    method.  Performs a very simple wrapping bit shift (4 bits wide,
///    towards the most significant bit) on the input value (unsigned
///    32 bit integer) and returns it as a signed 32 bit integer.
/// </summary>
/// <param name="orderId">Value to decode.</param>
/// <returns>Decoded value.</returns>
//=====================================================================
public static int DecodeOrderId( uint orderId )
{
   int newOrderId = (int) (( orderId << 4 ) | ( orderId >> 28 ));

   if ( newOrderId < 1 )
   {
      throw( new ArgumentException( "Invalid orderId: '" +
         orderId.ToString() + "'.", "orderId" ));
   }

   return( newOrderId );
}

I was doing integration testing and further more, I was nearly done. I didn't feel like firing up VS.Net to figure out how to get my test order number obfuscated, so I thought about it and decided to have a spontaneous moment.

I (1) fired up the Snippet Compiler, (2) added a reference to the assembly and (3) wrote a single line of code that called the static method DecodeOrderId() which wrote the result to the console output. Booya!

Thursday, July 05, 2007 9:20:48 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [1]  |