<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>Glen Scott - Keeping it simple</title>
	
	<link>http://www.glenscott.co.uk</link>
	<description>Thoughts on application development and other geeky pursuits.</description>
	<lastBuildDate>Sat, 17 Jul 2010 16:59:27 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/GlenScott-KeepingItSimple" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="glenscott-keepingitsimple" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Removing digital distractions 2010</title>
		<link>http://www.glenscott.co.uk/2010/01/28/removing-digital-distractions-2010/</link>
		<comments>http://www.glenscott.co.uk/2010/01/28/removing-digital-distractions-2010/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 21:21:36 +0000</pubDate>
		<dc:creator>Glen</dc:creator>
				<category><![CDATA[computing]]></category>
		<category><![CDATA[productivity]]></category>

		<guid isPermaLink="false">http://www.glenscott.co.uk/?p=482</guid>
		<description><![CDATA[Over the years I have built up an digital environment that demands my attention &#8211; both online and offline.  Today, I have started to remove the clutter from this digital life in order to add more clarity and give me breathing space.
Mac/iPhone
Focussing on important apps

Backdrop is a tool I&#8217;ve mentioned before.  The aim [...]]]></description>
			<content:encoded><![CDATA[<p>Over the years I have built up an digital environment that <em>demands</em> my attention &#8211; both online and offline.  Today, I have started to remove the clutter from this digital life in order to add more clarity and give me breathing space.</p>
<h3>Mac/iPhone</h3>
<h4>Focussing on important apps</h4>
<ul>
<li>Backdrop is a tool <a href="http://www.glenscott.co.uk/2008/01/29/removing-distractions/">I&#8217;ve mentioned before</a>.  The aim is simple;  it blacks out your screen allowing you to pick only the essential applications to focus on.</li>
<li><a href="http://www.hogbaysoftware.com/products/writeroom">WriteRoom</a> is a decent text editor that uses the same black-out effect as Backdrop, allowing you to concentrate purely on writing.</li>
</ul>
<h4> Removing notifications</h4>
<ul>
<li><a href="http://growl.info">Growl</a> notifications seemed like a good idea once-upon-a-time.  More often than not, they serve only as an annoyance and break my concentration.</li>
<li>I&#8217;ve disabled iPhone push notifications for Mail as e-mail is never important enough that I need to read it straight away</li>
</ul>
<h3>Online</h3>
<p>The key question that I kept coming back to as I sifted through this mess is</p>
<p><em>How does this support my life as it is now?</em></p>
<h4>Unsubscribing from e-mail alerts</h4>
<p>I&#8217;ve unsubscribed from the following e-mail alerts:</p>
<ul>
<li>Facebook notifications (<strong>57</strong> different notification types in all!)</li>
<li>Twitter user follows</li>
<li>Google alerts</li>
<li>Dozens of music and tech mailing lists</li>
</ul>
<p>Knowing that my level of e-mail will now drop, I&#8217;m less inclined to check it as often.</p>
<h4>Unsubscribing from blog RSS feeds</h4>
<p>I had 82 feeds in my feed reader, and I realised that I read new items from them very rarely.  I&#8217;ve now unsubscribed from all but 3;</p>
<ul>
<li><a href="http://misko.hevery.com/">Miško Hevery</a></li>
<li><a href="http://norwichcity.myfootballwriter.com/">myfootballwriter.com/norwichcity</a></li>
<li><a href="http://code.flickr.com/blog">Code: Flickr Developer Blog</a></li>
</ul>
<p>I&#8217;m sure these actions will be helpful in the long run, I am hoping this is a step towards a less overwhelming environment.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.glenscott.co.uk%2F2010%2F01%2F28%2Fremoving-digital-distractions-2010%2F&amp;linkname=Removing%20digital%20distractions%202010"><img src="http://www.glenscott.co.uk/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.glenscott.co.uk/2010/01/28/removing-digital-distractions-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LaTeX dissertation template for M801</title>
		<link>http://www.glenscott.co.uk/2010/01/24/latex-dissertation-template-for-m801/</link>
		<comments>http://www.glenscott.co.uk/2010/01/24/latex-dissertation-template-for-m801/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 16:06:27 +0000</pubDate>
		<dc:creator>Glen</dc:creator>
				<category><![CDATA[open university]]></category>
		<category><![CDATA[dissertation]]></category>
		<category><![CDATA[latex]]></category>
		<category><![CDATA[ou]]></category>
		<category><![CDATA[template]]></category>

		<guid isPermaLink="false">http://www.glenscott.co.uk/?p=474</guid>
		<description><![CDATA[Next month I start my 13 month research project and dissertation, which forms the last part of my MSc in Software Development.  The research project is based around the topic of mining software repositories.
I was disappointed to find that the OU offers a dissertation template in Microsoft Word format only, so I&#8217;ve knocked together [...]]]></description>
			<content:encoded><![CDATA[<p>Next month I start my 13 month research project and dissertation, which forms the last part of my <a href="http://www3.open.ac.uk/study/postgraduate/qualification/f26.htm">MSc in Software Development</a>.  The research project is based around the topic of mining software repositories.</p>
<p>I was disappointed to find that the OU offers a dissertation template in Microsoft Word format only, so I&#8217;ve knocked together a LaTeX version which I&#8217;m hoping will be of use to others.</p>
<ul>
<li>source file: <a href="http://github.com/glenscott/ou/blob/master/template.tex">http://github.com/glenscott/ou/blob/master/template.tex</a></li>
<li>PDF output: <a href="/download/m801-template.pdf">m801-template.pdf</a></li>
</ul>
<p>At the moment it&#8217;s quite rough, but it should provide a good starting point for further development.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.glenscott.co.uk%2F2010%2F01%2F24%2Flatex-dissertation-template-for-m801%2F&amp;linkname=LaTeX%20dissertation%20template%20for%20M801"><img src="http://www.glenscott.co.uk/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.glenscott.co.uk/2010/01/24/latex-dissertation-template-for-m801/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Install memcached PHP extension on OS X Snow Leopard</title>
		<link>http://www.glenscott.co.uk/2009/08/30/install-memcached-php-extension-on-os-x-snow-leopard/</link>
		<comments>http://www.glenscott.co.uk/2009/08/30/install-memcached-php-extension-on-os-x-snow-leopard/#comments</comments>
		<pubDate>Sun, 30 Aug 2009 15:54:21 +0000</pubDate>
		<dc:creator>Glen</dc:creator>
				<category><![CDATA[mac]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[macosx]]></category>
		<category><![CDATA[memcached]]></category>
		<category><![CDATA[pecl]]></category>
		<category><![CDATA[snowleopard]]></category>

		<guid isPermaLink="false">http://www.glenscott.co.uk/?p=424</guid>
		<description><![CDATA[memcached is a very useful memory object caching system, which can be used to increase the performance of your dynamic scripts by caching database calls.
This guide will explain how to install the memcached system, including the PHP extension, on Mac OS X 10.6.
Xcode
The Xcode package installs the necessary versions of tools like autoconf which is [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.danga.com/memcached/">memcached</a> is a very useful memory object caching system, which can be used to increase the performance of your dynamic scripts by caching database calls.</p>
<p>This guide will explain how to install the memcached system, including the PHP extension, on Mac OS X 10.6.</p>
<h3>Xcode</h3>
<p>The Xcode package installs the necessary versions of tools like autoconf which is needed during the PHP extension compilation process.  Make sure you have Xcode 3.2 installed;  the install package is available on the Snow Leopard install DVD under the &#8220;Optional Installs&#8221; folder.</p>
<h3>libevent</h3>
<p><a href="http://www.monkey.org/~provos/libevent/">libevent</a> is a pre-requisite for memcached.</p>
<ul>
<li><code>cd /tmp; curl -O http://www.monkey.org/~provos/libevent-1.4.12-stable.tar.gz</code></li>
<li><code>tar zxvf libevent-1.4.12-stable.tar.gz</code></li>
<li><code>cd libevent-1.4.12-stable</code></li>
<li><code>./configure; make</code></li>
<li><code>sudo make install</code></li>
</ul>
<h3>memcached</h3>
<p><a href="http://www.danga.com/memcached/download.bml">memcached</a> is the daemon responsible for actually storing and retrieving arbitrary objects for your applications.</p>
<ul>
<li><code>cd /tmp; curl -O http://memcached.googlecode.com/files/memcached-1.4.1.tar.gz</code></li>
<li><code>tar zxvf memcached-1.4.1.tar.gz</code></li>
<li><code>cd  memcached-1.4.1</code></li>
<li><code>./configure; make</code></li>
<li><code>sudo make install</code></li>
</ul>
<h3>libmemcached</h3>
<p><a href="http://freshmeat.net/projects/libmemcached">libmemcached</a> is the shared library that will allow clients, in this case PHP, access the memcached daemon.</p>
<ul>
<li>Download libmemcached, move to <code>/tmp</code> and unpack</li>
<li><code>cd libmemcached-0.31</code></li>
<li><code>./configure; make</code></li>
<li><code>sudo make install</code></li>
</ul>
<h3>php extension</h3>
<p>Now we are ready to prepare the PHP extension to memcached, which is available from <a href="http://pecl.php.net">pecl</a>.</p>
<ul>
<li><code>cd /tmp; pecl download memcached</code></li>
<li><code>gzip -d < memcached-1.0.0.tgz | tar -xvf -</code></li>
<li><code>cd memcached-1.0.0; phpize</code></li>
</ul>
<p>You should see output similar to the following:<br />
<code><br />
Configuring for:<br />
PHP Api Version:         20090626<br />
Zend Module Api No:      20090626<br />
Zend Extension Api No:   220090626<br />
</code></p>
<ul>
<li><code>./configure; make</code></li>
<li><code>sudo make install</code></li>
</ul>
<p>On a successful install, you will get the following message:</p>
<p><code>Installing shared extensions:     /usr/lib/php/extensions/no-debug-non-zts-20090626/</code></p>
<p>Modify your <code>php.ini</code> configuration file and make sure you have the following line included:</p>
<p><code>extension = memcached.so</code></p>
<p>You can then restart your Apache server:</p>
<ul>
<li><code>sudo apachectl restart</code></li>
</ul>
<p>to make the memcached functionality available in your scripts.</p>
<p><a href="/images/memcached-php.png"><img src="/images/memcached-php-med.png" width="450" height="140" alt="memcached php extension" border="0"></a></p>
<h3>References</h3>
<ul>
<li><a href="http://php.net/manual/en/install.pecl.phpize.php">Compiling shared PECL extensions with phpize</a></li>
<li><a href="http://php.net/memcached">PHP: Memcached - Manual</a></li>
</ul>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.glenscott.co.uk%2F2009%2F08%2F30%2Finstall-memcached-php-extension-on-os-x-snow-leopard%2F&amp;linkname=Install%20memcached%20PHP%20extension%20on%20OS%20X%20Snow%20Leopard"><img src="http://www.glenscott.co.uk/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.glenscott.co.uk/2009/08/30/install-memcached-php-extension-on-os-x-snow-leopard/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Fix PHP timezone warnings in OS X Snow Leopard</title>
		<link>http://www.glenscott.co.uk/2009/08/30/fix-php-timezone-warnings-in-os-x-snow-leopard/</link>
		<comments>http://www.glenscott.co.uk/2009/08/30/fix-php-timezone-warnings-in-os-x-snow-leopard/#comments</comments>
		<pubDate>Sun, 30 Aug 2009 09:07:30 +0000</pubDate>
		<dc:creator>Glen</dc:creator>
				<category><![CDATA[mac]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[datetime]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[snowleopard]]></category>

		<guid isPermaLink="false">http://www.glenscott.co.uk/?p=417</guid>
		<description><![CDATA[The standard Mac install of PHP has always been somewhat quirky, and 10.6 is no exception.  One of the most obvious issues occurs when attempting to use date/time functions.  PHP 5.3 requires that the date.timezone setting is available.  Without this, you will receive a warning similar to the following:
Warning: getdate() [function.getdate]: It [...]]]></description>
			<content:encoded><![CDATA[<p>The standard Mac install of PHP has always been somewhat quirky, and 10.6 is no exception.  One of the most obvious issues occurs when attempting to use <a href="http://php.net/manual/en/ref.datetime.php">date/time functions</a>.  PHP 5.3 requires that the <a href="http://php.net/manual/en/datetime.configuration.php#ini.date.timezone">date.timezone</a> setting is available.  Without this, you will receive a warning similar to the following:</p>
<p><code>Warning: getdate() [function.getdate]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/London' for 'BST/1.0/DST' instead in /Users/gscott/Sites/hello-world.php on line 9</code></p>
<p>The solution is to edit (or create, if it doesn&#8217;t exist) <code>/private/etc/php.ini</code> and make sure a setting exists for <code>date.timezone</code>.  For example:</p>
<p>    date.timezone = Europe/London</p>
<p>After making the change, restart Apache</p>
<p>    sudo apachectl restart</p>
<ul>
<li><a href="http://php.net/manual/en/timezones.php">List of supported timezones</a>.
</ul>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.glenscott.co.uk%2F2009%2F08%2F30%2Ffix-php-timezone-warnings-in-os-x-snow-leopard%2F&amp;linkname=Fix%20PHP%20timezone%20warnings%20in%20OS%20X%20Snow%20Leopard"><img src="http://www.glenscott.co.uk/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.glenscott.co.uk/2009/08/30/fix-php-timezone-warnings-in-os-x-snow-leopard/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>PHP 5.3: The Good, the Bad and the Ugly</title>
		<link>http://www.glenscott.co.uk/2009/06/30/php-53-the-good-the-bad-and-the-ugly/</link>
		<comments>http://www.glenscott.co.uk/2009/06/30/php-53-the-good-the-bad-and-the-ugly/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 21:55:20 +0000</pubDate>
		<dc:creator>Glen</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.glenscott.co.uk/?p=405</guid>
		<description><![CDATA[PHP 5.3 was released today;  here are my positive and negatives:
The Good:  Closures
Anonymous functions created with create_function have always been a bit messy.  With 5.3 comes support for closures with a much cleaner syntax:

    $greet = function($name)
    {
        printf("Hello [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://php.net/releases/5_3_0.php">PHP 5.3</a> was released today;  here are my positive and negatives:</p>
<h3>The Good:  Closures</h3>
<p>Anonymous functions created with <a href="http://php.net/create_function">create_function</a> have always been a bit messy.  With 5.3 comes support for closures with a much cleaner syntax:</p>
<pre name="code" class="php">
    $greet = function($name)
    {
        printf("Hello %s\r\n", $name);
    };

    $greet('World');
    $greet('PHP');
</pre>
<h3>The Bad:  Backwards incompatible changes</h3>
<p>Although not a massive change from 5.2, there are enough <a href="http://php.net/manual/en/migration53.incompatible.php">differences to break existing code</a>.</p>
<h3>The Ugly:  Namespaces</h3>
<p>There has been <a href="http://blog.fedecarg.com/2008/10/28/php-namespaces-controversy/">quite a discussion</a> about PHP&#8217;s new namespace syntax.  </p>
<pre name="code" class="php">$c = new \my\name\MyClass;</pre>
<p>It&#8217;s just damn ugly.  The more sensible choice, <code>::</code> is already used as the <a href="http://php.net/manual/en/language.oop5.paamayim-nekudotayim.php">scope resolution operator</a> and was therefore dismissed.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.glenscott.co.uk%2F2009%2F06%2F30%2Fphp-53-the-good-the-bad-and-the-ugly%2F&amp;linkname=PHP%205.3%3A%20The%20Good%2C%20the%20Bad%20and%20the%20Ugly"><img src="http://www.glenscott.co.uk/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.glenscott.co.uk/2009/06/30/php-53-the-good-the-bad-and-the-ugly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Synchronise your iPhone with Yahoo! Calendar</title>
		<link>http://www.glenscott.co.uk/2009/06/19/synchronise-your-iphone-with-yahoo-calendar/</link>
		<comments>http://www.glenscott.co.uk/2009/06/19/synchronise-your-iphone-with-yahoo-calendar/#comments</comments>
		<pubDate>Fri, 19 Jun 2009 18:35:05 +0000</pubDate>
		<dc:creator>Glen</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[iphone calendar yahoo sync]]></category>

		<guid isPermaLink="false">http://www.glenscott.co.uk/2009/06/19/synchronise-your-iphone-with-yahoo-calendar/</guid>
		<description><![CDATA[Since the iPhone OS 3 update,  you can now use the CalDAV protocol to automatically keep your Yahoo! Calendar updated on your iPhone:
Can I sync with my iPhone over the air?
]]></description>
			<content:encoded><![CDATA[<p>Since the iPhone OS 3 update,  you can now use the CalDAV protocol to automatically keep your Yahoo! Calendar updated on your iPhone:</p>
<p><a href="http://help.yahoo.com/l/us/yahoo/calendar/yahoocalendar/sync/sync-06.html">Can I sync with my iPhone over the air?</a></p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.glenscott.co.uk%2F2009%2F06%2F19%2Fsynchronise-your-iphone-with-yahoo-calendar%2F&amp;linkname=Synchronise%20your%20iPhone%20with%20Yahoo%21%20Calendar"><img src="http://www.glenscott.co.uk/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.glenscott.co.uk/2009/06/19/synchronise-your-iphone-with-yahoo-calendar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mcrypt support for PHP on 64 bit Mac OS X 10.5</title>
		<link>http://www.glenscott.co.uk/2009/03/16/mcrypt-support-for-php-on-64-bit-mac-os-x-105/</link>
		<comments>http://www.glenscott.co.uk/2009/03/16/mcrypt-support-for-php-on-64-bit-mac-os-x-105/#comments</comments>
		<pubDate>Mon, 16 Mar 2009 20:31:28 +0000</pubDate>
		<dc:creator>Glen</dc:creator>
				<category><![CDATA[mac]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[64bit]]></category>
		<category><![CDATA[mcrypt]]></category>

		<guid isPermaLink="false">http://www.glenscott.co.uk/?p=389</guid>
		<description><![CDATA[Adding additional functionality to the standard Apple-supplied PHP on Mac OS X 10.5 is a little tricky if you are running a 64 bit processor such as the Intel Core 2 Duo.  The reason is that any dynamic extensions that you add will need to be 64 bit, and many shared libraries by default [...]]]></description>
			<content:encoded><![CDATA[<p>Adding additional functionality to the standard Apple-supplied PHP on Mac OS X 10.5 is a little tricky if you are running a 64 bit processor such as the Intel Core 2 Duo.  The reason is that any dynamic extensions that you add will need to be 64 bit, and many shared libraries by default with compile as 32 bit binaries.  Trying to use a 32 bit extension with a 64 bit PHP results in the following unfriendly error message:</p>
<p><code>PHP Warning:  PHP Startup: Unable to load dynamic library './mcrypt.so' - (null) in Unknown on line 0</code></p>
<p><a href="http://php.net/mcrypt">mcrypt</a> is a good example of a useful extension that can be added to PHP with a little bit of effort:</p>
<ul>
<li>Open up your Terminal.app</li>
<li>To explicitly build for 64 bit architecture <code>export CFLAGS="-arch x86_64"</code></li>
<li>Download libmcrypt from sourceforge <a href="http://sourceforge.net/projects/mcrypt">http://sourceforge.net/projects/mcrypt</a></li>
<li>Unpack the archive</li>
<li><code>cd libmcrypt</code></li>
<li><code>./configure --disable-shared</code></li>
<li><code>make</code></li>
<li><code>sudo make install</code></li>
<li>download PHP 5.2.6 source from <a href=" http://www.php.net/get/php-5.2.6.tar.bz2/from/a/mirror">http://www.php.net/get/php-5.2.6.tar.bz2/from/a/mirror</a></li>
<li>unpack the archive and go into the <code>php-5.2.6/ext/mcrypt/</code> dir</li>
<li><code>phpize</code></li>
<li><code>./configure</code></li>
<li><code>make</code></li>
<li><code>sudo make install</code></li>
<li>verify the extension is 64 bit: <code>file /usr/lib/php/extensions/no-debug-non-zts-20060613/mcrypt.so</code></li>
</ul>
<p><code>/usr/lib/php/extensions/no-debug-non-zts-20060613/mcrypt.so: Mach-O 64-bit bundle x86_64</code></p>
<p>To actually use the extension, you can simply create a symbolic link to it.  For example:</p>
<ul>
<li><code>cd ~/Sites</code></li>
<li><code>ln -s  /usr/lib/php/extensions/no-debug-non-zts-20060613/mcrypt.so</code></li>
</ul>
<h3>Example code:  mcrypt.php</h3>
<p>Drop the following code into your <code>~/Sites</code> directory to verify everything is working:</p>
<pre name="code" class="php">
    &lt;?php

    if ( ! extension_loaded('mcrypt') ) {
        dl('mcrypt.so');
    }

    $key   = "this is a secret key";
    $input = "Let us meet at 9 o'clock at the secret place.";

    $td = mcrypt_module_open('tripledes', '', 'ecb', '');
    $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
    mcrypt_generic_init($td, $key, $iv);
    $encrypted_data = mcrypt_generic($td, $input);
    mcrypt_generic_deinit($td);
    mcrypt_module_close($td);

    print_r($encrypted_data);

    ?&gt;
</pre>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.glenscott.co.uk%2F2009%2F03%2F16%2Fmcrypt-support-for-php-on-64-bit-mac-os-x-105%2F&amp;linkname=mcrypt%20support%20for%20PHP%20on%2064%20bit%20Mac%20OS%20X%2010.5"><img src="http://www.glenscott.co.uk/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.glenscott.co.uk/2009/03/16/mcrypt-support-for-php-on-64-bit-mac-os-x-105/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>PHP Best Practices #2: Strictures</title>
		<link>http://www.glenscott.co.uk/2009/02/23/php-best-practices-2-strictures/</link>
		<comments>http://www.glenscott.co.uk/2009/02/23/php-best-practices-2-strictures/#comments</comments>
		<pubDate>Mon, 23 Feb 2009 19:26:06 +0000</pubDate>
		<dc:creator>Glen</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[bestpractices]]></category>

		<guid isPermaLink="false">http://www.glenscott.co.uk/?p=344</guid>
		<description><![CDATA[Make sure PHP is reporting all errors and warnings.
Warnings and notices are PHP&#8217;s way of letting you know that you are utilising features in a non-standard way.  If your code is omitting errors, then it should be fixed as soon as possible.  Strict warnings are a class of errors that are turned off [...]]]></description>
			<content:encoded><![CDATA[<h3>Make sure PHP is reporting all errors and warnings.</h3>
<p>Warnings and notices are PHP&#8217;s way of letting you know that you are utilising features in a non-standard way.  If your code is omitting errors, then it should be fixed as soon as possible.  Strict warnings are a class of errors that are turned off by default in most PHP installations.  Turning on strict warnings gives you another level of error reporting, which is helpful to prevent you from using misusing functions, making sure your code is compatible with future PHP versions.  </p>
<p>In the example here, using <code>date()</code> without explicitly setting a timezone will result in an <code>E_STRICT</code> warning.  In this case, we are using a function called <code>strictErrors</code> to tell PHP to report all error types.</p>
<h3>Example</h3>
<pre name="code" class="php">
    &lt;?php

    function strictErrors() {
        $reporting_level = E_ALL;

        // if version of PHP < 6, explicity report E_STRICT
        if ( version_compare( PHP_VERSION, '6.0.0', '<' ) ) {
            $reporting_level = E_ALL | E_STRICT;
        }

        return error_reporting( $reporting_level );
    }

    // turn on strict error and warnings
    strictErrors();

    // produces strict warning
    echo date( "d-M-Y" );

    // no warning
    date_default_timezone_set( 'Europe/London' );
    echo date( "d-M-Y" );

    ?&gt;
</pre>
<h3>Further information</h3>
<ul>
<li><a href="http://php.net/error_reporting">PHP: error_reporting</a></li>
</ul>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.glenscott.co.uk%2F2009%2F02%2F23%2Fphp-best-practices-2-strictures%2F&amp;linkname=PHP%20Best%20Practices%20%232%3A%20Strictures"><img src="http://www.glenscott.co.uk/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.glenscott.co.uk/2009/02/23/php-best-practices-2-strictures/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Objects in Perl (part 2,352)</title>
		<link>http://www.glenscott.co.uk/2009/02/20/objects-in-perl-part-2352/</link>
		<comments>http://www.glenscott.co.uk/2009/02/20/objects-in-perl-part-2352/#comments</comments>
		<pubDate>Fri, 20 Feb 2009 12:33:03 +0000</pubDate>
		<dc:creator>Glen</dc:creator>
				<category><![CDATA[perl]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[moose]]></category>
		<category><![CDATA[oop]]></category>

		<guid isPermaLink="false">http://www.glenscott.co.uk/?p=340</guid>
		<description><![CDATA[One of my issues with Perl has always been its implementation of OOP.  Or, to be precise, the multitude of ways that a class can be declared (blessed hash, inside-out, Class::Std etc).  I would argue that this is a case where TMTOWTDI is not advantageous.  Enter Piers Cawley and his _Moose for Ruby [...]]]></description>
			<content:encoded><![CDATA[<p>One of my issues with Perl has always been its implementation of OOP.  Or, to be precise, the multitude of ways that a class can be declared (blessed hash, <a href="http://search.cpan.org/dist/Object-InsideOut/lib/Object/InsideOut.pod">inside-out</a>, <a href="http://search.cpan.org/~dmuey/Class-Std-0.0.9/lib/Class/Std.pm">Class::Std</a> etc).  I would argue that this is a case where <a href="http://en.wikipedia.org/wiki/There_is_more_than_one_way_to_do_it">TMTOWTDI</a> is not advantageous.  Enter Piers Cawley and his _Moose for Ruby Programmers_ talk at the London.pm Technical Meeting, 20th February 2009.  MooseX::Declare is yet another way, but check this out&#8230;</p>
<pre name="code" class="perl">
    use MooseX::Declare;

    class BankAccount {
        has 'balance' =&gt; ( isa =&gt; 'Num', is =&gt; 'rw', default =&gt; 0 );

        method deposit (Num $amount) {
            $self-&gt;balance( $self-&gt;balance + $amount );
        }

        method withdraw (Num $amount) {
            my $current_balance = $self-&gt;balance();
            ( $current_balance &gt;= $amount )
                || confess "Account overdrawn";
            $self-&gt;balance( $current_balance - $amount );
        }
    }

    class CheckingAccount extends BankAccount {
        has 'overdraft_account' =&gt; ( isa =&gt; 'BankAccount', is =&gt; 'rw' );

        before withdraw (Num $amount) {
            my $overdraft_amount = $amount - $self-&gt;balance();
            if ( $self-&gt;overdraft_account &#038;&#038; $overdraft_amount > 0 ) {
                $self-&gt;overdraft_account-&gt;withdraw($overdraft_amount);
                $self-&gt;deposit($overdraft_amount);
            }
        }
    }
</pre>
<p>Firstly, yes, that is indeed Perl.  Secondly, wow:  it actually _looks_ like a class definition.  And this was the big win for me, as anyone coming from a Java or PHP background will find it trivial to understand what&#8217;s going on here.  The main point is that by using MooseX::Declare, you are moving towards a more declarative programming style describing _what_ the program should do rather than _how_ it should achieve it.  So, no more unrolling `@_` <img src='http://www.glenscott.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3>Links</h3>
<ul>
<li><a href="http://search.cpan.org/~flora/MooseX-Declare-0.03/lib/MooseX/Declare.pm">MooseX::Declare on CPAN</a></li>
<li><a href="http://www.bofh.org.uk/">Piers Cawley&#8217;s blog &#8211; Just A Summary</a></li>
</ul>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.glenscott.co.uk%2F2009%2F02%2F20%2Fobjects-in-perl-part-2352%2F&amp;linkname=Objects%20in%20Perl%20%28part%202%2C352%29"><img src="http://www.glenscott.co.uk/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.glenscott.co.uk/2009/02/20/objects-in-perl-part-2352/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Best Practices #1: Regular expressions</title>
		<link>http://www.glenscott.co.uk/2009/02/19/php-best-practices-1-regular-expressions/</link>
		<comments>http://www.glenscott.co.uk/2009/02/19/php-best-practices-1-regular-expressions/#comments</comments>
		<pubDate>Thu, 19 Feb 2009 18:00:03 +0000</pubDate>
		<dc:creator>Glen</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[phpbestpractices]]></category>

		<guid isPermaLink="false">http://www.glenscott.co.uk/?p=332</guid>
		<description><![CDATA[preg not ereg
This is the first in what I hope will be a regular series of posts on PHP best practices, inspired in part by Damian Conway&#8217;s Perl Best Practices book.
Historically, PHP has had two incompatible regular expression engines available, POSIX Extended and PCRE (Perl Compatible Regular Expressions).  Arguably, Perl-compatible regular expressions are more [...]]]></description>
			<content:encoded><![CDATA[<h3>preg not ereg</h3>
<p>This is the first in what I hope will be a regular series of posts on PHP best practices, inspired in part by Damian Conway&#8217;s <a href="http://www.amazon.co.uk/Perl-Best-Practices-Damian-Conway/dp/0596001738">Perl Best Practices</a> book.</p>
<p>Historically, PHP has had two incompatible regular expression engines available, POSIX Extended and <a href="http://www.pcre.org/">PCRE</a> (Perl Compatible Regular Expressions).  Arguably, Perl-compatible regular expressions are more powerful since they support non-greedy matching, assertions, conditional subpatterns and a number of other features not supported by POSIX Extended.  More importantly, the POSIX Extended extension is deprecated as of PHP 5.3, meaning that a call to any of its functions, such as `ereg`, will emit a `E_DEPRECATED` notice.  Therefore, for any regular expression functionality in your scripts, use the PCRE set of functions which are prefixed with `preg_`.</p>
<h3>Example</h3>
<pre name="code" class="php">
    $pattern = '/Hello/x';
    $subject = 'Wake up and say Hello.';
    $matches = array();

    if ( preg_match( $pattern, $subject, $matches ) ) {
        print_r( $matches );
    }
</pre>
<p>Output:</p>
<pre>
    Array ( [0] => Hello )
</pre>
<h3>Further information</h3>
<ul>
<li><a href="http://php.net/pcre">PHP: PCRE &#8211; Manual</a></li>
</ul>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.glenscott.co.uk%2F2009%2F02%2F19%2Fphp-best-practices-1-regular-expressions%2F&amp;linkname=PHP%20Best%20Practices%20%231%3A%20Regular%20expressions"><img src="http://www.glenscott.co.uk/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.glenscott.co.uk/2009/02/19/php-best-practices-1-regular-expressions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
