<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[Opgenorth.NET]]></title>
  <link href="http://www.opgenorth.net/atom.xml" rel="self"/>
  <link href="http://www.opgenorth.net/"/>
  <updated>2013-03-09T16:47:16-07:00</updated>
  <id>http://www.opgenorth.net/</id>
  <author>
    <name><![CDATA[Tom Opgenorth]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <entry>
    <title type="html"><![CDATA[Sublime Text 2 and Arduino]]></title>
    <link href="http://www.opgenorth.net/blog/2013/03/09/sublime-text-2-and-arduino/"/>
    <updated>2013-03-09T16:38:00-07:00</updated>
    <id>http://www.opgenorth.net/blog/2013/03/09/sublime-text-2-and-arduino</id>
    <content type="html"><![CDATA[<p>If you&#8217;re looking to get into Arduino, and you&#8217;re a programmer, the first thing that will jump out at you is the Arduino IDE. It&#8217;s best described as &#8220;spartan&#8221; (to say the least). As I&#8217;m used to full featured IDE&#8217;s I started looking for a replacement to the default Arduino IDE.</p>

<p>There are extensions to use Visual Studio, but that means me starting up a VM to run Windows which I don&#8217;t really want to do for Arduino development. There is a another IDE which looks promising called Maria Mole - but it&#8217;s Windows only so not really a contender for me.  I need something for OS X. I looked at setting up Eclipse as my default IDE, but ran into some issues with that. Nothing to major, but as I don&#8217;t like Eclipse in the first place I wasn&#8217;t to motivated to sort things out, so I abandoned Eclipse as an IDE choice.</p>

<p>The next thing I tried was <a href="http://www.sublimetext.com/">Sublime Text</a>. There is an Ardunio plugin called <a href="https://github.com/Robot-Will/Stino">Stino</a> that turns Sublime into a not bad IDE. In terms of writing your programs, Stino can pretty much do everything the Arduino IDE can do: compile programs, upload them to your Arduino board, import libraries, etc.</p>

<p><img src="https://raw.github.com/topgenorth/arduino/master/screenshots/sublime_menu_for_arduino.png" alt="image" /></p>

<p>Installing Stino isn&#8217;t that bad:</p>

<ol>
<li>First make sure that you have downloaded <a href="http://arduino.cc/en/Main/Software">Arduino 1.0.3</a>. I&#8217;m not to sure how well Stino will work with the current beta.</li>
<li>In Sublime Text, go to Package Control, and type <code>Install Package</code>.</li>
<li>Search using the keyword <code>Arduino</code>, you should see a couple of packages - one contains Stino and the other are a couple of snippets.</li>
<li>Next open a <code>.ino</code> file in Sublime Text. When you do this the <code>Arduino</code> menu should appear in the Sublime toolbard.</li>
<li>From the Arduino menu, specify the location of the Ardunio directory, i.e. <code>/Applications/Arduino.app</code>.</li>
</ol>


<p>Done!</p>

<p>To monitor the serial port, I&#8217;m using <a href="http://freeware.the-meiers.org/">CoolTerm</a>.  Seems to be &#8220;good enough&#8221; for what I want to do, and it&#8217;s free. On Windows, I&#8217;d probably use something like puTTY.</p>

<p>[1] Blog post for Stino: <a href="http://kaixin.netii.net/stino-a-sublime-text-2-plugin-for-arduino.html">http://kaixin.netii.net/stino-a-sublime-text-2-plugin-for-arduino.html</a></p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Writing GPS information to a JPEG]]></title>
    <link href="http://www.opgenorth.net/blog/2013/02/18/writing-gps-information-to-a-jpeg/"/>
    <updated>2013-02-18T18:32:00-07:00</updated>
    <id>http://www.opgenorth.net/blog/2013/02/18/writing-gps-information-to-a-jpeg</id>
    <content type="html"><![CDATA[<p>One of the handy things about the JPEG format is the ability to store meta-data inside the image using <a href="http://en.wikipedia.org/wiki/Exchangeable_image_file_format">EXIF</a>. There are a few libraries out there for the various programming languages that can help you out with this, and Android actually has something built in to the SDK - the class <a href="http://developer.android.com/reference/android/media/ExifInterface.html">ExifInterface</a>.</p>

<p>Google&#8217;s documentation on writing latitude and longitude to a JPEG are a bit light on details - they loosely hint at the format that latitude or longitude should have. (See the documentation for <a href="http://developer.android.com/reference/android/media/ExifInterface.html#TAG_GPS_LATITUDE">ExifInterface.TAG_GPS_LATITUDE</a>). The API itself is pretty straight forward, but what Google doesn&#8217;t tell you is HOW the GPS coordinates should encoded.</p>

<p>There are a few articles out there that explain the different ways latitude and longitude may be expressed. You might want to <a href="http://www.geomidpoint.com/latlon.html">quickly read</a> one of these articles to familiarize yourself with the different formats.</p>

<p>EXIF expects GPS coordinates to be encoded using geographical coordinates (degrees/minutes/seconds). There is <a href="http://en.wikipedia.org/wiki/Geographic_coordinate_conversion">Wikipedia article</a> that explains how to do the conversion and provides a Java sample. For the C# types in the crowd, here is an extension method that will convert a <code>double</code> to the DMS format that EXIF expects:</p>

<pre><code>public static class GpsHelpers
{
    public static string ToDMS(this double coord)
    {
        // gets the modulus the coordinate divided by one (MOD1).
        // in other words gets all the numbers after the decimal point.
        // e.g. mod = 87.728056 % 1 == 0.728056
        //
        // next get the integer part of the coord. On other words the whole number part.
        // e.g. intPart = 87
        var mod = coord % 1;
        var intPart = (int)coord;

        //set degrees to the value of intPart
        //e.g. degrees = "87"
        var degrees = intPart.ToString();

        // next time the MOD1 of degrees by 60 so we can find the integer part for minutes.
        // get the MOD1 of the new coord to find the numbers after the decimal point
        // e.g. coord = 0.728056 * 60 == 43.68336
        //      mod = 43.68336 % 1 == 0.68336
        //
        // next get the value of the integer part of the coord.
        // e.g. intPart = 43
        coord = mod * 60;
        mod = coord % 1;
        intPart = (int)coord;

        // set minutes to the value of intPart
        // e.g. minutes = "43"
        var minutes = intPart.ToString();

        //do the same again for minutes
        //e.g. coord = 0.68336 * 60 == 41.0016
        //e.g. intPart = 41
        coord = mod * 60;
        intPart = (int)coord;

        // set seconds to the value of intPart.
        // e.g. seconds = "41"
        var seconds = intPart.ToString();
        var output = String.Format("{0}/1,{1}/1,{2}/1", degrees, minutes, seconds);

        return output;
    }
}
</code></pre>

<p>This next C# code snippet will show you how to use ExifInterface to write/update the GPS information to your JPG:</p>

<pre><code>var exif = new ExifInterface("path to file");
exif.SetAttribute(ExifInterface.TagGpsProcessingMethod, "GPS");

// the variable latitude is a double that has been initialized elsewhere.
exif.SetAttribute(ExifInterface.TagGpsLatitude, latitude.ToDMS());
exif.SetAttribute(ExifInterface.TagGpsLatitudeRef, latitude &gt; 0 ? "N" : "S");

// The variable longitude is a double that has been initialized elsewhere.
exif.SetAttribute(ExifInterface.TagGpsLongitude, graffiti.Longitude.ToDMS());
exif.SetAttribute(ExifInterface.TagGpsLongitudeRef, graffiti.Longitude &gt; 0 ? "E" : "W");
</code></pre>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[rake your Mono for Android Application]]></title>
    <link href="http://www.opgenorth.net/blog/2013/02/04/rake-your-mono-for-android-application/"/>
    <updated>2013-02-04T16:14:00-07:00</updated>
    <id>http://www.opgenorth.net/blog/2013/02/04/rake-your-mono-for-android-application</id>
    <content type="html"><![CDATA[<p>Deploy early, deploy often is a popular goal in Agile methodologies. One easy way to support this to automate your build process. Last year at this time I would just use <a href="http://www.finalbuilder.com/finalbuilder.aspx">FinalBuilder</a> to automate the builds of my Mono for Android pet projects. It doesn&#8217;t take much to set FinalBuilder, and it does provide support for a lot of tasks such as versioning .NET assemblies, manipulating XML, dealing with the file system, and so on.</p>

<p>The problem is that FinalBuilder is Windows only. OS X and Linux types are left out in the cold. As I find myself working almost exclusive in OS X when developing my Mono for Android applications, I was looking for a Windows free way to automate my builds.</p>

<p>Enter <a href="http://rake.rubyforge.org/">rake</a> and <a href="http://albacorebuild.net/">albacore</a>. rake is, of course the build system for Ruby. Albacore is a suite of rake tasks for building .NET applications. With a trivial amount of effort, I managed to setup a command line build of my Mono for Android projects (which would also sign and zip align the APK file).</p>

<p>Assuming that you have ruby installed, you just need to install rake and albacore:</p>

<pre><code>gem install rake
gem install albacore
</code></pre>

<p>That&#8217;s pretty much it. Create your Rakefile and <code>require 'albacore'</code> and you now have access to a whole bunch of rake tasks to help you with building your Mono for Android app.</p>

<p>Right now my Rakefile is pretty barebones - I don&#8217;t auto-increment the build number and I don&#8217;t create any tags in git to track each build. Also, right now my Rakefile will pause partway through in order to collect the password for my keystore file as well. This is fine for me right now as I do all this at the command line by it would be a bit of a drag if I was using a headless CI server.</p>

<p>For references sake, here is the Rakefile I currently use:</p>

<figure class='code'><figcaption><span>Rakefile.rb</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
<span class='line-number'>31</span>
<span class='line-number'>32</span>
<span class='line-number'>33</span>
<span class='line-number'>34</span>
<span class='line-number'>35</span>
<span class='line-number'>36</span>
<span class='line-number'>37</span>
<span class='line-number'>38</span>
<span class='line-number'>39</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="nb">require</span> <span class="s1">&#39;albacore&#39;</span>
</span><span class='line'>
</span><span class='line'><span class="vi">@file_version</span> <span class="o">=</span> <span class="s2">&quot;2.3.0.0&quot;</span>
</span><span class='line'>
</span><span class='line'><span class="vi">@keystore</span>     <span class="o">=</span> <span class="s2">&quot;&lt;PATH TO MY KEYSTORE FILE&gt;&quot;</span>
</span><span class='line'><span class="vi">@alias_name</span>   <span class="o">=</span> <span class="s2">&quot;&lt;ALIAS TO THE KEY I WANT TO SIGN WITH&gt;&quot;</span>
</span><span class='line'><span class="vi">@input_apk</span>    <span class="o">=</span> <span class="s2">&quot;ReportGraffiti.Android/bin/Release/net.opgenorth.reportgraffiti.apk&quot;</span>
</span><span class='line'><span class="vi">@signed_apk</span>   <span class="o">=</span> <span class="s2">&quot;ReportGraffiti.Android/bin/Release/net.opgenorth.reportgraffiti_signed_notaligned.apk&quot;</span>
</span><span class='line'><span class="vi">@final_apk</span>    <span class="o">=</span> <span class="s2">&quot;ReportGraffiti.Android/reportgraffiti.apk&quot;</span>
</span><span class='line'>
</span><span class='line'><span class="n">task</span> <span class="ss">:default</span> <span class="o">=&gt;</span> <span class="o">[</span><span class="ss">:clean</span><span class="p">,</span> <span class="ss">:versioning</span><span class="p">,</span> <span class="ss">:build</span><span class="p">,</span> <span class="ss">:sign</span><span class="o">]</span>
</span><span class='line'>
</span><span class='line'><span class="n">desc</span> <span class="s2">&quot;Remove the bin and obj directories.&quot;</span>
</span><span class='line'><span class="n">task</span> <span class="ss">:clean</span> <span class="k">do</span>
</span><span class='line'>  <span class="n">rm_rf</span> <span class="s2">&quot;ReportGraffiti.Android/bin&quot;</span>
</span><span class='line'>  <span class="n">rm_rf</span> <span class="s2">&quot;ReportGraffiti.Android/obj&quot;</span>
</span><span class='line'><span class="k">end</span>
</span><span class='line'>
</span><span class='line'><span class="n">desc</span> <span class="s2">&quot;Update the build number before compiling.&quot;</span>
</span><span class='line'><span class="n">assemblyinfo</span> <span class="ss">:versioning</span> <span class="k">do</span> <span class="o">|</span><span class="n">asm</span><span class="o">|</span>
</span><span class='line'>  <span class="n">asm</span><span class="o">.</span><span class="n">input_file</span>  <span class="o">=</span> <span class="s2">&quot;ReportGraffiti.Android/Properties/AssemblyInfo.cs&quot;</span>
</span><span class='line'>  <span class="n">asm</span><span class="o">.</span><span class="n">output_file</span> <span class="o">=</span> <span class="s2">&quot;ReportGraffiti.Android/Properties/AssemblyInfo.cs&quot;</span>
</span><span class='line'>  <span class="n">asm</span><span class="o">.</span><span class="n">version</span> <span class="o">=</span> <span class="vi">@file_version</span>
</span><span class='line'>  <span class="n">asm</span><span class="o">.</span><span class="n">file_version</span> <span class="o">=</span> <span class="vi">@_file_version</span>
</span><span class='line'><span class="k">end</span>
</span><span class='line'>
</span><span class='line'><span class="n">desc</span> <span class="s2">&quot;Compiles the project&quot;</span>
</span><span class='line'><span class="n">xbuild</span> <span class="ss">:build</span> <span class="k">do</span> <span class="o">|</span><span class="n">msb</span><span class="o">|</span>
</span><span class='line'>  <span class="n">msb</span><span class="o">.</span><span class="n">solution</span> <span class="o">=</span> <span class="s2">&quot;ReportGraffiti.Android/ReportGraffiti.Android.csproj&quot;</span>
</span><span class='line'>  <span class="n">msb</span><span class="o">.</span><span class="n">properties</span> <span class="o">=</span> <span class="p">{</span> <span class="ss">:configuration</span> <span class="o">=&gt;</span> <span class="ss">:release</span> <span class="p">}</span>
</span><span class='line'>  <span class="n">msb</span><span class="o">.</span><span class="n">targets</span> <span class="o">[</span> <span class="ss">:Clean</span><span class="p">,</span> <span class="ss">:Build</span><span class="p">,</span> <span class="ss">:SignAndroidPackage</span> <span class="o">]</span>
</span><span class='line'><span class="k">end</span>
</span><span class='line'>
</span><span class='line'><span class="n">desc</span> <span class="s2">&quot;Signs and zip aligns the APK.&quot;</span>
</span><span class='line'><span class="n">task</span> <span class="ss">:sign</span> <span class="k">do</span>
</span><span class='line'>  
</span><span class='line'>  <span class="n">sh</span> <span class="s2">&quot;jarsigner&quot;</span><span class="p">,</span>  <span class="s2">&quot;-verbose&quot;</span><span class="p">,</span> <span class="s2">&quot;-sigalg&quot;</span><span class="p">,</span> <span class="s2">&quot;MD5withRSA&quot;</span><span class="p">,</span> <span class="s2">&quot;-digestalg&quot;</span><span class="p">,</span> <span class="s2">&quot;SHA1&quot;</span><span class="p">,</span> <span class="s2">&quot;-keystore&quot;</span><span class="p">,</span>  <span class="vi">@keystore</span><span class="p">,</span> <span class="s2">&quot;-signedjar&quot;</span><span class="p">,</span> <span class="vi">@signed_apk</span><span class="p">,</span> <span class="vi">@input_apk</span><span class="p">,</span> <span class="vi">@alias_name</span>
</span><span class='line'>  <span class="n">sh</span> <span class="s2">&quot;zipalign&quot;</span><span class="p">,</span> <span class="s2">&quot;-f&quot;</span><span class="p">,</span> <span class="s2">&quot;-v&quot;</span><span class="p">,</span> <span class="s2">&quot;4&quot;</span><span class="p">,</span> <span class="vi">@signed_apk</span><span class="p">,</span> <span class="vi">@final_apk</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>


<p>Notice as well that I use the <a href="https://github.com/Albacore/albacore/wiki/XBuild-Task">xbuild</a> task from albacore. The  documentation says that this task will be merged into the <a href="https://github.com/Albacore/albacore/wiki/MSBuild-Task">MsBuild</a> task, but until then I guess one is supposed to keep using xbuild.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Windows 8 64-bit and Android Debug Bridge (Where is my Galaxy Nexus?)]]></title>
    <link href="http://www.opgenorth.net/blog/2012/09/25/windows-8-64-bit-and-android-debug-bridge-where-is-my-galaxy-nexus/"/>
    <updated>2012-09-25T20:05:00-06:00</updated>
    <id>http://www.opgenorth.net/blog/2012/09/25/windows-8-64-bit-and-android-debug-bridge-where-is-my-galaxy-nexus</id>
    <content type="html"><![CDATA[<p>Setting up a new VM for development - this one based on Windows 8 64 bit. Not that I really want to, but it seems that I need to for work (yes, yes, first world problems). So the usual fun with standing up a new VM:</p>

<ul>
<li>Install OS</li>
<li>Download Chrome and Firefox and ditch IE</li>
<li>Download Resharper</li>
<li>Remember that you need Visual Studio for Resharper so install that.</li>
<li>Install Java SDK</li>
<li>Install Android SDK</li>
<li>Install Intellij and Eclipse</li>
<li>etc.</li>
</ul>


<p>Of course, then I notice that my phone, a Galaxy Nexus, isn&#8217;t being recognized by Android Debug Bridge.  This is a problem as I much prefer to develop using a device as opposed slow emulator that Google ships for Android, and you can&#8217;t deploy to the device without ADB.</p>

<p>The answer to the problem can be found over on this thread at <a href="http://forum.xda-developers.com/showthread.php?t=1583801">XDA-Developers</a>.  Here&#8217;s the short version:</p>

<ol>
<li>Download the <a href="http://www.mediafire.com/download.php?2tunwdxr3q2q8ec">USB drivers</a>.</li>
<li>Reboot the computer. This isn&#8217;t your usually reboot. You&#8217;ll need to <a href="http://www.tips-trick.com/use-access-windows-8-boot-loader-advanced-boot-options/">access the Windows 8 Boot Loader and Advanced Boot Options</a>. Basically, go to a command prompt and reboot using <code>shutdown.exe /r /o</code>. You;ll want to change the driver signing settings to allow unsigned or unverified driver installation.</li>
<li>Once you allow unsigned/unverified drivers to be installed, you can reboot into Windows 8 and connect your Galaxy Nexus.</li>
<li>Run <code>devmgmt.msc</code>. You&#8217;ll see that your Galaxy Nexus has the yellow triangle over it.  Install the drivers you download in step #1 (it&#8217;s a self extracting EXE).</li>
</ol>


<p>Viola! Now your Galaxy Nexus will be recognized by ADB.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Updating Octopress]]></title>
    <link href="http://www.opgenorth.net/blog/2012/09/08/updating-octopress/"/>
    <updated>2012-09-08T11:39:00-06:00</updated>
    <id>http://www.opgenorth.net/blog/2012/09/08/updating-octopress</id>
    <content type="html"><![CDATA[<p>Just did a quick update from <a href="http://www.octopress.org">Octopress</a>. This is mostly just a test post to make sure that things are working okay. We now return you to your regularily scheduled emptiness.</p>

<p>Have a nice day.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[PreferenceFragment.getPreferencesFromIntent]]></title>
    <link href="http://www.opgenorth.net/blog/2012/05/09/preferencefragment-getpreferencesfromintent/"/>
    <updated>2012-05-09T15:37:00-06:00</updated>
    <id>http://www.opgenorth.net/blog/2012/05/09/preferencefragment-getpreferencesfromintent</id>
    <content type="html"><![CDATA[<p>One of the new classes that Honeycomb introduced was the <a href="http://developer.android.com/reference/android/preference/PreferenceFragment.html">PreferenceFragment</a>. This class is meant to simplify the creatation of a setting / preferences screen in Android applications. It handles a lot of the displaying, saving, and changing of an application&#8217;s settings. There are a couple of ways to create a <code>PreferenceFragment</code>. The simplest way is to subclass, override <code>onCreate()</code> and then use either <code>getPreferencesFromResource</code> or <code>getPreferencesFromIntent</code>.</p>

<p>There are many examples on how to use <code>getPreferencesFromResource</code>, but I noticed that there aren&#8217;t that many on how to use <code>getPreferencesFromIntent</code>. Here is one such quick example.</p>

<p>The first thing to do is to create your <code>PreferenceFragment</code> and provide it with an Intent that identifies an Activity. This Activity will have some meta-data associated with it that the <code>PreferenceFragment</code> will use to create it&#8217;s layout (more on this later)</p>

<figure class='code'><figcaption><span>[MyPreferenceFragment.java] </span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
</pre></td><td class='code'><pre><code class='Java'><span class='line'><span class="kd">public</span> <span class="kd">class</span> <span class="nc">MyPreferenceFragment</span> <span class="kd">extends</span> <span class="n">PreferenceFragment</span>  <span class="o">{</span>
</span><span class='line'>    <span class="nd">@Override</span>
</span><span class='line'>    <span class="kd">public</span> <span class="kt">void</span> <span class="nf">onCreate</span><span class="o">(</span><span class="n">Bundle</span> <span class="n">savedInstanceState</span><span class="o">)</span> <span class="o">{</span>
</span><span class='line'>        <span class="kd">super</span><span class="o">.</span><span class="na">onCreate</span><span class="o">(</span><span class="n">savedInstanceState</span><span class="o">);</span>
</span><span class='line'>        <span class="n">Intent</span> <span class="n">intent</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Intent</span><span class="o">(</span><span class="n">getActivity</span><span class="o">(),</span> <span class="n">MyActivityWithPreferences</span><span class="o">.</span><span class="na">class</span> <span class="o">);</span>
</span><span class='line'>        <span class="n">addPreferencesFromIntent</span><span class="o">(</span><span class="n">intent</span><span class="o">);</span>
</span><span class='line'>    <span class="o">}</span>
</span><span class='line'><span class="o">}</span>
</span></code></pre></td></tr></table></div></figure>


<p>The next step is to create the Activity <code>MyActivityWithPreferences</code> (if you don&#8217;t already have it). The code inside the Activity doesn&#8217;t matter so much - what is important is how the Activity is declared in <code>AndroidManifest.xml</code>.  I provide <code>AndroidManifest.xml</code> here:</p>

<figure class='code'><figcaption><span>[AndroidManifest.xml]</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
</pre></td><td class='code'><pre><code class='xml'><span class='line'><span class="cp">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;</span>
</span><span class='line'><span class="nt">&lt;manifest</span> <span class="na">xmlns:android=</span><span class="s">&quot;http://schemas.android.com/apk/res/android&quot;</span>
</span><span class='line'>          <span class="na">package=</span><span class="s">&quot;com.example&quot;</span>
</span><span class='line'>          <span class="na">android:versionCode=</span><span class="s">&quot;1&quot;</span>
</span><span class='line'>          <span class="na">android:versionName=</span><span class="s">&quot;1.0&quot;</span><span class="nt">&gt;</span>
</span><span class='line'>    <span class="nt">&lt;uses-sdk</span> <span class="na">android:minSdkVersion=</span><span class="s">&quot;15&quot;</span><span class="nt">/&gt;</span>
</span><span class='line'>    <span class="nt">&lt;application</span> <span class="na">android:label=</span><span class="s">&quot;@string/app_name&quot;</span> <span class="na">android:icon=</span><span class="s">&quot;@drawable/ic_launcher&quot;</span><span class="nt">&gt;</span>
</span><span class='line'>        <span class="nt">&lt;activity</span> <span class="na">android:name=</span><span class="s">&quot;MyActivity&quot;</span>
</span><span class='line'>                  <span class="na">android:label=</span><span class="s">&quot;@string/app_name&quot;</span><span class="nt">&gt;</span>
</span><span class='line'>            <span class="nt">&lt;intent-filter&gt;</span>
</span><span class='line'>                <span class="nt">&lt;action</span> <span class="na">android:name=</span><span class="s">&quot;android.intent.action.MAIN&quot;</span><span class="nt">/&gt;</span>
</span><span class='line'>                <span class="nt">&lt;category</span> <span class="na">android:name=</span><span class="s">&quot;android.intent.category.LAUNCHER&quot;</span><span class="nt">/&gt;</span>
</span><span class='line'>            <span class="nt">&lt;/intent-filter&gt;</span>
</span><span class='line'>        <span class="nt">&lt;/activity&gt;</span>
</span><span class='line'>        <span class="nt">&lt;activity</span> <span class="na">android:name=</span><span class="s">&quot;.MyActivityWithPreferences&quot;</span><span class="nt">&gt;</span>
</span><span class='line'>            <span class="nt">&lt;meta-data</span> <span class="na">android:name=</span><span class="s">&quot;android.preference&quot;</span> <span class="na">android:resource=</span><span class="s">&quot;@xml/preference_from_intent&quot;</span><span class="nt">/&gt;</span>
</span><span class='line'>        <span class="nt">&lt;/activity&gt;</span>
</span><span class='line'>    <span class="nt">&lt;/application&gt;</span>
</span><span class='line'><span class="nt">&lt;/manifest&gt;</span>
</span></code></pre></td></tr></table></div></figure>


<p>Notice on line 16 the <code>meta-data</code> element that was added as a child of the <code>activity</code> element. <code>PreferenceFragment</code> will use the resource file <code>res/xml/preference_from_intent.xml</code> and inflate a preference heirarchy using that XML file. Here is an example one such XML file:</p>

<figure class='code'><figcaption><span>[res/xml/preference_from_intent.xml] </span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
<span class='line-number'>31</span>
<span class='line-number'>32</span>
<span class='line-number'>33</span>
<span class='line-number'>34</span>
<span class='line-number'>35</span>
<span class='line-number'>36</span>
<span class='line-number'>37</span>
<span class='line-number'>38</span>
<span class='line-number'>39</span>
<span class='line-number'>40</span>
<span class='line-number'>41</span>
<span class='line-number'>42</span>
<span class='line-number'>43</span>
</pre></td><td class='code'><pre><code class='xml'><span class='line'><span class="cp">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;</span>
</span><span class='line'>
</span><span class='line'><span class="nt">&lt;PreferenceScreen</span> <span class="na">xmlns:android=</span><span class="s">&quot;http://schemas.android.com/apk/res/android&quot;</span><span class="nt">&gt;</span>
</span><span class='line'>
</span><span class='line'>  <span class="nt">&lt;PreferenceCategory</span> <span class="na">android:title=</span><span class="s">&quot;Inline Preferences&quot;</span><span class="nt">&gt;</span>
</span><span class='line'>    <span class="nt">&lt;CheckBoxPreference</span> <span class="na">android:key=</span><span class="s">&quot;checkbox_preference&quot;</span>
</span><span class='line'>                        <span class="na">android:title=</span><span class="s">&quot;Checkbox Preference Title&quot;</span>
</span><span class='line'>                        <span class="na">android:summary=</span><span class="s">&quot;Checkbox Preference Summary&quot;</span> <span class="nt">/&gt;</span>
</span><span class='line'>
</span><span class='line'>  <span class="nt">&lt;/PreferenceCategory&gt;</span>
</span><span class='line'>
</span><span class='line'>  <span class="nt">&lt;PreferenceCategory</span> <span class="na">android:title=</span><span class="s">&quot;Dialog Based Preferences&quot;</span><span class="nt">&gt;</span>
</span><span class='line'>
</span><span class='line'>    <span class="nt">&lt;EditTextPreference</span> <span class="na">android:key=</span><span class="s">&quot;edittext_preference&quot;</span>
</span><span class='line'>                        <span class="na">android:title=</span><span class="s">&quot;EditText Preference Title&quot;</span>
</span><span class='line'>                        <span class="na">android:summary=</span><span class="s">&quot;EditText Preference Summary&quot;</span>
</span><span class='line'>                        <span class="na">android:dialogTitle=</span><span class="s">&quot;Edit Text Preferrence Dialog Title&quot;</span> <span class="nt">/&gt;</span>
</span><span class='line'>
</span><span class='line'>  <span class="nt">&lt;/PreferenceCategory&gt;</span>
</span><span class='line'>
</span><span class='line'>  <span class="nt">&lt;PreferenceCategory</span> <span class="na">android:title=</span><span class="s">&quot;Launch Preferences&quot;</span><span class="nt">&gt;</span>
</span><span class='line'>
</span><span class='line'>    <span class="nt">&lt;PreferenceScreen</span> <span class="na">android:key=</span><span class="s">&quot;screen_preference&quot;</span>
</span><span class='line'>                      <span class="na">android:title=</span><span class="s">&quot;Title Screen Preferences&quot;</span>
</span><span class='line'>                      <span class="na">android:summary=</span><span class="s">&quot;Summary Screen Preferences&quot;</span><span class="nt">&gt;</span>
</span><span class='line'>
</span><span class='line'>      <span class="nt">&lt;CheckBoxPreference</span> <span class="na">android:key=</span><span class="s">&quot;next_screen_checkbox_preference&quot;</span>
</span><span class='line'>                          <span class="na">android:title=</span><span class="s">&quot;Next Screen Toggle Preference Title&quot;</span>
</span><span class='line'>                          <span class="na">android:summary=</span><span class="s">&quot;Next Screen Toggle Preference Summary&quot;</span> <span class="nt">/&gt;</span>
</span><span class='line'>
</span><span class='line'>    <span class="nt">&lt;/PreferenceScreen&gt;</span>
</span><span class='line'>
</span><span class='line'>    <span class="nt">&lt;PreferenceScreen</span> <span class="na">android:title=</span><span class="s">&quot;Intent Preference Title&quot;</span>
</span><span class='line'>                      <span class="na">android:summary=</span><span class="s">&quot;Intent Preference Summary&quot;</span><span class="nt">&gt;</span>
</span><span class='line'>
</span><span class='line'>      <span class="nt">&lt;intent</span> <span class="na">android:action=</span><span class="s">&quot;android.intent.action.VIEW&quot;</span>
</span><span class='line'>              <span class="na">android:data=</span><span class="s">&quot;http://www.android.com&quot;</span> <span class="nt">/&gt;</span>
</span><span class='line'>
</span><span class='line'>    <span class="nt">&lt;/PreferenceScreen&gt;</span>
</span><span class='line'>
</span><span class='line'>  <span class="nt">&lt;/PreferenceCategory&gt;</span>
</span><span class='line'>
</span><span class='line'><span class="nt">&lt;/PreferenceScreen&gt;</span>
</span></code></pre></td></tr></table></div></figure>



]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Galaxy Nexus - an Update]]></title>
    <link href="http://www.opgenorth.net/blog/2012/05/06/galaxy-nexus-an-update/"/>
    <updated>2012-05-06T16:25:00-06:00</updated>
    <id>http://www.opgenorth.net/blog/2012/05/06/galaxy-nexus-an-update</id>
    <content type="html"><![CDATA[<p>In my last post I flashed a new firmware for the radio on my Galaxy Nexus. I notice that, after a day or so, my problems with connection to Wind Mobile returned. My phone would just not register on Wind&#8217;s network, regardless of where I was.</p>

<p>Once again I did a bit of search, and read something peculiar (I wish I had booked marked it for reference sake). Some people were claiming that by setting the minimum clock speed of their Galaxy Nexus to 700MHz, that their radio problems had disappeared.</p>

<p>I will say that by setting the minimum clock speed of my Galaxy Nexus to 700MHz I have had zero problems with connecting and staying on Wind Mobile&#8217;s network (it&#8217;s been a couple of days now).</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Galaxy Nexus - Why don't you stay connected?]]></title>
    <link href="http://www.opgenorth.net/blog/2012/05/02/galaxy-nexus/"/>
    <updated>2012-05-02T10:34:00-06:00</updated>
    <id>http://www.opgenorth.net/blog/2012/05/02/galaxy-nexus</id>
    <content type="html"><![CDATA[<p>I recently got a Galaxy Nexus, and like a typical geek I <a href="http://androidforums.com/international-galaxy-nexus-all-things-root/452146-how-root-gsm-hspa-samsung-galaxy-nexus.html">unlocked the bootloader and then rooted it</a>. Life was good running Android 4.0.1. Well sort of. I had problems tethering my MacBook Pro via the WiFi hotspot, but no problems using Bluetooth. So nothing I couldn&#8217;t work around.</p>

<p>Then I received an OTA update to Android 4.0.4 recently.  And this was when things started going not so good - specifically, for some blasted reason, I kept losing connectivity to Wind Mobile&#8217;s network. At first I thought it was Wind Mobile having issues. This would be odd, because for me, Wind Mobile has been pretty solid. To troubleshoot I pulled my SIM card and dropped it into my Nexus One. Everything worked fine. So apparently something with my phone.</p>

<p>None of the simple tricks worked:</p>

<ul>
<li>pull the battery for 45 seconds</li>
<li>verify the APN settings</li>
<li>pull and re insert the SIM card.</li>
</ul>


<p>I&#8217;d had good luck with <a href="http://www.cyanogenmod.com">CyanogenMod</a> in the past, so I figured that maybe by installing that my problems would go away. No such luck.</p>

<p>After a bit of searching, the nearest thing I could figure out is that the radio firmware I received with Android 4.0.4 (XXLA2) was troublesome - it seems that there are reports of people having issues with it going back to March or so. One suggestion that I followed through on was flashing a new firmware for the radios.</p>

<p>To make a long story short I went over to the <a href="http://forum.xda-developers.com/showthread.php?t=1405345">Galaxy Nexus I9250 Baseband dumps collection</a> page at <a href="http://forum.xda-developers.com/index.php">XDA-developers</a>, and update my radio to UGKL1. Now things to work just fine. If I understand things correctly, this radio has better support for the 850/1900/AWS frequencies that Wind Mobile uses.</p>

<p>Hopefully in the near future I&#8217;ll remember to do another blog post on what I did. The information is out there, but it is a bit scattered.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Migrating to Octopress]]></title>
    <link href="http://www.opgenorth.net/blog/2012/04/30/migrating-to-octopress/"/>
    <updated>2012-04-30T19:06:00-06:00</updated>
    <id>http://www.opgenorth.net/blog/2012/04/30/migrating-to-octopress</id>
    <content type="html"><![CDATA[<p>Seems that there is a bit of a mess-up / problem / issue with the company that was hosting my blog. So, finally took the plunge and decided to migrate from Wordpress to Octopress.  I must say that the whole process was pretty painless. The whole process took about an hour and I was setup on heroku.com. Now I guess I get to play with Octpress.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Using AutoCompleteTextView and SimpleCursorAdapter]]></title>
    <link href="http://www.opgenorth.net/blog/2011/09/06/using-autocompletetextview-and-simplecursoradapter-2/"/>
    <updated>2011-09-06T00:00:00-06:00</updated>
    <id>http://www.opgenorth.net/blog/2011/09/06/using-autocompletetextview-and-simplecursoradapter-2</id>
    <content type="html"><![CDATA[<p>I have a simple little pet project (for Android), and one of the things I wanted to do was to to have a text field that would show me previous values as I typed in the text box (see screenshot below). Of course, this control is already a part of the Android SDK - it&#8217;s our good friend the <a href="http://developer.android.com/reference/android/widget/AutoCompleteTextView.html">AutoCompleteTextView</a>. </p><p><img src="http://www.opgenorth.net/wp-content/uploads/2011/09/AutoCompleteTextView.png" /></p><p>To populate the drop-down, I have an SQLite table called vehicle_descriptions, which looks something like the screenshot below. What I want is for a given vehicle (a value derived from another control on my Activity) to show me the value of the description column in the table.</p><p><img src="http://www.opgenorth.net/wp-content/uploads/2011/09/vehicle_descriptions_table.png" /></p><p>At first I started out by sub-classing <a href="http://developer.android.com/reference/android/widget/CursorAdapter.html">CursorAdapter</a>, but that just seemed to be a bit to heavy. What I had worked, but it seemed like there should be a simpler way to do this. <a href="http://developer.android.com/reference/android/widget/CursorAdapter.html">CursorAdapter</a> is probably a better choice for more elaborate requirements (maybe displaying images or doing some calculations), but in this case it struck me as overkill - I just wanted to do a simple lookup against a table. Turns out I was right - the easy way is to just use a <a href="http://developer.android.com/reference/android/widget/SimpleCursorAdapter.html">SimpleCursorAdapter</a>.</p><pre>
    &lt;AutoCompleteTextView android:id=&quot;@+id/description&quot;
                          android:completionThreshold=&quot;1&quot;
                          android:layout_height=&quot;wrap_content&quot;
                          android:layout_width=&quot;fill_parent&quot;
                          android:hint=&quot;Trip Description (optional)&quot;
                          android:lines=&quot;1&quot; /&gt;
</pre><p>To setup my control, I have created a function that I call inside onCreate() of my Activity. Here is the code, and then I will explain it in more detail:</p><pre>    
    private void initializeDescription() {
        _descriptionText = (AutoCompleteTextView) findViewById(R.id.description);
        final int[] to = new int[]{android.R.id.text1};
        final String[] from = new String[]{VehicleDescriptionsTable.DESCRIPTION};
        SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
                android.R.layout.simple_dropdown_item_1line,
                null,
                from,
                to);

        // This will provide the labels for the choices to be displayed in the AutoCompleteTextView
        adapter.setCursorToStringConverter(new SimpleCursorAdapter.CursorToStringConverter() {
            @Override
            public CharSequence convertToString(Cursor cursor) {
                final int colIndex = cursor.getColumnIndexOrThrow(VehicleDescriptionsTable.DESCRIPTION);
                return cursor.getString(colIndex);
            }
        });

        // This will run a query to find the descriptions for a given vehicle.
        adapter.setFilterQueryProvider(new FilterQueryProvider() {
            @Override
            public Cursor runQuery(CharSequence description) {
                String vehicle = getSelectedVehicle();
                Cursor managedCursor = _helper.getDescriptionsFor(vehicle, description.toString());
                Log.d(TAG, "Query has " + managedCursor.getCount() + " rows of description for " + vehicle);
                return managedCursor;
            }
        });

        _descriptionText.setAdapter(adapter);
    }
</pre><p>So, first things first. We setup two arrays. The to[] array holds a list of resource id&#8217;s that will be used to display the text values in the drop down. I just want to display the items in a list, so I used android.R.id.text1. The other array, from[] hold the name of the column that will hold the values to display. As I mentioned above, I want to show the values in the description column.</p><p>After that we new up a <a href="http://developer.android.com/reference/android/widget/SimpleCursorAdapter.html">SimpleCursorAdapter</a>. The line itself should be pretty obvious. The null that we&#8217;re passing into the constructor is because we don&#8217;t yet have a cursor available. In this simple case, the 3rd parameter is android.R.layout.simple_dropdown_item1line will suffice. If we were making our own view for display description, then we&#8217;d pass in the resource id of the control that would display the text value.</p><p>After instantiating the adapter, we provide some direction as to how we should convert the cursor to a string value that can be displayed. We do this with a <a href="http://developer.android.com/reference/android/widget/SimpleCursorAdapter.CursorToStringConverter.html">CursorStringConverter</a>. All we do here is retrieve the value of the description column in the cursor as a string and return that.</p><p>The final part is to use a <a href="http://developer.android.com/reference/android/widget/FilterQueryProvider.html">FilterQueryProvider</a> to get a Cursor holding the rows and columns we want to display - note that I&#8217;m doing this by actually running a query each time. There are probably more efficient ways to do it (and if you have a better way I&#8217;d love to hear it). The line _helper.getDescriptionsFor() will return a cursor holding all the rows from my vehicle_descriptions table for a given vehicle. The user will select the vehicle from my vehicle spinner. I created the method getSelectedVehicle() as a convenience method to return the text that is selected in the spinner.</p><p>And of course, the final thing is to provide the adapter to the <a href="http://developer.android.com/reference/android/widget/AutoCompleteTextView.html">AutoCompleteTextView</a>.</p><p>For the sake of completeness, here is what getDescriptionsFor() looks like. The _activity below is a reference to whatever Activity. The code here is should be pretty simple - we just return a managedQuery from the ContentProvider for this application. Note that with our projection we return both the _id column and the description column. The <a href="http://developer.android.com/reference/android/widget/SimpleCursorAdapter.html">SimpleCursorAdapter</a> requires the _id filed be present. Anyway, without further adieu - the code:</p><pre>
    public Cursor getDescriptionsFor(String vehicle, String descriptionFragment) {
        String[] projection = new String[]{VehicleDescriptionsTable._ID, VehicleDescriptionsTable.DESCRIPTION};
        String[] selectionArgs = new String[]{vehicle};

        StringBuffer selection = new StringBuffer(VehicleDescriptionsTable.DESCRIPTION)
                .append(&quot; LIKE '&quot;)
                .append(descriptionFragment)
                .append(&quot;%' AND &quot;)
                .append(VehicleDescriptionsTable.VEHICLE)
                .append(&quot;=?&quot;);
        String sortOrder = VehicleDescriptionsTable.DESCRIPTION;

        return _activity.managedQuery(VehicleDescriptionsTable.VEHICLE_DESCRIPTION_URI,
                projection,
                selection.toString(),
                selectionArgs, sortOrder);
    }
</pre><p>There you have it - <a href="http://developer.android.com/reference/android/widget/AutoCompleteTextView.html">AutoCompleteTextView</a> and <a href="http://developer.android.com/reference/android/widget/SimpleCursorAdapter.html">SimpleCursorAdapter</a> together at last. </p><p> </p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Slide deck and code from Prairie Developers Conference 2011]]></title>
    <link href="http://www.opgenorth.net/blog/2011/06/16/slide-deck-and-code-from-prairie-developers-conference-2011/"/>
    <updated>2011-06-16T00:00:00-06:00</updated>
    <id>http://www.opgenorth.net/blog/2011/06/16/slide-deck-and-code-from-prairie-developers-conference-2011</id>
    <content type="html"><![CDATA[For those wanted the slide-decks and code from my talks at <a href="http://www.prairiedevcon.com/">Prairie Developer&#8217;s Conference 2011</a>, you can find them up on <a href="https://github.com/topgenorth/PrDC2011">GitHub</a>. Thanks to all who attended.&nbsp; Maybe we&#8217;ll see you again next year.<br />
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Gifts for Dogs]]></title>
    <link href="http://www.opgenorth.net/blog/2011/04/06/gifts-for-dogs/"/>
    <updated>2011-04-06T00:00:00-06:00</updated>
    <id>http://www.opgenorth.net/blog/2011/04/06/gifts-for-dogs</id>
    <content type="html"><![CDATA[<img style="display:block;margin-right:auto;margin-left:auto;" alt="image" src="http://www.opgenorth.net/wp-content/uploads/2011/04/wpid-Apr_6_2011_8285.jpg" />

<p>Casey the Samoyed gets a spring gift - a portable steam cleaner for small parts of your carpet.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Picking Apart PDF with Ruby and Linux]]></title>
    <link href="http://www.opgenorth.net/blog/2011/03/17/picking-apart-pdf-with-ruby-and-linux/"/>
    <updated>2011-03-17T00:00:00-06:00</updated>
    <id>http://www.opgenorth.net/blog/2011/03/17/picking-apart-pdf-with-ruby-and-linux</id>
    <content type="html"><![CDATA[<p>I ran into a curious problem for a side problem of mine where I had some information in PDF files, both text and images.&#160; What I want to do is display the information from the PDF&#8217;s on a mobile (Android) device.&#160; PDF isn&#8217;t exactly a mobile friendly format, so I got the idea use HTML.&#160; The next trick then becomes how to get the content out of the PDF&#8217;s I want into HTML.&#160; Tux to the rescue!</p>  <p>As luck would have the, the utilities pdftotext and pdfimage will allow you to extract your text and images from a PDF (respectively).&#160; pdftotext was even nice enough to extract the text from the PDF and put it into an HTML document for me. (To get these on your Ubuntu box:&#160;&#160; sudo apt-get install xpdf-utils).&#160; Once I had these apps installed, I used a bit of Ruby to automate the process - I had 65 PDF&#8217;s to convert and wasn&#8217;t crazy about the keystrokes involved for all 65 files.&#160; Net time to do all this was a comfortable couple of hours in front of my TV catching up on the backlog of shows on the PVR.&#160; How is that for multi-tasking?</p>  <p>Here is the Ruby script I wrote.&#160; I welcome suggestions / improvements / enhancements / comments / cash donations / bottles of scotch:</p> 
<pre lang="ruby" line="1">
#!/usr/bin/ruby
Dir.glob("*.txt") do |file| File.delete(file) end
Dir.glob("*.jpg") do |file| File.delete(file) end
Dir.glob("*.pdf") do |file|
	basename = File.basename(file,'.*')
	if (File.directory?(basename))
		Dir.glob("./#{basename}/*.*") do |file2| File.delete(file2) end
	else
	  Dir.mkdir basename unless File.directory?(basename)
	end
	system("pdftotext", "-htmlmeta", file, "./#{basename}/#{basename}.html")
	system("pdfimages", "-j",  file, "./#{basename}/")
	puts "Converted #{file} to text and extracted images to #{basename}."
end

</pre>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Purging your Privates (MSMQ with Powershell)]]></title>
    <link href="http://www.opgenorth.net/blog/2011/03/01/purging-your-privates-msmq-with-powershell/"/>
    <updated>2011-03-01T00:00:00-07:00</updated>
    <id>http://www.opgenorth.net/blog/2011/03/01/purging-your-privates-msmq-with-powershell</id>
    <content type="html"><![CDATA[A project I’m currently on makes heavy use of MSMQ and private queues.  Every so often, it’s necessary to purge messages from the queue during development. I got tired of always using the MMC snap-in to perform this task, so I whipped up this quick PowerShell script to handle the dirty work for me.  Granted, it’s pretty crude, but it gets the job done.  Any suggestions or improvements, feel free to let me know.

<pre lang="powershell" line="1">
$queuename = ".\private$\myprivatequeue"
[Reflection.Assembly]::LoadWithPartialName("System.Messaging") | Out-Null 
$queue = New-Object -TypeName "System.Messaging.MessageQueue"
$queue.Path = $queuename
$messagecount = $queue.GetAllMessages().Length 
$queue.Purge() 
Write-Host "$queuename has been purged of $messagecount messages." -ForegroundColor Yellow
</pre>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[WIND Mobile and my Nexus One]]></title>
    <link href="http://www.opgenorth.net/blog/2010/12/20/wind-mobile-and-my-nexus-one/"/>
    <updated>2010-12-20T00:00:00-07:00</updated>
    <id>http://www.opgenorth.net/blog/2010/12/20/wind-mobile-and-my-nexus-one</id>
    <content type="html"><![CDATA[<p>Just recently I switch my mobile carrier from Rogers to <a title="WIND mobile" href="../../www.windmobile.ca">WIND Mobile</a>. Their <a title="Holiday Miracle Plan" href="http://www2.windmobile.ca/en/Pages/unlimitedtalktextdata.aspx">Holiday Miracle plan</a> was just to good to pass up - even paying the penalty to break my Rogers contract I will still save money in the long run.

Anyway, once the number got transferred over, I didn&#8217;t have a 3G connection, even after selecting the WIND Home APN. &nbsp;After a bit of google, it seems that what I had to do is to setup an APN. &nbsp;In case I can&#8217;t find it later, here are the APN settings:</p><table><tbody><tr><td>APN</td><td>mms.WINDmobile.ca</td></tr><tr><td>Proxy</td><td>&lt;Not Set&gt;</td></tr><tr><td>Port</td><td>&lt;Not Set&gt;</td></tr><tr><td>Username</td><td>&lt;Not Set&gt;</td></tr><tr><td>Password</td><td>&lt;Not Set&gt;</td></tr><tr><td>Server</td><td>&lt;Not Set&gt;</td></tr><tr><td>MMSC</td><td>http://mms.WINDmobile.ca</td></tr><tr><td>MMS proxy</td><td>74.115.197.70</td></tr><tr><td>MMS port</td><td>8080</td></tr><tr><td>MMC</td><td>302</td></tr><tr><td>MNC</td><td>490</td></tr><tr><td>Authentication type</td><td>&lt;Not set&gt;</td></tr><tr><td>APN type</td><td>mms</td></tr></tbody></table><p>After setting this up, bingo, got my 3G connection going.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[TFS 2010, VS2010 Database Projects, and CI]]></title>
    <link href="http://www.opgenorth.net/blog/2010/11/29/tfs-2010-vs2010-database-projects-and-ci/"/>
    <updated>2010-11-29T00:00:00-07:00</updated>
    <id>http://www.opgenorth.net/blog/2010/11/29/tfs-2010-vs2010-database-projects-and-ci</id>
    <content type="html"><![CDATA[<p>I’m currently working on a project where there are some functional tests that require a SQL Server database. Before in the past I’ve always handled this by using Redgate’s excellent SQL Server tools to create a monolithic script that would deploy the DB Schema, and then another set of scripts to set up the data.&#160; Then it’s pretty trivial to use OSQL.EXE to run the scripts and setup the database.</p>  <p>However, in this case, I’m constrained to use the VS2010 database project and TFS Build.&#160; So, the trick for me became how to use TFS 2010 Team Build to deploy a fresh copy of the database before the functional tests are run.&#160; After a bit of jiggery-pokery, here is what I ended up doing.&#160; I’m sure that at some point in my future, I will have to do this again, and nothing helps my failing memory like writing it down.</p>  <p>First a rough overview:</p>  <ol>   <li>Declare some variables to hold the physical path of my .dbproj and the default data path for SQL Server. </li>    <li>Convert the source code control path of my .dbproj to the physical path on disk. </li>    <li>To help with debugging and diagnostics, write a build message with the location of the physical path of the .dbproj </li>    <li>Add an MSBuild task to my workflow that would deploy the .dbproj. </li> </ol>  <p>Without further adieu, here is more details breakdown of the steps involved.</p>  <h4>Declare Variables</h4>  <p>So, first things first – declare the two variables I need to hold the physical path to the .dbproj file, and the directory for my SQL Server databases.&#160; This should be pretty simple and straight forward (assuming that the POS that is the “Workflow Designer” isn’t crashing VS2010 constantly).</p>  <p><a href="http://www.opgenorth.net/wp-content/uploads/2010/11/image.png"><img style="background-image: none; border-right-width: 0px; margin: ; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.opgenorth.net/wp-content/uploads/2010/11/image_thumb.png" width="1000" height="379" /></a></p>  <p>Once that is out of the way I scrolled down the pretty, crashy, workflow designer until I came across the <u>Compile and Test</u> sequence.&#160; At the very start of it I added a sequence that I called <u>Deploy Database</u>.&#160; Inside this sequence I added the following Team Foundation Build Activities:</p>  <h4>ConvertWorkspaceItem</h4>  <p>The point to this BuildActivity is to figure where the hell on the file system TFS put one of the files.&#160; Pretty straight forward:</p>  <p><a href="http://www.opgenorth.net/wp-content/uploads/2010/11/image1.png"><img style="background-image: none; border-right-width: 0px; margin: ; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.opgenorth.net/wp-content/uploads/2010/11/image_thumb1.png" width="691" height="192" /></a></p>  <h4>WriteBuildMessage</h4>  <p>Always nice to have a message in your log file to help with troubleshooting.&#160; Here’s what my WriteBuildMessage activity looks like.&#160; Notice that the message makes use of the “DbProjectPath” variable that we set above in the ConvertWorkspaceItemActivity.</p>  <p><a href="http://www.opgenorth.net/wp-content/uploads/2010/11/image2.png"><img style="background-image: none; border-right-width: 0px; margin: ; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.opgenorth.net/wp-content/uploads/2010/11/image_thumb2.png" width="687" height="146" /></a></p>  <h4>MSBuild</h4>  <p>This the working part of the the sequence.&#160; In here we use MSBuild to call the .dbproj and deploy a fresh copy of the database to SQL Server. Key properties to set:</p>  <ul>   <li>CommandLineArguments : this contains the properties to pass on the command line when deploying.&#160; You’ll want to provide these properties      <ul>       <li>/p:TargetDatabase=YOUR_DATABASE_NAME </li>        <li>/p:”DefaultDataPath=DIRECTORY_OF_DATABASE_FILES” </li>        <li>/p:”TargetConnectionString=YOUR_CONNECTION_STRING_FOR_THE_TARGET_DATABASE” </li>        <li>/p:DeployToDatabase=True </li>     </ul>   </li>    <li>Configuration : just specify which configuration in the solution to use. </li>    <li>DisplayName : what ever you want, this is how the MSBuild activity will be displayed in your sequence </li>    <li>LogFile : the name of the log file for the deploy </li>    <li>OutDir : the output directory </li>    <li>Project : Notice that this is the value of DbProjectPath, which we set above in our ConvertWorkItem </li>    <li>RunCodeAnalysis : Set this to CodeAnalysisOption.Never.&#160; Doesn’t make much sense to do code analysis on a database project. </li>    <li>Targets : </li> </ul>  <p>Here is what the properties look like for this particuar Build Activity:</p>  <p><a href="http://www.opgenorth.net/wp-content/uploads/2010/11/image3.png"><img style="background-image: none; border-right-width: 0px; margin: ; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.opgenorth.net/wp-content/uploads/2010/11/image_thumb3.png" width="648" height="493" /></a></p>  <p>Now all of this has to live somewhere.&#160; You might want to have this live somewhere else depending on when or how you want the database to deploy.&#160; In my case, as I wanted to deploy the database BEFORE my tests ran, I hunted through the workflow and found the sequence called <u>Run Tests</u>.&#160; I modified one side of the If condition to include a new sequence call <u>Deploy DB and Run Tests</u>:<a href="http://www.opgenorth.net/wp-content/uploads/2010/11/image4.png"><img style="background-image: none; border-right-width: 0px; margin: ; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.opgenorth.net/wp-content/uploads/2010/11/image_thumb4.png" width="501" height="349" /></a></p>  <p>Here is an overview of what my Deploy DB and Run Tests sequence looks like</p>  <p><a href="http://www.opgenorth.net/wp-content/uploads/2010/11/image5.png"><img style="background-image: none; border-right-width: 0px; margin: ; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.opgenorth.net/wp-content/uploads/2010/11/image_thumb5.png" width="257" height="502" /></a></p>  <p>&#160;</p>  <h4>After Thoughts</h4>  <p>To be honest, I found the whole process annoying and awkward.&#160; Sure, I didn’t have to edit a bunch of XML by hand, but the Workflow Designer in Visual Studio 2010 wasn’t exactly a joy to work with either.&#160; I don’t know exactly what the problem was, but it kept crashing while I was trying to edit this Build Process Template. It was always the same error, an Out of Memory Exception.&#160; On a Dell Latitude E6510 with 4GB of memory, this shouldn’t be happening.&#160; As well, the whole editing process for the work flow was awkward at best.</p>  <p>As much as I dislike XML based build tools, at least text editors don’t get all crashy and such.&#160; As well, I found the overall experience of trying to create and piece together the workflow for Team Build to be sluggish and tedious.&#160; It’s great to have a GUI editor to hide the crummy XML, but honestly, I think the way <a href="http://www.finalbuilder.com/home.aspx">FinalBuilder</a> works is far superior to how VS2010 in terms of easy of use and readability(application crashes aside).</p>  <p>Next is to setup my Release build definition, and to tackle the issue of updated the version number in AssemblyInfo.cs and creating a zip file of all the deployment artifacts.&#160; But first I’ve got to go and buy a bottle or two of Talisker to help numb the pain that will follow as I go done down that path.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[First Impressions: Windows Phone 7 Development]]></title>
    <link href="http://www.opgenorth.net/blog/2010/11/15/first-impressions-windows-phone-7-development/"/>
    <updated>2010-11-15T00:00:00-07:00</updated>
    <id>http://www.opgenorth.net/blog/2010/11/15/first-impressions-windows-phone-7-development</id>
    <content type="html"><![CDATA[I’ve spent a bit of my spare time in the past week looking at Windows Phone 7 from a developer’s point of view.  I’d have started sooner, but honestly, I didn’t see the point until there were actually devices that I could hold and use.  I know that in the U.S., some guys got developer phones from Microsoft, but I don’t think that anybody up here in Canada was that lucky.

So, over the past year or so I’ve been dabbling with Android and I actually like programming for Android.  The biggest issues I’ve run into with Android are my lack of Java skills – I keep doing things the C# way (you really don’t realize how handy Linq is until you don’t have it) and the fact that Android doesn’t have a decent UI designer.  But otherwise, I like Android.

So, I was curious what the developer experience was for WP7.  In a nutshell – it’s not bad, and in some ways better than that of Android.

Things I like about WP7 development:
<ul>
	<li>Being a C# guy, it was pretty easy and fast for me to get going with WP7.  Of course, Novell now has <a href="http://www.monodroid.net">MonoDroid</a> which in theory should lessen the learning curve for a C# guy to create Android applications.</li>
	<li>It’s nice to have good tooling to help with creating my UI’s.  Blend and Cider are pretty decent. Android does have <a href="http://droiddraw.org">DroidDraw</a>, but I’ve never really found that tool to be good to work with.  Eclipse has some sort of an GUI designer thingy, but again, I’ve found it to be kind of lack-lustre at best.  That, and I don’t use Eclipse – I prefer IntelliJ.</li>
	<li>The Emulator seems to start up faster to me that the Android emulator – but that could just be me.</li>
	<li>The MVVM pattern.  I know the theory, and am now learning the more practical side of it.  Was worried that WP7 was going to decent into the path of darkness and pain that was/is Web Forms.</li>
	<li>I think that the debugger integrates better with the WP7 emulator.  Not that, generally speaking, I spend a lot of time in the debugger, but when you need it, it does seem to be more natural to me.  Again, this could just be because by day I do a lot of C# development so I’m more used to the Microsoft tooling to begin with.</li>
</ul>
Some things I didn’t like about WP7 development:
<ul>
	<li>You have to have Vista or Windows 7.  Yes, I know, XP is almost 10 years old, time to move on.  Call me an O/S curmudgeon.  I don’t mind Windows 7, but Vista sucks/sucked.</li>
	<li>It seems like to build your apps, you have to use Visual Studio 2010.  Not a problem for a developer, but I’m old school when it comes to compiling applications, and your build server shouldn’t be tainted by your IDE.</li>
	<li>I’m use to the relatively easy going Google marketplace and the fact I have numerous avenues available to me to distribute Android applications.  No such joy with WP7 apps.</li>
	<li>Editing XAML by hand.  But, I suppose it’s no worse that the XML resource files that Android uses.</li>
	<li>Not seeing a lot of projects whose code I can read.  Granted it’s still early, so hopefully that will change.  Or not.  .NET doesn’t seem to have the same OSS community spirit that Java does.</li>
</ul>
Microsoft has always tried to be pretty good to developers (sometimes to their own detriment), but I think Windows Phone 7 does have some things going for it, from a developer’s point of view anyway.  Here’s to hoping that strategy pays off – that cool apps will get written for WP7, and that it will be commercially viable.  Competition is good – it will keep Apple and Google on their toes.  <img class="wlEmoticon wlEmoticon-smile" style="border-style: none;" src="http://www.opgenorth.net/wp-content/uploads/2010/11/wlEmoticon-smile.png" alt="Smile" />
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[YEG Open Data, the 2010 Edmonton Municipal Election, and Android]]></title>
    <link href="http://www.opgenorth.net/blog/2010/10/15/yeg-open-data-the-2010-edmonton-municipal-election-and-android/"/>
    <updated>2010-10-15T00:00:00-06:00</updated>
    <id>http://www.opgenorth.net/blog/2010/10/15/yeg-open-data-the-2010-edmonton-municipal-election-and-android</id>
    <content type="html"><![CDATA[<p><em>(Or, things to do when you have a sick kid)</em></p>  <p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="election" border="0" alt="election" align="right" src="http://www.opgenorth.net/wp-content/uploads/2010/10/election.jpg" width="126" height="162" /></p>  <p>One of the new <a href="http://data.edmonton.ca/">data catalogues</a> that the City of Edmonton has put up is the <a href="http://data.edmonton.ca/DataBrowser/coe/Election2010Results#param=NOFILTER--DataView--Results">2010 Election Results</a>.&#160; This Thanksgiving Long Weekend I was kind of “grounded” at home when my son came down with a nasty inner ear infection.&#160; I was hanging out with him, and thought I could use the time to see how hard it would be and how quickly I could put together an Android application that would poll these results and show leading candidate in each contest for a given ward.&#160; Turns out it was not that hard at all.&#160; Development time was less than one day, and then I had the application running on my phone for a couple of days.</p>  <p>If you search the Android market place for YEG Vote, and you’re running Android 1.6 or higher you should able to find the application and install it (assuming, of course, you care about the election results).&#160; The application itself is pretty bare bones.&#160; It will get the results every five minutes, and then show the leading candidate.</p>  <p>I think my next trick will be to duplicate the application in C# and <a href="http://monodroid.net/">MonoDroid</a> just to get a feel for the differences and such.&#160; I’d wager that it will take even less time in <a href="http://monodroid.net/">MonoDroid</a> for me, given that I’m much more fluent in C# than I am in Java.&#160; I’d have done this in <a href="http://monodroid.net/">MonoDroid</a> to being with, but <a href="http://monodroid.net/">MonoDroid</a> is currently in a limited preview and one of the conditions of being in the preview program is that you can’t distribute applications written in <a href="http://monodroid.net/">MonoDroid</a> yet. I would have tried a Windows Phone 7 port, but it just doesn’t make much sense, given that the number of people in Alberta with actually WP7 devices is probably less than 10.&#160; Maybe next election.</p>  <p>If you have any suggestions or ideas, feel free to let me know. If I can scrounge up some time this weekend before the election I’ll see if I can implement them.</p>  <p>And, it goes without saying, regardless of what you think about this application,<strong> if you live in Alberta, make sure you get out and vote this Monday (October 18th, 2010).</strong></p>  <p><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="screenshot1" border="0" alt="screenshot1" src="http://www.opgenorth.net/wp-content/uploads/2010/10/screenshot1.png" width="234" height="349" /></p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Looking for a Job?]]></title>
    <link href="http://www.opgenorth.net/blog/2010/09/21/looking-for-a-job/"/>
    <updated>2010-09-21T00:00:00-06:00</updated>
    <id>http://www.opgenorth.net/blog/2010/09/21/looking-for-a-job</id>
    <content type="html"><![CDATA[<p>If you happen to be a .NET type, knowledgeable/interested in MVC and Agile, QuestionMark is looking for .NET developers (F/T only, no contractors) here in Edmonton, Alberta.&#160; Below is the job description.&#160; If you’re interested, send your resume to Kaitlyn Lardin at QuestionMark (kaitlyn AT questionmark DOT com):</p>  <p>&#160;</p>  <h3>Senior Software Developer</h3>  <p><b>Background</b></p>  <p>Questionmark is a company with a 20 year history recognised global presence in e-learning and assessment automation with software covering all aspects of this field, from authoring to delivery and reporting. Our software is used by over 3 million people in 15 different countries throughout the world. Questionmark<i> </i>is a fast-growing company, with a dedicated, passionate, and global workforce. We have offices in London, UK, Norwalk, CT and Tubize, Belgium. We care about the satisfaction of our employees and we reward them for meeting or exceeding expectations. The company promotes a relaxed, fun and highly productive approach to work. We have recently moved location to a vibrant office in the heart of downtown surrounded by software development companies.</p>  <p><b>Role of the Senior Developer</b></p>  <p>We are looking for a talented senior developer to join our development team in designing and creating the next generation of on-line assessment delivery software. This role will work closely with a Product Owner and other team members in a SCRUM environment, and be responsible for delivering potentially shippable functionality each Sprint. It also includes the mentoring of other team members through peer review. Our development team works in a Continuous Integration environment with automated builds and testing.</p>  <p><b>Essential skills:</b></p>  <p>· At least 5 years commercial experience development experience.</p>  <p>· You will be highly skilled in software development using our core technologies of C#, ASP.NET, XML, JavaScript, SQL Server and/or Oracle.</p>  <p>· Experience of jQuery very desirable </p>  <p>· Experience of working with .NET 2.0 or later</p>  <p>· Expertise in object oriented programming and relational databases</p>  <p>· Expertise in T-SQL and/or PL/SQL</p>  <p>· Good written and verbal communication. You must be able to write specifications</p>  <p>· Experience working in a SCRUM environment is desirable </p>  <p><b></b></p>  <p><b>Attributes of the Senior Software Developer:</b></p>  <p>The successful candidate will be highly skilled in software development using our core technologies, as above. You will be a self starting, self motivated individual who is enthusiastic and passionate about developing innovative software solutions.</p>  <p>Candidates must be eligible to work within Canada and relocate to Edmonton. </p>  <p>   <br /><b>The package: </b></p>  <p>We offer excellent salary and benefits that include flexible working hours, starting 14 days annual leave, company bonus scheme, generous health coverage, and subsidized gym membership. </p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Informal Poll:  Next Android Phone]]></title>
    <link href="http://www.opgenorth.net/blog/2010/09/16/informal-poll-next-android-phone/"/>
    <updated>2010-09-16T00:00:00-06:00</updated>
    <id>http://www.opgenorth.net/blog/2010/09/16/informal-poll-next-android-phone</id>
    <content type="html"><![CDATA[<p>My trusty old ADP1 is beginning to show it’s age, and I’m thinking that it’s time to get a new Android based smart phone.&#160; So, what should a guy get?&#160; My criteria (to be modified as thoughts come to mind):</p>  <ul>   <li>Not carrier locked</li>    <li>Would prefer it compatible with the frequencies used by Rogers (I’ve got about 18 months left on my contract with them).</li>    <li>I can install <a href="http://www.cyanogenmod.com/">CyanogenMod</a> on it.&#160; More to the point:&#160; I can install the latest versions of Android as they become available.&#160; <a href="http://www.cyanogenmod.com/">CyanogenMod</a> seems to be the handiest way to do so.</li> </ul>  <p>Personally, I’m thinking either an <a href="http://www.htc.com/www/product/desire/overview.html">HTC Desire</a> or a <a href="http://pages.samsung.com/wireless/product?productid=55">Samsung Galaxy S</a>.</p>  <p>I’m not against a Windows Phone 7 device, but there aren’t any on the market now, and I’m thinking that I don’t want to take the pain of a first generation Windows based device.</p>  <p>If you’ve got any thoughts/suggestions/comments/tips, feel free to post them in the comments.</p>
]]></content>
  </entry>
  
</feed>
