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

  <title>navitronic</title>
  <link href="http://navitronic.co.uk/atom.xml" rel="self"/>
  <link href="http://navitronic.co.uk/"/>
  <updated>2011-08-29T13:25:05+10:00</updated>
  <id>http://navitronic.co.uk/</id>
  <author>
    <name>Adrian</name>
    
  </author>

  
  <entry>
    <title>Apostles</title>
    <link href="http://navitronic.co.uk/2011/08/apostles/"/>
    <updated>2011-08-29T11:58:00+10:00</updated>
    <id>http://navitronic.co.uk/2011/08/apostles</id>
    <content type="html">&lt;p&gt;&lt;a href=&quot;http://www.flickr.com/photos/navitronic/5896022110/&quot; title=&quot;&quot;&gt;&lt;img src=&quot;http://farm7.static.flickr.com/6050/5896022110_0b1e418aaf_z.jpg&quot; width=&quot;612&quot; height=&quot;612&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Something has to change</title>
    <link href="http://navitronic.co.uk/2011/08/changes/"/>
    <updated>2011-08-26T00:00:00+10:00</updated>
    <id>http://navitronic.co.uk/2011/08/changes</id>
    <content type="html">&lt;p&gt;I haven't updated this place in a long, long time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; Oooh that worked. Have just tweaked the site to run on octopress/jekyll and deploy via rsync/ssh.&lt;/p&gt;

&lt;p&gt;I might actually enjoy updating this soon.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Walhalla, Victoria</title>
    <link href="http://navitronic.co.uk/2011/04/walhalla/"/>
    <updated>2011-04-25T00:00:00+10:00</updated>
    <id>http://navitronic.co.uk/2011/04/walhalla</id>
    <content type="html">&lt;p&gt;&lt;a href=&quot;http://www.flickr.com/photos/navitronic/5656125893/&quot; title=&quot;Walhalla, Victoria by navitronic, on Flickr&quot;&gt;&lt;img src=&quot;http://farm6.static.flickr.com/5190/5656125893_203e2fbcc1_z.jpg&quot; alt=&quot;Walhalla, Victoria&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This Easter, I spent some time in the lovely small town of &lt;a href=&quot;http://en.wikipedia.org/wiki/Walhalla,_Victoria&quot;&gt;Walhalla&lt;/a&gt;, after a night camping near Thompson Dam.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Helpful date helper</title>
    <link href="http://navitronic.co.uk/2011/04/helpful_date_helper/"/>
    <updated>2011-04-21T00:00:00+10:00</updated>
    <id>http://navitronic.co.uk/2011/04/helpful_date_helper</id>
    <content type="html">&lt;p&gt;A useful php function for presenting a date in a short easy to read format
wrapped in an &amp;lt;abbr&amp;gt; tag that displays a longer version of the date.&lt;/p&gt;

