<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Of Code and Me</title>
	<atom:link href="http://eliasbland.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://eliasbland.wordpress.com</link>
	<description>Somewhere to write down all the stuff I&#039;m going to forget and then need</description>
	<lastBuildDate>Thu, 22 Oct 2009 16:52:38 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='eliasbland.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/97879de2d18dcf83cea427a404badd05?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Of Code and Me</title>
		<link>http://eliasbland.wordpress.com</link>
	</image>
			<item>
		<title>Euclidean Distance and Similarity in C#</title>
		<link>http://eliasbland.wordpress.com/2009/10/22/euclidean-distance-and-similarity-in-c/</link>
		<comments>http://eliasbland.wordpress.com/2009/10/22/euclidean-distance-and-similarity-in-c/#comments</comments>
		<pubDate>Thu, 22 Oct 2009 16:46:57 +0000</pubDate>
		<dc:creator>Rupert Bates</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://eliasbland.wordpress.com/?p=162</guid>
		<description><![CDATA[Here are a couple of functions to calculate Euclidean distance between 2 points and similarity based on that distance. These are useful in the sort of algorithms described in the excellent book Programming Collective Intelligence

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace Algorithms
{
 public class Distance
 {
 /// &#60;summary&#62;
 /// Return the distance between 2 points
 /// [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eliasbland.wordpress.com&blog=1089842&post=162&subd=eliasbland&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Here are a couple of functions to calculate Euclidean distance between 2 points and similarity based on that distance. These are useful in the sort of algorithms described in the excellent book <a href="http://www.amazon.co.uk/Programming-Collective-Intelligence-Building-Applications/dp/0596529325/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1256230164&amp;sr=8-1" target="_blank">Programming Collective Intelligence</a></p>
<pre class="brush: csharp;">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace Algorithms
{
 public class Distance
 {
 /// &lt;summary&gt;
 /// Return the distance between 2 points
 /// &lt;/summary&gt;
 public static double Euclidean(Point p1, Point p2)
 {
 return Math.Sqrt(Math.Pow(p1.X - p2.X, 2) + Math.Pow(p1.Y - p2.Y, 2));
 }

 /// &lt;summary&gt;
 /// Calculates the similarity between 2 points using Euclidean distance.
 /// Returns a value between 0 and 1 where 1 means they are identical
 /// &lt;/summary&gt;
 public static double EuclideanSimilarity(Point p1, Point p2)
 {
 return 1/(1 + Euclidean(p1, p2));
 }
 }
}</pre>
<p>And some tests:</p>
<pre class="brush: csharp;">
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Algorithms.Test
{
 [TestClass]
 public class TestDistance
 {
 [TestMethod]
 public void Test_Euclidean()
 {
 var p1 = new Point(5, 4);
 var p2 = new Point(4, 1);

 Assert.AreEqual(3.1622776601683795, Distance.Euclidean(p1, p2));

 }
 [TestMethod]
 public void Test_EuclideanSimilarity()
 {
 var p1 = new Point(5, 4);
 var p2 = new Point(4, 1);

 Assert.AreEqual(0.2402530733520421, Distance.EuclideanSimilarity(p1, p2));

 }
 }
}
</pre>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/eliasbland.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/eliasbland.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/eliasbland.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/eliasbland.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/eliasbland.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/eliasbland.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/eliasbland.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/eliasbland.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/eliasbland.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/eliasbland.wordpress.com/162/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eliasbland.wordpress.com&blog=1089842&post=162&subd=eliasbland&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://eliasbland.wordpress.com/2009/10/22/euclidean-distance-and-similarity-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cc7ffd9d99152f554e9779bb745d6c50?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Rupert Bates</media:title>
		</media:content>
	</item>
		<item>
		<title>Access RouteData for the current Route from a library class in asp.net mvc</title>
		<link>http://eliasbland.wordpress.com/2009/10/07/access-routedata-for-the-current-route-from-a-library-class-in-asp-mvc/</link>
		<comments>http://eliasbland.wordpress.com/2009/10/07/access-routedata-for-the-current-route-from-a-library-class-in-asp-mvc/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 13:20:25 +0000</pubDate>
		<dc:creator>Rupert Bates</dc:creator>
				<category><![CDATA[Asp.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[MVC]]></category>

		<guid isPermaLink="false">http://eliasbland.wordpress.com/?p=158</guid>
		<description><![CDATA[Sometimes it&#8217;s useful to be able to access the current RouteData from outside a controller, for instance in a library class. In webforms you could always do


HttpContext.Current

but in Asp.Net MVC it&#8217;s a bit less obvious how you get access to this data.
I&#8217;ve found the following code works:


RouteTable.Routes.GetRouteData(new HttpContextWrapper(HttpContext.Current));

Whether there is an easier way or not [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eliasbland.wordpress.com&blog=1089842&post=158&subd=eliasbland&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Sometimes it&#8217;s useful to be able to access the current RouteData from outside a controller, for instance in a library class. In webforms you could always do</p>
<pre class="brush: csharp;">

HttpContext.Current
</pre>
<p>but in Asp.Net MVC it&#8217;s a bit less obvious how you get access to this data.</p>
<p>I&#8217;ve found the following code works:</p>
<pre class="brush: csharp;">

RouteTable.Routes.GetRouteData(new HttpContextWrapper(HttpContext.Current));
</pre>
<p>Whether there is an easier way or not I don&#8217;t know, but this will do me for now&#8230;</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/eliasbland.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/eliasbland.wordpress.com/158/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/eliasbland.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/eliasbland.wordpress.com/158/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/eliasbland.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/eliasbland.wordpress.com/158/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/eliasbland.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/eliasbland.wordpress.com/158/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/eliasbland.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/eliasbland.wordpress.com/158/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eliasbland.wordpress.com&blog=1089842&post=158&subd=eliasbland&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://eliasbland.wordpress.com/2009/10/07/access-routedata-for-the-current-route-from-a-library-class-in-asp-mvc/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cc7ffd9d99152f554e9779bb745d6c50?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Rupert Bates</media:title>
		</media:content>
	</item>
		<item>
		<title>Group By with Count in Linq</title>
		<link>http://eliasbland.wordpress.com/2009/09/29/group-by-with-count-in-linq/</link>
		<comments>http://eliasbland.wordpress.com/2009/09/29/group-by-with-count-in-linq/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 20:26:07 +0000</pubDate>
		<dc:creator>Rupert Bates</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Linq]]></category>

		<guid isPermaLink="false">http://eliasbland.wordpress.com/?p=149</guid>
		<description><![CDATA[To group a sequence getting a count for each element of the grouped sequence using Linq:

            var wordList = new List&#60;String&#62; { &#34;test&#34;, &#34;one&#34;, &#34;test&#34;, &#34;two&#34; };
            var grouped = wordList
   [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eliasbland.wordpress.com&blog=1089842&post=149&subd=eliasbland&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>To group a sequence getting a count for each element of the grouped sequence using Linq:</p>
<pre class="brush: csharp;">
            var wordList = new List&lt;String&gt; { &quot;test&quot;, &quot;one&quot;, &quot;test&quot;, &quot;two&quot; };
            var grouped = wordList
                .GroupBy(i =&gt; i) //Group the words
                .Select(i =&gt; new { Word = i.Key, Count = i.Count() }); //get a count for each
</pre>
<p>Which results in this sequence:</p>
<p><img class="alignnone size-full wp-image-153" title="watch" src="http://eliasbland.files.wordpress.com/2009/09/watch1.jpg?w=752&#038;h=288" alt="watch" width="752" height="288" /></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/eliasbland.wordpress.com/149/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/eliasbland.wordpress.com/149/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/eliasbland.wordpress.com/149/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/eliasbland.wordpress.com/149/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/eliasbland.wordpress.com/149/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/eliasbland.wordpress.com/149/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/eliasbland.wordpress.com/149/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/eliasbland.wordpress.com/149/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/eliasbland.wordpress.com/149/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/eliasbland.wordpress.com/149/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eliasbland.wordpress.com&blog=1089842&post=149&subd=eliasbland&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://eliasbland.wordpress.com/2009/09/29/group-by-with-count-in-linq/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cc7ffd9d99152f554e9779bb745d6c50?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Rupert Bates</media:title>
		</media:content>

		<media:content url="http://eliasbland.files.wordpress.com/2009/09/watch1.jpg" medium="image">
			<media:title type="html">watch</media:title>
		</media:content>
	</item>
		<item>
		<title>Open your hosts file in notepad from Powershell</title>
		<link>http://eliasbland.wordpress.com/2009/09/29/open-your-hosts-file-in-notepad-from-powershell/</link>
		<comments>http://eliasbland.wordpress.com/2009/09/29/open-your-hosts-file-in-notepad-from-powershell/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 12:36:59 +0000</pubDate>
		<dc:creator>Rupert Bates</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://eliasbland.wordpress.com/2009/09/29/open-your-hosts-file-in-notepad-from-powershell/</guid>
		<description><![CDATA[notepad (gci -Include hosts -Path c:\windows\system32 -Recurse)
       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eliasbland.wordpress.com&blog=1089842&post=148&subd=eliasbland&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>notepad (gci -Include hosts -Path c:\windows\system32 -Recurse)</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/eliasbland.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/eliasbland.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/eliasbland.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/eliasbland.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/eliasbland.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/eliasbland.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/eliasbland.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/eliasbland.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/eliasbland.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/eliasbland.wordpress.com/148/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eliasbland.wordpress.com&blog=1089842&post=148&subd=eliasbland&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://eliasbland.wordpress.com/2009/09/29/open-your-hosts-file-in-notepad-from-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cc7ffd9d99152f554e9779bb745d6c50?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Rupert Bates</media:title>
		</media:content>
	</item>
		<item>
		<title>When two problems appear at the same time no matter how seemingly unrelated, they probably are</title>
		<link>http://eliasbland.wordpress.com/2009/09/18/when-two-problems-appear-at-the-same-time-no-matter-how-seemingly-unrelated-they-probably-are/</link>
		<comments>http://eliasbland.wordpress.com/2009/09/18/when-two-problems-appear-at-the-same-time-no-matter-how-seemingly-unrelated-they-probably-are/#comments</comments>
		<pubDate>Fri, 18 Sep 2009 10:02:22 +0000</pubDate>
		<dc:creator>Rupert Bates</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://eliasbland.wordpress.com/?p=142</guid>
		<description><![CDATA[I&#8217;ve seen two examples of this in the last few days. 
Firstly we have an Asp.Net website which has recently moved to a new datacentre and seemed to be working well, but then the other day it fell over big time and the event log started filling up with errors about deadlocks in the aspnet_isapi.dll [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eliasbland.wordpress.com&blog=1089842&post=142&subd=eliasbland&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I&#8217;ve seen two examples of this in the last few days. </p>
<p>Firstly we have an Asp.Net website which has recently moved to a new datacentre and seemed to be working well, but then the other day it fell over big time and the event log started filling up with errors about deadlocks in the aspnet_isapi.dll and faults in the W3SVC service. We googled away and just came up with some thing about thread contention and upping the maxWorkerThreads parameter in the machine.config which I didn&#8217;t want to do without understanding why this had suddenly become and issue. </p>
<p>At the same time somebody noticed that printing no longer worked in non Internet Explorer browsers, but we ignored that to focus on the more serious stability issue. It was only when I gave up on the first error and looked into the printing bug that I worked out what was going on. The printing page for Non IE browsers tried to make an http request to another page on the site to load the image it was trying to print. Stricter firewall rules in our new datacentre meant that this http request was being blocked meaning that the thread that was trying to make this request was also blocked until the request timed out, and this was what caused both the printing problem and the threading deadlock. </p>
<p>The second example of this maxim is a bit less high tech; my washing machine started leaking water through the door and we noticed the seal was a bit torn. At the same time it kept stopping with an error message (yup, even washing machines have them now) about the filter being blocked (which it wasn&#8217;t). It turns out that the loss of pressure from the leaking water affected its ability to pump out water, so it thought that the filter was blocked (that may not be 100% accurate, but when it comes to washing machines I&#8217;m not technical).</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/eliasbland.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/eliasbland.wordpress.com/142/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/eliasbland.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/eliasbland.wordpress.com/142/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/eliasbland.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/eliasbland.wordpress.com/142/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/eliasbland.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/eliasbland.wordpress.com/142/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/eliasbland.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/eliasbland.wordpress.com/142/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eliasbland.wordpress.com&blog=1089842&post=142&subd=eliasbland&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://eliasbland.wordpress.com/2009/09/18/when-two-problems-appear-at-the-same-time-no-matter-how-seemingly-unrelated-they-probably-are/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cc7ffd9d99152f554e9779bb745d6c50?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Rupert Bates</media:title>
		</media:content>
	</item>
		<item>
		<title>Display C# code in a WordPress Blog</title>
		<link>http://eliasbland.wordpress.com/2009/09/16/display-c-code-in-a-wordpress-blog/</link>
		<comments>http://eliasbland.wordpress.com/2009/09/16/display-c-code-in-a-wordpress-blog/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 16:24:29 +0000</pubDate>
		<dc:creator>Rupert Bates</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://eliasbland.wordpress.com/?p=136</guid>
		<description><![CDATA[A cool way to get WordPress to format and sytax highlight your C# code:
&#91;sourcecode language=&#8217;csharp&#8217;&#93;
string MyCode = &#8220;My Code&#8221;;
&#91;/sourcecode&#93;
Which appears in the post as:

string MyCode = &#34;My Code&#34;;

       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eliasbland.wordpress.com&blog=1089842&post=136&subd=eliasbland&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>A cool way to get WordPress to format and sytax highlight your C# code:</p>
<p>&#91;sourcecode language=&#8217;csharp&#8217;&#93;<br />
string MyCode = &#8220;My Code&#8221;;<br />
&#91;/sourcecode&#93;</p>
<p>Which appears in the post as:</p>
<pre class="brush: csharp;">
string MyCode = &quot;My Code&quot;;
</pre>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/eliasbland.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/eliasbland.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/eliasbland.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/eliasbland.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/eliasbland.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/eliasbland.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/eliasbland.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/eliasbland.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/eliasbland.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/eliasbland.wordpress.com/136/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eliasbland.wordpress.com&blog=1089842&post=136&subd=eliasbland&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://eliasbland.wordpress.com/2009/09/16/display-c-code-in-a-wordpress-blog/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cc7ffd9d99152f554e9779bb745d6c50?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Rupert Bates</media:title>
		</media:content>
	</item>
		<item>
		<title>Auto Initialize a Dictionary in C#</title>
		<link>http://eliasbland.wordpress.com/2009/09/16/auto-initialize-a-dictionary-in-c-sharp/</link>
		<comments>http://eliasbland.wordpress.com/2009/09/16/auto-initialize-a-dictionary-in-c-sharp/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 16:05:28 +0000</pubDate>
		<dc:creator>Rupert Bates</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://eliasbland.wordpress.com/?p=130</guid>
		<description><![CDATA[I couldn&#8217;t find an example of using the new auto initialization syntax in C# 3.0 with a Dictionary so here is one:

var dict = new Dictionary&#60;string, string&#62; { { &#34;key1&#34;, &#34;value1&#34; }, { &#34;key2&#34;, &#34;value2&#34; } };

       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eliasbland.wordpress.com&blog=1089842&post=130&subd=eliasbland&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I couldn&#8217;t find an example of using the new auto initialization syntax in C# 3.0 with a Dictionary so here is one:</p>
<pre class="brush: csharp;">
var dict = new Dictionary&lt;string, string&gt; { { &quot;key1&quot;, &quot;value1&quot; }, { &quot;key2&quot;, &quot;value2&quot; } };
</pre>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/eliasbland.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/eliasbland.wordpress.com/130/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/eliasbland.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/eliasbland.wordpress.com/130/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/eliasbland.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/eliasbland.wordpress.com/130/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/eliasbland.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/eliasbland.wordpress.com/130/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/eliasbland.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/eliasbland.wordpress.com/130/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eliasbland.wordpress.com&blog=1089842&post=130&subd=eliasbland&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://eliasbland.wordpress.com/2009/09/16/auto-initialize-a-dictionary-in-c-sharp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cc7ffd9d99152f554e9779bb745d6c50?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Rupert Bates</media:title>
		</media:content>
	</item>
		<item>
		<title>Connect to IIS 6 over WMI with WMI CIM studio</title>
		<link>http://eliasbland.wordpress.com/2009/09/10/connect-to-iis-6-over-wmi-with-wmi-cim-studio/</link>
		<comments>http://eliasbland.wordpress.com/2009/09/10/connect-to-iis-6-over-wmi-with-wmi-cim-studio/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 16:08:34 +0000</pubDate>
		<dc:creator>Rupert Bates</dc:creator>
				<category><![CDATA[Systems Administration]]></category>

		<guid isPermaLink="false">http://eliasbland.wordpress.com/?p=126</guid>
		<description><![CDATA[Connect to:
\\[ServerName]\root\MicrosoftIISv2
In the connection dialog:
If you are logged in as a user who has admin rights on the server then check &#8216;Login as current user&#8217;, otherwise uncheck it and enter the credentials of a user who does.
Click &#8216;Options&#62;&#62;&#8217; button:
Set Impersonation level to &#8216;Impersonate&#8217;
Set Authentication level to &#8216;Packet Privacy&#8217;
Check &#8216;Enable all privileges&#8217;
Click &#8216;OK&#8217; and hey presto!
 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eliasbland.wordpress.com&blog=1089842&post=126&subd=eliasbland&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Connect to:</p>
<p>\\[ServerName]\root\MicrosoftIISv2</p>
<p>In the connection dialog:</p>
<p>If you are logged in as a user who has admin rights on the server then check &#8216;Login as current user&#8217;, otherwise uncheck it and enter the credentials of a user who does.</p>
<p>Click &#8216;Options&gt;&gt;&#8217; button:</p>
<p>Set Impersonation level to &#8216;Impersonate&#8217;</p>
<p>Set Authentication level to &#8216;Packet Privacy&#8217;</p>
<p>Check &#8216;Enable all privileges&#8217;</p>
<p>Click &#8216;OK&#8217; and hey presto!</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/eliasbland.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/eliasbland.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/eliasbland.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/eliasbland.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/eliasbland.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/eliasbland.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/eliasbland.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/eliasbland.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/eliasbland.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/eliasbland.wordpress.com/126/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eliasbland.wordpress.com&blog=1089842&post=126&subd=eliasbland&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://eliasbland.wordpress.com/2009/09/10/connect-to-iis-6-over-wmi-with-wmi-cim-studio/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cc7ffd9d99152f554e9779bb745d6c50?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Rupert Bates</media:title>
		</media:content>
	</item>
		<item>
		<title>A Total Newbies guide to a few Linux commands</title>
		<link>http://eliasbland.wordpress.com/2009/09/02/a-total-newbies-guide-to-a-few-linux-commands/</link>
		<comments>http://eliasbland.wordpress.com/2009/09/02/a-total-newbies-guide-to-a-few-linux-commands/#comments</comments>
		<pubDate>Wed, 02 Sep 2009 12:36:17 +0000</pubDate>
		<dc:creator>Rupert Bates</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://eliasbland.wordpress.com/?p=121</guid>
		<description><![CDATA[This is just a reminder for me really, as I struggle to debug one of our LAMP sites after our Sys Admin left&#8230;
cd [directoryname] &#8211; Change directory
cd .. &#8211; Go up one directory
cd ../.. &#8211; Go up 2 directories
ls &#8211; List directory contents
cat [filename] &#8211; Show the contents of a text file
rm [filename] &#8211; Delete [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eliasbland.wordpress.com&blog=1089842&post=121&subd=eliasbland&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>This is just a reminder for me really, as I struggle to debug one of our LAMP sites after our Sys Admin left&#8230;</p>
<p><strong>cd [directoryname]</strong> &#8211; Change directory</p>
<p><strong>cd ..</strong> &#8211; Go up one directory</p>
<p><strong>cd ../..</strong> &#8211; Go up 2 directories</p>
<p><strong>ls</strong> &#8211; List directory contents</p>
<p><strong>cat [filename]</strong> &#8211; Show the contents of a text file</p>
<p><strong>rm [filename]</strong> &#8211; Delete a file</p>
<p><strong>rmdir [directory]</strong> &#8211; Delete a directory</p>
<p><strong>rmdir -r [directory]</strong> &#8211; Delete a directory and all it&#8217;s contents</p>
<p><strong>sh [filename]</strong> &#8211; Execute a shell script file</p>
<p><strong>Tab</strong> &#8211; Complete a filename</p>
<p><strong>Ctrl + c</strong> &#8211; Cancel a running command</p>
<p><strong>crontab -l</strong> &#8211; List all the current user&#8217;s cron jobs</p>
<p><strong>ps -A</strong> &#8211; List all running processes</p>
<p><strong>ps -A | grep java</strong> &#8211; list all running java processes</p>
<p><strong>find -name *blah*.zip</strong> &#8211; Find all zip files with blah in their name, <a href="http://www.thegeekstuff.com/2009/03/15-practical-linux-find-command-examples/" target="_blank">more examples</a></p>
<p><strong>grep &#8220;[string literal]&#8221; *.log -C 4</strong> &#8211; Search for a string literal in all .log files and return 4 lines on either side of the matching line, <a href="http://www.thegeekstuff.com/2009/03/15-practical-unix-grep-command-examples/" target="_blank">more examples</a></p>
<p><strong>tail [filename] -follow </strong>- Show the last 10 lines of a file and watch it for changes (Ctrl + c to cancel)</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/eliasbland.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/eliasbland.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/eliasbland.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/eliasbland.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/eliasbland.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/eliasbland.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/eliasbland.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/eliasbland.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/eliasbland.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/eliasbland.wordpress.com/121/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eliasbland.wordpress.com&blog=1089842&post=121&subd=eliasbland&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://eliasbland.wordpress.com/2009/09/02/a-total-newbies-guide-to-a-few-linux-commands/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cc7ffd9d99152f554e9779bb745d6c50?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Rupert Bates</media:title>
		</media:content>
	</item>
		<item>
		<title>An Implementation of Fold for C#</title>
		<link>http://eliasbland.wordpress.com/2009/08/20/an-implementation-of-fold-for-c/</link>
		<comments>http://eliasbland.wordpress.com/2009/08/20/an-implementation-of-fold-for-c/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 09:22:50 +0000</pubDate>
		<dc:creator>Rupert Bates</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Functional programming]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://eliasbland.wordpress.com/?p=110</guid>
		<description><![CDATA[I expect there are a number of implementations of this around, but I couldn&#8217;t find one so I wrote this. It is an extension method which implements Fold on IEnumerable


public static class Extensions
{
  public delegate TDestination FoldOperation&#60;TSource, TDestination&#62;(TSource item, TDestination acc);
  public static TDestination Fold&#60;TSource, TDestination&#62;(this IEnumerable&#60;TSource&#62; list, FoldOperation&#60;TSource, TDestination&#62; foldOperation, TDestination acc)
 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eliasbland.wordpress.com&blog=1089842&post=110&subd=eliasbland&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I expect there are a number of implementations of this around, but I couldn&#8217;t find one so I wrote this. It is an extension method which implements <a href="http://en.wikipedia.org/wiki/Fold_(higher-order_function)" target="_blank">Fold</a> on IEnumerable</p>
<pre class="brush: csharp;">

public static class Extensions
{
  public delegate TDestination FoldOperation&lt;TSource, TDestination&gt;(TSource item, TDestination acc);
  public static TDestination Fold&lt;TSource, TDestination&gt;(this IEnumerable&lt;TSource&gt; list, FoldOperation&lt;TSource, TDestination&gt; foldOperation, TDestination acc)
  {
     foreach(TSource item in list)
     {
       acc = foldOperation(item, acc);
     }
     return acc;
  }
 }
</pre>
<p>I can then use this Fold function for something like this which takes an object with a number of properties and creates a querystring with the name/value pairs of all of those properties which are non-null:</p>
<pre class="brush: csharp;">
public class UrlConstructor
{
  //Takes a RequestParameter object with a number of properties which
  //if their value is set should be translated into querystring parameters
  public static string ConstructUrl(RequestParameters rp)
  {
    //Get all the properties where the value is not null
    var values = typeof(RequestParameters).GetProperties().Where(p =&gt; (p.GetValue(rp, null) != null));

    //Fold these values up into a string
    var querystring = values.Fold(((p, acc) =&gt; acc + p.Name + &quot;=&quot; + p.GetValue(rp, null) + &quot;&amp;&quot;), &quot;&quot;).TrimEnd('&amp;');

    return &quot;http://mybaseurl.com/default.aspx?&quot; + querystring;
  }
}
</pre>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/eliasbland.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/eliasbland.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/eliasbland.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/eliasbland.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/eliasbland.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/eliasbland.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/eliasbland.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/eliasbland.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/eliasbland.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/eliasbland.wordpress.com/110/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=eliasbland.wordpress.com&blog=1089842&post=110&subd=eliasbland&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://eliasbland.wordpress.com/2009/08/20/an-implementation-of-fold-for-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cc7ffd9d99152f554e9779bb745d6c50?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Rupert Bates</media:title>
		</media:content>
	</item>
	</channel>
</rss>