<?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>CodeCube.NET &#187; Programming</title>
	<atom:link href="http://codecube.net/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://codecube.net</link>
	<description>Joel Martinez' weblog</description>
	<lastBuildDate>Mon, 21 May 2012 20:28:24 +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>The Problem with C# 5&#8242;s async/await Pattern</title>
		<link>http://codecube.net/2012/05/the-problem-with-c-5s-asyncawait-pattern/</link>
		<comments>http://codecube.net/2012/05/the-problem-with-c-5s-asyncawait-pattern/#comments</comments>
		<pubDate>Mon, 21 May 2012 13:44:45 +0000</pubDate>
		<dc:creator>Joel Martinez</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://codecube.net/?p=556</guid>
		<description><![CDATA[C# 5 brings a fantastic new feature … built-in asynchrony (not to be confused with concurrency). The compiler has added two new keywords, async and await, which allows your code to transparently change execution contexts. For example, instead of writing: Task .StartNew(() =&#62; MakeSomeDecisionSlowly()) .ContinueWith(result =&#62; ProcessResult(result)); You can simply say: bool result = await [...]]]></description>
			<content:encoded><![CDATA[<p>C# 5 brings a fantastic new feature … <a href="http://msdn.microsoft.com/en-us/library/hh191443%28v=vs.110%29.aspx">built-in asynchrony</a> (not to be <a href="http://stackoverflow.com/a/4056583/5416">confused with concurrency</a>). The compiler has added two new keywords, async and await, which allows your code to transparently change execution contexts. For example, instead of writing:</p>
<blockquote>
<pre>Task
  .StartNew(() =&gt; MakeSomeDecisionSlowly())
  .ContinueWith(result =&gt; ProcessResult(result));</pre>
</blockquote>
<p>You can simply say:</p>
<blockquote>
<pre>bool result = await MakeSomeDecisionSlowly();
ProcessResult(result);</pre>
</blockquote>
<p>While the two pieces of code are exactly equivalent, the second code is so much simpler to understand. Because you don&#8217;t really have to think about the fact that there is an asynchronous context switch going on, you are free to focus on your program&#8217;s logic, rather than worrying about manually orchestrating what tasks are doing what.</p>
<p>However, after using these features for several days while porting my <a href="https://github.com/joelmartinez/Khan-Academy-for-Windows-Phone">KhanAcademy windows phone app to windows 8</a>, I&#8217;ve come to approach them with a bit of caution. While they are great for low level IO-bound tasks, in my opinion they don&#8217;t scale well to higher level API design. A few things to watch out for:</p>
<p>If you use await somewhere in your code, then the containing method needs to be marked with the async keyword, and there are specific rules about return types. Namely, the method must either be void, or return Task&lt;T&gt;. For example, the example above would have to be in a method</p>
<blockquote>
<pre>public async void DoThatThing() { … }</pre>
</blockquote>
<p>Or, if you wanted to return the result of &#8216;MakeSomeDecisionSlowly&#8217; back to the caller, it would have to look like this:</p>
<blockquote>
<pre>public async Task&lt;bool&gt; DoThatThing() { … }</pre>
</blockquote>
<p>Which is great, and all, but then it means that the calling method must be decorated with &#8216;async&#8217; as well. If you are refactoring an existing codebase, this can have the effect of rippling up the inheritance chain with numerous (albeit small) changes … depending on the situation.</p>
<p>Ok, fine, maybe that&#8217;s not a huge deal; it&#8217;s kind of annoying but I can definitely deal with that kind of refactoring. The big problem I have with async/await is that outside of relatively trivial pieces of code, it can tend to wipe away many benefits of proper abstractions.</p>
<p>Let&#8217;s say you are implementing a remote API call, and you have several requirements:</p>
<ul>
<li>Process the results if
<ul>
<li>You have a network connection (common mobile requirement)</li>
<li>The server is reachable (what if you&#8217;re connected at starbucks, but haven&#8217;t accepted the wifi&#8217;s terms of use?)</li>
<li>The server returns a code 200 (bugs happen)</li>
<li>The server indicates that your credentials are ok (what if the user&#8217;s password expired, or was changed by the user on your website?)</li>
<li>The server&#8217;s json response indicates a successful request</li>
</ul>
</li>
<li>If any of the above conditions are false, notify the user of the problem (with specific text for the situation).</li>
</ul>
<p>This is a very common scenario in any occasionally connected mobile application, and you can see that there are no less than five distinct decisions that need to be made during the course of an API call. If you use async/await blindly, you have two problems:</p>
<p>First, you are deferring these decisions to the caller … you&#8217;ll do a nice asynchronous call, and return a Task&lt;string&gt; with the json results; or if you&#8217;re sophisticated, a Task&lt;T&gt; with the results already parsed and converted to a strongly typed object. However, it&#8217;s up to the caller to handle exceptions, check for network connections, deal with individual response scenarios (logged out, invalid request, etc.). So you may end up with every call site looking like this:</p>
<blockquote>
<pre>if (HasConnection())
{
  try
  {
    MyObject result = await MakeRemoteAPICall();
    ProcessSuccessfulResult(result);
  }
  catch(Exception e)
  {
    ProcessError(e.Message);
  }
}
else
{
  ProcessError("No Connection");
}</pre>
</blockquote>
<p>Second, providing further abstractions is difficult because you are limited to a single return type. So if you want to handle all of the stated requirements for the caller, you will have to wrap up the result in a special return value that can provide some details to the user, such as &#8216;was it successful&#8217;, the error message if it wasn&#8217;t, and the parsed return value if it was. While the pros and cons of using error codes for return values have been <a href="https://www.google.com/search?q=error+codes+vs+exception&amp;ie=utf-8&amp;oe=utf-8&amp;aq=t&amp;rls=org.mozilla:en-US:official&amp;client=firefox-a">debated for ages</a>; I tend to prefer simpler return values for local APIs, since a complex return value adds an additional burden on the caller to know how to interpret the results. At best, every call site would look something like this:</p>
<blockquote>
<pre>Result&lt;MyObject&gt; value = await MakeRemoteAPICall();
if (value.WasSuccessful)
{
  ProcessSuccessfulResult(value.Result);
}
else
{
  ProcessError(value.ErrorMessage);
}</pre>
</blockquote>
<p>That&#8217;s a bit better than before, but still rather verbose for my taste.</p>
<p>I propose that the callback style of API design still has a place for situations like this. Consider the following sample:</p>
<blockquote>
<pre>MakeRemoteAPICall(
  result =&gt; ProcessSucessfulResult(result),
  error =&gt; ProcessError(error));</pre>
</blockquote>
<p>For the local consumer of this API, this is logically the same: if the call was successful do this, otherwise do that. But the caller doesn&#8217;t have to worry about all the nuances of deciding whether a call was successful or not. They can focus on how to process the results, rather than dealing with all of this ceremony. And after all, isn&#8217;t that what we&#8217;re all aiming to do, simplify our code?</p>
<p>I would love to hear thoughts about how this kind of code can be made even simpler. Would love to hear any opinions, for or against. Thanks!</p>
<p><em>edit: lively debate over on Reddit <img src='http://codecube.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  <a href="http://www.reddit.com/r/programming/comments/txhfq/the_problem_with_c_5s_asyncawait_pattern/">http://www.reddit.com/r/programming/comments/txhfq/the_problem_with_c_5s_asyncawait_pattern/</a></em></p>
]]></content:encoded>
			<wfw:commentRss>http://codecube.net/2012/05/the-problem-with-c-5s-asyncawait-pattern/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Twilio-CSharp for MonoTouch and Android</title>
		<link>http://codecube.net/2012/05/twilio-csharp-for-monotouch-and-android/</link>
		<comments>http://codecube.net/2012/05/twilio-csharp-for-monotouch-and-android/#comments</comments>
		<pubDate>Fri, 18 May 2012 02:28:13 +0000</pubDate>
		<dc:creator>Joel Martinez</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://codecube.net/?p=550</guid>
		<description><![CDATA[I noticed that Twilio&#8216;s official C# client didn&#8217;t have a version that you could use from MonoTouch and Mono for Android. So I took a few minutes, forked the project, and added some MonoDevelop projects so that you can compile for each of those two platforms. The mono versions are using the silverlight version of [...]]]></description>
			<content:encoded><![CDATA[<p>I noticed that <a href="http://twilio.com">Twilio</a>&#8216;s official <a href="https://github.com/twilio/twilio-csharp">C# client</a> didn&#8217;t have a version that you could use from <a href="http://xamarin.com/monotouch">MonoTouch</a> and <a href="http://xamarin.com/monoforandroid">Mono for Android</a>. So I took a few minutes, <a href="https://github.com/joelmartinez/twilio-csharp">forked the project</a>, and added some <a href="http://monodevelop.com/">MonoDevelop</a> projects so that you can compile for each of those two platforms.</p>
<p>The mono versions are using the silverlight version of the API, which uses async style methods where you pass in callbacks. There are two dependencies: <a href="https://github.com/restsharp/RestSharp">RestSharp</a>, and<a href="http://json.codeplex.com/"> json.net</a>. Though it looks like RestSharp has shed their dependency on json.net, there are still some references in the twilio code. The json.net project maintain mono specific versions &#8230; they depend on a portable library for that cross platform support. Unfortunately that means that you can&#8217;t compile it if you&#8217;re on a mac and only using monodevelop. Thankfully I found <a href="https://github.com/ayoung/Newtonsoft.Json">this helpful fork</a> that did this work for me.</p>
<p>At the risk of  <a href="http://john-sheehan.com/post/17964678895/dont-push-your-pull-requests">&#8216;pushing&#8217; my pull request</a> onto them, I submitted <a href="https://github.com/twilio/twilio-csharp/pull/28">a pull request</a>; But I made sure to word it such that I&#8217;m ok if they want to push back and ask for any changes &#8230; or maybe they don&#8217;t want to maintain a Mono version at all, in which case I&#8217;m happy to keep it in my fork. So we&#8217;ll see what happens. Please let me know if you have any feedback on this change.</p>
<p>As an aside, I also noticed while I was looking around github that many projects that have mono versions tend to use *.MonoTouch and *.MonoDroid for their project/solution names. It&#8217;s a subtle thing, but  Xamarin is careful not to refer to their product as MonoDroid, but Mono For Android. I wonder if this has to do with the trademarks that are <a href="http://www.businessinsider.com/verizon-drops-droid-brand-for-newest-android-phone-2010-2">owned by Lucasarts</a>, if so I&#8217;d hate to wake up to a nice C&amp;D in the mailbox <img src='http://codecube.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://codecube.net/2012/05/twilio-csharp-for-monotouch-and-android/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Parse an iOS plist on Android</title>
		<link>http://codecube.net/2012/05/parse-an-ios-plist-on-android/</link>
		<comments>http://codecube.net/2012/05/parse-an-ios-plist-on-android/#comments</comments>
		<pubDate>Wed, 16 May 2012 04:16:40 +0000</pubDate>
		<dc:creator>Joel Martinez</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://codecube.net/?p=547</guid>
		<description><![CDATA[I was implementing a feature in the CalorieCount Android App the other day that was previously implemented in the iOS version of that same app. Just needed to show a list of timezones based on what country was selected. Not rocket science at all, but the iOS implementation was storing the data in a plist [...]]]></description>
			<content:encoded><![CDATA[<p>I was implementing a feature in the <a href="http://caloriecount.about.com/">CalorieCount</a> <a href="https://market.android.com/details?id=com.about.CalorieCount">Android App</a> the other day that was previously implemented in the <a href="http://itunes.apple.com/us/app/calorie-counter-by-caloriecount/id367018196?mt=8">iOS version</a> of that same app. Just needed to show a list of timezones based on what country was selected. Not rocket science at all, but the iOS implementation was storing the data in a plist file, with a &lt;dict&gt; element inside. So rather than take that data and try to translate it to something more &#8216;android specific&#8217; &#8230; I decided to just use the file as is. The biggest benefit was that in the future if we ever had to update the file, I could update it in place, and simply copy it over to the other platform.</p>
<p>So I copied the file into my xml folder, and wrote this simple parser that reads the file in, and parses it into a HashMap</p>
<div id="gist-2655811" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="cp">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</span></div><div class='line' id='LC2'><span class="cp">&lt;!DOCTYPE plist PUBLIC &quot;-//Apple Computer//DTD PLIST 1.0//EN&quot; &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;</span></div><div class='line' id='LC3'><span class="nt">&lt;plist</span> <span class="na">version=</span><span class="s">&quot;1.0&quot;</span><span class="nt">&gt;</span></div><div class='line' id='LC4'><span class="nt">&lt;dict&gt;</span></div><div class='line' id='LC5'>	<span class="nt">&lt;key&gt;</span>key1<span class="nt">&lt;/key&gt;</span></div><div class='line' id='LC6'>	<span class="nt">&lt;array&gt;</span></div><div class='line' id='LC7'>		<span class="nt">&lt;string&gt;</span>one<span class="nt">&lt;/string&gt;</span></div><div class='line' id='LC8'>		<span class="nt">&lt;string&gt;</span>two<span class="nt">&lt;/string&gt;</span></div><div class='line' id='LC9'>	<span class="nt">&lt;/array&gt;</span></div><div class='line' id='LC10'><br/></div><div class='line' id='LC11'>	<span class="nt">&lt;key&gt;</span>key2<span class="nt">&lt;/key&gt;</span></div><div class='line' id='LC12'>	<span class="nt">&lt;array&gt;</span></div><div class='line' id='LC13'>		<span class="nt">&lt;string&gt;</span>one<span class="nt">&lt;/string&gt;</span></div><div class='line' id='LC14'>		<span class="nt">&lt;string&gt;</span>two<span class="nt">&lt;/string&gt;</span></div><div class='line' id='LC15'>	<span class="nt">&lt;/array&gt;</span></div><div class='line' id='LC16'><span class="nt">&lt;/dict&gt;</span></div><div class='line' id='LC17'><span class="nt">&lt;/plist&gt;</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/2655811/62f2efa5d7885f431f345b04a8d57675eec960fb/sample.plist" style="float:right;">view raw</a>
            <a href="https://gist.github.com/2655811#file_sample.plist" style="float:right;margin-right:10px;color:#666">sample.plist</a>
            <a href="https://gist.github.com/2655811">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="kn">package</span> <span class="n">cyborg</span><span class="o">;</span></div><div class='line' id='LC2'><br/></div><div class='line' id='LC3'><span class="kn">import</span> <span class="nn">java.io.IOException</span><span class="o">;</span></div><div class='line' id='LC4'><span class="kn">import</span> <span class="nn">java.util.ArrayList</span><span class="o">;</span></div><div class='line' id='LC5'><span class="kn">import</span> <span class="nn">java.util.HashMap</span><span class="o">;</span></div><div class='line' id='LC6'><br/></div><div class='line' id='LC7'><span class="kn">import</span> <span class="nn">org.xmlpull.v1.XmlPullParser</span><span class="o">;</span></div><div class='line' id='LC8'><span class="kn">import</span> <span class="nn">org.xmlpull.v1.XmlPullParserException</span><span class="o">;</span></div><div class='line' id='LC9'><br/></div><div class='line' id='LC10'><span class="kn">import</span> <span class="nn">android.content.Context</span><span class="o">;</span></div><div class='line' id='LC11'><br/></div><div class='line' id='LC12'><span class="cm">/**</span></div><div class='line' id='LC13'><span class="cm"> * This class parses an iOS plist with a dict element into a hashmap.</span></div><div class='line' id='LC14'><span class="cm"> */</span></div><div class='line' id='LC15'><span class="kd">public</span> <span class="kd">class</span> <span class="nc">XmlMapParser</span> <span class="o">{</span></div><div class='line' id='LC16'>	<span class="kd">private</span> <span class="n">XmlPullParser</span> <span class="n">parser</span><span class="o">;</span></div><div class='line' id='LC17'><br/></div><div class='line' id='LC18'>	<span class="kd">public</span> <span class="nf">XmlMapVisitor</span><span class="o">(</span><span class="n">Context</span> <span class="n">context</span><span class="o">,</span> <span class="kt">int</span> <span class="n">xmlid</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC19'>		<span class="n">parser</span> <span class="o">=</span> <span class="n">context</span><span class="o">.</span><span class="na">getResources</span><span class="o">().</span><span class="na">getXml</span><span class="o">(</span><span class="n">xmlid</span><span class="o">);</span></div><div class='line' id='LC20'>	<span class="o">}</span></div><div class='line' id='LC21'><br/></div><div class='line' id='LC22'>	<span class="kd">public</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">ArrayList</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;&gt;</span> <span class="n">convert</span><span class="o">()</span> <span class="o">{</span></div><div class='line' id='LC23'>		<span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">ArrayList</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;&gt;</span> <span class="n">map</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">ArrayList</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;&gt;();</span></div><div class='line' id='LC24'><br/></div><div class='line' id='LC25'>		<span class="kd">final</span> <span class="n">String</span> <span class="n">KEY</span> <span class="o">=</span> <span class="s">&quot;key&quot;</span><span class="o">,</span> <span class="n">STRING</span> <span class="o">=</span> <span class="s">&quot;string&quot;</span><span class="o">;</span></div><div class='line' id='LC26'><br/></div><div class='line' id='LC27'>		<span class="k">try</span> <span class="o">{</span></div><div class='line' id='LC28'>			<span class="n">parser</span><span class="o">.</span><span class="na">next</span><span class="o">();</span></div><div class='line' id='LC29'>			<span class="kt">int</span> <span class="n">eventType</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="na">getEventType</span><span class="o">();</span></div><div class='line' id='LC30'>			<span class="n">String</span> <span class="n">lastTag</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span></div><div class='line' id='LC31'>			<span class="n">String</span> <span class="n">lastKey</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span></div><div class='line' id='LC32'><br/></div><div class='line' id='LC33'>			<span class="k">while</span> <span class="o">(</span><span class="n">eventType</span> <span class="o">!=</span> <span class="n">XmlPullParser</span><span class="o">.</span><span class="na">END_DOCUMENT</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC34'><br/></div><div class='line' id='LC35'>				<span class="k">if</span> <span class="o">(</span><span class="n">eventType</span> <span class="o">==</span> <span class="n">XmlPullParser</span><span class="o">.</span><span class="na">START_TAG</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC36'>					<span class="n">lastTag</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="na">getName</span><span class="o">();</span></div><div class='line' id='LC37'>				<span class="o">}</span> </div><div class='line' id='LC38'>				<span class="k">else</span> <span class="nf">if</span> <span class="o">(</span><span class="n">eventType</span> <span class="o">==</span> <span class="n">XmlPullParser</span><span class="o">.</span><span class="na">TEXT</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC39'>					<span class="c1">// some text</span></div><div class='line' id='LC40'>					<span class="k">if</span> <span class="o">(</span><span class="n">KEY</span><span class="o">.</span><span class="na">equalsIgnoreCase</span><span class="o">(</span><span class="n">lastTag</span><span class="o">))</span> <span class="o">{</span></div><div class='line' id='LC41'>						<span class="c1">// start tracking a new key</span></div><div class='line' id='LC42'>						<span class="n">lastKey</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="na">getText</span><span class="o">();</span></div><div class='line' id='LC43'>					<span class="o">}</span></div><div class='line' id='LC44'>					<span class="k">else</span> <span class="nf">if</span> <span class="o">(</span><span class="n">STRING</span><span class="o">.</span><span class="na">equalsIgnoreCase</span><span class="o">(</span><span class="n">lastTag</span><span class="o">))</span> <span class="o">{</span></div><div class='line' id='LC45'>						<span class="c1">// a new string for the last encountered key</span></div><div class='line' id='LC46'>						<span class="k">if</span> <span class="o">(!</span><span class="n">map</span><span class="o">.</span><span class="na">containsKey</span><span class="o">(</span><span class="n">lastKey</span><span class="o">))</span> <span class="o">{</span></div><div class='line' id='LC47'>							<span class="n">map</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="n">lastKey</span><span class="o">,</span> <span class="k">new</span> <span class="n">ArrayList</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;());</span></div><div class='line' id='LC48'>						<span class="o">}</span></div><div class='line' id='LC49'><br/></div><div class='line' id='LC50'>						<span class="n">map</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">lastKey</span><span class="o">).</span><span class="na">add</span><span class="o">(</span><span class="n">parser</span><span class="o">.</span><span class="na">getText</span><span class="o">());</span></div><div class='line' id='LC51'>					<span class="o">}</span></div><div class='line' id='LC52'>				<span class="o">}</span></div><div class='line' id='LC53'><br/></div><div class='line' id='LC54'>				<span class="n">eventType</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="na">next</span><span class="o">();</span></div><div class='line' id='LC55'>			<span class="o">}</span></div><div class='line' id='LC56'>		<span class="o">}</span> <span class="k">catch</span> <span class="o">(</span><span class="n">XmlPullParserException</span> <span class="n">e</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC57'>			<span class="n">e</span><span class="o">.</span><span class="na">printStackTrace</span><span class="o">();</span></div><div class='line' id='LC58'>		<span class="o">}</span> <span class="k">catch</span> <span class="o">(</span><span class="n">IOException</span> <span class="n">e</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC59'>			<span class="n">e</span><span class="o">.</span><span class="na">printStackTrace</span><span class="o">();</span></div><div class='line' id='LC60'>		<span class="o">}</span></div><div class='line' id='LC61'><br/></div><div class='line' id='LC62'>		<span class="k">return</span> <span class="n">map</span><span class="o">;</span></div><div class='line' id='LC63'>	<span class="o">}</span></div><div class='line' id='LC64'><span class="o">}</span></div><div class='line' id='LC65'><br/></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/2655811/a3966addf131f679edd00d91c245f4dde83f4f1b/XmlMapParser.java" style="float:right;">view raw</a>
            <a href="https://gist.github.com/2655811#file_xml_map_parser.java" style="float:right;margin-right:10px;color:#666">XmlMapParser.java</a>
            <a href="https://gist.github.com/2655811">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>

<p>The way I look at it, may as well reuse what we&#8217;ve got, and spend less time yak shaving (ie. translating between platforms) &#8230; git &#8216;er done!</p>
]]></content:encoded>
			<wfw:commentRss>http://codecube.net/2012/05/parse-an-ios-plist-on-android/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GoogleAnalyticsTracker for Windows Phone</title>
		<link>http://codecube.net/2012/02/googleanalyticstracker-for-windows-phone/</link>
		<comments>http://codecube.net/2012/02/googleanalyticstracker-for-windows-phone/#comments</comments>
		<pubDate>Thu, 16 Feb 2012 04:18:04 +0000</pubDate>
		<dc:creator>Joel Martinez</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://codecube.net/?p=536</guid>
		<description><![CDATA[I&#8217;ve been wanting to add google analytics tracking to the Khan Academy app, but have been putting it off for a while since it looked like the only option was to use the Silverlight Analytics Framework. There&#8217;s so many things wrong with that distribution: Overly complex to support N number of different trackers &#8230; enterprise [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been wanting to add google analytics tracking to the Khan Academy app, but have been putting it off for a while since it looked like the only option was to use the <a href="http://msaf.codeplex.com/">Silverlight Analytics Framework</a>. There&#8217;s so many things wrong with that distribution:</p>
<ul>
<li>Overly complex to support <em>N</em> number of different trackers &#8230; enterprise software at it&#8217;s &#8220;best&#8221;</li>
<li>Binary distribution is only via <a href="http://msaf.codeplex.com/releases/view/80753">MSI installer</a>! seriously, in this day and age, either give me a NuGet package, or at worst just give me the .dlls.</li>
<li>Even though it&#8217;s open source, <a href="http://msaf.codeplex.com/SourceControl/changeset/view/85494">looking through the code</a> is an exercise in futility (see point 1). I considered going in and extracting just the code for GA, but it&#8217;s not even obvious where that is in the codebase &#8230; admittedly, I only browsed around through the online codeplex browser.</li>
</ul>
<p>Thankfully, <a href="http://syndicatex.com/">Justin</a> asked me yesterday about adding GA to his MonoDroid project. I hesitantly pointed him to the MSAF library, but kept searching when I finally came across <a href="http://blog.maartenballiauw.be/">Maarten Balliauw</a>&#8216;s sweet implementation of a <a href="https://github.com/maartenba/GoogleAnalyticsTracker">GoogleAnalyticsTracker for asp.net mvc</a>. He was able to quickly adapt the code for his monodroid project; and because GitHub is awesome, I also forked it and added a new project that lets you build the solution for Windows Phone. You can find it here: <a href="https://github.com/maartenba/GoogleAnalyticsTracker">https://github.com/joelmartinez/GoogleAnalyticsTracker</a></p>
<p>And then sent back a <a href="https://github.com/maartenba/GoogleAnalyticsTracker/pull/3">pull request</a> for the changes <img src='http://codecube.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  That&#8217;s the great thing about open source, done GitHub style. I&#8217;m free to make (and share) the changes I need &#8230; and if they are good enough, they can easily make their way back into the original/main project. Awesome.</p>
<p><em>Edit: Maarten quickly accepted my pull request, and even adjusted the NuGet package to include the windows 7 build. With that, I deleted my fork as I wasn&#8217;t planning on making any additional changes in the immediate future. So you can find the latest here: <a href="https://github.com/maartenba/GoogleAnalyticsTracker">https://github.com/maartenba/GoogleAnalyticsTracker</a><br />
</em></p>
]]></content:encoded>
			<wfw:commentRss>http://codecube.net/2012/02/googleanalyticstracker-for-windows-phone/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>AI and Machine Learning</title>
		<link>http://codecube.net/2011/10/ai-and-machine-learning/</link>
		<comments>http://codecube.net/2011/10/ai-and-machine-learning/#comments</comments>
		<pubDate>Tue, 11 Oct 2011 09:27:27 +0000</pubDate>
		<dc:creator>Joel Martinez</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://codecube.net/?p=518</guid>
		<description><![CDATA[Machine Learning and Artificial Intelligence have long been interests of mine. Socially Aware XBox Live Games Finite State Machine nBayes Most recently, I&#8217;ve enrolled for the AI and Machine learning classes being offered by Stanford. I truly feel as if advanced engineering practices such as machine learning and AI are going to be what separates [...]]]></description>
			<content:encoded><![CDATA[<p>Machine Learning and Artificial Intelligence have long been interests of mine.</p>
<ul>
<li><a title="Socially Aware XBox Live Games" href="http://codecube.net/2008/06/socially-aware-xbox-live-games/">Socially Aware XBox Live Games</a></li>
<li><a title="Finite State Machine" href="http://codecube.net/2008/11/finite-state-machine/">Finite State Machine</a></li>
<li><a title="Bayesian Filtering with C#" href="http://codecube.net/2009/05/bayesian-filtering-with-c/">nBayes</a></li>
</ul>
<p>Most recently, I&#8217;ve enrolled for the <a href="http://www.ai-class.com">AI</a> and <a href="http://www.ml-class.org">Machine learning</a> classes being offered by Stanford. I truly feel as if advanced engineering practices such as machine learning and AI are going to be what separates the good companies from the truly great companies over the course of the next decade. So far, these classes have great introductions if you&#8217;ve never been exposed to the fields, and promise to go much deeper.</p>
<p>I&#8217;m very glad that this online education movement, which was legitimized by <a href="http://www.khanacademy.org/">Khan Academy</a> IMO, is gaining momentum. Soon, the whole world will have easy access to even the most advanced topics &#8230; the future will be ours to create, if only we step up to the challenge.</p>
<p>In the meantime, if you&#8217;re interested you should get started by watching the intro lectures, and (at least in the case of the ML Class) installing Octave: <a href="http://www.gnu.org/software/octave/">http://www.gnu.org/software/octave/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://codecube.net/2011/10/ai-and-machine-learning/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Calorie Count @ NYTM</title>
		<link>http://codecube.net/2011/09/calorie-count-nytm/</link>
		<comments>http://codecube.net/2011/09/calorie-count-nytm/#comments</comments>
		<pubDate>Fri, 23 Sep 2011 13:40:22 +0000</pubDate>
		<dc:creator>Joel Martinez</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://codecube.net/?p=503</guid>
		<description><![CDATA[This is already a few weeks old, but someone finally uploaded a good video of the presentation that I was a part of at the September New York Tech Meetup. Igor showed off the awesome new voice logging feature that we recently added to the iPhone version of the app (coming soon to the Android [...]]]></description>
			<content:encoded><![CDATA[<p>This is already a few weeks old, but someone finally uploaded a good video of the presentation that I was a part of at the September New York Tech Meetup.</p>
<p><iframe src="http://www.youtube.com/embed/u09hLxTPJxw" frameborder="0" width="560" height="315"></iframe></p>
<p>Igor showed off the awesome new voice logging feature that we recently added to the iPhone version of the app (coming soon to the Android version). Then I manned the keyboard to show off a little hack that we put together that same day. We provisioned a <a href="http://twilio.com">Twilio</a> phone number, and let the user record a little 10 second clip of what they want to log (ie. &#8220;one banana, two cups of coffee&#8221;). We then took that clip and sent it to <a href="http://www.ispeech.org/">iSpeech</a> who transcribed it. And finally we ran the transcribed text through our own API to log it.</p>
<p>Igor asked the crowd to call in the phone number, which they did, and it worked! It was a great experience, and a fun day. Many thanks to Hal Rotholz as well as he was instrumental in getting this hack up and running, in addition to monitoring the server while we were up there <img src='http://codecube.net/wp-includes/images/smilies/icon_razz.gif' alt=':-P' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://codecube.net/2011/09/calorie-count-nytm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Conway&#8217;s Game of Life in C#</title>
		<link>http://codecube.net/2011/09/conways-game-of-life-in-c/</link>
		<comments>http://codecube.net/2011/09/conways-game-of-life-in-c/#comments</comments>
		<pubDate>Mon, 05 Sep 2011 03:41:25 +0000</pubDate>
		<dc:creator>Joel Martinez</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://codecube.net/?p=491</guid>
		<description><![CDATA[I wrote this for fun on the train a while ago, and just came across it again recently. So I figured I may as well post it. The code implements a simple game of life simulation, but the interesting bit is that it parallelizes the process using the TPL. I uploaded it to github as a gist, [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote this for fun on the train a while ago, and just came across it again recently. So I figured I may as well post it. The code implements a simple <a href="http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life" title="Conway's Game of Life in C# on GitHub">game of life</a> simulation, but the interesting bit is that it parallelizes the process using the TPL. I uploaded it to github as a gist, so please feel free to check it out, and see if you can do anything interesting with it <img src='http://codecube.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<div id="gist-1194013" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="k">using</span> <span class="nn">System</span><span class="p">;</span></div><div class='line' id='LC2'><span class="k">using</span> <span class="nn">System.Threading.Tasks</span><span class="p">;</span></div><div class='line' id='LC3'><br/></div><div class='line' id='LC4'><span class="k">namespace</span> <span class="nn">Life</span></div><div class='line' id='LC5'><span class="p">{</span></div><div class='line' id='LC6'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">public</span> <span class="k">class</span> <span class="nc">LifeSimulation</span></div><div class='line' id='LC7'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">{</span></div><div class='line' id='LC8'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">private</span> <span class="kt">bool</span><span class="p">[,]</span> <span class="n">world</span><span class="p">;</span></div><div class='line' id='LC9'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">private</span> <span class="kt">bool</span><span class="p">[,]</span> <span class="n">nextGeneration</span><span class="p">;</span></div><div class='line' id='LC10'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">private</span> <span class="n">Task</span> <span class="n">processTask</span><span class="p">;</span></div><div class='line' id='LC11'><br/></div><div class='line' id='LC12'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">public</span> <span class="nf">LifeSimulation</span><span class="p">(</span><span class="kt">int</span> <span class="n">size</span><span class="p">)</span></div><div class='line' id='LC13'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">{</span></div><div class='line' id='LC14'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="n">size</span> <span class="p">&lt;</span> <span class="m">0</span><span class="p">)</span> <span class="k">throw</span> <span class="k">new</span> <span class="n">ArgumentOutOfRangeException</span><span class="p">(</span><span class="s">&quot;Size must be greater than zero&quot;</span><span class="p">);</span></div><div class='line' id='LC15'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="n">Size</span> <span class="p">=</span> <span class="n">size</span><span class="p">;</span></div><div class='line' id='LC16'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">world</span> <span class="p">=</span> <span class="k">new</span> <span class="kt">bool</span><span class="p">[</span><span class="n">size</span><span class="p">,</span> <span class="n">size</span><span class="p">];</span></div><div class='line' id='LC17'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">nextGeneration</span> <span class="p">=</span> <span class="k">new</span> <span class="kt">bool</span><span class="p">[</span><span class="n">size</span><span class="p">,</span> <span class="n">size</span><span class="p">];</span></div><div class='line' id='LC18'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC19'><br/></div><div class='line' id='LC20'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">public</span> <span class="kt">int</span> <span class="n">Size</span> <span class="p">{</span> <span class="k">get</span><span class="p">;</span> <span class="k">private</span> <span class="k">set</span><span class="p">;</span> <span class="p">}</span></div><div class='line' id='LC21'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">public</span> <span class="kt">int</span> <span class="n">Generation</span> <span class="p">{</span> <span class="k">get</span><span class="p">;</span> <span class="k">private</span> <span class="k">set</span><span class="p">;</span> <span class="p">}</span></div><div class='line' id='LC22'><br/></div><div class='line' id='LC23'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">public</span> <span class="n">Action</span><span class="p">&lt;</span><span class="kt">bool</span><span class="p">[,]&gt;</span> <span class="n">NextGenerationCompleted</span><span class="p">;</span></div><div class='line' id='LC24'><br/></div><div class='line' id='LC25'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">public</span> <span class="kt">bool</span> <span class="k">this</span><span class="p">[</span><span class="kt">int</span> <span class="n">x</span><span class="p">,</span> <span class="kt">int</span> <span class="n">y</span><span class="p">]</span></div><div class='line' id='LC26'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">{</span></div><div class='line' id='LC27'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">get</span> <span class="p">{</span> <span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="n">world</span><span class="p">[</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">];</span> <span class="p">}</span></div><div class='line' id='LC28'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">set</span> <span class="p">{</span> <span class="k">this</span><span class="p">.</span><span class="n">world</span><span class="p">[</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">]</span> <span class="p">=</span> <span class="k">value</span><span class="p">;</span> <span class="p">}</span></div><div class='line' id='LC29'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC30'><br/></div><div class='line' id='LC31'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">public</span> <span class="kt">bool</span> <span class="nf">ToggleCell</span><span class="p">(</span><span class="kt">int</span> <span class="n">x</span><span class="p">,</span> <span class="kt">int</span> <span class="n">y</span><span class="p">)</span></div><div class='line' id='LC32'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">{</span></div><div class='line' id='LC33'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kt">bool</span> <span class="n">currentValue</span> <span class="p">=</span> <span class="k">this</span><span class="p">.</span><span class="n">world</span><span class="p">[</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">];</span></div><div class='line' id='LC34'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="n">world</span><span class="p">[</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">]</span> <span class="p">=</span> <span class="p">!</span><span class="n">currentValue</span><span class="p">;</span></div><div class='line' id='LC35'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC36'><br/></div><div class='line' id='LC37'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">public</span> <span class="k">void</span> <span class="nf">Update</span><span class="p">()</span></div><div class='line' id='LC38'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">{</span></div><div class='line' id='LC39'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="n">processTask</span> <span class="p">!=</span> <span class="k">null</span> <span class="p">&amp;&amp;</span> <span class="k">this</span><span class="p">.</span><span class="n">processTask</span><span class="p">.</span><span class="n">IsCompleted</span><span class="p">)</span></div><div class='line' id='LC40'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">{</span></div><div class='line' id='LC41'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1">// when a generation has completed</span></div><div class='line' id='LC42'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1">// now flip the back buffer so we can start processing on the next generation</span></div><div class='line' id='LC43'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kt">var</span> <span class="n">flip</span> <span class="p">=</span> <span class="k">this</span><span class="p">.</span><span class="n">nextGeneration</span><span class="p">;</span></div><div class='line' id='LC44'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="n">nextGeneration</span> <span class="p">=</span> <span class="k">this</span><span class="p">.</span><span class="n">world</span><span class="p">;</span></div><div class='line' id='LC45'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="n">world</span> <span class="p">=</span> <span class="n">flip</span><span class="p">;</span></div><div class='line' id='LC46'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">Generation</span><span class="p">++;</span></div><div class='line' id='LC47'><br/></div><div class='line' id='LC48'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1">// begin the next generation&#39;s processing asynchronously</span></div><div class='line' id='LC49'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="n">processTask</span> <span class="p">=</span> <span class="k">this</span><span class="p">.</span><span class="n">ProcessGeneration</span><span class="p">();</span></div><div class='line' id='LC50'><br/></div><div class='line' id='LC51'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="n">NextGenerationCompleted</span> <span class="p">!=</span> <span class="k">null</span><span class="p">)</span> <span class="n">NextGenerationCompleted</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="n">world</span><span class="p">);</span></div><div class='line' id='LC52'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC53'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC54'><br/></div><div class='line' id='LC55'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">public</span> <span class="k">void</span> <span class="nf">BeginGeneration</span><span class="p">()</span></div><div class='line' id='LC56'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">{</span></div><div class='line' id='LC57'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="n">processTask</span> <span class="p">==</span> <span class="k">null</span> <span class="p">||</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="n">processTask</span> <span class="p">!=</span> <span class="k">null</span> <span class="p">&amp;&amp;</span> <span class="k">this</span><span class="p">.</span><span class="n">processTask</span><span class="p">.</span><span class="n">IsCompleted</span><span class="p">))</span></div><div class='line' id='LC58'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">{</span></div><div class='line' id='LC59'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1">// only begin the generation if the previous process was completed</span></div><div class='line' id='LC60'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="n">processTask</span> <span class="p">=</span> <span class="k">this</span><span class="p">.</span><span class="n">ProcessGeneration</span><span class="p">();</span></div><div class='line' id='LC61'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC62'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC63'><br/></div><div class='line' id='LC64'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">public</span> <span class="k">void</span> <span class="nf">Wait</span><span class="p">()</span></div><div class='line' id='LC65'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">{</span></div><div class='line' id='LC66'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="n">processTask</span> <span class="p">!=</span> <span class="k">null</span><span class="p">)</span></div><div class='line' id='LC67'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">{</span></div><div class='line' id='LC68'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="n">processTask</span><span class="p">.</span><span class="n">Wait</span><span class="p">();</span></div><div class='line' id='LC69'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC70'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC71'><br/></div><div class='line' id='LC72'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">private</span> <span class="n">Task</span> <span class="nf">ProcessGeneration</span><span class="p">()</span></div><div class='line' id='LC73'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">{</span></div><div class='line' id='LC74'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">return</span> <span class="n">Task</span><span class="p">.</span><span class="n">Factory</span><span class="p">.</span><span class="n">StartNew</span><span class="p">(()</span> <span class="p">=&gt;</span></div><div class='line' id='LC75'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">{</span></div><div class='line' id='LC76'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">Parallel</span><span class="p">.</span><span class="n">For</span><span class="p">(</span><span class="m">0</span><span class="p">,</span> <span class="n">Size</span><span class="p">,</span> <span class="n">x</span> <span class="p">=&gt;</span></div><div class='line' id='LC77'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">{</span></div><div class='line' id='LC78'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">Parallel</span><span class="p">.</span><span class="n">For</span><span class="p">(</span><span class="m">0</span><span class="p">,</span> <span class="n">Size</span><span class="p">,</span> <span class="n">y</span> <span class="p">=&gt;</span></div><div class='line' id='LC79'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">{</span></div><div class='line' id='LC80'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kt">int</span> <span class="n">numberOfNeighbors</span> <span class="p">=</span> <span class="n">IsNeighborAlive</span><span class="p">(</span><span class="n">world</span><span class="p">,</span> <span class="n">Size</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">,</span> <span class="m">0</span><span class="p">)</span></div><div class='line' id='LC81'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">+</span> <span class="n">IsNeighborAlive</span><span class="p">(</span><span class="n">world</span><span class="p">,</span> <span class="n">Size</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">,</span> <span class="m">1</span><span class="p">)</span></div><div class='line' id='LC82'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">+</span> <span class="n">IsNeighborAlive</span><span class="p">(</span><span class="n">world</span><span class="p">,</span> <span class="n">Size</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">1</span><span class="p">)</span></div><div class='line' id='LC83'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">+</span> <span class="n">IsNeighborAlive</span><span class="p">(</span><span class="n">world</span><span class="p">,</span> <span class="n">Size</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span> <span class="m">1</span><span class="p">)</span></div><div class='line' id='LC84'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">+</span> <span class="n">IsNeighborAlive</span><span class="p">(</span><span class="n">world</span><span class="p">,</span> <span class="n">Size</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span> <span class="m">0</span><span class="p">)</span></div><div class='line' id='LC85'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">+</span> <span class="n">IsNeighborAlive</span><span class="p">(</span><span class="n">world</span><span class="p">,</span> <span class="n">Size</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">)</span></div><div class='line' id='LC86'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">+</span> <span class="n">IsNeighborAlive</span><span class="p">(</span><span class="n">world</span><span class="p">,</span> <span class="n">Size</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">)</span></div><div class='line' id='LC87'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">+</span> <span class="n">IsNeighborAlive</span><span class="p">(</span><span class="n">world</span><span class="p">,</span> <span class="n">Size</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span></div><div class='line' id='LC88'><br/></div><div class='line' id='LC89'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kt">bool</span> <span class="n">shouldLive</span> <span class="p">=</span> <span class="k">false</span><span class="p">;</span></div><div class='line' id='LC90'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kt">bool</span> <span class="n">isAlive</span> <span class="p">=</span> <span class="n">world</span><span class="p">[</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">];</span></div><div class='line' id='LC91'><br/></div><div class='line' id='LC92'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="n">isAlive</span> <span class="p">&amp;&amp;</span> <span class="p">(</span><span class="n">numberOfNeighbors</span> <span class="p">==</span> <span class="m">2</span> <span class="p">||</span> <span class="n">numberOfNeighbors</span> <span class="p">==</span> <span class="m">3</span><span class="p">))</span></div><div class='line' id='LC93'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">{</span></div><div class='line' id='LC94'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">shouldLive</span> <span class="p">=</span> <span class="k">true</span><span class="p">;</span></div><div class='line' id='LC95'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC96'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">else</span> <span class="nf">if</span> <span class="p">(!</span><span class="n">isAlive</span> <span class="p">&amp;&amp;</span> <span class="n">numberOfNeighbors</span> <span class="p">==</span> <span class="m">3</span><span class="p">)</span> <span class="c1">// zombification</span></div><div class='line' id='LC97'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">{</span></div><div class='line' id='LC98'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">shouldLive</span> <span class="p">=</span> <span class="k">true</span><span class="p">;</span></div><div class='line' id='LC99'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC100'><br/></div><div class='line' id='LC101'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">nextGeneration</span><span class="p">[</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">]</span> <span class="p">=</span> <span class="n">shouldLive</span><span class="p">;</span></div><div class='line' id='LC102'><br/></div><div class='line' id='LC103'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">});</span></div><div class='line' id='LC104'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">});</span></div><div class='line' id='LC105'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">});</span></div><div class='line' id='LC106'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC107'><br/></div><div class='line' id='LC108'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">private</span> <span class="k">static</span> <span class="kt">int</span> <span class="nf">IsNeighborAlive</span><span class="p">(</span><span class="kt">bool</span><span class="p">[,]</span> <span class="n">world</span><span class="p">,</span> <span class="kt">int</span> <span class="n">size</span><span class="p">,</span> <span class="kt">int</span> <span class="n">x</span><span class="p">,</span> <span class="kt">int</span> <span class="n">y</span><span class="p">,</span> <span class="kt">int</span> <span class="n">offsetx</span><span class="p">,</span> <span class="kt">int</span> <span class="n">offsety</span><span class="p">)</span></div><div class='line' id='LC109'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">{</span></div><div class='line' id='LC110'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kt">int</span> <span class="n">result</span> <span class="p">=</span> <span class="m">0</span><span class="p">;</span></div><div class='line' id='LC111'><br/></div><div class='line' id='LC112'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kt">int</span> <span class="n">proposedOffsetX</span> <span class="p">=</span> <span class="n">x</span> <span class="p">+</span> <span class="n">offsetx</span><span class="p">;</span></div><div class='line' id='LC113'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kt">int</span> <span class="n">proposedOffsetY</span> <span class="p">=</span> <span class="n">y</span> <span class="p">+</span> <span class="n">offsety</span><span class="p">;</span></div><div class='line' id='LC114'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kt">bool</span> <span class="n">outOfBounds</span> <span class="p">=</span> <span class="n">proposedOffsetX</span> <span class="p">&lt;</span> <span class="m">0</span> <span class="p">||</span> <span class="n">proposedOffsetX</span> <span class="p">&gt;=</span> <span class="n">size</span> <span class="p">|</span> <span class="n">proposedOffsetY</span> <span class="p">&lt;</span> <span class="m">0</span> <span class="p">||</span> <span class="n">proposedOffsetY</span> <span class="p">&gt;=</span> <span class="n">size</span><span class="p">;</span></div><div class='line' id='LC115'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(!</span><span class="n">outOfBounds</span><span class="p">)</span></div><div class='line' id='LC116'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">{</span></div><div class='line' id='LC117'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">result</span> <span class="p">=</span> <span class="n">world</span><span class="p">[</span><span class="n">x</span> <span class="p">+</span> <span class="n">offsetx</span><span class="p">,</span> <span class="n">y</span> <span class="p">+</span> <span class="n">offsety</span><span class="p">]</span> <span class="p">?</span> <span class="m">1</span> <span class="p">:</span> <span class="m">0</span><span class="p">;</span></div><div class='line' id='LC118'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC119'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">return</span> <span class="n">result</span><span class="p">;</span></div><div class='line' id='LC120'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC121'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC122'><br/></div><div class='line' id='LC123'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">class</span> <span class="nc">Program</span></div><div class='line' id='LC124'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">{</span></div><div class='line' id='LC125'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">static</span> <span class="k">void</span> <span class="nf">Main</span><span class="p">(</span><span class="kt">string</span><span class="p">[]</span> <span class="n">args</span><span class="p">)</span></div><div class='line' id='LC126'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">{</span></div><div class='line' id='LC127'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">LifeSimulation</span> <span class="n">sim</span> <span class="p">=</span> <span class="k">new</span> <span class="n">LifeSimulation</span><span class="p">(</span><span class="m">10</span><span class="p">);</span></div><div class='line' id='LC128'><br/></div><div class='line' id='LC129'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1">// initialize with a blinker</span></div><div class='line' id='LC130'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">sim</span><span class="p">.</span><span class="n">ToggleCell</span><span class="p">(</span><span class="m">5</span><span class="p">,</span> <span class="m">5</span><span class="p">);</span></div><div class='line' id='LC131'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">sim</span><span class="p">.</span><span class="n">ToggleCell</span><span class="p">(</span><span class="m">5</span><span class="p">,</span> <span class="m">6</span><span class="p">);</span></div><div class='line' id='LC132'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">sim</span><span class="p">.</span><span class="n">ToggleCell</span><span class="p">(</span><span class="m">5</span><span class="p">,</span> <span class="m">7</span><span class="p">);</span></div><div class='line' id='LC133'><br/></div><div class='line' id='LC134'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">sim</span><span class="p">.</span><span class="n">BeginGeneration</span><span class="p">();</span></div><div class='line' id='LC135'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">sim</span><span class="p">.</span><span class="n">Wait</span><span class="p">();</span></div><div class='line' id='LC136'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">OutputBoard</span><span class="p">(</span><span class="n">sim</span><span class="p">);</span></div><div class='line' id='LC137'><br/></div><div class='line' id='LC138'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">sim</span><span class="p">.</span><span class="n">Update</span><span class="p">();</span></div><div class='line' id='LC139'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">sim</span><span class="p">.</span><span class="n">Wait</span><span class="p">();</span></div><div class='line' id='LC140'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">OutputBoard</span><span class="p">(</span><span class="n">sim</span><span class="p">);</span></div><div class='line' id='LC141'><br/></div><div class='line' id='LC142'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">sim</span><span class="p">.</span><span class="n">Update</span><span class="p">();</span></div><div class='line' id='LC143'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">sim</span><span class="p">.</span><span class="n">Wait</span><span class="p">();</span></div><div class='line' id='LC144'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">OutputBoard</span><span class="p">(</span><span class="n">sim</span><span class="p">);</span></div><div class='line' id='LC145'><br/></div><div class='line' id='LC146'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">Console</span><span class="p">.</span><span class="n">ReadKey</span><span class="p">();</span></div><div class='line' id='LC147'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC148'><br/></div><div class='line' id='LC149'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">private</span> <span class="k">static</span> <span class="k">void</span> <span class="nf">OutputBoard</span><span class="p">(</span><span class="n">LifeSimulation</span> <span class="n">sim</span><span class="p">)</span></div><div class='line' id='LC150'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">{</span></div><div class='line' id='LC151'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kt">var</span> <span class="n">line</span> <span class="p">=</span> <span class="k">new</span> <span class="n">String</span><span class="p">(</span><span class="sc">&#39;-&#39;</span><span class="p">,</span> <span class="n">sim</span><span class="p">.</span><span class="n">Size</span><span class="p">);</span></div><div class='line' id='LC152'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">line</span><span class="p">);</span></div><div class='line' id='LC153'><br/></div><div class='line' id='LC154'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">for</span> <span class="p">(</span><span class="kt">int</span> <span class="n">y</span> <span class="p">=</span> <span class="m">0</span><span class="p">;</span> <span class="n">y</span> <span class="p">&lt;</span> <span class="n">sim</span><span class="p">.</span><span class="n">Size</span><span class="p">;</span> <span class="n">y</span><span class="p">++)</span></div><div class='line' id='LC155'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">{</span></div><div class='line' id='LC156'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">for</span> <span class="p">(</span><span class="kt">int</span> <span class="n">x</span> <span class="p">=</span> <span class="m">0</span><span class="p">;</span> <span class="n">x</span> <span class="p">&lt;</span> <span class="n">sim</span><span class="p">.</span><span class="n">Size</span><span class="p">;</span> <span class="n">x</span><span class="p">++)</span></div><div class='line' id='LC157'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">{</span></div><div class='line' id='LC158'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">Console</span><span class="p">.</span><span class="n">Write</span><span class="p">(</span><span class="n">sim</span><span class="p">[</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">]</span> <span class="p">?</span> <span class="s">&quot;1&quot;</span> <span class="p">:</span> <span class="s">&quot;0&quot;</span><span class="p">);</span></div><div class='line' id='LC159'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC160'><br/></div><div class='line' id='LC161'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">();</span></div><div class='line' id='LC162'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC163'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC164'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC165'><span class="p">}</span></div><div class='line' id='LC166'><span class="p">,</span> </div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/1194013/950541e727a52043c78df39706248705906195a6/GameOfLife.cs" style="float:right;">view raw</a>
            <a href="https://gist.github.com/1194013#file_game_of_life.cs" style="float:right;margin-right:10px;color:#666">GameOfLife.cs</a>
            <a href="https://gist.github.com/1194013">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>

<p>The included sample program that uses the &#8216;LifeSimulation&#8217; class initializes the a simple blinker, and then generates and outputs 3 generations.</p>
]]></content:encoded>
			<wfw:commentRss>http://codecube.net/2011/09/conways-game-of-life-in-c/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SequentialActionQueue in C#</title>
		<link>http://codecube.net/2011/07/sequentialactionqueue-in-c/</link>
		<comments>http://codecube.net/2011/07/sequentialactionqueue-in-c/#comments</comments>
		<pubDate>Fri, 15 Jul 2011 20:13:56 +0000</pubDate>
		<dc:creator>Joel Martinez</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://codecube.net/?p=488</guid>
		<description><![CDATA[A while ago, I created a clone on Google Code of the Stateless library because I wanted to use it in a .NET 4.0 project, and the current distribution was using VS 2008. After I did that, I started playing around with the library. Specifically, I wanted a way to have multiple state machines, and [...]]]></description>
			<content:encoded><![CDATA[<p>A while ago, I created a <a href="http://code.google.com/r/joelmartinez-stateless/">clone</a> on Google Code of the <a href="http://code.google.com/p/stateless/">Stateless library</a> because I wanted to use it in a .NET 4.0 project, and the current distribution was using VS 2008. After I did that, I started playing around with the library. Specifically, I wanted a way to have multiple state machines, and be able to process triggers and state changes in parallel. The problem of course is that although you can usually easily process state changes from different state machines in parallel, you can only process multiple triggers for a <strong>single</strong> state machine sequentially.</p>
<p>So I added a <em>ParallelExample</em> project to the solution and started experimenting. The end result is an easy to use class called <a href="http://code.google.com/r/joelmartinez-stateless/source/browse/Stateless/SequentialActionQueue.cs">SequentialActionQueue</a>. Usually when you need to synchronize access to a resource, you end up putting a lock section around your code so that only one thread may access it at a time. However things get more complex if you need to synchronize multiple sections of the code (ex. multiple methods in a class where only one may run at a time). This is classic thread-safety issues, and the dragons that lie in those waters. However, With the SequentialActionQueue, you can simply instantiate the class and proxy all actions through it and be guaranteed that everything will run safely one after the other.</p>
<blockquote>
<pre>private SequentialActionQueue queue = new SequentialActionQueue();
private int counter =0;

public void Add(int i)
{
    queue.Enqueue(() =&gt; counter += i);
}

public void Subtract(int i)
{
    queue.Enqueue(() =&gt; counter -= i);
}</pre>
</blockquote>
<p>The above is a simplified example which emulates the ability to use <a href="http://msdn.microsoft.com/en-us/library/system.threading.interlocked.aspx">Interlocked</a> to safely increment/decrement a number. I&#8217;d love to get some thoughts on the class &#8230; I wrote a few tests in the sample project, but that&#8217;s not to say there won&#8217;t be bugs in it, would love to hear your feedback <img src='http://codecube.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /><br />
&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://codecube.net/2011/07/sequentialactionqueue-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WebHelper for Desktop CLR</title>
		<link>http://codecube.net/2011/04/webhelper-for-desktop-clr/</link>
		<comments>http://codecube.net/2011/04/webhelper-for-desktop-clr/#comments</comments>
		<pubDate>Mon, 04 Apr 2011 16:53:31 +0000</pubDate>
		<dc:creator>Joel Martinez</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://codecube.net/?p=451</guid>
		<description><![CDATA[I recently posted a nice little helper class that I had been using on windows phone 7. This version works on the desktop CLR (there&#8217;s a minor difference in how you create a web request) &#8230; and also adds a new method that lets you get direct access to the response stream. So I figured [...]]]></description>
			<content:encoded><![CDATA[<p>I recently posted a nice little <a href="http://codecube.net/2010/09/windows-phone-7-webhelper/">helper class</a> that I had been using on windows phone 7. This version works on the desktop CLR (there&#8217;s a minor difference in how you create a web request) &#8230; and also adds a new method that lets you get direct access to the response stream. So I figured I&#8217;d post it as it is a generally useful class.</p>
<pre>public static class WebHelper
{
    public static WaitHandle Get(string url, Action&lt;WebResponse&gt; action)
    {
        return Get(new Uri(url), action);
    }

    public static WaitHandle Get(Uri uri, Action&lt;WebResponse&gt; action)
    {
        var request = WebRequest.CreateDefault(uri);
        ManualResetEvent handle = new ManualResetEvent(false);
        request.BeginGetResponse(i =&gt;
        {
            var response = request.EndGetResponse(i);
            action(response);
            handle.Set();
        }, null);

        return handle;
    }

    public static WaitHandle Get(string url, Action&lt;string&gt; action)
    {
        return Get(new Uri(url), action);
    }

    public static WaitHandle Get(Uri uri, Action&lt;string&gt; action)
    {
        return Get(uri, response =&gt;
        {
            var sreader = new StreamReader(response.GetResponseStream());
            var result = sreader.ReadToEnd();
            action(result);
        });
    }
}</pre>
<p>For some example usage, you can easily proxy a download through an ASP.NET MVC web app:</p>
<pre>        public ActionResult Get(string q)
        {
            Stream res = new MemoryStream();
            string contentType = "text/html";

            bool timedOut = !WebHelper
                .Get(q, html =&gt;
                    {
                        res = html.GetResponseStream();
                        contentType = html.ContentType;
                    })
                .WaitOne(30000); // wait 30 seconds to get a response

            if (timedOut)
            {
                StreamWriter writer = new StreamWriter(res);
                writer.WriteLine("The request timed out, sorry!");
                res.Seek(0, SeekOrigin.Begin);
            }

            return File(res, contentType);
        }</pre>
]]></content:encoded>
			<wfw:commentRss>http://codecube.net/2011/04/webhelper-for-desktop-clr/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Determining &#8220;place&#8221; Location by Averaging User Data</title>
		<link>http://codecube.net/2010/12/determining-place-location-by-averaging-user-data/</link>
		<comments>http://codecube.net/2010/12/determining-place-location-by-averaging-user-data/#comments</comments>
		<pubDate>Tue, 28 Dec 2010 17:00:06 +0000</pubDate>
		<dc:creator>Joel Martinez</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://codecube.net/?p=382</guid>
		<description><![CDATA[Location based services like foursquare, gowalla, and the recently minted &#8216;facebook places&#8217; let users check in from wherever they are at to inform their friends of their whereabouts. By this point, most places have already been defined in those services, so all you usually have to do is pick from a list of nearby locations. [...]]]></description>
			<content:encoded><![CDATA[<p>Location based services like foursquare, gowalla, and the recently minted &#8216;facebook places&#8217; let users check in from wherever they are at to inform their friends of their whereabouts. By this point, most places have already been defined in those services, so all you usually have to do is pick from a list of nearby locations. And if it&#8217;s not on the list, you can just define a new place.</p>
<p>Despite the social weight of these already existing services &#8230; there is still a lush breeding grounds for innovation in location services. If you were building such a service, let&#8217;s talk about the process of defining a &#8220;new place&#8221; as a user. What happens if the first user of your app to create a place is actually just around the corner, or if the place is large enough, on the east side rather than the west side. In a naively designed system, your place would be incorrectly defined from that point forward and would offer incorrect position data for the life of your service.</p>
<p>This post proposes a simple system that lets the place&#8217;s location in the world adjust itself over time. The more checkins you receive, the more accurate the location.</p>
<p>The concept is quite simple actually, by <a href="http://en.wikipedia.org/wiki/Centroid#Of_a_finite_set_of_points">computing the centroid</a> from all known checkins, you find the true &#8216;center&#8217; of you place. Doing this calculation could not be any simpler, centroid is just a fancy term for the average vector from a set (ie. Lat/Lon)</p>
<p><img class="alignnone" title="formula" src="http://upload.wikimedia.org/math/9/1/6/916178b5822b7f7ae920bad7e871d1db.png" alt="" width="199" height="39" /></p>
<p>I made a useful extension method that you can apply to a collection of vectors which can be invoked as such.</p>
<blockquote>
<pre>Vector2 centroid = locations.Centroid();

public static class VectorExtensions
{
    public static Vector2 Centroid(this List&lt;Vector2&gt; points)
    {
        int pointCount = points.Count;
        Vector2 total = Vector2.Zero;
        Vector2 centroid = Vector2.Zero;

        if (pointCount &gt; 0)
        {
            for (int i = 0; i &lt; pointCount; i++)
            {
                var point = points[i];
                total.X += point.X;
                total.Y += point.Y;
            }
            centroid = new Vector2(
                total.X / (float)pointCount,
                total.Y / (float)pointCount);
        }
        return centroid;
    }
}</pre>
</blockquote>
<p>So given a set of points, this would easily give you the logical center of them. Even if there&#8217;s a random checkin from outside the area, the average will not let the centroid vary by much.</p>
<p><img class="aligncenter size-full wp-image-387" title="centroid" src="http://codecube.net/wp-content/uploads/2010/08/centroid.png" alt="" width="374" height="240" /></p>
<p>But there is still an issue with this approach. How can this techique be applied to a real world system, you can&#8217;t expect me to keep a copy of every checkin ever done for a given location &#8230; I mean you can, but for most purposes it&#8217;s overkill.</p>
<p>Luckily, there is a way to reduce the problem domain to limit the amount of data needed to recalculate the centroid every time there is a new point to consider. By doing a weighted average, your data structure is greatly simplified because all you have to keep in the database for any given location is:</p>
<ul>
<li>latitude</li>
<li>longitude</li>
<li>numberOfCheckins</li>
</ul>
<p>With that, you can find your list of closest places to let the user see if their location is already in the db.</p>
<p>If the user selects an existing place to check in to, you can calc the centroid as follows:</p>
<blockquote>
<pre>public static Vector2 WeightedCentroid(
                                                this Vector2 newPoint,
                                                Vector2 oldCentroid,
                                                int numOfCheckins)
{
    return new Vector2(
        (oldCentroid.X * (float)numOfCheckins + newPoint.X) / ((float)numOfCheckins + 1),
        (oldCentroid.Y * (float)numOfCheckins + newPoint.Y) / ((float)numOfCheckins + 1)
        );
};</pre>
</blockquote>
<p>With that, you can save the value of the new average, along with the latest number of checkins. And that&#8217;s it!</p>
]]></content:encoded>
			<wfw:commentRss>http://codecube.net/2010/12/determining-place-location-by-averaging-user-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