&lt;p&gt;Your mileage may vary.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;function helpful_date($date, $sd_format = 'd/m/y', $ld_format = 'g:ia, l jS F Y', $non_date_return = 'n/a'){

    // send back any non applicable dates.
    // send back any unconvertable dates.
    if( $date == '' || !( $time = strtotime($date) ) ){ return $non_date_return; }

    // adjust time for time difference
    //$time += Config('timediff');

    $long_date  = date($ld_format, $time);
    $short_date = date($sd_format, $time);

    return '&amp;lt;abbr title=&quot;'.$long_date.'&quot;&amp;gt;'.$short_date.'&amp;lt;/abbr&amp;gt;';

}
&lt;/code&gt;&lt;/pre&gt;
</content>
  </entry>
  
  <entry>
    <title>St Kilda</title>
    <link href="http://navitronic.co.uk/2011/04/st-kilda/"/>
    <updated>2011-04-20T21:20:00+10:00</updated>
    <id>http://navitronic.co.uk/2011/04/st-kilda</id>
    <content type="html">&lt;p&gt;&lt;a href=&quot;http://www.flickr.com/photos/navitronic/4655957454/&quot; title=&quot;St Kilda by navitronic, on Flickr&quot;&gt;&lt;img src=&quot;http://farm5.static.flickr.com/4051/4655957454_c65eb6fb2e_z.jpg&quot; alt=&quot;St Kilda&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Harbour Bridge</title>
    <link href="http://navitronic.co.uk/2011/04/harbour-bridge/"/>
    <updated>2011-04-09T07:06:32+10:00</updated>
    <id>http://navitronic.co.uk/2011/04/harbour-bridge</id>
    <content type="html">&lt;p&gt;&lt;a href=&quot;http://www.flickr.com/photos/navitronic/5602226804/&quot; title=&quot;Harbour Bridge by navitronic, on Flickr&quot;&gt;&lt;img src=&quot;http://farm6.static.flickr.com/5227/5602226804_bfff33f946_z.jpg&quot; width=&quot;640&quot; height=&quot;426&quot; alt=&quot;Harbour Bridge&quot;&gt;&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Skyrail</title>
    <link href="http://navitronic.co.uk/2011/04/skyrail/"/>
    <updated>2011-04-09T03:49:15+10:00</updated>
    <id>http://navitronic.co.uk/2011/04/skyrail</id>
    <content type="html">&lt;p&gt;&lt;a href=&quot;http://www.flickr.com/photos/navitronic/5602214010/&quot; title=&quot;Skyrail to Kuranda by navitronic, on Flickr&quot;&gt;&lt;img src=&quot;http://farm6.static.flickr.com/5226/5602214010_9d8e9e66e2_z.jpg&quot; width=&quot;640&quot; height=&quot;426&quot; alt=&quot;Skyrail to Kuranda&quot;&gt;&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Portsea</title>
    <link href="http://navitronic.co.uk/2011/03/portsea/"/>
    <updated>2011-03-01T01:32:46+11:00</updated>
    <id>http://navitronic.co.uk/2011/03/portsea</id>
    <content type="html">&lt;p&gt;&lt;a title=&quot;Portsea by navitronic, on Flickr&quot; href=&quot;http://www.flickr.com/photos/navitronic/5487495036/&quot;&gt;&lt;img class=&quot;aligncenter&quot; src=&quot;http://farm6.static.flickr.com/5174/5487495036_22279a3e26.jpg&quot; alt=&quot;Portsea&quot; width=&quot;500&quot; height=&quot;500&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Realisation</title>
    <link href="http://navitronic.co.uk/2011/02/realisation/"/>
    <updated>2011-02-24T00:25:56+11:00</updated>
    <id>http://navitronic.co.uk/2011/02/realisation</id>
    <content type="html">&lt;p&gt;I realised today that I have spent more of my twenties living in Australia than I have in England. A slightly useless but fun fact I guess.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Super Meat Boy</title>
    <link href="http://navitronic.co.uk/2011/02/super-meat-boy/"/>
    <updated>2011-02-18T06:25:39+11:00</updated>
    <id>http://navitronic.co.uk/2011/02/super-meat-boy</id>
    <content type="html">&lt;p&gt;After the disappointing experience that was Force Unleashed II, I have been playing a lot of XBLA games to tide me over until Arkham City is released (as evidenced by completing Limbo a little while ago).&lt;/p&gt;

&lt;p&gt;Whilst hunting for a new platform style game, I came across Super Meat Boy, a nice slice of fiendishly difficult, super high paced fun. I am playing through it at the moment, but watch the video below for an indication of the game play style.&lt;/p&gt;

&lt;p&gt;http://www.youtube.com/watch?v=2ohjyhICYco&lt;/p&gt;

&lt;p&gt;I would highly recommend this game to anybody with an Xbox 360/Wii/PC, even though I know for a fact that I will never complete this game...&lt;/p&gt;

