Wednesday, September 29, 2010

Levenshtein distance

Needed to determine the distance between 2 strings.

Here is a basic implementation of the “Levenshtein distance” algorithm, which measures the distance as the number of edits required to change one string to the other via a series of insertion, deletion and substitution operations.

The following implementation is based of the pseudo-code on wikipedia. (

public class StringEditDistance 
public int LevenshteinDistance (string s, string t)
int m = s.Length; //length of s
int n = t.Length; //length of t

if(n == 0) return m;
if(m == 0) return n;

int[,] d = new int[m+1, n+1]; // d is a table with m+1 rows and n+1 columns
for(int i = 0; i <= m; i++)
d[i, 0] = i; //deletion
for(int j = 0; j <= n; j++)
d[0, j] = j; //insertion

for(int j = 1; j <= n; j++)
for(int i = 1; i <= m; i++)
if (s.Substring(i-1, 1) == t.Substring(j-1, 1))
d[i,j] = d[i-1,j-1];
int deletion = d[i - 1, j] + 1;
int insertion = d[i, j - 1] + 1;
int substitution = d[i - 1, j - 1] + 1;
d[i, j] = Math.Min(Math.Min(deletion, insertion),substitution);
return d[m, n];

Tuesday, September 28, 2010

Creative Truths

“The secret to creativity is knowing how to hide your sources” – Albert Einstein


“Every child is an artist, the problem is staying an artist when you grow up” – Pablo Picaso


Find more at:

Deploy Manager–GUI tool for creating

Came across Deploy Manager tool. It provides a GUI that allows you to manage and create digital certs.

Until today, I have had to use tools such as MakeCert to create self-signed certs. As I don’t do it often, I always forget the different command line options that I need to use when attempting to create a self-signed cert. Deploy Manager will help through its “New Certificate” UI.

The one thing you need to know: The X500 name needs to specified with a “CN=” (example: In addition you can specify more information using the following format:C=US, ST=Colorado,L=Denver,O=Raj Rao,OU=Aggregated Intelligence,, which will create a certificate that looks like the following screen shot:


Visual Studio 2008–Change active item selection color

When an item is selected in the Solution Explorer of Visual Studio (2008), it shows up with a nice dark colored back ground which makes it easy to find the item.


But when the Solution Explorer does not have current focus, then the color used makes it extremely hard to determine which item currently has focus.


Here is what you need to do to change the back ground color of the selected item – when it is in a window that does not have current focus.

Open up the Window Color and Appearance dialog.

- On Windows 7, Go to “Appearance and Personalization” –> “Personalization” –> “Window Color and Appearance”

- Click on “Advanced appearance settings….”

Under “Item” select “3D Objects” and change the color for “Color 1”


(The original color was RGB = 240,240,240).

That should do it.

Note: This solution does not work for Visual Studio 2010.

Monday, September 27, 2010

Compilation of Colorado fall drives information

Came across the following pages on Denver T.V. channel sites. They have great information on the best times as well as the best drives to view the changing colors of the fall season in Colorado’s mountain country. (The links to the original sites are included and they all have a ton of more information, as well as image galleries and updates to current conditions. So check them out. I have copied the information here just for archival purposes).

Best viewing timelines (according to

Best dates range from September 19th to October 16th.

Color Outlook


9 Best Fall Color Drives in Colorado

Northern Colorado fall color drives

1. Poudre Canyon: Take I-25 north to Fort Collins, turn north on Colorado 14 and then head west out of town and into the mountains. Drive along the Cache la Poudre River all the way over Cameron Pass to Walden, then go south on Colorado 125 through the Routt and Arapaho National Forests back down to US 40 at Granby
2. Trail Ridge Road: Take US 34 through Rocky Mountain National Park
3. Peak to Peak Highway: Take Colorado 119, 72 and 7 between Black Hawk and Estes Park

Southern Colorado fall color drives

4. Breckenridge: Take the long way by taking US 285 over Kenosha Pass and then down into South Park. At Fairplay, turn right on Colorado 9, which you will take over Hoosier Pass into Breckenridge
5. Boreas Pass: Between Como and Breckenridge
6. Independence Pass: Take I-70 to Copper Mountain, then take CO 91 south to Leadville; take US 24 south to CO 82 and head west on 82 to Aspen which will take you over the pass
7. Kenosha Pass: Take US 285 southwest out of Denver to South Park
8. Gold Camp Road: From the Broadmoor in Colorado Springs to Cripple Creek
9. Rampart Range Road: Between Sedalia and Woodland Park

Fall color drives from TheDenverChannel:

  1. CO 103 from Evergreen Parkway west to Echo Lake. Take Evergreen Parkway to Squaw Pass Road, turn west. Follow Squaw Pass Road (Hwy 103) for about 18 miles to Echo Lake. The road will twist and turn through a mix of aspen and pine forests with several good locations to pull off and take photos. The scenery is spectacular accompanied by a variety of wildlife. Echo Lake Lodge offers a nice stop for refreshments. From there, turn west and continue to Idaho Springs. At Idaho Springs get on I-70-east to the El Rancho/Evergreen exit. This takes about 3 hours and is spectacular when the aspens change color. If some snow has fallen on the peaks, you will enjoy magnificent views of the aspen gold and snow capped mountains.
  2. Guanella Pass between Grant and the top of the pass -- Take Highway 285 south from C470 through Conifer and Bailey. At the town of Grant, head north on the Guanella Pass Scenic and Historic Byway to the top of the pass. Guanella Pass is closed on the north side of the pass and through travel is prohibited to Georgetown. The aspens are typically exceptional on the south side of Guanella Pass, which sits at 11,699 feet in elevation. This refreshing 23-mile road will take you through the Pike and Arapahoe National Forests. The road is gravel to the top f the pass, which i above timberline.
  3. Trail Ridge Road (US 34) through Rocky Mountain National Park -- Take the Boulder Turnpike (US 36) west to Rocky Mountain National Park via Estes Park. Once in the park, drive Trail Ridge Road (the highest paved through highway in the US) and enjoy the breath-taking scenery. The weather can change quickly in the park so be sure and get the latest forecast from your 24/7 Weather Center. Trail Ridge Road peaks at 12,183 feet in elevation. Just west of the high point is Fall River Pass, elevation 11,796 feet, and the Alpine Visitor Center. Exit the west side of the park and continue on US 34 down into Grand Lake. From there, take US 40 east through Fraser and Winter Park, eventually meeting back up with I-70 at Empire.
  4. Boreas Pass between Como and Breckenridge -- Take I-70 west and then Highway 9 south through Breckenridge. Make a left at the stoplight on the south side of Breck onto Boreas Pass Road. After 3.5 miles the pavement ends, but you can continue another 11 miles to the town of Como. From there, take Highway 285 back to Denver over Kenosha Pass. The Boreas Pass Road will take you above timberline where the weather can change quickly, so check with us for your forecast before making the trip. Boreas Pass Road follows an abandoned railroad grade which was the original route of the Denver, South Park, and Pacific Railroad. You will have incredible views of the Continental Divide as you pass the flank of Bald Mountain.
  5. Colorado 14 through the Poudre Canyon west of Fort Collins -- Take I-25 north and exit onto Colorado 14 heading west. (Exit # 269) You will pass through the town of Laporte before entering the beautiful Poudre Canyon in the Roosevelt National Forest. The Pourde River Canyon was designated Colorado's First National Wild and Scenic River in 1986. Drive to Cameron Pass (10,276 feet) in the Medicine Bow Mountains for gorgeous views, and perhaps a picnic lunch.
  6. Colorado 67 Between Divide and Cripple Creek -- Take I-25 south to Colorado Springs, exit onto US 24 west (exit 141) toward Woodland Park. At Divide head south on Highway 67 toward Cripple Creek and Victor. The scenic Golden Loop Historic Parkway between Cripple Creek and Victor will not only afford beautiful views of fall color, but a look back to the 1890s gold rush that made this area one of the most famous mining districts in the world. As an added bonus, you will cross Colorado's highest bridge on the state highway system. The bridge crosses Arequa Gulch just west of Victor, is 250 feet tall at it's highest point, and 1,218 feet long. Colorado has 8,479 bridges on it's highway system.
  7. Tennessee Pass, US 24, From Leadville to Vail -- Take I-70 west to Vail and exit onto US 24 east to Leadville. On the way to Tennessee Pass you will see on of Colorado's fourteeners to the west. This route follows the Arkansas River and the Rio Grande Railroad. It was also the original Native American trail across the mountains. On the west side of the pass, the railroad follows the Eagle River down a 3% grade to the mining towns of Minturn and Belden. (Mount of the Holy Cross in the Sawatch Range).
  8. Independence Pass, Colorado 82, Between Twin Lakes and Aspen -- Take I-70 to exit 171 just past Vail to pick up US 24 west. This will take you to Twin Lakes, where you pick up Highway 82 toward Aspen. This beautiful drive through the San Isabel National Forest will afford picturesque views of the Sawatch Range, which is home to several of Colorado's 14ers. From Aspen you can continue on Highway 82 to Glenwood Springs where you will meet back up with I-70. Heading back toward Denver, you will drive through the gorgeous Glenwood Canyon where a hike to Hanging Lake and Spouting Rock would make for a nice picnic.
  9. Cottonwood Pass, Colorado 306 Between Buena Vista and Taylor Park -- Take Highway 285 south to Buena Vista where you will meet up with Highway 306. Head west over Cottonwood Pass (12,126 feet). Here you will be surrounded by several of Colorado's highest peaks, including Mt. Yale (14,194 feet), Mt. Princeton (14,197 feet), Mt. Antero (14,269 feet), and Mt. Harvard (14,420 feet). You will be right in the heart of the Sawatch Range. West of the pass you will pass through Taylor Park and by the Taylor Park Reservoir on your way to Almont. Once in Almont, take Highway 135 south to Gunnison where Highway 50 east will bring you back to Highway 285 Salida.
  10. Monarch Pass, US 50 from Salida to Gunnison Take Highway 285 south to Salida down through the Arkansas River Valley. Head west on Highway 50 to Gunnison, which will take you over Monarch Pass (11,312 feet).
  11. Cochetopa Pass Between Saguache and Gunnison -- Take Highway 285 south to Saguache where you will meet up with Highway 114. Head north toward Gunnison and enjoy incredible views of not only fall color, but the fascinating geology of this region. Several calderas are located in the part of the San Juan Mountains. Approaching Cochetopa Pass you will see some "columnar basalts" which formed in the same manner as Devil's Tower in Wyoming.
  12. Platoro Reservoir, south of Del Norte and West of Conejos -- Take Highway 285 south to Monte Vista and then Colorado Highway 15 (Gunbarrel Road) south 12.0 miles. Take the Twelve Mile Road 12.0 miles west to the forest boundary where it becomes the Alamosa-Conejos River Road (Forest Road 250). Then follow Forest Road 250 17.0 miles up the Alamosa River and over Stunner Pass to Mix Lake. Platoro Reservoir is just west of Mix Lake on Forest Road 247.
  13. Cucharas Pass, Colorado 12, from Trinidad to Walsenburg -- Take I-25 south to Trinidad and then Colorado 12 west. You will drive through the San Isabel National Forest and over Cucharas Pass (9,941 feet) back to Walsenburg and I-25. As a side trip on your way back toward Denver, you can take exit 74 on I-25 which is Colorado City. Highway 165 will take you on a beautiful drive up the spine of the Wet Mountains. You will intersect Highway 96 which you can take west to the delightful town of Westcliffe for a little shopping, or east to Pueblo and I-25.
  14. Steamboat Springs, Elk River country north and Buffalo Pass east -- Take I-70 west to Empire and exit onto US 40 west. This will take you through a scenic drive over many passes on your way to Steamboat Springs, including Berthoud Pass, Muddy Pass, and Rabbit Ears Pass. North of Steamboat out of Strawberry Pass you will find Forest Road 60 (Buffalo Pass Road). This scenic drive will take you across the Continental Divide into North Park where you will meet up with Highway 14. You can take Highway 14 east to Fort Collins or go west back to Muddy Pass on US 40 east to meet back up with I-70.
  15. Maroon Bells Near Aspen -- Take I-70 west to Glenwood Springs to Highway 82 east. Follow 82 to the Aspen Roundabout where you will pick up the Maroon Creek Road exit. A parking lot off the roundabout offers shuttle service to Maroon Bells Road. Nestled in the Gunnison and White River National Forests, this area varies from 7,500 to over 14,000 feet! The Maroon Bells is one of Colorado's most photographed landmarks. The mirror-like reflective Maroon Lake will afford incredible views of the surrounding terrain and vegetation, which happens to be full of our lovely Colorado Aspen.
  16. Colorado 135 Between Crested Butte and Gunnison -- Take Highway 285 south to Salida down through the Arkansas River Valley. Head west on Highway 50 to Gunnison, which will take you over Monarch Pass (11,312 feet). Once in Gunnison pick up Highway 135 north to Crested Butte and enjoy the beautiful views of surrounding forest. Once in Crested Butte, you can contiue west over Kebler Pass (9,980 feet) or north to Schofield Pass (10,707 feet).
  17. Slumgullion Pass, Colorado 149, Between Lake City, Creede, and South Fork -- Head south on Highway 285 to Salida, then west on Highway 50 to just past Gunnison. Pick up Highway 149 south and prepare for a breath-taking drive through the Gunnison, Rio Grande, and Uncompahgre National Forests. Slumgullion Pass is at 11,361 feet followed by Spring Creek Pass at 10,901 feet. Once on Slumgullion Pass, look west for a beautiful view of Uncompahgre Peak, with an elevation of 14,309 feet, Sheep Mountain at 13,1368 feet, and Redcloud Peak at 14,034 feet. Once in South Fork, take Highway 112 east to Highway 285 near Center.
  18. US 160, Navajo Trail, Between Pagosa Springs and Cortez -- Take Highway 285 south to Monte Vista in the San Luis Valley where you will pick up Highway 160 west. Once over Wolf Creek Pass (10,850 feet) in the San Juans, you will descend into the beautiful town of Pagosa Springs. Stop and take a look at the tranquil San Juan River that runs through the heart of town before continuing on your leaf viewing drive to Cortez.
  19. Lizard Head Pass, Colorado 145 Between Dolores and Telluride -- Take Highway 285 south to Salida, then Highway 50 west to Montrose. From there take Highway 550 to Ridgway where you will find Highway 62. Heading west you will go over Dallas Divide on your way through the Uncompahgre National Forest. Once you intersect Highway 145, go south toward Telluride, Lizard Head Pass, and Dolores.
  20. Grand Mesa, Colorado 65 East of Grand Junction and North of Delta -- Take I-70 west to Exit 49 just before Clifton. Head south on Highway 65 (Grand Mesa Scenic Byway) to Delta. This scenic drive on the western slope of the Rockies will take you over 60 miles and up as high as 11,000 feet with incredible views. Many lakes line the byway, including Sunset Lake. One really cool aspect of this drive is how the scenery changes. From a desert canyon to aspen foothills, lakes, alpine forests, lily ponds and rolling meadows. If you have time for a hike, the Land-O-Lakes is a trail that you can take for an awesome view of the many surrounding lakes. The West Elk Mountains will also be visible to your east. Another fun thing to do is drive up to the top of the mesa on Land's End road. From the top you will be looking 6,000 feet to the bottom of the canyon.
  21. Flat Tops Country Between Buford and New Castle -- Take I-70 west to New Castle (Exit 105) where you will pick up Highway 13 toward Meeker. You have two routes depending on how much time you have. One is to take Highway 325 to Buford which will afford some beautiful views of the Flat Tops. The second option is to stay on Highway 13 to Meeker and take the Flat Tops Trail Scenic Byway. This 82-mile trek will take you through the White River National Forest to Yampa. From Yampa, take Highway 131 south to Wolcott where you will meet back with I-70. The Flat Tops Wilderness is defined by basalt lava flows of the White River Plateau, and underlain by thick limestone formation in which water has carved numerous caves.
  22. McClure Pass -- From Glenwood Springs, take Highway 82 south to the junction of Highway 133, and follow this toward Carbondale. South of Carbondale, Highway 133 parallels the Crystal River and makes for some scenic photography. You will soon come to the town of Redstone, and the historic Redstone Inn. As you continue south to McClure Pass, elevation of 8,755 feet, you will see fantastic views of the Elk Mountains and Muddy Creek above Paonia State Park. While you are in the area, be sure to stop by the town of Marble. Marble is a legendary town where marble was quarried and finished for the Lincoln Memorial, the Tomb of the Unknown Soldier, and hundreds of other buildings. Once you are back onto Highway 133, a quick jaunt to the south will bring you to Paonia Reservoir and Paonia State Park.

  • Rocky Mountain National Park From Denver take highway 36 through Boulder, Estes Park and straight into the park, using Trail Ridge Road. Enter Rocky mountain National Park and follow the road to Bear Lake. One of the best places for viewing the aspens is the area around Glacier Gorge Junction. If you're lucky you may see a few bugling elk welcoming in the new season.
  • Guanella Pass From Denver take I-70 west and exit at historic Georgetown. Follow county road 381 over Guanella Pass to the town of Grant for some spectacular aspen viewing. The road is mostly unpaved, so a truck or 4 wheel drive might be a good idea. This is also a great time to ride on the Georgetown Loop Railroad. A steam locomotive will take you on a scenic ride to Silver Plume.
  • Peak to Peak Highway This drive will take you on the peak to peak highway. On U.S. 6 through Clear Creek Canyon, take highway 119 past Blackhawk and Central City up to the mountain town of Nederland. Look for highway 72 heading to Ward and Allenspark. You should see thousands of acres of golden aspen with the Continental Divide as the backdrop.
  • Poudre Canyon From Denver take I-25 north to exit 269. Take Colorado 14 west through Laporte and into Poudre Canyon. You will be driving through Roosevelt National Forest. On this drive you will go over Cameron Pass and have a good look at the Medicine Bow Mountains.
  • Aspen From Denver, take I-70 west to Copper Mountain, where you will follow highway 91 through Leadville to highway 82. the aspen should big and bold as you travel from Twin Lakes over Independence Pass and down into the town of Aspen. While your there you can take a little detour to the Maroon Bells, one of the most photographed areas in Colorado. Check out the John Denver Sanctuary while you are in Aspen.
  • The I-70 Corridor There are no complicated directions for this one. Drive from Denver west on I-70 all the way to Avon. The viewing is awesome as you travel from Vail Pass to Avon. The aspens will highlight the slopes on both sides of the interstate.
  • Hoosier Pass Go west along I-70 to the Frisco exit and head toward Breckenridge on highway 9. Continue over Hoosier Pass down into the towns of Alma and Fairplay.
  • Boreas Pass Again go west along I-70 to the Frisco exit and head south through Breckenridge on highway 9. Look for Boreas Pass Road on the south side of Breckenridge. Follow the road around 14.5 miles to the town of Como. Most of this road is unpaved, so don't take the Cadillac. The view of the Blue River Valley is great. And the waves of aspen groves are quite impressive.
  • West Elk Loop From Denver, take I-70 west to Glenwood Springs where you will follow highway 82 south to Carbondale. Take highway 133 through Carbondale and continue over McClure Pass, there you will find one of the largest expanses of aspen in Colorado. The loop will take you through Paonia, where you'll head east on highway 92 to Gunnison. The loop back takes you on highway 135 to the ski town of Crested Butte where you'll drive a gravel road over Kebler Pass and then back to Carbondale on highway 133. This is a longer trip but, well worth it.
  • San Juan Skyway The San Juan Skyway starts in Durango and travels north on U.S. 550 to Silverton where you'll follow the "Million Dollar Highway" over Red Mountain Pass down through Ouray(Colorado's little Switzerland) and into Ridgeway. Take Highway 62 over Dallas Divide on your way to Placerville where you'll want to turn south on highway 145 and head toward Telluride. Continue over Lizard Head Pass down to Cortez. Heading east on U.S. 160 will return you to Durango. This is considered one of the most scenic drives in America. I might also, add this is a great drive in the summer when all the wild flowers are blooming.
  • Cottonwood Lake Take U.S. 285 south from Denver to Buena Vista. Drive about seven miles west of Buena Vista on Main Street, and turn left on county road 344. You'll find Cottonwood Lake about four miles down the road surrounded by beautiful groves of Aspen.
  • Poncha Pass Take U.S. 285 south from Denver, or from Pueblo take U.S. 50 to Poncha Springs. Continue south on us 285 over Poncha Pass where you'll find stands of aspens along San Luis Creek.

Other Links:

Autumn Colors in Colorado (9 News)

U.S Forest Service – Fall Colors Update for Colorado

U.S Forest Service – Fall Colors information for the entire country -

Google Search -

Links to other drives (from

- 125
- 135
- Breckenridge
- Boreas
- Castlewood
- Chaffee County
- Cottonwood Pass
- Colorado 67
- Colorado 76
- Deckers
- Estes Park and Rocky Mountain National Park
- Gold Camp Road
- Golden and Golden Gate Canyon State Park
- Flat Tops Country
- Grand Mesa
- Guanella Pass
- Independence Pass
- Kenosha Pass
- Maroon Bells
- Monarch Pass
- Morrison and Evergreen
- Peak to Peak Highway
- Poudre Canyon
- Rampart Range Road
- Steamboat Springs
- Tennessee Pass/Vail
- Trail Ridge Road

- Cochetopa
- Cucharas Pass
- Kebler Pass
- Lizard Head Pass
- National Scenic Byway
- Platoro Reservoir
- Slumgullion Pass

Sunday, September 26, 2010

Home Mortgages, Wells Fargo and PMI

There seems to be a ton of misinformation on the web on how the PMI interacts with the home mortgage and I thought I would blog about my experience, as it might help someone out there. The following are my experiences with Wells Fargo. So the applicability to your situation might vary

PMI – Private Mortgage Insurance, is insurance that I had to pay monthly, as my down-payment was less than 20%. (I have a conventional 30 year loan). The PMI is used to make up any difference in the home price, in case I defaulted on the loan and Wells Fargo had to fore-close the loan on me. The important thing here is that the PMI is required whenever your Home To Loan value ratio is greater than 80%. (LTV definition: (Current outstanding loan amount)/(Home Purchase Price)).

One of the laws that govern how long PMI applies to a loan is called the Home Owners Protection Act of 1998. It specifies for how long PMI can be charged to a home loan and in addition also governs automatic termination of the HOP as well as buyer requested termination. Unfortunately, the act is not easy to understand and it led to many questions for me (such as, will the PMI be dropped if I reached a 80% LTV and will it be dropped if I reached that point within one year of getting the loan).

Here are my specific experiences with Wells Fargo:

  • I was able to call in and ask for a letter to be sent to me that specified how I could drop the PMI. The document specified that the PMI would be dropped when the loan reached 78% LTV. The letter also specified the exact amount (as of the date of the letter) that I could pay towards the principal so as to reach the 78% LTV to drop the PMI.
    In addition the document also provided other ways in which the PMI could be dropped. Specifically, by having the house appraised at a higher value (the %, etc was specified in the document). But in this economy, I was sure that my house would not have appraised for more (and probably would have appraised for less than my purchase amount). So this document told me exactly what I had to plan for, to get rid of the PMI.
  • The day that I got the LTV to 78% I called Wells Fargo so that I could request cancellation of the PMI. To my pleasant surprise, they told me that it had been already been removed automatically. About 2 weeks after the LTV reaching 78% I got a PMI deletion notice letter from Wells Fargo. (Although, it looks like the PMI does get automatically deleted by Wells Fargo, I would suggest that you call Wells Fargo to make sure that the PMI will get cancelled).


Wells Fargo FAQ on PMI:

Money Girl’s Quick and Dirty Tips: This page has tons of in-depth information on PMI. I strongly suggest you read this article as it covers all the different situation under which the PMI can be cancelled.

Federal Reserve document on the Home owners protection act:


I am not a banker or a lawyer or a mortgage loan specialist. So the above information might not be 100% accurate. The above post is based only on my experiences.

Friday, September 24, 2010

I <3 Microsoft Hohm

I have been using Microsoft Hohm since it was released and I love it. I love it because there is no other tool like it and I love it because of how well it shows information about the energy usage of your home.

For example, here is a graph of the energy usage of my home:


It not only shows me the cost per day, but also information about the temperature. There are options to view the graph by only electricity usage and by natural gas usage. Its nice, because, it lets me track my usage just as I would track my money on my bank’s site.

Hohm also shows you a breakdown by usage (which perplexes me, as I am not sure how they are deriving these numbers. my best guess its based on my home’s profile, where I put in information such as number of bulbs, water heater, etc.)


As of now, I think the only provider that is supported is Xcel Energy (Don’t know why more energy providers don’t provide this service).

If you want real-time usage data, then, check out Blue-Line, which uses a meter monitoring device in conjunction with Hohm to provide real-time monitoring:

Wednesday, September 22, 2010

Asp.Net Page LifeCycle in 3 stages

Its hard to remember all the stages of an Asp.Net page’s life-cycle. So being able to group them into 3 stages is a useful way for looking at them:

  1. Initialisation
  2. Event Handler Execution
  3. Rendering


  1. PreInit (Controls are available. Ids are set)
  2. Init
  3. InitComplete

Event Handler Execution

  1. Preload
  2. Load (During a post-back, control properties are available here and loaded from view state)
  3. Controls events (If a post-back call, events are fired and validation is performed by calling the Validate methods on each validator control – setting the IsValid property)
  4. Load Complete


  1. PreRender (databind method is called here)
  2. SaveState
  3. Render
  4. Unload

More information: MSDN: ASP.Net Page Life Cycle

The changing workspace of the software developer

Out: Cubicles, partitions

In: Team rooms, open spaces

Recently, I was trying to research how the workspace of the software developer was changing and how successful companies are setting up the space for their developers.

Here are some pictures that show the changing space:

Also, came across this article which has tons of information on Team Rooms:

Tuesday, September 21, 2010

WCF gotcha–DateTime

If your WCF service is going to be called across time-zone boundaries, then you need to make sure that you have a policy for handling date-time set by a client in a different time zone. (Process the dates as is, convert to local time before processing, or convert to UTC before processing are some strategies that you can use).

To unit test date time from different zones, use the DateTimeOffset struct.


DateTimeOffset doStart = new DateTimeOffset(2010, 10, 22, 0, 0, 0, new TimeSpan(-6, 0, 0)); //where –6 hours is the UTC offset for MST in the summer.

DateTime startDate = doStart.LocalDateTime; //use startdate in your unit test.

Fiddler–Capturing HTTP traffic for a WCF client running under an ASP.Net website

If you create a WCF client in an executable application (WinForm, Console, etc), then it is easy to capture the http traffic being exchanged between the client and the server.
But when your WCF client code is inside an Asp.Net website, then Fiddler does not automatically capture the traffic being generated between the client-code and the server.
To enable capturing the http traffic being exchanged by a WCF client implemented inside an ASP.Net website, you need to tell Asp.Net to use Fiddler’s proxy server. This is easily accomplished by adding the following to the web.config file :
The above snippet should be added under the Configuration node (easiest to add it right before the closing Configuration tag).
Once you add the above code, you should be able to capture the http traffic in Fiddler.
Notes: Make sure that Fiddler is capturing for “All Processes” (set in the Fiddler status bar). Also you might have to restart both Fiddler and your Visual Studio (make sure you restart Fiddler before Visual Studio).

Sunday, September 19, 2010

Windows Phone 7–Zune Software is not installed error

If you get the “Zune software is not launched. Retry after making sure that Zune software is launched.” error… Then make sure that the target selected for deployment of Windows Phone 7 projects is set to “Windows Phone 7 Emulator”.


Saturday, September 18, 2010

Asp.Net Cryptographic Oracle Padding (COP) Vulnerability

On September 17, 2010, Microsoft issued an important bulletin regarding a major vulnerability that exists in Asp.Net that can allow a hacker to decrypt and encrypt data used by the Asp.Net application (data such as what is typically stored in the ViewState).

First off, watch this video of an attack run against a DotNetNuke Asp.Net web-site and see the level to which an attacker can gain access to the site: (super user, ability to upload modules and files, ability to run commands and ability to download files once the attack was successful and the cryptographic keys were extracted).

More information:

MS bulletin: Microsoft Security Advisory (2416728)

  • Called the "Cryptographic Oracle Padding"  (COP) or sometimes just the “Padding Oracle” vulnerability. (I like COP better!)
  • Exists in many web-platforms (, ruby on rails, etc). It looks like it exploits the fact that some web-platforms return different error messages depending on the type of errors in the encrypted text. By modifying the encrypted information and sending it repeatedly to the server the hacker can get enough information to be able to begin decrypting and encrypting data.
  • Some other systems that are vulnerable:
    JSF implementations such as: Apache MyFaces and SUN Mojarra.
    Ruby on Rails
    OWASP ESAPI for Java (up to version 2.0 RC2)
    Video of an attack on a website hosted using Apache (created by Netifera):
  • Most developers follow the best practice of never storing sensitive information in the view-state, but sometimes people end up using the view-state to store sensitive information, because they think it is secure as it is encrypted. In this case, sensitive information may get compromised.
  • Best practice: never pass sensitive information to a client if the client has no use for it - which normally makes the ViewState ineligible for storing secure data. Also, never store security related information in the ViewState (eg: user access level, etc.)
  • Microsoft has provided a basic vb script that allows you to quickly determine which web-sites might be vulnerable.
  • Shutting down the vulnerability is as simple as making sure the server does not provide error specific information and uses a single error page for all errors. (In addition, the single error page can use a random delay to make it even harder to exploit cryptographic vulnerabilities – there is an old one where one could use the time taken to respond to a request to slowly glean more information into the cryptographic keys). (Enable custom errors and use a single error page for all errors)

As the paper by concludes by paraphrasing Nate Lawson, so do I, as the thoughts are important:

If you find yourself needing to implement crypto, it’s likely you
can avoid it by thinking about the situation differently. For example, many web developers get seduced into designing their own crypto as a way to push state to the client instead of managing it on the server. This opens up a much wider attack surface on the server application since now every part of that blob needs to be considered malicious. As the saying goes, "... now you have two problems."

The reason all this is so hard is that crypto is fundamentally unsafe. People hear that crypto is strong and confuse that with safe. Crypto can indeed be very strong but is extremely unsafe.

More technical info and background on the vulnerability is available from Microsoft at this blog-post:

Information about the exploit can be found at the Netifera (I believe they are the guys who found the vulnerability):

Also, while at NetiFera read their paper: Practical Padding Oracle Attacks.


More videos of attacks against the COP vulnerability:

A paper describing the attack in more detail:
A.K.L. Yau, K.G. Paterson and C.J. Mitchell, Padding oracle attacks on CBC-mode encryption with random and secret IVs. In H. Gilbert and H. Handschuh (eds.), FSE 2005, Lecture Notes in Computer Science Vol. 3557, pp. 299-319, Springer, 2005.

Friday, September 17, 2010

My new favorite free screen capture tool–PicPick

There is no price better than “free” and so I was using Faststone’s Capture version 5.3 tool until today for all my screen capture needs. Why version 5.3 when they are currently on version 6.7? Version 5.3 was the last one after which Faststone made their application a 30 day trial limited software.

I love Faststone Capture – even at version 5.3 it came close to SnagIt and its many features that I had grown used to. But 5.3 was getting dated and it wasn’t updated for Windows 7.

And today I found a new replacement for my screen capture tasks: PicPick.

PicPick, provides me with all the normal screen capture options: full screen, active window, free hand, etc. In addition it also provides me with the all important “Auto-Scroll” option that allows me to capture long documents and web-pages (a feature that is not available in all screen capture tools). PicPick, is more than a screen capture tool. It has a whole slew of tools for which I used to require to use multiple separate applications before (ruler, magnifier, protractor, etc.). I have been using it for only a day now, and I have already uninstalled Faststone Capture.

PicPick got a 4.5 star rating by CNet Editors and is tested spyware free: and ranked #12 in the Image Editing Software category.

Most importantly, PicPick is free!

Tuesday, September 14, 2010

Developer traits: Hubris vs Humility

Worst developer trait: Hubris {belief that only your ideas make sense and only you understand the technology and your coding skills are better than everybody else’s} : You have reached a plateau.

Good developer trait: Humility {belief that your code is not always correct and that you can make mistakes and that you can learn better coding techniques from others} : You are always growing and learning.

There is a ton that can be said for the above two, and this post will probably grow as I can come up with examples of both as well as other traits that I think make a developer a good developer or a bad developer

Wednesday, September 08, 2010

Phrase: Light the blue touch paper

Recently came across the phrase “Light the blue touch paper” and wondered what it meant.


If someone lights the touch paper or lights the blue touch paper, they do something which causes anger or excitement.

The basis of the phrase is in the meaning of “touch-paper”, which is a paper steeped in saltpeter, which burns slowly, and is used as a match for firing gunpowder, and the like. ( Lighting it initiates the process leading to the explosion. To "light the blue touch paper" is simply a colloquial expression meaning "to kick things off" or "to get things started"

Monday, September 06, 2010

Ad–Windows Phone 7 is coming…

I am excited enough that even though I was eligible for an iPhone upgrade in july of this year, I plan to wait for the Windows Phone 7 launch later.

Sunday, September 05, 2010

Infer.Net–Machine Learning framework for .Net

From MSR

Infer.NET is a framework for running Bayesian inference in graphical models.  You can use it to solve many different kinds of machine learning problems, from standard problems like classification or clusteringthrough to customised solutions to domain-specific problems. Infer.NET has been used in a wide variety of domains including information retrieval, bioinformatics, epidemiology, vision, and many others.

One of the interesting aspects of Infer.Net is that you define your problem as a model and Infer.Net creates source code based on that definition, which is then used to generate results.


Machine for .Net Learning on CodePlex: (Binary and multi-class classification and clustering algorithm implementations). Project has been developed by Seth Juarez.

At this point Infer.Net cannot be used in a commercial application. Whereas, Seth Juarez’s library can be used in a commercial application.

Words - Sisyphean

Sisyphean • \sis-uh-FEE-un\  • adjective
: of, relating to, or suggestive of the labors of Sisyphus; specifically : requiring continual and often ineffective effort

Saturday, September 04, 2010

The future of Silverlight

From a September 1st, 2010 blog post: The Future of Silverlight

Read the post as it talks about Silverlight and HTML5 and Microsoft’s commitment to both technologies. But for the following 3 major classes of applications here is what we will see happening:

Premium Media Experiences
  • High Definition (HD) H.264 and VC-1 video
  • Content protection including DRM
  • Stereoscopic 3D video
  • Multicast
  • Live broadcast support
  • (Adaptive) Smooth Streaming
  • Information overlays / Picture-in-picture
  • Analytics support with the Silverlight Analytics Framework
Consumer Apps and Games
  • Fully-customizable controls with styles and skins
  • The best designer – developer workflow through our tools and shared projects
  • Fluid motion via bitmap caching and effects
  • Perspective 3D
  • Responsive UI with .NET and multithreading
Business/Enterprise Apps
  • Full set of 60+ pre-built controls, fully stylable
  • Productive app design and development tools
  • Powerful performance with .NET and C#
  • Powerful, interactive data visualizations through charting controls and Silverlight PivotViewer
  • Flexible data support: Databinding, binary XML, LINQ, and Local Storage
  • Virtualized printing
  • COM automation (including Microsoft Office connectivity), group policy management

Silverlight is much more than a browser technology.

Silverlight will be available for out of browser scenarios (desktop), mobile, and even the living room. In the near future I am excited to see the innovations in the mobile field with Windows Phone 7.

Friday, September 03, 2010

Thursday, September 02, 2010

MsTests–Shortcut keys

Some useful shortcut keys for use with MsTests in Visual Studio.

CTRL + R, then press A: Runs all the tests in all test projects.

CTRL + R, then press D: Runs all tests that were run in the last test run.

CTRL + R, then press F: Runs all tests in the last test run that did not pass.

CTRL + R, then press T: Runs the tests in the current scope. Scope is determined from the current position of cursor (current test method, tests in the current test class, or all tests in the namespace).

CTRL + R, then press C: This runs all the tests in the current test class.

CTRL + R, then press N: This runs all tests in the current namespace.

Easily migrate your Asp.Net site to use WIF for federated authentication

A good post that takes you through the steps of implementing WIF on an ASP.Net website (starting from a basic Asp.Net site).

How To Migrate Existing ASP.NET Web Application To Claims Aware

MSTests - Multiple tests with ID {GUID} found error

If you get the error “Multiple tests with ID {GUID} found.” when attempting to run a MsTest list, then it is one of the following:

If you are using VS2005 then – inheritance of tests is not supported.

If you are using VS2008 or newer, then just refresh your test-manager and the error should go away.