Thursday, August 24, 2006

Filed under WTF?, this one is a goody.  I recently bought a new PC (which is really quiet and I need to write about it) and I installed Windows XP with SP2 and got it all patched up with something like 50-60 downloads from Windows Update and everything was good.  I thought so anyway.  I went to run something using the windows key + R combination and the trusty Run dialog popped up but I couldn't access it instead I had to click on it to gain focus.  What the hell?  So I tried to google on this phenomenon but no joy.  I finally recalled that this seemed to be an issues with Windows not allowing windows to grab focus.  So I downloade good ol' tweakUI and fixed it right up.

 

Sometimes the little things make all the difference.

Thursday, August 24, 2006 9:11:05 PM (Central Standard Time, UTC-06:00)  #    Comments [0]
 Wednesday, August 23, 2006

I was testing a new caching implementation for the 20 when I noticed that items I placed in the cache were not staying in the cache.

I ran into this yesterday and luckily I realized what was happening before I did something drastic.  The ASP.NET caching facility automagically dumps items out of the cache when roughly 90% of your physical memory is in use.  So a laptop with 1 Gig of memory has a pretty good chance of seeing this happen.  Load up Visual Studio 2005, Firefox, IE6, the ASP.NET development server and have SQL server running and you are going to get pretty close especially after you've been running all day without restarting any programs or the computer.  The two biggest offenders are typically Visual Studio and Firefox in that order.  In the defense of Firefox I usually have about 15 to 20 tabs open and I have about 15 extensions installed.  Visual Studio can chew up about 400K on its own with all of its child processes running around checking code, looking up help topics etc.

The moral of the story is to shut everything down and then bring it back up so that you have some room cleared out in memory for the obects you want to cache in memory.  Seems like a no  brainer when you think about it.  This is also a good reason to have at least 2GB of memory in your development machine.  That's right TWO Gigabytes of memory.  Someone at work thought I was crazy when I bought my new home machine with 2GB already installed but after using Visual Studio for a while I knew it would come in handy.

 

 |  |  | 
Wednesday, August 23, 2006 11:35:21 AM (Central Standard Time, UTC-06:00)  #    Comments [0]
 Friday, August 18, 2006

Here's a piece of JavaScript code that allows you to format strings in a style similar to C#.

String.prototype.format = function() {
   var params = String.prototype.format.arguments;
   var toReturn = this;

   for (var i = 0; i < params.length; i++) {
      var regex = new RegExp("\{" + i + "\}", "g");
      toReturn = toReturn.replace(regex, params[i]);
   }

   return toReturn;
}

Original Source:  http://chapnickman.com/2006/02/10/string-formatting-in-javascript/

I love this because I can program in a style in which I am familiar.  However does this reduce portability or can it lead to a collision?  If we all add our own little extensions to the built in objects will we end up with a uncooperative mess?  This comes to mind because of the way the very popular prototype javascript library extends the build in JavaScript objects.  Some people people criticize prototype.js pointing out that is monolithic or bloated and lacks documentation.  While it is rather large it is also very powerful and everthing works together.  I don't have to include 5 different libraries from 5 different authors and hope that they work and play together nicely.  The documentation criticism is certainly legitimate as the author provides very little documenation.  However many sites have posted articles and even whole user guides that have come in very handy. 

I haven't even discussed Scriptaculous yet.  Scriptaculous is a visual JavaScript framework that uses Prototype for a foundation.  I have used this library for several sites and it works well and that is the whole point.  Both of these frameworks Just Plain Work!  I don't have to cobble something together each time I need a visual effect or an AJAX updater I can just use something in this toolkit. 

There is something to be said for re-using the same set of tools.  You become very proficient with those tools over time and you can use them more effectively as your experience grows.  I find this especially true of using the .NET framework also. 

You can't get anywhere by reinventing the wheel each time you need to build a cart.  Use other people's experience and work as a foundation for your own and become more productive. 

Friday, August 18, 2006 9:51:05 AM (Central Standard Time, UTC-06:00)  #    Comments [0]