<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>manski's blog</title>
	
	<link>http://manski.net</link>
	<description>Diary of a programmer</description>
	<lastBuildDate>Mon, 20 May 2013 10:05:59 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/ManskisBlog" /><feedburner:info uri="manskisblog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>The Visitor Pattern Explained</title>
		<link>http://feedproxy.google.com/~r/ManskisBlog/~3/Q2VMiBzm6lU/</link>
		<comments>http://manski.net/2013/05/the-visitor-pattern-explained/#comments</comments>
		<pubDate>Mon, 06 May 2013 19:11:34 +0000</pubDate>
		<dc:creator>Sebastian Krysmanski</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Code Project]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[design patterns]]></category>
		<category><![CDATA[method dispatching]]></category>
		<category><![CDATA[oop]]></category>
		<category><![CDATA[visitor pattern]]></category>

		<guid isPermaLink="false">http://manski.net/?p=3349</guid>
		<description><![CDATA[In my last job interview I got a (rather vague) question about traversing a tree and operating on the tree nodes. I think I&#8217;ve a lot of experience in programming but I couldn&#8217;t figure out the answer on my own. The answer the guy wanted to hear was: visitor pattern. I had never heard of [...]]]></description>
				<content:encoded><![CDATA[ <p>  <!-- Cached "rss-item" item from 2013-05-20 10:06:17 --> In my last job interview I got a (rather vague) question about traversing a tree and operating on the tree nodes. I think I&#8217;ve a lot of experience in programming but I couldn&#8217;t figure out the answer on my own. The answer the guy wanted to hear was: <strong>visitor pattern</strong>. </p> 
 <p> I had never heard of it before. So, in preparation for my next job interview, I thought I take a look at it. </p> 
 <p> While trying to figure it out, I stumbled over this quote: </p> 
<blockquote> <p> The Visitor pattern is possibly the most complicated design pattern you will face. (<a href="http://www.jquantlib.org/index.php/A_better_implementation_of_Visitor_pattern" target="_blank">Source</a>)
 </p> </blockquote>
 <p> I totally agree. (And this is probably why I&#8217;ve never heard or used it before.) </p> 
 <p> But since I&#8217;m not a quitter I went on and tamed it. So, in this article I&#8217;m going to shed some light on this mysterious design pattern. </p> 
 <p> <span id="more-3349"></span> </p> 
<h2 id="definition">Definition</h2>
 <p> The main problem (in my opinion) with the visitor pattern is that it&#8217;s often not really clear what it does. So, let&#8217;s start with the following definition (based on <a href="http://en.wikipedia.org/wiki/Visitor pattern" target="_blank">Wikipedia</a>): </p> 
<blockquote> <p>  The visitor design pattern is a way of <em>separating an operation from an object structure</em> on which it operates. [...] In essence, this pattern allows one to <em>add new virtual functions</em> to a family of classes without modifying the classes themselves;
 </p> </blockquote>
<h2 id="motivation">Motivation</h2>
 <p> Let&#8217;s explore what this means. I&#8217;ll provide some basic examples with increasing complexity to illustrate the motivation behind the visitor pattern. </p> 
 <p> <em>Note:</em> All examples are in C#. </p> 
<h3 id="object_structure">The Object Structure</h3>
 <p> The definition above states that the visitor pattern separates &#8220;an operation from an <em>object structure</em>&#8220;. So, let&#8217;s define this object structure. </p> 
 <p> Assume we have some kind of wikicode parser. The wikicode allows us to write documents in plain text but enrich them with some formatting (bold text) and hyperlinks. </p> 
 <p> So, we have classes for plain text, bold text, and hyperlinks: </p> 
<pre class="code">public abstract class DocumentPart {
  public string Text { get; private set; }
}

public class PlainText : DocumentPart { }

public class BoldText : DocumentPart { }

public class Hyperlink : DocumentPart {
  public string Url { get; private set; }
}</pre>
 <p> And we have a document class: </p> 
<pre class="code">public class Document {
  private List&lt;DocumentPart&gt; m_parts;
}</pre>
<h3 id="scenario-1.3A-converting-into-html">Scenario 1: Converting Into HTML</h3>
 <p> Now let&#8217;s assume we want to convert this document into HTML. </p> 
 <p> The most straightforward way would be to add a <code>virtual</code> method called <code>ToHTML()</code> to <code>DocumentPart</code>, like this: </p> 
<pre class="code">public abstract class DocumentPart {
  public string Text { get; private set; }
  public abstract string ToHTML();
}

public class PlainText : DocumentPart { 
  public override string ToHTML() {
    return this.Text;
  }
}

public class BoldText : DocumentPart { 
  public override string ToHTML() {
    return &quot;&lt;b&gt;&quot; + this.Text + &quot;&lt;/b&gt;&quot;;
  }
}

public class Hyperlink : DocumentPart {
  public string Url { get; private set; }

  public override string ToHTML() {
    return &quot;&lt;a href=\&quot;&quot; + this.Url + &quot;\&quot;&gt;&quot; + this.Text + &quot;&lt;/a&gt;&quot;;
  }
}</pre>
 <p> And the <code>Document</code> class would also get a <code>ToHTML()</code> method: </p> 
<pre class="code">public class Document {
  private List&lt;DocumentPart&gt; m_parts;

  public string ToHTML() {
    string output = &quot;&quot;;
    foreach (DocumentPart part in this.m_parts) {
      output += part.ToHTML();
    }
    return output;
  }
}</pre>
 <p> Then, by calling <code>Document.ToHTML()</code> one could convert the whole document into HTML. </p> 
<h3 id="scenario-2.3A-different-output-formats">Scenario 2: Different Output Formats</h3>
 <p> Let&#8217;s add some complexity. Additionally to the previous scenario, we now also want to allow the conversion into plain text and LaTeX. </p> 
 <p> A naive way would be to provide implementations for each output format: </p> 
<pre class="code">public abstract class DocumentPart {
  public string Text { get; private set; }
  public abstract string ToHTML();
  public abstract string ToPlainText();
  public abstract string ToLatex();
}

public class PlainText : DocumentPart { 
  public override string ToHTML() {
    return this.Text;
  }
  public override string ToPlainText() {
    return this.Text;
  }
  public override string ToLatex() {
    return this.Text;
  }
}

public class BoldText : DocumentPart { 
  public override string ToHTML() {
    return &quot;&lt;b&gt;&quot; + this.Text + &quot;&lt;/b&gt;&quot;;
  }
  public override string ToPlainText() {
    return &quot;**&quot; + this.Text + &quot;**&quot;;
  }
  public override string ToLatex() {
    return &quot;\\textbf{&quot; + this.Text + &quot;}&quot;;
  }
}

public class Hyperlink : DocumentPart {
  public string Url { get; private set; }

  public override string ToHTML() {
    return &quot;&lt;a href=\&quot;&quot; + this.Url + &quot;\&quot;&gt;&quot; + this.Text + &quot;&lt;/a&gt;&quot;;
  }
  public override string ToPlainText() {
    return this.Text + &quot; [&quot; + this.Url + &quot;]&quot;;
  }
  public override string ToLatex() {
    return &quot;\\href{&quot; + this.Url + &quot;}{&quot; + this.Text + &quot;}&quot;;
  }
}

public class Document {
  private List&lt;DocumentPart&gt; m_parts;

  public string ToHTML() {
    string output = &quot;&quot;;
    foreach (DocumentPart part in this.m_parts) {
      output += part.ToHTML();
    }
    return output;
  }

  public string ToPlainText() {
    string output = &quot;&quot;;
    foreach (DocumentPart part in this.m_parts) {
      output += part.ToPlainText();
    }
    return output;
  }

  public string ToLatex() {
    string output = &quot;&quot;;
    foreach (DocumentPart part in this.m_parts) {
      output += part.ToLatex();
    }
    return output;
  }
}</pre>
 <p> This implementation suffers two major problems: </p> 
<ul>
<li class="first-item">The code for the <code>Document.To...()</code> methods is almost identical. This may lead to errors when changing one of the methods but forgetting to update the others.</li>
<li class="last-item">
 <p> Each document part needs to know every possible output format. </p> 
</li>
</ul>
 <p> These problems can be solved with the <strong>visitor pattern</strong>. </p> 
<h2 id="the-visitor-pattern">The Visitor Pattern</h2>
 <p> The visitor pattern consists of two parts: </p> 
<ul>
<li class="first-item">a method called <code>Visit()</code> which is implemented by the <strong>visitor</strong> and is called for every element in the data structure</li>
<li class="last-item">
 <p> <strong>visitable</strong> classes providing <code>Accept()</code> methods that accept a visitor </p> 
</li>
</ul>
<h3 id="visitor.3A-convert-to-html">Visitor: Convert To HTML</h3>
 <p> Let&#8217;s start with the <strong>visitor</strong>. As example, we&#8217;re going to implement the &#8220;convert to html&#8221; operation. </p> 
 <p> For this, we need to define an interface called <code>IVisitor</code>: </p> 
<pre class="code">public interface IVisitor {
  void Visit(PlainText docPart);
  void Visit(BoldText docPart);
  void Visit(Hyperlink docPart);
}</pre>
 <p> Then we implement to HTML conversion: </p> 
<pre class="code">public class HtmlVisitor : IVisitor {
  public string Output { 
    get { return this.m_output; }
  }
  private string m_output = &quot;&quot;;

  public void Visit(PlainText docPart) {
    this.Output += docPart.Text;
  }

  public void Visit(BoldText docPart) {
    this.m_output += &quot;&lt;b&gt;&quot; + docPart.Text + &quot;&lt;/b&gt;&quot;;
  }

  public void Visit(Hyperlink docPart) {
    this.m_output += &quot;&lt;a href=\&quot;&quot; + docPart.Url + &quot;\&quot;&gt;&quot; + docPart.Text + &quot;&lt;/a&gt;&quot;;
  }
}</pre>
<h3 id="visitable.3A-the-document-structure">Visitable: The Document Structure</h3>
 <p> By applying the visitor pattern to our document classes, they change to this: </p> 
<pre class="code">public abstract class DocumentPart {
  public string Text { get; private set; }
  public abstract void Accept(IVisitor visitor);
}

public class PlainText : DocumentPart { 
  public override void Accept(IVisitor visitor) {
    visitor.Visit(this);
  }
}

public class BoldText : DocumentPart { 
  public override void Accept(IVisitor visitor) {
    visitor.Visit(this);
  }
}

public class Hyperlink : DocumentPart {
  public string Url { get; private set; }

  public override void Accept(IVisitor visitor) {
    visitor.Visit(this);
  }
}

public class Document {
  private List&lt;DocumentPart&gt; m_parts;

  public void Accept(IVisitor visitor) {
    foreach (DocumentPart part in this.m_parts) {
      part.Accept(visitor);
    }
  }
}</pre>
 <p> <em>Note:</em> The implementations of <code>Accept()</code> seem to be identical for all child classes of <code>DocumentPart</code>. However, we can&#8217;t move the code into the base class because <code>IVisitor</code> doesn&#8217;t have an method <code>Visit(DocumentPart)</code> but only for the concrete implementations. (We could solve this through reflection, though, but would lose compile-time checking.) </p> 
<h3 id="putting-it-all-together">Putting It All Together</h3>
 <p> Now, to convert a document to HTML we can use this code: </p> 
<pre class="code">Document doc = ...;
HtmlVisitor visitor = new HtmlVisitor();
doc.Accept(visitor);
Console.WriteLine(&quot;Html:\n&quot; + visitor.Output);</pre>
 <p> To convert the document into LaTeX, we&#8217;d need to implement a <code>LatexVisitor</code>: </p> 
<pre class="code">public class LatexVisitor : IVisitor {
  public string Output { 
    get { return this.m_output; }
  }
  private string m_output = &quot;&quot;;

  public void Visit(PlainText docPart) {
    this.Output += docPart.Text;
  }

  public void Visit(BoldText docPart) {
    this.m_output += &quot;\\textbf{&quot; + docPart.Text + &quot;}&quot;;
  }

  public void Visit(Hyperlink docPart) {
    this.m_output += &quot;\\href{&quot; + docPart.Url + &quot;}{&quot; + docPart.Text + &quot;}&quot;;
  }
}</pre>
 <p> The implementation of the actual document classes remain unchanged. </p> 
 <p> <em>Side note:</em> If you&#8217;re wondering whether <code>Accept</code> is a good name or whether the method should be renamed (e.g. to <code>Convert</code>): Check whether operations other than conversions are possible. For example, one could implement a <code>BoldTextCountVisitor</code> or a <code>UrlExtractorVisitor</code>. If such operations are possible, you should stick with the name <code>Accept</code> &#8211; as this communicates that the visitor pattern is being used here. </p> 
<h2 id="the-actual-problem-being-solved">The Actual Problem Being Solved</h2>
 <p> If you&#8217;re not into theory, you can skip this part. It explains the formal problem the visitor pattern solves: something called <strong>double dispatch</strong>.  </p> 
 <p> Now, what&#8217;s that? </p> 
<h3 id="single-dispatch">Single Dispatch</h3>
 <p> Most (all?) OOP programming languages support <strong>single dispatch</strong>, more commonly known as <strong>virtual methods</strong>. For example, consider the following code: </p> 
<pre class="code">public class SpaceShip { 
  public virtual string GetShipType() {
    return &quot;SpaceShip&quot;;
  }
}

public class ApolloSpacecraft : SpaceShip { 
  public virtual string GetShipType() {
    return &quot;ApolloSpacecraft&quot;;
  }
}</pre>
 <p> Now, execute this code: </p> 
<pre class="code">SpaceShip ship = new ApolloSpacecraft();
Console.WriteLine(ship.GetShipType());</pre>
 <p> This will print &#8220;ApolloSpacecraft&#8221;. The actual method implementation to be called is chosen <strong>at runtime</strong> based solely on the actual type of <code>ship</code>. So, only the type of a <em>single</em> object is used to select the method, hence the name <em>single</em> dispatch. </p> 
 <p> <em>Note:</em> &#8220;Single dispatch&#8221; is one form of &#8220;dynamic dispatch&#8221;, i.e. the method is chosen at runtime. If the method is chosen at compile time (true for all non-virtual methods), it&#8217;s called &#8220;static dispatch&#8221;. </p> 
<h3 id="double-dispatch">Double Dispatch</h3>
 <p> Let&#8217;s add some asteroids: </p> 
<pre class="code">public class Asteroid {
  public virtual void CollideWith(SpaceShip ship) {
    Console.WriteLine(&quot;Asteroid hit a SpaceShip&quot;);
  }
  public virtual void CollideWith(ApolloSpacecraft ship) {
    Console.WriteLine(&quot;Asteroid hit an ApolloSpacecraft&quot;);
  }
};
 
public class ExplodingAsteroid : Asteroid {
  public override void CollideWith(SpaceShip ship) {
    Console.WriteLine(&quot;ExplodingAsteroid hit a SpaceShip&quot;);
  }
  public override void CollideWith(ApolloSpacecraft ship) {
    Console.WriteLine(&quot;ExplodingAsteroid hit an ApolloSpacecraft&quot;);
  }
};</pre>
 <p> With this, let&#8217;s execute some more code. With: </p> 
<pre class="code">Asteroid theAsteroid = new Asteroid();
ExplodingAsteroid theExplodingAsteroid = new ExplodingAsteroid();
SpaceShip theSpaceShip = new SpaceShip();
ApolloSpacecraft theApolloSpacecraft = new ApolloSpacecraft();</pre>
 <p> this code: </p> 
<pre class="code">theAsteroid.CollideWith(theSpaceShip); 
theAsteroid.CollideWith(theApolloSpacecraft);
theExplodingAsteroid.CollideWith(theSpaceShip); 
theExplodingAsteroid.CollideWith(theApolloSpacecraft);</pre>
 <p> will print: </p> 
<pre class="code">Asteroid hit a SpaceShip
Asteroid hit an ApolloSpacecraft
ExplodingAsteroid hit a SpaceShip
ExplodingAsteroid hit an ApolloSpacecraft</pre>
 <p> Everything is as expected. Now, consider this code: </p> 
<pre class="code">// Note the different data types!
Asteroid theExplodingAsteroidRef = new ExplodingAsteroid();
SpaceShip theApolloSpacecraftRef = new ApolloSpacecraft();
theExplodingAsteroidRef.CollideWith(theApolloSpacecraftRef);</pre>
 <p> The desired result here would be &#8220;ExplodingAsteroid hit an <em>ApolloSpacecraft</em>&#8221; but instead we get &#8220;ExplodingAsteroid hit a <em>SpaceShip</em>&#8220;. </p> 
 <p> The problem is that C# (and Java, C++, &#8230;) only supports single dispatch, but not double dispatch. The method chosen is <strong>only</strong> based on <code>theExplodingAsteroidRef</code>, but not on <code>theExplodingAsteroidRef</code> <strong>and</strong> <code>theApolloSpacecraftRef</code> (which would be double dispatch). </p> 
<h2 id="not-actually-solved-problem.3A-iterators">Not Actually Solved Problem: Iterators</h2>
 <p> Many pages on the internet associate the visitor pattern with traversing some data structure, usually a tree or hierarchy. </p> 
 <p> This got me totally confused because at first I couldn&#8217;t figure out <strong>what&#8217;s the difference between the visitor pattern and the iterator pattern</strong>. </p> 
 <p> The point here is: The main goal of the visitor pattern is to solve the double dispatch problem. Solving the iterator pattern is only a byproduct. If you&#8217;re just look for a way to iterate a data structure, the iterator pattern may be a better alternative instead. </p> 
 <p> Suppose you have this class: </p> 
<pre class="code">// List of ints
public class MyList : IVisitable, IEnumerable {
  private List&lt;int&gt; m_list;
  public Enumerator GetEnumerator() { ... } // iterator pattern
  public void Accept(IVisitor visitor) { ... } // visitor pattern
}</pre>
 <p> Now, you want to calculate the sum of all integers in the list. </p> 
 <p> You can do this either by using the <strong>iterator pattern</strong>: </p> 
<pre class="code">IEnumerable myList = new MyList(...);

int sum = 0;
foreach (int value in myList) {
  sum += value;
}

Console.WriteLine(&quot;Sum: &quot; + sum);</pre>
 <p> Or you can do this by using the <strong>visitor pattern</strong>: </p> 
<pre class="code">IVisitable myList = new MyList(...);

IVisitor visitor = new SumVisitor();
myList.Accept(visitor);

Console.WriteLine(&quot;Sum: &quot; + visitor.Sum);</pre>
<h2 id="issues">Issues</h2>
 <p> There are some issues (or problems) with the visitor pattern. </p> 
<h3 id="iteration-order">Iteration Order</h3>
 <p> One problem is the iteration order. </p> 
 <p> For example, if you define a visitor pattern on a tree, the iteration may be depth-first or breadth-first. </p> 
 <p> So, if you have some operation (visitor) that requires a certain iteration order, you <em>may</em> have a problem. </p> 
 <p> For example, you could implement the visitor pattern for saving a data structure to disk where each visitor represents a different file format. This would allow you to easily add new file formats later. However, this only works as long as all file formats store the data <strong>in the same order</strong>. If two formats require different orders, this pattern doesn&#8217;t work anymore. </p> 
<h3 id="new-visitables">New Visitables</h3>
 <p> If you add new visitable, you need to update every visitor that&#8217;s already implemented. </p> 
 <p> Let&#8217;s take our document classes from <a href="#object_structure">above</a>. We had the classes <code>PlainText</code>, <code>BoldText</code>, and <code>Hyperlink</code>.  </p> 
 <p> Now, let&#8217;s say we want to add a class for underlined text. The interface <code>IVisitor</code> would thus change to: </p> 
<pre class="code">public interface IVisitor {
  void Visit(PlainText docPart);
  void Visit(BoldText docPart);
  void Visit(Hyperlink docPart);
  void Visit(UnderlinedText docPart); // added
}</pre>
 <p> Due to this change we would also need to update all visitors we&#8217;ve already implemented. We could use reflection to solve (or just hide) the problem but in the end the visitor pattern <strong>works best on data structures that don&#8217;t change</strong>. </p> 
<h3 id="access-to-private-members">Access to Private Members</h3>
 <p> There&#8217;s another issue when the visitors need access to private data of the visitables. </p> 
 <p> To stick with the visitor pattern, you may be force to make this data public, even though it&#8217;s not supposed to be public, thereby breaking the principle of information hiding. </p> 
<h2 id="summary">Summary</h2>
 <p> The visitor pattern is a relatively complicated pattern. </p> 
 <p> <strong>Design goal:</strong> Separate operations from the data structures they work on. As a nice side effect, this allows you to add operations to data structures that you can&#8217;t change (maybe because you lost the source code for them). </p> 
 <p> <strong>You need:</strong> </p> 
<ul>
<li class="first-item"><code>IVisitor</code> (the operation) providing a <code>Visit()</code> method for each visitable class; needs to be implemented by every visitor.</li>
<li class="last-item">
 <p> <code>IVisitable</code> providing an <code>Accept(Visitor)</code> method; needs to be implemented by every visitable class. </p> 
</li>
</ul>
 <p> <strong>Issues:</strong> </p> 
<ul>
<li class="first-item">Difference to iterator pattern sometimes a little fuzzy.</li>
<li>Iteration order can&#8217;t be controlled.</li>
<li>Adding or removing visitables requires you to update all visitors.</li>
<li class="last-item">
 <p> Visitor implementations may be in conflict with the principle of information hiding. </p> 
</li>
</ul>
 <p> <strong>Real world examples:</strong> </p> 
<ul>
<li class="first-item">Converting a data structure into different output formats. Compilers are a good example for this.</li>
<li class="last-item">
 <p> Implementing drawing code for some scene graph/map structure on different platforms (e.g. OpenGL vs. DirectX). </p> 
</li>
</ul>
 <p> <a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=274673" rel="tag" style="display:none">CodeProject</a> </p> 
<img src="http://feeds.feedburner.com/~r/ManskisBlog/~4/Q2VMiBzm6lU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://manski.net/2013/05/the-visitor-pattern-explained/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://manski.net/2013/05/the-visitor-pattern-explained/</feedburner:origLink></item>
		<item>
		<title>Windows Setup, Boot Manager, And Multiple Disks</title>
		<link>http://feedproxy.google.com/~r/ManskisBlog/~3/9Pq1ypgEatE/</link>
		<comments>http://manski.net/2013/05/windows-setup-boot-manager-and-multiple-disks/#comments</comments>
		<pubDate>Fri, 17 May 2013 13:09:03 +0000</pubDate>
		<dc:creator>Sebastian Krysmanski</dc:creator>
				<category><![CDATA[Annoyances]]></category>
		<category><![CDATA[Articles]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[boot manager]]></category>
		<category><![CDATA[partitions]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://manski.net/?p=3376</guid>
		<description><![CDATA[Although Windows Setup has evolved since the days of Windows 95, it sometimes is still a real pain in the ass. Today, I spent the whole morning figuring out why Windows Setup always placed the Windows boot manager on a separate drive &#8211; and not on the drive I was installing Windows onto. The &#8220;easiest&#8221; [...]]]></description>
				<content:encoded><![CDATA[ <p>  <!-- Cached "rss-item" item from 2013-05-17 13:35:23 --> Although Windows Setup has evolved since the days of Windows 95, it sometimes is still a real pain in the ass. </p> 
 <p> Today, I spent the whole morning figuring out why Windows Setup always placed the Windows boot manager on a separate drive &#8211; and not on the drive I was installing Windows onto. </p> 
 <p> The &#8220;easiest&#8221; solution would be to unplug all other drives, install Windows, and then replug all drives. But since I&#8217;m a engineer I wanted to find out the real cause of the problem. </p> 
 <p> Turns out, the root problem is the BIOS&#8217; <strong>boot order</strong> (a.k.a. <strong>boot sequence</strong>). A computer&#8217;s BIOS has a boot order list which basically defines from which device (hard disk, CD drive) to boot. If the BIOS can&#8217;t boot from the first device, it tries the second one, and so on.  </p> 
 <p> The BIOS usually lets you define this order. Either all devices are in one big list, or each device type (CD drives, hard disks) has its own list. </p> 
<div class="align-center image-align-center"><a href="http://manski.net/wordpress/wp-content/uploads/2013/05/boot-order.jpg" rel="attachment" title="Example of a boot order menu item in a BIOS"><img class="wp-post-image" src="http://manski.net/wordpress/wp-content/plugins/blogtext/api/thumbnail/do.php?id=e3601564192e0899e30c47f928b64aba0f781287_300x300_resize_if_larger" title="Example of a boot order menu item in a BIOS" alt="Example of a boot order menu item in a BIOS" width="300" height="165"/></a></div>
 <p> Now, when you install Windows, the setup asks the BIOS for this list. And no matter what you do, Windows Setup will <strong>always install the boot manager on the first hard disk</strong> in this boot order list. </p> 
 <p> In particular, the disk on which you want to install Windows has <em>no influence</em> on where the boot manager is being installed. </p> 
 <p> So, the only way to influence the location of the boot manager is to change to boot order in the BIOS. </p> 
 <p> <em>Side note:</em> New devices are usually added to the end of the boot order list. So if you have multiple hard drives and replace one (e.g. because the old one was broken or too small), the new drive may end up at the <em>end</em> of the list &#8211; and not at the position where the replaced drive was before; thus messing up the boot order. </p> 
<h2 id="determining-the-boot-manager-partition">Determining the Boot Manager Partition</h2>
 <p> So, how can one determine the location of where boot manager is installed? </p> 
<h3 id="from-windows-setup">From Windows Setup</h3>
 <p> Determining on which drive Windows Setup will install the boot manager onto is almost impossible from Windows Setup itself.  </p> 
 <p> The only <em>hint</em> you get, is if: </p> 
<ul>
<li class="first-item">your installation disk has no partitions (i.e. is empty) &#8230;</li>
<li class="last-item">
 <p> .. and then you can create a partition on this disk. </p> 
</li>
</ul>
 <p> In this case Windows Setup will show you a dialog reading: </p> 
<blockquote> <p>  To ensure that all Windows features work correctly, Windows might create additional partitions for system  files.
 </p> </blockquote>
 <p> If this happens and you click on &#8220;OK&#8221;, Windows Setup will automatically create a partition called &#8220;System Reserved&#8221; where it&#8217;ll install the boot manager. </p> 
<div class="align-center image-align-center"><a href="http://manski.net/wordpress/wp-content/uploads/2013/05/boot-manager-in-windows-setup.jpg" rel="attachment" title="boot-manager-in-windows-setup.jpg"><img class="wp-post-image" src="http://manski.net/wordpress/wp-content/plugins/blogtext/api/thumbnail/do.php?id=3113a496febe218e56b7cbd7ad1055168e9e360a_300x300_resize_if_larger" title="boot-manager-in-windows-setup.jpg" alt="boot-manager-in-windows-setup.jpg" width="300" height="227"/></a></div>
 <p> If this doesn&#8217;t happen the boot manager may or may not be installed in the correct location. If this is the case, you can only check the location <em>after</em> Windows has been installed. </p> 
<h3 id="from-windows">From Windows</h3>
 <p> To determine the partition where the boot manager is installed, go to: </p> 
<p class="indented"><strong>Control Panel</strong> > <strong>Administrative Tools</strong> > <strong>Computer Management</strong> > <strong>Disk Management</strong> </p> 
 <p> The partition where the boot manager is installed has the word <strong>System</strong> in its status. </p> 
<div class="align-center image-align-center"><a href="http://manski.net/wordpress/wp-content/uploads/2013/05/sytem-partition.jpg" rel="attachment" title="sytem-partition.jpg"><img class="wp-post-image" src="http://manski.net/wordpress/wp-content/plugins/blogtext/api/thumbnail/do.php?id=64c2200224577da624cd6f1599e58b0895fc59b2_300x300_resize_if_larger" title="sytem-partition.jpg" alt="sytem-partition.jpg" width="300" height="89"/></a></div>
<img src="http://feeds.feedburner.com/~r/ManskisBlog/~4/9Pq1ypgEatE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://manski.net/2013/05/windows-setup-boot-manager-and-multiple-disks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://manski.net/2013/05/windows-setup-boot-manager-and-multiple-disks/</feedburner:origLink></item>
		<item>
		<title>Windows Update Progress Bar Fail</title>
		<link>http://feedproxy.google.com/~r/ManskisBlog/~3/HdhAS4IAxcI/</link>
		<comments>http://manski.net/2013/05/windows-update-progress-bar-fail/#comments</comments>
		<pubDate>Wed, 15 May 2013 12:55:11 +0000</pubDate>
		<dc:creator>Sebastian Krysmanski</dc:creator>
				<category><![CDATA[Annoyances]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[progress bar]]></category>
		<category><![CDATA[user interface]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[windows 7]]></category>
		<category><![CDATA[windows update]]></category>

		<guid isPermaLink="false">http://manski.net/?p=3371</guid>
		<description><![CDATA[If you have some progress you can use a progress bar to show this progress. So, if you copy some files and have already copied about 60%, you may see something like this: Knowing this, what&#8217;s wrong with this image? Why the heck do I get an indeterminate progress bar for a download progress. Hell, [...]]]></description>
				<content:encoded><![CDATA[ <p>  <!-- Cached "rss-item" item from 2013-05-15 12:55:35 --> If you have some progress you can use a progress bar to show this progress. </p> 
 <p> So, if you copy some files and have already copied about 60%, you may see something like this: </p> 
<div class="align-center image-align-center"><img class="wp-post-image" src="http://manski.net/wordpress/wp-content/uploads/2013/05/progressbar.jpg" title="Progress bar showing copy progress of some files" alt="Progress bar showing copy progress of some files"/></div>
 <p> Knowing this, what&#8217;s wrong with this image? </p> 
<div class="align-center image-align-center"><img class="wp-post-image" src="http://manski.net/wordpress/wp-content/uploads/2013/05/ui-progressbar-fail.jpg" title="Indeterminate progress bar on download progress in Windows Update" alt="Indeterminate progress bar on download progress in Windows Update"/></div>
 <p> Why the heck do I get an indeterminate progress bar for a download progress. Hell, there&#8217;s even a percentage displayed for the download. </p> 
<img src="http://feeds.feedburner.com/~r/ManskisBlog/~4/HdhAS4IAxcI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://manski.net/2013/05/windows-update-progress-bar-fail/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://manski.net/2013/05/windows-update-progress-bar-fail/</feedburner:origLink></item>
		<item>
		<title>Extending Wi-Fi networks (with AirPort Express)</title>
		<link>http://feedproxy.google.com/~r/ManskisBlog/~3/4ipPQB9_jxQ/</link>
		<comments>http://manski.net/2013/05/extending-wi-fi-networks-with-airport-express/#comments</comments>
		<pubDate>Wed, 01 May 2013 06:35:22 +0000</pubDate>
		<dc:creator>Sebastian Krysmanski</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[access points]]></category>
		<category><![CDATA[airport]]></category>
		<category><![CDATA[airport express]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[wi-fi]]></category>
		<category><![CDATA[wlan]]></category>

		<guid isPermaLink="false">http://manski.net/?p=3318</guid>
		<description><![CDATA[I recently bought an Apple AirPort Express Base Station so that I can hear music without powering up my computer. And since the AirPort Express is a full-fledged Wi-Fi access point, I thought it&#8217;d be nice to use it to extend the range of my existing Wi-Fi network. With Apple&#8217;s AirPort Utility, configuring an AirPort [...]]]></description>
				<content:encoded><![CDATA[ <p>  <!-- Cached "rss-item" item from 2013-05-01 06:35:41 --> I recently bought an Apple AirPort Express Base Station so that I can hear music without powering up my computer. And since the AirPort Express is a full-fledged Wi-Fi access point, I thought it&#8217;d be nice to use it to extend the range of my existing Wi-Fi network. </p> 
 <p> With Apple&#8217;s <em>AirPort Utility</em>, configuring an AirPort Express Base Station is quite easy. There are, however, some pitfalls when trying to extend an existing Wi-Fi network. So I&#8217;m going to shed some light on this topic in this blog post. I&#8217;ll be using my AirPort Express Base Station to illustrate these pitfalls but the information should apply to any other Wi-Fi access point as well. </p> 
 <p> <span id="more-3318"></span> </p> 
<h2 id="extending-wi-fi-networks-over-wi-fi-.28repeater.29">Extending Wi-Fi networks over Wi-Fi (repeater)</h2>
 <p> In the &#8220;Wireless&#8221; section, the AirPort Utility gives you an option called &#8220;Extend a wireless network&#8221;. This option allows you to extend an existing Wi-Fi network. (Who would have guessed?) </p> 
<div class="align-center image-align-center"><a href="http://manski.net/wordpress/wp-content/uploads/2013/05/extend-network.jpg" rel="attachment" title="extend-network.jpg"><img class="wp-post-image" src="http://manski.net/wordpress/wp-content/plugins/blogtext/api/thumbnail/do.php?id=752b1d8e79c2fd7aaa38a763eaebf6eb25625f47_300x300_resize_if_larger" title="extend-network.jpg" alt="extend-network.jpg" width="300" height="283"/></a></div>
 <p> The catch here is, though, that this will <strong>extend your Wi-Fi network over Wi-Fi</strong>. So, the AirPort Express Base Station will communicate with your other access point(s) over Wi-Fi. It&#8217;ll become a <strong>repeater</strong>. </p> 
 <p> The advantage is that you don&#8217;t need any cables to extend the range of your network. The disadvantage is that this will reduce your wireless bandwidth (by 50% in the worst case). While this will probably have no real effect on your surfing speed, the speed of copying files from one computer to another will be drastically reduced. </p> 
<h2 id="extending-wi-fi-networks-over-ethernet-.28roaming.29">Extending Wi-Fi networks over Ethernet (roaming)</h2>
 <p> Fortunately, there is an alternative: <strong>extending Wi-Fi networks over Ethernet (cables)</strong>. This is called <em>roaming</em> and has existed since the earliest days of Wi-Fi. </p> 
 <p> For the AirPort Express Base Station (and maybe other Wi-Fi access points as well) there are three things you need to know: </p> 
<ol>
<li class="first-item">In &#8220;Wireless&#8221; section, don&#8217;t use &#8220;Extend a wireless network&#8221;! Instead, use <strong>&#8220;Create a wireless network&#8221;</strong> and enter the same SSID and Wi-Fi encryption as the network you&#8217;re extending. <br /> 
Background info: If a computer finds multiple Wi-Fi networks with the same SSID, it&#8217;ll assume they represent the same network. It&#8217;ll then pick the one that&#8217;s best suited (usually the one with the best signal strength).</li>
<li>
<div class="align-right image-align-right"><a href="http://manski.net/wordpress/wp-content/uploads/2013/05/bridge-mode.jpg" rel="attachment" title="bridge-mode.jpg"><img class="wp-post-image" src="http://manski.net/wordpress/wp-content/plugins/blogtext/api/thumbnail/do.php?id=2a93e56274b337951cfcaa03f1471808d2c5a561_150x150_crop" title="bridge-mode.jpg" alt="bridge-mode.jpg" width="150" height="150"/></a></div>
 <p> In the &#8220;Network&#8221; section, you need to <strong>set &#8220;Router Mode&#8221; to &#8220;Off (Bridge Mode)&#8221;</strong>.</li>
<li class="last-item">
<div class="align-right image-align-right"><a href="http://manski.net/wordpress/wp-content/uploads/2013/04/Airport_Express_Ports.jpg" rel="attachment" title="Image by Fletcher6 (http://en.wikipedia.org/wiki/File:Airport_Express_Ports_%282012%29.jpg); licensed under Creative Commons Attribution-Share Alike 3.0"><img class="wp-post-image" src="http://manski.net/wordpress/wp-content/plugins/blogtext/api/thumbnail/do.php?id=fcba91e0d8c7e7fa937e1ee49d1a0481390054bb_150x150_crop" title="Image by Fletcher6 (http://en.wikipedia.org/wiki/File:Airport_Express_Ports_%282012%29.jpg); licensed under Creative Commons Attribution-Share Alike 3.0" alt="Image by Fletcher6 (http://en.wikipedia.org/wiki/File:Airport_Express_Ports_%282012%29.jpg); licensed under Creative Commons Attribution-Share Alike 3.0" width="150" height="150"/></a></div>
 <p> You need to plug your Ethernet cable into the <strong>WAN port</strong> &#8211; not the Ethernet port. <br /> 
Note: I&#8217;ve only tested this with an AirPort Express Base Station of the second generation. As far as I understand it, on the first generation you need to plug your Ethernet cable into the (only-existing) Ethernet port instead. </p> 
</li>
</ol>
<h2 id="wi-fi-channels">Wi-Fi channels</h2>
 <p> Most modern Wi-Fi access points can choose their Wi-Fi channels automatically and you should usually let them do this. </p> 
 <p> However, if you really want to manually select the Wi-Fi channels, use <strong>different channels</strong> for each access point (if possible). Computers recognize Wi-Fi networks by their SSIDs, not by the channel they use. </p> 
<h2 id="the-5-ghz-band">The 5 GHz band</h2>
 <p> Wi-Fi channels are selected from a so called &#8220;frequency band&#8221;. All access points support the 2.4 GHz band, while most newer access points also support the new 5 GHz band.  </p> 
 <p> The advantage of the 5 GHz band is that it&#8217;s (currently) less crowded. So, Wi-Fi speed is usually higher in the 5 GHz band than in the 2.4 GHz band. </p> 
 <p> Not all Wi-Fi access points can use both bands at the same time. The AirPort Express Base Station (2nd generation), for example, does support this, while my FritzBox 7270 only supports <em>either</em> 2.4 or 5 GHz (but not both at the same time). </p> 
 <p> If your access point support both bands at the same time, use the same SSID for both (if you have the option to choose). This helps on devices where you can&#8217;t prioritize your Wi-Fi networks (like on iOS or Android) to always pick the 5 GHz band. </p> 
 <p> You should also know that only the newest (at the time of writing) and more expensive devices support the 5 GHz band. For example, only the iPhone 5 supports the 5 GHz band while all older iPhones do not. Also, most cheap notebooks don&#8217;t support 5 GHz either. </p> 
<h2 id="links">Links</h2>
 <p> This article is mostly based on my own experience as well as the following links: </p> 
<ul>
<li class="first-item"><a href="http://superuser.com/q/122441/92893" target="_blank">Multiple access points for the same SSID?</a></li>
<li class="last-item">
 <p> <a href="http://superuser.com/q/362366/92893" target="_blank">Does it make sense to keep different SSIDs for 2.4GHz and 5GHz wireless networks?</a> </p> 
</li>
</ul>
 <p> Also, very helpful is the <a href="http://support.apple.com/kb/HT4600" target="_blank">AirPort base station status lights (LED) listing</a> from Apple, if you want to know what the color and state of your AirPort&#8217;s LED means. </p> 
<img src="http://feeds.feedburner.com/~r/ManskisBlog/~4/4ipPQB9_jxQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://manski.net/2013/05/extending-wi-fi-networks-with-airport-express/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://manski.net/2013/05/extending-wi-fi-networks-with-airport-express/</feedburner:origLink></item>
		<item>
		<title>File Download Script for Visual Studio</title>
		<link>http://feedproxy.google.com/~r/ManskisBlog/~3/bTAy6Waw46Q/</link>
		<comments>http://manski.net/2013/04/file-download-script-for-visual-studio/#comments</comments>
		<pubDate>Thu, 18 Apr 2013 12:43:20 +0000</pubDate>
		<dc:creator>Sebastian Krysmanski</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Manski's Toolbox]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://manski.net/?p=3290</guid>
		<description><![CDATA[If you have some binary files you need for your Visual Studio project but you don&#8217;t want to add them to your version control system, here&#8217;s a PowerShell script that does the downloading for you: download.ps1 Basically this mimics a very simple dependency management. Source Repository: https://bitbucket.org/mayastudios/powershell-downloader/ Configuration At the very top of the script, [...]]]></description>
				<content:encoded><![CDATA[ <p>  <!-- Cached "rss-item" item from 2013-04-30 12:15:02 --> 
<div class="align-right image-align-right"><a href="http://manski.net/wordpress/wp-content/uploads/2013/04/download-progress-dialog.png" rel="attachment" title="download-progress-dialog.png"><img class="wp-post-image" src="http://manski.net/wordpress/wp-content/plugins/blogtext/api/thumbnail/do.php?id=5dd51a43ed53bc4961fc1a09024c081e16ac8d31_150x150_crop" title="download-progress-dialog.png" alt="download-progress-dialog.png" width="150" height="150"/></a></div>
 <p> If you have some binary files you need for your Visual Studio project but you don&#8217;t want to add them to your version control system, here&#8217;s a PowerShell script that does the downloading for you: </p> 
<p class="indented"><strong><a href="https://bitbucket.org/mayastudios/powershell-downloader/raw/dcc769df290f1e486bdb34d92557bf7e4327001a/libs/download.ps1" target="_blank">download.ps1</a></strong> </p> 
 <p> Basically this mimics a very simple dependency management. </p> 
 <p> Source Repository: <a href="https://bitbucket.org/mayastudios/powershell-downloader/" target="_blank">https://bitbucket.org/mayastudios/powershell-downloader/</a> </p> 
<h2 id="configuration">Configuration</h2>
 <p> At the very top of the script, you define which files to download where. </p> 
 <p> For example, this downloads the x86 and the x64 version of a SQLite <code>.dll</code> file: </p> 
<pre class="code">$base_url = 'https://mydomain.com/sqlite'
$files = @{
  '..\sqlite.dll' = &quot;$base_url/x86/sqlite.dll&quot;
  '..\sqlite_x64.dll' = &quot;$base_url/x64/sqlite_x64.dll&quot;
}</pre>
 <p> Entries must be separated by line breaks or semicolon (<code>;</code>). </p> 
 <p> Paths are relative to the location of the script file. </p> 
<h2 id="usage">Usage</h2>
 <p> To include the script in your project, call it from your project&#8217;s <strong>Pre-build event</strong>. </p> 
 <p> For example, if you&#8217;ve placed <code>download.ps1</code> in a folder called <code>libs</code> in your project, use this line to execute it: </p> 
<pre class="code">powershell -ExecutionPolicy ByPass -File &quot;$(ProjectDir)\libs\download.ps1&quot;</pre>
 <p> That&#8217;s it. </p> 
<h2 id="when-does-it-download">When Does It Download</h2>
 <p> The script will download the files if: </p> 
<ul>
<li class="first-item">they don&#8217;t exist</li>
<li>the script file is newer as the files (idea behind this: you&#8217;ve changed the file version to download)</li>
<li class="last-item">
 <p> a file named <code>force-download.txt</code> exists in the scripts folder and this file contains anything else but &#8220;false&#8221; </p> 
</li>
</ul>
 <p> These rules are defined in the <code>Needs-Downloading</code> function. </p> 
<img src="http://feeds.feedburner.com/~r/ManskisBlog/~4/bTAy6Waw46Q" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://manski.net/2013/04/file-download-script-for-visual-studio/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://manski.net/2013/04/file-download-script-for-visual-studio/</feedburner:origLink></item>
		<item>
		<title>File Path in Spotlight on OS X</title>
		<link>http://feedproxy.google.com/~r/ManskisBlog/~3/e35Oz29kFbo/</link>
		<comments>http://manski.net/2013/03/file-path-in-spotlight-on-os-x/#comments</comments>
		<pubDate>Sun, 24 Mar 2013 17:19:01 +0000</pubDate>
		<dc:creator>Sebastian Krysmanski</dc:creator>
				<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[spotlight]]></category>

		<guid isPermaLink="false">http://manski.net/?p=3300</guid>
		<description><![CDATA[When you click a search result in Spotlight, the item will open with its default program. But what if you want to know the file&#8217;s path instead of opening it? Here&#8217;s how: Hold down ⌘ + ⌥ to reveal the file&#8217;s path below the preview box appearing to the left of the search result list. [...]]]></description>
				<content:encoded><![CDATA[ <p>  <!-- Cached "rss-item" item from 2013-03-24 17:29:04 --> When you click a search result in Spotlight, the item will open with its default program.  </p> 
 <p> But what if you want to know the file&#8217;s path instead of opening it? Here&#8217;s how: </p> 
<ul>
<li class="first-item">Hold down <kbd>⌘</kbd> + <kbd>⌥</kbd> to reveal the file&#8217;s path below the preview box appearing to the left of the search result list.</li>
<li class="last-item">
 <p> <kbd>⌘</kbd> + <strong>click</strong>, or <kbd>⌘</kbd> + <kbd>⏎</kbd>, to reveal the file in the Finder. </p> 
</li>
</ul>
<img src="http://feeds.feedburner.com/~r/ManskisBlog/~4/e35Oz29kFbo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://manski.net/2013/03/file-path-in-spotlight-on-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://manski.net/2013/03/file-path-in-spotlight-on-os-x/</feedburner:origLink></item>
		<item>
		<title>PowerShell functions for the uninitiated (C# programmer)</title>
		<link>http://feedproxy.google.com/~r/ManskisBlog/~3/I_pmFRCwwTY/</link>
		<comments>http://manski.net/2013/03/powershell-functions-for-the-uninitiated-c-programmer/#comments</comments>
		<pubDate>Mon, 18 Mar 2013 12:27:04 +0000</pubDate>
		<dc:creator>Sebastian Krysmanski</dc:creator>
				<category><![CDATA[Annoyances]]></category>
		<category><![CDATA[Articles]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[return values]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[wtf]]></category>

		<guid isPermaLink="false">http://manski.net/?p=3278</guid>
		<description><![CDATA[Being a C# programmer, I recently found some use for Microsoft&#8217;s PowerShell (the cmd replacement). What&#8217;s nice about PowerShell is that it has full access to the .NET framework. However, there are also some very pit falls when coming from C# (or any related programming language). There&#8217;s one very mean pit fall when it comes [...]]]></description>
				<content:encoded><![CDATA[ <p>  <!-- Cached "rss-item" item from 2013-03-18 12:52:03 --> Being a C# programmer, I recently found some use for Microsoft&#8217;s PowerShell (the <code>cmd</code> replacement). What&#8217;s nice about PowerShell is that it has full access to the .NET framework. </p> 
 <p> However, there are also some very pit falls when coming from C# (or any related programming language).  </p> 
 <p> There&#8217;s one very mean pit fall when it comes to <strong>functions and their return values</strong> that &#8211; if you don&#8217;t exactly know how PowerShell works &#8211; makes you pull out your hair. </p> 
 <p> <span id="more-3278"></span> </p> 
 <p> Assume this PowerShell code: </p> 
<pre class="code">function PrintAndReturnSomething {
  echo &quot;Hello, World&quot;
  return 42
}

$result = PrintAndReturnSomething</pre>
 <p> What do you expect <code>$result</code> to be? An integer with value <code>42</code>, right? Let&#8217;s check it out. </p> 
 <p> We&#8217;re adding the following line to the end of the script: </p> 
<pre class="code">echo (&quot;Return type: &quot; + $result.GetType().FullName)</pre>
 <p> Now, when you run the script, you&#8217;ll get: </p> 
<pre class="code">Return type: System.Object[]</pre>
 <p> <strong>Wait, what? Where&#8217;s the &#8220;Hello, World&#8221;? And why the heck is <code>$return</code> an object array?</strong> </p> 
 <p> The first problem (pit fall) is that PowerShell treats every non-captured object (i.e. one that isn&#8217;t assigned to a variable) as return value. </p> 
<h2 id="functions-return-everything-that-isn.27t-captured">Functions Return Everything That Isn&#8217;t Captured</h2>
 <p> Let&#8217;s have a look at a different script for a moment: </p> 
<pre class="code">function LongNumericString {
  $strBld = new-object System.Text.StringBuilder
  for ($i=0; $i -lt 20; $i++) {
    $strBld.Append($i)
  }
  return $strBld.ToString()
}</pre>
 <p> One would expect that <code>LongNumericString</code> returns just a string; but it doesn&#8217;t. Instead it returns an <code>object[]</code> with this contents: </p> 
<pre class="code">Capacity           MaxCapacity                        Length
——–                ———–                               ——
16                 2147483647                         1
16                 2147483647                         2
16                 2147483647                         3
16                 2147483647                         4
16                 2147483647                         5
16                 2147483647                         6
16                 2147483647                         7
16                 2147483647                         8
16                 2147483647                         9
16                 2147483647                        10
16                 2147483647                        12
16                 2147483647                        14
16                 2147483647                        16
32                 2147483647                        18
32                 2147483647                        20
32                 2147483647                        22
32                 2147483647                        24
32                 2147483647                        26
32                 2147483647                        28
32                 2147483647                        30
012345678910111213141516171819</pre>
 <p> The problem here is that <code>$strBld.Append</code> returns a <code>StringBuilder</code> object. And since this return value isn&#8217;t assigned to a variable, PowerShell considers it part of the return value. </p> 
 <p> To resolve this problem, prefix <code>$strBld.Append</code> with <code>[void]</code>: </p> 
<pre class="code">function LongNumericString {
  $strBld = new-object System.Text.StringBuilder
  for ($i=0; $i -lt 20; $i++) {
    [void]$strBld.Append($i)
  }
  return $strBld.ToString()
}</pre>
 <p> <strong>Note:</strong> The keyword <code>return</code> is totally optional. The expression <code>return $strBld.ToString()</code> is equivalent to <code>$strBld.ToString()</code>, and even to <code>$strBld.ToString(); return</code>. </p> 
<h2 id="function-return-values-.3D-function-output">Function Return Values = Function Output</h2>
 <p> Back to our initial script. Now that we know how PowerShell composes return values for functions, why didn&#8217;t <code>PrintAndReturnSomething</code> return just <code>42</code>? </p> 
 <p> One needs to understand that <strong>PowerShell doesn&#8217;t actually care about return value but rather about output of functions</strong>. The return value is just considered to be <em>a part</em> of the output. This way, PowerShell doesn&#8217;t just allow you to pipe text (like <code>ls -l | sort</code> in bash), but to <a href="http://technet.microsoft.com/en-us/library/ee176927.aspx" target="_blank">pipe actual objects</a>. </p> 
 <p> For example, <code>Get-ChildItem C:\ | Format-Table Name, Length</code> is the same as: </p> 
<pre class="code">$child_items = Get-ChildItem C:\
Format-Table -InputObject $child_items Name, Length</pre>
 <p> <code>PrintAndReturnSomething</code> uses <code>echo</code> (which is an alias for <code>Write-Output</code>) to print &#8220;Hello, World&#8221;. This is output and thus part of the function&#8217;s return value. </p> 
 <p> To force PowerShell to write something to the console (rather than including it in the return value), use <code>Write-Host</code> instead of <code>echo</code>. </p> 
 <p> The corrected code is: </p> 
<pre class="code">function PrintAndReturnSomething {
  Write-Host &quot;Hello, World&quot;
  return 42
}

$result = PrintAndReturnSomething
# Return is now a &quot;System.Int32&quot; with value 42.</pre>
<h2 id="summary">Summary</h2>
 <p> To sum things up: </p> 
<ul>
<li class="first-item">
<p class="no-margin">PowerShell functions will always return (as <code>object[]</code>, if there&#8217;s more than one return value): </p> 
<ul>
<li class="first-item">all uncaptured objects (i.e. objects that haven&#8217;t been assigned to variables)</li>
<li class="last-item">as well as all output (from <code>echo</code>/<code>Write-Output</code>)</li>
</ul>
</li>
<li class="last-item">
<p class="no-margin">Exclude from return value: </p> 
<ul>
<li class="first-item">Uncaptured objects: prefix with <code>[void]</code></li>
<li class="last-item">
 <p> Console output: use <code>Write-Host</code> instead of <code>echo</code>/<code>Write-Output</code> </p> 
</li>
</ul>
</li>
</ul>
<img src="http://feeds.feedburner.com/~r/ManskisBlog/~4/I_pmFRCwwTY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://manski.net/2013/03/powershell-functions-for-the-uninitiated-c-programmer/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://manski.net/2013/03/powershell-functions-for-the-uninitiated-c-programmer/</feedburner:origLink></item>
		<item>
		<title>Bug of the day: Acronis Drive Monitor</title>
		<link>http://feedproxy.google.com/~r/ManskisBlog/~3/gq8ifFdDNUU/</link>
		<comments>http://manski.net/2013/03/bug-of-the-day-acronis-drive-monitor/#comments</comments>
		<pubDate>Sat, 09 Mar 2013 15:29:01 +0000</pubDate>
		<dc:creator>Sebastian Krysmanski</dc:creator>
				<category><![CDATA[Annoyances]]></category>
		<category><![CDATA[Bug of the Day]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[external drive]]></category>
		<category><![CDATA[SMART]]></category>
		<category><![CDATA[usb]]></category>
		<category><![CDATA[usb 3]]></category>

		<guid isPermaLink="false">http://manski.net/?p=3274</guid>
		<description><![CDATA[Although the Acronis Drive Monitor is a handy tool for keeping taps on your hard drives&#8217; state, it also totally breaks USB 3.0 (at least on my Windows Server 2012). Acronis Drive Monitor comes with a service called &#8220;Acronis Scheduler2 Service&#8221;. As long as this service runs, it somehow breaks access to my external USB [...]]]></description>
				<content:encoded><![CDATA[ <p>  <!-- Cached "rss-item" item from 2013-03-09 15:29:28 --> Although the <a href="http://www.acronis.eu/homecomputing/products/drive-monitor/" target="_blank">Acronis Drive Monitor</a> is a handy tool for keeping taps on your hard drives&#8217; state, it also totally breaks USB 3.0 (at least on my Windows Server 2012). </p> 
<div class="align-center image-align-center"><a href="http://manski.net/wordpress/wp-content/uploads/2013/03/adm.jpg" rel="attachment" title="Acronis Drive Monitor main window"><img class="wp-post-image" src="http://manski.net/wordpress/wp-content/plugins/blogtext/api/thumbnail/do.php?id=212fe0c7e46ce1f4540047812992e3f7b7d22f9a_500x500_resize_if_larger" title="Acronis Drive Monitor main window" alt="Acronis Drive Monitor main window" width="500" height="421"/></a></div>
 <p> Acronis Drive Monitor comes with a service called <strong>&#8220;Acronis Scheduler2 Service&#8221;</strong>. As long as this service runs, it somehow breaks access to my external USB 3.0 drives. If I try to copy files to my external drive, the progress will freeze after a minute or so (together with a explorer window trying to access the external drive). </p> 
 <p> <strong>Solution:</strong> Stop the service (USB drives will start working again immediately), or uninstall Acronis Drive Monitor completely. </p> 
<img src="http://feeds.feedburner.com/~r/ManskisBlog/~4/gq8ifFdDNUU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://manski.net/2013/03/bug-of-the-day-acronis-drive-monitor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://manski.net/2013/03/bug-of-the-day-acronis-drive-monitor/</feedburner:origLink></item>
		<item>
		<title>How To Fix Multiple Items In The ‘Open With’ Menu in OS X</title>
		<link>http://feedproxy.google.com/~r/ManskisBlog/~3/hxp4nVl3r0Q/</link>
		<comments>http://manski.net/2013/02/how-to-fix-multiple-items-in-the-open-with-menu-in-os-x/#comments</comments>
		<pubDate>Fri, 22 Feb 2013 08:41:49 +0000</pubDate>
		<dc:creator>Sebastian Krysmanski</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[finder]]></category>
		<category><![CDATA[Mac OS X]]></category>

		<guid isPermaLink="false">http://manski.net/?p=3268</guid>
		<description><![CDATA[Did you ever get that annoying problem that in your &#8220;Open With&#8221; menu the same app shows multiple times? Fortunately, this is easy to fix. Just open up Terminal and paste in the following lines (all at once) to fix the problem! /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain system -domain user &#38;&#38; pkill Finder Cause [...]]]></description>
				<content:encoded><![CDATA[ <p>  <!-- Cached "rss-item" item from 2013-02-22 08:42:10 --> Did you ever get that annoying problem that in your &#8220;Open With&#8221; menu the same app shows multiple times?  </p> 
<div class="align-center image-align-center"><img class="wp-post-image" src="http://manski.net/wordpress/wp-content/uploads/2013/02/open-with-menu.jpg" title="Multiple items for the same app showing in OS X's &quot;Open With&quot; menu." alt="Multiple items for the same app showing in OS X's &quot;Open With&quot; menu."/></div>
 <p> Fortunately, this is easy to fix. Just open up Terminal and paste in the following lines (all at once) to fix the problem! </p> 
<pre class="code">/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain system -domain user &amp;&amp; pkill Finder</pre>
 <p> <em>Cause of the problem:</em> When you delete an application, its entry in the &#8220;Open With&#8221; menu is <em>not</em> deleted. This also applies to app updates, where the old version of the app is deleted and replaced by a new one (which gets its own menu entry). The problem probably only occurs for non-Mac App Store apps. </p> 
<img src="http://feeds.feedburner.com/~r/ManskisBlog/~4/hxp4nVl3r0Q" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://manski.net/2013/02/how-to-fix-multiple-items-in-the-open-with-menu-in-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://manski.net/2013/02/how-to-fix-multiple-items-in-the-open-with-menu-in-os-x/</feedburner:origLink></item>
		<item>
		<title>Bug of the Day: Mono for Android</title>
		<link>http://feedproxy.google.com/~r/ManskisBlog/~3/kyhhzmXSv4Y/</link>
		<comments>http://manski.net/2013/02/bug-of-the-day-mono-for-android/#comments</comments>
		<pubDate>Tue, 19 Feb 2013 12:02:16 +0000</pubDate>
		<dc:creator>Sebastian Krysmanski</dc:creator>
				<category><![CDATA[Annoyances]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Bug of the Day]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[Mono for Android]]></category>

		<guid isPermaLink="false">http://manski.net/?p=3261</guid>
		<description><![CDATA[Today&#8217;s bug is again sponsored by Mono for Android: Random &#8220;The type or namespace name &#8216;XXX&#8217; could not be found&#8221; errors when building Mono for Android randomly produces &#8220;The type or namespace name &#8216;XXX&#8217; could not be found&#8221; errors when building a solution. These errors don&#8217;t really exist and disappear after a rebuild.]]></description>
				<content:encoded><![CDATA[ <p>  <!-- Cached "rss-item" item from 2013-02-19 12:09:29 --> Today&#8217;s bug is again sponsored by Mono for Android: </p> 
<p class="indented"><a href="https://bugzilla.xamarin.com/show_bug.cgi?id=10433" target="_blank">Random &#8220;The type or namespace name &#8216;XXX&#8217; could not be found&#8221; errors when building</a> </p> 
 <p> Mono for Android randomly produces &#8220;The type or namespace name &#8216;XXX&#8217; could not be found&#8221; errors when building a solution. These errors don&#8217;t really exist and disappear after a rebuild. </p> 
<img src="http://feeds.feedburner.com/~r/ManskisBlog/~4/kyhhzmXSv4Y" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://manski.net/2013/02/bug-of-the-day-mono-for-android/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://manski.net/2013/02/bug-of-the-day-mono-for-android/</feedburner:origLink></item>
		<item>
		<title>Bug of the Day: NullReferenceException in AppDomain.UnhandledException handler</title>
		<link>http://feedproxy.google.com/~r/ManskisBlog/~3/WQkqpDoinqM/</link>
		<comments>http://manski.net/2013/02/bug-of-the-day-nullreferenceexception-in-appdomain-unhandledexception-handler/#comments</comments>
		<pubDate>Mon, 18 Feb 2013 16:52:05 +0000</pubDate>
		<dc:creator>Sebastian Krysmanski</dc:creator>
				<category><![CDATA[Annoyances]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Bug of the Day]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[Mono for Android]]></category>

		<guid isPermaLink="false">http://manski.net/?p=3259</guid>
		<description><![CDATA[Today&#8217;s bug is provided by Mono for Android: NullReferenceException in AppDomain.UnhandledException handler]]></description>
				<content:encoded><![CDATA[ <p>  <!-- Cached "rss-item" item from 2013-02-18 16:52:35 --> Today&#8217;s bug is provided by Mono for Android: </p> 
<p class="indented"><a href="https://bugzilla.xamarin.com/show_bug.cgi?id=10379" target="_blank">NullReferenceException in AppDomain.UnhandledException handler</a> </p> 
<img src="http://feeds.feedburner.com/~r/ManskisBlog/~4/WQkqpDoinqM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://manski.net/2013/02/bug-of-the-day-nullreferenceexception-in-appdomain-unhandledexception-handler/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://manski.net/2013/02/bug-of-the-day-nullreferenceexception-in-appdomain-unhandledexception-handler/</feedburner:origLink></item>
		<item>
		<title>Sort posts by modification date in WordPress</title>
		<link>http://feedproxy.google.com/~r/ManskisBlog/~3/3XRsAUTvUQ8/</link>
		<comments>http://manski.net/2013/02/sort-posts-by-modification-date-in-wordpress/#comments</comments>
		<pubDate>Wed, 13 Feb 2013 10:35:00 +0000</pubDate>
		<dc:creator>Sebastian Krysmanski</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[themes]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://manski.net/?p=3255</guid>
		<description><![CDATA[By default, WordPress sorts blog posts by creation date. However, if you update your blog posts from time to time, you may want to sort them by modification date rather than creation date. To achieve this, use this snippet: function order_posts_by_mod_date($orderby) { if (is_home() &#124;&#124; is_archive() &#124;&#124; is_feed()) { $orderby = &#34;post_modified_gmt DESC&#34;; } return [...]]]></description>
				<content:encoded><![CDATA[ <p>  <!-- Cached "rss-item" item from 2013-02-13 10:35:26 --> By default, WordPress sorts blog posts by <em>creation date</em>. However, if you update your blog posts from time to time, you may want to sort them by <em>modification date</em> rather than creation date. </p> 
 <p> To achieve this, use this snippet: </p> 
<pre class="code">function order_posts_by_mod_date($orderby) {
  if  (is_home() || is_archive() || is_feed()) {
    $orderby = &quot;post_modified_gmt DESC&quot;;
  }

  return $orderby;
}

add_filter('posts_orderby', 'order_posts_by_mod_date', 999);</pre>
 <p> In your theme, just dump this snippet into <code>functions.php</code>. (You may need to create this file in your theme&#8217;s directory.) </p> 
<img src="http://feeds.feedburner.com/~r/ManskisBlog/~4/3XRsAUTvUQ8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://manski.net/2013/02/sort-posts-by-modification-date-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://manski.net/2013/02/sort-posts-by-modification-date-in-wordpress/</feedburner:origLink></item>
		<item>
		<title>Android Source Code in Eclipse</title>
		<link>http://feedproxy.google.com/~r/ManskisBlog/~3/pAusEfXCQt8/</link>
		<comments>http://manski.net/2011/11/android-source-code-in-eclipse/#comments</comments>
		<pubDate>Mon, 14 Nov 2011 16:36:04 +0000</pubDate>
		<dc:creator>Sebastian Krysmanski</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[eclipse]]></category>

		<guid isPermaLink="false">http://manski.net/?p=1767</guid>
		<description><![CDATA[Google made developing an Android app fairly simple. Everything you need can be downloaded for free from Android&#8217;s development site. This includes the Android API, an Android emulator (for running Android apps directly on your computer), and an Eclipse plugin called ADT (Android Developer Tools). However, there is was one thing missing: the Java source [...]]]></description>
				<content:encoded><![CDATA[ <p>  <!-- Cached "rss-item" item from 2013-02-13 10:35:26 --> Google made developing an Android app fairly simple. Everything you need can be downloaded for free from <a href="http://developer.android.com/sdk/installing.html" target="_blank">Android&#8217;s development site</a>. This includes the Android API, an Android emulator (for running Android apps directly on your computer), and an Eclipse plugin called ADT (Android Developer Tools). However, there <span class="strike">is</span> was one thing missing: the <em>Java source code</em>. </p> 
 <p> <span id="more-1767"></span> </p> 
<h1 id="since-android-4.0">Since Android 4.0</h1>
 <p> Since Android 4.0 (API level 14) you can download the source code by using the &#8220;SDK Manager&#8221;.  </p> 
<div class="align-center image-align-center"><a href="http://manski.net/wordpress/wp-content/uploads/2011/11/android-sources.jpg" rel="attachment" title="android-sources.jpg"><img class="wp-post-image" src="http://manski.net/wordpress/wp-content/plugins/blogtext/api/thumbnail/do.php?id=fc94e0974223d125e31e3a6dbb8e88a9177b6da7_500x500_resize_if_larger" title="android-sources.jpg" alt="android-sources.jpg" width="500" height="620"/></a></div>
 <p> After downloading them, you&#8217;ll find them under <code>&lt;android-sdk&gt;/sources</code>. </p> 
<h1 id="before-android-4.0">Before Android 4.0</h1>
<h2 id="the-problem">The Problem</h2>
 <p> Despite the fact the Android is (supposed to be) an open source project, the downloads don&#8217;t include the source code of Android. So, when opening an Android class in Eclipse, you may see something like this: </p> 
<div class="align-center image-align-center"><a href="http://manski.net/wordpress/wp-content/uploads/2011/11/source-not-found.png" rel="attachment" title="&quot;Source not found&quot; error in Eclipse"><img class="wp-post-image" src="http://manski.net/wordpress/wp-content/plugins/blogtext/api/thumbnail/do.php?id=aff27d40442096b905248f8217afc7508df51a8b_500x500_resize_if_larger" title="&quot;Source not found&quot; error in Eclipse" alt="&quot;Source not found&quot; error in Eclipse" width="500" height="243"/></a></div>
 <p> To solve this problem you had to manually download the whole Android source code (which contains much more than just the Java source code files) and then manually assemble a source files directory from the Java files scattered throughout the Android source tree. Very tedious and certainly not very simple. </p> 
<h2 id="the-solution">The Solution</h2>
 <p> Fortunately, there is a Google Code project named &#8220;adt-addons&#8221; aiming to solve this problem (for API levels 13 and lower). The project actually consists of several Eclipse plugins, but the one you want is called &#8220;Android Sources&#8221;. You can either search the instructions on the project page, or follow them (nicely formatted) here. </p> 
 <p> Basically what you need is to install the &#8220;Android Sources&#8221; plugin (about <em>170 MB</em>). Here&#8217;s the update URL: </p> 
<p class="indented"><a href="http://adt-addons.googlecode.com/svn/trunk/source/com.android.ide.eclipse.source.update/" target="_blank">http://adt-addons.googlecode.com/svn/trunk/source/com.android.ide.eclipse.source.update/</a> </p> 
 <p> After installing the plugin, simply restart Eclipse and the Android source code is already attached to the Android classes. </p> 
<div class="align-center image-align-center"><a href="http://manski.net/wordpress/wp-content/uploads/2011/11/source-found.png" rel="attachment" title="Sources found for Android classes"><img class="wp-post-image" src="http://manski.net/wordpress/wp-content/plugins/blogtext/api/thumbnail/do.php?id=cc1f35a156ddbf4751b6e2e6368f32b0abf635c0_500x500_resize_if_larger" title="Sources found for Android classes" alt="Sources found for Android classes" width="500" height="252"/></a></div>
<img src="http://feeds.feedburner.com/~r/ManskisBlog/~4/pAusEfXCQt8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://manski.net/2011/11/android-source-code-in-eclipse/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://manski.net/2011/11/android-source-code-in-eclipse/</feedburner:origLink></item>
		<item>
		<title>Special search characters in Firefox</title>
		<link>http://feedproxy.google.com/~r/ManskisBlog/~3/iiFhkyVIYg8/</link>
		<comments>http://manski.net/2013/02/special-search-characters-in-firefox/#comments</comments>
		<pubDate>Wed, 13 Feb 2013 08:43:21 +0000</pubDate>
		<dc:creator>Sebastian Krysmanski</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[bookmarks]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[search]]></category>

		<guid isPermaLink="false">http://manski.net/?p=3248</guid>
		<description><![CDATA[In Firefox, I use the InstantFox add-on to combine address bar and search bar into one item &#8211; like in Google Chrome. But even without this add-on, Firefox allows you to restrict your search by adding a character in front of the search terms, like so: Notice the * in front of the search term [...]]]></description>
				<content:encoded><![CDATA[ <p>  <!-- Cached "rss-item" item from 2013-02-13 08:43:42 --> In Firefox, I use the <a href="http://www.instantfox.net/" target="_blank">InstantFox</a> add-on to combine address bar and search bar into one item &#8211; like in Google Chrome. </p> 
 <p> But even without this add-on, Firefox allows you to restrict your search by adding a character in front of the search terms, like so: </p> 
<div class="align-center image-align-center"><a href="http://manski.net/wordpress/wp-content/uploads/2013/02/firefox-search.jpg" rel="attachment" title="firefox-search.jpg"><img class="wp-post-image" src="http://manski.net/wordpress/wp-content/plugins/blogtext/api/thumbnail/do.php?id=ce23a6bbd686aa74de2a09672f7a304d32b8b480_500x500_resize_if_larger" title="firefox-search.jpg" alt="firefox-search.jpg" width="500" height="224"/></a></div>
 <p> Notice the <code>*</code> in front of the search term <code>bugs</code>. This restricts the search to bookmarks. </p> 
 <p> Here&#8217;s a list of the most important restrictions: </p> 
<table>
<thead>
<tr>
<th>Character</th>
<th>Restriction</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>*</code></td>
<td>Bookmarks</td>
</tr>
<tr>
<td><code>^</code></td>
<td>History</td>
</tr>
<tr>
<td><code>%</code></td>
<td>Open Tabs</td>
</tr>
<tr>
<td><code>+</code></td>
<td>Tags (in bookmarks)</td>
</tr>
<tr>
<td><code>#</code></td>
<td>Search in titles only</td>
</tr>
<tr>
<td><code>@</code></td>
<td>Search in URLs only</td>
</tr>
</tbody>
</table>
 <p> All these shortcuts can be edited in <a href="about:config">about:config</a> under <code>browser.urlbar</code>. </p> 
<img src="http://feeds.feedburner.com/~r/ManskisBlog/~4/iiFhkyVIYg8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://manski.net/2013/02/special-search-characters-in-firefox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://manski.net/2013/02/special-search-characters-in-firefox/</feedburner:origLink></item>
		<item>
		<title>Etwas veraltet, oder?</title>
		<link>http://feedproxy.google.com/~r/ManskisBlog/~3/i-CyQLZmPlk/</link>
		<comments>http://manski.net/2013/02/etwas-veraltet-oder/#comments</comments>
		<pubDate>Mon, 11 Feb 2013 14:32:44 +0000</pubDate>
		<dc:creator>Sebastian Krysmanski</dc:creator>
				<category><![CDATA[Personal Stuff]]></category>

		<guid isPermaLink="false">http://manski.net/?p=3243</guid>
		<description><![CDATA[Da ich gerade auf Job-Suche bin, bin ich auch bei StepStone gelandet. Dort kann man unter anderem seine IT-Kenntnisse angeben. Allerdings scheint es, dass deren Datenbank seit so ungefährt 11 Jahren nicht mehr aktualisiert wurde:]]></description>
				<content:encoded><![CDATA[ <p>  <!-- Cached "rss-item" item from 2013-02-11 14:34:23 --> Da ich gerade auf Job-Suche bin, bin ich auch bei StepStone gelandet. Dort kann man unter anderem seine IT-Kenntnisse angeben. Allerdings scheint es, dass deren Datenbank seit so ungefährt 11 Jahren nicht mehr aktualisiert wurde: </p> 
<div class="align-center image-align-center"><a href="http://manski.net/wordpress/wp-content/uploads/2013/02/windows-kenntnisse.png" rel="attachment" title="Wo sind denn hier bitte Windows Vista, 7 und 8?"><img class="wp-post-image" src="http://manski.net/wordpress/wp-content/plugins/blogtext/api/thumbnail/do.php?id=f763914ba23e77b758cb054f7ae4c47686f9491b_500x500_resize_if_larger" title="Wo sind denn hier bitte Windows Vista, 7 und 8?" alt="Wo sind denn hier bitte Windows Vista, 7 und 8?" width="500" height="139"/></a></div>
<img src="http://feeds.feedburner.com/~r/ManskisBlog/~4/i-CyQLZmPlk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://manski.net/2013/02/etwas-veraltet-oder/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://manski.net/2013/02/etwas-veraltet-oder/</feedburner:origLink></item>
		<item>
		<title>Bug of the Day: Backup running, ok/cancel?</title>
		<link>http://feedproxy.google.com/~r/ManskisBlog/~3/2DjKvVA93eI/</link>
		<comments>http://manski.net/2013/02/bug-of-the-day-backup-running-okcancel/#comments</comments>
		<pubDate>Wed, 06 Feb 2013 17:38:53 +0000</pubDate>
		<dc:creator>Sebastian Krysmanski</dc:creator>
				<category><![CDATA[Annoyances]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Bug of the Day]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[windows server 2012]]></category>
		<category><![CDATA[windows server backup]]></category>

		<guid isPermaLink="false">http://manski.net/?p=3230</guid>
		<description><![CDATA[Today&#8217;s bug is a GUI design bug in Windows Server Backup (2012). What do you think of this screenshot? Why is there an &#8220;OK&#8221; and a &#8220;Cancel&#8221; button? What do they mean? (&#8220;OK&#8221; means &#8220;Close&#8221; and &#8220;Cancel&#8221; means &#8220;Stop Backup&#8221;. When you start a backup, the button is actually labeled &#8220;Close&#8221; (instead of &#8220;OK&#8221;).)]]></description>
				<content:encoded><![CDATA[ <p>  <!-- Cached "rss-item" item from 2013-02-06 17:41:18 --> Today&#8217;s bug is a GUI design bug in Windows Server Backup (2012). What do you think of this screenshot? </p> 
<div class="align-center image-align-center"><img class="wp-post-image" src="http://manski.net/wordpress/wp-content/uploads/2013/02/progress-ok-cancel.png" title="progress-ok-cancel.png" alt="progress-ok-cancel.png"/></div>
 <p> Why is there an &#8220;OK&#8221; and a &#8220;Cancel&#8221; button? What do they mean? </p> 
 <p> (&#8220;OK&#8221; means &#8220;Close&#8221; and &#8220;Cancel&#8221; means &#8220;Stop Backup&#8221;. When you start a backup, the button is actually labeled &#8220;Close&#8221; (instead of &#8220;OK&#8221;).) </p> 
<img src="http://feeds.feedburner.com/~r/ManskisBlog/~4/2DjKvVA93eI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://manski.net/2013/02/bug-of-the-day-backup-running-okcancel/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://manski.net/2013/02/bug-of-the-day-backup-running-okcancel/</feedburner:origLink></item>
		<item>
		<title>Bug of the day: Broken renaming in ReSharper</title>
		<link>http://feedproxy.google.com/~r/ManskisBlog/~3/62_2-Zk76-0/</link>
		<comments>http://manski.net/2013/01/bug-of-the-day-broken-renaming-in-resharper/#comments</comments>
		<pubDate>Tue, 29 Jan 2013 15:11:45 +0000</pubDate>
		<dc:creator>Sebastian Krysmanski</dc:creator>
				<category><![CDATA[Annoyances]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Bug of the Day]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[resharper]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://manski.net/?p=3206</guid>
		<description><![CDATA[In my opinion, refactoring is the way to keep a software project clean. So, it&#8217;s good to have tools that support the refactoring process. ReSharper is such a tool. It provides refactoring capabilities for C#/Visual Studio. Unfortunately, the renaming code in ReSharper currently (version 7.1.1) contains a bug. This bug may prevent ReSharper from renaming [...]]]></description>
				<content:encoded><![CDATA[ <p>  <!-- Cached "rss-item" item from 2013-02-06 08:43:19 --> In my opinion, refactoring is <em>the</em> way to keep a software project clean. So, it&#8217;s good to have tools that support the refactoring process. </p> 
 <p> <a href="http://www.jetbrains.com/resharper/" target="_blank">ReSharper</a> is such a tool. It provides refactoring capabilities for C#/Visual Studio.  </p> 
 <p> Unfortunately, the renaming code in ReSharper currently (version 7.1.1) contains <a href="http://youtrack.jetbrains.com/issue/RSRP-337801" target="_blank">a bug</a>. This bug may prevent ReSharper from renaming <span class="underline">all</span> occurrences of a certain symbol. </p> 
 <p> The following code exhibits this problem: </p> 
<pre class="code">using System;

public class SomeOtherClass {
  public string GetString(int col) {
    return null;
  }
}

public class MyClass {
  public void YouCantRenameMe() { }

  public void ThisFunctionBreaksTheRenaming() {
    // The following line breaks the renaming.
    SomeFunction((row) =&gt; row.GetString(0));
  }

  public void SomeFunction&lt;T&gt;(Func&lt;SomeOtherClass, T&gt; func) {
    YouCantRenameMe();
  }
}</pre>
 <p> If you try to rename the method <code>YouCantRenameMe()</code> (in line 10), ReSharper won&#8217;t rename the method call in line 18. </p> 
 <p> The problem is the code in method <code>ThisFunctionBreaksTheRenaming()</code> which somehow breaks the renaming process. </p> 
 <p> <strong>Update:</strong> This bug is not present in version 7.1. So, for now, I&#8217;ve downgraded to this version. </p> 
<img src="http://feeds.feedburner.com/~r/ManskisBlog/~4/62_2-Zk76-0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://manski.net/2013/01/bug-of-the-day-broken-renaming-in-resharper/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://manski.net/2013/01/bug-of-the-day-broken-renaming-in-resharper/</feedburner:origLink></item>
		<item>
		<title>Bug of the Day: Fast Deployment</title>
		<link>http://feedproxy.google.com/~r/ManskisBlog/~3/9RtDEwO6Tdk/</link>
		<comments>http://manski.net/2013/02/bug-of-the-day-fast-deployment/#comments</comments>
		<pubDate>Tue, 05 Feb 2013 16:25:11 +0000</pubDate>
		<dc:creator>Sebastian Krysmanski</dc:creator>
				<category><![CDATA[Annoyances]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Bug of the Day]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[Mono for Android]]></category>

		<guid isPermaLink="false">http://manski.net/?p=3227</guid>
		<description><![CDATA[Today, I&#8217;ve been hunting down a bug in Mono for Android (4.4.55). This bug flooded the Android log with this entry (thousands of times): 02-04 17:09:32.010: W/(4300): Bad call to mono_mutex_lock result 11 02-04 17:09:32.010: A/(4300): * Assertion at /Users/builder/data/lanes/monodroid-mac-monodroid-4.4-series/6418373f/source/mono/mono/metadata/loader.c:2181, condition `ret == 0' not met This flood of log messages made the whole deployment [...]]]></description>
				<content:encoded><![CDATA[ <p>  <!-- Cached "rss-item" item from 2013-02-06 08:40:48 --> Today, I&#8217;ve been hunting down a bug in Mono for Android (4.4.55). This bug flooded the Android log with this entry (thousands of times): </p> 
<pre class="code">02-04 17:09:32.010: W/(4300): Bad call to mono_mutex_lock result 11
02-04 17:09:32.010: A/(4300): * Assertion at /Users/builder/data/lanes/monodroid-mac-monodroid-4.4-series/6418373f/source/mono/mono/metadata/loader.c:2181, condition `ret == 0' not met</pre>
 <p> This flood of log messages made the whole deployment process very slow (54 seconds to deploy a fresh project). </p> 
 <p> As workaround I found that disabling <strong>Use Fast Deployment</strong> in the project settings &#8220;solved&#8221; the problem for me.  </p> 
 <p> <span class="strike">I&#8217;m still waiting for an answer from Xamarin on this issue.</span> <strong>Update:</strong> This problem is tracked <a href="https://bugzilla.xamarin.com/show_bug.cgi?id=9572" target="_blank">here</a>. </p> 
<img src="http://feeds.feedburner.com/~r/ManskisBlog/~4/9RtDEwO6Tdk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://manski.net/2013/02/bug-of-the-day-fast-deployment/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://manski.net/2013/02/bug-of-the-day-fast-deployment/</feedburner:origLink></item>
		<item>
		<title>Unit Testing Framework for MonoDroid</title>
		<link>http://feedproxy.google.com/~r/ManskisBlog/~3/Ehref38WgRw/</link>
		<comments>http://manski.net/2012/07/unit-testing-framework-for-monodroid/#comments</comments>
		<pubDate>Mon, 09 Jul 2012 12:30:24 +0000</pubDate>
		<dc:creator>Sebastian Krysmanski</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Mono for Android]]></category>
		<category><![CDATA[unit testing]]></category>

		<guid isPermaLink="false">http://manski.net/?p=2624</guid>
		<description><![CDATA[Currently MonoDroid (or &#8220;Mono for Android&#8221;) is lacking a unit testing framework. Since Xamarin (the guys behind MonoDroid) enable us to use C# on almost every platform it would be nice to be able to reuse C# unit tests written for Visual Studio on other platforms, such as Android. This is the goal behind the [...]]]></description>
				<content:encoded><![CDATA[ <p>  <!-- Cached "rss-item" item from 2013-02-04 21:59:13 --> Currently MonoDroid (or &#8220;Mono for Android&#8221;) is lacking a unit testing framework. Since Xamarin (the guys behind MonoDroid) enable us to use C# on almost every platform it would be nice to be able to reuse C# unit tests written for Visual Studio on other platforms, such as Android. </p> 
 <p> This is the goal behind the <strong>MonoDroid Unit Testing Framework</strong> which can be obtained here: </p> 
<p class="indented"><a href="https://bitbucket.org/mayastudios/monodroid-unittest/" target="_blank">https://bitbucket.org/mayastudios/monodroid-unittest/</a> </p> 
 <p> Happy testing! </p> 
 <p> <a href="http://manski.net/wordpress/wp-content/uploads/2012/07/test-overview.png" rel="attachment" title="Overview over all tests"><img class="wp-post-image" src="http://manski.net/wordpress/wp-content/plugins/blogtext/api/thumbnail/do.php?id=067a3a25cf8454358bdf2ed851d858a4510c08ee_150x150_crop" title="Overview over all tests" alt="Overview over all tests" width="150" height="150"/></a><a href="http://manski.net/wordpress/wp-content/uploads/2012/07/test-details.png" rel="attachment" title="Details about one test method"><img class="wp-post-image" src="http://manski.net/wordpress/wp-content/plugins/blogtext/api/thumbnail/do.php?id=93175c47a5b85eb8cbe89c69f4a54f54ad7a70bf_150x150_crop" title="Details about one test method" alt="Details about one test method" width="150" height="150"/></a> </p> 
<img src="http://feeds.feedburner.com/~r/ManskisBlog/~4/Ehref38WgRw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://manski.net/2012/07/unit-testing-framework-for-monodroid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://manski.net/2012/07/unit-testing-framework-for-monodroid/</feedburner:origLink></item>
		<item>
		<title>Bug of the day: Copying not allowed</title>
		<link>http://feedproxy.google.com/~r/ManskisBlog/~3/CSTjEBpZTI0/</link>
		<comments>http://manski.net/2013/02/bug-of-the-day-copying-not-allowed/#comments</comments>
		<pubDate>Mon, 04 Feb 2013 17:29:00 +0000</pubDate>
		<dc:creator>Sebastian Krysmanski</dc:creator>
				<category><![CDATA[Annoyances]]></category>
		<category><![CDATA[Bug of the Day]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[Mono for Android]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://manski.net/?p=3222</guid>
		<description><![CDATA[Mono for Android provides a window to view all Android log messages directly in Visual Studio. However, you can&#8217;t copy these log messages. Since I&#8217;m a well-behaved programmer, I filed a bug report for this. For now, I have to use monitor.bat from the Android SDK&#8217;s tools directory to work around this issue.]]></description>
				<content:encoded><![CDATA[ <p>  <!-- Cached "rss-item" item from 2013-02-04 17:29:19 --> Mono for Android provides a window to view all Android log messages directly in Visual Studio. However, you can&#8217;t copy these log messages.  </p> 
 <p> Since I&#8217;m a well-behaved programmer, I filed a <a href="https://bugzilla.xamarin.com/show_bug.cgi?id=10020" target="_blank">bug report for this</a>. </p> 
 <p> For now, I have to use <code>monitor.bat</code> from the Android SDK&#8217;s <code>tools</code> directory to work around this issue. </p> 
<img src="http://feeds.feedburner.com/~r/ManskisBlog/~4/CSTjEBpZTI0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://manski.net/2013/02/bug-of-the-day-copying-not-allowed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://manski.net/2013/02/bug-of-the-day-copying-not-allowed/</feedburner:origLink></item>
		<item>
		<title>Click to play for plugins (Flash, Java) in Firefox</title>
		<link>http://feedproxy.google.com/~r/ManskisBlog/~3/mZChkRTFmb8/</link>
		<comments>http://manski.net/2013/01/click-to-play-for-plugins-flash-java-in-firefox/#comments</comments>
		<pubDate>Wed, 30 Jan 2013 08:47:09 +0000</pubDate>
		<dc:creator>Sebastian Krysmanski</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://manski.net/?p=3214</guid>
		<description><![CDATA[In Google Chrome, there is an option to enable &#8220;Click to Play&#8221; for plugins, such as Flash, Java, or Silverlight. This makes the browser safer (especially after all the Java security vulnerability in the last time) and a little bit fast. Today, I found out that this option exists in Firefox too &#8211; although its [...]]]></description>
				<content:encoded><![CDATA[ <p>  <!-- Cached "rss-item" item from 2013-01-30 08:47:30 --> In Google Chrome, there is an option to enable &#8220;Click to Play&#8221; for plugins, such as Flash, Java, or Silverlight. This makes the browser safer (especially after all the Java security vulnerability in the last time) and a little bit fast. Today, I found out that this option exists in Firefox too &#8211; although its a little bit hidden. </p> 
 <p> To enable &#8220;Click to Play&#8221; in Firefox&#8230; </p> 
<ol>
<li class="first-item">go to <strong><code>about:config</code></strong> and click on <strong>&#8220;I&#8217;ll be careful, I promise!&#8221;</strong></li>
<li class="last-item">
 <p> search for <strong><code>plugins.click_to_play</code></strong> and set it to <strong>true</strong> (by double-clicking the entry) </p> 
</li>
</ol>
<div class="align-center image-align-center"><img class="wp-post-image" src="http://manski.net/wordpress/wp-content/uploads/2013/01/click_to_play_settings.jpg" title="click_to_play_settings.jpg" alt="click_to_play_settings.jpg"/></div>
 <p> After that, when you get to a page that contains Flash (videos), Java, or any other plugin, you&#8217;ll get a &#8220;Click to Play&#8221; message for the plugin. </p> 
<div class="align-center image-align-center"><a href="http://manski.net/wordpress/wp-content/uploads/2013/01/click_to_play_message.jpg" rel="attachment" title="click_to_play_message.jpg"><img class="wp-post-image" src="http://manski.net/wordpress/wp-content/plugins/blogtext/api/thumbnail/do.php?id=b563ba4b9ebc6d6c3ddbb8ac95dab59ab4933c4d_500x500_resize_if_larger" title="click_to_play_message.jpg" alt="click_to_play_message.jpg" width="500" height="493"/></a></div>
<img src="http://feeds.feedburner.com/~r/ManskisBlog/~4/mZChkRTFmb8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://manski.net/2013/01/click-to-play-for-plugins-flash-java-in-firefox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://manski.net/2013/01/click-to-play-for-plugins-flash-java-in-firefox/</feedburner:origLink></item>
		<item>
		<title>Bug of the day: Low &lt; High &lt; Current?</title>
		<link>http://feedproxy.google.com/~r/ManskisBlog/~3/11ueqEYaof8/</link>
		<comments>http://manski.net/2013/01/bug-of-the-day-low-high-current/#comments</comments>
		<pubDate>Wed, 30 Jan 2013 15:11:53 +0000</pubDate>
		<dc:creator>Sebastian Krysmanski</dc:creator>
				<category><![CDATA[Funny Stuff]]></category>
		<category><![CDATA[Bug of the Day]]></category>

		<guid isPermaLink="false">http://manski.net/?p=3210</guid>
		<description />
				<content:encoded><![CDATA[ <p>  <!-- Cached "rss-item" item from 2013-01-30 15:13:33 --> 
<div class="align-center image-align-center"><img class="wp-post-image" src="http://manski.net/wordpress/wp-content/uploads/2013/01/weather.jpg" title="weather.jpg" alt="weather.jpg"/></div>
<img src="http://feeds.feedburner.com/~r/ManskisBlog/~4/11ueqEYaof8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://manski.net/2013/01/bug-of-the-day-low-high-current/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://manski.net/2013/01/bug-of-the-day-low-high-current/</feedburner:origLink></item>
		<item>
		<title>Calculate return value for sort by int</title>
		<link>http://feedproxy.google.com/~r/ManskisBlog/~3/nC3uhJn6_8o/</link>
		<comments>http://manski.net/2013/01/calculate-return-value-for-sort-by-int/#comments</comments>
		<pubDate>Thu, 17 Jan 2013 12:55:00 +0000</pubDate>
		<dc:creator>Sebastian Krysmanski</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[comparison]]></category>
		<category><![CDATA[sorting]]></category>

		<guid isPermaLink="false">http://manski.net/?p=3175</guid>
		<description><![CDATA[Most programming languages (such as C#, Java, &#8230;) allow you to sort lists. Most of them also allow you to specify a sorting function so that you can customize the sort order. These functions usually take parameters a and b and define the return value as follows: Return value if less than zero a is [...]]]></description>
				<content:encoded><![CDATA[ <p>  <!-- Cached "rss-item" item from 2013-01-22 10:12:45 --> Most programming languages (such as C#, Java, &#8230;) allow you to sort lists. Most of them also allow you to specify a <em>sorting function</em> so that you can customize the sort order. These functions usually take parameters <code>a</code> and <code>b</code> and define the return value as follows: </p> 
<table>
<thead>
<tr>
<th>Return value</th>
<th>if</th>
</tr>
</thead>
<tbody>
<tr>
<td>less than zero</td>
<td><code>a</code> is less than <code>b</code></td>
</tr>
<tr>
<td>equals zero</td>
<td><code>a</code> is equal to <code>b</code></td>
</tr>
<tr>
<td>greater than zero</td>
<td><code>a</code> is greater than <code>b</code></td>
</tr>
</tbody>
</table>
 <p> Usually you would do something like this (code in C#): </p> 
<pre class="code">int Compare(int a, int b) {
  if (a &lt; b) {
    return -1;
  }
  else if (a &gt; b) {
    return 1;
  }
  else {
    return 0;
  }
}</pre>
 <p> However, when comparing <code>int</code> values, there&#8217;s a much quicker way to do this: </p> 
<pre class="code">int Compare(int a, int b) {
  return a - b;
}</pre>
 <p> That&#8217;s it. </p> 
 <p> <strong>Note:</strong> Care should be taken if <code>a</code> and/or <code>b</code> can come close to <code>int.MaxValue</code> or <code>int.MinValue</code>. In this case the results may not be what one wants (like if <code>a = int.MinValue</code> and <code>b = 1</code> then the result will be <code>int.MaxValue</code> which is wrong obviously). </p> 
<img src="http://feeds.feedburner.com/~r/ManskisBlog/~4/nC3uhJn6_8o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://manski.net/2013/01/calculate-return-value-for-sort-by-int/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://manski.net/2013/01/calculate-return-value-for-sort-by-int/</feedburner:origLink></item>
		<item>
		<title>Want!</title>
		<link>http://feedproxy.google.com/~r/ManskisBlog/~3/Bn1NrbVOqow/</link>
		<comments>http://manski.net/2013/01/want/#comments</comments>
		<pubDate>Fri, 18 Jan 2013 10:28:21 +0000</pubDate>
		<dc:creator>Sebastian Krysmanski</dc:creator>
				<category><![CDATA[Gagdets]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[tv]]></category>

		<guid isPermaLink="false">http://manski.net/?p=3200</guid>
		<description><![CDATA[Click here to view the embedded video.]]></description>
				<content:encoded><![CDATA[ <p>  <!-- Cached "rss-item" item from 2013-01-18 10:28:43 -->  <p> <a href="http://manski.net/2013/01/want/"><em>Click here to view the embedded video.</em></a> </p>  </p> 
<img src="http://feeds.feedburner.com/~r/ManskisBlog/~4/Bn1NrbVOqow" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://manski.net/2013/01/want/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://manski.net/2013/01/want/</feedburner:origLink></item>
		<item>
		<title>Plotting graphs with R</title>
		<link>http://feedproxy.google.com/~r/ManskisBlog/~3/L0rii4_waWI/</link>
		<comments>http://manski.net/2013/01/plotting-graphs-with-r/#comments</comments>
		<pubDate>Fri, 18 Jan 2013 10:13:01 +0000</pubDate>
		<dc:creator>Sebastian Krysmanski</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[graphs]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[R]]></category>

		<guid isPermaLink="false">http://manski.net/?p=3186</guid>
		<description><![CDATA[I recently stumbled over R, a programming language for data analysis. R is open-source and available on all major platforms (Windows, Linux, Mac). This post is about how to display (draw) a mathematical function with R. Side note: There&#8217;s a very nice and interactive tutorial for R available over at codeschool.com. It&#8217;s free and takes [...]]]></description>
				<content:encoded><![CDATA[ <p>  <!-- Cached "rss-item" item from 2013-01-18 10:13:28 --> I recently stumbled over <a href="http://www.r-project.org/" target="_blank">R</a>, a programming language for data analysis. R is open-source and available on all major platforms (Windows, Linux, Mac).  </p> 
 <p> This post is about how to display (draw) a mathematical function with R. </p> 
 <p> <em>Side note:</em> There&#8217;s a very nice and interactive <a href="http://www.codeschool.com/courses/try-r" target="_blank">tutorial for R</a> available over at <a href="http://www.codeschool.com/" target="_blank">codeschool.com</a>. It&#8217;s free and takes about 3 &#8211; 4 hours to complete. </p> 
 <p> <span id="more-3186"></span> </p> 
 <p> To draw a function, use the built-in function <code>curve()</code>. </p> 
 <p> Let&#8217;s start with something simple: </p> 
<pre class="code">curve(x^2)</pre>
 <p> This will plot the function <em>x<sup>2</sup></em> and will look like this: </p> 
<div class="align-center image-align-center"><a href="http://manski.net/wordpress/wp-content/uploads/2013/01/curve1.png" rel="attachment" title="curve1.png"><img class="wp-post-image" src="http://manski.net/wordpress/wp-content/plugins/blogtext/api/thumbnail/do.php?id=f863365ed3df2e1db98b6e37adac1b7c7fdffd7b_300x300_resize_if_larger" title="curve1.png" alt="curve1.png" width="300" height="240"/></a></div>
 <p> Since we didn&#8217;t specify any boundaries for the x and y axes, R used <code>0..1</code> for the x axis and chose the y axis to fit. </p> 
 <p> Of course, we can manually specify the range for the values on the x axis: </p> 
<pre class="code">curve(x^2, -4, 3)</pre>
 <p> This will plot <em>x<sup>2</sup></em> with <code>-4..3</code>: </p> 
<div class="align-center image-align-center"><a href="http://manski.net/wordpress/wp-content/uploads/2013/01/curve2.png" rel="attachment" title="curve2.png"><img class="wp-post-image" src="http://manski.net/wordpress/wp-content/plugins/blogtext/api/thumbnail/do.php?id=e7b6aada0600136f57c10d8b89bf08082878c580_300x300_resize_if_larger" title="curve2.png" alt="curve2.png" width="300" height="243"/></a></div>
 <p> As you can see in this plot, R makes the y axis match the required value range (here: <code>0..15</code>). </p> 
 <p> Sometimes, however, this may not be desired. There are two ways to fix this. </p> 
 <p> First, you can specify the aspect ratio to be 1 (<a href="http://xkcd.com/1162/" target="_blank">cause log scales are for quitters</a>). In this case, the x and the y axes will use the same scale: </p> 
<pre class="code">curve(x^2, -4, 3, asp=1)</pre>
 <p> will give us: </p> 
<div class="align-center image-align-center"><a href="http://manski.net/wordpress/wp-content/uploads/2013/01/curve3.png" rel="attachment" title="curve3.png"><img class="wp-post-image" src="http://manski.net/wordpress/wp-content/plugins/blogtext/api/thumbnail/do.php?id=10a66a80bd144eb1a51a47a6a4c6bc6db13ceb86_300x300_resize_if_larger" title="curve3.png" alt="curve3.png" width="300" height="243"/></a></div>
 <p> The other option is to explicitely specify the range for the y axis by using the <code>ylim</code> parameter: </p> 
<pre class="code">curve(x^2, -4, 3, ylim=range(c(-1, 4)))</pre>
 <p> will give us a y axis range of <code>-1..4</code>: </p> 
<div class="align-center image-align-center"><a href="http://manski.net/wordpress/wp-content/uploads/2013/01/curve4.png" rel="attachment" title="curve4.png"><img class="wp-post-image" src="http://manski.net/wordpress/wp-content/plugins/blogtext/api/thumbnail/do.php?id=4847a084008fad0c9e4e7db35e400b331a4fa512_300x300_resize_if_larger" title="curve4.png" alt="curve4.png" width="300" height="245"/></a></div>
 <p> For more information on <code>curve()</code>, just type <code>?curve</code> in R&#8217;s prompt. </p> 
<img src="http://feeds.feedburner.com/~r/ManskisBlog/~4/L0rii4_waWI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://manski.net/2013/01/plotting-graphs-with-r/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://manski.net/2013/01/plotting-graphs-with-r/</feedburner:origLink></item>
	</channel>
</rss>
