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]
 Sunday, July 23, 2006

I've noticed a habit of mine recently.  I have a tendancy to open up a web browser and/or and email client when I first log into my home or work computer.  I do this out of habit, just like a check the mailbox for new mail when I get home from work.  The email thing is not such a big deal because I usually just delete the junk mail and take care of the few items that actually need my attention.  The web browser on the other hand can be quite the menace.  The web browser coupled with and RSS aggregator such as www.netvibes.com can be a real productivity killer.  Before I'm really aware of it, I'm reading some blog on libertarian economic thought or browsing through www.techbargains.com drooling over a new piece of hardware.

So What can I/you do about this?

Open up the IDE first.  I'm assuming you're using an IDE (Integrated Development Environment) but you could also be using VI or Emacs or Excel.  The point is that you should open up the IDE first and just start working on something or anything really just to get started.  I find that once I get started on a task I've won half the battle.  Once I'm really working on a task I slip into concentration mode and can focus on a problem and I'm usally very stalwart in searching for the solution.

Have your essentials near at hand.  You want to have your cup of water|joe|soda full and within reach before you put on your headphones and slip into the zone.  Once I've got my glass of water and my headphones are on I'm safe.  I can usually code for at least a few hours like this before I need a bathroom break.

Make sure to read Part 2 about staying in the zone which is almost more difficult, especially if you have non-coders in your work environment.

Sunday, July 23, 2006 7:41:42 PM (Central Standard Time, UTC-06:00)  #    Comments [0]
 Wednesday, July 12, 2006
Here's one that I've used several times in the past.  Microsoft has a virtual CD Control Panel that let's you mount an ISO image as a drive letter.  This is really handy if you have an MSDN subscription and are constantly downloading ISO's from the MSDN site.  Instead of burning each ISO to a CD you can keep it on a local or network drive and simply mount it as needed.  This will save the cost of a CD and the clutter of having a bunch of CD's laying around.

I've tested this only under Windows XP.

Here's the link:
Virtual CD-ROM Control Panel

This one is destined for the Pragmatic SDK.

Wednesday, July 12, 2006 8:44:05 AM (Central Standard Time, UTC-06:00)  #    Comments [1]
 Monday, July 03, 2006

Visual Studio 2005 is pretty useable on its own.  MS has really done a good job and the studio is one of the reasons I stay on the MS platform.  I've used Java, Ruby etc and I ended up using eclipse for my IDE and while it does a decent job it also seems to have heavy system requirements and theres the feeling that everything is kind of duct taped together  But I digress, the reason for this post is to highlight tools that make Visual Studio even more useable.  So Here they are:

1. Cool Commands

Everything except (including?) the kitchen sink

Adds context menu commands like open project folder etc.  It just keeps getting bigger and better.  You have to try it to get the full effect.

Most Recent version of Cool Commands

2.   CopySourceAsHTML

Ultimate Blogger Tool

If you have a blog and who doesn't these days, you should look into this one.  It lets you copy souce out of Visual Studio and keep the code formatted as HTML which is very helpful if you are trying to post code to a blog.

CopySourceAsHtml

3.  Smart Paster

The easy way to embedded SQL, JavaScript, etc

This one gives you multiple Paste As... options in the context menu.  Helpful for pasting inline SQL (oh my), JavaScript, XSLT, etc.

Smart Paster

 

 

Additional resource for Visual Studio 2005 Add-Ins

Monday, July 03, 2006 9:26:57 AM (Central Standard Time, UTC-06:00)  #    Comments [0]
 Friday, June 30, 2006

I was in the process of downloading Cygwin to in order to get the wc command (among others) in order to do some file verification work.  I stopped for a second and thought why not use PowerShell?  I found a good source for this so here is the command:

PS C:\Scripts\AMA> gc test.134.* | Measure-Object

Count    : 395587
Average  :
Sum      :
Maximum  :
Minimum  :
Property :
Notice that I'm using gc as an alias for Get-Content.  gc, type and cat all work as aliases for Get-Content.  
test.134.* is just a typical DOS file mask to get all files that start with test.134.
Now let's get a word count:
PS C:\Scripts\AMA> gc test.134.23.00 |  Measure-Object -word
Lines                             Words Characters          Property
-----                             ----- ----------          --------
                                   8391
How about a character count:
PS C:\Scripts\AMA> gc test.134.23.00 |  Measure-Object -char
Lines               Words                        Characters Property
-----               -----                        ---------- --------
                                                    1670774
How about an explicit line count:
PS C:\Scripts\AMA> gc test.134.23.00 |  Measure-Object -line
              Lines Words               Characters          Property
              ----- -----               ----------          --------
               8391