&lt;p&gt;Well, unless I grow an extra pair of fingers and start taking speed... actually that's quite the idea...&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://navitronic.co.uk/uploads/2011/02/Super_Meat_Boy.png&quot;&gt;&lt;img class=&quot;aligncenter size-full wp-image-361&quot; title=&quot;Super_Meat_Boy&quot; src=&quot;http://navitronic.co.uk/uploads/2011/02/Super_Meat_Boy.png&quot; alt=&quot;&quot; width=&quot;400&quot; height=&quot;314&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Limbo</title>
    <link href="http://navitronic.co.uk/2011/02/limbo/"/>
    <updated>2011-02-01T01:20:22+11:00</updated>
    <id>http://navitronic.co.uk/2011/02/limbo</id>
    <content type="html">&lt;p&gt;First computer game I have bothered to complete in years.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://navitronic.co.uk/uploads/2011/02/screenshot06-800x450.jpg&quot;&gt;&lt;img class=&quot;aligncenter size-medium wp-image-358&quot; title=&quot;screenshot06-800x450&quot; src=&quot;http://navitronic.co.uk/uploads/2011/02/screenshot06-800x450-640x360.jpg&quot; alt=&quot;&quot; width=&quot;640&quot; height=&quot;360&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Removing Google Analytics cruft from urls</title>
    <link href="http://navitronic.co.uk/2010/12/removing-google-analytics-cruft-from-urls/"/>
    <updated>2010-12-29T05:40:22+11:00</updated>
    <id>http://navitronic.co.uk/2010/12/removing-google-analytics-cruft-from-urls</id>
    <content type="html">&lt;p&gt;So I have decided to be productive over the Christmas break and continue work on my super secret, somewhat stalled twitter app. So apparently I am also going to blog about it here.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Warning:&lt;/strong&gt; nerdery ahead, no cat photos.&lt;/p&gt;

&lt;h2&gt;The Problem&lt;/h2&gt;


&lt;p&gt;Today, I have begun work on a part of the application that processes the url's posted within tweets and attempts to normalise them as much as possible. By normalising them, I mean expanding short urls, such as bit.ly links and also removing certain pieces of tracking code within the url itself. The main culprit I have come across so far has been the tracking code inserted as part of Google Analytics campaigns.&lt;/p&gt;

&lt;p&gt;It is a very common pattern to see in urls, and looks very similar to:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;?utm_source=twitter&amp;amp;utm_medium=social&amp;amp;utm_campaign=Our+vain+attempt+to+track+you
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Why is this a problem?&lt;/h2&gt;


&lt;p&gt;If someone posts a link without the google tracking code and then an automated tool, such as twitterfeed or similar posts a shortened link with google tracking code inserted, I want my application to see that they both point to a single url.&lt;/p&gt;

&lt;p&gt;The easiest way I can see to do this, is to remove the google tracking code. So I need to employ everyone's favourite hammer, regular expressions.&lt;/p&gt;

&lt;h2&gt;The Solution&lt;/h2&gt;


&lt;p&gt;I took a selection of 500 url's containing google tracking code and looked for the common factors in the urls. My first attempt at matching the tracking code involved looking at the various parameters in order and matching their possible values. The regex pattern came out like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;/(\?)utm_source=[^\r\n]+\&amp;amp;utm_medium=[^\r\n]+\&amp;amp;utm_campaign=[^\r\n]+/
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I ran a preg_replace against the 500 urls and found that it worked as expected about 95% of the time. Issues came from url's that were missing the utm_campaign parameter and url's where the parameters were in a different order to the majority of the urls.&lt;/p&gt;

&lt;p&gt;How to solve this issue? The obvious change to the regex was to match the parameters of the tracking code individually and then the order or the lack of a parameter wouldn't affect the matching. I came up with the following regex to achieve this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;/((\?)?(\&amp;amp;)?utm_source=[^\&amp;amp;]+|(\?)?(\&amp;amp;)?utm_medium=[^\&amp;amp;]+|(\?)?(\&amp;amp;)?utm_campaign=[^\&amp;amp;]+)/
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This worked a lot better and had numerous improvements. However, it seemed far too verbose and lead to me discovering a fourth parameter in google tracking code, utm_content.&lt;/p&gt;

&lt;h2&gt;Refactoring&lt;/h2&gt;


