<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">
  <title>thedersen.com</title>
  <id>http://thedersen.com</id>
  <updated>2010-01-07T00:00:00Z</updated>
  <author>
    <name>Thomas Pedersen</name>
  </author>
  <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/thedersen" /><feedburner:info uri="thedersen" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry>
    <title>Backbone.Validation</title>
    <link href="http://feedproxy.google.com/~r/thedersen/~3/iWSe0ECCOgI/" rel="alternate" />
    <id>http://thedersen.com/2011/12/28/backbonevalidation/</id>
    <published>2011-12-28T00:00:00Z</published>
    <updated>2011-12-28T00:00:00Z</updated>
    <author>
      <name>Thomas Pedersen</name>
    </author>
    <summary type="html">&lt;p&gt;I just released version 0.2.0 of my &lt;a href="http://github.com/thedersen/backbone.validation"&gt;validation plugin&lt;/a&gt; for &lt;a href="http://backbonejs.org/"&gt;Backbone.js&lt;/a&gt;. The plugin lets you declare validation rules on your Backbone model, ensuring that input from the user is valid. It currently ships with 18 built-in validators such as required, min, max, range, length, minLength, maxLength, regex-validator etc. In addition to the built-in validators, it is very easy to extend with your custom validators&amp;hellip;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;I just released version 0.2.0 of my &lt;a href="http://github.com/thedersen/backbone.validation"&gt;validation plugin&lt;/a&gt; for &lt;a href="http://backbonejs.org/"&gt;Backbone.js&lt;/a&gt;. The plugin lets you declare validation rules on your Backbone model, ensuring that input from the user is valid. It currently ships with 18 built-in validators such as required, min, max, range, length, minLength, maxLength, regex-validator etc. In addition to the built-in validators, it is very easy to extend with your custom validators.&lt;/p&gt;

&lt;p&gt;Lets start with an example of how to declare validation rules on your model:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;:::js
var SomeModel = Backbone.Model.extend({
  validation: {
    name: {
      required: true,
      msg: 'Name is required'
    },
    age: {
      range: [1, 80]
    },
    email: {
      pattern: 'email'  
    },
    someAttribute: function(value) {
      if(value !== 'somevalue') {
        return 'Error'; 
      }
    }
  }
});
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;To configure your validation rules, simply add a validation object with a property for each attribute you want to validate on your model. The validation rules can either be an object with one of the built-in validators or a combination of two or more of them, or a function where you implement your own custom validation logic. If you want to provide a custom error message when using one of the built-in validators, simply define the &lt;code&gt;msg&lt;/code&gt; property with your message.&lt;/p&gt;

&lt;p&gt;To add your own validators, extend the &lt;code&gt;Backbone.Validation.validators&lt;/code&gt; object as shown in the example below where we use &lt;a href="http://underscorejs.org"&gt;underscore.js&lt;/a&gt; &lt;code&gt;extend&lt;/code&gt; method. You can also redefine one or more of the built-in validators if it doesn&amp;rsquo;t fit your needs.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;:::js
_.extend(Backbone.Validation.validators, {
  myValidator: function(value, attr, customValue, model) {
    if(value !== customValue) {
      return 'error';
    }
  },
  required: function(value, attr, customValue, model) {
    if(!value) {
      return 'My version of the required validator';
    }
  }, 
});

var Model = Backbone.Model.extend({
  validation: {
    age: {
      myValidator: 1 // uses your custom validator
    }
  }
});
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;A couple conventions&lt;/h2&gt;

&lt;p&gt;After performing validation, an &lt;code&gt;isValid&lt;/code&gt; attribute is set on the model that is (obviously) &lt;code&gt;true&lt;/code&gt; when all the attributes on the model is valid, otherwise it is &lt;code&gt;false&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;Backbone.Validation.callbacks&lt;/code&gt; contains two methods: &lt;code&gt;valid&lt;/code&gt; and &lt;code&gt;invalid&lt;/code&gt;. These are called (in addition to the error event raised by Backbone) after validation of an attribute is performed.&lt;/p&gt;

&lt;p&gt;The default implementation of invalid tries to look up an element within the view with an id equal to the name of the attribute that is validated. If it finds one, an invalid class is added to the element as well as a data-error attribute with the error message. The valid method removes these if they exists. You can also configure it to use a class selector instead of id selector.&lt;/p&gt;

&lt;p&gt;As with the validators, you can redefined the behavior of these callbacks by overriding the implementation.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;:::js
_.extend(Backbone.Validation.callbacks, {
  valid: function(view, attr, selector) {
    // do something
  },
  invalid: function(view, attr, error, selector) {
    // do something
  }
});
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Validation binding&lt;/h2&gt;

&lt;p&gt;For all of this to work, you need to hook up the validation. The validation binding code is executed with a call to &lt;code&gt;Backbone.Validation.bind(view)&lt;/code&gt;. The &lt;a href="http://backbonejs.org/#Model-validate"&gt;validate&lt;/a&gt; method on the view&amp;rsquo;s model is then overridden to perform the validation.&lt;/p&gt;

&lt;p&gt;There are several places that it can be called from, depending on your circumstances.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;:::js
// Binding when rendering
var SomeView = Backbone.View.extend({
  render: function(){
    Backbone.Validation.bind(this);
  }
});

// Binding when initializing
var SomeView = Backbone.View.extend({
  initialize: function(){
    Backbone.Validation.bind(this);
  }
});

// Binding from outside a view
var SomeView = Backbone.View.extend({
});
var someView = new SomeView();
Backbone.Validation.bind(someView);
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Summary&lt;/h2&gt;

&lt;p&gt;With this declarative way of defining validation, combined with the conventional updating of your user interface, it makes for an easy way to handle client validation. At least I think so.&lt;/p&gt;

&lt;p&gt;But remember: you add client validation to be nice to your users, but you also need to add server validation to be nice to yourself and your company.&lt;/p&gt;

