<?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>simianzombie.com</title>
	<atom:link href="http://simianzombie.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://simianzombie.com</link>
	<description>Adventures in Coding</description>
	<lastBuildDate>Sat, 19 May 2012 04:11:02 +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>What Woopsi Did Next</title>
		<link>http://simianzombie.com/?p=2217</link>
		<comments>http://simianzombie.com/?p=2217#comments</comments>
		<pubDate>Fri, 18 May 2012 15:14:44 +0000</pubDate>
		<dc:creator>Ant</dc:creator>
				<category><![CDATA[Woopsi]]></category>
		<category><![CDATA[nxwidgets]]></category>

		<guid isPermaLink="false">http://simianzombie.com/?p=2217</guid>
		<description><![CDATA[Woopsi appears to have been adapted into a set of UI components for a real-time operating system called &#8220;NuttX&#8221;. I&#8217;m pleased to see that the code has been useful outside of its original platform and purpose. It now runs on &#8230; <a href="http://simianzombie.com/?p=2217">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Woopsi appears to have been adapted into a set of UI components for a real-time operating system called &#8220;<a href="http://nuttx.sourceforge.net/">NuttX</a>&#8221;.  I&#8217;m pleased to see that the code has been useful outside of its original platform and purpose.  It now runs on ARM, Atmel and Intel chips, and will even run on the Zilog Z80.  NxWidgets can be found here:</p>

<ul>
<li><a href="http://nuttx.sourceforge.net/NxWidgets.html">http://nuttx.sourceforge.net/NxWidgets.html</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://simianzombie.com/?feed=rss2&#038;p=2217</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>EarthShakerDS 20120513</title>
		<link>http://simianzombie.com/?p=2219</link>
		<comments>http://simianzombie.com/?p=2219#comments</comments>
		<pubDate>Sun, 13 May 2012 16:12:10 +0000</pubDate>
		<dc:creator>Ant</dc:creator>
				<category><![CDATA[DS Coding]]></category>
		<category><![CDATA[earthshakerds]]></category>
		<category><![CDATA[release]]></category>
		<category><![CDATA[spaghetti]]></category>

		<guid isPermaLink="false">http://simianzombie.com/?p=2219</guid>
		<description><![CDATA[It&#8217;s about time for another EarthShakerDS release: EarthShakerDS 20120513 Changes this time around include: The ability to load and save levels in the editor with user-defined names (so you can have more than one custom level, and share them with &#8230; <a href="http://simianzombie.com/?p=2219">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s about time for another EarthShakerDS release:</p>

<p><a href="https://bitbucket.org/ant512/earthshakerds/downloads/EarthShakerDS_20120513.zip">EarthShakerDS 20120513</a></p>

<p>Changes this time around include:</p>

<ul>
<li>The ability to load and save levels in the editor with user-defined names (so you can have more than one custom level, and share them with other people);</li>
<li>A &#8220;Custom Level&#8221; option on the title screen listing all user-created levels</li>
<li>Slightly re-organised level editor;</li>
<li>The ability to load and save boulder/wall/door/soil types in a custom level;</li>
<li>Fixed for the latest devkitARM;</li>
<li>Updated to the latest WoopsiGfxGameTemplate (fixes SDL version);</li>
<li>Start button can be used to test a level in the editor;</li>
<li>Select button can page through level editor menu panels.</li>
</ul>

<p>I need to finish off the file requester in the level editor and it&#8217;ll finally be done.</p>

<p>Looking through this code again, I&#8217;m astonished at the level of spaghettification.  On the other hand, I did knock the whole thing up in a couple of weeks.</p>
]]></content:encoded>
			<wfw:commentRss>http://simianzombie.com/?feed=rss2&#038;p=2219</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iOS Provisioning</title>
		<link>http://simianzombie.com/?p=2212</link>
		<comments>http://simianzombie.com/?p=2212#comments</comments>
		<pubDate>Thu, 10 May 2012 16:11:45 +0000</pubDate>
		<dc:creator>Ant</dc:creator>
				<category><![CDATA[OSX]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[provisioning]]></category>
		<category><![CDATA[ux]]></category>

		<guid isPermaLink="false">http://simianzombie.com/?p=2212</guid>
		<description><![CDATA[The code signing and provisioning aspect of iOS development is, without a doubt, the worst thing that Apple has ever produced. I&#8217;ve been reminded of this because I just updated to OSX 10.7.4 and for some reason all of my &#8230; <a href="http://simianzombie.com/?p=2212">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The code signing and provisioning aspect of iOS development is, without a doubt, the <em>worst</em> thing that Apple has ever produced.  I&#8217;ve been reminded of this because I just updated to OSX 10.7.4 and for some reason all of my provisioning profiles now complain that they can&#8217;t find a valid signing identity.  An hour or so of googling and button clicking later and I&#8217;m admitting defeat for the moment.</p>

<p>As an example of how hateful the process is and how little regard Apple has for its community of developers, here&#8217;s a screenshot from their certificate history page:</p>

<p><a href="http://simianzombie.com/wp-content/uploads/2012/05/certifcatedates.png" rel="lightbox[2212]" title="certifcatedates"><img src="http://simianzombie.com/wp-content/uploads/2012/05/certifcatedates.png" alt="" title="certifcatedates" width="228" height="351" class="aligncenter size-full wp-image-2213" /></a></p>

<p>Yes, those are dates.  And yes, they are sorted <em>alphabetically</em>.  This from a company that is universally praised for its attention to detail and the ease of use of its products.</p>

<p>Developers!  <em>Apple hates you.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://simianzombie.com/?feed=rss2&#038;p=2212</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>EarthShakerDS Revived</title>
		<link>http://simianzombie.com/?p=2205</link>
		<comments>http://simianzombie.com/?p=2205#comments</comments>
		<pubDate>Mon, 07 May 2012 04:47:10 +0000</pubDate>
		<dc:creator>Ant</dc:creator>
				<category><![CDATA[DS Coding]]></category>
		<category><![CDATA[OSX]]></category>
		<category><![CDATA[earthshakerds]]></category>

		<guid isPermaLink="false">http://simianzombie.com/?p=2205</guid>
		<description><![CDATA[It&#8217;s been 10 months since the last update, so I figure it&#8217;s about time to revive the EarthShakerDS code and finish off the level editor. Changes so far: Updated the OSX version to the latest codebase; Fixed SDL bugs in &#8230; <a href="http://simianzombie.com/?p=2205">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been 10 months since the last update, so I figure it&#8217;s about time to revive the <a href="https://bitbucket.org/ant512/earthshakerds">EarthShakerDS code</a> and finish off the level editor.  Changes so far:</p>

<ul>
<li>Updated the OSX version to the latest codebase;</li>
<li>Fixed SDL bugs in the WoopsiGfxGameTemplate;</li>
<li>Added the ability to save and load soil/boulder/wall/door types to the level editor;</li>
<li>Added a keyboard and file lister to the level editor to allow the saving and loading of custom levels with user-defined names;</li>
<li>Added a list of custom levels to the title screen menu;</li>
<li>The Start button tests the current level in the level editor;</li>
<li>The Select button flips between level editor panels.</li>
</ul>

<p>I&#8217;ve got to make the custom level select on the title screen actually start a level and allow interaction with the file requester in the level editor.  Once those are done the game will finally be finished.</p>

<p>Here&#8217;s a grab of the new file requester.  It isn&#8217;t pretty but it&#8217;ll work&#8230;</p>

<p><a href="http://simianzombie.com/wp-content/uploads/2012/05/earthshakerleveleditor.png" rel="lightbox[2205]" title="earthshakerleveleditor"><img src="http://simianzombie.com/wp-content/uploads/2012/05/earthshakerleveleditor.png" alt="" title="earthshakerleveleditor" width="370" height="520" class="aligncenter size-full wp-image-2206" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://simianzombie.com/?feed=rss2&#038;p=2205</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Email Address Validation For iOS</title>
		<link>http://simianzombie.com/?p=2193</link>
		<comments>http://simianzombie.com/?p=2193#comments</comments>
		<pubDate>Tue, 01 May 2012 00:29:39 +0000</pubDate>
		<dc:creator>Ant</dc:creator>
				<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[parser]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[rfc]]></category>
		<category><![CDATA[standards]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://simianzombie.com/?p=2193</guid>
		<description><![CDATA[If you&#8217;ve ever needed to validate an email address, the chances are you used a regex engine and validated the address&#8217; structure against something like this: ^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$ It works well enough for the average case. But what about this email &#8230; <a href="http://simianzombie.com/?p=2193">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve ever needed to validate an email address, the chances are you used a regex engine and validated the address&#8217; structure against something like this:</p>

<pre><code>^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$
</code></pre>

<p>It works well enough for the average case.  But what about this email address?</p>

<pre><code>joe+bloggs@example.com
</code></pre>

<p>Not so good.  You could modify the regex to support the &#8220;+&#8221; character, but if you read <a href="http://www.ietf.org/rfc/rfc0822.txt">RFC 822</a> and <a href="http://tools.ietf.org/html/rfc5321">RFC 5321</a> you&#8217;ll quickly discover that the structure of an email address isn&#8217;t just &#8220;alphanumeric@alphanumeric.alphanumeric&#8221;.  Email addresses include a built-in comment system using parentheses, escape characters, quoted sections, &#8220;dot-atoms&#8221; and more.  A regex to correctly parse the entirety of RFC 822 <a href="http://ex-parrot.com/~pdw/Mail-RFC822-Address.html">would be huge</a>, and that&#8217;s the older, simpler version of an email address.</p>

<p>Once you start really digging into the syntax of an email address, you find that:</p>

<ul>
<li>Domain names (the part after the &#8220;@&#8221;) can now be in character sets other than Latin, so your primitive [a-z][0-9] regex won&#8217;t work;</li>
<li>The local part of the address (the part before the &#8220;@&#8221;) can also now be in other character sets, but as this idea is about 2 months old nothing supports it yet;</li>
<li>Trying to figure out if Exchange supports internationalised domain names (IDN) or not is basically guesswork;</li>
<li>There are multiple standards for email addresses, most of which disagree with each other and most of which appear to be deprecated.  Figuring out which is the current standard is like trying to find a particular Skittle in a bag of Skittles.</li>
</ul>

<p>Pretty much the only fact you&#8217;ll be entirely sure of after your research is that regex is a really bad solution for validating email addresses.</p>

<p>My favourite part of <a href="http://tools.ietf.org/html/rfc3696">RFC 3696</a> is where it says these addresses are valid:</p>

<pre><code>Fred\ Bloggs@example.com
"Fred Bloggs"@example.com
</code></pre>

<p>This makes sense.  The backslash is used to escape a single character, whereas the quotes are used to signify that everything between them should be automatically escaped.  One&#8217;s really a shortcut for the other.  Simple.</p>

<p>However, the <a href="http://www.rfc-editor.org/errata_search.php?rfc=3696">errata</a> suggests that this is a mistake, and that this is the correct form:</p>

<pre><code> "Fred\ Bloggs"@example.com
</code></pre>

<p>Now we have a backslash system embedded within a quoting system.  The former makes the latter entirely superfluous.  I think this amendment is probably why so many developers just stick with regex: The standard is crap.</p>

<p>So, you have two choices:</p>

<ol>
<li>Ignore the complexity, do what everyone else does, and use regex regardless;</li>
<li>Write an email address parser.</li>
</ol>

<p>As I&#8217;m crazy, here&#8217;s an email address parser written in Objective-C.  It has some limitations:</p>

<ul>
<li>It does not allow the local part of the address to be internationalised as nothing supports this yet.</li>
<li>It does not allow domain name literals (ie. joe@[10.0.1.2]) as Exchange does not support them and I&#8217;ve never seen one in the wild.</li>
<li>It may not apply all of the backslash escape rules correctly, as this is one area where every document entirely disagrees with every other document.</li>
<li>It may not enforce the omission of certain ASCII ranges correctly, as this is another area where the docs suck.</li>
</ul>

<p>On the plus side:</p>

<ul>
<li>It validates comments and nested comments (comments are apparently deprecated, but I can&#8217;t find anywhere that specifically says that this is the case).</li>
<li>It correctly enforces at least some of the backslash escape rules.</li>
<li>It allows the use of quoted sections (that can include characters like &#8220;@&#8221;, &#8220;(&#8220;, etc) and enforces their rules (quotes must be matched; quoted sections must be the only element of the local part or must be delimited by periods).</li>
<li>It enforces period rules (periods cannot be the first or last part of the local or domain parts of the address; periods cannot be adjacent except within a quoted section).</li>
<li>It enforces the maximum and minimum lengths of each section (up to 64 chars for the local part; up to 254 chars for the entire address; there must be a local and domain part of the address).</li>
<li>It allows IDN.</li>
<li>Domain names can only contain letters, numbers, periods and hyphens.</li>
<li>It passes all of the test cases written by <a href="http://isemail.info/_system/is_email/test/?all">Dominic Sayers</a> except those concerning carriage/line returns and domain name literals, which aren&#8217;t relevant to what I&#8217;m trying to do.</li>
</ul>


<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">// .h</span>
<span style="color: #a61390;">@interface</span> SZEmailValidator <span style="color: #002200;">:</span> <span style="color: #400080;">NSObject</span>
&nbsp;
<span style="color: #002200;">+</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">BOOL</span><span style="color: #002200;">&#41;</span>isValid<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>candidate;
&nbsp;
<span style="color: #a61390;">@end</span>
&nbsp;
<span style="color: #11740a; font-style: italic;">// .m</span>
<span style="color: #6e371a;">#import &quot;SZEmailValidator.h&quot;</span>
&nbsp;
<span style="color: #a61390;">struct</span> SZEmailParserState <span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">BOOL</span> quoted <span style="color: #002200;">:</span> <span style="color: #2400d9;">1</span>;
	<span style="color: #a61390;">BOOL</span> escaped <span style="color: #002200;">:</span> <span style="color: #2400d9;">1</span>;
	<span style="color: #a61390;">BOOL</span> domain <span style="color: #002200;">:</span> <span style="color: #2400d9;">1</span>;
	<span style="color: #a61390;">BOOL</span> dot <span style="color: #002200;">:</span> <span style="color: #2400d9;">1</span>;
	<span style="color: #a61390;">BOOL</span> followingQuoteBlock <span style="color: #002200;">:</span> <span style="color: #2400d9;">1</span>;
<span style="color: #002200;">&#125;</span>;
&nbsp;
<span style="color: #a61390;">@implementation</span> SZEmailValidator
&nbsp;
<span style="color: #002200;">+</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">BOOL</span><span style="color: #002200;">&#41;</span>isValid<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>candidate <span style="color: #002200;">&#123;</span>
&nbsp;
	<span style="color: #a61390;">unsigned</span> <span style="color: #a61390;">int</span> domainPartStart <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>;
	<span style="color: #a61390;">unsigned</span> <span style="color: #a61390;">int</span> commentDepth <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>;
&nbsp;
	<span style="color: #a61390;">struct</span> SZEmailParserState state;
&nbsp;
	state.dot <span style="color: #002200;">=</span> <span style="color: #a61390;">NO</span>;
	state.quoted <span style="color: #002200;">=</span> <span style="color: #a61390;">NO</span>;
	state.escaped <span style="color: #002200;">=</span> <span style="color: #a61390;">NO</span>;
	state.followingQuoteBlock <span style="color: #002200;">=</span> <span style="color: #a61390;">NO</span>;
	state.domain <span style="color: #002200;">=</span> <span style="color: #a61390;">NO</span>;
&nbsp;
	<span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">unsigned</span> <span style="color: #a61390;">int</span> i <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>; i &lt; candidate.length; <span style="color: #002200;">++</span>i<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
		unichar character <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>candidate characterAtIndex<span style="color: #002200;">:</span>i<span style="color: #002200;">&#93;</span>;
&nbsp;
		<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">!</span>state.domain<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
&nbsp;
			<span style="color: #11740a; font-style: italic;">// Do not allow characters beyond the ASCII set in the username</span>
			<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>character &gt; <span style="color: #2400d9;">126</span><span style="color: #002200;">&#41;</span> <span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
&nbsp;
			<span style="color: #11740a; font-style: italic;">// Do not allow NULL</span>
			<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>character <span style="color: #002200;">==</span> <span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span> <span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
&nbsp;
			<span style="color: #11740a; font-style: italic;">// Do not allow LF</span>
			<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>character <span style="color: #002200;">==</span> <span style="color: #2400d9;">10</span><span style="color: #002200;">&#41;</span> <span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
		<span style="color: #002200;">&#125;</span>
&nbsp;
		<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>i &gt; <span style="color: #2400d9;">253</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
&nbsp;
			<span style="color: #11740a; font-style: italic;">// Do not allow more than 254 characters in the entire address</span>
			<span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
		<span style="color: #002200;">&#125;</span>
&nbsp;
		<span style="color: #11740a; font-style: italic;">// The only characters that can follow a quote block are @ and period.</span>
		<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>state.followingQuoteBlock<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
			<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>character <span style="color: #002200;">!=</span> <span style="color: #bf1d1a;">'@'</span> <span style="color: #002200;">&amp;&amp;</span> character <span style="color: #002200;">!=</span> <span style="color: #bf1d1a;">'.'</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
				<span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
			<span style="color: #002200;">&#125;</span>
&nbsp;
			state.followingQuoteBlock <span style="color: #002200;">=</span> <span style="color: #a61390;">NO</span>;
		<span style="color: #002200;">&#125;</span>
&nbsp;
		<span style="color: #a61390;">switch</span> <span style="color: #002200;">&#40;</span>character<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
			<span style="color: #a61390;">case</span> <span style="color: #bf1d1a;">'@'</span><span style="color: #002200;">:</span>
&nbsp;
				<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>state.domain<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
&nbsp;
					<span style="color: #11740a; font-style: italic;">// @ not allowed in the domain portion of the address</span>
					<span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
&nbsp;
				<span style="color: #002200;">&#125;</span> <span style="color: #a61390;">else</span> <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>state.quoted<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
&nbsp;
					<span style="color: #11740a; font-style: italic;">// Ignore @ signs when quoted</span>
&nbsp;
				<span style="color: #002200;">&#125;</span> <span style="color: #a61390;">else</span> <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>state.dot<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
&nbsp;
					<span style="color: #11740a; font-style: italic;">// Dots are not allowed as the final character in the local</span>
					<span style="color: #11740a; font-style: italic;">// part</span>
					<span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
&nbsp;
				<span style="color: #002200;">&#125;</span> <span style="color: #a61390;">else</span> <span style="color: #002200;">&#123;</span>
&nbsp;
					<span style="color: #11740a; font-style: italic;">// Swapping to the domain portion of the address</span>
					state.domain <span style="color: #002200;">=</span> <span style="color: #a61390;">YES</span>;
					domainPartStart <span style="color: #002200;">=</span> i <span style="color: #002200;">+</span> <span style="color: #2400d9;">1</span>;
&nbsp;
					<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>i &gt; <span style="color: #2400d9;">64</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
&nbsp;
						<span style="color: #11740a; font-style: italic;">// Do not allow more than 63 characters in the local part</span>
						<span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
&nbsp;
					<span style="color: #002200;">&#125;</span>
				<span style="color: #002200;">&#125;</span>
&nbsp;
				<span style="color: #11740a; font-style: italic;">// No longer in dot/escape mode</span>
				state.dot <span style="color: #002200;">=</span> <span style="color: #a61390;">NO</span>;
				state.escaped <span style="color: #002200;">=</span> <span style="color: #a61390;">NO</span>;
&nbsp;
				<span style="color: #a61390;">break</span>;
&nbsp;
			<span style="color: #a61390;">case</span> <span style="color: #bf1d1a;">'('</span><span style="color: #002200;">:</span>
&nbsp;
				<span style="color: #11740a; font-style: italic;">// Comments only activate when not quoted or escaped</span>
				<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">!</span>state.quoted <span style="color: #002200;">&amp;&amp;</span> <span style="color: #002200;">!</span>state.escaped<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
					<span style="color: #002200;">++</span>commentDepth;
				<span style="color: #002200;">&#125;</span>
&nbsp;
				<span style="color: #a61390;">break</span>;
&nbsp;
			<span style="color: #a61390;">case</span> <span style="color: #bf1d1a;">')'</span><span style="color: #002200;">:</span>
&nbsp;
				<span style="color: #11740a; font-style: italic;">// Comments only activate when not quoted or escaped</span>
				<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">!</span>state.quoted <span style="color: #002200;">&amp;&amp;</span> <span style="color: #002200;">!</span>state.escaped<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
&nbsp;
					<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>commentDepth <span style="color: #002200;">==</span> <span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span> <span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
&nbsp;
					<span style="color: #002200;">--</span>commentDepth;
				<span style="color: #002200;">&#125;</span>
&nbsp;
				<span style="color: #a61390;">break</span>;
&nbsp;
			<span style="color: #a61390;">case</span> <span style="color: #bf1d1a;">'<span style="color: #2400d9;">\\</span>'</span><span style="color: #002200;">:</span>
&nbsp;
				<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">!</span>state.quoted <span style="color: #002200;">&amp;&amp;</span> commentDepth <span style="color: #002200;">==</span> <span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
&nbsp;
					<span style="color: #11740a; font-style: italic;">// Backslash isn't allowed outside of quote/comment mode</span>
					<span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
				<span style="color: #002200;">&#125;</span>
&nbsp;
				<span style="color: #11740a; font-style: italic;">// Flip the escape bit to enter/exit escape mode</span>
				state.escaped <span style="color: #002200;">=</span> <span style="color: #002200;">!</span>state.escaped;
&nbsp;
				<span style="color: #11740a; font-style: italic;">// No longer in dot mode</span>
				state.dot <span style="color: #002200;">=</span> <span style="color: #a61390;">NO</span>;
&nbsp;
				<span style="color: #a61390;">break</span>;
&nbsp;
			<span style="color: #a61390;">case</span> <span style="color: #bf1d1a;">'&quot;'</span><span style="color: #002200;">:</span>
&nbsp;
				<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>state.domain <span style="color: #002200;">&amp;&amp;</span> commentDepth <span style="color: #002200;">==</span> <span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
&nbsp;
					<span style="color: #11740a; font-style: italic;">// &quot; not allowed in the domain portion of the address</span>
					<span style="color: #11740a; font-style: italic;">// outside of a comment</span>
					<span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
				<span style="color: #002200;">&#125;</span>
&nbsp;
				<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">!</span>state.escaped<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
&nbsp;
					<span style="color: #11740a; font-style: italic;">// Quotes are only allowed at the start of the local part,</span>
					<span style="color: #11740a; font-style: italic;">// after a dot or to close an existing quote part</span>
					<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>i <span style="color: #002200;">==</span> <span style="color: #2400d9;">0</span> || state.dot || state.quoted<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
&nbsp;
						<span style="color: #11740a; font-style: italic;">// Remember that we just left a quote block</span>
						<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>state.quoted<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
							state.followingQuoteBlock <span style="color: #002200;">=</span> <span style="color: #a61390;">YES</span>;
						<span style="color: #002200;">&#125;</span>
&nbsp;
						<span style="color: #11740a; font-style: italic;">// Flip the quote bit to enter/exit quote mode</span>
						state.quoted <span style="color: #002200;">=</span> <span style="color: #002200;">!</span>state.quoted;
					<span style="color: #002200;">&#125;</span> <span style="color: #a61390;">else</span> <span style="color: #002200;">&#123;</span>
						<span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
					<span style="color: #002200;">&#125;</span>
				<span style="color: #002200;">&#125;</span>
&nbsp;
				<span style="color: #11740a; font-style: italic;">// No longer in dot/escape mode</span>
				state.dot <span style="color: #002200;">=</span> <span style="color: #a61390;">NO</span>;
				state.escaped <span style="color: #002200;">=</span> <span style="color: #a61390;">NO</span>;
&nbsp;
				<span style="color: #a61390;">break</span>;
&nbsp;
			<span style="color: #a61390;">case</span> <span style="color: #bf1d1a;">'.'</span><span style="color: #002200;">:</span>
&nbsp;
				<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>i <span style="color: #002200;">==</span> <span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
&nbsp;
					<span style="color: #11740a; font-style: italic;">// Dots are not allowed as the first character of the local</span>
					<span style="color: #11740a; font-style: italic;">// part</span>
					<span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
&nbsp;
				<span style="color: #002200;">&#125;</span> <span style="color: #a61390;">else</span> <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>i <span style="color: #002200;">==</span> domainPartStart<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
&nbsp;
					<span style="color: #11740a; font-style: italic;">// Dots are not allowed as the first character of the domain</span>
					<span style="color: #11740a; font-style: italic;">// part</span>
					<span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
&nbsp;
				<span style="color: #002200;">&#125;</span> <span style="color: #a61390;">else</span> <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>i <span style="color: #002200;">==</span> candidate.length <span style="color: #002200;">-</span> <span style="color: #2400d9;">1</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
&nbsp;
					<span style="color: #11740a; font-style: italic;">// Dots are not allowed as the last character of the domain</span>
					<span style="color: #11740a; font-style: italic;">// part</span>
					<span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
				<span style="color: #002200;">&#125;</span>
&nbsp;
				<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">!</span>state.quoted<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
&nbsp;
					<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>state.dot<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
&nbsp;
						<span style="color: #11740a; font-style: italic;">// Cannot allow adjacent dots</span>
						<span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
					<span style="color: #002200;">&#125;</span> <span style="color: #a61390;">else</span> <span style="color: #002200;">&#123;</span>
&nbsp;
						<span style="color: #11740a; font-style: italic;">// Entering dot mode</span>
						state.dot <span style="color: #002200;">=</span> <span style="color: #a61390;">YES</span>;
					<span style="color: #002200;">&#125;</span>
&nbsp;
				<span style="color: #002200;">&#125;</span>
&nbsp;
				<span style="color: #11740a; font-style: italic;">// No longer in escape mode</span>
				state.escaped <span style="color: #002200;">=</span> <span style="color: #a61390;">NO</span>;
&nbsp;
				<span style="color: #a61390;">break</span>;
&nbsp;
			<span style="color: #a61390;">case</span> <span style="color: #bf1d1a;">' '</span><span style="color: #002200;">:</span>
			<span style="color: #a61390;">case</span> <span style="color: #bf1d1a;">','</span><span style="color: #002200;">:</span>
			<span style="color: #a61390;">case</span> <span style="color: #bf1d1a;">'['</span><span style="color: #002200;">:</span>
			<span style="color: #a61390;">case</span> <span style="color: #bf1d1a;">']'</span><span style="color: #002200;">:</span>
			<span style="color: #a61390;">case</span> <span style="color: #2400d9;">1</span><span style="color: #002200;">:</span>
			<span style="color: #a61390;">case</span> <span style="color: #2400d9;">2</span><span style="color: #002200;">:</span>
			<span style="color: #a61390;">case</span> <span style="color: #2400d9;">3</span><span style="color: #002200;">:</span>
			<span style="color: #a61390;">case</span> <span style="color: #2400d9;">4</span><span style="color: #002200;">:</span>
			<span style="color: #a61390;">case</span> <span style="color: #2400d9;">5</span><span style="color: #002200;">:</span>
			<span style="color: #a61390;">case</span> <span style="color: #2400d9;">6</span><span style="color: #002200;">:</span>
			<span style="color: #a61390;">case</span> <span style="color: #2400d9;">7</span><span style="color: #002200;">:</span>
			<span style="color: #a61390;">case</span> <span style="color: #2400d9;">8</span><span style="color: #002200;">:</span>
			<span style="color: #a61390;">case</span> <span style="color: #2400d9;">9</span><span style="color: #002200;">:</span>
			<span style="color: #a61390;">case</span> <span style="color: #2400d9;">11</span><span style="color: #002200;">:</span>
			<span style="color: #a61390;">case</span> <span style="color: #2400d9;">13</span><span style="color: #002200;">:</span>
			<span style="color: #a61390;">case</span> <span style="color: #2400d9;">15</span><span style="color: #002200;">:</span>
&nbsp;
				<span style="color: #11740a; font-style: italic;">// These characters can only appear when quoted</span>
				<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">!</span>state.quoted<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
					<span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
				<span style="color: #002200;">&#125;</span>
&nbsp;
			<span style="color: #a61390;">default</span><span style="color: #002200;">:</span>
&nbsp;
				<span style="color: #11740a; font-style: italic;">// No longer in dot/escape mode</span>
				state.dot <span style="color: #002200;">=</span> <span style="color: #a61390;">NO</span>;
				state.escaped <span style="color: #002200;">=</span> <span style="color: #a61390;">NO</span>;
&nbsp;
				<span style="color: #11740a; font-style: italic;">// Do not allow characters outside of unicode, numerals, hyphens</span>
				<span style="color: #11740a; font-style: italic;">// and periods in the domain part.  We use letterCharacterSet</span>
				<span style="color: #11740a; font-style: italic;">// because we're supporting internationalised domain names.</span>
				<span style="color: #11740a; font-style: italic;">// We don't have to do anything special with the name; that's up</span>
				<span style="color: #11740a; font-style: italic;">// to the email client/server to handle.</span>
				<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>state.domain<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
					<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">!</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSCharacterSet</span> letterCharacterSet<span style="color: #002200;">&#93;</span> characterIsMember<span style="color: #002200;">:</span>character<span style="color: #002200;">&#93;</span> <span style="color: #002200;">&amp;&amp;</span>
						<span style="color: #002200;">!</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSCharacterSet</span> decimalDigitCharacterSet<span style="color: #002200;">&#93;</span> characterIsMember<span style="color: #002200;">:</span>character<span style="color: #002200;">&#93;</span> <span style="color: #002200;">&amp;&amp;</span>
						character <span style="color: #002200;">!=</span> <span style="color: #bf1d1a;">'-'</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
&nbsp;
						<span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
					<span style="color: #002200;">&#125;</span>
				<span style="color: #002200;">&#125;</span>
&nbsp;
				<span style="color: #a61390;">break</span>;
		<span style="color: #002200;">&#125;</span>
	<span style="color: #002200;">&#125;</span>
&nbsp;
	<span style="color: #11740a; font-style: italic;">// Do not allow unclosed comments</span>
	<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>commentDepth &gt; <span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span> <span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
&nbsp;
	<span style="color: #11740a; font-style: italic;">// If we didn't identify a local and a domain part the address isn't valid</span>
	<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">!</span>state.domain<span style="color: #002200;">&#41;</span> <span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
	<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>candidate.length <span style="color: #002200;">==</span> domainPartStart<span style="color: #002200;">&#41;</span> <span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
	<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>domainPartStart <span style="color: #002200;">==</span> <span style="color: #2400d9;">1</span><span style="color: #002200;">&#41;</span> <span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
&nbsp;
	<span style="color: #11740a; font-style: italic;">// Validate domain name components</span>
	<span style="color: #400080;">NSArray</span> <span style="color: #002200;">*</span>components <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>candidate substringFromIndex<span style="color: #002200;">:</span>domainPartStart<span style="color: #002200;">&#93;</span> componentsSeparatedByString<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;.&quot;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>item <span style="color: #a61390;">in</span> components<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
&nbsp;
		<span style="color: #11740a; font-style: italic;">// We can't allow a hyphen as the first or last char in a domain name</span>
		<span style="color: #11740a; font-style: italic;">// component</span>
		<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>item characterAtIndex<span style="color: #002200;">:</span><span style="color: #2400d9;">0</span><span style="color: #002200;">&#93;</span> <span style="color: #002200;">==</span> <span style="color: #bf1d1a;">'-'</span> || <span style="color: #002200;">&#91;</span>item characterAtIndex<span style="color: #002200;">:</span>item.length <span style="color: #002200;">-</span> <span style="color: #2400d9;">1</span><span style="color: #002200;">&#93;</span> <span style="color: #002200;">==</span> <span style="color: #bf1d1a;">'-'</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
			<span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
		<span style="color: #002200;">&#125;</span>
&nbsp;
		<span style="color: #11740a; font-style: italic;">// Items must not be longer than 63 chars</span>
		<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>item.length &gt; <span style="color: #2400d9;">63</span><span style="color: #002200;">&#41;</span> <span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
	<span style="color: #002200;">&#125;</span>
&nbsp;
	<span style="color: #a61390;">return</span> <span style="color: #a61390;">YES</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #a61390;">@end</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://simianzombie.com/?feed=rss2&#038;p=2193</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Team Foundation Server</title>
		<link>http://simianzombie.com/?p=2188</link>
		<comments>http://simianzombie.com/?p=2188#comments</comments>
		<pubDate>Tue, 28 Feb 2012 22:48:44 +0000</pubDate>
		<dc:creator>Ant</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[steve ballmer]]></category>
		<category><![CDATA[tfs]]></category>

		<guid isPermaLink="false">http://simianzombie.com/?p=2188</guid>
		<description><![CDATA[Using TFS as a source control system is an experience akin to having Steve Ballmer repeatedy stamp on your face. Using TFS on a Mac is like having Ballmer stamp on your face whilst wearing running spikes, calling you names &#8230; <a href="http://simianzombie.com/?p=2188">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Using TFS as a source control system is an experience akin to having Steve Ballmer repeatedy stamp on your face.</p>

<p>Using TFS on a Mac is like having Ballmer stamp on your face whilst wearing running spikes, calling you names and reminding you that it&#8217;s all your fault; you paid him to do it.</p>
]]></content:encoded>
			<wfw:commentRss>http://simianzombie.com/?feed=rss2&#038;p=2188</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JSON, .NET and NSDate</title>
		<link>http://simianzombie.com/?p=2180</link>
		<comments>http://simianzombie.com/?p=2180#comments</comments>
		<pubDate>Tue, 24 Jan 2012 20:45:07 +0000</pubDate>
		<dc:creator>Ant</dc:creator>
				<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[datetime]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[nsdate]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[web service]]></category>

		<guid isPermaLink="false">http://simianzombie.com/?p=2180</guid>
		<description><![CDATA[If you&#8217;re trying to access a JSON web service created using .NET from an iOS device, you&#8217;ve probably discovered that dates are produced in a less than useful format: /Date(1233423345345)/ The rationale for the date format can be found here, &#8230; <a href="http://simianzombie.com/?p=2180">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re trying to access a JSON web service created using .NET from an iOS device, you&#8217;ve probably discovered that dates are produced in a less than useful format:</p>

<pre><code>/Date(1233423345345)/
</code></pre>

<p>The rationale for the date format can be found <a href="http://weblogs.asp.net/bleroy/archive/2008/01/18/dates-and-json.aspx">here</a>, but it&#8217;s basically a call to the JavaScript Date object constructor.  The numeric value represents the number of milliseconds since 1970-01-01.</p>

<p>Below I&#8217;ve added a handy Objective-C function that will extract the value and return an NSDate object.  Note that we&#8217;re losing accuracy by magnitudes as we translate from .NET DateTime objects (which measure time in ticks) to JavaScript Date objects (which measure time in milliseconds) and finally to iOS NSDate objects (which measure time in seconds).</p>


<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">/**
 * Converts a .NET JSON date in the format &quot;/Date(x)/&quot; to an NSDate object.
 * @param string The NSString to convert.
 * @return the NSDate object.
 */</span>
<span style="color: #002200;">&#40;</span><span style="color: #400080;">NSDate</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>jsonStringToNSDate<span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span> <span style="color: #a61390;">string</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
&nbsp;
	<span style="color: #11740a; font-style: italic;">// Extract the numeric part of the date.  Dates should be in the format</span>
	<span style="color: #11740a; font-style: italic;">// &quot;/Date(x)/&quot;, where x is a number.  This format is supplied automatically</span>
	<span style="color: #11740a; font-style: italic;">// by JSON serialisers in .NET.</span>
	<span style="color: #a61390;">NSRange</span> range <span style="color: #002200;">=</span> NSMakeRange<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">6</span>, <span style="color: #002200;">&#91;</span><span style="color: #a61390;">string</span> length<span style="color: #002200;">&#93;</span> <span style="color: #002200;">-</span> <span style="color: #2400d9;">8</span><span style="color: #002200;">&#41;</span>;
	<span style="color: #400080;">NSString</span><span style="color: #002200;">*</span> substring <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #a61390;">string</span> substringWithRange<span style="color: #002200;">:</span>range<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #11740a; font-style: italic;">// Have to use a number formatter to extract the value from the string into</span>
	<span style="color: #11740a; font-style: italic;">// a long long as the longLongValue method of the string doesn't seem to</span>
	<span style="color: #11740a; font-style: italic;">// return anything useful - it is always grossly incorrect.</span>
	<span style="color: #400080;">NSNumberFormatter</span><span style="color: #002200;">*</span> formatter <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumberFormatter</span> alloc<span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span>;
	<span style="color: #400080;">NSNumber</span><span style="color: #002200;">*</span> milliseconds <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>formatter numberFromString<span style="color: #002200;">:</span>substring<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #002200;">&#91;</span>formatter release<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #11740a; font-style: italic;">// NSTimeInterval is specified in seconds.  The value we get back from the</span>
	<span style="color: #11740a; font-style: italic;">// web service is specified in milliseconds.  Both values are since 1st Jan</span>
	<span style="color: #11740a; font-style: italic;">// 1970 (epoch).</span>
	NSTimeInterval seconds <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>milliseconds longLongValue<span style="color: #002200;">&#93;</span> <span style="color: #002200;">/</span> <span style="color: #2400d9;">1000</span>;
&nbsp;
	<span style="color: #a61390;">return</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSDate</span> dateWithTimeIntervalSince1970<span style="color: #002200;">:</span>seconds<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://simianzombie.com/?feed=rss2&#038;p=2180</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Blogging with Mercurial from the Rocky Mountains</title>
		<link>http://simianzombie.com/?p=2176</link>
		<comments>http://simianzombie.com/?p=2176#comments</comments>
		<pubDate>Tue, 10 Jan 2012 23:47:02 +0000</pubDate>
		<dc:creator>Ant</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[appharbor]]></category>
		<category><![CDATA[birmingham]]></category>
		<category><![CDATA[bitbucket]]></category>
		<category><![CDATA[colorado]]></category>
		<category><![CDATA[immigration]]></category>
		<category><![CDATA[mercurial]]></category>
		<category><![CDATA[rocky mountains]]></category>
		<category><![CDATA[uk]]></category>
		<category><![CDATA[usa]]></category>

		<guid isPermaLink="false">http://simianzombie.com/?p=2176</guid>
		<description><![CDATA[It&#8217;s been a while since the last update, but I do have a good excuse. I&#8217;ve upped sticks and moved from dingy Birmingham, in the UK, to sunny Littleton, Colorado, in the USA. So, who&#8217;s hiring? I&#8217;ve decided to start &#8230; <a href="http://simianzombie.com/?p=2176">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a while since the last update, but I do have a good excuse.  I&#8217;ve upped sticks and moved from dingy Birmingham, in the UK, to sunny Littleton, Colorado, in the USA.</p>

<p>So, who&#8217;s hiring?</p>

<p>I&#8217;ve decided to start blogging about those experiences, but rather than flood this blog with personal posts I&#8217;m making a separate blog.  But what blogging platform to use?  It&#8217;s not going to have much traffic, I don&#8217;t want to put any admin time into it, I don&#8217;t want comments or tags or categories.  All I want is to be able to post text as quickly as possible using Markdown.</p>

<p>It would be great if there was a blogging platform for Mercurial like the one available to Github users, but I&#8217;ve looked around and haven&#8217;t been able to find one.  So why not write one?</p>

<p>Here&#8217;s my list of requirements:</p>

<ul>
<li>Displays blog posts in reverse chronological order (newest first).</li>
<li>Posts are written in Markdown and reformatted into HTML automatically.</li>
<li>Posts are stored in a repository on BitBucket.</li>
<li>Pushing to the posts repository automatically updates the blog.</li>
<li>Allows paging through blog posts.</li>
<li>Includes an &#8220;Archive&#8221; page that lists all blog posts.</li>
<li>Has an RSS feed.</li>
<li>Maintains a cache of blog posts to minimise queries to BitBucket&#8217;s API.</li>
<li>Looks a bit like WordPress&#8217; &#8220;TwentyEleven&#8221; theme, as that&#8217;s my favourite theme at the moment.</li>
</ul>

<p>After a couple of evenings of hacking, here&#8217;s the result:</p>

<ul>
<li><a href="https://bitbucket.org/ant512/bitblogger">BitBlogger</a></li>
</ul>

<p>And here&#8217;s a demo:</p>

<ul>
<li><a href="http://bitblogger.apphb.com">BitBlogger Demo</a></li>
</ul>

<p>A blog powered by BitBucket and Mercurial.  Neat!</p>

<p>I&#8217;ve included instructions for getting a BitBlogger instance up and running on <a href="http://appharbor.com">AppHarbor</a>, a .NET hosting site that offers a basic freemium option.  As BitBlogger doesn&#8217;t use any local storage or background events (BitBucket notifies it of changes, rather than BitBlogger needing to poll for updates), it doesn&#8217;t need anything above the free package.</p>

<p>I&#8217;ve copied bits and pieces of the TwentyEleven theme&#8217;s CSS file in order to replicate some of the appearance, so the licence for this application is the GPL rather than my preferred MIT licence.  If anyone feels like putting together a simple and very legible theme to replace the current look and feel, I&#8217;ll be able to switch it over.</p>
]]></content:encoded>
			<wfw:commentRss>http://simianzombie.com/?feed=rss2&#038;p=2176</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stuff I Use</title>
		<link>http://simianzombie.com/?p=2169</link>
		<comments>http://simianzombie.com/?p=2169#comments</comments>
		<pubDate>Thu, 15 Dec 2011 18:59:07 +0000</pubDate>
		<dc:creator>Ant</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[OSX]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://simianzombie.com/?p=2169</guid>
		<description><![CDATA[Inspired by Scott Hanselman&#8217;s enormous list of tools that he uses, used, or heard of once, here&#8217;s three comparatively tiny lists of tools I use every day. The first list is comprised of cross-platform software that I use on both &#8230; <a href="http://simianzombie.com/?p=2169">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Inspired by Scott Hanselman&#8217;s <a href="http://www.hanselman.com/blog/ScottHanselmans2011UltimateDeveloperAndPowerUsersToolListForWindows.aspx">enormous list</a> of tools that he uses, used, or heard of once, here&#8217;s three comparatively tiny lists of tools I use every day.  The first list is comprised of cross-platform software that I use on both OSX and Windows.  The second is OSX-only software and the third is Windows-only software.</p>

<p>I don&#8217;t use Linux enough to have a set of tools I recommend.  As I&#8217;m the only person on the planet to think that Unity is actually a small step in the right direction, even if it does need optimising, my opinion doesn&#8217;t count.</p>

<h2>Cross-Platform</h2>

<ul>
<li><a href="http://www.sublimetext.com/2">Sublime Text 2</a> - Without a doubt, the best text editor I&#8217;ve used on any platform.</li>
<li><a href="http://www.videolan.org/vlc/">VLC</a> - The most versatile media playback program around.</li>
<li><a href="http://www.sourcegear.com/diffmerge/">DiffMerge</a> - 3-way diff tool.</li>
<li><a href="http://mercurial.selenic.com">Mercurial</a> - Distributed version control.</li>
<li><a href="http://filezilla-project.org/">FileZilla</a> - FTP client.</li>
<li><a href="http://dropbox.com">Dropbox</a> - File syncing in the cloud.</li>
</ul>

<p>DiffMerge and FileZilla make the list over other more advanced programs by virtue of being free and cross-platform.  Mercurial triumphs over Git thanks to its first-rate Windows support and its spectacular command line UI.  I recommend TortoiseHg for Windows as it is often handy to see at a glance if anything in a repository has changed without firing up PowerShell.</p>

<h2>OSX</h2>

<ul>
<li><a href="http://www.iterm2.com/">iTerm2</a> - Replacement for the standard Terminal.app featuring tabs.</li>
<li><a href="http://ridiculousfish.com/hexfiend/">Hex Fiend</a> - Because everyone needs a hex editor.</li>
<li><a href="http://www.jwwalker.com/pages/plaincalc.html">PlainCalc</a> - Calculator with a console interface.</li>
<li><a href="http://adium.im">Adium</a> - Fantastic IM client.</li>
<li><a href="http://www.keepassx.org/">KeePassX</a> - Encrypted password storage.</li>
<li><a href="http://flyingmeat.com/acorn/">Acorn</a> - Simple image editor.</li>
<li><a href="http://www.vmware.com/products/fusion/overview.html">VMWare Fusion</a> - OS virtualisation, great for Windows.</li>
<li><a href="https://www.virtualbox.org/">VirtualBox</a> - OS virtualisation, great for Linux.</li>
<li><a href="http://wakaba.c3.cx/s/apps/unarchiver">The Unarchiver</a> - Decompressor for zip, 7zip, etc.</li>
<li><a href="http://www.bean-osx.com/Bean.html">Bean</a> - Simple word processor.</li>
<li><a href="http://xbmc.org/">XBMC</a> - Media player.</li>
</ul>

<p>VMWare and VirtualBox both make the list because they have different strengths.  VirtualBox is open source, free and cross-platform, but it makes no effort to integrate into the host operating system.  VMWare Fusion&#8217;s full screen mode means I can three-finger-swipe to switch from OSX to Windows, which is almost magical.</p>

<h2>Windows</h2>

<ul>
<li><a href="http://www.7-zip.org/">7-zip</a> - Archiver and dearchiver.</li>
<li><a href="http://www.zoesoft.com/console-calculator/">Console Calculator</a> - Calculator with a console interface.</li>
<li><a href="http://tools.tortoisesvn.net/grepWin.html">GrepWin</a> - Windows port of grep with Explorer integration.</li>
<li><a href="http://mh-nexus.de/en/hxd/">HxD Hex Editor</a> - Because even Windows users need a hex editor.</li>
<li><a href="http://www.codesector.com/teracopy.php">TeraCopy</a> - Explorer file copy replacement.</li>
<li><a href="http://keepass.info/">KeePass</a> - Encrypted password storage.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://simianzombie.com/?feed=rss2&#038;p=2169</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Was the iPad &#8220;Undesigned&#8221;?</title>
		<link>http://simianzombie.com/?p=2155</link>
		<comments>http://simianzombie.com/?p=2155#comments</comments>
		<pubDate>Thu, 08 Dec 2011 21:11:06 +0000</pubDate>
		<dc:creator>Ant</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://simianzombie.com/?p=2155</guid>
		<description><![CDATA[This is what baekdal has to say about Samsung&#8217;s inability to design a tablet that doesn&#8217;t look like an iPad: Apple didn&#8217;t trademark their design. They trademarked the natural shape a tablet could have. It&#8217;s like the New York Times &#8230; <a href="http://simianzombie.com/?p=2155">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This is what <a href="http://www.baekdal.com/opinion/apple-never-designed-the-ipad-they-undesigned-it/">baekdal</a> has to say about Samsung&#8217;s inability to design a tablet that doesn&#8217;t look like an iPad:</p>

<blockquote>
  <p>Apple didn&#8217;t trademark their design. They trademarked the
  natural shape a tablet could have. It&#8217;s like the New York Times
  trademarking the shape of the newspaper.</p>
  
  <p>Samsung is saying that there is no other way to design a
  tablet, and they are right. They could have used different
  materials, but the overall shape is not Apple&#8217;s design. As I
  demonstrated in this article, the shape of an iPad is the logic
  progression of simplicity itself.</p>
</blockquote>

<p>This is Steve Ballmer, holding a pre-iPad tablet computer running Windows XP:</p>

<p><a href="http://simianzombie.com/wp-content/uploads/2011/12/Windows-XP-Tablet.jpg" rel="lightbox[2155]" title="Windows-XP-Tablet"><img src="http://simianzombie.com/wp-content/uploads/2011/12/Windows-XP-Tablet.jpg" alt="" title="Windows-XP-Tablet" width="500" height="387" class="aligncenter size-full wp-image-2156" /></a></p>

<p>The similarity to the iPad is <em>uncanny</em>.  Why, there&#8217;s no other way it <em>could</em> be designed.  The sleek, uniform black bezel around the screen, the lack of buttons and surface distractions, the round corners; even the guy in the black turtle neck holding it!</p>

<p>No, wait.  <em>It looks nothing like an iPad.</em></p>

<p>Let&#8217;s be honest - all tablets prior to the iPad were junk.  They ran desktop operating systems that were entirely inappropriate to the constraints of the hardware (hello Windows 8!).  They had terrible battery life.  Aesthetically, they were dreadful.  However, the iPad isn&#8217;t the only possible way to design a tablet.  It&#8217;s just the best design around at the moment, which is why everyone else is copying it.</p>

<p>All of the ideas Apple suggested Samsung use in their design - non-black surface, hard corners, fat profile, non-centred screen, etc - sound utterly stupid.  However, these are precisely the same design ideas that every tablet manufacturer was using before Apple put some thought into the problem.  Apple isn&#8217;t saying, &#8220;You should use these obviously dumb ideas we&#8217;ve just come up with so that your product is crippled in comparison to ours.&#8221;  They&#8217;re saying, &#8220;You should continue to use the dumb ideas that crippled your products before we showed you how to make tablets that don&#8217;t suck.&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://simianzombie.com/?feed=rss2&#038;p=2155</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