&lt;p&gt;Hmmmm, should I get even more verbose or can I refactor? Refactoring is always my preferred answer.&lt;/p&gt;

&lt;p&gt;I find that when I need to refactor code, the best starting point is always to look at what you are trying to do again and work out if you understand the problem as well as you could. In this case, the problem I started with was that I had a specific list of parameters, in a specific order that I wanted to get rid of from a url.&lt;/p&gt;

&lt;p&gt;I had already worked out that they cannot be in order and now I was looking for each parameter individually and each parameter begins with &quot;utm_&quot;...&lt;/p&gt;

&lt;p&gt;There we go, we have the catalyst for refactoring, lets adjust the regex to match any parameter that begins with &quot;utm_&quot;&lt;/p&gt;

&lt;h2&gt;The Finished Solution?&lt;/h2&gt;


&lt;p&gt;Adjusting the regex to match any parameter starting with utm_ was just a case of replacing the name part of the parameter with a pattern to match repeating lowercase letters and removing the redundant parts of the rest of the pattern.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;/(\?|\&amp;amp;)?utm_[a-z]+=[^\&amp;amp;]+/
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I tested this against the 500 urls and it worked 100% of the time.&lt;/p&gt;

&lt;p&gt;Bingo, a short and concise regular expression to strip out Google Analytics tracking code from urls.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://gist.github.com/758177&quot;&gt;See it in use here.&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;A Disclaimer...&lt;/h2&gt;


&lt;p&gt;This was tested with PHP's preg_replace function, mileage in other environments will vary.&lt;/p&gt;

&lt;p&gt;You can see how it is used &lt;a href=&quot;https://gist.github.com/758177&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I am terrible at regular expressions compared to some. I welcome all and any suggestions or feedback via the comments or &lt;a href=&quot;mailto:navitronic@gmail.com&quot;&gt;via email&lt;/a&gt;.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Sydney Harbour</title>
    <link href="http://navitronic.co.uk/2010/06/sydney-harbour/"/>
    <updated>2010-06-25T06:45:44+10:00</updated>
    <id>http://navitronic.co.uk/2010/06/sydney-harbour</id>
    <content type="html">&lt;p&gt;&lt;a href=&quot;http://www.flickr.com/photos/navitronic/4655957054/&quot; title=&quot;Sydney Harbour by navitronic, on Flickr&quot;&gt;&lt;img src=&quot;http://farm5.static.flickr.com/4011/4655957054_f6d5e0a851_z.jpg&quot; width=&quot;640&quot; height=&quot;368&quot; alt=&quot;Sydney Harbour&quot;&gt;&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Relaxing</title>
    <link href="http://navitronic.co.uk/2010/06/relaxing/"/>
    <updated>2010-06-25T06:44:59+10:00</updated>
    <id>http://navitronic.co.uk/2010/06/relaxing</id>
    <content type="html">&lt;p&gt;&lt;a href=&quot;http://www.flickr.com/photos/navitronic/4673506894/&quot; title=&quot;Max just chilling. by navitronic, on Flickr&quot;&gt;&lt;img src=&quot;http://farm2.static.flickr.com/1270/4673506894_1317f8f154_z.jpg&quot; width=&quot;640&quot; height=&quot;480&quot; alt=&quot;Max just chilling.&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I know I keep posting this elsewhere, but it makes me laugh every time I see it.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Portarlington</title>
    <link href="http://navitronic.co.uk/2010/04/portarlington/"/>
    <updated>2010-04-26T10:42:13+10:00</updated>
    <id>http://navitronic.co.uk/2010/04/portarlington</id>
    <content type="html">&lt;p style=&quot;text-align: center;&quot;&gt;&lt;a title=&quot;Portarlington by navitronic, on Flickr&quot; href=&quot;http://www.flickr.com/photos/navitronic/4554279352/&quot;&gt;&lt;img class=&quot;aligncenter&quot; src=&quot;http://farm4.static.flickr.com/3190/4554279352_e6fd5e9f23.jpg&quot; alt=&quot;Portarlington&quot; width=&quot;500&quot; height=&quot;330&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