&lt;p&gt;The source code for this project is licensed under the &lt;a href="http://thedersen.mit-license.org/"&gt;MIT License&lt;/a&gt; and is available on &lt;a href="https://github.com/thedersen/backbone.validation"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/thedersen?a=iWSe0ECCOgI:t91LVmFyNJY:_tX2Dl0juqE"&gt;&lt;img src="http://feeds.feedburner.com/~ff/thedersen?i=iWSe0ECCOgI:t91LVmFyNJY:_tX2Dl0juqE" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/thedersen/~4/iWSe0ECCOgI" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://thedersen.com/2011/12/28/backbonevalidation/</feedburner:origLink></entry>
  <entry>
    <title>UnityConfiguration 1.4 is out</title>
    <link href="http://feedproxy.google.com/~r/thedersen/~3/g9rx6czV1gc/" rel="alternate" />
    <id>http://thedersen.com/2011/11/15/unityconfiguration-14-is-out/</id>
    <published>2011-11-15T00:00:00Z</published>
    <updated>2011-11-15T00:00:00Z</updated>
    <author>
      <name>Thomas Pedersen</name>
    </author>
    <summary type="html">&lt;p&gt;Some minor improvements has been made, issues are closed, and here&amp;rsquo;s the new version for you&amp;hellip;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;Some minor improvements has been made, issues are closed, and here&amp;rsquo;s the new version for you.&lt;/p&gt;

&lt;p&gt;So, what&amp;rsquo;s changed in v1.4?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Added extension methods to the &lt;code&gt;IAssemblyScanner&lt;/code&gt; for easier discovery and configuration of conventions

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;scan.WithFirstInterfaceConvention()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;scan.WithNamingConvention()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;scan.WithAddAllConvention()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;scan.WithSetAllPropertiesConvention()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Added non-generic overload to the &lt;code&gt;AddAllConvention&lt;/code&gt; that allows you to register open generic interfaces

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;scan.WithAddAllConvention().TypesImplementing(typeof(IHandler&amp;lt;&amp;gt;))&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Added option on the &lt;code&gt;IAssemblyScanner&lt;/code&gt; interface to scan for internal types in an assembly

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;scan.InternalTypes()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Strong named the assembly&lt;/li&gt;
&lt;li&gt;Switched to &lt;a href="http://semver.org/"&gt;Semantic Versioning&lt;/a&gt;. In short this means that when

&lt;ul&gt;
&lt;li&gt;the major number is changed: There will be breaking changes&lt;/li&gt;
&lt;li&gt;the minor number is changed: New features are added, but it is still backwards compatible&lt;/li&gt;
&lt;li&gt;the patch number is changed: Backwards compatible bugs fixes only&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;As usual you can install it via &lt;a href="http://nuget.org/List/Packages/UnityConfiguration"&gt;NuGet&lt;/a&gt; using the package manager in Visual Studio:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;PM&amp;gt; Install-Package UnityConfiguration
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;or, if you like, you can grab the code at &lt;a href="http://github.com/thedersen/unityconfiguration"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Hope you enjoy it!&lt;/p&gt;
&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/thedersen?a=g9rx6czV1gc:l_QWJ1IAAg4:_tX2Dl0juqE"&gt;&lt;img src="http://feeds.feedburner.com/~ff/thedersen?i=g9rx6czV1gc:l_QWJ1IAAg4:_tX2Dl0juqE" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/thedersen/~4/g9rx6czV1gc" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://thedersen.com/2011/11/15/unityconfiguration-14-is-out/</feedburner:origLink></entry>
  <entry>
    <title>New version of UnityConfiguration</title>
    <link href="http://feedproxy.google.com/~r/thedersen/~3/E9c2XLi9lUI/" rel="alternate" />
    <id>http://thedersen.com/2011/07/17/new-version-of-unityconfiguration/</id>
    <published>2011-07-17T00:00:00Z</published>
    <updated>2011-07-17T00:00:00Z</updated>
    <author>
      <name>Thomas Pedersen</name>
    </author>
    <summary type="html">&lt;p&gt;I just pushed a new release of &lt;a href="http://github.com/thedersen/unityconfiguration"&gt;UnityConfiguration&lt;/a&gt; to &lt;a href="http://nuget.org/List/Packages/UnityConfiguration"&gt;NuGet&lt;/a&gt;&amp;hellip;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;I just pushed a new release of &lt;a href="http://github.com/thedersen/unityconfiguration"&gt;UnityConfiguration&lt;/a&gt; to &lt;a href="http://nuget.org/List/Packages/UnityConfiguration"&gt;NuGet&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;So what&amp;rsquo;s new in v1.3?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Documented public facing methods&lt;/li&gt;
