<?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/blog</link>
	<description>Thoughts on software development and other geeky pursuits.</description>
	<lastBuildDate>Tue, 13 Mar 2012 10:40:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<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>Compiling PHP extensions using Xcode 4.3 and above</title>
		<link>http://www.glenscott.co.uk/blog/2012/03/07/compiling-php-extensions-using-xcode-4-3-and-above/</link>
		<comments>http://www.glenscott.co.uk/blog/2012/03/07/compiling-php-extensions-using-xcode-4-3-and-above/#comments</comments>
		<pubDate>Wed, 07 Mar 2012 15:51:22 +0000</pubDate>
		<dc:creator>Glen</dc:creator>
				<category><![CDATA[mac]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[xcode]]></category>

		<guid isPermaLink="false">http://www.glenscott.co.uk/blog/?p=795</guid>
		<description><![CDATA[Prior to version 4.3 of Xcode, Apple bundled a load of command line tools with it that are used to compile native binaries, including PHP extensions. However, as of version 4.3, these tools are not bundled by default. Therefore, if you require these tools you need to take one of two actions: 1. If you [...]]]></description>
			<content:encoded><![CDATA[<p>Prior to version 4.3 of Xcode, Apple bundled a load of command line tools with it that are used to compile native binaries, including PHP extensions.  However, as of version 4.3, these tools are not bundled by default.  Therefore, if you require these tools you need to take one of two actions:</p>
<p>1. If you already have Xcode 4.3 installed, go into the <strong>Components</strong> tab of the <strong>Download</strong> preferences panel and make sure Command Line Tools are selected</p>
<p><img src="http://www.glenscott.co.uk/images/xcode-43-cli-tools-m.png" alt="Xcode CLI tools installation" /></p>
<p>OR </p>
<p>2. Download and install the command line tools as an independent package from either;</p>
<p>a. <a href="https://developer.apple.com/downloads/index.action?=command%20line%20tools">Apple (requires Apple ID)</a><br />
b. <a href="https://github.com/kennethreitz/osx-gcc-installer">GitHub</a></p>
<p>Once you have the command line tools installed, you are able to compile native binaries.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.glenscott.co.uk/blog/2012/03/07/compiling-php-extensions-using-xcode-4-3-and-above/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Refactoring a large PHP codebase – where do you start?</title>
		<link>http://www.glenscott.co.uk/blog/2012/03/06/refactoring-a-large-php-codebase-where-do-you-start/</link>
		<comments>http://www.glenscott.co.uk/blog/2012/03/06/refactoring-a-large-php-codebase-where-do-you-start/#comments</comments>
		<pubDate>Tue, 06 Mar 2012 14:48:42 +0000</pubDate>
		<dc:creator>Glen</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[quality]]></category>
		<category><![CDATA[refactoring tools]]></category>

		<guid isPermaLink="false">http://www.glenscott.co.uk/blog/?p=793</guid>
		<description><![CDATA[If you are finding a codebase less manageable than it should be, chances are that refactoring could help. But where can you start? I&#8217;ve found the following tools are good for focussing on the areas of code that require attention: PHPMD &#8211; http://phpmd.org/ PHPMD (Mess Detector) scans your source code and computes various quality metrics [...]]]></description>
			<content:encoded><![CDATA[<p>If you are finding a codebase less manageable than it should be, chances are that refactoring could help.  But where can you start?  I&#8217;ve found the following tools are good for focussing on the areas of code that require attention:</p>
<p>PHPMD &#8211; <a href="http://phpmd.org/">http://phpmd.org/</a></p>
<p>PHPMD (Mess Detector) scans your source code and computes various quality metrics such as cyclomatic and NPath complexity.  These metrics can be used to assess which classes in your codebase need refactoring.</p>
<p>phpcpd &#8211; <a href="https://github.com/sebastianbergmann/phpcpd">https://github.com/sebastianbergmann/phpcpd</a></p>
<p>phpcd (Copy Paste Detector) scans your source for code clones &#8212; identical fragments of code that are usually created by copying and pasting.  Source code with high levels of clones may benefit from refactoring.</p>
<p>What are your favourite tools to help in your refactoring efforts?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.glenscott.co.uk/blog/2012/03/06/refactoring-a-large-php-codebase-where-do-you-start/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Finding function dependencies in your PHP applications</title>
		<link>http://www.glenscott.co.uk/blog/2012/03/01/finding-function-dependencies-in-your-php-applications/</link>
		<comments>http://www.glenscott.co.uk/blog/2012/03/01/finding-function-dependencies-in-your-php-applications/#comments</comments>
		<pubDate>Thu, 01 Mar 2012 10:33:01 +0000</pubDate>
		<dc:creator>Glen</dc:creator>
				<category><![CDATA[open source]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.glenscott.co.uk/blog/?p=776</guid>
		<description><![CDATA[A recent post on reddit/PHP asked an interesting question: how can you determine the extension requirements of your PHP application in a programmatic way? And could you add such a check to a continuous integration environment to validate dependencies? I&#8217;ve come up with a relative simple solution, albeit with some caveats (see below). The process [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/josefstuefer/9500503/" title="wide web by josef.stuefer, on Flickr"><img src="http://farm1.staticflickr.com/4/9500503_83de095ccf.jpg" width="500" height="500" alt="wide web"></a></p>
<p>A <a href="http://www.reddit.com/r/PHP/comments/q860y/how_can_i_see_which_extensions_are_in_use_in_a/">recent post on reddit/PHP</a> asked an interesting question:  how can you determine the extension requirements of your PHP application in a programmatic way?  And could you add such a check to a continuous integration environment to validate dependencies?</p>
<p>I&#8217;ve come up with a relative simple solution, albeit with some caveats (<a href="#caveats">see below</a>).  The process requires two distinct stages:</p>
<ol>
<li>Gather a list of extensions and functions from a PHP environment</li>
<li>Scan PHP source code for function calls and flag up any that are not either a) available in the PHP environment or b) user defined.</li>
</ol>
<p>I&#8217;ve posted some code to Github that demonstrates how this can be done.  You can find the source code here: <a href="https://github.com/glenscott/php-dependencies">https://github.com/glenscott/php-dependencies</a>.</p>
<p>For stage 1, you must determine the functions that are defined in your PHP environment.  This is done by running <code>get-env-functions.php</code> either on the command line, or from within your document root.  This will create a config file in the directory defined by <code>CONFIG_PATH</code>.  This config file will be used by the second script, <code>scan-dependencies.php</code>.</p>
<p><code>scan-dependencies.php</code> will scan through PHP source code defined by <code>SOURCE_PATH</code> and use the configuration file generated previously.  After it finishes scanning, it will list all function calls made that are not defined in either PHP itself, or within the source directory.</p>
<h2>Example Run</h2>
<h3>Getting details of your PHP environment</h3>
<pre>
$ php get-env-functions.php
Found 1743 total functions in 61 extensions available in PHP.
</pre>
<h3>Scanning source code for dependencies</h3>
<pre>
$ php scan-dependencies.php
Found 3 function calls and 1 object instantiations in your script.
Function ps_setgray not defined.
</pre>
<p>In this example, the function <a href="http://php.net/ps_setgray">ps_setgray</a> was called in a script but not defined anywhere.</p>
<h2 id="caveats">Caveats</h2>
<ul>
<li>Your source code and its dependencies must lie under one directory &#8212; included/required files outside this directory are not scanned
<li>As it stands, only _function_ dependencies are found.  This means that class dependencies are not checked.</li>
</ul>
<h2>Final thoughts</h2>
<p>This is by no means a complete solution, but I hope it is of some use.  Please feel free to comment, or suggest improvements.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.glenscott.co.uk/blog/2012/03/01/finding-function-dependencies-in-your-php-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Alternative PHP Cache (APC) on Mac OS X Lion</title>
		<link>http://www.glenscott.co.uk/blog/2012/02/15/installing-alternative-php-cache-apc-on-mac-os-x-lion/</link>
		<comments>http://www.glenscott.co.uk/blog/2012/02/15/installing-alternative-php-cache-apc-on-mac-os-x-lion/#comments</comments>
		<pubDate>Wed, 15 Feb 2012 04:39:18 +0000</pubDate>
		<dc:creator>Glen</dc:creator>
				<category><![CDATA[mac]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[apc]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[pecl]]></category>

		<guid isPermaLink="false">http://www.glenscott.co.uk/blog/?p=763</guid>
		<description><![CDATA[The APC extension should be a straightforward PECL install, but sadly it does not work on Mac OS X Lion. Attempting to install will result in make errors similar to the following: Thankfully, the solution is simple. APC requires PCRE libraries and header files to be available, so we can download and install these from [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://php.net/apc">APC</a> extension should be a straightforward PECL install, but sadly it does not work on Mac OS X Lion.  Attempting to install will result in make errors similar to the following:</p>
<pre class="brush: bash; title: ; notranslate">
In file included from /private/tmp/APC/apc.c:44:
/usr/include/php/ext/pcre/php_pcre.h:29:18: error: pcre.h: No such file or directory
In file included from /private/tmp/APC/apc.c:44:
/usr/include/php/ext/pcre/php_pcre.h:37: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
/usr/include/php/ext/pcre/php_pcre.h:38: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
/usr/include/php/ext/pcre/php_pcre.h:44: error: expected specifier-qualifier-list before ‘pcre’
/private/tmp/APC/apc.c:393: error: expected specifier-qualifier-list before ‘pcre’
/private/tmp/APC/apc.c: In function ‘apc_regex_compile_array’:
/private/tmp/APC/apc.c:454: error: ‘apc_regex’ has no member named ‘preg’
/private/tmp/APC/apc.c:454: error: ‘apc_regex’ has no member named ‘preg’
/private/tmp/APC/apc.c:455: error: ‘apc_regex’ has no member named ‘nreg’
/private/tmp/APC/apc.c:455: error: ‘apc_regex’ has no member named ‘nreg’
/private/tmp/APC/apc.c: In function ‘apc_regex_match_array’:
/private/tmp/APC/apc.c:487: error: ‘apc_regex’ has no member named ‘preg’
/private/tmp/APC/apc.c:487: error: ‘apc_regex’ has no member named ‘preg’
/private/tmp/APC/apc.c:488: error: ‘apc_regex’ has no member named ‘nreg’
/private/tmp/APC/apc.c:488: error: ‘apc_regex’ has no member named ‘nreg’
make: *** [apc.lo] Error 1
ERROR: `make' failed
</pre>
<p>Thankfully, the solution is simple.  APC requires PCRE libraries and header files to be available, so we can download and install these from source:</p>
<ul>
<li>Download the latest PCRE from <a href="http://sourceforge.net/projects/pcre/files/latest/download?source=files">http://sourceforge.net/projects/pcre/files/latest/download?source=files</a></li>
<li>Unzip the file</li>
<li>cd into the unzipped <code>pcre-</code> directory and then type:</li>
</ul>
<pre class="brush: bash; title: ; notranslate">
./configure
make
sudo make install
</pre>
<p>Next, we can install the APC extension using the normal PECL route:</p>
<pre class="brush: bash; title: ; notranslate">
sudo pecl install apc
</pre>
<p>Confirm that you have the following line in your php.ini file:</p>
<pre class="brush: bash; title: ; notranslate">
extension=apc.so
</pre>
<p>Restart Apache, if required:</p>
<pre class="brush: bash; title: ; notranslate">
sudo apachectl graceful
</pre>
<p>You should now have APC available, and you can confirm this by looking at your phpinfo output:</p>
<p><img src="/images/apc-phpinfo.png" width="618" height="245" alt="APC PHP info"></p>
]]></content:encoded>
			<wfw:commentRss>http://www.glenscott.co.uk/blog/2012/02/15/installing-alternative-php-cache-apc-on-mac-os-x-lion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SimpleCrypt PHP class for simple cryptography</title>
		<link>http://www.glenscott.co.uk/blog/2012/02/09/simplecrypt-php-class-for-simple-cryptography/</link>
		<comments>http://www.glenscott.co.uk/blog/2012/02/09/simplecrypt-php-class-for-simple-cryptography/#comments</comments>
		<pubDate>Thu, 09 Feb 2012 09:33:50 +0000</pubDate>
		<dc:creator>Glen</dc:creator>
				<category><![CDATA[open source]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.glenscott.co.uk/blog/?p=743</guid>
		<description><![CDATA[I have just pushed a simple class called SimpleCrypt to GitHub: https://github.com/glenscott/simple-crypt This is an OO wrapper around the most common mcrypt functions. An example of use: If you find it useful, please let me know!]]></description>
			<content:encoded><![CDATA[<p>I have just pushed a simple class called <code>SimpleCrypt</code> to GitHub:</p>
<p><a href="https://github.com/glenscott/simple-crypt">https://github.com/glenscott/simple-crypt</a></p>
<p>This is an OO wrapper around the most common mcrypt functions.  An example of use:</p>
<pre class="brush: php; title: ; notranslate">
require_once 'SimpleCrypt.php';

// show the algorithms available for use
print_r( SimpleCrypt::get_available_algorithms() );

// encrypt a string using Triple DES (CBC mode)
$crypt = new SimpleCrypt( 'tripledes', 'mysecretkey' );
$encrypted_data = $crypt-&gt;encrypt_data( 'stringtoencrypt' );
echo &quot;Encrypted data: &quot; . bin2hex( $encrypted_data ) . &quot;\n&quot;;
echo &quot;Decrypted data: &quot; . $crypt-&gt;decrypt_data( $encrypted_data ) . &quot;\n&quot;;
</pre>
<p>If you find it useful, please let me know!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.glenscott.co.uk/blog/2012/02/09/simplecrypt-php-class-for-simple-cryptography/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Mac OS X 10.7.3 upgrades PHP from 5.3.6 to 5.3.8</title>
		<link>http://www.glenscott.co.uk/blog/2012/02/08/mac-os-x-10-7-3-upgrades-php-from-5-3-6-to-5-3-8/</link>
		<comments>http://www.glenscott.co.uk/blog/2012/02/08/mac-os-x-10-7-3-upgrades-php-from-5-3-6-to-5-3-8/#comments</comments>
		<pubDate>Wed, 08 Feb 2012 17:22:31 +0000</pubDate>
		<dc:creator>Glen</dc:creator>
				<category><![CDATA[mac]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.glenscott.co.uk/blog/?p=741</guid>
		<description><![CDATA[As described in Apple&#8217;s security notes for Mac OS X 10.7.3, PHP is upgraded from 5.3.6 to version 5.3.8 as part of the update.]]></description>
			<content:encoded><![CDATA[<p>As described in Apple&#8217;s <a href="http://support.apple.com/kb/HT5130">security notes for Mac OS X 10.7.3</a>, PHP is upgraded from 5.3.6 to version 5.3.8 as part of the update.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.glenscott.co.uk/blog/2012/02/08/mac-os-x-10-7-3-upgrades-php-from-5-3-6-to-5-3-8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Map invoke errors when using MongoDB MapReduce</title>
		<link>http://www.glenscott.co.uk/blog/2012/02/02/map-invoke-errors-when-using-mongodb-mapreduce/</link>
		<comments>http://www.glenscott.co.uk/blog/2012/02/02/map-invoke-errors-when-using-mongodb-mapreduce/#comments</comments>
		<pubDate>Thu, 02 Feb 2012 11:34:33 +0000</pubDate>
		<dc:creator>Glen</dc:creator>
				<category><![CDATA[mongodb]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.glenscott.co.uk/blog/?p=732</guid>
		<description><![CDATA[When running MapReduce operations on your data, you must make sure that any fields you refer to within your map operation are available for every document in your collection. If you try a map operation and some documents do not have the required field, you will get the following assertion error when running the command: [...]]]></description>
			<content:encoded><![CDATA[<p>When running MapReduce operations on your data, you must make sure that any fields you refer to within your map operation <strong>are available for every document</strong> in your collection.  If you try a map operation and some documents do not have the required field, you will get the following assertion error when running the command:</p>
<pre>map invoke failed: JS Error: TypeError: this.fieldname has no properties</pre>
<p><code>fieldname</code> in this case is a field that does not exist in all of the documents.</p>
<p>To prevent this error, you can pass the optional <code>query</code> parameter to the command to make sure that only documents with this field are queried.  For example, in PHP, add the following to the command operation:</p>
<pre class="brush: php; title: ; notranslate">

$db-&gt;command(
    'mapreduce' =&gt; 'collection',
    'map'       =&gt; $map,
    'reduce'    =&gt; $reduce,
    'out'       =&gt; array( 'inline' =&gt; 1 ),
    'query'     =&gt; array( &quot;fieldname&quot; =&gt; array( '$exists' =&gt; true, ) )
);
</pre>
<p>This makes sure that MapReduce operations are only run on a subset of the collection.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.glenscott.co.uk/blog/2012/02/02/map-invoke-errors-when-using-mongodb-mapreduce/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Complaining to Virgin Media</title>
		<link>http://www.glenscott.co.uk/blog/2012/01/18/complaining-to-virgin-media/</link>
		<comments>http://www.glenscott.co.uk/blog/2012/01/18/complaining-to-virgin-media/#comments</comments>
		<pubDate>Wed, 18 Jan 2012 09:01:01 +0000</pubDate>
		<dc:creator>Glen</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[broadband]]></category>
		<category><![CDATA[complain]]></category>
		<category><![CDATA[virgin]]></category>

		<guid isPermaLink="false">http://www.glenscott.co.uk/blog/?p=725</guid>
		<description><![CDATA[Yesterday, the 17th January 2012, Virgin Media broadband customers experienced partial or total loss of connectivity throughout the afternoon and evening. As one of those customers affected by the outage, I am making a formal complaint to the company. As I work from home and require internet connectivity at all times, this outage had a [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/raver_mikey/3570914819/" title="&quot;Broadband power to all the people&quot; by Gene Hunt, on Flickr"><img src="http://farm4.staticflickr.com/3623/3570914819_1c2251f513.jpg" width="500" height="375" alt="&quot;Broadband power to all the people&quot;"></a></p>
<p>Yesterday, the 17th January 2012, Virgin Media broadband customers experienced partial or total loss of connectivity throughout the afternoon and evening.  As one of those customers affected by the outage, I am making a formal complaint to the company.  As I work from home and require internet connectivity at all times, this outage had a serious affect on my business.</p>
<p>For others that are considering complaining, here is how you can do it &#8212; it took me a fair bit of searching to find this, so I hope this is helpful to others.</p>
<p>Firstly, you may wish to read <a href="http://shop.virginmedia.com/content/dam/allyours/pdf/Consumer%20Complaint%20code%20Jan%2011.pdf">Virgin Media&#8217;s Code of Practice for complaints</a>.</p>
<p>To submit a complaint, you can use the web form located here:</p>
<p><a href="https://help.virginmedia.com/system/selfservice.controller?CONFIGURATION=1002&#038;PARTITION_ID=1&#038;TIMEZONE_OFFSET=&#038;USERTYPE=1&#038;VM_CUSTOMER_TYPE=Cable&#038;CMD=ESCALATION_REQUEST">Virgin Media &#8211; Contact Us</a></p>
<ol>
<li>Select <strong>General Enquiry</strong></li>
<li>Choose <strong>I have cable services</strong></li>
<li>Select <strong>Make a customer services complaint</strong></li>
<li>Click the red <strong>Next</strong> button at the bottom of the page</li>
</ol>
<p>This leads you to a contact form where you can submit your complaint.  You will also need you Virgin Media account number and the password you use for logging into the site.</p>
<p>Good luck!</p>
<p><small>Photo credit: Gene Hunt</small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.glenscott.co.uk/blog/2012/01/18/complaining-to-virgin-media/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Going Freelance – Part 3</title>
		<link>http://www.glenscott.co.uk/blog/2012/01/09/going-freelance-part-3/</link>
		<comments>http://www.glenscott.co.uk/blog/2012/01/09/going-freelance-part-3/#comments</comments>
		<pubDate>Mon, 09 Jan 2012 09:29:15 +0000</pubDate>
		<dc:creator>Glen</dc:creator>
				<category><![CDATA[freelancing]]></category>
		<category><![CDATA[accounting]]></category>
		<category><![CDATA[freeagent]]></category>
		<category><![CDATA[invoicing]]></category>

		<guid isPermaLink="false">http://www.glenscott.co.uk/blog/?p=721</guid>
		<description><![CDATA[In Part 2, I mentioned how I used Google Docs as a way of managing business records. Although this turned out to be a reasonable solution, I soon found myself wanting something more bespoke. Enter FreeAgent. I heard a few other freelancers recommending this service, so I signed up for a free 30 day trial [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/teegardin/5913014568/" title="Balancing The Account By Hand by kenteegardin, on Flickr"><img src="http://farm7.staticflickr.com/6052/5913014568_a1f3148bf7.jpg" width="500" height="347" alt="Balancing The Account By Hand"></a></p>
<p>In <a href="/blog/2011/09/23/going-freelance-part-2/">Part 2</a>, I mentioned how I used <a href="http://docs.google.com/">Google Docs</a> as a way of managing business records.  Although this turned out to be a reasonable solution, I soon found myself wanting something more bespoke.</p>
<p>Enter <a href="http://www.freeagent.com">FreeAgent</a>.  I heard a few other freelancers recommending this service, so I signed up for a free 30 day trial to see what the fuss was about.  FreeAgent provides a way of managing your client details, invoices and tax affairs.  The interface is very slick and friendly, and means keeping on top of record keeping is now much less of a chore!</p>
<p>I&#8217;ve now been using the paid service for 2 months and I can heartily recommend it.  If you want to give it a go, you can <a href="http://fre.ag/41if4gaa">use this link to get 10% off the subscription price of FreeAgent</a>.</p>
<p><small>(photo credit: <a href="http://www.seniorliving.org/">www.seniorliving.org</a>)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.glenscott.co.uk/blog/2012/01/09/going-freelance-part-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exporting specific documents from MongoDB</title>
		<link>http://www.glenscott.co.uk/blog/2012/01/05/exporting-a-single-document-from-mongodb/</link>
		<comments>http://www.glenscott.co.uk/blog/2012/01/05/exporting-a-single-document-from-mongodb/#comments</comments>
		<pubDate>Thu, 05 Jan 2012 12:29:34 +0000</pubDate>
		<dc:creator>Glen</dc:creator>
				<category><![CDATA[mongodb]]></category>

		<guid isPermaLink="false">http://www.glenscott.co.uk/blog/?p=710</guid>
		<description><![CDATA[MongoDB comes with a useful tool, mongoexport, for exporting collections. However, you can also use it to export specific documents by utilising the query parameter. You can export a single document using it&#8217;s ObjectId using a command similar to the following: Replace host_name, username, database_name and collection_name with the appropriate values. Replace 4f045677a1ef264746000011 with the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/crodas/4941192194/" title="Mongodb by Cesar Rodas, on Flickr"><img src="http://farm5.staticflickr.com/4078/4941192194_b3b2f39653.jpg" width="500" height="333" alt="Mongodb"></a></p>
<p>MongoDB comes with a useful tool, <code>mongoexport</code>, for exporting collections.  However, you can also use it to export specific documents by utilising the <code>query</code> parameter.  You can export a single document using it&#8217;s ObjectId using a command similar to the following:</p>
<pre class="brush: bash; title: ; notranslate">
mongoexport -h &quot;host_name&quot; -u &quot;username&quot; -d &quot;database_name&quot; -c &quot;collection_name&quot; -q '{&quot;_id&quot;:ObjectId(&quot;4f045677a1ef264746000011&quot;)}' -o output.js -p
</pre>
<ul>
<li>Replace host_name, username, database_name and collection_name with the appropriate values.
</li>
<li>Replace <code>4f045677a1ef264746000011</code> with the ObjectID that you wish to export</li>
</ul>
<p>You will be prompted for a password, and then the document will be written to <code>output.js</code>. </p>
<p>To export multiple documents, you can utilise an <code>$in</code> clause in the query parameter like this:</p>
<pre class="brush: bash; title: ; notranslate">
-q '{&quot;_id&quot;:{&quot;$in&quot; :[ ObjectId(&quot;4f048dc6a1ef26da4b000008&quot;),ObjectId(&quot;4ed8ee16a1ef26085600001a&quot;),ObjectId(&quot;4efc46e0a1ef26b73d0007be&quot;)]}}'
</pre>
<p>To import these exported documents into another MongoDB server, you can use the <code>mongoimport</code> like so:</p>
<pre class="brush: bash; title: ; notranslate">
mongoimport -h &quot;host_name&quot; -u &quot;username&quot; -p -d &quot;database_name&quot; -c &quot;collection_name&quot; output.js
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.glenscott.co.uk/blog/2012/01/05/exporting-a-single-document-from-mongodb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss><!-- Dynamic page generated in 0.420 seconds. --><!-- Cached page generated by WP-Super-Cache on 2012-03-24 19:27:45 -->

