<?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>Kelvin Jones – Freelance PHP &#38; MySQL web developer from London &#187; Blog</title>
	<atom:link href="http://kelvinjones.co.uk/my/blog/feed" rel="self" type="application/rss+xml" />
	<link>http://kelvinjones.co.uk</link>
	<description>Gravity sucks</description>
	<lastBuildDate>Fri, 01 Jul 2011 10:38:44 +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>The future is Bright, the future is a Machine…</title>
		<link>http://kelvinjones.co.uk/futuremachine</link>
		<comments>http://kelvinjones.co.uk/futuremachine#comments</comments>
		<pubDate>Wed, 15 Jun 2011 13:20:36 +0000</pubDate>
		<dc:creator>Kelvin Jones</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://kelvinjones.co.uk/?p=189</guid>
		<description><![CDATA[As of now, I am no longer accepting any freelance work. Together with Chris Martin of Coldplay Coldpie fame, we have founded a new company called Bright Machine. If you need some kick-ass mobile app or web development, then please email me here.]]></description>
			<content:encoded><![CDATA[<p><em><strong>As of now, I am no longer accepting any freelance work.</strong></em></p>
<p>Together with Chris Martin of <del>Coldplay</del> <a title="Coldpie site" href="http://www.coldpie.co.uk" target="_blank">Coldpie</a> fame, we have founded a new company called <a title="Bright Machine website" href="http://brightmachine.co.uk" target="_blank">Bright Machine</a>. If you need some kick-ass mobile app or web development, then please <a title="Protected email link" href="http://scr.im/kjbm" target="_blank">email me here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://kelvinjones.co.uk/futuremachine/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux Tips</title>
		<link>http://kelvinjones.co.uk/linuxtips</link>
		<comments>http://kelvinjones.co.uk/linuxtips#comments</comments>
		<pubDate>Fri, 16 Jul 2010 13:36:28 +0000</pubDate>
		<dc:creator>Kelvin Jones</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[linux commandline tips]]></category>

		<guid isPermaLink="false">http://kelvinjones.co.uk/?p=163</guid>
		<description><![CDATA[Below are tips that I&#8217;ve used throughout the years to get shit done on the command line. Every geek (apart from the fake ones who deploy on Windows) uses the shell every day; some of these tips I use every day, some only occasionally… anyway it&#8217;s my list of &#8220;things to remember&#8221;. Swan Dive. Some [...]]]></description>
			<content:encoded><![CDATA[<p>Below are tips that I&#8217;ve used throughout the years to get shit done on the command line. Every geek (apart from the fake ones who deploy on Windows) uses the shell every day; some of these tips I use every day, some only occasionally… anyway it&#8217;s my list of &#8220;things to remember&#8221;. Swan Dive.</p>
<p>Some of the commands below may require additional software that doesn&#8217;t come with your default server installation.</p>
<p><em>Disclaimer: if you&#8217;re stupid enough to do any of the below, don&#8217;t blame me.</em></p>
<p><span id="more-163"></span></p>
<h2>General Things</h2>
<h3>Firewall / iptables</h3>
<p>From <a href="http://www.netfilter.org/projects/iptables/index.html">netfilter.org</a>:</p>
<blockquote><p>iptables is the userspace command line program used to configure the Linux 2.4.x and 2.6.x IPv4 packet filtering ruleset</p></blockquote>
<p>Basic info:</p>
<ul>
<li><strong>Config file</strong>: <code>/etc/sysconfig/iptables</code></li>
<li><strong>List rules</strong>: <code>iptables -L</code></li>
<li><strong>Open a port</strong>: <code>iptables -I INPUT 1 -p tcp --dport 80 -j ACCEPT</code></li>
</ul>
<hr />
<h3>Adding an IP address to an existing network adaptor</h3>
<p>Stolen from <a href="http://www.oclc.org/support/documentation/ezproxy/technote/2l.htm">here</a>.</p>
<pre class="brush: bash; title: ;">
cd /etc/sysconfig/network-scripts
ls ifcfg-* # check for existing interfaces
cp ifcfg-eth0 ifcfg-eth0:0
</pre>
<p>Then edit the <code>ifcfg-eth0:0</code> file and change the <code>DEVICE</code> and <code>IPADDR</code> settings, eg.</p>
<pre class="brush: bash; title: ;">
DEVICE=eth0:0
IPADDR=999.888.777.195 # whatever your IP address is
</pre>
<p>…then…</p>
<pre class="brush: bash; title: ;">
ifup eth0:0
</pre>
<hr />
<h3>Adding an additional loopback address in OS-X</h3>
<pre class="brush: bash; title: ;">
ifconfig lo0 alias 127.0.0.2 up
</pre>
<hr />
<h3>Setting up SSH so you don&#8217;t need to enter a password</h3>
<p>Stolen from <a href="http://bashcurescancer.com/">here</a>.</p>
<blockquote><p>If you manage more than one or two hosts, you likely have to type the same password too often. This can get quite annoying. SSH allows you to setup a public and private keypair. Using these keys, you can connect to any host which has the public key, from any host which has the private key, typing your password only once.</p></blockquote>
<p>So, the process goes like this:</p>
<ol>
<li>Generate a keypair</li>
<li>Add your public key to the <code>authorized_keys</code> file on the remote host</li>
<li>… errr that&#8217;s it</li>
</ol>
<p>NB: make sure the <code>.ssh</code> directory exists in the user home directory on both your local and remote machine.</p>
<pre class="brush: bash; title: ;">
ssh-keygen -t rsa
cd ~/.ssh
cat id_rsa.pub &amp;amp;gt; authorized_keys; chmod 600 authorized_keys # adds your public key to your localhost
chmod 600 authorized_keys
cat id_rsa.pub | ssh YourRemoteHost 'cd .ssh; cat &amp;amp;gt;&amp;amp;gt; authorized_keys; chmod 600 authorized_keys'
</pre>
<p>Alternatively, you can do that last bit manually by <code>scp</code>&#8216;ing the public key up to the remote host and <code>cat</code>&#8216;ing it onto the <code>authorized_keys</code>.</p>
<hr />
<h2>Command Line Mojo</h2>
<h3>Change to the Previous Working Directory</h3>
<pre class="brush: bash; title: ;">
cd $OLDPWD # old way
cd - # new way
</pre>
<p><kbd>-</kbd> on its own is the same as <kbd>$OLDPWD</kbd>… nice!</p>
<hr />
<h3>Which version of Linux?</h3>
<pre class="brush: bash; title: ;">
lsb_release -a
</pre>
<p>You may need to add lsb support, just <kbd>yum search lsb</kbd> to find the package for your OS.</p>
<hr />
<h3>Run the last command</h3>
<pre class="brush: bash; title: ;">
!!
sudo !! # when you forget to run the command as root
</pre>
<p>This is great is your coding up a command line script, and debugging, and continually running the same command one after the other. Using <kbd>!!</kbd> will run the last command but not pollute your history.</p>
<hr />
<h3>Open ports</h3>
<pre class="brush: bash; title: ;">
nmap -sT -O localhost
netstat -tlnp
</pre>
<p>One of those commands usually gives me the info I&#8217;m looking for.</p>
<hr />
<h3>Create a local mirror of a site using wget</h3>
<pre class="brush: bash; title: ;">
wget -m -k --adjust-extension http://url-of-site.com
</pre>
<h3>Disk Usage</h3>
<pre class="brush: bash; title: ;">
df -h # show disk usage on all partitions
du -sh /var/log/maillog # size of 1 directory / file
du -sh /var/* # size of all files / folders within a folder
</pre>
<hr />
<h3>Truncate a file</h3>
<p>Useful emptying a log file. There are 2 situations when I want to do this.</p>
<h4>Emptying a file from within VI</h4>
<pre class="brush: bash; title: ;">
vi some_file.log
[esc]
:1 # go to top of the file
dG # delete all contents until the bottom
</pre>
<h4>From the command line</h4>
<pre class="brush: bash; title: ;">
cat /dev/null &amp;amp;gt; some_file.log
</pre>
<hr />
<h3>Clearing the terminal</h3>
<p>Any of the following</p>
<pre class="brush: bash; title: ;">
CTRL+l # lowercase L
clear
reset # resets the shell if it starts acting a bit weird
</pre>
<hr />
<h3>Setting your date &amp; time using an NTP server</h3>
<pre class="brush: bash; title: ;">
ntpdate time.apple.com
</pre>
]]></content:encoded>
			<wfw:commentRss>http://kelvinjones.co.uk/linuxtips/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducing Traffic</title>
		<link>http://kelvinjones.co.uk/introducing-traffic</link>
		<comments>http://kelvinjones.co.uk/introducing-traffic#comments</comments>
		<pubDate>Thu, 27 May 2010 12:58:00 +0000</pubDate>
		<dc:creator>Kelvin Jones</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://kelvinjones.co.uk/?p=148</guid>
		<description><![CDATA[Traffic is a routing library for PHP 5.3 and above. I created traffic to take the pain out of mapping incoming requests to your site to code that does whatever you need it to do. Most existing solutions, like the atrocious Zend_Controller_Router_Rewrite whatever assume that you want to map requests to method on a class, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://github.com/kelvinj/Traffic" target="_blank">Traffic</a> is a routing library for PHP 5.3 and above.</p>
<p>I created traffic to take the pain out of mapping incoming requests to your site to code that does whatever you need it to do. Most existing solutions, like the atrocious <a href="http://framework.zend.com/manual/en/zend.controller.router.html" target="_blank">Zend_Controller_Router_Rewrite whatever</a> assume that you want to map requests to method on a class, with enough magic mixed in to be a pain in the arse.</p>
<p>With Traffic, I&#8217;ve taken the approach that you should be in charge of how you organise your code. All Traffic does is the matching, and leaves the rest up to you. if you&#8217;re a framework monkey with an incessant need for hand holding, then move on, coz I&#8217;m not gonna tell you how to structure your app or anything like that.</p>
<p>Traffic is inspired by <a href="http://www.sinatrarb.com/" target="_blank">Sinatra</a> &amp; <a href="http://code.quirkey.com/sammy/" target="_blank">Sammy JS</a> without pretending that it&#8217;s not PHP.</p>
<p><span id="more-148"></span></p>
<p>Here&#8217;s a snippet:</p>
<pre class="brush: php; title: ;">
use Fu\Traffic as t;

// relative_to is an alias to rel, in case you prefer to be more verbose
t::relative_to('/user/:username', function () {
  t::get(function ($params) {
    echo 'Viewing user:'.$params['username'];
  });

  t::post(function ($params) {
    echo 'Creating user:'.$params['username'];
  });

  t::put(function ($params) {
    echo 'Updating user:'.$params['username'];
  });

  t::delete(function ($params) {
   echo 'Deleting user:'.$params['username'];
  });
});
</pre>
<p>Go <a href="http://github.com/kelvinj/Traffic" target="_blank">check out the code</a> and a smidgen of documentation.</p>
]]></content:encoded>
			<wfw:commentRss>http://kelvinjones.co.uk/introducing-traffic/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Unblock The Tubes</title>
		<link>http://kelvinjones.co.uk/unblock-the-tubes</link>
		<comments>http://kelvinjones.co.uk/unblock-the-tubes#comments</comments>
		<pubDate>Mon, 14 Dec 2009 00:20:47 +0000</pubDate>
		<dc:creator>Kelvin Jones</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Google]]></category>

		<guid isPermaLink="false">http://kelvinjones.co.uk/?p=90</guid>
		<description><![CDATA[Most websites built today use JavaScript. It is an essential building block of the web along with HTML &#38; CSS. However, when it comes to performance JavaScript has one problem… it Blocks The Tubes™! When CSS and images are included in your HTML, they are loaded asynchronously. This is not the case with JavaScript. When [...]]]></description>
			<content:encoded><![CDATA[<p>Most websites built today use JavaScript. It is an essential building block of the web along with HTML &amp; CSS. However, when it comes to performance JavaScript has one problem… it Blocks The Tubes™!</p>
<p>When CSS and images are included in your HTML, they are loaded <a href="http://en.wikipedia.org/wiki/Asynchrony">asynchronously</a>. This is not the case with JavaScript. When a JavaScript file is loaded, no other resources will be downloaded.</p>
<p><span id="more-90"></span></p>
<p>In terms of performance, most developers right now follow this rule: CSS at the top, JavaScript at the bottom. This allows all CSS &amp; images to be loaded asynchronously, before it hits the roadblock of JavaScript, but at least by that point you have all your resources, so as soon as JavaScript is finished your page will be displayed.</p>
<p>However, there are alternatives available that allow JavaScript to be loaded asynchronously. <a href="http://www.stevesouders.com/blog/2009/04/27/loading-scripts-without-blocking/">These methods are documented here by Steve Soulders</a>, but the main problem with this is it means a fair amount of work to implement… a developer must architect his or her code specifically to allow it to be loaded in this manner.</p>
<p>Over the last few weeks, there has been some progress in bringing one of the techniques (Script DOM Element) to the masses.</p>
<h2>Analyze This!</h2>
<p>First off, and probably the easiest way for a developer to get into asynchronous JavaScript loading, <a href="http://googlecode.blogspot.com/2009/12/google-analytics-launches-asynchronous.html">Google launched asynchronous tracking code</a> for Google Analytics.</p>
<p>As Google Analytics uses JavaScript to collect usage data, it usually adds more load time to each page it is installed on, and can potentially cause pages to hang, if there are issues with Google&#8217;s servers. But with the following code, this issue goes away:</p>
<pre class="brush: jscript; title: ;">
&lt;script type=&quot;text/javascript&quot;&gt;
var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXX-X']);
  _gaq.push(['_trackPageview']);

(function() {
    var ga = document.createElement('script');
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' :
        'http://www') + '.google-analytics.com/ga.js';
    ga.setAttribute('async', 'true');
    document.documentElement.firstChild.appendChild(ga);
  })();
&lt;/script&gt;
</pre>
<p>Just replace the <code>UA-XXXXX-X</code> with your own identfier.</p>
<p>To see an example of this, just have a look at the source code of <a href="http://kelvinjones.co.uk">this site</a>.</p>
<h2>Straight From The Lab</h2>
<p>Another project that has been emerging to tackle this same issue is <a href="http://labjs.com">LABjs</a>.</p>
<p>From the <a href="http://labjs.com/documentation.php">LABjs documentation</a>, the following code shows how one might use it:</p>
<pre class="brush: jscript; title: ;">
$LAB
.script(&quot;framework.js&quot;).wait()
.script(&quot;plugin.framework.js&quot;)
.script(&quot;myplugin.framework.js&quot;).wait()
.script(&quot;init.js&quot;);
</pre>
<p>The wait() bit would be where you want the browser to block, everything else would be loaded asynchronously.</p>
<p>I&#8217;m sure the LABjs project will evolve a lot over the next few months, but it&#8217;s an interesting start… one to keep your eye on.</p>
<h6 class="zemanta-related-title" style="font-size: 1em;">Related articles by Zemanta</h6>
<ul class="zemanta-article-ul">
<li class="zemanta-article-ul-li"><a href="http://stereonaut.net/yahoo-yslow-for-firebug/">Yahoo! YSlow for Firebug</a> (stereonaut.net)</li>
<li class="zemanta-article-ul-li"><a href="http://www.bruceclay.com.au/blog/archives/2009/11/google-on-speed.html">Google on Speed</a> (bruceclay.com.au)</li>
</ul>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Reblog this post [with Zemanta]" href="http://reblog.zemanta.com/zemified/6a8b9d54-2430-4bbe-9dae-52ce54024c22/"><img class="zemanta-pixie-img" style="border: medium none; float: right;" src="http://img.zemanta.com/reblog_e.png?x-id=6a8b9d54-2430-4bbe-9dae-52ce54024c22" alt="Reblog this post [with Zemanta]" /></a><span class="zem-script more-related pretty-attribution"><script src="http://static.zemanta.com/readside/loader.js" type="text/javascript"></script></span></div>
]]></content:encoded>
			<wfw:commentRss>http://kelvinjones.co.uk/unblock-the-tubes/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Time to make a change</title>
		<link>http://kelvinjones.co.uk/time-to-make-a-change</link>
		<comments>http://kelvinjones.co.uk/time-to-make-a-change#comments</comments>
		<pubDate>Tue, 01 Dec 2009 20:40:48 +0000</pubDate>
		<dc:creator>Kelvin Jones</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://kelvinjones.co.uk/?p=1</guid>
		<description><![CDATA[Two weeks ago I met with my boss at A7 Creative to let him know that I was planning to leave as of 18th December. Although I&#8217;ve enjoyed myself at A7, with the diversity of work and the flexibility that they&#8217;ve offered me, there are a few reasons that I have now chosen to freelance. [...]]]></description>
			<content:encoded><![CDATA[<p>Two weeks ago I met with my boss at A7 Creative to let him know that I was planning to leave as of 18th December. Although I&#8217;ve enjoyed myself at A7, with the diversity of work and the flexibility that they&#8217;ve offered me, there are a few reasons that I have now chosen to freelance.</p>
<p>Firstly, there&#8217;s the new addition to the family that is coming along right around the corner. To make it work, I&#8217;m just gonna have to have complete control over how &amp; when I work, more than I would be willing to ask of any employer.</p>
<p><span id="more-1"></span></p>
<p>Secondly, I&#8217;ve been wanting to run a business for a few years now. Although I didn&#8217;t envisage it being in a freelancing/consulting capacity, it made sense when I thought about it. Why jump in trying to do something new? Surely it would be sensible to do the thing that I&#8217;ve been doing for…</p>
<p><strong>10 years</strong>. That&#8217;s the third reason, or at least part of the third reason. As well as my second child, 2010 will bring with it my 30th birthday (oy vey) and my 10th year in full-time employment as a web developer. The long and short of it is, it&#8217;s time for me to do this for myself.</p>
<p>So, there you have it. 2010 here I come. It&#8217;s gonna be HUGE.</p>
]]></content:encoded>
			<wfw:commentRss>http://kelvinjones.co.uk/time-to-make-a-change/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
