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

<channel>
	<title>.Org</title>
	<atom:link href="http://philiphanson.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://philiphanson.org</link>
	<description>Code for the social web, data management, and other interesting things.</description>
	<lastBuildDate>Sat, 25 Jun 2011 11:06:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>The Mind-Killer</title>
		<link>http://philiphanson.org/2011/the-mind-killer/</link>
		<comments>http://philiphanson.org/2011/the-mind-killer/#comments</comments>
		<pubDate>Sat, 25 Jun 2011 11:06:34 +0000</pubDate>
		<dc:creator>Philip Hanson</dc:creator>
				<category><![CDATA[Cognition]]></category>
		<category><![CDATA[ideas]]></category>
		<category><![CDATA[procrastination]]></category>
		<category><![CDATA[productivity]]></category>
		<category><![CDATA[strategy]]></category>
		<category><![CDATA[thinking]]></category>

		<guid isPermaLink="false">http://philiphanson.org/?p=63</guid>
		<description><![CDATA[It starts out going so well. I'm focused, ideas are flowing, and I'm putting them directly into my code or blog post or weekend project or whatever. The break from inspiration comes when I decide I don't want to work on something right now. Then my brain revolts. This essay is about what happens in [...]]]></description>
			<content:encoded><![CDATA[<p>It starts out going so well. I'm focused, ideas are flowing, and I'm putting them directly into my code or blog post or weekend project or whatever. The break from inspiration comes when I decide I don't want to work on something right now. Then my brain revolts. This essay is about what happens in my brain when I reject an idea. It comes from the synthesis of many sources which I don't remember, and hopefully it will be useful to you in understanding your own cognitive process (assuming you don't mind slightly-more-flowery-than-necessary language).</p>
<p>If I have an idea, I have to write it down. I am a cyborg, and the pad of paper is my augmentation. Paper does not forget. It does not change what I write. I would change my ideas later on to sound more reasonable, but paper does not change a thing. The pad is an extension of my long-term memory that actually requires less processing to store. It is an overflow file where I can route the excess bandwidth during peak times and come back to parse the logs when things have died down.</p>
<p>Ironically, I am not writing this on a pad, or paper of any kind. I did use a pad earlier, to capture fleeting thoughts during a speech. When high-tech isn't available (for whatever reason), low-tech is well-developed enough to handle some scribbled half-baked notion, as it has been for millenia. While driving, I dictate voice memos to myself (for safety as much as anything). At my desk I use whatever program is at hand -- or a pad, or a post-it note, or a piece of scrap paper, or my PDA... as long as it is captured somehow, I can attempt to salvage it later. While writing this short essay I opened two or three tabs in various background applications as a way to record ideas that were flashing through my mind.</p>
<p>There are three things that can happen to an idea after you have had it:</p>
<ol>
<li>it can be forgotten and all potential lost,</li>
<li>it can be acted upon and made to serve you, or</li>
<li>it can be ignored, sinking into disuse but not erasure.</li>
</ol>
<p>The first is unfortunate but rarely fatal. The second is the best case, but it can monopolize your time. The third is the killer; an idea ignored comes back again and again, sounding worse each time but never going away. Know this, that either you will cause your thoughts to serve you or you will be made to serve them. It is a tyranny of the mind, and you must capture them somehow. Otherwise your mind may choose to hold onto its ideas until you are ready to listen again. Even if you capture an idea only to throw it away later on, now it is out of your mind and you can move on with accomplishing other things. If you were not going to act on that idea, then you have forcibly moved it from the third case to the first and avoided the mental fatigue that accompanies an idea that is ignored!</p>
<p>So, with apologies to Frank Herbert:</p>
<blockquote><p>I must not procrastinate. Procrastination is the mind-killer. Procrastination is the little-death that brings total obliteration. I will face my idea. I will permit it to pass over my mind and through my fingers. And when it has been recorded I will turn the inner eye to see its path. Where the procrastination has gone there will be nothing. Only my productivity will remain.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://philiphanson.org/2011/the-mind-killer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Finding Images Using Images</title>
		<link>http://philiphanson.org/2011/finding-images-using-images/</link>
		<comments>http://philiphanson.org/2011/finding-images-using-images/#comments</comments>
		<pubDate>Tue, 14 Jun 2011 15:32:43 +0000</pubDate>
		<dc:creator>Philip Hanson</dc:creator>
				<category><![CDATA[Algorithms]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://philiphanson.org/?p=54</guid>
		<description><![CDATA[So Google Image Search is great when you can express what you’re looking for in text, like "cat on roof" or "map of Kansas." But what if you want an image similar to one you already have? Wouldn’t it be better to search using the image? For content producers, it might also be important to [...]]]></description>
			<content:encoded><![CDATA[<p>So <a href="http://images.google.com/">Google Image Search</a> is great when you can express what you’re looking for in text, like "cat on roof" or "map of Kansas." But what if you want an image similar to one you already have? Wouldn’t it be better to search using the image?</p>
<p>For content producers, it might also be important to search the Internet for images identical to images they own to protect against copyright infringement. Performing that kind of search using text would be difficult at best, and impossible to automate.</p>
<p>This is not really my research area, but a few years ago I needed to write a research paper for a class and hit on the idea of using fingerprint recognition algorithms for image search. Thus the incredibly wordy title of (deep breath):</p>
<p><a href="http://philiphanson.org/?attachment_id=55">A Novel Use of Automated Fingerprint Identification Systems for Large-Scale Image Search on the World Wide Web</a></p>
<p>Self-important titling out of the way, it was quite an interesting technology evaluation to perform. Of note, several of the companies I looked at also sell facial recognition software, and some may even produce large-scale image search systems now; I haven't kept up with the market.</p>
<p>Most interesting of all, though, is the productization of image search: a site called <a href="http://www.tineye.com/">TinEye</a> takes an image as input and returns a list of similar images, along with their location on the Internet. This, of course, is a long tradition in computing: yesterday's research project is today's hot product and tomorrow's old hat. Fun to see it in action, though.</p>
<p><strong>Update</strong>: <a href="http://techcrunch.com/2011/06/14/google-search-by-image-use-a-snapshot-as-your-search-query/">Google image search using images</a> was just announced today at Google's 'Inside Search' event. Interesting that this space is starting to get populated now!</p>
]]></content:encoded>
			<wfw:commentRss>http://philiphanson.org/2011/finding-images-using-images/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Extract Images from a Microsoft Word Document</title>
		<link>http://philiphanson.org/2011/how-to-extract-images-from-a-microsoft-word-document/</link>
		<comments>http://philiphanson.org/2011/how-to-extract-images-from-a-microsoft-word-document/#comments</comments>
		<pubDate>Tue, 24 May 2011 14:50:27 +0000</pubDate>
		<dc:creator>Philip Hanson</dc:creator>
				<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://philiphanson.org/?p=51</guid>
		<description><![CDATA[Why would you need to extract images from a Word document? You saved the originals, right? Right? No? Me either. Or maybe you did direct copy-and-paste composition, taking images directly from your web browser. For whatever reason, now you need your images back and don't have the sources. This is not a common use case, [...]]]></description>
			<content:encoded><![CDATA[<p>Why would you need to extract images from a Word document? You saved the originals, right? Right? No? Me either. Or maybe you did direct copy-and-paste composition, taking images directly from your web browser. For whatever reason, now you need your images back and don't have the sources.</p>
<p>This is not a common use case, so Word doesn't make it easy for you. Fortunately, there is a simple (though non-obvious) process for getting the sources back:</p>
<ol>
<li>Export the document as a "Web page with supporting files".
<ul>
<li>This will save all embedded images (and their original forms, if they've been modified) to a folder in the same directory as your exported HTML file.</li>
<li>Note that the folder and files are linked to the HTML file, so moving it around may have unintended consequences.</li>
</ul>
</li>
<li>Look inside the 'supporting files' folder and find the image(s) you want to use.</li>
<li>Copy the image(s) to another location to break their link to the exported HTML file.</li>
</ol>
<p>That's it! Your source images will even be in the same format as they were originally.</p>
]]></content:encoded>
			<wfw:commentRss>http://philiphanson.org/2011/how-to-extract-images-from-a-microsoft-word-document/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Three-Legged Products</title>
		<link>http://philiphanson.org/2011/three-legged-products/</link>
		<comments>http://philiphanson.org/2011/three-legged-products/#comments</comments>
		<pubDate>Fri, 13 May 2011 14:45:10 +0000</pubDate>
		<dc:creator>Philip Hanson</dc:creator>
				<category><![CDATA[Marketing]]></category>

		<guid isPermaLink="false">http://philiphanson.org/?p=49</guid>
		<description><![CDATA[A three-legged stool is the most stable of all seats because three points define a plane. No matter what surface it is sitting on, the three legs will find places to rest, and the stool will not wobble. It might be tilted and uncomfortable, but it will be stable. One leg is not stable at [...]]]></description>
			<content:encoded><![CDATA[<p>A three-legged stool is the most stable of all seats because three points define a plane. No matter what surface it is sitting on, the three legs will find places to rest, and the stool will not wobble. It might be tilted and uncomfortable, but it will be stable.</p>
<p>One leg is not stable at all; two legs, stable on one axis; three legs, stable on both axes. But four legs (a chair) can be unstable if the surface does not match the lengths of the legs precisely.</p>
<p>So it is with product marketing: you need to provide some number of selling points in order to make a solid case. You must be careful in the construction of these points, however, because if you are too zealous and exaggerate the benefits, later selling points may interfere with or negate those that came before.</p>
<p>If you can't add any more selling points to your list without contradicting what you've already said, you don't have any more selling points. Or you lied. If you run out of selling points before the sale is stable (a two-legged stool), then you don't have a compelling product.</p>
]]></content:encoded>
			<wfw:commentRss>http://philiphanson.org/2011/three-legged-products/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Attaching an Interface to a Class</title>
		<link>http://philiphanson.org/2010/attaching-interface-class/</link>
		<comments>http://philiphanson.org/2010/attaching-interface-class/#comments</comments>
		<pubDate>Tue, 23 Nov 2010 11:30:52 +0000</pubDate>
		<dc:creator>Philip Hanson</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[interfaces]]></category>
		<category><![CDATA[object-oriented]]></category>

		<guid isPermaLink="false">http://philiphanson.org/?p=27</guid>
		<description><![CDATA[There's a reminder that I need from time to time. Here, I'll share it with you: it is not possible to attach an interface to a class in C#. If the class does not declare that it implements the interface, then you have no way to attach that interface or its methods to an instance [...]]]></description>
			<content:encoded><![CDATA[<p>There's a reminder that I need from time to time. Here, I'll share it with you: <em>it is not possible to attach an interface to a class in C#</em>. If the class does not declare that it implements the interface, then you have no way to attach that interface or its methods to an instance of the class. This is annoying when you're trying to program to an interface and realize  For example, suppose we've defined the following interface and a couple classes:<br />
<script src="https://gist.github.com/710153.js?file=InterfaceImplementation.cs"></script></p>
<p>This is a toy example, so the interface isn't really that useful. However, what if I want to treat ExplicitAdder and ImplicitAdder the same way? Both classes provide an Add method that accepts two integers and returns void. They're still different types, however, and ImplicitAdder doesn't declare that it implements IAdd even though the method signature matches the definition. This is by design, of course; it could be that the method in ImplicitAdder has nothing to do with IAdd and only matches the signature by accident. But it does make things difficult when you <em>really</em> want that class to implement IAdd:<br />
<script src="https://gist.github.com/710153.js?file=InterfaceUsageExample.cs"></script></p>
<p>This code shows the result of two different types of casting in an attempt to "attach" the IAdd interface to ImplicitAdder. Of course, casting ExplicitAdder to a variable of type IAdd works just fine. But when we use the 'as' keyword to perform the same conversion on ImplicitAdder, a null value is returned, indicating that this is an invalid cast. The explicit cast throws an InvalidCastException.</p>
<p>It is possible to execute the Add method using reflection on the type (or in C# 4, using the <a href="http://msdn.microsoft.com/en-us/library/dd264741.aspx">dynamic</a> type), but this makes code fragile. What if the interface changes? The compiler cant' tell us to update the class. What if the class changes? The compiler can't tell us to update the reflection code. It just moves the problem into the run-time arena. This is a tactic to use when there's no other solution, but I don't like it much for software maintenance. No, the proper way to attach an interface to a class is by using a decorator of sorts:<br />
<script src="https://gist.github.com/710153.js?file=CorrectSolution.cs"></script></p>
<p>Here we wrap the ImplicitAdder in a class that <em>does</em> implement IAdd. We pass a reference to an ImplicitAdder into the constructor and then use the wrapper object instead. This way the compiler can check all of our references at compile-time due to static typing.</p>
]]></content:encoded>
			<wfw:commentRss>http://philiphanson.org/2010/attaching-interface-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generic Visitor Pattern in C#</title>
		<link>http://philiphanson.org/2010/generic-visitor-pattern-csharp/</link>
		<comments>http://philiphanson.org/2010/generic-visitor-pattern-csharp/#comments</comments>
		<pubDate>Thu, 05 Aug 2010 20:37:17 +0000</pubDate>
		<dc:creator>Philip Hanson</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[generics]]></category>
		<category><![CDATA[patterns]]></category>

		<guid isPermaLink="false">http://philiphanson.org/?p=17</guid>
		<description><![CDATA[The traditional model for application of the Visitor pattern, assuming that the visitable classes are immutable, is that the visitor class can produce data in one of two ways: it can either return data from the Visit() method, or it can aggregate data types inside the class. (The third option is to do both, of [...]]]></description>
			<content:encoded><![CDATA[<p>The traditional model for application of the <a title="Wikipedia: Visitor pattern" href="http://en.wikipedia.org/wiki/Visitor_pattern">Visitor pattern</a>, assuming that the visitable classes are immutable, is that the visitor class can produce data in one of two ways: it can either return data from the <code>Visit()</code> method, or it can aggregate data types inside the class. (The third option is to do both, of course.)</p>
<p>All well and good, but this model feels pretty limiting if you want to have multiple visitors that work on the same objects but produce different data types. In that case you can a) create as many versions of the visitor interface as you have data types to be returned, b) always aggregate within the visitor class, thus having to deal with mutable state inside the visitor, or c) always return <code>object</code>. Of those options, the first is tedious and the third is ugly. To my mind, both of them defeat the purpose of having the pattern in the first place. The second option is not bad, but I wanted something better than that.</p>
<p>Modern languages such as Java and C# include support for generics, so I tried my hand at writing a generic Visitor pattern that could be used on the same data structures by multiple visitor implementations that produce different data types. Using the new (well, newly old) features in C# 3.0, I was able to get a lot more. Let's start by looking at the <code>IVisitor</code> interface, which is parameterized by data type:</p>
<p><script src="http://gist.github.com/510251.js?file=IVisitor.cs"></script></p>
<p><code>IVisitor</code> is fairly straightforward when you think about it — we define a set of methods that accept an object of type R and produce an object of type R by visiting an <code>IVisitable</code>. This way we can write a single <code>IVisitor</code> interface for a data structure and then specialize it for a specific type later on, during the implementation.  This is a nice improvement, but there's more we can do. C# 3.5 introduced <a title="MSDN: Extension Methods" href="http://msdn.microsoft.com/en-us/library/bb383977.aspx">extension methods</a>, which allow us to attach methods to a wide range of classes at one time. Using a single extension method, we can eliminate the need for the second half of the traditional Visitor pattern, the <code>Accept()</code> method:</p>
<p><script src="http://gist.github.com/510251.js?file=Extensions.cs"></script></p>
<p>Now the <code>Accept()</code> method is available to be called on any class that implements <code>IVisitable</code>, as long as we provide an implementation of <code>IVisitor</code>. This means that we don't have to copy and paste the same code to every class that implements <code>IVisitable</code> any more! We can just call this method and .NET will wire it up.</p>
<p>The above definition makes use of a marker interface called <code>IVisitable</code>, but you could even restrict the application implicitly by which <code>Visit()</code> methods you define. In the case of a marker interface, you simply need to include a default method for visiting an <code>IVisitable</code> like so:</p>
<p><script src="http://gist.github.com/510251.js?file=ExampleVisitor.cs"></script></p>
<p>Which completes the generic visitor. Using a generalized class like this one allows us to program in a more functional and (hopefully) testable way. Plus, it's nice to actually use the new language features once in a while.</p>
<p>It's entirely possible that I've missed something in the implementation, so be sure to shout out in the comments if you've found a problem. Otherwise, enjoy your new generic Visitor in C#!</p>
<p>P.S. I should also give credit to some StackOverflow answers that suggested this approach, as well as a blog post on <a href="Generic Visitor Implementation">generic visitors in C#</a> by Nicolas Penin, though I'm not aware of anyone else with an identical approach.</p>
<p><strong>Update</strong>: Daniel Gr&ouml;ndal pointed out some issues with this approach in the comments. It turns out that the extension method does not work as I thought it did during my initial testing. Please read the comment thread for more details!</p>
]]></content:encoded>
			<wfw:commentRss>http://philiphanson.org/2010/generic-visitor-pattern-csharp/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

