Wednesday, December 19, 2007

scrolling numbers with javascript

I needed a javascript based list that could scroll numbers. Additionaly, the list needed to have a min and max values.

I found one list that created an initial set of information and then shifted the div around - after spending a large amount of time trying to figure out the position I decided to create a list based on clock cycle.

The new list would compute values based on a global tracker and spin new values based on a clock ticker. At this point I went and found a clock ticker and used that as the base.

Next I wrote functions to create a list of values and pushed the values to a div.
see code below.
This could be modified to work with an array of strings...












Tuesday, December 11, 2007

Design Patterns

I have started taking a serious look at design patterns. If you google Design Patterns check out the wiki - there is loads of info contained in there and it is a good starting place. I started a book group at work and we are slated to start reading "Head First Design Patterns". So far myself and a couple of other developers are reading ahead - most seem excited.

A friend of mine went to a c# course taught by Jean-Paul S. Boodhoo (Blog at:http://www.jpboodhoo.com/blog/). The course taught my friend a great deal about test driven development and design patterns. In just a week I saw his programming ability skyrocket.

I have started trying to use design patterns in my applications - all I can say is spend most of your time thinking. The design patterns require extra effort in forethought and minimal effort for implementation.

thats all for now ~ peace

Saturday, December 8, 2007

asp.net 2.0 - disable web site with caching

So,
we have been trying to get our website to be disabled using the application state. Makes sense, it is very easy, cheap, and maintainable. Imagine my surprise when it failed on its second live use. Not sure why it failed, but I figure some point in the future I'll have to fix it. I started thinking about how this could be done.

requirements:
no database
easy to implement
potentially deployed in a web farm so must be able to hit all servers at once
does not switch users to alternate server
potentially initiated by file push (only if possible)

An additional request came to mind. One co-worker wanted to disable the site when he initiates a site update. So a file based approach would be warranted, but no one wants to check a file setting every time a post back occurs.

Then I remembered hearing that you can set cache dependency to files. I started trying to build a cache dependency against a file and guess what, it worked.

By setting the cache dependency to a file when the file changes to have settings that disable the site the cache fires the dependency method and sets the site to disabled with the appropriate message. I'll post code later.

More over, by implementing design patterns (factory/structure) I can create two separate classes with the same interfaces. Each class is used to disable the site but one class will use application state while the other will use cache. The call to the code is the same (and the type is the same (interface type)) and switching between the two is handled by the factory method.

Needless to say, this could make disabling sites during database updates easier than ever before.