Attention: We are retiring the ASP.NET Community Blogs. Learn more >

Dev Blog - Johan Danforth

I'm Johan Danforth and this is my dev blog - a mix of .NET, ASP.NET, Rest, Azure and some other random coding stuff.

  • [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>();
            list.Add(1);
            list.Add(2);
            list.Add(3);
            list.Add(4);

            
    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);
            }
            
    Console.WriteLine();
            
    Console.WriteLine();

            
    //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);
            }
            
    Console.WriteLine();
            
    Console.WriteLine();

            
    //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);
            }

            
    Console.WriteLine();
            
    Console.WriteLine();

            
    //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);
            }
            
            
    Console.WriteLine();
        }
    }

    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 -> http://playgo.to/interactive/