<?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>/Gregular Expressions/</title>
	<atom:link href="http://www.gregularexpressions.co.uk/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gregularexpressions.co.uk</link>
	<description>Technology &#38; Life Related Musings</description>
	<lastBuildDate>Wed, 08 Feb 2012 20:31:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Cistec&#8217;s 0800 Pro</title>
		<link>http://www.gregularexpressions.co.uk/2012/02/cistecs-0800-pro/</link>
		<comments>http://www.gregularexpressions.co.uk/2012/02/cistecs-0800-pro/#comments</comments>
		<pubDate>Wed, 08 Feb 2012 20:30:07 +0000</pubDate>
		<dc:creator>Greg</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[0800]]></category>
		<category><![CDATA[0800 Pro]]></category>
		<category><![CDATA[App]]></category>
		<category><![CDATA[Cheap Calls]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://www.gregularexpressions.co.uk/?p=833</guid>
		<description><![CDATA[There&#8217;s quite a few &#8216;call 0800 numbers for free&#8217; apps out there, and most work but don&#8217;t do it particularly well. We thought we could improve on it. Let me know what you think. App Store Cistec Site]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s quite a few &#8216;call 0800 numbers for free&#8217; apps out there, and most work but don&#8217;t do it particularly well. We thought we could improve on it.</p>
<p>Let me know what you think.</p>
<p><a title="0800 Pro" href="http://bit.ly/ysP1wt" target="_blank">App Store</a><a title="0800 Pro" href="http://www.cistec.co.uk/0800-pro/" target="_blank"><br />
Cistec Site</a></p>
<p style="text-align: center;"><a href="http://bit.ly/ysP1wt"><img class="aligncenter  wp-image-834" title="0800 Pro" src="http://www.gregularexpressions.co.uk/wp-content/uploads/2012/02/0800ProPromo.png" alt="0800ProPromo Cistecs 0800 Pro" width="432" height="504" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gregularexpressions.co.uk/2012/02/cistecs-0800-pro/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CentOS Git server and OS X Client</title>
		<link>http://www.gregularexpressions.co.uk/2012/01/centos-git-server-and-os-x-client/</link>
		<comments>http://www.gregularexpressions.co.uk/2012/01/centos-git-server-and-os-x-client/#comments</comments>
		<pubDate>Sat, 07 Jan 2012 12:05:54 +0000</pubDate>
		<dc:creator>Greg</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Fedora]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[OS-X]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[OSX]]></category>
		<category><![CDATA[sourceTree]]></category>
		<category><![CDATA[xcode]]></category>

		<guid isPermaLink="false">http://www.gregularexpressions.co.uk/?p=812</guid>
		<description><![CDATA[Why? One of the things we needed to establish for Cistec App Development was some sort of remote version control. Up until now we&#8217;d been using the world renowned Dropbox for working on our projects but it had several issues (updated in realtime, so if you attempted to compile after a colleague made a typo..). ]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://www.gregularexpressions.co.uk/wp-content/uploads/2012/01/Screen-Shot-2012-01-07-at-11.41.36.png"><img class="wp-image-822 aligncenter" style="border-image: initial; border-width: 1px; border-color: black; border-style: solid;" title="SourceTreeGit" src="http://www.gregularexpressions.co.uk/wp-content/uploads/2012/01/Screen-Shot-2012-01-07-at-11.41.36.png" alt="Screen Shot 2012 01 07 at 11.41.36 CentOS Git server and OS X Client" width="529" height="245" /></a></p>
<h2>Why?</h2>
<p>One of the things we needed to establish for <a title="Cistec App Development - UK App Developers" href="http://www.cistec.co.uk" target="_blank">Cistec App Development</a> was some sort of remote version control. Up until now we&#8217;d been using the world renowned <a href="http://www.dropbox.com" target="_blank">Dropbox</a> for working on our projects but it had several issues (updated in realtime, so if you attempted to compile after a colleague made a typo..).</p>
<p>After some googling to decide between the two version control systems Xcode will integrate with (SVN and Git) we went with Git thanks to some strong opinions on StackOverflow.</p>
<p><span id="more-812"></span></p>
<h2>What?</h2>
<p>We have a hosted Linux server and we access the Git repos via SSH from a potential 6+ Macs currently. We did initially have access setup via the git:// protocol but there were complications securing this so we moved to SSH.</p>
<h2>How?</h2>
<h3>Server</h3>
<p>You may want to have a few Git users (read-only for example) but I&#8217;ll let you sort those out yourself.</p>
<blockquote><p><code>yum install git<br />
mkdir /home/git/coolNewProject<br />
cd /home/git/coolNewProject<br />
git init --bare<br />
</code></p></blockquote>
<p>Okay, so we&#8217;ve got the git infrastructure and a bare repo. The optional &#8211;bare means that the server doesn&#8217;t store a working copy, it just handles the source control. We found this to be easier.</p>
<h3>Client</h3>
<p>If you&#8217;ve got Xcode installed then you should have git already, failing that it&#8217;s available via Macports. Open the terminal and we&#8217;ll do some basic setup first:</p>
<blockquote><p><code>git config --global user.name "Your Name/Handle"<br />
git config --global user.email you@yourdomain.com<br />
</code></p></blockquote>
<p>Now, an optional step is to setup SSH keys so you don&#8217;t need to enter the server&#8217;s SSH password every time you use git. Here&#8217;s a brief overview:</p>
<blockquote><p><code>ssh-keygen (all defaults are fine)<br />
cat ~/.ssh/id_rsa.pub<br />
*copy the contents*<br />
ssh user@server<br />
nano/pico/vi ~/.ssh/authorized-keys (may not exist yet)<br />
*paste it in all on one line*<br />
</code></p></blockquote>
<p>Time to now pull down that nice Git repo you made, this will create a directory in your current directory so make sure you&#8217;re somewhere you want to keep your projects.</p>
<blockquote><p><code>git clone user@gitserver:/home/git/coolNewProject<br />
cd coolNewProject<br />
</code></p></blockquote>
<p>When working with Xcode we have to tell Git a few things to stop it getting confused:</p>
<blockquote><p><code>echo "*.pbxproj -crlf -diff -merge" &gt; .gitattributes<br />
nano/pico/vi .gitignore<br />
*paste the below in*<br />
-----------------------<br />
# xcode noise<br />
build/*<br />
*.pbxuser<br />
*.mode1v3<br />
UserInterfaceState.xcuserstate</code></p>
<p># old skool<br />
.svn</p>
<p># osx noise<br />
.DS_Store<br />
profile<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p></blockquote>
<p>Okay, almost ready to start using your new source control. We need do our initial add, commit and push. Copy your project into the coolNewProject directory or start a new Xcode project (without local git!).</p>
<blockquote><p><code>git add .<br />
git commit -a -m "Initial commit, repo setup."<br />
git push master<br />
</code></p></blockquote>
<p>That should be your new project files up on the server, ready for anyone else who needs to git clone them down. You can pull down any changes at any time by using &#8216;<code>git pull</code>&#8216;. It will warn you if there are conflicts etc.</p>
<p>The process for committing and pushing your changes from now on is slight shorter, new files added outside of Xcode will require you to do another &#8216;<code>git add .</code>&#8216; but Xcode takes care of that for you if you do it within it&#8217;s GUI.</p>
<blockquote><p><code>git commit -a -m "I made an awesome change to our cool new project"<br />
git push<br />
</code></p></blockquote>
<p>Xcode itself should pick up on the repo and you&#8217;ll be able to pull, commit and push via it&#8217;s source control bits (file-&gt;source control). Whilst Xcode is slower than the command line it&#8217;s conflict resolution is far superior so it&#8217;s worth using.</p>
<p>I find I use a combination of CLI, Xcode and <a href="http://itunes.apple.com/gb/app/sourcetree-git-hg/id411678673?mt=12" target="_blank">SourceTree</a> (free Git GUI, Mac app store) as they&#8217;re all good for different things.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gregularexpressions.co.uk/2012/01/centos-git-server-and-os-x-client/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Launched an App Development Company</title>
		<link>http://www.gregularexpressions.co.uk/2011/12/launched-an-app-development-company/</link>
		<comments>http://www.gregularexpressions.co.uk/2011/12/launched-an-app-development-company/#comments</comments>
		<pubDate>Sat, 10 Dec 2011 16:38:19 +0000</pubDate>
		<dc:creator>Greg</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[app development]]></category>
		<category><![CDATA[ios apps]]></category>
		<category><![CDATA[iPad apps]]></category>
		<category><![CDATA[iphone app development]]></category>
		<category><![CDATA[iphone apps]]></category>

		<guid isPermaLink="false">http://www.gregularexpressions.co.uk/?p=798</guid>
		<description><![CDATA[What A colleague and I have setup Cistec App Development for your app development needs. Why? The reasons are two fold: We enjoy app development. There&#8217;s some little bit of magic to good app development, even a small piece of clever UI design can make people smile. The company we were previously employed at doing iOS ]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;">
<p style="text-align: center;"><a href="http://www.cistec.co.uk"><img class="size-medium wp-image-805 aligncenter" title="CistecNoShadowWhite" src="http://www.gregularexpressions.co.uk/wp-content/uploads/2011/12/CistecNoShadowWhite-300x126.png" alt="CistecNoShadowWhite 300x126 Launched an App Development Company" width="300" height="126" /></a></p>
<h3>What</h3>
<p>A colleague and I have setup <a title="Cistec App Development" href="http://www.cistec.co.uk" target="_blank">Cistec App Development</a> for your app development needs.</p>
<h3>Why?</h3>
<p>The reasons are two fold:</p>
<ol>
<li>We enjoy app development. There&#8217;s some little bit of magic to good app development, even a small piece of clever UI design can make people smile.</li>
<li>The company we were previously employed at doing iOS development didn&#8217;t want to reassign resources to all the app development requests that were coming in.</li>
</ol>
<p>So, <a title="Contact Us" href="http://www.cistec.co.uk/contact-us/" target="_blank">drop us a line</a> if you&#8217;re thinking of having an app developed.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gregularexpressions.co.uk/2011/12/launched-an-app-development-company/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reduce search engine bot load without sacrificing all indexing</title>
		<link>http://www.gregularexpressions.co.uk/2011/10/reduce-search-engine-bot-load-without-sacrificing-all-indexing/</link>
		<comments>http://www.gregularexpressions.co.uk/2011/10/reduce-search-engine-bot-load-without-sacrificing-all-indexing/#comments</comments>
		<pubDate>Wed, 12 Oct 2011 22:04:11 +0000</pubDate>
		<dc:creator>Greg</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[defer bots]]></category>
		<category><![CDATA[high load]]></category>
		<category><![CDATA[search bots]]></category>

		<guid isPermaLink="false">http://www.gregularexpressions.co.uk/?p=760</guid>
		<description><![CDATA[Recently we had an overworked machine with around 60% of the traffic coming from search engine indexing bots. We needed to stabilise the load but didn&#8217;t want to sacrifice all indexing and thus our SEO entirely. This is the solution we came up with. First off we decided there were a few bots we could ]]></description>
			<content:encoded><![CDATA[<p>Recently we had an overworked machine with around 60% of the traffic coming from search engine indexing bots. We needed to stabilise the load but didn&#8217;t want to sacrifice all indexing and thus our SEO entirely.</p>
<p>This is the solution we came up with.<br />
<span id="more-760"></span></p>
<p>First off we decided there were a few bots we could live without so we added some .htaccess rules to 302 these away:</p>

<div class="wp_syntax"><div class="code"><pre class="apache"><span class="co1"># looking for majestic bot to kick it away.</span>
<span class="kw1">RewriteCond</span> %{HTTP_USER_AGENT} ^.*MJ12bot.*$ [NC]
<span class="kw1">RewriteRule</span> ^(.*)$ http://go.away/ [R=<span class="nu0">302</span>,L]
<span class="co1"># Ditto Yandex</span>
<span class="kw1">RewriteCond</span> %{HTTP_USER_AGENT} ^.*Yandex.*$ [NC]
<span class="kw1">RewriteRule</span> ^(.*)$ http://go.away/ [R=<span class="nu0">302</span>,L]
<span class="co1"># Ditto Baidu</span>
<span class="kw1">RewriteCond</span> %{HTTP_USER_AGENT} ^.*Baiduspider.*$ [NC]
<span class="kw1">RewriteRule</span> ^(.*)$ http://go.away/ [R=<span class="nu0">302</span>,L]</pre></div></div>

<p>But there were the larger more important ones that we wanted to just delay until less busy periods. Our solution was to 503 (temporarily unavailable) the requests with a header suggesting they come back in 12 hours:</p>

<div class="wp_syntax"><div class="code"><pre class="apache"><span class="co1"># Other bots we will allow, but during peak hours we will ask them to come back later.</span>
<span class="kw1">RewriteCond</span> %{HTTP_USER_AGENT} ^.*bot.*$ [NC]
<span class="kw1">RewriteCond</span> %{TIME_HOUR} ^08|09|<span class="nu0">10</span>|<span class="nu0">11</span>|<span class="nu0">12</span>|<span class="nu0">13</span>|<span class="nu0">14</span>|<span class="nu0">15</span>|<span class="nu0">16</span>|<span class="nu0">17</span>|<span class="nu0">18</span>|<span class="nu0">19</span>$
<span class="kw1">Header</span> set Retry-After: <span class="nu0">43200</span>
<span class="kw1">RewriteRule</span> .* - [R=<span class="nu0">503</span>,L]</pre></div></div>

<p>The above is by no means entirely foolproof as it&#8217;s reliant on the requesting bot having &#8216;bot&#8217; in it&#8217;s user-agent but we found it lowered the load significantly as soon as it was put live.</p>
<p>It did manifest one further problem in that our server is monitored by pingdom which does feature &#8216;bot&#8217; in it&#8217;s user agent as below:</p>

<div class="wp_syntax"><div class="code"><pre class="apache"><span class="st0">&quot;GET / HTTP/1.0&quot;</span> <span class="nu0">200</span> <span class="nu0">35120</span> <span class="st0">&quot;-&quot;</span> <span class="st0">&quot;Pingdom.com_bot_version_1.4_(http://www.pingdom.com/)&quot;</span> <span class="st0">&quot;www.domain.com&quot;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.gregularexpressions.co.uk/2011/10/reduce-search-engine-bot-load-without-sacrificing-all-indexing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use a SSH tunnel as a (Mac) system-wide SOCKS proxy to secure your traffic or bypass firewalls.</title>
		<link>http://www.gregularexpressions.co.uk/2011/10/use-a-ssh-tunnel-as-a-mac-system-wide-socks-proxy-to-secure-your-traffic-or-bypass-firewalls/</link>
		<comments>http://www.gregularexpressions.co.uk/2011/10/use-a-ssh-tunnel-as-a-mac-system-wide-socks-proxy-to-secure-your-traffic-or-bypass-firewalls/#comments</comments>
		<pubDate>Sat, 01 Oct 2011 14:42:48 +0000</pubDate>
		<dc:creator>Greg</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[OS-X]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[route all traffic via SSH]]></category>
		<category><![CDATA[socks]]></category>
		<category><![CDATA[ssh tunnel]]></category>

		<guid isPermaLink="false">http://www.gregularexpressions.co.uk/?p=748</guid>
		<description><![CDATA[Alright, so before you push on through this post lets cover some basic scenarios where-by this might be useful: You&#8217;re on an insecure network and want to prevent your traffic being snooped on. All your traffic will be sent over SSH so it&#8217;ll all be encrypted to the point that it leaves your tunnel end. ]]></description>
			<content:encoded><![CDATA[<p>Alright, so before you push on through this post lets cover some basic scenarios where-by this might be useful:</p>
<ol>
<li><strong>You&#8217;re on an insecure network and want to prevent your traffic being snooped on.</strong><br />
All your traffic will be sent over SSH so it&#8217;ll all be encrypted to the point that it leaves your tunnel end.</li>
<li><strong>You want to get local access to a work or home network that&#8217;s behind a firewall.</strong><br />
By tunnelling all your traffic through a host internal to that network requests will appear to come from it&#8217;s local address within that network, allowing you to access things you usually wouldn&#8217;t be able to remotely as if you were internal to the network.</li>
</ol>
<p>Amusingly this was actually the best explanatory image on the subject of SSH tunnelling I could find, courtesy of an Engadget post <a title="Engadget-SSH-Tunnelling" href="http://www.engadget.com/2006/03/21/how-to-ssh-tunnels-for-secure-network-access/" target="_blank">here</a>.</p>
<p><img class="aligncenter" title="SSH-Tunnel" src="http://www.engadget.com/media/2006/03/ssh-tunnel-diagram-ht.jpg" alt="ssh tunnel diagram ht Use a SSH tunnel as a (Mac) system wide SOCKS proxy to secure your traffic or bypass firewalls." width="424" height="260" /></p>
<p><span id="more-748"></span></p>
<p>So, if you&#8217;ve made it this far then hopefully this is something that&#8217;ll actually be useful for you. To start off with you&#8217;re first going to need a host somewhere that is running an SSH server and of which you have access to.</p>
<p>So lets go ahead and open our tunnel:</p>
<blockquote><p>ssh -D 1234 greg@111.112.113.114</p></blockquote>
<p>The &#8216;-D 1234&#8242; is assigning this SSH connection to a port on our local machine, you can use 1234 or pick another unused port of your own. Then it&#8217;s obviously the user &#8216;greg&#8217; at host 111.112.113.114. If you&#8217;ve already put one of my previous posts about <a title="SSH-Keys" href="http://www.gregularexpressions.co.uk/2009/12/setup-rsa-keys-for-password-less-ssh-login/" target="_blank">SSH keys</a> into practice then you&#8217;ll be connected, otherwise you&#8217;ll have to enter your password.</p>
<p>Alright, so that&#8217;s the tunnel established, now we just need to tell OS X to use it. For that we&#8217;ll be needing System Preferences &#8211;&gt; Network:</p>
<p><a href="http://www.gregularexpressions.co.uk/wp-content/uploads/2011/10/Screen-Shot-2011-10-01-at-15.33.52.png"><img class="aligncenter size-full wp-image-751" title="Screen Shot 2011-10-01 at 15.33.52" src="http://www.gregularexpressions.co.uk/wp-content/uploads/2011/10/Screen-Shot-2011-10-01-at-15.33.52.png" alt="Screen Shot 2011 10 01 at 15.33.52 Use a SSH tunnel as a (Mac) system wide SOCKS proxy to secure your traffic or bypass firewalls." width="630" height="560" /></a><br />
Select your active network down the left (in my case Ethernet) and click Advanced. Navigate to the Proxies heading and enter in your machine and the port you chose under SOCKS proxy:</p>
<p><a href="http://www.gregularexpressions.co.uk/wp-content/uploads/2011/10/Screen-Shot-2011-10-01-at-15.36.45.png"><img class="aligncenter size-full wp-image-752" title="Screen Shot 2011-10-01 at 15.36.45" src="http://www.gregularexpressions.co.uk/wp-content/uploads/2011/10/Screen-Shot-2011-10-01-at-15.36.45.png" alt="Screen Shot 2011 10 01 at 15.36.45 Use a SSH tunnel as a (Mac) system wide SOCKS proxy to secure your traffic or bypass firewalls." width="630" height="560" /></a>Click Okay and then Apply. Now your machine should be routing all it&#8217;s traffic via the tunnel you setup earlier.</p>
<p>Now if all that messing around in system preferences is a bit much for you to want to do every time then there is a terminal command to enable and disable this newly setup SOCKS proxy:</p>
<blockquote><p>networksetup -setsocksfirewallproxystate Ethernet on</p></blockquote>
<p>OR</p>
<blockquote><p>networksetup -setsocksfirewallproxystate Ethernet off</p></blockquote>
<p>So you can script the SSH connection and enabling of the proxy if you&#8217;d like, enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gregularexpressions.co.uk/2011/10/use-a-ssh-tunnel-as-a-mac-system-wide-socks-proxy-to-secure-your-traffic-or-bypass-firewalls/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Set decimal places from variable in Objective C</title>
		<link>http://www.gregularexpressions.co.uk/2011/07/set-decimal-places-from-variable-in-objective-c/</link>
		<comments>http://www.gregularexpressions.co.uk/2011/07/set-decimal-places-from-variable-in-objective-c/#comments</comments>
		<pubDate>Tue, 19 Jul 2011 22:14:39 +0000</pubDate>
		<dc:creator>Greg</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[decimal places from variable]]></category>
		<category><![CDATA[Objective-c]]></category>
		<category><![CDATA[xcode]]></category>

		<guid isPermaLink="false">http://www.gregularexpressions.co.uk/?p=739</guid>
		<description><![CDATA[I recently needed to create a function that took an NSString as the input number and then another to specify the number of decimal places it was to be returned with and I thought I&#8217;d share. (in reality it expanded to also handle any multiplication and division I needed also). It&#8217;s quite short but the ]]></description>
			<content:encoded><![CDATA[<p>I recently needed to create a function that took an NSString as the input number and then another to specify the number of decimal places it was to be returned with and I thought I&#8217;d share. (in reality it expanded to also handle any multiplication and division I needed also).</p>
<p>It&#8217;s quite short but the awkwardness was in getting StringWithFormat to output what I needed.</p>

<div class="wp_syntax"><div class="code"><pre class="objc"><span class="sy0">+</span><span class="br0">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a> <span class="sy0">*</span><span class="br0">&#41;</span> returnNumber<span class="sy0">:</span><span class="br0">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a> <span class="sy0">*</span><span class="br0">&#41;</span>numberIn toDecimalPlaces<span class="sy0">:</span><span class="br0">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a> <span class="sy0">*</span><span class="br0">&#41;</span>decimalPlaces
<span class="br0">&#123;</span>
    <span class="co2">// Assign the right number of decimal places:</span>
    decimalPlaces <span class="sy0">=</span> <span class="br0">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a> stringWithFormat<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;%%.%@f&quot;</span>, decimalPlaces<span class="br0">&#93;</span>;
    <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a><span class="sy0">*</span> result <span class="sy0">=</span> <span class="br0">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a> stringWithFormat<span class="sy0">:</span>decimalPlaces, numberIn<span class="br0">&#93;</span>;
&nbsp;
    <span class="kw1">return</span> result;
<span class="br0">&#125;</span></pre></div></div>

<p>Here&#8217;s the expanded function managing everything I needed at the time:</p>

<div class="wp_syntax"><div class="code"><pre class="objc"><span class="sy0">+</span><span class="br0">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a> <span class="sy0">*</span><span class="br0">&#41;</span> multiplyThenDivide<span class="sy0">:</span><span class="br0">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a> <span class="sy0">*</span><span class="br0">&#41;</span>numberIn by<span class="sy0">:</span><span class="br0">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a> <span class="sy0">*</span><span class="br0">&#41;</span>multiplicationFactorIn divideBy<span class="sy0">:</span><span class="br0">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a> <span class="sy0">*</span><span class="br0">&#41;</span>divisionFactor toDecimalPlaces<span class="sy0">:</span><span class="br0">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a> <span class="sy0">*</span><span class="br0">&#41;</span>decimalPlaces
<span class="br0">&#123;</span>
    <span class="co2">// Make arguments into floats so we can do operations on them:</span>
    <span class="kw4">float</span> numberInFloat <span class="sy0">=</span> <span class="br0">&#91;</span>numberIn floatValue<span class="br0">&#93;</span>;
    <span class="kw4">float</span> multiplicationInFloat <span class="sy0">=</span> <span class="br0">&#91;</span>multiplicationFactorIn floatValue<span class="br0">&#93;</span>;
&nbsp;
    <span class="co2">// Do those operations:</span>
    <span class="kw4">float</span> resultFloat <span class="sy0">=</span> numberInFloat <span class="sy0">*</span> multiplicationInFloat;
    resultFloat <span class="sy0">=</span> resultFloat <span class="sy0">/</span> <span class="nu0">100</span>;
&nbsp;
    <span class="co2">// Assign the right number of decimal places:</span>
    decimalPlaces <span class="sy0">=</span> <span class="br0">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a> stringWithFormat<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;%%.%@f&quot;</span>, decimalPlaces<span class="br0">&#93;</span>;
    <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a><span class="sy0">*</span> result <span class="sy0">=</span> <span class="br0">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a> stringWithFormat<span class="sy0">:</span>decimalPlaces, resultFloat<span class="br0">&#93;</span>;
&nbsp;
    <span class="kw1">return</span> result;
<span class="br0">&#125;</span></pre></div></div>

<p>By no means a master class, but hopefully it&#8217;ll help someone at some point.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gregularexpressions.co.uk/2011/07/set-decimal-places-from-variable-in-objective-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Courier-imap and Outlook&#8221;s idle errors</title>
		<link>http://www.gregularexpressions.co.uk/2011/06/courier-imap-and-outlooks-idle-errors/</link>
		<comments>http://www.gregularexpressions.co.uk/2011/06/courier-imap-and-outlooks-idle-errors/#comments</comments>
		<pubDate>Mon, 20 Jun 2011 14:23:57 +0000</pubDate>
		<dc:creator>Greg</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[courier-imap]]></category>
		<category><![CDATA[IMAP]]></category>
		<category><![CDATA[Outlook]]></category>

		<guid isPermaLink="false">http://www.gregularexpressions.co.uk/?p=730</guid>
		<description><![CDATA[We had a staff member that was intermittently seeing the error: Your IMAP server closed the connection. This can occur if you leave the connection idle for too long. This was rather tedious as it grabbed focus and had to be acknowledged before you could use Outlook again. I edited imapd which I found at ]]></description>
			<content:encoded><![CDATA[<p>We had a staff member that was intermittently seeing the error:</p>
<blockquote><p><span style="color: #ff0000;">Your IMAP server closed the connection. This can occur if you leave the connection idle for too long.</span></p></blockquote>
<p>This was rather tedious as it grabbed focus and had to be acknowledged before you could use Outlook again. I edited imapd which I found at <code>/usr/lib/courier-imap/etc/imapd</code> and changed the following:</p>
<blockquote><p>IMAP_ENHANCEDIDLE=1<br />
IMAP_USELOCKS=1</p></blockquote>
<p>I also made sure that <code>IMAP_CAPABILITY</code> had <code>IDLE</code> in it&#8221;s list and that appeared to fix it. Apparently it&#8221;s something to do with shared mailboxes, IDLE and some email clients not playing nice.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gregularexpressions.co.uk/2011/06/courier-imap-and-outlooks-idle-errors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Yum &#8211; Install a specific version that&#8217;s not in the repos</title>
		<link>http://www.gregularexpressions.co.uk/2011/05/yum-install-a-specific-version-thats-not-in-the-repos/</link>
		<comments>http://www.gregularexpressions.co.uk/2011/05/yum-install-a-specific-version-thats-not-in-the-repos/#comments</comments>
		<pubDate>Thu, 12 May 2011 20:49:03 +0000</pubDate>
		<dc:creator>Greg</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[php 5.2.17]]></category>
		<category><![CDATA[rpm]]></category>
		<category><![CDATA[specific version]]></category>
		<category><![CDATA[yum]]></category>

		<guid isPermaLink="false">http://www.gregularexpressions.co.uk/?p=712</guid>
		<description><![CDATA[Long story short, I needed PHP 5.2.17. The CentOS repos still had 5.1.x and all third partys seemed to be way up at 5.3.x. In the end I located a web repository that contained the PHP RPM I needed (php-5.2.17-1.el5.i386.rpm) but when I did; yum local install php-5.2.17-1.el5.i386.rpm It told me that I needed some ]]></description>
			<content:encoded><![CDATA[<p>Long story short, I needed PHP 5.2.17. The CentOS repos still had 5.1.x and all third partys seemed to be way up at 5.3.x.</p>
<p>In the end I located a web repository that contained the PHP RPM I needed (php-5.2.17-1.el5.i386.rpm) but when I did;</p>
<p><code>yum local install php-5.2.17-1.el5.i386.rpm</code></p>
<p>It told me that I needed some other dependencies:</p>
<blockquote><p>Error: Missing Dependency: php-common = 5.2.16-jason.1 is needed by package php-soap-5.2.16-jason.1.i386 (installed)<br />
Error: Missing Dependency: php-common = 5.2.16-jason.1 is needed by package php-mbstring-5.2.16-jason.1.i386 (installed)<br />
Error: Missing Dependency: php-common = 5.2.16-jason.1 is needed by package php-xml-5.2.16-jason.1.i386 (installed)<br />
Error: Missing Dependency: php-common = 5.2.16-jason.1 is needed by package php-gd-5.2.16-jason.1.i386 (installed)<br />
Error: Missing Dependency: php-common = 5.2.16-jason.1 is needed by package php-mysql-5.2.16-jason.1.i386 (installed)<br />
Error: Missing Dependency: php-common = 5.2.16-jason.1 is needed by package php-ldap-5.2.16-jason.1.i386 (installed)<br />
Error: Missing Dependency: php-common = 5.2.16-jason.1 is needed by package php-imap-5.2.16-jason.1.i386 (installed)<br />
Error: Missing Dependency: php-common = 5.2.16-jason.1 is needed by package php-xmlrpc-5.2.16-jason.1.i386 (installed)<br />
Error: Missing Dependency: php-common = 5.2.16-jason.1 is needed by package php-mcrypt-5.2.16-jason.1.i386 (installed)<br />
Error: Missing Dependency: php-common = 5.2.16-jason.1 is needed by package php-pdo-5.2.16-jason.1.i386 (installed)</p></blockquote>
<p><span id="more-712"></span><br />
Fortunately the web repo also had all the RPMs for the corresponding php extensions that I needed so I downloaded them all;</p>
<blockquote><p>[root@server2 php5.2.17]# ls -al<br />
drwxr-xr-x  2 root root    4096 May 12 13:23 .<br />
drwxr-x&#8212; 15 root root    4096 May 12 13:19 ..<br />
-rw-r&#8211;r&#8211;  1 root root 1244645 Jan  7 05:13 php-5.2.17-1.el5.i386.rpm<br />
-rw-r&#8211;r&#8211;  1 root root 2449935 Jan  7 05:13 php-cli-5.2.17-1.el5.i386.rpm<br />
-rw-r&#8211;r&#8211;  1 root root  281663 Jan  7 05:13 php-common-5.2.17-1.el5.i386.rpm<br />
-rw-r&#8211;r&#8211;  1 root root  565327 Jan  7 05:13 php-devel-5.2.17-1.el5.i386.rpm<br />
-rw-r&#8211;r&#8211;  1 root root  124288 Jan  7 05:13 php-gd-5.2.17-1.el5.i386.rpm<br />
-rw-r&#8211;r&#8211;  1 root root   51924 Jan  7 05:13 php-imap-5.2.17-1.el5.i386.rpm<br />
-rw-r&#8211;r&#8211;  1 root root   33537 Jan  7 05:13 php-ldap-5.2.17-1.el5.i386.rpm<br />
-rw-r&#8211;r&#8211;  1 root root   33537 Jan  7 05:13 php-ldap-5.2.17-1.el5.i386.rpm.1<br />
-rw-r&#8211;r&#8211;  1 root root 1111156 Jan  7 05:13 php-mbstring-5.2.17-1.el5.i386.rpm<br />
-rw-r&#8211;r&#8211;  1 root root   27890 Jan  7 05:13 php-mcrypt-5.2.17-1.el5.i386.rpm<br />
-rw-r&#8211;r&#8211;  1 root root   83622 Jan  7 05:13 php-mysql-5.2.17-1.el5.i386.rpm<br />
-rw-r&#8211;r&#8211;  1 root root   64944 Jan  7 05:13 php-pdo-5.2.17-1.el5.i386.rpm<br />
-rw-r&#8211;r&#8211;  1 root root  146634 Jan  7 05:13 php-soap-5.2.17-1.el5.i386.rpm<br />
-rw-r&#8211;r&#8211;  1 root root  114790 Jan  7 05:13 php-xml-5.2.17-1.el5.i386.rpm<br />
-rw-r&#8211;r&#8211;  1 root root   55025 Jan  7 05:13 php-xmlrpc-5.2.17-1.el5.i386.rpm</p></blockquote>
<p>and ran:</p>
<p><code>yum localinstall *</code></p>
<blockquote><p>
Updating:<br />
php                                           i386                                  5.2.17-1.el5                                       /php-5.2.17-1.el5.i386                                           3.0 M<br />
php-cli                                       i386                                  5.2.17-1.el5                                       /php-cli-5.2.17-1.el5.i386                                       5.8 M<br />
php-common                                    i386                                  5.2.17-1.el5                                       /php-common-5.2.17-1.el5.i386                                    739 k<br />
php-devel                                     i386                                  5.2.17-1.el5                                       /php-devel-5.2.17-1.el5.i386                                     2.7 M<br />
php-gd                                        i386                                  5.2.17-1.el5                                       /php-gd-5.2.17-1.el5.i386                                        358 k<br />
php-imap                                      i386                                  5.2.17-1.el5                                       /php-imap-5.2.17-1.el5.i386                                       96 k<br />
php-ldap                                      i386                                  5.2.17-1.el5                                       /php-ldap-5.2.17-1.el5.i386                                       41 k<br />
php-mbstring                                  i386                                  5.2.17-1.el5                                       /php-mbstring-5.2.17-1.el5.i386                                  1.8 M<br />
php-mcrypt                                    i386                                  5.2.17-1.el5                                       /php-mcrypt-5.2.17-1.el5.i386                                     32 k<br />
php-mysql                                     i386                                  5.2.17-1.el5                                       /php-mysql-5.2.17-1.el5.i386                                     171 k<br />
php-pdo                                       i386                                  5.2.17-1.el5                                       /php-pdo-5.2.17-1.el5.i386                                       108 k<br />
php-soap                                      i386                                  5.2.17-1.el5                                       /php-soap-5.2.17-1.el5.i386                                      320 k<br />
php-xml                                       i386                                  5.2.17-1.el5                                       /php-xml-5.2.17-1.el5.i386                                       269 k<br />
php-xmlrpc                                    i386                                  5.2.17-1.el5                                       /php-xmlrpc-5.2.17-1.el5.i386                                     87 k</p>
<p>Installing for dependencies:<br />
libXaw                                        i386                                  1.0.2-8.1                                          base                                                             324 k<br />
libXmu                                        i386                                  1.0.2-5                                            base                                                              62 k<br />
t1lib                                         i386                                  5.1.2-1.el4.rf                                     rpmforge                                                         353 k</p>
<p>Updating for dependencies:<br />
libevent                                      i386                                  1.4.13-1                                           base                                                             112 k<br />
nfs-utils                                     i386                                  1:1.0.9-50.el5                                     base                                                             394 k
</p></blockquote>
<p>You can see above that Yum was then happy to install php 5.2.17 combining the RPMs with other bits from repos it was already aware of. The only downside of this approach is that if I needed another php extension I would have to source the RPM and install via a similar method.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gregularexpressions.co.uk/2011/05/yum-install-a-specific-version-thats-not-in-the-repos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Run multiple dropbox instances on Mac OS X</title>
		<link>http://www.gregularexpressions.co.uk/2011/03/run-multiple-dropbox-instances-on-mac-os-x/</link>
		<comments>http://www.gregularexpressions.co.uk/2011/03/run-multiple-dropbox-instances-on-mac-os-x/#comments</comments>
		<pubDate>Mon, 07 Mar 2011 20:50:01 +0000</pubDate>
		<dc:creator>Greg</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[macbook pro]]></category>
		<category><![CDATA[OS-X]]></category>
		<category><![CDATA[dropbox]]></category>
		<category><![CDATA[multiple]]></category>

		<guid isPermaLink="false">http://www.gregularexpressions.co.uk/?p=699</guid>
		<description><![CDATA[I threw this process together because I was already an avid dropbox user and needed to start doing some joint iOS development with a friend and suggested we make use of dropbox as a centralized project store. Naturally I wanted to keep mine and ours separate so I needed to run dual instances because I ]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.dropbox.com"><img class="aligncenter size-medium wp-image-700" title="dropbox-coverflow" src="http://www.gregularexpressions.co.uk/wp-content/uploads/2011/03/dropbox-coverflow-300x266.png" alt="dropbox coverflow 300x266 Run multiple dropbox instances on Mac OS X" width="300" height="266" /></a></p>
<p>I threw this process together because I was already an avid dropbox user and needed to start doing some joint iOS development with a friend and suggested we make use of dropbox as a centralized project store. Naturally I wanted to keep mine and ours separate so I needed to run dual instances because I didn&#8217;t want to be logging in and out all the time.</p>
<p><span style="color: #ff0000;">Please don&#8217;t just use this to get around the 2GB free limit.</span><br />
<span id="more-699"></span><br />
The following terminal command will get  a secondary dropbox instance running in the background and independent of your terminal window (copy and paste all as one line):</p>
<p><code>HOME=/Users/$USER/.dropbox-alt; nohup /Applications/Dropbox.app/Contents/MacOS/Dropbox &amp;</code></p>
<p>However, even with a bash alias like &#8216;dropbox2&#8242; setup this still wasn&#8217;t very &#8216;nice&#8217; so I decided to explore some way to have it masquerade as an app so I could have it on my dock.</p>
<p>My research led me to <a href="http://www.sveinbjorn.org/platypus">Platypus</a>; It can be used to create native, integrated Mac OS X applications from interpreted scripts such as shell scripts or Perl. So I just needed to bung my terminal command into a .sh file, open Platypus, choose an icon and tweak the following:</p>
<p>- Switched &#8216;Output&#8217; to &#8216;None&#8217;.<br />
- Confirm &#8216;Script Type&#8217; is &#8216;Shell&#8217;.<br />
- Untick &#8216;Remains running after initial execution&#8217;.</p>
<p>(I went with this icon btw)<br />
<a href="http://www.gregularexpressions.co.uk/wp-content/uploads/2011/03/dropbox.png"><img class="aligncenter size-full wp-image-704" title="dropbox" src="http://www.gregularexpressions.co.uk/wp-content/uploads/2011/03/dropbox.png" alt="dropbox Run multiple dropbox instances on Mac OS X" width="128" height="128" /></a></p>
<p>Dual apps showing in applications folder:</p>
<p><a href="http://www.gregularexpressions.co.uk/wp-content/uploads/2011/03/Screen-shot-2011-03-07-at-20.48.02.jpg"><img class="aligncenter size-medium wp-image-706" title="dual-dropbox" src="http://www.gregularexpressions.co.uk/wp-content/uploads/2011/03/Screen-shot-2011-03-07-at-20.48.02-300x167.jpg" alt="Screen shot 2011 03 07 at 20.48.02 300x167 Run multiple dropbox instances on Mac OS X" width="300" height="167" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gregularexpressions.co.uk/2011/03/run-multiple-dropbox-instances-on-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generate arbitrary network traffic</title>
		<link>http://www.gregularexpressions.co.uk/2011/01/generate-arbitrary-network-traffic/</link>
		<comments>http://www.gregularexpressions.co.uk/2011/01/generate-arbitrary-network-traffic/#comments</comments>
		<pubDate>Thu, 27 Jan 2011 09:50:20 +0000</pubDate>
		<dc:creator>Greg</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[flood network]]></category>
		<category><![CDATA[generate network traffic]]></category>

		<guid isPermaLink="false">http://www.gregularexpressions.co.uk/?p=692</guid>
		<description><![CDATA[We recently wanted to do some network tinkering but we needed to generate large volumes of traffic to test how it behaved. After some searching I came across hping which allowed me to generate large packets quickly. I yum installed hping, from RPM forge I believe. The below command then generated about 25Mbit per second ]]></description>
			<content:encoded><![CDATA[<p>We recently wanted to do some network tinkering but we needed to generate large volumes of traffic to test how it behaved.</p>
<p>After some searching I came across <a href="http://www.hping.org/">hping</a> which allowed me to generate large packets quickly. I yum installed hping, from RPM forge I believe.</p>
<p>The below command then generated about 25Mbit per second until it was stopped:</p>
<p><code>hping2 targethost -d 65400 --faster</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gregularexpressions.co.uk/2011/01/generate-arbitrary-network-traffic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

