<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>robertomurray.co.uk</title>
	<atom:link href="http://robertomurray.co.uk/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://robertomurray.co.uk/blog</link>
	<description>blogging, mapping and travelling from a network engineer in UK</description>
	<lastBuildDate>Wed, 22 May 2013 17:24:19 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Implementing an Enum in PHP</title>
		<link>http://robertomurray.co.uk/blog/2013/implementing-an-enum-in-php/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=implementing-an-enum-in-php</link>
		<comments>http://robertomurray.co.uk/blog/2013/implementing-an-enum-in-php/#comments</comments>
		<pubDate>Sun, 05 May 2013 17:12:32 +0000</pubDate>
		<dc:creator>rob</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://robertomurray.co.uk/blog/?p=838</guid>
		<description><![CDATA[A quick PHP example; how to implement an Enum. PHP lacks this useful feature so this is a bit of a hack to emulate an Enum. &#160; Example below with an example of usage; &#160; &#160;]]></description>
				<content:encoded><![CDATA[<p class="lead">A quick PHP example; how to implement an Enum. PHP lacks this useful feature so this is a bit of a hack to emulate an Enum.</p>
<p>&nbsp;</p>
<p>Example below with an example of usage;<br />
<script src="https://gist.github.com/5516919.js"></script><noscript><pre><code class="language-php php">&lt;?php

namespace Company\AppName\PackageName;

/**
 * SystemProperty is designed as an enum
 *
 * Example usage:
 * &lt;code&gt;
 * echo SystemProperty::A_PROPERTY_VALUE;
 * &lt;/code&gt;
 *
 * @author rmurray
 */
final class SystemProperty {
    
    /**
     * The xxx property, I think you will like it.
     * 
     * @var string
     */
    const A_PROPERTY_VALUE = 'wow-this-is-amazing';
    
    
    /* block instantiation */
    protected function __construct() {}
}</code></pre></noscript></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://robertomurray.co.uk/blog/2013/implementing-an-enum-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP PDO Connection class</title>
		<link>http://robertomurray.co.uk/blog/2013/php-pdo-connection-class/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=php-pdo-connection-class</link>
		<comments>http://robertomurray.co.uk/blog/2013/php-pdo-connection-class/#comments</comments>
		<pubDate>Sun, 28 Apr 2013 09:50:32 +0000</pubDate>
		<dc:creator>rob</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://robertomurray.co.uk/blog/?p=832</guid>
		<description><![CDATA[A useful, perhaps, class for database connections using the PHP PDO library: PDOConnection.php &#160; Singleton implementation with the class method getConnection() returning a \PDO connection with connection details; &#160; &#160; &#160; &#160;]]></description>
				<content:encoded><![CDATA[<p class="lead">A useful, perhaps, class for database connections using the PHP PDO library: <a title="PDOConnection.php" href="https://gist.github.com/rob-murray/5454707" target="_blank">PDOConnection.php</a></p>
<p>&nbsp;</p>
<p>Singleton implementation with the class method getConnection() returning a \PDO connection with connection details;</p>
<p>&nbsp;</p>
<p>&nbsp;<br />
<script src="https://gist.github.com/5454707.js"></script><noscript><pre><code class="language-php php">&lt;?php

namespace ACompany\AnAppName\Dao;

/**
 * PDOConnection is a singleton implementation.
 * getConnection() returning an instance of PDO connection.
 * 
 * &lt;code&gt;
 * Example usage:
 * 
 * $pdo = PDOConnection::instance();
 * $conn = $pdo-&gt;getConnection( 'dsn', 'username', 'password' );
 *    
 * $results = $conn-&gt;exec(&quot;SELECT * FROM Table&quot;);
 * 
 * &lt;/code&gt;
 *
 * @author rmurray
 */
class PDOConnection {
    
    /**
     * singleton instance
     * 
     * @var PDOConnection 
     */
    protected static $_instance = null;

    /**
     * Returns singleton instance of PDOConnection
     * 
     * @return PDOConnection 
     */
    public static function instance() {
        
        if ( !isset( self::$_instance ) ) {
            
            self::$_instance = new PDOConnection();
            
        }
        
        return self::$_instance;
    }
    
    /**
     * Hide constructor, protected so only subclasses and self can use
     */
    protected function __construct() {}
    
    function __destruct(){}
    
    /**
     * Return a PDO connection using the dsn and credentials provided
     * 
     * @param string $dsn The DSN to the database
     * @param string $username Database username
     * @param string $password Database password
     * @return PDO connection to the database
     * @throws PDOException
     * @throws Exception
     */
    public function getConnection($dsn, $username, $password) {
        
        $conn = null;
        try {
            
            $conn = new \PDO($dsn, $username, $password);
            
            //Set common attributes
            $conn-&gt;setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
            
            return $conn;
            
        } catch (PDOException $e) {
            
            //TODO: flag to disable errors?
            throw $e;
            
        }
        catch(Exception $e) {
            
            //TODO: flag to disable errors?
            throw $e;
            
        }
    }
    
    /** PHP seems to need these stubbed to ensure true singleton **/
    public function __clone()
    {
        return false;
    }
    public function __wakeup()
    {
        return false;
    }
}</code></pre></noscript></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://robertomurray.co.uk/blog/2013/php-pdo-connection-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More photos from Borneo</title>
		<link>http://robertomurray.co.uk/blog/2013/more-photos-from-borneo/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=more-photos-from-borneo</link>
		<comments>http://robertomurray.co.uk/blog/2013/more-photos-from-borneo/#comments</comments>
		<pubDate>Fri, 29 Mar 2013 19:35:11 +0000</pubDate>
		<dc:creator>rob</dc:creator>
				<category><![CDATA[Photography]]></category>
		<category><![CDATA[robertomurray.co.uk]]></category>

		<guid isPermaLink="false">http://robertomurray.co.uk/blog/?p=806</guid>
		<description><![CDATA[Recently uploaded some more photos from the latest holiday in Borneo; I have used some of the effects in Picasa in an attempt to enhance some of the photos! The full gallery is here. &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;]]></description>
				<content:encoded><![CDATA[<p class="lead">Recently uploaded some more photos from the latest holiday in <a title="Borneo travel page" href="http://robertomurray.co.uk/travels/borneo">Borneo</a>; I have used some of the effects in Picasa in an attempt to enhance some of the photos! The full gallery is <a title="Photo gallery of Borneo holiday" href="https://plus.google.com/u/0/photos/110615100250851207372/albums/5853663899717764593" target="_blank">here</a>.</p>
<p>&nbsp;</p>
<p><a href="http://robertomurray.co.uk/blog/2013/more-photos-from-borneo/sunrise-from-mount-kinabalu/" rel="attachment wp-att-812"><img class="aligncenter size-full wp-image-812" alt="Sunrise from Mount Kinabalu" src="http://rmweb-wp.s3.amazonaws.com/blog/wp-content/uploads/2013/03/BORNEO-122_2.jpg" /></a><br />
&nbsp;</p>
<a href="http://robertomurray.co.uk/blog/2013/more-photos-from-borneo/mabul-island-celebes-sea/" rel="attachment wp-att-813"><img class="aligncenter size-medium wp-image-813" alt="Mabul island, Celebes sea" src="http://rmweb-wp.s3.amazonaws.com/blog/wp-content/uploads/2013/03/BORNEO-272_2.jpg" /></a>
<p>&nbsp;</p>
<p>&nbsp;</p>
<a href="http://robertomurray.co.uk/blog/2013/more-photos-from-borneo/sunset-over-mabul-island-celebes-sea/" rel="attachment wp-att-814"><img class="aligncenter size-medium wp-image-814" alt="Sunset over Mabul island, Celebes sea" src="http://rmweb-wp.s3.amazonaws.com/blog/wp-content/uploads/2013/03/BORNEO-315_2.jpg" /></a>
<p>&nbsp;</p>
<p>&nbsp;</p>
<a href="http://robertomurray.co.uk/blog/2013/more-photos-from-borneo/sunset-sky-mabul-island-celebes-sea/" rel="attachment wp-att-815"><img class="aligncenter size-medium wp-image-815" alt="Sunset sky, Mabul island, Celebes sea" src="http://rmweb-wp.s3.amazonaws.com/blog/wp-content/uploads/2013/03/BORNEO-319_2.jpg" /></a>
<p>&nbsp;<br />
<a href="http://robertomurray.co.uk/blog/2013/more-photos-from-borneo/china-town-area-singapore/" rel="attachment wp-att-816"><img class="aligncenter size-medium wp-image-816" alt="China town area, Singapore" src="http://rmweb-wp.s3.amazonaws.com/blog/wp-content/uploads/2013/03/BORNEO-367_2.jpg" /></a><br />
&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://robertomurray.co.uk/blog/2013/more-photos-from-borneo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Photos from Borneo</title>
		<link>http://robertomurray.co.uk/blog/2013/photos-from-borneo/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=photos-from-borneo</link>
		<comments>http://robertomurray.co.uk/blog/2013/photos-from-borneo/#comments</comments>
		<pubDate>Fri, 22 Mar 2013 14:27:27 +0000</pubDate>
		<dc:creator>rob</dc:creator>
				<category><![CDATA[Borneo 2013]]></category>
		<category><![CDATA[Photography]]></category>
		<category><![CDATA[robertomurray.co.uk]]></category>

		<guid isPermaLink="false">http://robertomurray.co.uk/blog/?p=796</guid>
		<description><![CDATA[My photos from Borneo holiday have been sorted out and uploaded so check them out or on Google+. &#160; Sabah region \ Malaysia \ Borneo \ Asia &#160; I have to say that it was one of my favourite holidays; this being down to a few things such as this area of Malaysian Borneo being...  <a href="http://robertomurray.co.uk/blog/2013/photos-from-borneo/" class="more-link" title="Read Photos from Borneo">Read more &#187;</a>]]></description>
				<content:encoded><![CDATA[<p class="lead">My photos from<a class="map-link" title="Details about my Borneo holiday" href="http://robertomurray.co.uk/travels/borneo"> Borneo holiday</a> have been sorted out and uploaded so <a class="photo-link" title="Photo gallery of Borneo holiday" href="http://robertomurray.co.uk/gallery/27-borneo">check them out</a> or on <a title="My Borneo photos on Google+" href="https://plus.google.com/u/0/photos/110615100250851207372/albums/5853663899717764593" target="_blank">Google+</a>.</p>
<h4></h4>
<p>&nbsp;</p>
<h3>Sabah region \ Malaysia \ Borneo \ Asia</h3>
<p>&nbsp;</p>
<p>I have to say that it was one of my favourite holidays; this being down to a few things such as this area of Malaysian Borneo being a wonderful country, lovely and friendly people and the activities and experiences had there were fantastic. The country was beautiful (mostly; see below) and it has everything from coral reefs around the coast, through dense jungle rainforests to high mountains &#8211; every type of terrain and I had the pleasure to see examples of them all. As I travelled through their country I was welcomed everywhere, not because of money but just because I was there &#8211; this is rare thing these days, enjoy and cherish it where you can. We were given help and advice in many situations for no reason other than the generosity of the people there &#8211; many countries, UK included can learn a lot from this positive, friendly atmosphere.</p>
<p>In our time in Borneo we managed to fit a lot of varying experiences in, through good planning and a lot of travelling these all came off without a problem. Not the most relaxing of holidays but worth when you consider we climbed a mountain, trekked through proper jungle and crammed in 13 dives, some of them often voted in the top 5 dives in the world. Proud and pleased to complete everything and survive!</p>
<p>&lt;Rant&gt;</p>
<p>OK, if the holiday was as perfect as it sounds then something would be wrong with the world &#8211; the downside I saw in Borneo was that the rest of the world has and still is taking advantage of Borneo and destroying it.</p>
<p>Rainforests are being cut down to make way for Palm Oil plantations; vast areas of rainforest is cut down every year and millions of palm trees go up in its place. You may think that these are vegetation too and what&#8217;s the problem? Well, its very well documented elsewhere what the problems are with this; wildlife is displaced by chopping down the rainforest, they cant live in palm trees, lots of chemicals are used on the plantations both on the crop and in processing the seeds into oil. Anyone who thinks palm oil and biofuels (produced from palm oil) are OK is wrong, they are destroying parts of the world while other parts of the world just keep using more and more &#8211; i&#8217;m looking at you USA and China.</p>
<p>The seas and fishing; wildlife in the seas isn&#8217;t faring any better than that on land, large scale, corporate, unsustainable fishing is sweeping the oceans clean and at the same time small scale local fishermen are doing whatever they can to make a living. This is often catching endangered species because they sell for a lot of money or fishing with dynamite or chemicals in order to catch more because they are forced to sell at low prices due to the large scale fishing. Fishing, and any other type of farming is OK if it is sustainable &#8211; it rarely is though.</p>
<p>&lt;/Rant&gt;</p>
<p>&nbsp;</p>
<a href="http://robertomurray.co.uk/blog/2013/photos-from-borneo/looking-down-on-laban-rata-guesthouse-mount-kinabalu/" rel="attachment wp-att-801"><img class="aligncenter size-full wp-image-801" alt="Looking down on Laban Rata guesthouse, Mount Kinabalu" src="http://rmweb-wp.s3.amazonaws.com/blog/wp-content/uploads/2013/03/BORNEO-119_sm.jpg" /></a>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>PS. Visit Borneo!</p>
]]></content:encoded>
			<wfw:commentRss>http://robertomurray.co.uk/blog/2013/photos-from-borneo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Borneo challenges</title>
		<link>http://robertomurray.co.uk/blog/2013/borneo-challenges/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=borneo-challenges</link>
		<comments>http://robertomurray.co.uk/blog/2013/borneo-challenges/#comments</comments>
		<pubDate>Wed, 27 Feb 2013 10:08:13 +0000</pubDate>
		<dc:creator>rob</dc:creator>
				<category><![CDATA[Borneo 2013]]></category>

		<guid isPermaLink="false">http://robertomurray.co.uk/blog/?p=781</guid>
		<description><![CDATA[When I first went travelling an Internet connection was not too common, a working Internet connection even less so but here I am in a (reasonably) remote part of borneo typing this in a cafe on an iPad! How times have changed! I used to frown upon backpackers with over exuberant technology, it was a...  <a href="http://robertomurray.co.uk/blog/2013/borneo-challenges/" class="more-link" title="Read Borneo challenges">Read more &#187;</a>]]></description>
				<content:encoded><![CDATA[<p class="lead">When I first went travelling an Internet connection was not too common, a working Internet connection even less so but here I am in a (reasonably) remote part of borneo typing this in a cafe on an iPad! How times have changed! I used to frown upon backpackers with over exuberant technology, it was a target for thieves, unnecessary luggage and I never took anything that couldn&#8217;t be replaced half way round. But I have swayed ands and the pad has become an important backpacking essential now!</p>
<p>&nbsp;</p>
<p>So, I am in Borneo and the challenge has not been Internet connections, these have popped up everywhere, often in the most unexpected shops, cafes and hostels. The challenge has been fitting everything in that we planned and the rain! We are halfway through the holiday and it has been hectic but worked out OK so far having started with a day of luxury in Singapore &#8211; I broke the law here by bringing in chewing gum but luckily was not caught. We have now made it almost to the the final place in Borneo; Palau Mabul &#8211; an island off Semporna on the north east Malaysian district of Sabah.</p>
<p>&nbsp;</p>
<p>We have travelled from the west coast city of Kota Kinabalu to here and crammed in a lot in the week; have climbed 4095 metres of Mount Kinabalu, visited Orang utan sanctuary, been on river safaris in the jungle and got wet. It seems the wet season lasted a bit longer and it rains at random inconvenient intervals but at least it&#8217;s warm rain, and not snow.</p>
<p>&nbsp;</p>
<p>Next up is a few days diving in one of the worlds top scuba diving spots with turtles, rays and sharks common before a trip back to Singapore and then home. Will have to get rid of that illegal chewing gum first.</p>
]]></content:encoded>
			<wfw:commentRss>http://robertomurray.co.uk/blog/2013/borneo-challenges/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>IP Addressing and Connectivity application &#8211; IPAC</title>
		<link>http://robertomurray.co.uk/blog/2013/ip-addressing-and-connectivity-application-ipac/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ip-addressing-and-connectivity-application-ipac</link>
		<comments>http://robertomurray.co.uk/blog/2013/ip-addressing-and-connectivity-application-ipac/#comments</comments>
		<pubDate>Sun, 17 Feb 2013 18:15:24 +0000</pubDate>
		<dc:creator>rob</dc:creator>
				<category><![CDATA[IPAC]]></category>
		<category><![CDATA[IP address management]]></category>

		<guid isPermaLink="false">http://robertomurray.co.uk/blog/?p=773</guid>
		<description><![CDATA[A preliminary article here about a current project I have resurrected recently; IPAC &#8211; IP Addressing and Connectivity management application. It is a web based application backed by a database to manage an organisation&#8217;s network focussing on Host connectivity and IP addressing. The reason this application exists is the lack of an existing equivalent; a...  <a href="http://robertomurray.co.uk/blog/2013/ip-addressing-and-connectivity-application-ipac/" class="more-link" title="Read IP Addressing and Connectivity application &#8211; IPAC">Read more &#187;</a>]]></description>
				<content:encoded><![CDATA[<p class="lead">A preliminary article here about a current project I have resurrected recently; IPAC &#8211; IP Addressing and Connectivity management application.</p>
<p>It is a web based application backed by a database to manage an organisation&#8217;s network focussing on Host connectivity and IP addressing. The reason this application exists is the lack of an existing equivalent; a while ago during my time working in a Network Operations team I spent a some time searching for decent applications to manage our IT infrastructure including everything from switches, routers, servers to management equipment. There were several almost suitable applications but nothing that concentrated on how your host was connected and it&#8217;s interface&#8217;s IP addresses were managed and that which also fitted our workflow, allowing a host to be created and allocated an IP address.</p>
<p>&nbsp;</p>
<p>We needed something that managed the host / IP address / network switch relationship, in the IPAC model a Host entity has many Interfaces, these are physical or virtual interfaces such as a NIC on a server. These Interfaces then have IP Addresses which are part of a Subnet which in turn is allocated to a VLAN. All these entities then sit under one site, therefore allowing you to manage multiple sites of distinct or connected networks.</p>
<p>&nbsp;</p>
<p>IPAC; the application is still immature and in the early stages of development but it is truly open source and I welcome contributions &#8211; this, I believe will allow the application to grow and improve. I have released the project on <a title="Github.com" href="https://github.com" target="_blank">github.com</a> and under the GNU General Public License, anyone can take my code and use it, improve on it, etc but just don&#8217;t try and make some money without recognising my work.</p>
<p>&nbsp;</p>
<a href="http://robertomurray.co.uk/blog/2013/ip-addressing-and-connectivity-application-ipac/ipac-scr-shot1/" rel="attachment wp-att-774"><img class="aligncenter size-full wp-image-774" alt="ip addressing and connectivity image" src="http://rmweb-wp.s3.amazonaws.com/blog/wp-content/uploads/2013/02/ipac-scr-shot1.png" /></a>
<p>&nbsp;</p>
<h4>Features</h4>
<p>&nbsp;</p>
<p>Here are some of the features available</p>
<ul>
<li>Site based architecture</li>
<li>Multiple VLANs per site</li>
<li>Hosts with configurable interfaces</li>
<li>Manage subnets</li>
<li>Set host IP address or get the next available</li>
<li>User authentication, control access to sections</li>
<li>Audit trail of activity and changes</li>
</ul>
<p>&nbsp;</p>
<h4>Pre-requisites</h4>
<p>&nbsp;</p>
<p>To use this software you need to build and run it &#8211; more details coming up but basically just a few things:</p>
<ul>
<li>JDK &gt;=1.7.x</li>
<li>PostgreSQL &gt;=9.1</li>
<li>Application servers &#8211; Does not require full JEE compliant app server; Apache Tomcat &gt;=7.0 and Maven Jetty are fine and tested</li>
<li>Apache Maven ~3</li>
</ul>
<p>&nbsp;</p>
<p>You can <a title="IPAC - IP Addressing and Connectivity application" href="https://github.com/rob-murray/ipac" target="_blank">use, view or contribute to the IPAC</a>.</p>
<p>&nbsp;</p>
<p>The IPAC is currently in early development, it does build and work just with limited functionality but I will be working on the IPAC over the next few months and hope to get a working demo available soon.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://robertomurray.co.uk/blog/2013/ip-addressing-and-connectivity-application-ipac/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Objective C Prefix headers file wrongs</title>
		<link>http://robertomurray.co.uk/blog/2013/objective-c-prefix-headers-file-wrongs/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=objective-c-prefix-headers-file-wrongs</link>
		<comments>http://robertomurray.co.uk/blog/2013/objective-c-prefix-headers-file-wrongs/#comments</comments>
		<pubDate>Fri, 01 Feb 2013 13:29:20 +0000</pubDate>
		<dc:creator>rob</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Objective C]]></category>

		<guid isPermaLink="false">http://robertomurray.co.uk/blog/?p=734</guid>
		<description><![CDATA[TL ; DR &#160; Do not use the Xcode automatically generated Prefix headers (.pch) file and the preprocessor for constants, configuration, environment settings, etc &#8211; The name gives away its purpose, it is not called Prefix headers and configuration settings. Best practice; if you have to share constants between classes then create something like a Constants class by subclassing...  <a href="http://robertomurray.co.uk/blog/2013/objective-c-prefix-headers-file-wrongs/" class="more-link" title="Read Objective C Prefix headers file wrongs">Read more &#187;</a>]]></description>
				<content:encoded><![CDATA[<h3>TL ; DR</h3>
<p class="lead">&nbsp;</p>
<p>Do not use the Xcode automatically generated Prefix headers (.pch) file and the preprocessor for constants, configuration, environment settings, etc &#8211; The name gives away its purpose, it is not called Prefix headers and configuration settings. Best practice; if you have to share constants between classes then create something like a <code>Constants</code> class by subclassing <code>NSObject</code> and store any constants or settings there and then use the Prefix header file to import that class &#8211; stay in Objective C or C.</p>
<p>&nbsp;</p>
<h3>Intro</h3>
<p>&nbsp;</p>
<p>I have recently seen an iOS project with a Prefix headers file containing 400 lines of code, 10 preprocessor if statements with a maximum depth of if statements of 3.</p>
<ol>
<li>It looks terrible and is hard to read</li>
<li>Each change requires the whole project recompiled</li>
<li>To switch environments or change a setting dynamically requires preprocessor statements</li>
</ol>
<p>A better idea would be to go back to Objective C land and use <code>static const</code> to define your constants &#8211; here the <code>static</code> part sets or limits the scope of the variable to that compilation unit, think class, method. The <code>const</code> tells the compiler not to let anything change it.</p>
<p>&nbsp;</p>
<h3>Class Constants</h3>
<p>&nbsp;</p>
<p>If the constant is only used in one class then why not keep the constant in that class? Make it easy for someone coming in to work on your code by keeping related items together, its likely they will be jumping about around over class files anyway so help them out a little by reducing one switch to the .pch file.</p>
<p>BTW; Don&#8217;t forget to follow <a title="Apples coding guidelines" href="http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingBasics.html#//apple_ref/doc/uid/20001281-BBCHBFAH" target="_blank">Apple&#8217;s coding guidelines</a> for naming conventions!<br />
<script src="https://gist.github.com/4691225.js"></script><noscript><pre><code class="language-c c">// ExampleViewController.m

/*
 * Define class constants a top of @implementation
 */
static const NSString * kRMMyViewTitle = @&quot;Amazing App Home&quot;;

@implementation ExampleViewController


// ... //


- (void)myMethod
{
    NSLog(@&quot;%@&quot;, kRMMyViewTitle);
}</code></pre></noscript></p>
<p>&nbsp;</p>
<h3>Global Constants</h3>
<p>&nbsp;</p>
<p>If you need something across the project then create a class to define them, subclass NSObject and implement the constants. Then use the prefix header for what it is meant for by adding the import statement to every class.</p>
<p>&nbsp;<br />
<script src="https://gist.github.com/4691299.js"></script><noscript><pre><code class="language-c c">//Configuration.h

#import &lt;Foundation/Foundation.h&gt;

@interface Configuration : NSObject

extern NSString *const kRMAWebServiceURL;

extern const NSTimeInterval kRMTimeoutValue;

@end

//Configuration.m
#import &quot;Configuration.h&quot;

@implementation Configuration

NSString *const kRMAWebServiceURL = @&quot;http://mywebservice.com&quot;;

const NSTimeInterval kRMTimeoutValue = 90;

@end

// AppName-Prefix.pch

// ... //

#ifdef __OBJC__
    #import &lt;UIKit/UIKit.h&gt;
    #import &lt;Foundation/Foundation.h&gt;
    #import &quot;Configuration.h&quot;
#endif

// ... //


/*
 * Usage
 */

// Afile.m

- (void)aMethodThatDoesSomething
{

    NSLog(@&quot;%@&quot;, kRMAWebServiceURL);
    NSLog(@&quot;%f&quot;, kRMTimeoutValue);

}</code></pre></noscript><br />
&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://robertomurray.co.uk/blog/2013/objective-c-prefix-headers-file-wrongs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mapping BBC Price of Football survey</title>
		<link>http://robertomurray.co.uk/blog/2012/mapping-bbc-price-of-football-survey/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mapping-bbc-price-of-football-survey</link>
		<comments>http://robertomurray.co.uk/blog/2012/mapping-bbc-price-of-football-survey/#comments</comments>
		<pubDate>Wed, 24 Oct 2012 08:50:59 +0000</pubDate>
		<dc:creator>rob</dc:creator>
				<category><![CDATA[Football]]></category>
		<category><![CDATA[Mapping]]></category>
		<category><![CDATA[Open Data]]></category>
		<category><![CDATA[OpenLayers]]></category>

		<guid isPermaLink="false">http://robertomurray.co.uk/blog/?p=709</guid>
		<description><![CDATA[The BBC have released results of a survey undertaken in 2012 involving 166 clubs in 10 divisions across British football, including the Conference Premier and Women&#8217;s Super League gathering the prices for the most expensive, and cheapest, season tickets and adult matchday tickets along with a programme and some say, most importantly a pie and tea. The...  <a href="http://robertomurray.co.uk/blog/2012/mapping-bbc-price-of-football-survey/" class="more-link" title="Read Mapping BBC Price of Football survey">Read more &#187;</a>]]></description>
				<content:encoded><![CDATA[<p class="lead">The BBC have released results of a survey undertaken in 2012 involving 166 clubs in 10 divisions across British football, including the Conference Premier and Women&#8217;s Super League gathering the prices for the most expensive, and cheapest, season tickets and adult matchday tickets along with a programme and some say, most importantly a pie and tea. The results have been published on the <a title="BBC Price of Football 2012" href="http://www.bbc.co.uk/news/uk-19842397" target="_blank">BBC website</a> but I notice two problems;</p>
<ul>
<li>The raw data has not been released minimising new visualisations of the results</li>
<li>The results are not geographically displayed</li>
</ul>
<p>I have grabbed their results and geolocated all 166 clubs, this then enables you to plot the data on a map (in this case via <a title="Ordnance Survey OpenSpace" href="http://www.ordnancesurvey.co.uk/oswebsite/web-services/os-openspace/api/index.html" target="_blank">Ordnance Survey OpenSpace</a>) as I have <a title="BBC Price of Football 2012 mapped" href="http://maps.robertomurray.co.uk/pof-2012">done in my app</a>.</p>
<p>&nbsp;</p>
<div id="attachment_711" class="wp-caption aligncenter" style="width: 414px"><a title="BBC Price of Football mapped" href="http://maps.robertomurray.co.uk/pof-2012" rel="attachment wp-att-711"><img class="size-full wp-image-711" title="pof-2012-scr" alt="BBC Price of Football 2012 mapped" src="http://rmweb-wp.s3.amazonaws.com/blog/wp-content/uploads/2012/10/pof-2012-scr.png" width="404" height="204" /></a><p class="wp-caption-text">BBC Price of Football 2012 mapped</p></div>
<p>&nbsp;</p>
<h4>Creating the map</h4>
<dl>
<dt>Get the BBC data</dt>
<dd>Simple script to scrape the BBC webpage and output the table data into CSV</dd>
<dd></dd>
<dt>Geocode the clubs</dt>
<dd>I found a source of all address of Football clubs so easy to geocode this via Ordnance Survey data</dd>
<dd></dd>
<dt>Format the data</dt>
<dd>I output the data in geoJSON which is easy to integrate into OpenLayers and allowed me to store the club price data as feature attributes</dd>
<dd></dd>
<dt>Display the data</dt>
<dd>The map is using OpenLayers and Ordnance Survey OpenSpace mapping, the geoJSON is read on page load and displayed as styled vectors</dd>
</dl>
<p>&nbsp;</p>
<h4>Results</h4>
<p>So what do the results show? There has always been talk of a north/south divide in football, and indeed GB in general but the results show that this is not the case, yes the most expensive tickets are in the South but the North has its share too. I think basically the &#8216;big&#8217; clubs charge big money no matter where they are, now if you could also quantify and display value for money then that would be a useful graphic.</p>
<p>For football fans, I suppose one use of this map could be to decide where you will watch your football, you could find the cheapest clubs around you and then decide where you part with your cash. Just because &#8216;big&#8217; clubs charge so much for match tickets and related items doesn&#8217;t mean you have to pay it in order to view live football.<br />
@datasource: via <a title="BBC Price of Football Source data 2012" href="https://docs.google.com/spreadsheet/ccc?key=0Aox8knJZwgFBdHdKV3NvcVhtSnlob2hkeWtMWnVMN0E" target="_blank">Google Docs</a></p>
]]></content:encoded>
			<wfw:commentRss>http://robertomurray.co.uk/blog/2012/mapping-bbc-price-of-football-survey/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mapping #OpFortress tweets</title>
		<link>http://robertomurray.co.uk/blog/2012/mapping-opfortress-tweets/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mapping-opfortress-tweets</link>
		<comments>http://robertomurray.co.uk/blog/2012/mapping-opfortress-tweets/#comments</comments>
		<pubDate>Sun, 07 Oct 2012 14:20:19 +0000</pubDate>
		<dc:creator>rob</dc:creator>
				<category><![CDATA[Mapping]]></category>
		<category><![CDATA[Open Data]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://robertomurray.co.uk/blog/?p=697</guid>
		<description><![CDATA[The Twitter hashtag #OpFortress refers to Operation Fortress, a Hampshire Police operation to reduce crime in Southampton. The police force have been Tweeting about it, reporting updates, arrests, raids or crimes &#8211; with road names in the Tweets. Road name = location data&#8230; Location data = mapping visualisation. An ideal method to visualise where the...  <a href="http://robertomurray.co.uk/blog/2012/mapping-opfortress-tweets/" class="more-link" title="Read Mapping #OpFortress tweets">Read more &#187;</a>]]></description>
				<content:encoded><![CDATA[<p class="lead">The Twitter hashtag #OpFortress refers to Operation Fortress, a Hampshire Police <a title="Operation fortress bbc article" href="http://www.bbc.co.uk/news/uk-england-hampshire-19421594" target="_blank">operation to reduce crime</a> in Southampton. The police force have been <a title="Twitter search for op fortress" href="https://twitter.com/i/#!/search/?q=opfortress" target="_blank">Tweeting</a> about it, reporting updates, arrests, raids or crimes &#8211; with road names in the Tweets. Road name = location data&#8230; Location data = mapping visualisation. An ideal method to visualise where the police are working in Southampton would be to plot these tweets on a map, all you need is location data.</p>
<p>&nbsp;</p>
<blockquote class="twitter-tweet" width="550"><p>13 arrested in 5 <a href="https://twitter.com/search/%23OpFortress">#OpFortress</a> raids in <a href="https://twitter.com/search/%23Southampton">#Southampton</a> yesterday on Northbrook Road, Atherley Road x2, Kern Close and Nelson Road</p>
<p>&mdash; Hampshire Police (@HantsPolice) <a href="https://twitter.com/HantsPolice/status/223450992266588161">July 12, 2012</a></p></blockquote>
<p><script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script></p>
<p>&nbsp;</p>
<div id="attachment_703" class="wp-caption aligncenter" style="width: 485px"><a title="Show map of operation fortress tweets" href="http://maps.robertomurray.co.uk/op-fortress" rel="attachment wp-att-703"><img class="size-full wp-image-703" title="op-fort-scrshot" src="http://rmweb-wp.s3.amazonaws.com/blog/wp-content/uploads/2012/10/op-fort-scrshot.png" alt="Operation fortress tweets visualised on map" width="475" height="316" /></a><p class="wp-caption-text">Operation fortress tweets visualised on map</p></div>
<p>&nbsp;</p>
<p>View the <a title="Show map of operation fortress tweets" href="http://maps.robertomurray.co.uk/op-fortress">map</a></p>
<p>&nbsp;</p>
<p>In order to visualise this unstructured data as the map above, there were a few operations of my own I had to step through so that I could plot the tweets correctly.</p>
<p>&nbsp;</p>
<dl>
<dt>Search all <a title="https://twitter.com/HantsPolice" href="https://twitter.com/HantsPolice" target="_blank">@HantsPolice</a> tweets for #OpFortress</dt>
<dd>Easy to do so with various libraries using the Twitter API</dd>
<dd></dd>
<dt>Identify road names in the Tweets and geolocate</dt>
<dd>Here I took each Tweet and ran them it a MySQL database using Full Text search on a table of Ordnance Survey <a title="OS Locator OpenData product" href="http://www.ordnancesurvey.co.uk/oswebsite/products/os-locator/index.html" target="_blank">OS Locator</a> data (Open Data). OS Locator is a gazetteer of road names allowed me to identify if Tweets contained road names and then get that road location.</dd>
<dd></dd>
<dt>Visualise</dt>
<dd>Simple case of plotting each Tweet that contained a road name in the location of that road. Again used OS and their OpenSpace web mapping service as the source for this.</dd>
</dl>
<p>&nbsp;</p>
<p><span style="text-decoration: underline;">Code</span>:</p>
<p>Here is a SQL <a title="SQL script to load OS Locator into MySQL" href="https://gist.github.com/3803657" target="_blank">script to load OS Locator</a> data into MySQL MyISAM table with Full Text index.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://robertomurray.co.uk/blog/2012/mapping-opfortress-tweets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mapping Mr Correcter tweets</title>
		<link>http://robertomurray.co.uk/blog/2012/mapping-mr-correcter-tweets/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mapping-mr-correcter-tweets</link>
		<comments>http://robertomurray.co.uk/blog/2012/mapping-mr-correcter-tweets/#comments</comments>
		<pubDate>Sat, 22 Sep 2012 17:49:48 +0000</pubDate>
		<dc:creator>rob</dc:creator>
				<category><![CDATA[Mapping]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://robertomurray.co.uk/blog/?p=685</guid>
		<description><![CDATA[As an update to a previous post about Mr Correcter, the Twitter spelling bot here is a post about how I managed to find and geolocate so many offenders. Quick update; Mr Correcter was a script that searched Twitter for 2x common spelling mistakes (beleive and acommodate) and replied back to the tweeter reminding them...  <a href="http://robertomurray.co.uk/blog/2012/mapping-mr-correcter-tweets/" class="more-link" title="Read Mapping Mr Correcter tweets">Read more &#187;</a>]]></description>
				<content:encoded><![CDATA[<p class="lead">As an update to a previous <a title="The Twitter account – Mr Correcter" href="http://robertomurray.co.uk/blog/2012/the-twitter-account-mr-correcter/">post</a> about <a title="Mr Correcter" href="https://twitter.com/Mr_Correcter" target="_blank">Mr Correcter</a>, the Twitter spelling bot here is a post about how I managed to find and geolocate so many offenders. Quick update; Mr Correcter was a script that searched Twitter for 2x common spelling mistakes (beleive and acommodate) and replied back to the tweeter reminding them of the spelling mistake.</p>
<p>Stats:</p>
<ul>
<li>Mr Correcter ran for a total of 9 days</li>
<li>Mr Correcter tweeted 246 times (236 of these were replies to spelling mistakes)</li>
<li>I was able to geolocate 105 of those Tweets programmatically</li>
</ul>
<div id="attachment_687" class="wp-caption aligncenter" style="width: 383px"><a title="Map of Mr Correcter tweets" href="http://maps.robertomurray.co.uk/mr-correcter" rel="attachment wp-att-687"><img class="size-full wp-image-687" title="map of mr-correcter tweets" src="http://rmweb-wp.s3.amazonaws.com/blog/wp-content/uploads/2012/09/mr-c-img.png" alt="map of mr-correcter tweets" width="373" height="266" /></a><p class="wp-caption-text">map of mr-correcter tweets</p></div>
<p>&nbsp;</p>
<p>I wanted to geolocate the offenders to generalise which part of the world was the worst at spelling, at least on social media anyway. I previously guessed America due to the number of replies back to Mr Correcter (see previous post for some amusing ones) and as you can see from the map, this turned out to be true.</p>
<p>&nbsp;</p>
<p><span style="text-decoration: underline;">How I gathered this information</span></p>
<p>I used three methods in this algorithm to identify where (lat, lng) these Tweets (or accounts) orginated;</p>
<p>&nbsp;</p>
<pre class="brush:php">if( the tweet has geolocation data available ){
  then use this
} elseif ( the user has geolocation data available on their account ){
  then use this data
} elseif ( the user has a location string set and this can be geolocated ){
  then use the geolocation of this
} else {
  unable to geotag the tweet
}</pre>
<p>&nbsp;</p>
<p>The obstacles were the Twitter API, getting some of this data is restricted to hourly limits so I had to use a cronjob to schedule the script and aggregate the data after completion.</p>
<p>&nbsp;</p>
<p>The script I used is <a title="basic script to scrape twitter for tweets specific to custom filter" href="https://gist.github.com/3739021" target="_blank">openly available</a>.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://robertomurray.co.uk/blog/2012/mapping-mr-correcter-tweets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