&lt;li&gt;Included the xml documentation in the NuGet package&lt;/li&gt;
&lt;li&gt;Debugging symbols are available on &lt;a href="http://symbolsource.org"&gt;SymbolSource.org&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Several more overloads for adding assemblies to the scanner&lt;/li&gt;
&lt;li&gt;One more overload for adding a registry that takes an instance of a UnityRegistry&lt;/li&gt;
&lt;li&gt;New convention that scans for registries&lt;/li&gt;
&lt;li&gt;New convention that uses an overridable naming convention for registering a type mapping&lt;/li&gt;
&lt;li&gt;Added Transient, PerThread, PerResolve, ExternallyControlled and HierarchicalControlled lifetime scope configuration&lt;/li&gt;
&lt;li&gt;&lt;code&gt;MakeSingleton&lt;T&gt;()&lt;/code&gt; and &lt;code&gt;MakeSingleton&lt;T&gt;(string)&lt;/code&gt; is marked as obsolete. Use &lt;code&gt;Configure&lt;T&gt;().AsSingleton()&lt;/code&gt; or &lt;code&gt;Configure&lt;T&gt;().WithName(name).AsSingleton()&lt;/code&gt; instead&lt;/li&gt;
&lt;li&gt;&lt;code&gt;ConfigureCtorArgsFor&lt;T&gt;(params object[] args)&lt;/code&gt; is marked as obsolete. Use &lt;code&gt;Configure&lt;T&gt;().WithConstructorArguments(params object[])&lt;/code&gt; instead&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Install using the package manager console in Visual Studio:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;PM&amp;gt; Install-Package UnityConfiguration
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Hope you enjoy it!&lt;/p&gt;
&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/thedersen?a=E9c2XLi9lUI:iz-Mev0TlM8:_tX2Dl0juqE"&gt;&lt;img src="http://feeds.feedburner.com/~ff/thedersen?i=E9c2XLi9lUI:iz-Mev0TlM8:_tX2Dl0juqE" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/thedersen/~4/E9c2XLi9lUI" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://thedersen.com/2011/07/17/new-version-of-unityconfiguration/</feedburner:origLink></entry>
  <entry>
    <title>Auto mocking with Unity and Moq</title>
    <link href="http://feedproxy.google.com/~r/thedersen/~3/g8lrlvcbQZs/" rel="alternate" />
    <id>http://thedersen.com/2011/02/21/auto-mocking-with-unity-and-moq/</id>
    <published>2011-02-21T00:00:00Z</published>
    <updated>2011-02-21T00:00:00Z</updated>
    <author>
      <name>Thomas Pedersen</name>
    </author>
    <summary type="html">&lt;p&gt;As mentioned in my &lt;a href="http://thedersen.com/2011/02/20/convention-based-configuration-for-microsoft-unity/"&gt;previous post&lt;/a&gt; we used the &lt;a href="http://unity.codeplex.com/"&gt;Microsoft Unity&lt;/a&gt; container in a previous project. We also used &lt;a href="http://code.google.com/p/moq/"&gt;Moq&lt;/a&gt; as our mocking library. Combining these two and making an auto mocking container seemed fairly easy, so I went ahead and created something I called UnityAutoMoq&amp;hellip;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;As mentioned in my &lt;a href="http://thedersen.com/2011/02/20/convention-based-configuration-for-microsoft-unity/"&gt;previous post&lt;/a&gt; we used the &lt;a href="http://unity.codeplex.com/"&gt;Microsoft Unity&lt;/a&gt; container in a previous project. We also used &lt;a href="http://code.google.com/p/moq/"&gt;Moq&lt;/a&gt; as our mocking library. Combining these two and making an auto mocking container seemed fairly easy, so I went ahead and created something I called UnityAutoMoq.&lt;/p&gt;

&lt;p&gt;Now, some say that auto mocking is a bad practice since it can hide certain design flaws in your system, like classes with to many dependencies etc. I say, that if you have these issues, it is probably not the auto mocking that is causing them. Auto mocking can increase your productivity, so I have no issues with using it. In fact, I encourage you to do so.&lt;/p&gt;

&lt;h2&gt;Using the container&lt;/h2&gt;

&lt;pre&gt;&lt;code&gt;:::cs
// Creating a new instance of the auto mock container
var container = new UnityAutoMoqContainer();

// Resolving a concrete class automatically creates
// mocks for the class dependencies and injects them
// before returning an instance of the class
Service service = container.Resolve&amp;lt;Service&amp;gt;();

// Resolving an interface, returns a mocked
// instance of that interface
IService mocked = container.Resolve&amp;lt;IService&amp;gt;();

// GetMock returns the mock on which you can do setup etc.
Mock&amp;lt;IService&amp;gt; mock = container.GetMock&amp;lt;IService&amp;gt;();

// Sometimes you need to cast your interface to some other type
// This is how that is done
container.ConfigureMock&amp;lt;IService&amp;gt;().As&amp;lt;IDisposable&amp;gt;();
Mock&amp;lt;IDisposable&amp;gt; disposable = container.GetMock&amp;lt;IService&amp;gt;().As&amp;lt;IDisposable&amp;gt;();
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Download&lt;/h2&gt;

&lt;p&gt;The framework is available as a &lt;a href="http://nuget.org/Packages/Packages/Details/UnityAutoMoq-2-0-1-0"&gt;NuGet package&lt;/a&gt;, and can be installed either using the package manager console in Visual Studio like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;PM&amp;gt; Install-Package UnityAutoMoq
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Or by right clicking on references in your project and select the Add Library Package Reference option&lt;/p&gt;

&lt;p&gt;&lt;img src="http://thedersen.com/images/unity-auto-moq-nuget.png" alt="NuGet" /&gt;&lt;/p&gt;

&lt;p&gt;The source code for this project is licensed under the &lt;a href="http://www.opensource.org/licenses/mit-license.php"&gt;MIT License&lt;/a&gt; and is available on my &lt;a href="http://github.com/thedersen/unityautomoq"&gt;GitHub profile&lt;/a&gt;.&lt;/p&gt;
&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/thedersen?a=g8lrlvcbQZs:f6HnrWUQT8U:_tX2Dl0juqE"&gt;&lt;img src="http://feeds.feedburner.com/~ff/thedersen?i=g8lrlvcbQZs:f6HnrWUQT8U:_tX2Dl0juqE" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/thedersen/~4/g8lrlvcbQZs" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://thedersen.com/2011/02/21/auto-mocking-with-unity-and-moq/</feedburner:origLink></entry>
  <entry>
    <title>Convention based configuration for Microsoft Unity</title>
    <link href="http://feedproxy.google.com/~r/thedersen/~3/FtvXkmylDok/" rel="alternate" />
    <id>http://thedersen.com/2011/02/20/convention-based-configuration-for-microsoft-unity/</id>
    <published>2011-02-20T00:00:00Z</published>
    <updated>2011-02-20T00:00:00Z</updated>
    <author>
      <name>Thomas Pedersen</name>
    </author>
    <summary type="html">&lt;p&gt;In a previous project, long story short, we used the &lt;a href="http://unity.codeplex.com/"&gt;Microsoft Unity&lt;/a&gt; IoC container. After writing line upon line with configuration statements while looking at the nice convention based configuration options for other containers, I decided that enough was enough. Replacing the Unity container was sadly not an option at the moment, so I went ahead and created a convention based configuration api for Unity&amp;hellip;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;In a previous project, long story short, we used the &lt;a href="http://unity.codeplex.com/"&gt;Microsoft Unity&lt;/a&gt; IoC container. After writing line upon line with configuration statements while looking at the nice convention based configuration options for other containers, I decided that enough was enough. Replacing the Unity container was sadly not an option at the moment, so I went ahead and created a convention based configuration api for Unity.&lt;/p&gt;

