<?xml version="1.0"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
    <title>brendan forster</title>
    <link>http://brendanforster.com/</link>
    <atom:link href="http://brendanforster.com/rss.xml" rel="self" type="application/rss+xml" />
    <description></description>
    <language>en-au</language>
    <pubDate>Mon, 20 May 2013 12:27:05 +0000</pubDate>
    <lastBuildDate>Mon, 20 May 2013 12:27:05 +0000</lastBuildDate>

    
    <item>
      <title>Should I make this object a singleton?</title>
      <link>http://brendanforster.com//blog/should-i-make-this-object-a-singleton.html</link>
      <pubDate>Mon, 20 May 2013 00:30:00 +0000</pubDate>
      <author>shift.key@gmail.com (Brendan Forster)</author>
      <guid>http://brendanforster.com/blog/should-i-make-this-object-a-singleton.html</guid>
      <description>&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: This is just a first pass on the post, as I need to touch on various tools I&#39;ve used in the past to identify these constraints. But let&#39;s start with the concepts.&lt;/p&gt;

&lt;p&gt;Someone asked me a question yesterday along the lines of, well, this:&lt;/p&gt;

&lt;blockquote class=&quot;twitter-tweet&quot; data-conversation=&quot;none&quot;&gt;&lt;p&gt;@&lt;a href=&quot;https://twitter.com/nickhodgemsft&quot;&gt;nickhodgemsft&lt;/a&gt; Roger, cheers @&lt;a href=&quot;https://twitter.com/shiftkey&quot;&gt;shiftkey&lt;/a&gt; thoughts? Will it be better to create a life long Crypto obj rather than this &lt;a href=&quot;http://t.co/bn3hRIiGdt&quot; title=&quot;http://twitter.com/HDizzle84/status/336104817707589633/photo/1&quot;&gt;twitter.com/HDizzle84/stat…&lt;/a&gt;&lt;/p&gt;&amp;mdash; HDizzle (@HDizzle84) &lt;a href=&quot;https://twitter.com/HDizzle84/status/336104817707589633&quot;&gt;May 19, 2013&lt;/a&gt;&lt;/blockquote&gt;


&lt;script async src=&quot;//platform.twitter.com/widgets.js&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;


&lt;p&gt;Singletons? My first instinct was to reach for the hose and dampen such discussion down immediately before someone got hurt.&lt;/p&gt;

&lt;p&gt;But no, that&#39;s not right. I need to explain myself.&lt;/p&gt;

&lt;p&gt;So I wanted to put together a simple guide on how to determine &lt;em&gt;when&lt;/em&gt; the &lt;a href=&quot;http://en.wikipedia.org/wiki/Singleton_pattern&quot;&gt;Singleton pattern&lt;/a&gt; is a suitable use case - yes, it gets a bad reputation due to misuse, but there are some scenarios where it does add value (and is often necessary).&lt;/p&gt;

&lt;h2&gt;How expensive is it to create?&lt;/h2&gt;

&lt;p&gt;Imagine you have a database connection - say &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.aspx&quot;&gt;SqlConnection&lt;/a&gt; - and you create an instance of it to connect to a database?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TODO:&lt;/strong&gt; show windbg object dump of a SqlConnection object&lt;/p&gt;

&lt;p&gt;Inside this SqlConnection object you should see a bunch of underlying resources - these are the components which make the magic happen when you perform a &quot;SELECT * FROM Table&quot; in your application.&lt;/p&gt;

&lt;p&gt;Many of the objects you create in your application are probably simpler than this - classes to hold data, for example - but once you start interacting with the underlying platform and identify various bottlenecks in your applications understanding what resources are hiding where is invaluable knowledge.&lt;/p&gt;

&lt;p&gt;The other thing to keep in mind with objects is what they encapsulate. If your classes interacts with the network, storage or attached devices, for example, you are likely to face specific rules with how you use access these resources.&lt;/p&gt;

&lt;p&gt;An example: if you&#39;re ever making concurrent web requests to a specific domain, .NET will actually throttle you to two concurrent requests. You can change this if you &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/fb6y0fyc.aspx&quot;&gt;know where to look&lt;/a&gt; but the defaults are designed to be &quot;good enough&quot; for most scenarios.&lt;/p&gt;

&lt;p&gt;Another example: &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/8xx3tyca.aspx&quot;&gt;database connection pools&lt;/a&gt; - a finite number of connections which are managed and reused over the lifetime of an application - instead of arbitrarily creating, using, and then destroying connections each time we need them.&lt;/p&gt;

&lt;h2&gt;What about my memory footprint?&lt;/h2&gt;

&lt;p&gt;So assuming the above constraint isn&#39;t affecting your classes, you might be able to get away with creating objects whenever necessary.&lt;/p&gt;

&lt;p&gt;But what if you&#39;re making a mobile app? Memory becomes a significant constraint on any mobile applications - and the more moving parts you have in a mobile application, the more you need to optimise to reduce the impact of those moving parts.&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;I don&#39;t need to worry about that, my stack has generational garbage collection (GC).&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;But that&#39;s not actually a solution - more like a crutch. GC isn&#39;t a free lunch - it&#39;s overhead that you&#39;re now invoking periodically (technically GC will run whenever it needs to, which is often at the worst possible time due to memory pressure) because you were lazy with how you structured your application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TODO:&lt;/strong&gt; demonstrate .NET performance counters around GC, with a sample that does stupid things&lt;/p&gt;

&lt;h2&gt;What about multi-threaded code?&lt;/h2&gt;

&lt;p&gt;This is the hardest part to discuss, because multi-threaded code is hard. Really hard.&lt;/p&gt;

&lt;p&gt;If your object is &lt;a href=&quot;http://en.wikipedia.org/wiki/Immutable_object&quot;&gt;immutable&lt;/a&gt; (that is, you can call the same function on an object &lt;strong&gt;as many times as possible until the end of time&lt;/strong&gt; and you&#39;ll always get the same result) then it might be possible for it to be used as a singleton object.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TODO:&lt;/strong&gt; discuss the simplest gotcha - two threads entering a function at the same time&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TODO:&lt;/strong&gt; discuss where basic locking will cause you different sorts of headaches&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TODO:&lt;/strong&gt; what would Ayende do?&lt;/p&gt;

&lt;h2&gt;But I just want to use it as a global object&lt;/h2&gt;

&lt;p&gt;Please don&#39;t. This introduces unnecessary coupling into your application, at the value of saving a few keystrokes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TODO:&lt;/strong&gt; explain the god object pattern and why it is bad&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TODO:&lt;/strong&gt; outline where this is utterly unavoidable and you need to suck it up and just God Object that sucker&lt;/p&gt;

&lt;h2&gt;What&#39;s the damn answer, Brendan?&lt;/h2&gt;

&lt;p&gt;Ok, so if you&#39;ve read this far - I thank you.&lt;/p&gt;