Keep in mind that Measure-Object can also be used with objects but we'll save that for another post.  Also it might be nice to try to create a nice short alias like wc to save me some typing.
Friday, June 30, 2006 1:40:55 PM (Central Standard Time, UTC-06:00)  #    Comments [1]
 Thursday, June 29, 2006

I discovered content fitlers today in dasBlog.  They are little macros that save you some typing.  The documentation says the google search macro supports multiple terms but in practice I can only get it to support one term.

Example:

dasblog content filter

should take you to a google search page dasblog content filter as search terms but only dasblog is passed through.  What am I doing wrong?

Content Filter Documentation

Update:

$g(dasblog\+content\+filter) doesn't work

$g(dasblog+content+filter) doesn't work

$g(dasblog\scontent\sfilter) no worky

hmmmm...

Thursday, June 29, 2006 9:51:58 PM (Central Standard Time, UTC-06:00)  #    Comments [1]

http://dasblog.info/CategoryView,category,Customization,Content%20Filters.aspx

Kinda funny how the documentation for this is the seventh result returned: dasblog content filter 

Thursday, June 29, 2006 9:24:30 PM (Central Standard Time, UTC-06:00)  #    Comments [0]
I've had a problem with Captcha images not showing up in the comments section of this blog.  I checked around to see if others have had this problem and apparently they have.  The solution?

It seems you just have to repeatedly refresh the page you are trying to mak the comment on until it works.  I noticed some references to managed hosting and Web Host 4 Life (WH4L) which I am using to host this blog.  I will have to keep on eye on this.  Not that my comments section was swamped before but I have seen 0 (ZERO!) comments since upgrading to the new version and know I think I know why.

This morning at work I kept refreshing the page but didn't get anything.  I'm at home this evening and now everything appears A-OK.  Hmmm...

Thursday, June 29, 2006 6:06:19 PM (Central Standard Time, UTC-06:00)  #    Comments [2]

This is useful when you want to group records by date but your datetime column has a time value also.  This code converts your date to a varchar in a specified format.

--101 is "mm/dd/yyyy"

SELECT CONVERT(varchar,DateField,101)

-- 1 is "mm//dd/yy"

SELECT CONVERT(varchar,DateField,1)

-- 108 is "hh:mm:ss"

SELECT CONVERT(varchar,DateField,1)

-- An example query

Select convert(varchar,CallDateTime ,101), count(*)

FROM [DBName].[dbo].[TableName]

where

CallDateTime between '04/21/2006' and '05/21/2006'

group by convert(varchar,CallDateTime ,101)

Thursday, June 29, 2006 2:22:36 PM (Central Standard Time, UTC-06:00)  #    Comments [0]
 Tuesday, June 27, 2006

I'm developing a set of server controls in ASP.NET 2.0 that use several JavaScript, image and stylesheet (CSS) files.  One of the problems with distributing controls is that you usually have to send along these files and tell the end user to install them in the appropriate directory.

Along comes ASP.NET 2.0 and the ability to embed resources right into assemblies and then access these resources via URLs.  My first impression is that this seems like a good idea but I'm wary because I've been burned by MS's good ideas in the past.  My main concerns are debugging and the effect this embedding has on caching. 

Caching

One of the problems with frameworks like ASP.NET is that they sometimes take you too far away from the underlying system.  HTTP and HTML is rather straight forward.  Embedded resources in ASP.NET call the the resources via URL's and  use cache headers to insure the browser caches the content correctly.  Also the output cache in the form of disk output cache is automatically used to cache these resources.  So these embedded resources should still allow a fairly performant solution.  My question is still whether this is as good as a plain static file and the caching IIS can perform on these files.  I still need to research this.

Debugging

One of the problems I've run into involves debugging.  When a JavaScript file is embedded and it contains an error, Visual Studio.NET 2005 will open a file dialog asking for the location of the file.  This is a pain as you lose the precious JavaScript debugging ability that we gained with VS 2005.  Is this behavior by design or is there something I'm missing in regards to debugging JavaScript as an embedded resource?  My tempo ray solution is to keep the JavaScript files in a static folder while I'm debugging and then switch them to Embedded Resources when I'm deploying the control. 

However on the plus side of debugging when you change the JavaScript file it is automatically picked up the next time you do a build.  The URL of the embedded resource is changed and thus the browser grabs the newer file.  However this has a downside in that you must stop the running project to make changes to the JavaScript file and then rebuild the project to have the changes show up.

I've found that the static file path is much easier for debugging.

 An excellent article that I've referenced for this post:

http://www.nikhilk.net/WebResourceAttribute.aspx

 |  |  | 
Tuesday, June 27, 2006 3:45:02 PM (Central Standard Time, UTC-06:00)  #    Comments [0]