&lt;p&gt;Below you can see a small example of configuring a container using registries, and I should probably apologize for the poor (or rather lack of) documentation at this time.&lt;/p&gt;

&lt;p&gt;You get access to the configuration api by using the extension method Configure on the IUnityContainer interface.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;:::cs
var container = new UnityContainer();
container.Configure(x =&amp;gt;
{
    x.AddRegistry&amp;lt;FooRegistry&amp;gt;();
    x.AddRegistry&amp;lt;BarRegistry&amp;gt;();
});
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Configuration is done in one or several registries that inherit the UnityRegistry base class.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;:::cs
public class FooRegistry : UnityRegistry
{
    public FooRegistry()
    {
        // Scan one or several assemblies and auto register types based on a 
        // convention. You can also include or exclude certain types and/or 
        // namespaces using a filter.
        Scan(scan =&amp;gt;
        {
            scan.AssemblyContaining&amp;lt;FooRegistry&amp;gt;();
            scan.With&amp;lt;FirstInterfaceConvention&amp;gt;();
            scan.With&amp;lt;AddAllConvention&amp;gt;()
                .TypesImplementing&amp;lt;IHaveManyImplementations&amp;gt;();
            scan.With&amp;lt;SetAllPropertiesConvention&amp;gt;().OfType&amp;lt;ILogger&amp;gt;();
            scan.ExcludeType&amp;lt;FooService&amp;gt;();
        });

        // Manually register a service
        Register&amp;lt;IFooService, FooService&amp;gt;().WithName("Foo").AsSingleton();

        // Make services a singleton
        MakeSingleton&amp;lt;ISingletonService&amp;gt;();

        // You can automatically configure the container to call
        // a method on any service when they are created
        AfterBuildingUp&amp;lt;IStartable&amp;gt;().Call((c, s) =&amp;gt; s.Start();

        // You can automatically configure the container to 
        // decorate services when they are created
        AfterBuildingUp&amp;lt;IFooService&amp;gt;().DecorateWith((c, t) =&amp;gt; new FooDecorator(t));

        // If you want to inject values or objects that are not registered in
        // the container, you can do so by adding them using this statement.
        // For instances you want the container to create, just specify the type.
        ConfigureCtorArgsFor&amp;lt;ServiceWithCtorArgs&amp;gt;("some string", typeof (IFooService));

        // Unity follows the greedy constructor pattern when creating instances.
        // If you want to use a different constructor, you specify it by listing 
        // the types of the arguments in the constructor you want it to use.
        SelectConstructor&amp;lt;ServiceWithCtorArgs&amp;gt;(typeof (IFooService));
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;At the moment, built in conventions includes AddAllConvention, FirstInterfaceConvention and SetAllPropertiesConvention. If these doesn&amp;rsquo;t suit you, creating custom conventions is as easy as creating a class that implements the IAssemblyScanner interface.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;:::cs
public class CustomConvention : IAssemblyScannerConvention
{
    void IAssemblyScannerConvention.Process(Type type, IUnityRegistry registry)
    {
        if (type == typeof(FooService))
            registry.Register&amp;lt;IFooService, FooService&amp;gt;().WithName("Custom");
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Download&lt;/h2&gt;

&lt;p&gt;The framework is available as a &lt;a href="http://nuget.org/Packages/Packages/Details/UnityConfiguration-1-2-0-0"&gt;NuGet package&lt;/a&gt;, and can be installed either using the package manager console in Visual Studio like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;PM&amp;gt; Install-Package UnityConfiguration
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Or by right clicking on references in your project and select the Add Library Package Reference option&lt;/p&gt;

&lt;p&gt;&lt;img src="http://thedersen.com/images/unity-configuration-nuget.png" alt="NuGet" /&gt;&lt;/p&gt;

&lt;p&gt;The source code for this project is licensed under the &lt;a href="http://www.opensource.org/licenses/mit-license.php"&gt;MIT License&lt;/a&gt; and is available on my &lt;a href="http://github.com/thedersen/unityconfiguration"&gt;GitHub profile&lt;/a&gt;.&lt;/p&gt;
&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/thedersen?a=FtvXkmylDok:XUH_VwADO2Q:_tX2Dl0juqE"&gt;&lt;img src="http://feeds.feedburner.com/~ff/thedersen?i=FtvXkmylDok:XUH_VwADO2Q:_tX2Dl0juqE" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/thedersen/~4/FtvXkmylDok" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://thedersen.com/2011/02/20/convention-based-configuration-for-microsoft-unity/</feedburner:origLink></entry>
  <entry>
    <title>Best of 2010</title>
    <link href="http://feedproxy.google.com/~r/thedersen/~3/3yCWNy5oHLY/" rel="alternate" />
    <id>http://thedersen.com/2010/12/19/best-of-2010/</id>
    <published>2010-12-19T00:00:00Z</published>
    <updated>2010-12-19T00:00:00Z</updated>
    <author>
      <name>Thomas Pedersen</name>
    </author>
    <summary type="html">&lt;p&gt;It&amp;rsquo;s that time of the year again. Lists are popping up all over. Here is one more&amp;hellip;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;It&amp;rsquo;s that time of the year again. Lists are popping up all over. Here is one more.&lt;/p&gt;

&lt;div id="slider" class="nivoSlider"&gt;
    &lt;img src="http://thedersen.com/images/bestof2010/01.jpg" width="500" height="500" alt="" title="01. Arcade Fire - The Suburbs" /&gt;
    &lt;img src="http://thedersen.com/images/bestof2010/02.jpg" width="500" height="500" alt="" title="02. The National - High Violet" /&gt;
    &lt;img src="http://thedersen.com/images/bestof2010/03.jpg" width="500" height="500" alt="" title="03. Sufjan Stevens - The Age of Adz" /&gt;
    &lt;img src="http://thedersen.com/images/bestof2010/04.jpg" width="500" height="500" alt="" title="04. Deerhunter - Halcyon Digest" /&gt;
    &lt;img src="http://thedersen.com/images/bestof2010/05.jpg" width="500" height="500" alt="" title="05. Motorpsycho - Heavy Metal Fruit" /&gt;
    &lt;img src="http://thedersen.com/images/bestof2010/06.jpg" width="500" height="500" alt="" title="06. Beach House - Teen Dream" /&gt;
    &lt;img src="http://thedersen.com/images/bestof2010/07.jpg" width="500" height="500" alt="" title="07. LCD Soundsystem - This Is Happening" /&gt;
    &lt;img src="http://thedersen.com/images/bestof2010/08.jpg" width="500" height="500" alt="" title="08. Tame Impala - Innerspeaker" /&gt;
    &lt;img src="http://thedersen.com/images/bestof2010/09.jpg" width="500" height="500" alt="" title="09. Shearwater - The Golden Archipelago" /&gt;
    &lt;img src="http://thedersen.com/images/bestof2010/10.jpg" width="500" height="500" alt="" title="10. Menomena - Mines" /&gt;
    &lt;img src="http://thedersen.com/images/bestof2010/11.jpg" width="500" height="500" alt="" title="11. The Black Angels - Phosphene Dream" /&gt;
    &lt;img src="http://thedersen.com/images/bestof2010/12.jpg" width="500" height="500" alt="" title="12. The Besnard Lakes - The Besnard Lakes Are The Roaring Night" /&gt;
    &lt;img src="http://thedersen.com/images/bestof2010/13.jpg" width="500" height="500" alt="" title="13. The Walkmen - Lisbon" /&gt;
    &lt;img src="http://thedersen.com/images/bestof2010/14.jpg" width="500" height="500" alt="" title="14. I Am Kloot - Sky at Night" /&gt;
    &lt;img src="http://thedersen.com/images/bestof2010/15.jpg" width="500" height="500" alt="" title="15. Titus Andronicus - The Monitor" /&gt;
    &lt;img src="http://thedersen.com/images/bestof2010/16.jpg" width="500" height="500" alt="" title="16. Broken Social Scene - Forgiveness Rock Record" /&gt;
    &lt;img src="http://thedersen.com/images/bestof2010/17.jpg" width="500" height="500" alt="" title="17. Perfume Genius - Learning" /&gt;
    &lt;img src="http://thedersen.com/images/bestof2010/18.jpg" width="500" height="500" alt="" title="18. Belle &amp; Sebastian - Write about Love" /&gt;
    &lt;img src="http://thedersen.com/images/bestof2010/19.jpg" width="500" height="500" alt="" title="19. The Black Keys - Brothers " /&gt;
    &lt;img src="http://thedersen.com/images/bestof2010/20.jpg" width="500" height="500" alt="" title="20. Black Mountain - Wilderness Heart" /&gt;
    &lt;img src="http://thedersen.com/images/bestof2010/21.jpg" width="500" height="500" alt="" title="21. The Tallest Man on Earth - The Wild Hunt" /&gt;
    &lt;img src="http://thedersen.com/images/bestof2010/22.jpg" width="500" height="500" alt="" title="22. Suckers - Wild Smile" /&gt;
    &lt;img src="http://thedersen.com/images/bestof2010/23.jpg" width="500" height="500" alt="" title="23. The Morning Benders - Big Echo" /&gt;
    &lt;img src="http://thedersen.com/images/bestof2010/24.jpg" width="500" height="500" alt="" title="24. MGMT - Congratulations" /&gt;
    &lt;img src="http://thedersen.com/images/bestof2010/25.jpg" width="500" height="500" alt="" title="25. Midlake - The Courage Of Others" /&gt;
    &lt;img src="http://thedersen.com/images/bestof2010/26.jpg" width="500" height="500" alt="" title="26. Wolf Parade - Expo 86" /&gt;
    &lt;img src="http://thedersen.com/images/bestof2010/27.jpg" width="500" height="500" alt="" title="27. Broken Bells - Broken Bells" /&gt;
    &lt;img src="http://thedersen.com/images/bestof2010/28.jpg" width="500" height="500" alt="" title="28. Ariel Pink's Haunted Graffiti - Before Today" /&gt;
    &lt;img src="http://thedersen.com/images/bestof2010/29.jpg" width="500" height="500" alt="" title="29. Teenage Fanclub - Shadows" /&gt;
    &lt;img src="http://thedersen.com/images/bestof2010/30.jpg" width="500" height="500" alt="" title="30. of Montreal - False Priest" /&gt;
&lt;/div&gt;


&lt;p&gt;It&amp;rsquo;s been a good year.&lt;/p&gt;
&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/thedersen?a=3yCWNy5oHLY:FAS-eRZC_xE:_tX2Dl0juqE"&gt;&lt;img src="http://feeds.feedburner.com/~ff/thedersen?i=3yCWNy5oHLY:FAS-eRZC_xE:_tX2Dl0juqE" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/thedersen/~4/3yCWNy5oHLY" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://thedersen.com/2010/12/19/best-of-2010/</feedburner:origLink></entry>
  <entry>
    <title>Setting up a Rails 3 app with RSpec, Cucumber, MongoDB and jQuery</title>
    <link href="http://feedproxy.google.com/~r/thedersen/~3/UHT_pwuUe-E/" rel="alternate" />
    <id>http://thedersen.com/2010/09/13/setting-up-a-rails-3-app-with-rspec-cucumber-mongodb-and-jquery/</id>
    <published>2010-09-13T00:00:00Z</published>
    <updated>2010-09-13T00:00:00Z</updated>
    <author>
      <name>Thomas Pedersen</name>
    </author>
    <summary type="html">&lt;p&gt;With &lt;a href="http://weblog.rubyonrails.org/2010/8/29/rails-3-0-it-s-done"&gt;Rails 3 released&lt;/a&gt;, it comes with a set of new switches that let you opt out various stuff when generating apps. This makes it a bit easier to use alternatives to the default Active Record, Test::Unit etc. than it was with previous versions of Rails. Some of the options are:&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;With &lt;a href="http://weblog.rubyonrails.org/2010/8/29/rails-3-0-it-s-done"&gt;Rails 3 released&lt;/a&gt;, it comes with a set of new switches that let you opt out various stuff when generating apps. This makes it a bit easier to use alternatives to the default Active Record, Test::Unit etc. than it was with previous versions of Rails. Some of the options are:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;-O, [--skip-activerecord]  # Skip Active Record files
-J, [--skip-prototype]     # Skip Prototype files
-T, [--skip-testunit]      # Skip Test::Unit files
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You can get a complete list of all the available options by running the command:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ rails new --help
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Creating the app&lt;/h2&gt;

&lt;pre&gt;&lt;code&gt;$ sudo gem install rails
$ rails new YourApp -OJT
$ cd YourApp
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The gem command will install the latest version of Rails 3. The rails command creates a new app named &amp;lsquo;YourApp&amp;rsquo; without Active Record (-O), Test::Unit (-T), and the Prototype javascript files (-J).&lt;/p&gt;

&lt;h2&gt;Configuring the app and the required gems&lt;/h2&gt;

&lt;p&gt;To get things working you first have to install all the required gems. Since Rails 3 introduces  &lt;a href="http://gembundler.com/"&gt;Bundler&lt;/a&gt;, the gem management is as simple as it can get.&lt;/p&gt;

&lt;p&gt;Open your Gemfile at the root of you application and specify the gems:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;:::ruby
source "http://rubygems.org"

gem "rails", "3.0.0"
gem "bson_ext"
gem "mongo_mapper"

group :test, :spec, :cucumber do
    gem "rspec"
    gem "rspec-rails", "&amp;gt;= 2.0.0.beta"
    gem "capybara"
    gem "cucumber"
    gem "database_cleaner"
    gem "cucumber-rails"
    gem "spork"
    gem "launchy"
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then, install all of them by simply running:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ bundle install
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Finally, you have to tell the generators that you are not using the default stuff. You do that by editing the  config/application.rb and add these lines:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;:::ruby
config.generators do |g|
    g.orm             :mongo_mapper
    g.template_engine :erb
    g.test_framework  :rspec
end
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Setting up the connection to MongoDB&lt;/h2&gt;

&lt;p&gt;Create a new file, config/initializers/mongo.rb with the following content:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;:::ruby
logger = Logger.new("log/mongodb-#{Rails.env}.log")
MongoMapper.connection = Mongo::Connection.new('127.0.0.1', 27017, :logger =&amp;gt; logger)
MongoMapper.database = "YourApp-#{Rails.env}"
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If you use different databases in the different environments (e.g. dev, production), go ahead and put some if-else logic in here.&lt;/p&gt;

&lt;h2&gt;Generating the Cucumber and RSpec stuff&lt;/h2&gt;

&lt;pre&gt;&lt;code&gt;$ rails g rspec:install    
$ rails g cucumber:install --capybara --rspec --skip-database
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;That&amp;rsquo;s it. You&amp;rsquo;ll now have a folder &lt;em&gt;features&lt;/em&gt; for your Cucumber features and a folder &lt;em&gt;spec&lt;/em&gt; for your RSpec specs.&lt;/p&gt;

&lt;h2&gt;Adding jQuery&lt;/h2&gt;

&lt;pre&gt;&lt;code&gt;$ curl http://code.jquery.com/jquery-1.4.2.min.js &amp;gt; public/javascripts/jquery-1.4.2.min.js
$ curl http://github.com/rails/jquery-ujs/raw/master/src/rails.js &amp;gt; public/javascripts/rails.js
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The first line downloads jQuery 1.4.2 and saves it to your public/javascripts/ folder. The second line downloads rails.js which is a wrapper around jQuery for Rails.&lt;/p&gt;

&lt;p&gt;Finally, specify that the javascripts should be loaded as part of the default scripts by opening the file config/application.rb and change&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;:::ruby
config.action_view.javascript_expansions[:defaults] = %w()
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;to&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;:::ruby
config.action_view.javascript_expansions[:defaults] = %w(jquery rails application)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And, you&amp;rsquo;re done!&lt;/p&gt;
&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/thedersen?a=UHT_pwuUe-E:bPo7Rba7P3w:_tX2Dl0juqE"&gt;&lt;img src="http://feeds.feedburner.com/~ff/thedersen?i=UHT_pwuUe-E:bPo7Rba7P3w:_tX2Dl0juqE" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/thedersen/~4/UHT_pwuUe-E" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://thedersen.com/2010/09/13/setting-up-a-rails-3-app-with-rspec-cucumber-mongodb-and-jquery/</feedburner:origLink></entry>
  <entry>
    <title>Shotgun</title>
    <link href="http://feedproxy.google.com/~r/thedersen/~3/3RkohYW1aDM/" rel="alternate" />
    <id>http://thedersen.com/2010/08/23/shotgun/</id>
    <published>2010-08-23T00:00:00Z</published>
    <updated>2010-08-23T00:00:00Z</updated>
    <author>
      <name>Thomas Pedersen</name>
    </author>
    <summary type="html">&lt;p&gt;In my &lt;a href="http://http://thedersen.com/2010/08/05/new-blog-in-five-minutes/"&gt;previous post&lt;/a&gt; I wrote about using the thin web server to run your Rack app locally. This works fine, but there is one issue. If you change your code or configuration you have to restart the server. This is not a big deal, but it do get quite annoying after a while. The solution is a gem called &lt;a href="http://github.com/rtomayko/shotgun"&gt;Shotgun&lt;/a&gt;&amp;hellip;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;In my &lt;a href="http://http://thedersen.com/2010/08/05/new-blog-in-five-minutes/"&gt;previous post&lt;/a&gt; I wrote about using the thin web server to run your Rack app locally. This works fine, but there is one issue. If you change your code or configuration you have to restart the server. This is not a big deal, but it do get quite annoying after a while. The solution is a gem called &lt;a href="http://github.com/rtomayko/shotgun"&gt;Shotgun&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;From the &lt;a href="http://github.com/rtomayko/shotgun/blob/master/README"&gt;readme&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;The shotgun command starts one of Rack&amp;rsquo;s supported servers (e.g., mongrel, thin,
webrick) and listens for requests but does not load any part of the actual
application. Each time a request is received, it forks, loads the application in
the child process, processes the request, and exits the child process. The
result is clean, application-wide reloading of all source files and templates on
each request.&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;As you can see, there in no longer a need to restart your server when code has changed, Shotgun does it for you. Nice.&lt;/p&gt;

&lt;p&gt;To get going you need to install the gem&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ sudo gem install shotgun
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;To start the web server, simply type&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ shotgun
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;if the current directory contains the config.ru file, or specify the config file like this&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ shotgun config.ru
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The output should be something like&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;== Shotgun/Mongrel on http://127.0.0.1:9393/
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;telling you which server got started and on what port it is listening.&lt;/p&gt;

&lt;p&gt;There are some more options available, which you can find by looking at the help&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ shotgun --help

Ruby options:
  -e, --eval LINE          evaluate a LINE of code
  -d, --debug              set debugging flags (set $DEBUG to true)
  -w, --warn               turn warnings on for your script
  -I, --include PATH       specify $LOAD_PATH (may be used more than once)
  -r, --require LIBRARY    require the library, before executing your script

Rack options:
  -s, --server SERVER      server (webrick, mongrel, thin, etc.)
  -o, --host HOST          listen on HOST (default: 127.0.0.1)
  -p, --port PORT          use PORT (default: 9393)
  -E, --env ENVIRONMENT    use ENVIRONMENT for defaults (default: development)

Shotgun options:
  -O, --browse             open browser immediately after starting
  -u, --url URL            specify url path (default: /)
  -P, --public PATH        serve static files under PATH
  -h, --help               show this message
      --version            show version
&lt;/code&gt;&lt;/pre&gt;
&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/thedersen?a=3RkohYW1aDM:NwMPYUD2CDk:_tX2Dl0juqE"&gt;&lt;img src="http://feeds.feedburner.com/~ff/thedersen?i=3RkohYW1aDM:NwMPYUD2CDk:_tX2Dl0juqE" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/thedersen/~4/3RkohYW1aDM" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://thedersen.com/2010/08/23/shotgun/</feedburner:origLink></entry>
  <entry>
    <title>New blog in five minutes</title>
    <link href="http://feedproxy.google.com/~r/thedersen/~3/ayDxmPyx0cw/" rel="alternate" />
    <id>http://thedersen.com/2010/08/05/new-blog-in-five-minutes/</id>
    <published>2010-08-05T00:00:00Z</published>
    <updated>2010-08-05T00:00:00Z</updated>
    <author>
      <name>Thomas Pedersen</name>
    </author>
    <summary type="html">&lt;p&gt;As part of learning Ruby I wanted to move my blog to the Ruby platform. I started out by creating one myself using &lt;a href="http://rubyonrails.org/"&gt;Ruby on Rails&lt;/a&gt;, but then I came across &lt;a href="http://cloudhead.io/toto"&gt;toto&lt;/a&gt;, &amp;ldquo;the tiniest blogging engine in Oz&amp;rdquo;, in a &lt;a href="http://cre8ivethought.com/blog/2010/08/04/blog-moved-once-again/"&gt;blog post by Mark Nijhof&lt;/a&gt;. It looked very promising, and I decided to give it a shot&amp;hellip;&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;As part of learning Ruby I wanted to move my blog to the Ruby platform. I started out by creating one myself using &lt;a href="http://rubyonrails.org/"&gt;Ruby on Rails&lt;/a&gt;, but then I came across &lt;a href="http://cloudhead.io/toto"&gt;toto&lt;/a&gt;, &amp;ldquo;the tiniest blogging engine in Oz&amp;rdquo;, in a &lt;a href="http://cre8ivethought.com/blog/2010/08/04/blog-moved-once-again/"&gt;blog post by Mark Nijhof&lt;/a&gt;. It looked very promising, and I decided to give it a shot.&lt;/p&gt;

&lt;p&gt;This walkthrough assumes that you have installed &lt;a href="http://www.ruby-lang.org/en/"&gt;Ruby&lt;/a&gt; and &lt;a href="http://git-scm.com/"&gt;Git&lt;/a&gt; and is somewhat familiar with using Git. Oh, and I am using a Mac, but I think it should work just as fine on Windows.&lt;/p&gt;

&lt;h2&gt;toto&lt;/h2&gt;

&lt;pre&gt;&lt;code&gt;$ sudo gem install toto
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;That&amp;rsquo;s it. You have now installed the blog engine, but before you can get started writing your articles you need a toto template.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ git clone git://github.com/cloudhead/dorothy.git myblog
$ cd myblog
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Dorothy is toto&amp;rsquo;s default template. It&amp;rsquo;s very minimalistic, but fully functional. If you want to customize it, all the files you need to change is located in the templates and public folders. It also comes with a &lt;a href="http://rack.rubyforge.org/"&gt;Rack&lt;/a&gt; configuration file, &lt;em&gt;config.ru&lt;/em&gt;, where you can configure your toto instance.&lt;/p&gt;

&lt;h2&gt;Writing in Markdown&lt;/h2&gt;

&lt;p&gt;toto uses no database or anything except .txt files for storing articles with metadata. The articles are written in &lt;a href="http://daringfireball.net/projects/markdown/"&gt;Markdown&lt;/a&gt; and the metadata is stored in &lt;a href="http://www.yaml.org/"&gt;yaml&lt;/a&gt; at the very beginning of the file. Markdown is a plain text formatting syntax that gets converted to html. Its goal is to make it as readable as possible and I think they&amp;rsquo;ve succeeded. All you need is a simple text editor to get going.&lt;/p&gt;

&lt;p&gt;To create a new article I recommend using the rake task for it.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ rake new
Title: 
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You enter the title, hit enter, and the .txt file is created with necessary metadata and saved to the articles folder.&lt;/p&gt;

&lt;p&gt;Open the file and start writing your article. When you are done writing, you need to commit the article to the git repository.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ git add -A
$ git commit -m"Added new article"
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Hosting it&lt;/h2&gt;

&lt;p&gt;The best (in my opinion) hosting option for Ruby is &lt;a href="http://heroku.com/"&gt;Heroku&lt;/a&gt;. It&amp;rsquo;s very easy to set up and it uses a pure git workflow for publishing your blog or site. For a small blog like mine, it is also completely free. No cost what so ever.&lt;/p&gt;

&lt;p&gt;To publish your blog go to &lt;a href="http://heroku.com/"&gt;Heroku&lt;/a&gt; and sign up for an account. Then install Heroku on your machine.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ sudo gem install heroku
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;After that is done, you need to make your blog a Heroku application.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ heroku create myblog
Created http://myblog.heroku.com
git@heroku.com:myblog.git
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Finally, you publish it. There are two ways of doing so. You can either use the rake task that comes with Dorothy or you can use the git push command. Essentially, they both do the same thing.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ rake publish
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;or&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ git push heroku master
-----&amp;gt; Heroku receiving push
-----&amp;gt; Rack app detected
-----&amp;gt; Launching......... done
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Your blog is now online! If you want to use your own domain it is also possible and very easy to set up with Heroku.&lt;/p&gt;

&lt;h2&gt;Disqus it&lt;/h2&gt;

&lt;p&gt;As part of the minimalistic approach of toto, it does not come with any custom built commentary module. For comments it uses the &lt;a href="http://disqus.com/"&gt;Disqus service&lt;/a&gt;. If you would like to enable comments, you go to &lt;a href="http://disqus.com/"&gt;http://disqus.com/&lt;/a&gt;, register for an account, and then you open the toto configuration file, config.ru, and changes&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#set :disqus, false          # disqus id, or false
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;to&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;set :disqus, "YourDisqusId"  # disqus id, or false
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;People can now comment on your articles.&lt;/p&gt;

&lt;h2&gt;Running it locally&lt;/h2&gt;

&lt;p&gt;Sometimes it can be very useful to run the blog on local machine. Especially when tweaking layout and css there can be a lot of changes. I choose to run it on the &lt;a href="http://code.macournoyer.com/thin/"&gt;thin web server&lt;/a&gt;.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ sudo gem install thin
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;To start the web server type:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ thin start -R config.ru
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;When I started it the first time I got an error&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;/Library/Ruby/Gems/1.8/gems/rack-1.2.1/lib/rack/utils.rb:138:in `union': can't convert Array into String (TypeError)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;After some Googling I found that the error was most likely caused by Rack 1.2.1. When downgrading to Rack 1.1.0 it worked, although I don&amp;rsquo;t know why (yet).&lt;/p&gt;

&lt;p&gt;When thin is running, go to http://localhost:3000 and browse your blog.&lt;/p&gt;

&lt;h2&gt;Summary&lt;/h2&gt;

&lt;p&gt;It took me longer to write this article than to get the blog up and running. That, I think, says a lot. I really like the minimalistic approach of toto and the frictionless publishing to Heroku. I also actually like writing in markdown.&lt;/p&gt;

&lt;p&gt;If you are considering creating a blog, or maybe moving your existing, I would definitively recommend the toto and Heroku combo. After all, it will only cost you five minutes.&lt;/p&gt;
&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/thedersen?a=ayDxmPyx0cw:LkUYhQnwKQU:_tX2Dl0juqE"&gt;&lt;img src="http://feeds.feedburner.com/~ff/thedersen?i=ayDxmPyx0cw:LkUYhQnwKQU:_tX2Dl0juqE" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/thedersen/~4/ayDxmPyx0cw" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://thedersen.com/2010/08/05/new-blog-in-five-minutes/</feedburner:origLink></entry>
  <entry>
    <title>Show hidden files in Finder</title>
    <link href="http://feedproxy.google.com/~r/thedersen/~3/RugWNofZp_8/" rel="alternate" />
    <id>http://thedersen.com/2010/08/04/show-hidden-files-in-finder/</id>
    <published>2010-08-04T00:00:00Z</published>
    <updated>2010-08-04T00:00:00Z</updated>
    <author>
      <name>Thomas Pedersen</name>
    </author>
    <summary type="html">&lt;p&gt;By convention all files starting with a dot (.) is hidden in Mac OS X. To view these files open terminal and type the following:&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;By convention all files starting with a dot (.) is hidden in Mac OS X. To view these files open terminal and type the following:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ defaults write com.apple.finder AppleShowAllFiles TRUE
$ killall Finder
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This will show you all of the hidden files and folders on your operating system. If you want to reverse the command replace TRUE with FALSE.&lt;/p&gt;

&lt;p&gt;That&amp;rsquo;s all.&lt;/p&gt;
&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/thedersen?a=RugWNofZp_8:Yw8ti_AcRHM:_tX2Dl0juqE"&gt;&lt;img src="http://feeds.feedburner.com/~ff/thedersen?i=RugWNofZp_8:Yw8ti_AcRHM:_tX2Dl0juqE" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/thedersen/~4/RugWNofZp_8" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://thedersen.com/2010/08/04/show-hidden-files-in-finder/</feedburner:origLink></entry>
</feed>