&lt;p&gt;So when should you consider wrapping an object in the singleton pattern?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Firstly, beware of how multi-threading &lt;em&gt;actually&lt;/em&gt; works - no, the TPL is cheating.&lt;/li&gt;
&lt;li&gt;If it&#39;s expensive to create, consider it.&lt;/li&gt;
&lt;li&gt;If it&#39;s touching underlying system resources, consider it.&lt;/li&gt;
&lt;li&gt;If you need to optimise for memory usage, consider it.&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;Feedback is Welcome&lt;/h2&gt;

&lt;p&gt;Did I miss something? Get something wrong?&lt;/p&gt;

&lt;p&gt;Leave a comment and let me know.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Yet Another "Add LESS to your ASP.NET MVC Project" Post</title>
      <link>http://brendanforster.com//blog/yet-another-implement-less-in-aspnetmvc-post.html</link>
      <pubDate>Sun, 12 May 2013 13:00:00 +0000</pubDate>
      <author>shift.key@gmail.com (Brendan Forster)</author>
      <guid>http://brendanforster.com/blog/yet-another-implement-less-in-aspnetmvc-post.html</guid>
      <description>&lt;h2&gt;You&#39;ve probably done this too&lt;/h2&gt;

&lt;p&gt;If you kicked off a new ASP.NET webapp recently, somewhere after &lt;code&gt;File -&amp;gt; New Project&lt;/code&gt; you probably got excited about using a CSS preprocessor like LESS or SASS because:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;nobody writes CSS directly anymore&lt;/li&gt;
&lt;li&gt;it&#39;s supposed to make your life easier&lt;/li&gt;
&lt;li&gt;something with unicorns and rainbows&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;This post isn&#39;t about that. This is about the little quirks I had to jump through to get a usable development environment for writing LESS code.&lt;/p&gt;

&lt;p&gt;NOTE: This uses the bundling features in MVC4. If you&#39;re using a version of MVC which is older than that, go upgrade. Bundling is &lt;strong&gt;so nice&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;Step 1 - The Installer-ation&lt;/h2&gt;

&lt;p&gt;To NuGet!&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;PM&amp;gt; Install-Package dotLess
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Go run that in a new project. I&#39;ll wait.&lt;/p&gt;