</content>
  </entry>
  
  <entry>
    <title>Bowlarama.</title>
    <link href="http://navitronic.co.uk/2010/02/bowlarama/"/>
    <updated>2010-02-28T05:14:22+11:00</updated>
    <id>http://navitronic.co.uk/2010/02/bowlarama</id>
    <content type="html">&lt;p&gt;&lt;a href=&quot;http://navitronic.co.uk/uploads/2010/02/web-seq-cab.jpg&quot;&gt;&lt;img class=&quot;aligncenter size-medium wp-image-347&quot; title=&quot;web-seq-cab&quot; src=&quot;http://navitronic.co.uk/uploads/2010/02/web-seq-cab-640x480.jpg&quot; alt=&quot;&quot; width=&quot;640&quot; height=&quot;480&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I spent last weekend in Bondi for the annual Bowlarama competition. It was a blast and I managed to do a write up for Caught in the Crossfire. &lt;a href=&quot;http://caughtinthecrossfire.com/skate/features/10344&quot; target=&quot;_blank&quot;&gt;You can read it here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I also met &lt;a href=&quot;http://www.flickr.com/photos/navitronic/4390728839/&quot;&gt;Steve Caballero&lt;/a&gt; and &lt;a href=&quot;http://www.flickr.com/photos/navitronic/4390728325/&quot;&gt;Lance Mountain&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://sambarkerphotography.blogspot.com/&quot; target=&quot;_blank&quot;&gt;Photos by Sam Barker.&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Let me help!</title>
    <link href="http://navitronic.co.uk/2010/01/let-me-help/"/>
    <updated>2010-01-31T06:18:55+11:00</updated>
    <id>http://navitronic.co.uk/2010/01/let-me-help</id>
    <content type="html">&lt;p&gt;&lt;a href=&quot;http://www.flickr.com/photos/navitronic/4317399145/&quot; title=&quot;Kitteh wants moleskine by navitronic, on Flickr&quot;&gt;&lt;img src=&quot;http://farm5.static.flickr.com/4019/4317399145_456705d2da.jpg&quot; width=&quot;500&quot; height=&quot;375&quot; alt=&quot;Kitteh wants moleskine&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Abyss</title>
    <link href="http://navitronic.co.uk/2010/01/abyss/"/>
    <updated>2010-01-25T05:22:38+11:00</updated>
    <id>http://navitronic.co.uk/2010/01/abyss</id>
    <content type="html">&lt;p&gt;&lt;a title=&quot;CNV00026 by navitronic, on Flickr&quot; href=&quot;http://www.flickr.com/photos/navitronic/206756677/&quot;&gt;&lt;img src=&quot;http://farm1.static.flickr.com/65/206756677_d08b77cfbe.jpg&quot; alt=&quot;CNV00026&quot; width=&quot;500&quot; height=&quot;334&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Pigeon</title>
    <link href="http://navitronic.co.uk/2010/01/pigeon/"/>
    <updated>2010-01-24T05:22:15+11:00</updated>
    <id>http://navitronic.co.uk/2010/01/pigeon</id>
    <content type="html">&lt;p&gt;&lt;a title=&quot;Pigeon by navitronic, on Flickr&quot; href=&quot;http://www.flickr.com/photos/navitronic/206756755/&quot;&gt;&lt;img src=&quot;http://farm1.static.flickr.com/62/206756755_cab57caa0d.jpg&quot; alt=&quot;Pigeon&quot; width=&quot;500&quot; height=&quot;334&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Thorn</title>
    <link href="http://navitronic.co.uk/2010/01/thorn/"/>
    <updated>2010-01-08T00:12:23+11:00</updated>
    <id>http://navitronic.co.uk/2010/01/thorn</id>
    <content type="html">&lt;p&gt;http://www.youtube.com/watch?v=DYp2LGKOF_M&lt;/p&gt;

&lt;p&gt;&lt;em&gt;(Testing Wordpress's oEmbed support...)&lt;/em&gt;&lt;/p&gt;
</content>
  </entry>
  
</feed>

