<?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>Precision Computing</title>
	<atom:link href="http://www.leeholmes.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.leeholmes.com/blog</link>
	<description>Software Design and Development</description>
	<lastBuildDate>Thu, 26 Apr 2012 16:50:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Queueing Theory for the Busy PowerShell Admin</title>
		<link>http://www.leeholmes.com/blog/2012/04/26/queueing-theory-for-the-busy-powershell-admin/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=queueing-theory-for-the-busy-powershell-admin</link>
		<comments>http://www.leeholmes.com/blog/2012/04/26/queueing-theory-for-the-busy-powershell-admin/#comments</comments>
		<pubDate>Thu, 26 Apr 2012 16:50:47 +0000</pubDate>
		<dc:creator>Lee Holmes</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.leeholmes.com/blog/?p=371</guid>
		<description><![CDATA[The biggest scripting event of the year is getting close to wrapping up &#8211; Scripting Games 2012! There have been a ton of great challenges, a ton of great competitors, and a ton of great commentary. As one of the guest commentators, I was asked to write a script to monitor uptime on servers in [...]]]></description>
			<content:encoded><![CDATA[<p>The biggest scripting event of the year is getting close to wrapping up &#8211; <a href="http://blogs.technet.com/b/heyscriptingguy/archive/tags/2012+scripting+games/">Scripting Games 2012</a>! There have been a ton of great challenges, a ton of great competitors, and a ton of great commentary.</p>
<p>As one of the guest commentators, I was asked to write a script to monitor uptime on servers in the environment.</p>
<p>To make this as efficient as possible, the solution leveraged WMI jobs to process 32 computers at a time. What’s most amazing about Windows PowerShell jobs running 32 tasks in parallel is not that it makes things 32 times faster. It’s that it makes them even faster than that! The reason is a branch of computer science called “queueing theory.”</p>
<p>For the surprising and cool reasons why, see the blog post here: <a title="http://blogs.technet.com/b/heyscriptingguy/archive/2012/04/23/expert-commentary-2012-scripting-games-advanced-event-6.aspx" href="http://blogs.technet.com/b/heyscriptingguy/archive/2012/04/23/expert-commentary-2012-scripting-games-advanced-event-6.aspx">http://blogs.technet.com/b/heyscriptingguy/archive/2012/04/23/expert-commentary-2012-scripting-games-advanced-event-6.aspx</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leeholmes.com/blog/2012/04/26/queueing-theory-for-the-busy-powershell-admin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MakerBot Replicator Rainbow Color Pack Group Buy</title>
		<link>http://www.leeholmes.com/blog/2012/04/17/makerbot-replicator-rainbow-color-pack-group-buy/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=makerbot-replicator-rainbow-color-pack-group-buy</link>
		<comments>http://www.leeholmes.com/blog/2012/04/17/makerbot-replicator-rainbow-color-pack-group-buy/#comments</comments>
		<pubDate>Tue, 17 Apr 2012 21:31:02 +0000</pubDate>
		<dc:creator>Lee Holmes</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.leeholmes.com/blog/?p=368</guid>
		<description><![CDATA[If you own a Makerbot Replicator, you might have seen some of the amazing colours they offer: http://store.makerbot.com/plastic/1-75mm-filament.html. &#160; Unfortunately, trying to get a full colour palette (13 colours in stock) means having so much plastic you&#8217;ll never get through it all. Makerbot tried offering rainbow colour packs before, but they are now no longer [...]]]></description>
			<content:encoded><![CDATA[<p>If you own a Makerbot Replicator, you might have seen some of the amazing colours they offer: <a href="http://store.makerbot.com/plastic/1-75mm-filament.html">http://store.makerbot.com/plastic/1-75mm-filament.html</a>.</p>
<p><a href="http://www.leeholmes.com/blog/wp-content/uploads/2012/04/image.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; border-left: 0px; display: block; padding-right: 0px; margin-right: auto" border="0" alt="image" src="http://www.leeholmes.com/blog/wp-content/uploads/2012/04/image_thumb.png" width="624" height="417" /></a></p>
<p>&#160;</p>
<p> Unfortunately, trying to get a full colour palette (13 colours in stock) means having so much plastic you&#8217;ll never get through it all. Makerbot <a href="http://www.makerbot.com/blog/2010/03/04/makebot-abs-rainbow-pack/">tried offering rainbow colour packs before</a>, but they are now no longer for sale. I suggested it again via email, but it sounds like they’re pretty slammed with making Replicators :)&#160;
<p>&#160;</p>
<p>Here’s the idea:</p>
<p><u>Standard Variety Pack – $100</u></p>
<p>Silver, Dark Brown, Yellow, Green, Red, Magenta, Orange, Blue</p>
<p>You get 1/8th of a spool (~ 150m) of each – for 1kg in total.</p>
<p>&#160;</p>
<p><u>Electric Pack – $100</u></p>
<p>Light Brown, Fluorescent Yellow, Nuclear Green, Fluorescent Red</p>
<p>You get /14 of a spool (~ 300m) of each – for 1kg in total.</p>
<p>&#160;</p>
<p>In searching elsewhere online, the only alternative I’ve found is <a href="http://www.faberdashery.co.uk/products-page/">Faberdashery</a> – where the same deal would cost about $250 USD. I’ve done some back-of-the-envelope calculating, and I think a group buy would be an effective way to get a rainbow colour pack at cost-effective prices.</p>
<p>If you’re interested, mail me: makerbot @ this domain.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leeholmes.com/blog/2012/04/17/makerbot-replicator-rainbow-color-pack-group-buy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Download an Entire WordPress Blog</title>
		<link>http://www.leeholmes.com/blog/2012/03/31/how-to-download-an-entire-wordpress-blog/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-download-an-entire-wordpress-blog</link>
		<comments>http://www.leeholmes.com/blog/2012/03/31/how-to-download-an-entire-wordpress-blog/#comments</comments>
		<pubDate>Sun, 01 Apr 2012 02:09:34 +0000</pubDate>
		<dc:creator>Lee Holmes</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.leeholmes.com/blog/?p=358</guid>
		<description><![CDATA[Sometimes, you stumble on a blog that is so chock full of information that you revel in its every word. And then you realize their archive goes back 5 years! I’ve read a bunch of great posts on Nate Lawson’s awesome security blog, and decided that I wanted to read it beginning to end. If [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes, you stumble on a blog that is so chock full of information that you revel in its every word. And then you realize their archive goes back 5 years!</p>
<p><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.leeholmes.com/blog/wp-content/uploads/2012/03/image.png" width="644" height="484" /></p>
<p>I’ve read a bunch of great posts on <a href="http://rdist.root.org/">Nate Lawson’s awesome security blog</a>, and decided that I wanted to read it beginning to end.</p>
<p>If you are the owner of said WordPress blog, the solution is easy – use WordPress’ built-in <strong>Export</strong> feature. There are even handy services that will turn this into a PDF, eBook, or even printed book.</p>
<p>If you’re not the owner, things aren’t so easy:</p>
<ol>
<li>Sit in front of the computer </li>
<li>Go to the oldest month in the archives menu that I hadn’t yet visited </li>
<li>Read that page </li>
<li>Click “Next Page” until those links stop appearing </li>
<li>Go back to the home page </li>
<li>(Repeat steps 2-5 until you’re done with the blog) </li>
</ol>
<p>Oh, and if you intend to take a break at any point in time, add in a few “try to remember where you were, and find that blog post again” entries.</p>
<p>What I was really hoping for was:</p>
<ol>
<li>Open a PDF on my Kindle, and read the entire thing in chronological order, letting the Kindle software keep track of where I am. </li>
</ol>
<p>It turns out that the difference between reality and desire is about twelve lines of PowerShell!</p>
<p>PowerShell’s recent technology previews (and the Windows 8 consumer and developer preview) include the Invoke-WebRequest cmdlet.Think wget / curl, but with PowerShell’s traditional object-based awesome-sauce. For example:</p>
<pre style="background-color: #012456; color: #eeedf0">PS C:\temp&gt; Invoke-WebRequest http://www.leeholmes.com/blog |
&gt;&gt;     Foreach-Object Links |
&gt;&gt;     Where-Object InnerText -match &quot;August&quot; |
&gt;&gt;     Foreach-Object Href       

http://www.leeholmes.com/blog/2011/08/

http://www.leeholmes.com/blog/2010/08/

http://www.leeholmes.com/blog/2008/08/

http://www.leeholmes.com/blog/2007/08/

http://www.leeholmes.com/blog/2006/08/

http://www.leeholmes.com/blog/2005/08/
</pre>
<p>When you look at links to the monthly archives, they all follow the pattern:</p>
<blockquote>
<p><a href="http://www.example.com/url/&lt;number&gt;&lt;number&gt;&lt;number&gt;&lt;number&gt;/&lt;number&gt;&lt;number&gt;/">//&quot;&gt;//&quot;&gt;http://www.example.com/url/<em>&lt;number&gt;&lt;number&gt;&lt;number&gt;&lt;number&gt;</em>/<em>&lt;number&gt;&lt;number&gt;</em>/</a></p>
</blockquote>
<p>When you visit any of these pages, they have another link. The exact text depends on the blog itself – but it may be “Earlier Entries”, “Next Page”, or similar:</p>
<pre style="background-color: #012456; color: #eeedf0">PS C:\temp&gt; $page = Invoke-WebRequest http://www.leeholmes.com/blog/2005/06/
PS C:\temp&gt; $page.Links | Where-Object InnerText -match &quot;Earlier Entries&quot; |
&gt;&gt;     Select-Object -First 1
&gt;&gt;                                                                                                                      

innerHTML : Earlier Entries ?
innerText : Earlier Entries ?
outerHTML : <span>&lt;</span>A href=&quot;http://www.leeholmes.com/blog/2005/06/page/2/&quot;&gt;Earlier Entries ?<span>&lt;</span>/A&gt;
outerText : Earlier Entries ?
tagName   : A
href      : http://www.leeholmes.com/blog/2005/06/page/2/                                                               
</pre>
<p>Given that knowledge, we can automate the download of the entire blog, dumping it into an HTML file as we go. As a final step, we print this HTML to PDF, and upload it to our Kindle or other reading device.</p>
<blockquote>
<p><em>Note to purists</em>: this HTML file is brutally malformed. It is a collection of HTML pages packed into the same file, rather than one HTML page with all the important content. It is of course possible to make this a valid HTML file by manipulating the content before writing it – there’s just no need to do it if the destination is a PDF anyhow.</p>
</blockquote>
<p>And how about time effort? In the end, I had a PDF of the entire blog on my Kindle 20 minutes after first having thought of it.</p>
<p>Here’s the PowerShell script that automates this all – cleaned up for your consumption, of course :)</p>
<pre class="PowerShellColorizedScript"><span style="color: #006400">## Things you might want to change</span>
<span style="color: #ff4500">$blogUrl</span> <span style="color: #a9a9a9">=</span> <span style="color: #8b0000">&quot;http:/www.leeholmes.com/blog&quot;</span>
<span style="color: #ff4500">$archiveLinkPattern</span> <span style="color: #a9a9a9">=</span> <span style="color: #8b0000">'/\d\d\d\d/\d\d/$'</span>
<span style="color: #ff4500">$nextPageText</span> <span style="color: #a9a9a9">=</span> <span style="color: #8b0000">&quot;Earlier Entries&quot;</span>            

<span style="color: #006400">## Get the page</span>
<span style="color: #ff4500">$r</span> <span style="color: #a9a9a9">=</span> <span style="color: #0000ff">Invoke-WebRequest</span> <span style="color: #ff4500">$blogUrl</span>            

<span style="color: #006400">## Extract the archives links</span>
<span style="color: #ff4500">$links</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$r</span><span style="color: #a9a9a9">.</span><span style="color: #000000">Links</span> <span style="color: #a9a9a9">|</span> <span style="color: #0000ff">Where-Object</span> <span style="color: #8a2be2">href</span> <span style="color: #000080">-match</span> <span style="color: #ff4500">$archiveLinkPattern</span> <span style="color: #a9a9a9">|</span>
    <span style="color: #0000ff">Foreach-Object</span> <span style="color: #8a2be2">href</span>            

<span style="color: #006400">## Sort the archives in reverse order</span>
<span style="color: #ff4500">$links</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$links</span><span style="color: #a9a9a9">[</span><span style="color: #ff4500">$links</span><span style="color: #a9a9a9">.</span><span style="color: #000000">Count</span><span style="color: #a9a9a9">..</span><span style="color: #800080">0</span><span style="color: #a9a9a9">]</span>            

<span style="color: #006400">## Go through each archive page</span>
<span style="color: #00008b">foreach</span><span style="color: #000000">(</span><span style="color: #ff4500">$link</span> <span style="color: #00008b">in</span> <span style="color: #ff4500">$links</span><span style="color: #000000">)</span>
<span style="color: #000000">{</span>
    <span style="color: #006400">## Create a variable to hold the HTML content for this month</span>
    <span style="color: #ff4500">$monthExport</span> <span style="color: #a9a9a9">=</span> <span style="color: #8b0000">&quot;&quot;</span>            

    <span style="color: #00008b">do</span>
    <span style="color: #000000">{</span>
        <span style="color: #006400">## Get the archives for that month</span>
        <span style="color: #ff4500">$month</span> <span style="color: #a9a9a9">=</span> <span style="color: #0000ff">Invoke-WebRequest</span> <span style="color: #ff4500">$link</span>            

        <span style="color: #006400">## Get the page content, and put it at the beginning of the</span>
        <span style="color: #006400">## monthExport variable. That's because &quot;Earlier Entries&quot;</span>
        <span style="color: #006400">## should be placed before the content we just got.</span>
        <span style="color: #ff4500">$monthExport</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$month</span><span style="color: #a9a9a9">.</span><span style="color: #000000">Content</span> <span style="color: #a9a9a9">+</span> <span style="color: #8b0000">&quot;`r`n&quot;</span> <span style="color: #a9a9a9">+</span> <span style="color: #ff4500">$monthExport</span>            

        <span style="color: #006400">## Find the link to &quot;Earlier Entires&quot;</span>
        <span style="color: #ff4500">$link</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$month</span><span style="color: #a9a9a9">.</span><span style="color: #000000">Links</span> <span style="color: #a9a9a9">|</span> <span style="color: #0000ff">?</span> <span style="color: #8a2be2">innertext</span> <span style="color: #000080">-match</span> <span style="color: #ff4500">$nextPageText</span> <span style="color: #a9a9a9">|</span>
            <span style="color: #0000ff">Foreach-Object</span> <span style="color: #8a2be2">href</span> <span style="color: #a9a9a9">|</span> <span style="color: #0000ff">Select-Object</span> <span style="color: #000080">-First</span> <span style="color: #800080">1</span>            

    <span style="color: #006400">## Keep on doing this while we found an &quot;Earlier Entries&quot; link</span>
    <span style="color: #000000">}</span> <span style="color: #00008b">while</span><span style="color: #000000">(</span><span style="color: #ff4500">$link</span><span style="color: #000000">)</span>            

    <span style="color: #006400">## Now that we're done with the month, put it at the end of the</span>
    <span style="color: #006400">## HTML file (since we're processing months in order)</span>
    <span style="color: #ff4500">$monthExport</span> <span style="color: #a9a9a9">&gt;&gt;</span> <span style="color: #8a2be2">leeholmes.html</span>
<span style="color: #000000">}</span></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.leeholmes.com/blog/2012/03/31/how-to-download-an-entire-wordpress-blog/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>A Celebration, if You Can Figure it Out</title>
		<link>http://www.leeholmes.com/blog/2012/03/17/a-celebration-if-you-can-figure-it-out/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=a-celebration-if-you-can-figure-it-out</link>
		<comments>http://www.leeholmes.com/blog/2012/03/17/a-celebration-if-you-can-figure-it-out/#comments</comments>
		<pubDate>Sat, 17 Mar 2012 18:04:17 +0000</pubDate>
		<dc:creator>Lee Holmes</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.leeholmes.com/blog/2012/03/17/a-celebration-if-you-can-figure-it-out/</guid>
		<description><![CDATA[We were talking about a very cool astrological date on the internal PowerShell mailing list recently. In celebration of this event, Josh Rowe made this brilliant comment. See if you can figure out what it does :) clear;$00=(0..1250&#124;%{9608}),(0..7645&#124;%{9617})&#124;%{$_};(-10..29)&#124; %{$OO='';$O0=$_;-10..64&#124;%{$0O=$_;$OO+=[char]($00[$0O*$0O-48*$0O+ 1720+4*$O0*$O0-96*$O0],@($00[$0O*$0O-52*$0O+1644+4*$O0*$O0-88* $O0],9617,9617)[(0,1)[($0O-lt28)]+($O0-gt12)])[(0,1)[$0O-gt24]* ($O0-lt14)]};$OO};0..573892165&#124;%{$OO=@((($OO+0)*4*$_*$_/(4*$_* $_-1)),1d)[$_-lt1];write-progress ":-)"($OO*2)} I suppose that’s not really fair. Here it is in all [...]]]></description>
			<content:encoded><![CDATA[<p>We were talking about a very cool astrological date on the internal PowerShell mailing list recently. In celebration of this event, Josh Rowe made this brilliant comment. See if you can figure out what it does :)</p>
<pre>clear;$00=(0..1250|%{9608}),(0..7645|%{9617})|%{$_};(-10..29)|
%{$OO='';$O0=$_;-10..64|%{$0O=$_;$OO+=[char]($00[$0O*$0O-48*$0O+
1720+4*$O0*$O0-96*$O0],@($00[$0O*$0O-52*$0O+1644+4*$O0*$O0-88*
$O0],9617,9617)[(0,1)[($0O-lt28)]+($O0-gt12)])[(0,1)[$0O-gt24]*
($O0-lt14)]};$OO};0..573892165|%{$OO=@((($OO+0)*4*$_*$_/(4*$_*
$_-1)),1d)[$_-lt1];write-progress ":-)"($OO*2)}</pre>
<p>I suppose that’s not really fair. Here it is in all of its syntax-highlighted glory:</p>
<pre class="PowerShellColorizedScript"><span style="color: #0000ff;">clear</span><span style="color: #000000;">;</span><span style="color: #ff4500;">$00</span><span style="color: #a9a9a9;">=</span><span style="color: #000000;">(</span><span style="color: #800080;">0</span><span style="color: #a9a9a9;">..</span><span style="color: #800080;">1250</span><span style="color: #a9a9a9;">|</span><span style="color: #0000ff;">%</span><span style="color: #000000;">{</span><span style="color: #800080;">9608</span><span style="color: #000000;">}</span><span style="color: #000000;">)</span><span style="color: #a9a9a9;">,</span><span style="color: #000000;">(</span><span style="color: #800080;">0</span><span style="color: #a9a9a9;">..</span><span style="color: #800080;">7645</span><span style="color: #a9a9a9;">|</span><span style="color: #0000ff;">%</span><span style="color: #000000;">{</span><span style="color: #800080;">9617</span><span style="color: #000000;">}</span><span style="color: #000000;">)</span><span style="color: #a9a9a9;">|</span><span style="color: #0000ff;">%</span><span style="color: #000000;">{</span><span style="color: #ff4500;">$_</span><span style="color: #000000;">}</span><span style="color: #000000;">;</span><span style="color: #000000;">(</span><span style="color: #800080;">-10</span><span style="color: #a9a9a9;">..</span><span style="color: #800080;">29</span><span style="color: #000000;">)</span><span style="color: #a9a9a9;">|</span>
<span style="color: #0000ff;">%</span><span style="color: #000000;">{</span><span style="color: #ff4500;">$OO</span><span style="color: #a9a9a9;">=</span><span style="color: #8b0000;">''</span><span style="color: #000000;">;</span><span style="color: #ff4500;">$O0</span><span style="color: #a9a9a9;">=</span><span style="color: #ff4500;">$_</span><span style="color: #000000;">;</span><span style="color: #800080;">-10</span><span style="color: #a9a9a9;">..</span><span style="color: #800080;">64</span><span style="color: #a9a9a9;">|</span><span style="color: #0000ff;">%</span><span style="color: #000000;">{</span><span style="color: #ff4500;">$0O</span><span style="color: #a9a9a9;">=</span><span style="color: #ff4500;">$_</span><span style="color: #000000;">;</span><span style="color: #ff4500;">$OO</span><span style="color: #a9a9a9;">+=</span><span style="color: #008080;">[char]</span><span style="color: #000000;">(</span><span style="color: #ff4500;">$00</span><span style="color: #a9a9a9;">[</span><span style="color: #ff4500;">$0O</span><span style="color: #a9a9a9;">*</span><span style="color: #ff4500;">$0O</span><span style="color: #a9a9a9;">-</span><span style="color: #800080;">48</span><span style="color: #a9a9a9;">*</span><span style="color: #ff4500;">$0O</span><span style="color: #a9a9a9;">+</span>
<span style="color: #800080;">1720</span><span style="color: #a9a9a9;">+</span><span style="color: #800080;">4</span><span style="color: #a9a9a9;">*</span><span style="color: #ff4500;">$O0</span><span style="color: #a9a9a9;">*</span><span style="color: #ff4500;">$O0</span><span style="color: #a9a9a9;">-</span><span style="color: #800080;">96</span><span style="color: #a9a9a9;">*</span><span style="color: #ff4500;">$O0</span><span style="color: #a9a9a9;">]</span><span style="color: #a9a9a9;">,</span><span style="color: #000000;">@(</span><span style="color: #ff4500;">$00</span><span style="color: #a9a9a9;">[</span><span style="color: #ff4500;">$0O</span><span style="color: #a9a9a9;">*</span><span style="color: #ff4500;">$0O</span><span style="color: #a9a9a9;">-</span><span style="color: #800080;">52</span><span style="color: #a9a9a9;">*</span><span style="color: #ff4500;">$0O</span><span style="color: #a9a9a9;">+</span><span style="color: #800080;">1644</span><span style="color: #a9a9a9;">+</span><span style="color: #800080;">4</span><span style="color: #a9a9a9;">*</span><span style="color: #ff4500;">$O0</span><span style="color: #a9a9a9;">*</span><span style="color: #ff4500;">$O0</span><span style="color: #a9a9a9;">-</span><span style="color: #800080;">88</span><span style="color: #a9a9a9;">*</span>
<span style="color: #ff4500;">$O0</span><span style="color: #a9a9a9;">]</span><span style="color: #a9a9a9;">,</span><span style="color: #800080;">9617</span><span style="color: #a9a9a9;">,</span><span style="color: #800080;">9617</span><span style="color: #000000;">)</span><span style="color: #a9a9a9;">[</span><span style="color: #000000;">(</span><span style="color: #800080;">0</span><span style="color: #a9a9a9;">,</span><span style="color: #800080;">1</span><span style="color: #000000;">)</span><span style="color: #a9a9a9;">[</span><span style="color: #000000;">(</span><span style="color: #ff4500;">$0O</span><span style="color: #a9a9a9;">-lt</span><span style="color: #800080;">28</span><span style="color: #000000;">)</span><span style="color: #a9a9a9;">]</span><span style="color: #a9a9a9;">+</span><span style="color: #000000;">(</span><span style="color: #ff4500;">$O0</span><span style="color: #a9a9a9;">-gt</span><span style="color: #800080;">12</span><span style="color: #000000;">)</span><span style="color: #a9a9a9;">]</span><span style="color: #000000;">)</span><span style="color: #a9a9a9;">[</span><span style="color: #000000;">(</span><span style="color: #800080;">0</span><span style="color: #a9a9a9;">,</span><span style="color: #800080;">1</span><span style="color: #000000;">)</span><span style="color: #a9a9a9;">[</span><span style="color: #ff4500;">$0O</span><span style="color: #a9a9a9;">-gt</span><span style="color: #800080;">24</span><span style="color: #a9a9a9;">]</span><span style="color: #a9a9a9;">*</span>
<span style="color: #000000;">(</span><span style="color: #ff4500;">$O0</span><span style="color: #a9a9a9;">-lt</span><span style="color: #800080;">14</span><span style="color: #000000;">)</span><span style="color: #a9a9a9;">]</span><span style="color: #000000;">}</span><span style="color: #000000;">;</span><span style="color: #ff4500;">$OO</span><span style="color: #000000;">}</span><span style="color: #000000;">;</span><span style="color: #800080;">0</span><span style="color: #a9a9a9;">..</span><span style="color: #800080;">573892165</span><span style="color: #a9a9a9;">|</span><span style="color: #0000ff;">%</span><span style="color: #000000;">{</span><span style="color: #ff4500;">$OO</span><span style="color: #a9a9a9;">=</span><span style="color: #000000;">@(</span><span style="color: #000000;">(</span><span style="color: #000000;">(</span><span style="color: #ff4500;">$OO</span><span style="color: #a9a9a9;">+</span><span style="color: #800080;">0</span><span style="color: #000000;">)</span><span style="color: #a9a9a9;">*</span><span style="color: #800080;">4</span><span style="color: #a9a9a9;">*</span><span style="color: #ff4500;">$_</span><span style="color: #a9a9a9;">*</span><span style="color: #ff4500;">$_</span><span style="color: #a9a9a9;">/</span><span style="color: #000000;">(</span><span style="color: #800080;">4</span><span style="color: #a9a9a9;">*</span><span style="color: #ff4500;">$_</span><span style="color: #a9a9a9;">*</span>
<span style="color: #ff4500;">$_</span><span style="color: #a9a9a9;">-</span><span style="color: #800080;">1</span><span style="color: #000000;">)</span><span style="color: #000000;">)</span><span style="color: #a9a9a9;">,</span><span style="color: #800080;">1d</span><span style="color: #000000;">)</span><span style="color: #a9a9a9;">[</span><span style="color: #ff4500;">$_</span><span style="color: #a9a9a9;">-lt</span><span style="color: #800080;">1</span><span style="color: #a9a9a9;">]</span><span style="color: #000000;">;</span><span style="color: #0000ff;">write-progress</span> <span style="color: #8b0000;">":-)"</span><span style="color: #000000;">(</span><span style="color: #ff4500;">$OO</span><span style="color: #a9a9a9;">*</span><span style="color: #800080;">2</span><span style="color: #000000;">)</span><span style="color: #000000;">}</span></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.leeholmes.com/blog/2012/03/17/a-celebration-if-you-can-figure-it-out/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>PowerShell Book Reviews</title>
		<link>http://www.leeholmes.com/blog/2012/03/11/powershell-book-reviews/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=powershell-book-reviews</link>
		<comments>http://www.leeholmes.com/blog/2012/03/11/powershell-book-reviews/#comments</comments>
		<pubDate>Sun, 11 Mar 2012 18:09:13 +0000</pubDate>
		<dc:creator>Lee Holmes</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.leeholmes.com/blog/2012/03/11/powershell-book-reviews/</guid>
		<description><![CDATA[There have been a handful of useful posts recently giving reviews across the spectrum of PowerShell books. I always love reading these posts, as they let you compare and contrast the whole range of quality and approaches. When reading reviews that focus only on a single book, it’s sometimes hard to calibrate – does the [...]]]></description>
			<content:encoded><![CDATA[<p>There have been a handful of useful posts recently giving reviews across the spectrum of PowerShell books. I always love reading these posts, as they let you compare and contrast the whole range of quality and approaches. When reading reviews that focus only on a single book, it’s sometimes hard to calibrate – does the reviewer get this excited about blank reams of paper? Slag Shakespeare for his typos?</p>
<p>My favourite is Richard Siddaway’s summary, freshly updated today: <a title="http://richardspowershellblog.wordpress.com/2012/03/11/powershell-booksmarch-2012/" href="http://richardspowershellblog.wordpress.com/2012/03/11/powershell-booksmarch-2012/">http://richardspowershellblog.wordpress.com/2012/03/11/powershell-booksmarch-2012/</a>. The ecosystem of PowerShell books has really blossomed – I love that there are two books on managing VMWare on this list!</p>
<p>Jonathan Medd also has a good list here: <a title="http://www.jonathanmedd.net/2011/01/recommended-powershell-books.html" href="http://www.jonathanmedd.net/2011/01/recommended-powershell-books.html">http://www.jonathanmedd.net/2011/01/recommended-powershell-books.html</a>.</p>
<p>A resource I am hopeful about is Don Jones’ recently launched <a title="http://www.powershellbooks.com" href="http://www.powershellbooks.com">http://www.powershellbooks.com</a>. Its goal is to “<em>help you select the Windows PowerShell book or books that best fit your current learning and reference needs</em>.” Several of Don’s books are in every “PowerShell must have” list. His “Learn PowerShell in a Month of Lunches” book for beginners is tearing up the charts. Right now, the review site only covers books by Manning Press (plus an additional book that Don wrote), so it’s not an objective survey. I hope he expands his scope to make it one. It also doesn’t actually review the books (it links to product pages), but I’m still crossing my fingers because Don’s touch has a way of turning things into gold :)</p>
<p>The books that tend to get left off these lists are the domain-specific ones: PowerShell + SQL, PowerShell + Exchange, PowerShell + SharePoint. Those ecosystems are becoming robust enough to support a survey of “PowerShell SQL” books, for example, although I’m not aware of any that have done so.</p>
<p>If you know of any good book comparison lists, please let me know!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leeholmes.com/blog/2012/03/11/powershell-book-reviews/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The PowerShell Pay-it-Forward Award</title>
		<link>http://www.leeholmes.com/blog/2011/11/10/the-powershell-pay-it-forward-award/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-powershell-pay-it-forward-award</link>
		<comments>http://www.leeholmes.com/blog/2011/11/10/the-powershell-pay-it-forward-award/#comments</comments>
		<pubDate>Thu, 10 Nov 2011 18:09:54 +0000</pubDate>
		<dc:creator>Lee Holmes</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.leeholmes.com/blog/2011/11/10/the-powershell-pay-it-forward-award/</guid>
		<description><![CDATA[As I was going through some things, I realized that I have a handful of author copies of my PowerShell Cookbook remaining. There are several of the first edition, several of the second edition, and several of the pocket references. After thinking about what to do with them, I hereby announce the PowerShell Pay-it-Forward Award. [...]]]></description>
			<content:encoded><![CDATA[<p>As I was going through some things, I realized that I have a handful of author copies of my PowerShell Cookbook remaining. There are several of the <a href="http://www.amazon.com/Windows-Powershell-Cookbook-Exchange-2007/dp/0596528493">first edition</a>, several of the <a href="http://www.amazon.com/gp/product/0596801505/">second edition</a>, and several of the <a href="http://www.amazon.com/Windows-PowerShell-Pocket-Reference-OReilly/dp/0596521782">pocket references</a>.</p>
<p>After thinking about what to do with them, I hereby announce the PowerShell Pay-it-Forward Award.</p>
<p>If you would like a free signed copy of any of these books, I have a simple request. Go forth on the internet: Stack Overflow, blogs, Twitter, whatever. Find a PowerShell newbie with a gnarly problem. Not just a syntax problem, but some hairy business problem. Work with them to solve it.</p>
<p>Post your results back here in the comments (with a link to the interaction,) and I’ll give books to those that have helped a user (or users) the most.</p>
<p>I’ll announce the winners on December 1st.</p>
<p>Good luck!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leeholmes.com/blog/2011/11/10/the-powershell-pay-it-forward-award/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Breaking Hash Codes &#8211; Part I</title>
		<link>http://www.leeholmes.com/blog/2011/11/06/breaking-hash-codes-part-i/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=breaking-hash-codes-part-i</link>
		<comments>http://www.leeholmes.com/blog/2011/11/06/breaking-hash-codes-part-i/#comments</comments>
		<pubDate>Mon, 07 Nov 2011 06:36:29 +0000</pubDate>
		<dc:creator>Lee Holmes</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.leeholmes.com/blog/2011/11/06/breaking-hash-codes-part-i/</guid>
		<description><![CDATA[When we last left off, we discussed hash codes &#8211; a small unique identifier for an item based on its properties or features. There are many different ways to calculate unique identifiers for items. These different ways are called Hash Algorithms. Each serves a different purpose, but some popular ones right now are are MD5, [...]]]></description>
			<content:encoded><![CDATA[<p>When we last left off, <a href="http://www.leeholmes.com/blog/2011/02/06/an-introduction-to-hashing-and-hash-codes/">we discussed hash codes</a> &#8211; <em>a small unique identifier for an item based on its properties or features</em>.</p>
<p>There are many different ways to calculate unique identifiers for items. These different ways are called <em>Hash Algorithms</em>. Each serves a different purpose, but some popular ones right now are are MD5, SHA1, and SHA256.</p>
<p>Why so many?</p>
<p>The reason is security. Our last post finished with the question:</p>
<blockquote><p><em>Using hash codes for simple content verification is one thing. But what if an attacker is trying to trick you with hash code collisions? For example, can you use that Visual Studio download if it’s from your worst enemy – but the hash code still matches? It depends on the algorithm!</em></p></blockquote>
<p>The security industry first started touching on the importance of “secure” hash algorithms in the 1970s. There were a flurry of proposals in the 80s that were immediately dismissed with security problems, but one called “<a href="http://en.wikipedia.org/wiki/MD5">MD5</a>” was introduced in the early 90s that seemed like it might last the test of time.</p>
<p>In 2004, however, advances in security research found issues in MD5 – thus “breaking MD5”. While you can still use MD5 just fine when security is not a concern, you cannot trust a version of Visual Studio from your enemy just because the MD5 hash value matches.</p>
<p>Here are the four features of an ideal <a href="http://en.wikipedia.org/wiki/Cryptographic_hash_function">cryptographic hash algorithm</a>:</p>
<ul>
<li>it is easy (but not necessarily quick) to compute the hash value for any given message</li>
<li>it is infeasible to generate a message that has a given hash</li>
<li>it is infeasible to modify a message without changing the hash</li>
<li>it is infeasible to find two different messages with the same hash</li>
</ul>
<p>If you get #2, then for the most part you get #3 and #4 automatically.</p>
<p>How does one “break” a hash algorithm? Let’s take a look a a few from the .NET Framework for an interesting exercise in reverse engineering.</p>
<p>As a background, every object in the .NET Framework supports a method called “<a href="http://msdn.microsoft.com/en-us/library/system.object.gethashcode.aspx">GetHashCode()</a>”. It does a good job of returning a small random(ish) identifier for an object, so it is used primarily for putting objects into hash tables. This method returns a 32-bit integer, and is <strong><span style="text-decoration: underline;">not</span></strong> designed for security purposes:</p>
<blockquote><p><span style="font-family: Consolas;"><span style="line-height: normal; word-wrap: break-word; white-space: pre; word-break: break-all;"><span style="color: #0000ff;"><span style="font-size: 9.7pt;">public</span></span></span><span style="font-size: 9.7pt;"><span style="line-height: normal; word-wrap: break-word; white-space: pre; word-break: break-all;"><span style="color: #0000ff;">virtual</span></span><span style="line-height: normal; word-wrap: break-word; white-space: pre; word-break: break-all;"><span style="color: #0000ff;">int</span></span><span style="color: #000000;"> GetHashCode() </span></span></span></p></blockquote>
<p>The <a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.sha256.aspx">HashAlgorithm</a> class <strong><span style="text-decoration: underline;">is</span></strong> designed for security purposes, however, and should be used when security is a concern. We won’t use that class as an example, because if I can break that class in this blog, then it wouldn’t be in the .NET Framework!</p>
<h2>Breaking Int32</h2>
<p>Let’s see how this works on integers, and see how it would fare as a cryptographic hash algorithm:</p>
<blockquote>
<pre style="background-color: #012456; font-family: 'Lucida Console'; color: #f0edee;">PS &gt; (1).GetHashCode()
1
PS &gt; (2).GetHashCode()
2
PS &gt; (1337).GetHashCode()
1337
PS &gt; (-1337).GetHashCode()
-1337</pre>
</blockquote>
<p>I think we see a pattern :) It looks like .NET is returning our input right back at us. It’s a sure way to prevent collisions, that’s for sure! If we open Int32.GetHashCode() in .NET Reflector (or ILSpy), we can see why:</p>
<blockquote><p><span style="font-family: Times New Roman;"><span style="line-height: normal;"><span style="color: #0000ff;"><strong><span style="font-size: 12pt;">public</span></strong></span></span><span style="font-size: 12pt;"><span style="color: #000000;"> </span><span style="line-height: normal;"><span style="color: #a52a2a;">override</span></span><span style="color: #000000;"> </span><span style="line-height: normal;"><span style="color: #ff0000;"><strong>int</strong></span></span><span style="color: #000000;"> </span><span style="line-height: normal;"><span style="color: #191970;"><strong>GetHashCode</strong></span></span></span></span><span style="font-family: Times New Roman;"><span style="font-size: 12pt;"><span style="color: #006400;"><span style="line-height: normal;">()</span> </span></span></span></p>
<p><span style="line-height: normal;">{</span></p>
<p><span style="color: #000000;">    </span><span style="line-height: normal;"><span style="color: #000080;">return</span></span><span style="color: #000000;"> <span style="line-height: normal;"><strong>this</strong></span></span><span style="color: #006400;"><span style="line-height: normal;">;</span> </span></p>
<p><span style="line-height: normal;"><span style="color: #006400; font-size: 12pt;">}</span></span></p></blockquote>
<p>The score sheet?</p>
<blockquote>
<table style="line-height: normal;">
<tbody>
<tr>
<td><span><span style="font-family: Times New Roman;"><span style="color: #008a00; font-size: 13.6pt;">☑</span></span></span></td>
<td><span style="font-family: Times New Roman;"><span style="color: #000000; font-size: 12pt;">it is easy to compute the hash value for any given message</span></span></td>
</tr>
<tr>
<td><span><span style="font-family: Times New Roman;"><span style="color: #8a0000; font-size: 13.6pt;">☒</span></span></span></td>
<td><span style="font-family: Times New Roman;"><span style="color: #000000; font-size: 12pt;">it is infeasible to generate a message that has a given hash</span></span></td>
</tr>
<tr>
<td><span><span style="font-family: Times New Roman;"><span style="color: #008a00; font-size: 13.6pt;">☑</span></span></span></td>
<td><span style="font-family: Times New Roman;"><span style="color: #000000; font-size: 12pt;">it is infeasible to modify a message without changing the hash</span></span></td>
</tr>
<tr>
<td><span><span style="font-family: Times New Roman;"><span style="color: #008a00; font-size: 13.6pt;">☑</span></span></span></td>
<td><span style="font-family: Times New Roman;"><span style="color: #000000; font-size: 12pt;">it is infeasible to find two different messages with the same hash</span></span></td>
</tr>
</tbody>
</table>
</blockquote>
<p>Not bad, but you can’t do much with just integers.</p>
<h2>Breaking Int64</h2>
<p>That wasn’t too challenging to break. What about Int64? That doesn’t fit in 32 bits by definition, so let’s see if there is any pattern:</p>
<blockquote>
<pre style="background-color: #012456; font-family: 'Lucida Console'; color: #f0edee;">PS &gt; ([Int64] 1).GetHashCode()
1
PS &gt; ([Int64] 1337).GetHashCode()
1337
PS &gt; ([Int64] 12345678987654321).GetHashCode()
1656367333</pre>
</blockquote>
<p>For “low” numbers (below 32 bits?) it seems to be the same as the input number. After that, not quite sure. We can’t break this one by intuition. Let’s see the source:</p>
<blockquote><p><span style="font-family: Times New Roman;"><span style="line-height: normal;"><span style="color: #0000ff;"><strong><span style="font-size: 12pt;">public</span></strong></span></span><span style="font-size: 12pt;"><span style="color: #000000;"> </span><span style="line-height: normal;"><span style="color: #a52a2a;">override</span></span><span style="color: #000000;"> </span><span style="line-height: normal;"><span style="color: #ff0000;"><strong>int</strong></span></span><span style="color: #000000;"> </span><span style="line-height: normal;"><span style="color: #191970;"><strong>GetHashCode</strong></span></span></span></span><span style="font-family: Times New Roman;"><span style="font-size: 12pt;"><span style="color: #006400;"><span style="line-height: normal;">()</span> </span></span></span></p>
<p><span style="line-height: normal;">{</span></p>
<p><span style="color: #000000;">    </span><span style="line-height: normal;"><span style="color: #000080;">return</span></span><span style="color: #000000;"> </span><span style="line-height: normal;"><span style="color: #006400;">(</span></span><span style="line-height: normal;"><span style="color: #ff0000;"><strong>int</strong></span></span><span style="line-height: normal;"><span style="color: #006400;">)</span></span><span style="color: #000000;"><span style="line-height: normal;"><strong>this</strong></span> </span><span style="line-height: normal;"><span style="color: #006400;">^</span></span><span style="color: #000000;"> </span><span style="line-height: normal;"><span style="color: #006400;">(</span></span><span style="line-height: normal;"><span style="color: #ff0000;"><strong>int</strong></span></span><span style="line-height: normal;"><span style="color: #006400;">)(</span></span><span style="color: #000000;"><span style="line-height: normal;"><strong>this</strong></span> </span><span style="line-height: normal;"><span style="color: #006400;">&gt;&gt;</span></span><span style="color: #000000;"> </span><span style="line-height: normal;"><span style="color: #00008b;">32</span></span><span style="color: #006400;"><span style="line-height: normal;">);</span> </span></p>
<p><span style="line-height: normal;"><span style="color: #006400; font-size: 12pt;">}</span></span></p></blockquote>
<p>What the .NET Framework is doing here is pretty simple:</p>
<blockquote>
<table width="400" border="0" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td valign="top" width="152"><span style="line-height: normal;"><span style="color: #006400;">(</span></span><span style="line-height: normal;"><span style="color: #ff0000;"><strong>int</strong></span></span><span style="line-height: normal;"><span style="color: #006400;">)</span></span><span style="color: #000000;"><span style="line-height: normal;"><strong>this</strong></span> </span></td>
<td valign="top" width="248">Takes the lower 32-bits of the 64-bit number.</td>
</tr>
<tr>
<td valign="top" width="152"><span style="line-height: normal;"><span style="color: #006400;">(</span></span><span style="line-height: normal;"><span style="color: #ff0000;"><strong>int</strong></span></span><span style="line-height: normal;"><span style="color: #006400;">)(</span></span><span style="color: #000000;"><span style="line-height: normal;"><strong>this</strong></span> </span><span style="line-height: normal;"><span style="color: #006400;">&gt;&gt;</span></span><span style="line-height: normal;"><span style="color: #00008b;">32</span></span><span style="color: #006400;"><span style="line-height: normal;">)</span></span></td>
<td valign="top" width="248">Shifts the number to the right by 32 places, and then takes the lower 32 bits of the number. That is the same thing as taking the upper 32 bits of the number.</td>
</tr>
<tr>
<td valign="top" width="152"><span style="line-height: normal;"><span style="color: #006400;">(</span></span><span style="line-height: normal;"><span style="color: #ff0000;"><strong>int</strong></span></span><span style="line-height: normal;"><span style="color: #006400;">)</span></span><span style="color: #000000;"><span style="line-height: normal;"><strong>this</strong></span> </span><span style="line-height: normal;"><span style="color: #006400;">^</span></span><span style="line-height: normal;"><span style="color: #006400;">(</span></span><span style="line-height: normal;"><span style="color: #ff0000;"><strong>int</strong></span></span><span style="line-height: normal;"><span style="color: #006400;">)(</span></span><span style="color: #000000;"><span style="line-height: normal;"><strong>this</strong></span> </span><span style="line-height: normal;"><span style="color: #006400;">&gt;&gt;</span></span><span style="line-height: normal;"><span style="color: #00008b;">32</span></span><span style="color: #006400;"><span style="line-height: normal;">)</span></span></td>
<td valign="top" width="248">Uses the binary XOR operator to combine the upper 32 bits and the lower 32 bits.</td>
</tr>
</tbody>
</table>
</blockquote>
<p>The first row explains why all of our “low” numbers seemed to just return themselves. The low numbers were the lower 32 bits, and there were no upper 32 bits.</p>
<p>Let’s take a look at:</p>
<blockquote>
<pre style="background-color: #012456; font-family: 'Lucida Console'; color: #f0edee;">
PS &gt; ([Int64] 12345678987654321).GetHashCode()
1656367333</pre>
</blockquote>
<p>If we convert this to the upper and lower 32 bits, we get:</p>
<blockquote>
<pre style="background-color: #012456; font-family: 'Lucida Console'; color: #f0edee;">PS &gt; [Convert]::ToString(12345678987654321, 2)
101011110111000101010001100010100100011111010010110001
PS &gt; [Convert]::ToString(12345678987654321, 2).PadLeft(64, "0")
0000000000101011110111000101010001100010100100011111010010110001</pre>
</blockquote>
<p>Now, split them into the top and bottom 32 bits take the <a href="http://www.xcprod.com/titan/XCSB-DOC/binary_xor.html">binary exclusive OR</a> (either bit is 1, but not both):</p>
<blockquote>
<table width="400" border="0" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td valign="top" width="78">Upper 32</td>
<td valign="top" width="322">00000000001010111101110001010100</td>
</tr>
<tr>
<td valign="top" width="78">Lower 32</td>
<td valign="top" width="322">01100010100100011111010010110001</td>
</tr>
<tr>
<td valign="top" width="78">XOR</td>
<td valign="top" width="322">01100010101110100010100011100101</td>
</tr>
</tbody>
</table>
</blockquote>
<p>Taking a look at the final result, it looks like we have the same as what .NET gave us:</p>
<blockquote>
<pre style="background-color: #012456; font-family: 'Lucida Console'; color: #f0edee;">
PS &gt; [Convert]::ToInt32("01100010101110100010100011100101", 2)
1656367333

PS &gt; ([Int64] 12345678987654321).GetHashCode()
1656367333</pre>
</blockquote>
<p>Now that we understand the algorithm, let’s see how we might break the strongest guarantee of a hash algorithm – namely, “<em>it is infeasible to generate a message that has a given hash</em>.”</p>
<p>Let’s pretend we want to generate a 64-bit number with the hash value of <strong>1337. </strong>That has the following binary value:</p>
<blockquote>
<pre style="background-color: #012456; font-family: 'Lucida Console'; color: #f0edee;">PS &gt; [Convert]::ToString(1337, 2).PadLeft(32, "0")
00000000000000000000010100111001</pre>
</blockquote>
<p>Since the 64-bit hash is generated by combining the upper and lower halves of the number, the simplest way is to simply ignore the upper 32 bits:</p>
<blockquote>
<table width="402" border="0" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td valign="top" width="78">Upper 32</td>
<td valign="top" width="322">00000000000000000000000000000000</td>
</tr>
<tr>
<td valign="top" width="78">Lower 32</td>
<td valign="top" width="322">00000000000000000000010100111001</td>
</tr>
<tr>
<td valign="top" width="78">XOR</td>
<td valign="top" width="322">00000000000000000000010100111001</td>
</tr>
</tbody>
</table>
</blockquote>
<p>That was simple enough. What about breaking the next strongest feature: “<em>it is infeasible to find two different messages with the same hash.</em>”</p>
<p>Given that we know how to find an Int64 for any given hash value, how can we find <em>multiple</em> Int64s that have the same hash value?</p>
<p>To figure this out, we’ll use a trick from the XOR operation frequently used in <a href="http://en.wikipedia.org/wiki/XOR_cipher">XOR cyphers and XOR encryption</a>:</p>
<blockquote><p><em>If A XOR B = C</p>
<p>Then A = B XOR C </em></p>
<p>And B = A XOR C</p></blockquote>
<p>If we pretend that A is the upper 32 bits of a number, B is the lower 32 bits of a number, and C is the hash code, then we have the following options:</p>
<blockquote><p>Upper 32 bits = (Lower 32 bits) XOR (Hash code)</p>
<p>or</p>
<p>Lower 32 bits = (Upper 32 bits) XOR (Hash code)</p></blockquote>
<p>Given that, here’s all we have to do to find a number with a specific hash code:</p>
<ul>
<li>Pick an arbitrary number for the lower (or upper) 32 bits</li>
<li>XOR it with the hash code</li>
<li>The result will be the other 32 bits you need</li>
</ul>
<p>Let’s look at an example, using 10001011001010110101101011010111 as a randomly-chosen number:</p>
<blockquote>
<table width="402" border="0" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td valign="top" width="120">Upper 32</td>
<td valign="top" width="280">10001011001010110101101011010111</td>
</tr>
<tr>
<td valign="top" width="120">Hash Code</td>
<td valign="top" width="280">00000000000000000000010100111001</td>
</tr>
<tr>
<td valign="top" width="120">XOR (= Lower 32)</td>
<td valign="top" width="280">?</td>
</tr>
</tbody>
</table>
</blockquote>
<p>PowerShell has the “-bxor” operator, so let’s make this easier on ourselves:</p>
<blockquote>
<pre style="background-color: #012456; font-family: 'Lucida Console'; color: #f0edee;">PS &gt; $upper32 = [Convert]::ToInt32("10001011001010110101101011010111", 2)
PS &gt; $hash = [Convert]::ToInt32("00000000000000000000010100111001", 2)
PS &gt; $lower32 = $upper32 -bxor $hash
PS &gt; [Convert]::ToString($lower32, 2)
10001011001010110101111111101110</pre>
</blockquote>
<p>So now we have a hash collision – let’s be sure:</p>
<blockquote>
<pre style="background-color: #012456; font-family: 'Lucida Console'; color: #f0edee;">PS &gt; $number = [Convert]::ToInt64(
&gt;&gt;     "10001011001010110101101011010111" +
&gt;&gt;     "10001011001010110101111111101110", 2)
&gt;&gt;
PS &gt; $number
-8418535196639666194</pre>
</blockquote>
<p>Let’s see:</p>
<blockquote>
<pre style="background-color: #012456; font-family: 'Lucida Console'; color: #f0edee;">PS &gt; ([Int64] -8418535196639666194).GetHashCode()
1337</pre>
</blockquote>
<p>Bingo. We can now generate hash collisions for arbitrary hash codes. What does that mean?</p>
<blockquote>
<table>
<tbody>
<tr>
<td><span style="color: #008a00; font-size: larger;">☑</span></td>
<td>it is easy to compute the hash value for any given message</td>
</tr>
<tr>
<td><span style="color: #8a0000; font-size: larger;">☒</span></td>
<td>it is infeasible to generate a message that has a given hash</td>
</tr>
<tr>
<td><span style="color: #8a0000; font-size: larger;">☒</span></td>
<td>it is infeasible to modify a message without changing the hash</td>
</tr>
<tr>
<td><span style="color: #8a0000; font-size: larger;">☒</span></td>
<td>it is infeasible to find two different messages with the same hash</td>
</tr>
</tbody>
</table>
</blockquote>
<p><strong>Bonus question</strong>: <em>how many hash collisions can you generate for a given hash code? And how might you do so systematically?</em></p>
<p>Chew on that a bit – in our next post, we’ll take a crack at reverse-engineering <strong>String.GetHashCode()</strong>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leeholmes.com/blog/2011/11/06/breaking-hash-codes-part-i/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubisoft Rocksmith Review</title>
		<link>http://www.leeholmes.com/blog/2011/10/26/ubisoft-rocksmith-review/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ubisoft-rocksmith-review</link>
		<comments>http://www.leeholmes.com/blog/2011/10/26/ubisoft-rocksmith-review/#comments</comments>
		<pubDate>Wed, 26 Oct 2011 08:49:33 +0000</pubDate>
		<dc:creator>Lee Holmes</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.leeholmes.com/blog/2011/10/26/ubisoft-rocksmith-review/</guid>
		<description><![CDATA[On Tuesday of last week, Ubisoft released Rocksmith: an XBOX / PS3 / PC guitar game with a twist. You play a real guitar. You learn the real notes. Your fingers hurt just like every great guitarist before you. &#160; For some context, guitar has been part of my life for a long time – [...]]]></description>
			<content:encoded><![CDATA[<p>On Tuesday of last week, Ubisoft released <a href="http://rocksmith.ubi.com/rocksmith/en-US/home/">Rocksmith</a>: an <a href="http://www.amazon.com/s?ie=UTF8&amp;x=0&amp;ref_=nb_sb_noss&amp;y=0&amp;field-keywords=rocksmith&amp;url=search-alias%3Daps&amp;_encoding=UTF8&amp;tag=preciscomput-20&amp;linkCode=ur2&amp;camp=1789&amp;creative=390957">XBOX / PS3 / PC guitar game</a> with a twist.</p>
<p align="center">You play a real guitar.</p>
<p align="center">You learn the real notes.</p>
<p align="center">Your fingers hurt just like every great guitarist before you.</p>
<p align="center">&#160;</p>
<p><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://www.leeholmes.com/blog/wp-content/uploads/2011/10/image1.png" width="504" height="281" /></p>
<p>For some context, guitar has been part of my life for a long time – although my proficiency with it has waxed and waned (currently waning). I made the most progress with classical guitar, but ran into a cliff of frustration when songs started calling for notes out of the basic first few positions. A couple of editions of the PowerShell Cookbook will put a dent in your free time, so that may have something to do with it, too :)</p>
<p>This kind of “Guitar Hero but with real guitar” game has been a pipe dream for a long time. A few years ago, the <a href="http://en.wikipedia.org/wiki/Guitar_Wizard#Guitar_Wizard">Music Wizard</a> folks started shopping around a new game called “Guitar Wizard”. After hearing about it, I promptly signed up for their mailing list &#8211; but they’ve now removed all of the product pages from their site and I suspect have abandoned the project entirely.</p>
<p>The primary reason behind this lack of advancement in the field has long been technical. Most software that tries to convert raw guitar sounds into something that a computer can understand ends up failing pretty fast. The note recognition ends up being glitchy, inaccurate, and frustrating. Things have heated up recently, with applications like <a href="http://plus.ultimate-guitar.com/jamguru/">JamGuru</a> (PC) and <a href="http://rockprodigy.com/">Rock Prodigy</a> (iPad) that help you learn the tablature versions of songs through sophisticated note recognition. </p>
<p>Rock Band 3 introduced “Pro Mode” for guitar (which has been getting good reviews), but there have been mixed feelings about the way the guitar interface is presented. Also, they took another approach to resolving the technical issues by making you use their specific guitar. That second point really hurts if you have a well-loved (or unloved!) guitar already.</p>
<p>While computer scientists are out flogging and publishing minor advances in audio recognition, Rocksmith and this new breed of apps have somehow just quietly and magically <a href="http://www.xkcd.com/664/">figured it out, and shipped it</a>. The note recognition truly does feel magical, and never crosses your mind after that.</p>
<p>After getting a brief intro on how to use the system, Rocksmith starts you off with a simple lead part to “(I Can’t Get No) Satisfaction” by the Rolling Stones.</p>
<p><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; display: block; padding-right: 0px; border-top-width: 0px; margin-right: auto" border="0" alt="image" src="http://www.leeholmes.com/blog/wp-content/uploads/2011/10/image2.png" width="488" height="220" /></p>
<h2>It’s really you</h2>
<p>At even its simplest levels, you truly feel like you’re playing the song. This is where Rocksmith stands out as a music game. In rhythm games like Rock Band, you use the guitar controller (or real guitar) to hit the right notes at the right time. As long as you do that correctly, the game continues to replace you with the pre-recorded guitar track of the song. If you make a mistake, it replaces you with a squelchy sound of a guitar mistake. What kind of mistake, you might ask? Were you off by a fret? Too late? Too early? Who knows!</p>
<p>Rocksmith, on the other hand, plays the actual sounds from your guitar. They send it through a virtual amplifier and effects chain so that you have the same tone as the guitar from the original song, but you’ll hear it immediately if you’re off by a fret. The note will sound too high or low (just as it does in real guitar), so you can easily correct by ear alone.</p>
<h2>Don’t be afraid to experiment</h2>
<p>If you’ve played other rhythm games like Rock Band, you’ve probably looked down the “Note Highway” with dread as 2 minutes of the same boring pattern approach.</p>
<p>Rocksmith solves this problem wonderfully. Want to noodle around for the beginning of the song? Add some trills, double-plucks or experimental harmonies? Go ahead! Rocksmith doesn’t penalize you for these – as long as you still at least hit the notes that it’s displayed.</p>
<p>Speaking of noodling around, Rocksmith has the best load screen I’ve ever seen. It activates the virtual amp whenever it’s “Loading…”, so you can take that time to warm up, play around, or experiment with new ideas.</p>
<p>As I mentioned earlier, Rocksmith creates your in-game sound by sending your guitar through a virtual amplifier and effects chain. Once you start completing songs, Rocksmith makes these components available to you in a free-form playground called “Amp Mode”. You can pick pre-set sounds from any of the songs you earned them from, or mix and match components (pedals, amps, etc.) to make something completely different. Spend a minute, spend an hour, either way you’ll have fun.</p>
<p><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; display: block; padding-right: 0px; border-top-width: 0px; margin-right: auto" border="0" alt="image" src="http://www.leeholmes.com/blog/wp-content/uploads/2011/10/image3.png" width="504" height="277" /></p>
<h2>You learn actual guitar</h2>
<p>After playing the songs for awhile, you’ll amaze yourself by picking up the guitar when it’s not even plugged in. You’ll play the same thing you’ve been playing all along, but then realize the sounds of the song are coming from your <em>guitar</em>, not your <em>video game</em>. They don’t include <a href="http://www.youtube.com/watch?v=FOt3r_aNNxE">Stairway to Heaven</a> in the song list, so you’ll be safe playing these at the local guitar shop, too!</p>
<p>After you’ve been playing songs for a while, Rocksmith opens up a handful of guitar trainers / challenge games. These games let you practice specific techniques (chords, scales, neck position, bends) that improve your actual guitar skill, as well as in-game performance.</p>
<p><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; border-left: 0px; display: block; padding-right: 0px; margin-right: auto" border="0" alt="image" src="http://www.leeholmes.com/blog/wp-content/uploads/2011/10/image4.png" width="504" height="276" /></p>
<p>So, far I’ve only unlocked two challenge games: Ducks (which teaches you how to find fret positions quickly) and Dawn of the Chordead (which teaches you to play and recall chords). Dawn of the Chordead unquestionably teaches you transferrable guitar skills. Being able to quickly find and play a chord (and then smoothly transition to the next one) is crucial for playing many songs. Ducks makes you a much better <em>game</em> player, but offers limited benefit for <em>real</em> guitar (see My One Big Complaint).</p>
<h2></h2>
<h2>What’s not to like?</h2>
<p>While I’m a big fan of the game, there are some rough edges. First off, you need to use your regular game controller to navigate through the game. When you’ve got a guitar strapped around your neck and the wireless controllers are going to sleep, this is just annoying. Why you can’t just use the guitar to control the entire game is beyond me – Rocksmith has already proven that it can accurately recognize input from a real guitar!</p>
<p>Second is practice mode. When a song starts to prove challenging, they offer a neat set of trainers that let you just practice through a difficult section. These trainers let you gradually increase difficulty or speed for a specific section. It would be nice if there was a more holistic practice mode that let you master a song section-by-section by increasing difficulty and then speed for each section. What’s most annoying about the practice mode is that you’ve got five “lives”. If you can’t play it fast enough or accurately enough in five attempts, then it kicks you back to the practice screen. From there, you have to click through all the menus, loading screen, tuning process, etc. It’s just a lot of process for something that should be the most forgiving in the entire game.</p>
<h3>My One Big Complaint</h3>
<p>My One Big Complaint stems from wanting the skills from the game to have more benefit to my real guitar playing.</p>
<p>As I mentioned before, guitar mastery is heavily influenced by how well you know the fretboard. To show you where to put your fingers when you play, Rocksmith sends fret numbers down the Note Highway:</p>
<p><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; border-left: 0px; display: block; padding-right: 0px; margin-right: auto" border="0" alt="image" src="http://www.leeholmes.com/blog/wp-content/uploads/2011/10/image5.png" width="504" height="252" /></p>
<p>This is very similar to Guitar tablature, and is a great way to learn a song. The alternative is the traditional music staff, which even professional musicians have difficulty sight-reading and would be a deal breaker for the game.</p>
<p>However, becoming a lightning-fast tablature reader hits a dead-end at some point. It’s like becoming a god at watercolour paint-by-numbers. Just as you need to learn to draw and choose pigment at some point while becoming an artist, a guitarist will eventually need to know what notes they are playing (C,D,E, etc.) On this point, Rocksmith misses a great opportunity. If they simply offered an option to replace the coloured blocks with coloured letters (i.e.: yellow on the 5th fret = D), they’d unlock a vast world of <em>true musicianship</em> to millions of fledgling guitarists. Rock Prodigy offers this in their interface, and it help immensely:</p>
<p><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; border-left: 0px; display: block; padding-right: 0px; margin-right: auto" border="0" alt="image" src="http://www.leeholmes.com/blog/wp-content/uploads/2011/10/image6.png" width="504" height="279" /></p>
<p>&#160;</p>
<h2>I bought it, and would buy it again</h2>
<p>When you add up all the pros and cons, there isn’t really a question in my mind. If my cat ate the game tonight, I would buy it again tomorrow.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leeholmes.com/blog/2011/10/26/ubisoft-rocksmith-review/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Morser &#8211; Keyboard Morse Input Device</title>
		<link>http://www.leeholmes.com/blog/2011/10/04/morser-keyboard-morse-input-device-2/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=morser-keyboard-morse-input-device-2</link>
		<comments>http://www.leeholmes.com/blog/2011/10/04/morser-keyboard-morse-input-device-2/#comments</comments>
		<pubDate>Wed, 05 Oct 2011 05:50:01 +0000</pubDate>
		<dc:creator>Lee Holmes</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.leeholmes.com/blog/2011/10/04/morser-keyboard-morse-input-device-2/</guid>
		<description><![CDATA[[Download: Morser.zip, 155kb] [Updated 10/04/2011 – V2 includes support for audio input] &#160; If you’re interested in Morse Code as a hobby or just as a neat lo-fi communication mechanism, one thing that might set you back is the lack of practical opportunities to use it. You can find lots of Morse Code apps that [...]]]></description>
			<content:encoded><![CDATA[<p>[Download: <a href="http://www.leeholmes.com/projects/morser/Morser.zip">Morser.zip</a>, 155kb]</p>
<p><em>[Updated 10/04/2011 – V2 includes support for audio input]</em></p>
<p>&#160;</p>
<p>If you’re interested in Morse Code as a hobby or just as a neat lo-fi communication mechanism, one thing that might set you back is the lack of practical opportunities to use it.</p>
<p>You can find lots of Morse Code apps that let you practice into a little text box, but nothing that you can tweet with, blog with chat with, etc.</p>
<p>Morser is a simple little program that solves this need.</p>
<p><a href="http://www.leeholmes.com/blog/wp-content/uploads/2011/10/image.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; border-left: 0px; display: block; padding-right: 0px; margin-right: auto" border="0" alt="image" src="http://www.leeholmes.com/blog/wp-content/uploads/2011/10/image_thumb.png" width="341" height="484" /></a></p>
<p>After launching it, press Control-Alt-M to enable or disable it. It works no matter what application you have running, so you can minimize it and switch to an application that you want to use it with. When enabled, Morser acts as a straight keyer. It listens for presses of your keyboard’s down arrow and automatically types the letter that corresponds to your Morse code input.</p>
<p>If you hook up any audio device (i.e.: a real actual keyer) to an input jack, Morser converts the audio input to text as well.</p>
<p>If you have funny characters to enter, just type them on your keyboard as you normally would.</p>
<p>The Control-Alt-M hotkey also works in any application, so you don’t need to switch back to Morser to enable or disable it.</p>
<p>Here’s an example of it interpreting somebody’s YouTube video. I hooked my audio output to my Mic Input.</p>
<div id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:9548fc86-1aee-41af-8430-a31bc99fd090" class="wlWriterEditableSmartContent" style="width: 448px; float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px auto; display: block; padding-right: 0px">
<div><object width="448" height="252"><param name="movie" value="http://www.youtube.com/v/pDLvAwEEszM?hl=en&amp;hd=1"></param><embed src="http://www.youtube.com/v/pDLvAwEEszM?hl=en&amp;hd=1" type="application/x-shockwave-flash" width="448" height="252"></embed></object></div>
</div>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leeholmes.com/blog/2011/10/04/morser-keyboard-morse-input-device-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PowerShell Wallpapers</title>
		<link>http://www.leeholmes.com/blog/2011/09/26/powershell-wallpapers/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=powershell-wallpapers</link>
		<comments>http://www.leeholmes.com/blog/2011/09/26/powershell-wallpapers/#comments</comments>
		<pubDate>Mon, 26 Sep 2011 16:27:49 +0000</pubDate>
		<dc:creator>Lee Holmes</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.leeholmes.com/blog/?p=332</guid>
		<description><![CDATA[Shay Levy, one of our great MVPs, has been crafting sweet PowerShell desktop backgrounds for years now. One thing I&#8217;ve always loved is that they seem to carry a message. His first wallpaper was a screaming crowd. In my head, they are people chanting for the power of PowerShell, or the IT rock star that [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blogs.microsoft.co.il/blogs/ScriptFanatic/">Shay Levy</a>, one of our great MVPs, has been crafting sweet PowerShell desktop backgrounds for years now. One thing I&#8217;ve always loved is that they seem to carry a message.</p>
<p>His first wallpaper was a screaming crowd. In my head, they are people chanting for the power of PowerShell, or the IT rock star that saved the deployment. It&#8217;s been my background since he posted it, and has graced many a conference presentation.</p>
<p>He&#8217;s just created another two with a Superman theme. It makes me think of a bunch of out-of-date<br />
systems out there needing automation &#8211; so the PowerShell IT admin superhero kicks into action :)</p>
<p><a href="http://www.leeholmes.com/blog/wp-content/uploads/2011/09/superman_wallpaper_small.png"><img class="size-full wp-image-333 aligncenter" title="superman_wallpaper_small" src="http://www.leeholmes.com/blog/wp-content/uploads/2011/09/superman_wallpaper_small.png" alt="" width="488" height="302" /></a></p>
<p>&nbsp;</p>
<p>Check out his post on the <a href="http://www.powershellmagazine.com/2011/09/23/powershell-wallpapers/">PowerShell Magazine site</a> for the full resolution downloads!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leeholmes.com/blog/2011/09/26/powershell-wallpapers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