&lt;p&gt;Done? Great, so go write a little LESS code (I&#39;ve just called this file &lt;code&gt;sample.less&lt;/code&gt; for the purposes of this demo):&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;css&quot;&gt;&lt;span class=&quot;k&quot;&gt;@color&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;#4D926F&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;nc&quot;&gt;.site-title&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;h3&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;And then include it in your Razor layout...&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;xml&quot;&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;html&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;lang=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;en&amp;quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;charset=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;title&amp;gt;&lt;/span&gt;@ViewBag.Title - My ASP.NET MVC Application&lt;span class=&quot;nt&quot;&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;link&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;href=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;~/favicon.ico&amp;quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;rel=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;shortcut icon&amp;quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;image/x-icon&amp;quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;viewport&amp;quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;content=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;width=device-width&amp;quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
        @Styles.Render(&amp;quot;~/Content/less&amp;quot;)
        @Scripts.Render(&amp;quot;~/bundles/modernizr&amp;quot;)
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;&amp;lt;!--  and more stuff here obvs --&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;But you&#39;re application doesn&#39;t know about &lt;em&gt;how&lt;/em&gt; it can transform LESS code into CSS. That&#39;s where bundles come in.&lt;/p&gt;

&lt;h2&gt;Step 2 - Dude, where&#39;s my bundle?&lt;/h2&gt;

&lt;p&gt;Bundles are an easy way to merge and minify resources in your application (such as JavaScript files and CSS stylesheets). In addition to being a lovely convenience, it&#39;s actually a great way to improve site performance (fewer HTTP requests, reducing size of response payload).&lt;/p&gt;

&lt;p&gt;So go back to NuGet and use this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;PM&amp;gt; Install-Package System.Web.Optimization.Less
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And add your bundle to the appropriate location within &lt;code&gt;BundleConfig.cs&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;csharp&quot;&gt;&lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;BundleConfig&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;RegisterBundles&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;BundleCollection&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bundles&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// NOTE: existing bundles are here &lt;/span&gt;

        &lt;span class=&quot;c1&quot;&gt;// add this line&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;bundles&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Add&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;LessBundle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;~/Content/less&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Include&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;~/Content/*.less&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Bundles support a limited subset of wildcard syntax, but you can include multiple folders within a bundle.&lt;/p&gt;

&lt;p&gt;So this &lt;code&gt;LessBundle&lt;/code&gt; gives you the ability to combine and minify files when running the application in &lt;code&gt;&amp;lt;compilation debug=&quot;false&quot; /&amp;gt;&lt;/code&gt; mode, and it takes care of transforming LESS code into CSS - without needing to update the layout everytime you add a new file to the project.&lt;/p&gt;

&lt;p&gt;Editor&#39;s note: I wasn&#39;t aware of this package on the last runthrough - instead I found this &lt;code&gt;LessBundle&lt;/code&gt; code in a &lt;a href=&quot;https://gist.github.com/benfoster/3924025&quot;&gt;gist&lt;/a&gt; from &lt;a href=&quot;http://ben.onfabrik.com/&quot;&gt;@benfosterdev&lt;/a&gt; which looks very similar to the source for that package, so I&#39;ll give him kudos for it.&lt;/p&gt;

&lt;h2&gt;Step 3 - But wait, there&#39;s more!&lt;/h2&gt;

&lt;p&gt;But what about when testing locally? Well, bundles are rather lazy in development mode:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;no minification&lt;/li&gt;
&lt;li&gt;no bundling&lt;/li&gt;
&lt;li&gt;in fact the files just appear as LESS resources to the browser&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;So you &lt;em&gt;still&lt;/em&gt; need to tell your application how it can serve LESS files to the browser, independent all this bundling work.&lt;/p&gt;

&lt;p&gt;dotLess will apply transforms to your web.config when you install it through NuGet to provide handlers which can process a specific LESS file:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;xml&quot;&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;configuration&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;configSections&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;section&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;dotless&amp;quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;dotless.Core.configuration.DotlessConfigurationSectionHandler, dotless.Core&amp;quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/configSections&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;c&quot;&gt;&amp;lt;!-- these probably do something useful --&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;dotless&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;minifyCss=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;false&amp;quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;cache=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;true&amp;quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;web=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;false&amp;quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;system.webServer&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;handlers&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;c&quot;&gt;&amp;lt;!-- for IIS7+ --&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;add&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;dotless&amp;quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;path=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;*.less&amp;quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;verb=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;GET&amp;quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;dotless.Core.LessCssHttpHandler,dotless.Core&amp;quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;resourceType=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;File&amp;quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;preCondition=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/handlers&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/system.webServer&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;system.web&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;httpHandlers&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;c&quot;&gt;&amp;lt;!-- for IIS6 --&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;add&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;path=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;*.less&amp;quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;verb=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;GET&amp;quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;dotless.Core.LessCssHttpHandler, dotless.Core&amp;quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/httpHandlers&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/system.web&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/configuration&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Editor&#39;s Note: when I last ran through these steps I didn&#39;t get these config transforms applied on install. I was really looking forward to a rant here because I&#39;d gone through the hard yards to add these handlers by hand - but of course it worked this time.&lt;/p&gt;

&lt;p&gt;So these handlers allow you to compile an individual LESS file and see the results in the browser.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/img/posts/less/dev-experience.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Oh, and don&#39;t forget to remove the handlers in your config transforms when you go to production (this is an example of the &lt;code&gt;Web.Release.config&lt;/code&gt; transforms file).&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;xml&quot;&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot;?&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;configuration&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;xmlns:xdt=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;http://schemas.microsoft.com/XML-Document-Transform&amp;quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;system.web&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;compilation&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;xdt:Transform=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;RemoveAttributes(debug)&amp;quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;httpHandlers&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;add&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;xdt:Transform=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;Remove&amp;quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;xdt:Locator=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;Match(type)&amp;quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;path=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;*.less&amp;quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;verb=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;GET&amp;quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;dotless.Core.LessCssHttpHandler, dotless.Core&amp;quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/httpHandlers&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/system.web&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;system.webServer&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;handlers&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;add&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;xdt:Transform=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;Remove&amp;quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;xdt:Locator=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;Match(name)&amp;quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;dotless&amp;quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;path=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;*.less&amp;quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;verb=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;GET&amp;quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;dotless.Core.LessCssHttpHandler,dotless.Core&amp;quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;resourceType=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;File&amp;quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;preCondition=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/handlers&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/system.webServer&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/configuration&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

</description>
    </item>
    
    <item>
      <title>Custom server headers - bad for your health?</title>
      <link>http://brendanforster.com//blog/custom-server-headers-bad-for-your-health.html</link>
      <pubDate>Sat, 04 May 2013 06:00:00 +0000</pubDate>
      <author>shift.key@gmail.com (Brendan Forster)</author>
      <guid>http://brendanforster.com/blog/custom-server-headers-bad-for-your-health.html</guid>
      <description>&lt;p&gt;I just finished another project with a customer which involved a pentest (penetration testing) review for their upcoming launch. And as usual, this involves hiding a bunch of headers that IIS and ASP.NET serve up on each response.&lt;/p&gt;

&lt;p&gt;In particuar:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Server (from IIS)&lt;/li&gt;
&lt;li&gt;X-Powered-By (from IIS)&lt;/li&gt;
&lt;li&gt;X-AspNet-Version (from ASP.NET)&lt;/li&gt;
&lt;li&gt;X-AspNetMvc-Version (from ASP.NET MVC)&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Why? Because sending these headers in your response exposes information about your server to clients (including the bad guys). &lt;a href=&quot;http://www.troyhunt.com/2012/02/shhh-dont-let-your-response-headers.html&quot;&gt;Troy Hunt&lt;/a&gt; explains it in more detail but our approaches differ slightly:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I&#39;ve just focused on the ASP.NET stack&lt;/li&gt;
&lt;li&gt;this approach doesn&#39;t require any changes to IIS&lt;/li&gt;
&lt;li&gt;I don&#39;t care about IIS 6 (it shipped with Windows Server 2003, so that&#39;ll be 10 years soon!)&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;NuGet all the pain away&lt;/h2&gt;

&lt;p&gt;So I was going to write a NuGet package to solve this problem but I was then pointed to this package from David Duffett - &lt;a href=&quot;https://github.com/davidduffett/Dinheiro/tree/master/Dinheiro.RemoveUnnecessaryHeaders&quot;&gt;Dinheiro.RemoveUnnecessaryHeaders&lt;/a&gt;. Thanks for saving me the time, David!&lt;/p&gt;

&lt;p&gt;So go grab it from NuGet:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;PM&amp;gt; Install-Package Dinheiro.RemoveUnnecessaryHeaders
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You can do this by hand if you want - in fact, I&#39;ll explain the package behaviour here.&lt;/p&gt;

&lt;p&gt;First, it applies a config transform to remove the &lt;code&gt;X-Powered-By&lt;/code&gt; and &lt;code&gt;X-AspNet-Version&lt;/code&gt; headers:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;xml&quot;&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;configuration&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;system.web&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;httpRuntime&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;enableVersionHeader=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;false&amp;quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/system.web&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;system.webServer&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;httpProtocol&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;customHeaders&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;remove&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;X-Powered-By&amp;quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;/customHeaders&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/httpProtocol&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/system.webServer&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/configuration&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Next, we use &lt;code&gt;WebActivator&lt;/code&gt; to hook into the &lt;code&gt;PreApplicationStart&lt;/code&gt; event to run some custom behaviour:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;csharp&quot;&gt;&lt;span class=&quot;na&quot;&gt;[assembly: WebActivator.PreApplicationStartMethod(typeof(MyWebApplication.App_Start.RemoveUnnecessaryHeaders), &amp;quot;Start&amp;quot;)]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;This method takes care of two things. The first is disabling the &lt;code&gt;X-AspNetMvc-Version&lt;/code&gt; header, and then registering a module to remove the &lt;code&gt;Server&lt;/code&gt; header.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;csharp&quot;&gt;&lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;RemoveUnnecessaryHeaders&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;Start&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;DynamicModuleUtility&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RegisterModule&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;typeof&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RemoveUnnecessaryHeadersModule&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;MvcHandler&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DisableMvcResponseHeader&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;And there&#39;s an important note about this code - it&#39;s only supported for IIS7+. Just a heads up.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;csharp&quot;&gt;&lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;RemoveUnnecessaryHeadersModule&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IHttpModule&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;Init&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;HttpApplication&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// This only works if running in IIS7+ Integrated Pipeline mode&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(!&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;HttpRuntime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;UsingIntegratedPipeline&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

        &lt;span class=&quot;n&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;PreSendRequestHeaders&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sender&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;kt&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;app&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sender&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;HttpApplication&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;app&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;null&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Context&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Headers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Remove&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;Server&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;Dispose&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;That &lt;code&gt;PreSendRequestHeaders&lt;/code&gt; event is the last opportunity ASP.NET gets to intercept the response (including reading headers set by IIS) before it gets sent to the client.&lt;/p&gt;

&lt;h2&gt;Defaults are good - except when they&#39;re not&lt;/h2&gt;

&lt;p&gt;Just about all of the teams I&#39;ve worked with have had this requirement as part of their go-live checklist (or raised by a security review) which made me think...&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Why aren&#39;t these headers disabled by default?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;And why does it require changes in so many different places in IIS and ASP.NET?&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;A footnote on X- Headers&lt;/h2&gt;

&lt;p&gt;If this is the first you are reading about this issue, HTTP headers which are prefixed by X- are custom headers which are not part of the HTTP spec. It allows servers, frameworks and applications to include custom metadata in HTTP requests and responses.&lt;/p&gt;

&lt;p&gt;My favourite example of this is Twitter&#39;s Rate Limiting API, which sends custom headers with each API call that an application makes:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;X-RateLimit-Limit: 350
X-RateLimit-Remaining: 350
X-RateLimit-Reset: 1277485629
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;As a consumer of Twitter&#39;s API, my application would need to look for these headers and understand the values.&lt;/p&gt;

&lt;p&gt;Recently &lt;a href=&quot;http://cprieto.com&quot;&gt;Cristian&lt;/a&gt; pointed me at &lt;a href=&quot;http://tools.ietf.org/html/rfc6648&quot;&gt;RFC 6648&lt;/a&gt; which, as it clearly states, is about:&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;&quot;Deprecating the &quot;X-&quot; Prefix and Similar Constructs in Application Protocols&quot;&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;It&#39;s very RFC-y in it&#39;s wording - and it&#39;s also only a year old which is really young in RFC time - but it&#39;s definitely something to keep in mind when designing custom headers for your application to serve or handle in the future.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Internet Sabbatical - An Experiment</title>
      <link>http://brendanforster.com//blog/experiment-internet-sabbatical.html</link>
      <pubDate>Mon, 26 Nov 2012 12:00:00 +0000</pubDate>
      <author>shift.key@gmail.com (Brendan Forster)</author>
      <guid>http://brendanforster.com/blog/experiment-internet-sabbatical.html</guid>
      <description>&lt;p&gt;As this year comes to a close (a few more things to do yet) I wanted to try something different over the holiday season - an internet sabbatical.&lt;/p&gt;

&lt;h3&gt;A What?&lt;/h3&gt;

&lt;p&gt;From 21 December (when I jump on a plane for the holidays) to 6 January (when I jump on a plane to come back for work) I plan to &quot;go to ground&quot; and avoid the internet.&lt;/p&gt;

&lt;h3&gt;Why?&lt;/h3&gt;

&lt;p&gt;I am burned out - plain and simple.&lt;/p&gt;

&lt;p&gt;I would love to just &quot;power on through&quot; like it wasn&#39;t a problem but I&#39;ve been doing that for the past few weeks already and its not changing much.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/img/posts/internet/swanson.gif&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Plus I intend to spend a bunch of time here:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/img/posts/internet/beach.jpg&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Doing stuff like this:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/img/posts/internet/hammock.jpg&quot; /&gt;&lt;/p&gt;

&lt;p&gt;And it has terrible phone reception anyway (yay!)&lt;/p&gt;

&lt;h3&gt;The Ground Rules&lt;/h3&gt;

&lt;p&gt;Here&#39;s the low-down:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No Internet Access&lt;/li&gt;
&lt;li&gt;No Twitter/Facebook&lt;/li&gt;
&lt;li&gt;No checking emails&lt;/li&gt;
&lt;li&gt;No computers or things that will let me code&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;But I won&#39;t go completely off the reservation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Phone - to keep in contact with friends and family, but that&#39;s it&lt;/li&gt;
&lt;li&gt;Xbox - I&#39;m keen to play some Assassin&#39;s Creed III (or other games) so that&#39;s included&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;And given I won&#39;t have technology to report on my progress (pen and paper perhaps?), you&#39;ll just have to wait and see how I go.&lt;/p&gt;

&lt;h3&gt;Happy Holidays&lt;/h3&gt;

&lt;p&gt;If you need to get in touch with me over the holidays, there are &quot;old-school&quot; methods (see above) but otherwise I wish you all a happy and safe holiday season and we&#39;ll see you all in 2013!&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>What's my secret? An unoffical unconfirmed guide</title>
      <link>http://brendanforster.com//blog/unofficial-unconfirmed-awesome-guide.html</link>
      <pubDate>Sun, 23 Sep 2012 12:30:00 +0000</pubDate>
      <author>shift.key@gmail.com (Brendan Forster)</author>
      <guid>http://brendanforster.com/blog/unofficial-unconfirmed-awesome-guide.html</guid>
      <description>&lt;h2&gt;Introduction&lt;/h2&gt;

&lt;p&gt;After surviving &lt;a href=&quot;http://australia.msteched.com/&quot;&gt;TechEd Australia&lt;/a&gt; - as well as hitting some important deadlines for a client - I was looking forward to getting back into various side-projects again now that things are coming back to (realtively) normal.&lt;/p&gt;

&lt;p&gt;I fired off an email looking for tips from my colleagues what they do to help get creative, and one of the replies I got back was this:&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;I find the third question silly coming from you. You are one of the the most productive and creative people I know and I wish I knew your secret to it. &lt;br/&gt; &lt;br/&gt;Sorry mate; but you don&#39;t get to be an MVP, a main member on Code52, talk at conferences and so on and then ask others how they are productive and creative :p&lt;br/&gt; &lt;br/&gt;Share your secret already ;-)&lt;/p&gt;&lt;/blockquote&gt;


&lt;p&gt;So I owe someone a blog post to explain myself.&lt;/p&gt;

&lt;h2&gt;Brendan&#39;s Unofficial Unconfirmed Guide To Being Awesome&lt;/h2&gt;

&lt;p&gt;First up, some warnings:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This is me speaking from my experiences only.&lt;/li&gt;
&lt;li&gt;I will often suggest things which I do not do. Yes, that makes me appear hypocritical. No, it is not intended.&lt;/li&gt;
&lt;li&gt;Please consult with a medical professional before taking any of the below advice.&lt;/li&gt;
&lt;li&gt;This is all subject to change.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Without further ado, let&#39;s dive in...&lt;/p&gt;

&lt;h3&gt;Make time for it&lt;/h3&gt;

&lt;p&gt;While I appreciate that there are many developers who are happy &lt;a href=&quot;http://www.hanselman.com/blog/DarkMatterDevelopersTheUnseen99.aspx&quot;&gt;&quot;dark matter&quot; developers&lt;/a&gt;, I&#39;ve always seen a correlation between awesome developers and developers who will spend time improving themselves outside of work hours.&lt;/p&gt;

&lt;p&gt;Don&#39;t feel bad if you&#39;re not someone who obsesses over code outside of work. But don&#39;t feel that it&#39;s out of reach.&lt;/p&gt;

&lt;p&gt;Not sure where to start? Start small. Set aside a half hour once a week.&lt;/p&gt;

&lt;p&gt;Can&#39;t find time in the evenings? Why not try and &lt;a href=&quot;http://99u.com/tips/6954/The-1-Step-Plan-for-Super-Productivity&quot;&gt;get up earlier&lt;/a&gt; instead?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; As many people who know me will testify, I am not a morning person.  I&#39;ll generally find a couple of evenings each week to hack on various things late into the night - it&#39;s an old habit I still haven&#39;t shaken from my university days - as that&#39;s when things are quieter and I can focus better on things. Your milage will vary.&lt;/p&gt;

&lt;h3&gt;Set yourself goals (even small ones)&lt;/h3&gt;

&lt;p&gt;To ensure you&#39;re making the best of youur spare time, set some goals up front to ensure you work towards something tangible and useful. Starting small with your goals will help.&lt;/p&gt;

&lt;p&gt;To illustrate this, here&#39;s a few goals which I would like to work on over the coming weeks/months:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;learn about Neo4J and graph database concepts by building a proof-of-concept accounting webapp&lt;/li&gt;
&lt;li&gt;learn about DirectX and de-rust on my C++ skills by building a Windows 8 app&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;See how they can be considered daunting goals?&lt;/p&gt;

&lt;p&gt;Let&#39;s break that first item down a bit:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Read up on concepts behind graph databases&lt;/li&gt;
&lt;li&gt;Getting Neo4J setup on my local machine&lt;/li&gt;
&lt;li&gt;Experimenting with working with Neo4J and the REST API&lt;/li&gt;
&lt;li&gt;Getting a simple webapp setup to interact with Neo4J (Ruby/Python?)&lt;/li&gt;
&lt;li&gt;Sketching out the app idea&lt;/li&gt;
&lt;li&gt;Build out a small piece to demonstrate the app&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;You get the picture - take a big piece of work and break it down into manageable chunks.&lt;/p&gt;

&lt;p&gt;By tackling something in chunks you also get a number of other benefits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;be able to demonstrate learning earlier on (e.g. interacting with an API first before building the app)&lt;/li&gt;
&lt;li&gt;get feedback without investing significant amounts of time (and put it aside if its not fun)&lt;/li&gt;
&lt;li&gt;be able to work on multiple goals at the same thing (rather than procrastinating because you&#39;re stumped on something)&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Of course it looks like Dave Tchepak beat me to the punch on this with a &lt;a href=&quot;http://davesquared.net/2012/02/goals-for-devs.html&quot;&gt;more detailed post&lt;/a&gt; earlier in the year, so I&#39;ll defer to him on this.&lt;/p&gt;

&lt;h3&gt;Don&#39;t just read and watch&lt;/h3&gt;

&lt;p&gt;It&#39;s easy to sit down and read some blogs on a topic and think to yourself &quot;Well that was easy!&quot; It&#39;s easy to watch some screencasts on a subject and think &quot;I know X now, great!&quot;&lt;/p&gt;

&lt;p&gt;I want to challenge you to go beyond the passive learning and build something based on what you&#39;ve learned. The size of it doesn&#39;t really matter, but I&#39;ve always found it important to take the things I&#39;ve learned and apply them to the real world.&lt;/p&gt;

&lt;p&gt;This helps in several ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;demonstrating that I was paying attention&lt;/li&gt;
&lt;li&gt;leaving the hand-holding of the blog posts/screencasts and work without that safety net&lt;/li&gt;
&lt;li&gt;reinforcing the learning while it is fresh in my mind&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;I love blog posts and screencasts, but these days I try and balancing consuming posts/screencasts and creating things.&lt;/p&gt;

&lt;h3&gt;Don&#39;t be afraid to fail&lt;/h3&gt;

&lt;p&gt;It can be daunting when faced with something completely new and unfamiliar. With the amazing pace that technology and software moves at these days, it&#39;s impossible to keep up with everything. And that&#39;s OK.&lt;/p&gt;

&lt;p&gt;Focus on what you could use at work.&lt;/p&gt;

&lt;p&gt;Focus on what you&#39;re interested in.&lt;/p&gt;

&lt;p&gt;Focus on what might make you a better developer.&lt;/p&gt;

&lt;p&gt;Dive in, try something, don&#39;t be afraid to make a mistake. Because you will. And that&#39;s OK.&lt;/p&gt;

&lt;p&gt;Just make sure you learn from your mistakes, or that you make different mistakes.&lt;/p&gt;

&lt;p&gt;Here&#39;s a couple of little experiments I&#39;ve worked on in the past that haven&#39;t come to fruition (yet?):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;bringing WebRat syntax tests to &lt;a href=&quot;/simpler-ui-testing-for-wpf-apps.html&quot;&gt;automating testing of WPF apps&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;weaving async/await code to trace when &lt;a href=&quot;https://github.com/shiftkey/Fody.AsyncErrorHandling&quot;&gt;background tasks fail silently&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/shiftkey/winrt-backport-hilarity&quot;&gt;backporting WinRT APIs&lt;/a&gt; to .NET so that libraries and apps can transition to the new APIs more easily&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;I could weep for things that didn&#39;t eventuate, but life&#39;s too short.&lt;/p&gt;

&lt;h3&gt;Share all the things!&lt;/h3&gt;

&lt;p&gt;And how will we know how awesome you are if you don&#39;t tell us?&lt;/p&gt;

&lt;p&gt;After parking my blog ages ago (mostly because I was never really &quot;happy&quot; with it and I&#39;d compulsively tweak things), I&#39;ve started to come around to Hanselman&#39;s words: &lt;a href=&quot;http://www.hanselman.com/blog/YourWordsAreWasted.aspx&quot;&gt;&quot;Every developer should have a blog&quot;&lt;/a&gt;. I&#39;m a habitual Twitter user and thoroughly enjoy the medium for what it is, and I know that I spend time which I should be spending on blogging.&lt;/p&gt;

&lt;p&gt;To compensate for this, I publish a lot of my stuff on &lt;a href=&quot;https://github.com/shiftkey&quot;&gt;GitHub&lt;/a&gt;. Yeah, its lazy. But its out there at least. Even this blog is &lt;a href=&quot;https://github.com/shiftkey/blog&quot;&gt;public&lt;/a&gt; - and its just a static site generated using &lt;a href=&quot;https://github.com/mojombo/jekyll&quot;&gt;Jekyll&lt;/a&gt; and hosted on &lt;a href=&quot;http://www.heroku.com/&quot;&gt;Heroku&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Don&#39;t be afraid to write - for example, my last post on &lt;a href=&quot;http://brendanforster.com/notes/git-alias.html&quot;&gt;git aliases&lt;/a&gt; got several &quot;Hey you missed X&quot; comments on it because I wrote it in a rush and missed a couple of details with the end script.&lt;/p&gt;

&lt;p&gt;If people only blogged perfect posts I&#39;d never end up blogging anything.&lt;/p&gt;

&lt;h2&gt;Feedback&lt;/h2&gt;

&lt;p&gt;I&#39;m running out of words and I bet you guys are getting tired of me over-sharing, so I&#39;ll tie this one off here. What have I missed? What did I say wrong? Let me know in the comments.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Why You Should Care About Git Alias</title>
      <link>http://brendanforster.com//notes/git-alias.html</link>
      <pubDate>Sun, 16 Sep 2012 12:30:00 +0000</pubDate>
      <author>shift.key@gmail.com (Brendan Forster)</author>
      <guid>http://brendanforster.com/notes/git-alias.html</guid>
      <description>&lt;h3&gt;Why do I need alias?&lt;/h3&gt;

&lt;p&gt;One of my favourite bits of &quot;feedback&quot; from Mercurial users is that &quot;you don&#39;t need to type out the full command with hg - git is dumb&quot; or something like that. While they&#39;re not totally incorrect here, they are comparing the out of the box experiences between git and hg.&lt;/p&gt;

&lt;p&gt;Mercurial will recognise shorthand for commands when you type enough characters to distingush the right command, like:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;hg com -&amp;gt; hg commit
hg sta -&amp;gt; hg status
hg sum -&amp;gt; hg summary
hg ci -&amp;gt; hg commit 
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;That&#39;s right, hg does &lt;a href=&quot;http://mercurial.selenic.com/wiki/AliasExtension&quot;&gt;aliases&lt;/a&gt; too...&lt;/p&gt;

&lt;p&gt;Git however will scream at you when you mistype a command. And you will swear in return (either at yourself or at git).&lt;/p&gt;

&lt;p&gt;So to save yourself from screaming in the future, you can customise git to recognise custom commands. It will save you so much time.&lt;/p&gt;

&lt;p&gt;Aliases are stored per-user in the &lt;code&gt;.gitconfig&lt;/code&gt; file - or in the &lt;code&gt;.git/config&lt;/code&gt; file for a repository. All the below scripts will install in the global config file - but you can drop the &lt;code&gt;--global&lt;/code&gt; parameter if you don&#39;t want that behaviour.&lt;/p&gt;

&lt;h3&gt;Adding shorthand as aliases&lt;/h3&gt;

&lt;p&gt;Here&#39;s some shorthand commands for the common git tasks:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# git st
git config --global alias.st &quot;status&quot;   
# git co 
git config --global alias.co &quot;checkout&quot; 
# git ci
git config --global alias.ci &quot;commit&quot;   
# git br
git config --global alias.br &quot;branch&quot;   
# git df
git config --global alias.df &quot;diff&quot;     
# git lp
git config --global alias.lp &quot;log -p&quot;   
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;These are some of the common examples from the &lt;a href=&quot;http://gitready.com/intermediate/2009/02/06/helpful-command-aliases.html&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;Customising existing commands&lt;/h3&gt;

&lt;p&gt;My favourite example of this is a prettier output from &lt;code&gt;git log&lt;/code&gt; - so you can see at a glance the activity on the branch you are currently working on:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# git lg
git config --global alias.lg &quot;log --graph --pretty=format:&#39;%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset&#39; --abbrev-commit --date=relative&quot;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Of course, someone far smarter than me &lt;a href=&quot;http://www.jukie.net/bart/blog/pimping-out-git-log&quot;&gt;wrote this one&lt;/a&gt;...&lt;/p&gt;

&lt;p&gt;A few simpler ones:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# git com -&amp;gt; checkout master
git config --global alias.com &quot;checkout master&quot;

# git fe -&amp;gt; fetch latest changes
git config --global alias.fe &quot;fetch origin&quot;

# git hr -&amp;gt; hard reset state of master
git config --global alias.hr &quot;reset origin/master --hard&quot;

# git me -&amp;gt; get my user name
git config --global alias.me &quot;config user.name&quot;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And you can even embed scripts into an alias. Here&#39;s a couple of simple scripts to see what commits have been added for today (by me any by others):&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# git today
git config --global alias.today &quot;!git all --since=&#39;12am&#39; --committer=\&quot;`git me`\&quot;&quot;

# git today-all
git config --global alias.today-all &quot;!git all --since=&#39;12am&#39;&quot;

# git bn -&amp;gt; get current branch name
git config --global alias.bn &quot;!git for-each-ref --format=&#39;%(refname:short)&#39; `git symbolic-ref HEAD`&quot;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Do you see where we&#39;re going with this? :)&lt;/p&gt;

&lt;h3&gt;Mashing commands together&lt;/h3&gt;

&lt;p&gt;Remember how in my &lt;a href=&quot;/notes/my-git-habits.html&quot;&gt;last post&lt;/a&gt; I mentioned a rather verbose workflow for merging in changes?&lt;/p&gt;

&lt;p&gt;Well let&#39;s take it away with one simple command: &lt;code&gt;sync&lt;/code&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# git sync
git config --global alias.sync &quot;!git update &amp;amp;&amp;amp; git co master &amp;amp;&amp;amp; git pull &amp;amp;&amp;amp; git co @{-1}&quot; 
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;But that&#39;s rather basic - it doesn&#39;t actually rebase my branch that I&#39;m on.&lt;/p&gt;

&lt;p&gt;Let&#39;s do a slightly different command: &lt;code&gt;resync&lt;/code&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# git resync -&amp;gt; sync repository and rebase current branch    
git config --global alias.resync &quot;!sh -c &#39;BRANCH_NAME=$(git bn) &amp;amp;&amp;amp; git com &amp;amp;&amp;amp; git fe &amp;amp;&amp;amp; git hr &amp;amp;&amp;amp; git rebase master $BRANCH_NAME&#39;&quot;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Note how this one uses aliases defined earlier in the post for readability? Yeah, it&#39;s rad.&lt;/p&gt;

&lt;h3&gt;I&#39;m lazy, give me the gist of it (lol pun)&lt;/h3&gt;

&lt;p&gt;I&#39;m checking some other git repos I have lying around to ensure I have all my aliases in one spot, but in the meantime open your &lt;code&gt;~/.gitconfig&lt;/code&gt; file (check &lt;code&gt;C:\Users\{username}\&lt;/code&gt; if you&#39;re on Windows) and paste these values under the &lt;code&gt;[alias]&lt;/code&gt; node. If the &lt;code&gt;[alias]&lt;/code&gt; node doesn&#39;t exist, create it.&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/3732023.js?file=.gitconfig&quot;&gt;&lt;/script&gt;


&lt;p&gt;Got a cool alias you want to share? Fork the gist above!&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>My Git Habits</title>
      <link>http://brendanforster.com//notes/my-git-habits.html</link>
      <pubDate>Sun, 16 Sep 2012 06:30:00 +0000</pubDate>
      <author>shift.key@gmail.com (Brendan Forster)</author>
      <guid>http://brendanforster.com/notes/my-git-habits.html</guid>
      <description>&lt;p&gt;First up, a disclaimer: &lt;strong&gt;This is just one person&#39;s opinion and should be treated as such.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you workflow is similar, that&#39;s great. If you workflow is radically different, that&#39;s great too. With things like git its very easy to have different workflows, so I&#39;ll just be speaking from my experiences here.&lt;/p&gt;

&lt;h3&gt;Introduction&lt;/h3&gt;

&lt;p&gt;Generally speaking, my git flow is based off the &lt;a href=&quot;https://github.com/NancyFx/Nancy/wiki/Git-Workflow&quot;&gt;documentation&lt;/a&gt; for contributors to the NancyFx project. When working on features, this is my high-level flow:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a local branch for the feature&lt;/li&gt;
&lt;li&gt;Work on your feature and get it reviewed -- you do code reviews, right?&lt;/li&gt;
&lt;li&gt;Merge the changes into master&lt;/li&gt;
&lt;li&gt;Push the changes up to the remote repository&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;How does that look from the comamnd line?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;git checkout -b ReallyCoolFeature master&lt;/li&gt;
&lt;li&gt;... stuff gets done ...&lt;/li&gt;
&lt;li&gt;git add -u . -- add all removes and modifies to the staging area&lt;/li&gt;
&lt;li&gt;git add .    -- add new files to the staging area&lt;/li&gt;
&lt;li&gt;git commit -m &quot;#1234 implemented&quot; -- associating commits with work items is awesomely helpful&lt;/li&gt;
&lt;li&gt;git checkout master&lt;/li&gt;
&lt;li&gt;git pull origin/master&lt;/li&gt;
&lt;li&gt;git merge ReallyCoolFeature&lt;/li&gt;
&lt;li&gt;git push origin master&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Yeah, I like to be explicit with my remotes and branch names in these commands. Haters gonna hate.&lt;/p&gt;

&lt;p&gt;But that&#39;s all fairly straight-forward and not really leveraging the &lt;a href=&quot;http://think-like-a-git.net/sections/git-makes-more-sense-when-you-understand-x/example-4-lsd-and-chainsaws.html&quot;&gt;new states of mind&lt;/a&gt; that git makes possible.&lt;/p&gt;

&lt;h3&gt;Rebase all the things&lt;/h3&gt;

&lt;p&gt;Where git truly comes into its own is with rebasing. For those who aren&#39;t familiar with it, rebasing allows you to change the history of a branch. This is generally considered very bad&amp;#0153; to do with public repositories but when you use it only locally it gives you so much control over everything.&lt;/p&gt;

&lt;p&gt;For example, have you ever:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;used a branch for multiple, disparate tasks that you wish you could reorder for readability?&lt;/li&gt;
&lt;li&gt;accidentally forgot to save a file and had to spread a task over multiple commits as a result?&lt;/li&gt;
&lt;li&gt;wanted to update an old branch to the latest changes and avoid merge conflicts?&lt;/li&gt;
&lt;li&gt;wanted to split out a branch into multiple branches and process them separately?&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;If you consider a branch to be a chain of commits - with a parent commit representing the creation point of the branch - then rebasing is the operation to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;change the creation point of a branch&lt;/li&gt;
&lt;li&gt;change the order of the commits in a branch&lt;/li&gt;
&lt;li&gt;change the commits in a branch - squash commits together&lt;/li&gt;
&lt;li&gt;remove commits from a branch&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;At this point you are probably thinking &quot;Oh man, I&#39;m going to nuke my branch and lose all my work&quot; but if you look more closely at what the rebase does, you&#39;ll find that its a lot safer than you think.&lt;/p&gt;

&lt;p&gt;A rebase operation will&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;set the repository to the new creation point&lt;/li&gt;
&lt;li&gt;create a temporary branch just for this rebase operation&lt;/li&gt;
&lt;li&gt;apply the commits one by one to ensure they apply cleanly&lt;/li&gt;
&lt;li&gt;update the pointers for the branch and remove the temporary branch&lt;/li&gt;
&lt;li&gt;set the repository to the last commit of the new branch&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;When I say &quot;ensure the commits apply cleanly&quot; here, I indicate that git will ensure that additions and subtractions to each file make sense. If they don&#39;t (for example, the file has changed significantly enough), it will pause and ask the user to manually confirm the commit.&lt;/p&gt;

&lt;p&gt;At any point during a rebase that requires user input, you can abort and git will roll back to the state it was in before the rebase operation started.&lt;/p&gt;

&lt;h3&gt;Speak English, Brendan!&lt;/h3&gt;

&lt;p&gt;So I got side-tracked a bit just then. Apologies.&lt;/p&gt;

&lt;p&gt;So what do I use rebasing for?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;reordering&lt;/em&gt; - if I do a bit of code cleanup during my work, that remains separate from the current task and can be put before/after when reviewing code&lt;/li&gt;
&lt;li&gt;&lt;em&gt;squashing&lt;/em&gt; - generally speaking, your commits should be granular enough to be easy to follow. But sometimes things go too far and you want to bring related commits together (e.g. missed deleting a file from the previous commit)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;splitting&lt;/em&gt; - if you&#39;ve got a complex branch you could split it up into multiple branches and integrate them in gradually.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;All of this is possible by using interactive rebase - before it kicks off the operation, it displays the commits available and allows you to specify the operations to perform.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; There&#39;s two minor differences when you squash commits together. One operation, &lt;code&gt;fixup&lt;/code&gt;, is intended to merge a commit without including the commit message. The other, &lt;code&gt;squash&lt;/code&gt;, will bring the commit message across and allow you to edit the commit message after the squash.&lt;/p&gt;

&lt;h3&gt;Merging is overrated anyway&lt;/h3&gt;

&lt;p&gt;Yes, that might be a controversial thing to say at this point. Merges are considered important to indicate when two branches have been brought together. But I submit to you, the jury of the internet - do we really need it? I&#39;m not advocating abandoning merges at all - they have a purpose, which is to indicate changes additional to the branch being merged in.&lt;/p&gt;

&lt;p&gt;If I can rebase a branch on top of the current master, I&#39;ve just avoided the need for a merge commit completely (it becomes a fast-forward merge and the pointers are moved forward). I can then push and get on with the next task.&lt;/p&gt;

&lt;p&gt;I guess this comes back to how you use branches. Git works excellently when you create a branch for a task, integrate the code into master, and delete the branch once its reached the end of its useful life.&lt;/p&gt;

&lt;p&gt;Not everyone can work that way (that might be a rant for another day), but I see this a discipline issue rather than a pro/con of the tool itself.&lt;/p&gt;

&lt;h3&gt;My Opinionated Git Flow&lt;/h3&gt;

&lt;p&gt;So with a slight tweak to step 3, my flow becomes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a local branch for the feature&lt;/li&gt;
&lt;li&gt;Work on your feature and get it reviewed -- you do code reviews, right?&lt;/li&gt;
&lt;li&gt;Rebase the branch on master&lt;/li&gt;
&lt;li&gt;Push the changes up to the remote repository&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;How does that look from the comamnd line?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;git checkout -b ReallyCoolFeature master&lt;/li&gt;
&lt;li&gt;... stuff gets done ...&lt;/li&gt;
&lt;li&gt;git add -u . -- add all removes and modifies to the staging area&lt;/li&gt;
&lt;li&gt;git add .    -- add new files to the staging area&lt;/li&gt;
&lt;li&gt;git commit -m &quot;#1234 implemented&quot; -- associating commits with work items is awesomely helpful&lt;/li&gt;
&lt;li&gt;git checkout master&lt;/li&gt;
&lt;li&gt;git pull origin/master master&lt;/li&gt;
&lt;li&gt;git rebase master ReallyCoolFeature&lt;/li&gt;
&lt;li&gt;git checkout master&lt;/li&gt;
&lt;li&gt;git merge ReallyCoolFeature --ff-only&lt;/li&gt;
&lt;li&gt;git push origin master&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Combine that with some hot git alias action (this is getting fairly long as-is), you can strip away much of those commands into a simple &quot;sync&quot; step which you run against the branch you are working on.&lt;/p&gt;

&lt;h3&gt;What&#39;s next?&lt;/h3&gt;

&lt;p&gt;I could go on about using &lt;code&gt;reset&lt;/code&gt; and &lt;code&gt;cherry-pick&lt;/code&gt; commands and head further down the git rabbit hole, but I think the next posts should cover these things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;git alias&lt;/code&gt; - seriously, this is like crack for scripters&lt;/li&gt;
&lt;li&gt;a general rant about discipline when managing commits - git has corrupted my brain, and I&#39;ve found myself applying concepts to situations where I have used other VCSes (even TFS, not using git-tfs or tf-git)&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    
    <item>
      <title>Sharing my personal backlog with the world</title>
      <link>http://brendanforster.com//visible-personal-backlog.html</link>
      <pubDate>Mon, 16 Jul 2012 10:30:00 +0000</pubDate>
      <author>shift.key@gmail.com (Brendan Forster)</author>
      <guid>http://brendanforster.com/visible-personal-backlog.html</guid>
      <description>&lt;p&gt;Ever since I got back from holidays a few weeks ago I&#39;ve been in a bit of a rut trying to tackle the backlog of stuff I&#39;ve been meaning to do (projects half-done, contributions I&#39;ve promised other people, things I&#39;ve been meaning to blog about).&lt;/p&gt;

&lt;h3&gt;The Experiment&lt;/h3&gt;

&lt;p&gt;This experiment comes down to three simple things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;maintain a list of tasks which need to be done (ordered by priority)&lt;/li&gt;
&lt;li&gt;focus on one thing at a time&lt;/li&gt;
&lt;li&gt;make it visible to the world to add some peer input to the situation&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;For the tool to make this happen, I&#39;ve decided to use &lt;a href=&quot;https://trello.com/&quot;&gt;Trello&lt;/a&gt;. After using Trello for the Code52 projects in the past, I felt that it was the best fit between ease of administration and ease of viewing.&lt;/p&gt;

&lt;p&gt;The board is hosted at &lt;a href=&quot;https://trello.com/board/public-backlog/50039c94fe5e1f8037b9b583&quot;&gt;https://trello.com/board/public-backlog/50039c94fe5e1f8037b9b583&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;What can you do?&lt;/h3&gt;

&lt;p&gt;You should be able to leave a comment on any of the items currently there. What sort of comments would help? Things like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&quot;Can you explain this one?&quot; (I&#39;ve been too brief with a task which may be complex)&lt;/li&gt;
&lt;li&gt;&quot;Can you do this sooner?&quot; (this is something you are interested in)&lt;/li&gt;
&lt;li&gt;&quot;Can I help out with this?&quot; (this is something you might be able to help out with)&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;Caveats&lt;/h3&gt;

&lt;p&gt;This is something that I&#39;ll flesh out over the next few days and there may be some details missing.&lt;/p&gt;

&lt;p&gt;There are some items on the list which are deliberately vague - I&#39;ll indicate which tasks are &quot;teasers&quot; at this point in time, but I&#39;ve got no issues with you seeing where they sit in my priority queue.&lt;/p&gt;

&lt;p&gt;And there are some things which I just can&#39;t plain talk about (but really need to do anyway) so I&#39;ll need to figure out a way to represent them properly. Not everything on my plate at the moment is OSS work :)&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>So I accidentally a web guy MVP</title>
      <link>http://brendanforster.com//so-i-accidentally-a-web-guy-mvp.html</link>
      <pubDate>Sun, 08 Jul 2012 10:30:00 +0000</pubDate>
      <author>shift.key@gmail.com (Brendan Forster)</author>
      <guid>http://brendanforster.com/so-i-accidentally-a-web-guy-mvp.html</guid>
      <description>&lt;p&gt;So I just had this little email land in my inbox last week.&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;Congratulations! We are pleased to present you with the 2012 Microsoft MVP Award! This award is given to exceptional technical community leaders who actively share their high quality, real world expertise with others. We appreciate your outstanding contributions in ASP.NET/IIS technical communities during the past year.&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;After the chaos of first half of the year (which I still want to get back to, just trying to summon the energy again after a brief respite to head over to NDC this year) this caught me off-guard, but has been an honour to accept nonetheless.&lt;/p&gt;

&lt;p&gt;I&#39;ll comment a bit further on the details once I&#39;ve signed away my life and get an idea of what&#39;s involved, but given the ASP.NET dev stack (well, the &lt;em&gt;good&lt;/em&gt; bits anyway ::smileyface::) is now on &lt;a href=&quot;http://aspnetwebstack.codeplex.com/&quot;&gt;Codeplex&lt;/a&gt; I&#39;m keen to spend some time digging into that and helping out wherever my powers might be of benefit.&lt;/p&gt;

&lt;p&gt;There&#39;s also shiny things coming along in the upcoming release (I&#39;ve hacked a bit on Web API, and Single Page Apps is on my radar but I haven&#39;t used in anger) which are on my never-ending TODO list.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Introducing code52</title>
      <link>http://brendanforster.com//introducing-code52.html</link>
      <pubDate>Tue, 03 Jan 2012 10:30:00 +0000</pubDate>
      <author>shift.key@gmail.com (Brendan Forster)</author>
      <guid>http://brendanforster.com/introducing-code52.html</guid>
      <description>&lt;p&gt;Back from a self-imposed internet break (taking a phone which doesn&#39;t do 3G coverage and going rural is a good way to do this) and &lt;a href=&quot;http://twitter.com/aeoth&quot;&gt;Paul&lt;/a&gt; and &lt;a href=&quot;http://twitter.com/tobin&quot;&gt;Tobin&lt;/a&gt; couldn&#39;t wait to kick off our new collaborative project.&lt;/p&gt;

&lt;center&gt;&lt;a href=&quot;http://code52.org&quot;&gt;&lt;img class=&#39;right &#39; src=&#39;/img/posts/Code52/logo.png&#39; width=&#39;&#39; height=&#39;&#39; alt=&#39;&#39; title=&#39;&#39;&gt;&lt;/a&gt;&lt;/center&gt;


&lt;br/&gt;


&lt;p&gt;There&#39;s a bit more of a blurb on &lt;a href=&quot;http://code52.org/about.html&quot;&gt;the website&lt;/a&gt; - its an idea we&#39;re still wrapping our heads around by using a bit of trial and error.&lt;/p&gt;

&lt;p&gt;We&#39;re already hard at work on our &lt;a href=&quot;http://code52.org/downmarker&quot;&gt;first project&lt;/a&gt; and we&#39;d love to see people drop into the &lt;a href=&quot;http://jabbr.net/#/rooms/code52&quot;&gt;Jabbr room&lt;/a&gt; and get involved. Amd pf course, there&#39;s a &lt;a href=&quot;http://twitter.com/code_52&quot;&gt;Twitter account&lt;/a&gt; too to follow.&lt;/p&gt;
</description>
    </item>
    

  </channel>
</rss>