Archives / 2006 / May
  • [Vista] What does Vista do when it Sleeps?

    I have to say the new "power button" which puts Vista into the new "Sleep" mode seems nice. My 2 Ghz laptop (which doesn't have much on it yet I must admit) goes to sleep in 1 second and starts up in pretty much the same time. Superfast - I like it.

    As I understand it, by default a laptop is put into sleep mode when the power button is pressed, then goes into hibernate (saves memory to disk) after a few hours or so, to save power. When resuming from hibernate it takes a bit longer for the box to get going, but that's understandable. It's possible to configure what happens when you press the power button or close the lid, also depending on if you're on battery or plugged in.

    You can read more of what Vista does when it's in sleep mode on the Microsoft Vista Performance pages.

  • [Ajax] GWT - Google Web Toolkit

    Related to what I wrote in my previous post about Script#, there is already GWT - Google Web Toolkit, which does something similar but with Java. You write your front end in the Java language, and the GWT compiler converts the code into JavaScript and HTML.
  • [Ajax] Check Out the Script# Prototype

    This should interest all of you who are into AJAX, Atlas and that kind of stuff no the ASP.NET platform - Nikhil (who is an architect on the Web Platform and Tools team at Microsoft) releases a prototype of a C# to Javascript/Ajax compiler and looks for feedback:

    Script# brings the C# developer experience (programming and tooling) to Javascript/Ajax world. This post shares a prototype project for enabling script authoring via C#...

    Check it out - Nikhil also got a video to explain how it works.

  • Stylish Quotes in Blog Posts

    I found a few CSS tips and tricks to format (in my view) prettier quotes in your blog posts. For example:

    This is a quote.

    For the above, I added this CSS:

    blockquote {
      background: transparent url(quoleft.png) left top no-repeat;

    If you want to add a closing quote to it as well, add this:

    blockquote p {
      padding: 0 48px;
      background: transparent url(quoright.png) right bottom no-repeat;

    If you use <P> inside the quote, you may get additional quote signs, so use a couple of <BR /> instead.

  • [Vista] Is Sami the Default Swedish Language?

    I had heard about this before, but someone had also said it was going to be fixed for beta 2. Looks like it wasn't because when I selected Sweden as my region, it defaulted to Sami, Lule (Sweden) as language :)

    There were actually 3 different Sami dialects available; Lule, Northern and Southern, which is amazing in itself. I had no idea we had all these different versions of the Sami language... I can't remember seeing Finnish in that list though, but it should be.

    Overall, the installation went really smooth, but I'm installing on the bare metal here, and not in VPC or Virtual Server. Graphic is stunning...

  • [Vista] Beta 2 Available on MSDN Subscription

    Guess I'm not the first to notice, but beta 2 of Vista is available for download to MSDN subscription owners. 3200 MB ISO :)

    EDIT: There still (day after release) seems to be a problem with generating license keys for any other Vista version than the premium home edition. I guess we'll have to check back on the MSDN Subscription page every now and then and see if it gets fixed.

  • Copy Code and Paste as HTML From VisualStudio 2005

    There are 100's of macros and add-ins and plug-ins doing this, but I got this one from "CodingHorror" installed and configured an ALT-C shortcut to copy the code as HTML. It's a manual installation process, but it's good enough for me.

    Now why VS 2005 doesn't ship with a proper copy/paste functionality is something I don't really understand. But it gives a whole lot of happy late-nighters a chance to whip up something useful on their own :)

  • [.NET 2.0] Testing Generics, Collections and Yield Return

    I've not looked too much at the yield return statement in c# 2.0 yet, but if you learn how to use it I'm sure it will become something you use "every day" when programming. Whenever you need to do some conditional iterations on a collection, array or list, yield may be a nice solution to go for. A few, silly and not perfect, snippets which helped me understand how to use yield return:

    using System;
    using System.Collections;
    using System.Collections.Generic;

    public class Program

    static void Main()
            // Build up a few arrays and a list to work with
    string[] names = { "Johan", "Per", "Thomas", "Lina", "Juan", "Jan-Erik", "Mats" };
    int[] values = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
    List<int> list = new List<int>();

    Console.WriteLine("Get the names which contains an 'a':");

    // Iterate on all names which contains letter 'a'
            foreach (string name in EnumerableUtils<string>.GetNamesContainingLetter(names, 'a'))
    Console.Write("{0} ", name);

    //iterate through first half of this collection
            Console.WriteLine("First half of the name-array:");
    foreach (string name in EnumerableUtils<string>.GetFirstHalfFromList(names))
    Console.Write("{0} ", name);

    //iterate through first half of another collection
            Console.WriteLine("First half of the value-array:");
    foreach (int value in EnumerableUtils<int>.GetFirstHalfFromList(values))
    Console.Write("{0} ", value);


    //iterate through first half of a List
            Console.WriteLine("First half of the value-list:");
    foreach (int value in EnumerableUtils<int>.GetFirstHalfFromList(list))
    Console.Write("{0} ", value);

    public class EnumerableUtils<T>
    public static IEnumerable GetNamesContainingLetter(string[] names, char letter)
    foreach (string name in names)
    if (name.ToLower().Contains(letter.ToString().ToLower()))
    yield return name;

    public static IEnumerable<T> GetFirstHalfFromList(List<T> arr)
    for (int i = 0; i < arr.Count / 2; i++)
    yield return arr[i];

    public static IEnumerable<T> GetFirstHalfFromList(T[] arr)
    for (int i = 0; i < arr.Length / 2; i++)
    yield return arr[i];

  • Martin Fowler on Ruby

    Martin Fowler just blogged a pretty long post on his view on Ruby. I don't want to ruin the reading for you but it ends with:

    But overall I'm increasingly positive about using Ruby for serious work where speed, responsiveness, and productivity are important.


    Personally I've managed to install Rails and went through some tutorials. Not enough for me to give it a verdict.

  • [.NET 2.0] Quick Way of Closing VisualStudio Files

    If you end up having a zillion files opened in the VisualStudio 2005 IDE and want to close a few of them, just click with the MIDDLE mouse button on their tabs where you see the filename. Quick and easy.

  • [.NET 2.0] Visual Studio 2005 Web Application Project V1.0 Released

    From the Visual Studio 2005 Web Application Project webby:

    Today we released the V1.0 release of the VS 2005 Web Application Project option. You can learn about it here, and download it here.

    You should then check out the tutorials on this site to learn more about it and how to use it. You might also want to keep an eye on my blog -- where I'll be posting updates about it regularly.

    This forum is the best place to ask questions or get get answers about the VS 2005 Web Application Project option.

  • [Ajax] Check Out the "Atlas" Control Toolkit

    You may want to look at the "Atlas" Control Toolkit site where they have a list of cool samples of what you can do with it, and it's dead simple. You can probably live without some of the controls, but some of them are quite useful and you would have to spend quite some time to achieve the effects you get for free. My favos on that list are the CollapsiblePanel and the TextBoxWatermark.

    Some may argue that these controls have nothing to do with Ajax, but Ajax has become synonymous with a rich UI, and this is what "Atlas" gives you for sure.

  • How to Play Go

    I'm learning how to play Go, the old boardgame. Easy to learn, but hard to master. This is a pretty good web site with introduction to the game, and some interactive training ->
  • Windows Defender

    If you don't have it installed yet you should consider it. I have been running the Anti Spyware beta from Microsoft for quite some time now, and today it automatically updated itself to Windows Defender Beta 2. This program has been quite helpful with protecting my kids' computers. The young ones doesn't always know what is harmful to their boxes or not. I've told them "if you see a big pupup with a spyware warning in the right corner - let me know at once" :)

    About Windows Defender:

    Windows Defender (Beta 2) is a free program that helps protect your computer against pop-ups, slow performance, and security threats caused by spyware and other unwanted software. It features Real-Time Protection, a monitoring system that recommends actions against spyware when it's detected, and a new streamlined interface that minimizes interruptions and helps you stay productive.

  • [.NET 2.0] Visual Studio 2005 Web Application Project - Old Skool

    My thanks to ScottGu who commented on my earlier blog post about checking out the Visual Studio 2005 Web Application Project, which gives you Old Skool style of working with ASP.NET applications. I'm sure lots of people (like me) prefer the way it used to work. Whole thing with teaching old dogs... Snip from the site:

    The Visual Studio 2005 Web Application Project Model is a new web project option for Visual Studio 2005 that provides the same conceptual web project approach as VS 2003 (a project file based structure where all code in the project is compiled into a single assembly) but with all the new features of VS 2005 (refactoring, class diagrams, test development, generics, etc) and ASP.NET 2.0 (master pages, data controls, membership/login, role management, Web Parts, personalization, site navigation, themes, etc).

  • [.NET 2.0] Using Web Deployment Projects with Visual Studio 2005

    Got a tip from a friend to have a look at this page on the MSDN webby about different web deployment options with VS.NET 2005. Snippet from that page:

    Visual Studio 2005 provides deployment support though its Copy Web Site and Publish Web Site features. While these are ideal for many scenarios, there are other, more advanced scenarios where developers need the following capabilities:

      • More control over assembly naming and output.
      • Custom pre-processing and post-processing for the build.
      • The ability to exclude, add, and transform files and directories during builds.
      • The ability to modify the Web.config file to change database connection strings, application settings, or the URLs for Web references, depending on the build configuration. (For example, it might be necessary to use different values for development, test, staging, and release settings).
    This white paper describes a solution to these advanced scenarios and introduces a new feature called Web Deployment Projects for Visual Studio 2005.

    There is a VS.NET plugin available on that page with the following features for building ASP.NET 2.0 web sites:

    • ASP.NET 2.0 precompilation as part of the build process.
    • More flexible options for generating compiled assemblies from a Web project, including these alternatives:
      • A single assembly for the entire Web site.
      • One assembly per content folder.
      • A single assembly for all UI components.
      • An assembly for each compiled file in the Web site.
    • Assembly signing options.
    • The ability to define custom pre-build and post-build actions.
    • The ability to exclude folders from the build.
    • The ability to modify settings in the Web.config file, such as the <connectionString> element, based on the Visual Studio build configuration.
    • Support for creating .msi files with setup projects.

    The extensibility of Web Deployment projects enables you to tailor the build and deploy process to suit your needs. This is done without sacrificing the optimized workflow improvements achieved with Visual Studio 2005 Web site projects.

    I still have to read the whole page myself and try out the add-in. Looks interesting and useful though.
  • [.NET 2.0] Writing Your Own Provider

    Being intrigued by the provider system, I though I would spend some time on the excellent Provider Toolkit page on MSDN to see if I could understand how to write your own provider. From scratch that is, not based on the membership stuff.

    I found this great page, which describes how to write an SqlImageProvider from ground up. The sample code on the page got some errors in it, but I got it working eventually, and it's just amazing. I'll write another really simple provider and post the code here soon.

    I'm thinking what I could use the provider system for... perhaps if you wanted to construct a system where you know you would start using Access or even XML files, then at a later state move to SQL or Oracle. You could write the whole interface to your DAL as a provider... perhaps a bit too much code to be funny, but it could work. Each method would have to be written at least three times - once for the base, once for the service and of course once for the concrete provider where you would probably use whatever helper classes you got to actually manage the data. Oh well...

  • [.NET 2.0] Taking a Web App Offline

    This is a neat feature of ASP.NET 2.0 I just found out about. Loads of people have already written about it, but it's so useful that I decided to put it on my blog as well. By placing a file called 'app_offline.htm' in the root directory of your web app, no ASP.NET dynamic pages are no longer served. The web server returns the content of that file instead. This is what ScottGu wrote about this feature on his blog:

    Basically, if you place a file with this name in the root of a web application directory, ASP.NET 2.0 will shut-down the application, unload the application domain from the server, and stop processing any new incoming requests for that application.  ASP.NET will also then respond to all requests for dynamic pages in the application by sending back the content of the app_offline.htm file (for example: you might want to have a “site under construction” or “down for maintenance” message).

    This provides a convenient way to take down your application while you are making big changes or copying in lots of new page functionality (and you want to avoid the annoying problem of people hitting and activating your site in the middle of a content update).  It can also be a useful way to immediately unlock and unload a SQL Express or Access database whose .mdf or .mdb data files are residing in the /app_data directory.

    Once you remove the app_offline.htm file, the next request into the application will cause ASP.NET to load the application and app-domain again, and life will continue along as normal.

    You may want to read all the comments to this blog entry, some interesting conversation there.

    I just happened to stumble upon this feature when I was publishing my web app directly from within VisualStudio (Build->Publish...), because VS automatically places that file in the web app during upload of the new files. Neat. What is not so neat is that VS didn't remove the app_offline.htm file once it was done publishing :) Maybe it was because I was publishing to an FTP site... not sure. Will try again some other time.