<?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>the codem web development blog - Surry Hills, Sydney, Australia</title>
	<atom:link href="http://www.codem.com.au/streams/feed" rel="self" type="application/rss+xml" />
	<link>http://www.codem.com.au/streams</link>
	<description>web development, architecture and server management</description>
	<lastBuildDate>Wed, 30 Nov 2011 23:22:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Use Github without using Git (and without really trying)</title>
		<link>http://www.codem.com.au/streams/2011/web-development/use-github-without-using-git-and-without-really-trying.html</link>
		<comments>http://www.codem.com.au/streams/2011/web-development/use-github-without-using-git-and-without-really-trying.html#comments</comments>
		<pubDate>Wed, 30 Nov 2011 13:16:31 +0000</pubDate>
		<dc:creator>James Ellis</dc:creator>
				<category><![CDATA[bazaar]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[tech tips]]></category>
		<category><![CDATA[version control]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[work]]></category>
		<category><![CDATA[bzr]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[launchpad]]></category>
		<category><![CDATA[repo]]></category>
		<category><![CDATA[versioning]]></category>

		<guid isPermaLink="false">http://www.codem.com.au/streams/?p=101</guid>
		<description><![CDATA[Learn how to hack in Bzr but use Github to share your code, without using Git.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m probably on the outer when it comes to using <a href="http://git-scm.com/">Git</a>. I find <a href="http://bazaar.canonical.com">Bzr</a> much easier to use, just as fast and prefer it over Git unless absolutely necessary.</p>
<p><a href="http://github.com/codem">One plus Git has over Bzr is Github</a> which is an awesome solution to sharing code, especially within Open Source projects. <a href="http://launchpad.net">Bzr has Launchpad</a> but I&#8217;ve often found it slow and cumbersome. Github has presence as well and really makes a good effort to promote sharing of code.</p>
<p>I wanted to use Github to share some of the Open Source libraries and modules we develop but didn&#8217;t want to change version control systems to do so. The solution is simple:</p>
<ol>
<li>Log in to Github</li>
<li>Create a repository &#8211; give it a name and description.</li>
<li>Grab the URL to the repo &#8211; it will look something like git@github.com:user/repo.git</li>
<li>Ignore the instructions Github gives you, just grab that URL</li>
<li>On your dev machine, switch to the Bzr branch you want to host on Github</li>
<li>Run the command bzr dpush git+ssh://git@github.com/user/repo.git</li>
<li>Wait for a result and that&#8217;s it. If you browse to Github page for your repo, you&#8217;ll see the source</li>
<li>If you have troubles at step #6 run the command but with a -Derror switch. One common error is to not switch that &#8220;:user/repo.git to &#8220;/user/repo.git&#8221;</li>
</ol>
<p>The above relies on you having Bzr installed (2.4 is the latest), the bzr-git plugin and also assumes you&#8217;ve already set up your SSH keys with Github</p>
<p>Branching from Github is just as easy:</p>
<ol>
<li>bzr branch git+ssh://git@github.com/user/repo.git feature_directory</li>
<li>hack away</li>
<li>push back to the same branch or a different one</li>
</ol>
<p>Too easy!</p>
<p>Related to this &#8211; <a href="https://github.com/codem/DisplayAnything">check out our new project &#8220;DisplayAnything&#8221; &#8211; an image gallery module for Silverstripe</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.codem.com.au/streams/2011/web-development/use-github-without-using-git-and-without-really-trying.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Desk space available (Bapple)</title>
		<link>http://www.codem.com.au/streams/2011/office/desk-space-available-bapple.html</link>
		<comments>http://www.codem.com.au/streams/2011/office/desk-space-available-bapple.html#comments</comments>
		<pubDate>Thu, 03 Feb 2011 04:54:54 +0000</pubDate>
		<dc:creator>James Ellis</dc:creator>
				<category><![CDATA[office]]></category>
		<category><![CDATA[desk space]]></category>
		<category><![CDATA[surry hills]]></category>
		<category><![CDATA[sydney]]></category>
		<category><![CDATA[sydphp]]></category>

		<guid isPermaLink="false">http://www.codem.com.au/streams/?p=83</guid>
		<description><![CDATA[Are you looking for a desk/office space in Surry Hills 3 minutes from Central station? Codem&#8217;s web collaborators Bapple are offering a desk space &#8211; here&#8217;s the low down: &#8220;Offering a desk space to web/creative professionals. We&#8217;d also like to work with you if you choose! $86/wk + GST (or $395/mth all inclusive). The space [...]]]></description>
			<content:encoded><![CDATA[<p>Are you looking for a desk/office space in Surry Hills 3 minutes from Central station? Codem&#8217;s web collaborators Bapple are offering a desk space &#8211; here&#8217;s the low down:</p>
<p>&#8220;Offering a desk space to web/creative  professionals. We&#8217;d also like to work with you if you choose! $86/wk + GST (or $395/mth all inclusive). The space comes with:</p>
<ul>
<li> large desk</li>
<li> chair</li>
<li> broadband</li>
<li> A/C</li>
<li>Kitchen and Loo access</li>
<li>24/7 access</li>
<li>sunlight + balcony</li>
</ul>
<p>It&#8217;s a clean, bright office with friendly creative/web developer folk and no  bills&#8221;</p>
<p><img src="http://img1.classistatic.com/cps/kj/110117/537r7/0507ibk_19.jpeg" alt="desk space available, Surry Hills, Sydney" /><br />
(Desk on right will be on the left where white table is pictured.)</p>
<p>Contact Pete for more info on 0419144829 or visit <a href="http://bapple.com.au">the Bapple website</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.codem.com.au/streams/2011/office/desk-space-available-bapple.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>a soft relaunch of the codem website</title>
		<link>http://www.codem.com.au/streams/2010/silverstripe/a-soft-relaunch-of-the-codem-website.html</link>
		<comments>http://www.codem.com.au/streams/2010/silverstripe/a-soft-relaunch-of-the-codem-website.html#comments</comments>
		<pubDate>Mon, 11 Oct 2010 03:07:33 +0000</pubDate>
		<dc:creator>James Ellis</dc:creator>
				<category><![CDATA[news]]></category>
		<category><![CDATA[silverstripe]]></category>
		<category><![CDATA[beta]]></category>
		<category><![CDATA[cms]]></category>
		<category><![CDATA[port]]></category>
		<category><![CDATA[social integration]]></category>
		<category><![CDATA[softlaunch]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.codem.com.au/streams/?p=73</guid>
		<description><![CDATA[I&#8217;ve just merged in v2.0 of the codem website. The update brings a new theme, better integration with social networks and, most importantly, the backend of the site has been switched from WordPress to SilverStripe. I&#8217;m really impressed with SilverStripe as a content managed solution for client websites so have decided to eat our own [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just merged in v2.0 of the codem website. The update brings a new theme, better integration with social networks and, most importantly, the backend of the site has been switched from WordPress to SilverStripe.</p>
<p>I&#8217;m really impressed with SilverStripe as a content managed solution for client websites so have decided to eat our own dog food in order to be better acquainted with the product itself. The complete website port to SilverStripe only took two days of development work &#8211; including the theme updates and implementation of the image gallery (a feature missing from the old site).</p>
<p>If you have any questions/problems regarding the site, please <a href="http://twitter.com/_codem">@_codem</a> us on Twitter or leave a comment here.  One thing to note: As I&#8217;m pushing some new CSS3 and other development techniques, Internet Explorer users will get a slightly squarer and less pretty version.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codem.com.au/streams/2010/silverstripe/a-soft-relaunch-of-the-codem-website.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Zeus and crazy URL rewriting</title>
		<link>http://www.codem.com.au/streams/2010/web-development/zeus-and-crazy-url-rewriting.html</link>
		<comments>http://www.codem.com.au/streams/2010/web-development/zeus-and-crazy-url-rewriting.html#comments</comments>
		<pubDate>Tue, 14 Sep 2010 11:49:38 +0000</pubDate>
		<dc:creator>James Ellis</dc:creator>
				<category><![CDATA[commentary]]></category>
		<category><![CDATA[silverstripe]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[director]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[setbaseurl]]></category>
		<category><![CDATA[zeus]]></category>

		<guid isPermaLink="false">http://www.codem.com.au/streams/?p=64</guid>
		<description><![CDATA[Recently I had a SilverStripe project go live on a host running the &#8220;Zeus&#8221; web server. I&#8217;ve never worked with this beasty before and I can see why &#8211; a pretty bog standard URL rewrite using mod_rewrite in Apache turned into multi-line horror. Here&#8217;s the Apache rewrite, pretty standard stuff that ships with SilverStripe: &#60;IfModule [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I had a <a href="http://www.silverstripe.org">SilverStripe</a> project go live on a host running the &#8220;Zeus&#8221; web server. I&#8217;ve never worked with this beasty before and I can see why &#8211; a pretty bog standard URL rewrite using mod_rewrite in Apache turned into multi-line horror.</p>
<p>Here&#8217;s the Apache rewrite, pretty standard stuff that ships with SilverStripe:</p>
<pre>&lt;IfModule  mod_rewrite.c&gt;
	RewriteEngine On
	RewriteBase /
	RewriteCond %{REQUEST_URI} ^(.*)$
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteRule .* sapphire/main.php?url=%1&amp;%{QUERY_STRING} [L]
&lt;IfModule&gt;</pre>
<p>Here&#8217;s the Zeus equivalent:</p>
<pre><span style="text-decoration: line-through;">insensitive match URL into $ with ^/.*\.(gif|jpg|jpeg|png|css|js|swf|php|html|htm|pdf)$
if not matched
	insensitive match URL into $ with ^/(.*)$
	if matched
		look for file at $1
		if not exists
			# Set the default page to be displayed if the URL is not a file or resource
			set URL = /sapphire/main.php?url=$1
			goto END
		endif
	endif
endif</span></pre>
<p><span style="text-decoration: line-through;">Notice the case insensitivity matching, the Leaning Tower of Ifs and the file extension matching. It works, but not very nicely &#8211; for instance I missed the &#8220;swf&#8221; extension and no Flash files loaded, so it seems to automatically shove anything that doesn&#8217;t match down the pipe with a 404 header (even though the file exists on the server)<br />
</span></p>
<p><strong>Edit</strong> &#8211; I&#8217;ve found a better way to do this.. which started by reading some <a href="http://drupal.org/node/577714">Zeus/Apache rewrite translations at this Drupal page</a>.</p>
<pre>RULE_0_START:
# get the document root
map path into SCRATCH:DOCROOT from /
# initialize our variables
set SCRATCH:ORIG_URL = %{URL}
set SCRATCH:REQUEST_URI = %{URL}

# see if theres any queries in our URL
match URL into $ with ^(.*)\?(.*)$
if matched then
  set SCRATCH:REQUEST_URI = $1
  set SCRATCH:QUERY_STRING = $2
endif
RULE_0_END:

RULE_1_START:
# prepare to search for file, rewrite if its not found
set SCRATCH:REQUEST_FILENAME = %{SCRATCH:DOCROOT}
set SCRATCH:REQUEST_FILENAME . %{SCRATCH:REQUEST_URI}

# check to see if the file requested is an actual file or
# a directory with possibly an index.  don't rewrite if so
look for file at %{SCRATCH:REQUEST_FILENAME}
if not exists then
  look for dir at %{SCRATCH:REQUEST_FILENAME}
  if not exists then
    set URL = /sapphire/main.php?url=%{SCRATCH:REQUEST_URI}
    goto QSA_RULE_START
  endif
endif

# if we made it here then its a file or dir and no rewrite
goto END
RULE_1_END:

QSA_RULE_START:
# append the query string if there was one originally
# the same as [QSA,L] for apache
match SCRATCH:ORIG_URL into % with \?(.*)$
if matched then
  set URL = %{URL}&amp;%{SCRATCH:QUERY_STRING}
endif
goto END
QSA_RULE_END:</pre>
<p>That&#8217;s half the problem &#8211; after changing this I noticed that the base path in SilverStripe was set to  &#8220;/index.php&#8221; resulting in all the links to various CSS and JS files to be broken. To get around this, in your _config.php file, make this change to force the base path</p>
<pre>//force base URL for zeus
Director::setBaseURL('/');</pre>
<p>And you should end up with a functioning site mimicking the (simpler) Apache setup.</p>
<p>In any case, even if it does work, my advice: anything that makes mod_rewrite even harder to implement by turning a 4 line rewrite into a 44 line monster should be avoided.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codem.com.au/streams/2010/web-development/zeus-and-crazy-url-rewriting.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cufón and the flash of unstyled text</title>
		<link>http://www.codem.com.au/streams/2010/web-development/cufon-and-the-flash-of-unstyled-text.html</link>
		<comments>http://www.codem.com.au/streams/2010/web-development/cufon-and-the-flash-of-unstyled-text.html#comments</comments>
		<pubDate>Thu, 09 Sep 2010 00:59:30 +0000</pubDate>
		<dc:creator>James Ellis</dc:creator>
				<category><![CDATA[tech tips]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[cufon]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[font]]></category>
		<category><![CDATA[font replacement]]></category>
		<category><![CDATA[font-face]]></category>
		<category><![CDATA[fouc]]></category>
		<category><![CDATA[ie7]]></category>
		<category><![CDATA[ie8]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[offscreen]]></category>
		<category><![CDATA[replacement]]></category>
		<category><![CDATA[sifr]]></category>

		<guid isPermaLink="false">http://www.codem.com.au/streams/?p=58</guid>
		<description><![CDATA[Want to avoid the flash of unstyled text using Cufón? Try this out.]]></description>
			<content:encoded><![CDATA[<p>A quickie but a goodie. Cufón&#8217;s great for embedding fonts into web pages without having to resort to images or Flash. In some cases there is a Flash Of Unstyled Text (FOUT) when the page is loading, with the default pre-replaced text rendered in a web font shining through for a split second.</p>
<p>I tried all the recommended options including Cufon.now() <a href="http://www.chris-wallace.com/2009/07/25/fix-flash-of-unstyled-content-with-cufon/">and a visibility CSS trick</a> but neither seemed to work. Eventually I came up with this solution, which only involves removing a  class added to Cufón targets. All your offscreen rules happen in a CSS file and not in Javascript.</p>
<p>In your  stylesheet add this class rule (which is applied to every HTML element you wish to have Cufón-ised) e.g &lt;h2 class=&#8221;cufonised&#8221;&gt;</p>
<pre> .cufonised { text-indent : -9000px; }</pre>
<p><em>After</em> your <a href="http://github.com/sorccu/cufon/wiki/usage">Cufon.replace</a> javascript (which I place in a document.ready event handler), add this JS:</p>
<pre>jQuery('.cufonised').removeClass('cufonised');</pre>
<p>&#8230;which resets the text-indent style and shows the Cufón-ised text (i.e the &#8220;Cufon.replace()&#8221; happens off-screen to the left). visibility : hidden/visible doesn&#8217;t seem to work in IE here, so we resort to text-indent.</p>
<p>For non JS enabled browsers and devices, use a noscript tag to reset the style and show the un-Cufón-ised text</p>
<pre>&lt;noscript&gt;&lt;style type="text/css"&gt; .cufonised { text-indent : 0px; } &lt;/style&gt;&lt;/noscript&gt;</pre>
<p>After all that you should have a well behaved Cufón replacement happening cross browser.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codem.com.au/streams/2010/web-development/cufon-and-the-flash-of-unstyled-text.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL &#8211; dealing correctly with date diffs &amp; timezones</title>
		<link>http://www.codem.com.au/streams/2009/web-development/mysql-dealing-correctly-with-date-diffs-timezones.html</link>
		<comments>http://www.codem.com.au/streams/2009/web-development/mysql-dealing-correctly-with-date-diffs-timezones.html#comments</comments>
		<pubDate>Fri, 23 Oct 2009 06:53:48 +0000</pubDate>
		<dc:creator>James Ellis</dc:creator>
				<category><![CDATA[tech tips]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[dates]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[techtip]]></category>
		<category><![CDATA[utc]]></category>

		<guid isPermaLink="false">http://www.customr.net/streams/?p=53</guid>
		<description><![CDATA[A recent project had us dealing with the differences in whole days between two dates stored in a MySQL table. As a first effort, you may turn to the trusty DATEFIFF() function to return the interval. This works well when the dates you have to diff are in the same timezone as the dates you [...]]]></description>
			<content:encoded><![CDATA[<p>A recent project had us dealing with the differences in whole days between two dates stored in a MySQL table. As a first effort, you may turn to the trusty <code>DATEFIFF()</code> function to return the interval. This works well when the dates you have to diff are in the same timezone as the dates you want to display but breaks down when, for instance, your dates are stored in UTC (as they should be) and are displayed in a local timezone.</p>
<p>Take this case of a datetime stored as UTC in a table &#8211; &#8217;2009-10-24 23:00:00&#8242; compared against the current UTC_TIMESTAMP() of, say, &#8217;2009-10-23 02:00:00&#8242;.<br />
A simple <code>DATEFIFF()</code> will return 1 as the day difference between the two datetimes -which is correct.</p>
<p>Now let&#8217;s take a look at those dates when displayed, for instance as UTC + 10. The first datetime becomes &#8217;2009-10-25 09:00:00&#8242; and the second becomes &#8217;2009-10-23 12:00:00&#8242;.  If we&#8217;re displaying those local datetimes as dates on a website along with the day difference, we&#8217;ll get 23/10/2009 &#8211; 25/10/2009 (1 day)  &#8211; as an example, which is  plainly wrong. We could do the diff in scriptland but then MySQL comes with excellent date mathematics functions already.</p>
<p>The issue is that <code>DATEDIFF</code> ignores the time part of the timestamp, only working on the date part.</p>
<p>MySQL provides another method called <code>TIMEDIFF</code>, returning a time value of the datetime difference. In this example, the time value returned is 45:00:00 (i.e 45 hours). This is great, as you can now write a query something like</p>
<pre>SELECT ROUND(EXTRACT(HOUR FROM TIMEDIFF('2009-10-24 23:00:00', '2009-10-23 02:00:00')) / 24)</pre>
<p>Which is a bit of a mess, but gives the required result of 2 days. Solved? yes, until you hit something like the following:</p>
<pre>SELECT ROUND(EXTRACT(HOUR FROM TIMEDIFF('2009-10-23 02:00:00', '2008-05-29 23:00:00'))/ 24)</pre>
<p>&#8230; and suddenly the day difference becomes 35! The problem here is that &#8220;<a title="10.3.2. The TIME Type" href="http://dev.mysql.com/doc/refman/5.1/en/time.html"><code class="literal">TIME</code></a> values may range from <code class="literal">'-838:59:59'</code> to  <code class="literal">'838:59:59'"</code> (<a href="http://dev.mysql.com/doc/refman/5.1/en/time.html">quoting the MySQL TIME documentation</a>), which happens to be about 35 days.</p>
<p>You may tear your hair out here unless you look at the <code>TIMESTAMPDIFF</code> function, which will do exactly what you want, regardless of timezone:</p>
<pre>SELECT ROUND(TIMESTAMPDIFF(HOUR, '2009-10-23 02:00:00', '2009-10-24 23:00:00') / 24)</pre>
<p>Noting that the query uses <code>HOUR</code> as the interval in order to get a fractional day that can be rounded to the nearest integer day after division.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codem.com.au/streams/2009/web-development/mysql-dealing-correctly-with-date-diffs-timezones.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building mongodb on Ubuntu</title>
		<link>http://www.codem.com.au/streams/2009/testing/building-mongodb-on-ubuntu.html</link>
		<comments>http://www.codem.com.au/streams/2009/testing/building-mongodb-on-ubuntu.html#comments</comments>
		<pubDate>Thu, 20 Aug 2009 13:38:37 +0000</pubDate>
		<dc:creator>James Ellis</dc:creator>
				<category><![CDATA[testing]]></category>
		<category><![CDATA[couchdb]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[kubuntu]]></category>
		<category><![CDATA[mongo]]></category>
		<category><![CDATA[mongodb]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[rdbms]]></category>
		<category><![CDATA[schema]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[ububtu]]></category>

		<guid isPermaLink="false">http://www.customr.net/streams/?p=50</guid>
		<description><![CDATA[The basics of installing MongoDB on Ubuntu, for some testing.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been looking at mongodb as a solution for some projects. It looks like a decent solution that sits between a standard RDBMS like MySQL or Postgres and schema-less solutions like CouchDB. Result: I need to do some testing&#8230;</p>
<p>As the <a href="http://mongodb.org">mongodb website says</a>: <cite>A key goal of MongoDB is to bridge the gap between key/value stores (which are fast and highly scalable) and traditional RDBMS systems (which are deep in functionality).</cite></p>
<p>It&#8217;s also <a title="warning: nerd alert" href="http://en.wikipedia.org/wiki/Mongo_(planet)">the name of the planet in <em>Flash Gordon</em></a>, the big guy&#8217;s name in <em>Blazing Saddles</em> and the name of the giant Gingerbread man in <em>Shrek</em>, in case you were wondering.<br />
According to the mongodb site, it draws it&#8217;s name from &#8220;hu<strong>mongo</strong>us&#8221; &#8211; although I always thought that was spelt hum<strong>u</strong>ngous but then we&#8217;d have ended up with MungoDB which doesn&#8217;t have the same pop culture links. Digression.</p>
<h4>Update for 10.10</h4>
<p>For users of Ubuntu + derivatives 10.10 and up, mongodb is available via APT, the Ubuntu package management system.<br />
Simply:</p>
<pre>sudo aptitude install mongodb</pre>
<p>Which will install the core and any dependencies, along with setting up a mongodb user and providing an <code>upstart</code> job to manage mongod. To stop, start and restart mongodb, issue the commands <code>sudo service mongodb stop|start|restart</code> or alternatively <code>sudo stop|start|restart mongodb</code>.<br />
On Ubuntu, the mongodb config file lives at /etc/mongodb.conf. Unfortunately it doesn&#8217;t look like we have a conf.d system to allow core config overrides just yet.</p>
<p>For those using older versions of Ubuntu, read on. If you have 10.10+ installed, then skip to the <a href="#install-a-php-driver">Install a PHP Driver</a> part below.</p>
<h4>10.04 and earlier&#8230;</h4>
<p>I do most testing on a Kubuntu (9.04) system, so <a href="http://www.mongodb.org/display/DOCS/Building+for+Linux#BuildingforLinux-Ubuntu9.04">the instructions for building on Ubuntu can be used</a>. (Kubuntu is just Ubuntu with KDE as the desktop environment).</p>
<p>Here&#8217;s the process (with some changes based on some problems I encountered):</p>
<h4>Install the related packages</h4>
<p>You can substitute aptitude for apt-get if you want. I  prefer aptitude as it covers all the APT commands.</p>
<pre>sudo aptitude install tcsh git-core <a href="http://www.scons.org/">scons</a> g++
sudo aptitude install libpcre++-dev libboost1.37-dev libreadline-dev</pre>
<p>There are two changes here from the instructions:</p>
<ol>
<li>libmozjs-dev in Ubuntu 9.04 conflicts with xulrunner-1.9. This means the package manager will try to remove anything that depends on xulrunner-1.9, namely Firefox 3.5. In my case aptitude tried to downgrade Firefox to 3.5b4. To work around this install it from source (see below). This won&#8217;t be a problem if you don&#8217;t need xulrunner-1.9 or its dependencies (or if you aren&#8217;t installing in a desktop environment that uses Firefox 3.5)</li>
<li>You will need libboost1.37-dev rather than libboost-dev, otherwise the mongodb install process will complain about an old version of libboost.</li>
</ol>
<p>Finally, I&#8217;m not sure why tcsh is needed given it&#8217;s just a shell and I have bash installed &#8211; maybe scons needs it?</p>
<h4>SpiderMonkey</h4>
<p>This process will install SpiderMonkey in place of the libmozjs-dev packages, which MongoDB uses to parse data reduction functions. The <a href="http://www.mongodb.org/display/DOCS/Building+Spider+Monkey">MongoDB site provides the background to this</a>.<br />
I&#8217;m installing in a tmp directory in my home directory</p>
<pre>cd ~
mkdir tmp &amp;&amp; cd tmp
wget ftp://ftp.mozilla.org/pub/mozilla.org/js/js-1.7.0.tar.gz
tar -zxvf js-1.7.0.tar.gz
cd js/src
export CFLAGS="-DJS_C_STRINGS_ARE_UTF8"
make -f Makefile.ref
sudo JS_DIST=/usr make -f Makefile.ref export</pre>
<h4>Download and install MongoDB</h4>
<p>Finally, get MongoDB using Git and install it using scons:</p>
<pre>cd ~/tmp
git clone git://github.com/mongodb/mongo.git
cd mongo
scons all
sudo scons --prefix=/opt/mongo install</pre>
<p>If all goes well, MongoDB should install to /opt/mongo. In /opt/mongo/bin you&#8217;ll see a mongod executable, which when executed starts the mongo daemon.</p>
<p>Create a location to store the mongodb database(s). I&#8217;m just testing so I created it in my home directory. You can create it anywhere you want, providing the user starting mongod can read and write to it.</p>
<pre>mkdir -p ~/testing/mongo/data/db</pre>
<p>Start mongo, as your user</p>
<pre>/opt/mongo/bin/mongod --dbpath ~/testing/mongo/data/db</pre>
<p>Mongodb should spit out some startup information, telling you there is a web interface listening on port 28017 (browse to http://localhost:28017, or the IP of the system, for the results). Hit Ctrl-c to kill mongod when done.</p>
<h4>Help and keeping up-to-date</h4>
<p>To get some basic mongod help:</p>
<pre>/opt/mongo/bin/mongod --help</pre>
<p>To keep up to date, switch to your mongo source directory (~/tmp/mongo in my case) and:</p>
<pre>git pull</pre>
<p>Then rebuild.</p>
<h4 id="install-a-php-driver">Install a PHP driver</h4>
<p>The <a href="http://php.net/mongo">PHP Mongo driver</a> can be installed using PECL:</p>
<pre>sudo pecl install mongo</pre>
<p>and follow the instructions.</p>
<p>Now for some testing!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codem.com.au/streams/2009/testing/building-mongodb-on-ubuntu.html/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>wouldn&#8217;t it be nice&#8230;</title>
		<link>http://www.codem.com.au/streams/2009/web-development/wouldnt-it-be-nice.html</link>
		<comments>http://www.codem.com.au/streams/2009/web-development/wouldnt-it-be-nice.html#comments</comments>
		<pubDate>Thu, 14 May 2009 13:18:57 +0000</pubDate>
		<dc:creator>James Ellis</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[arora]]></category>
		<category><![CDATA[broken page icon]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[browser support]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[compatibility mode]]></category>
		<category><![CDATA[ie8]]></category>
		<category><![CDATA[safari]]></category>
		<category><![CDATA[webkit]]></category>

		<guid isPermaLink="false">http://www.customr.net/streams/?p=42</guid>
		<description><![CDATA[Could Microsoft offer a WebKit rendering option in Internet Explorer 8?]]></description>
			<content:encoded><![CDATA[<p>With the release of Internet Explorer 8 (IE8) developers are finally in the position of enjoying the benefits of a standards compliant browser from each major vendor (think Firefox, Opera, Safari, Chrome and now IE8) &#8211; I thought the day would never come!</p>
<p>IE8 though, still tips a hat to its less illustrious predecessors with &#8220;compatibility mode&#8221; &#8211; something sure to confuse the browsing public, especially <a href="http://www.microsoft.com/library/media/1033/windows/images/internet-explorer/default/feat_200_compatview.jpg">that broken page icon</a>. To me it just seems to be a half-baked solution that will cause more problems than its worth &#8211; I can envisage people clicking away at that button and ending up in page layout hell.</p>
<p>It&#8217;s a hole that Microsoft have dug themselves into by not doing incremental updates to their browser rendering engine, so forcing developers to keep in step as new, non backwards-compatible, changes appear.</p>
<p>Rather than delving into it further, I&#8217;d like to propose a solution. Instead of dealing with the various idiosyncratic rendering engine(s) in IE, how about letting developers specify, say, <a href="http://webkit.org">WebKit</a> as the rendering engine for their sites? Microsoft engineers have shown that they can switch rendering modes on the fly with their &#8220;X-UA-Compatible&#8221; HTTP header &#8211; would it be too much to ask for support of something like&#8230;</p>
<pre>header('X-IE-RenderEngine: WebKit');</pre>
<p>which could tell IE to pass the incoming document off to WebKit?</p>
<p><a href="http://google.com/chrome">Google</a>, <a href="http://code.google.com/p/arora/">Arora</a> and <a href="http://apple.com/safari">Apple</a> have shown they can get excellent WebKit based browsers running on Windows &#8211; why not Microsoft, too?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codem.com.au/streams/2009/web-development/wouldnt-it-be-nice.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Consuming XML, fast, with PHP and XMLReader</title>
		<link>http://www.codem.com.au/streams/2009/web-development/consuming-xml-fast-with-php-and-xmlreader.html</link>
		<comments>http://www.codem.com.au/streams/2009/web-development/consuming-xml-fast-with-php-and-xmlreader.html#comments</comments>
		<pubDate>Sun, 03 May 2009 12:37:13 +0000</pubDate>
		<dc:creator>James Ellis</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[pullparsing]]></category>
		<category><![CDATA[simplexml]]></category>
		<category><![CDATA[sydphp]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[xmlreader]]></category>

		<guid isPermaLink="false">http://www.customr.net/streams/?p=32</guid>
		<description><![CDATA[Let&#8217;s face it, XML isn&#8217;t the lightest of data serialisation formats out there. Consider and compare this: &#60;alternate_description&#62;something else&#60;alternate_description&#62; against this, in JSON { alternate_description : "something else" } Those repetitive XML tags are really just extra bytes to download and parse. Unfortunately, sometimes, we have to consume huge gobs of XML for a project [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s face it, XML isn&#8217;t the lightest of data serialisation formats out there. Consider and compare this:</p>
<pre>&lt;alternate_description&gt;something else&lt;alternate_description&gt;</pre>
<p>against this, in JSON</p>
<pre>{ alternate_description : "something else" }</pre>
<p>Those repetitive XML tags are really just extra bytes to download and parse. Unfortunately, sometimes, we have to consume huge gobs of XML for a project and for that we have <a href="http://php.net/xmlreader">XMLReader</a>, the lesser known cousin of <a href="http://php.net/simplexml">SimpleXML.</a></p>
<p>Unlike SimpleXML, which consumes the entire document before making it available for parsing, XMLReader &#8220;acts as a cursor going forward on the document stream and stopping at each node on the way&#8221; (php.net/xmlreader). Kind of like a line-by-line CSV parser but acting on the nodes of an XML document.<br />
Choosing the right XML parser for the job is very important, as if you don&#8217;t choose correctly it can lead to unwanted and avoidable performance issues on your server.</p>
<p>To illustrate this, I pointed both SimpleXML and XMLReader at the same 190MB XML document via a PHP shell script, ran two tests on each extension and profiled the results.  Test one found a node at the start of the file, the other test found a node at the end of the file.</p>
<p>The XML document in question is a standard XML document containing 21467 records, it looks something like this:</p>
<pre>&lt;persons&gt;
   &lt;person&gt;
       &lt;name&gt;John&lt;/name&gt;
       &lt;!-- other nodes --&gt;
   &lt;/person&gt;
   &lt;!-- 21466 person nodes --&gt;
&lt;/persons&gt;</pre>
<p>Peak memory usage is measured by the &#8220;top&#8221; command (%MEM).</p>
<h4>SimpleXML</h4>
<pre>Test One:
Nodes : 1
Peak Memory Usage: 18%
Processed 190MB of XML in 3.14164 seconds

Test Two:
Nodes : 21467
Peak Memory Usage: 18%
Processed 190MB of XML in 3.20796 seconds</pre>
<h4>XMLReader</h4>
<pre>Test One:
Nodes: 1
Peak Memory Usage: 0.3%
Processed 190MB of XML in 0.00128 seconds

Test Two:
Nodes : 21467
Peak Memory Usage: 0.7%
Processed 190MB of XML in 16.4478 seconds</pre>
<p>These results really give an indication of the different uses of both extensions.</p>
<p>XMLReader flew through finding the first element in no time at all while SimpleXML took about the same time to find the first and the last element. The big difference is memory &#8212; XMLReader performed about 50 times better than SimpleXML.<br />
Understandably, XMLReader took a lot longer to find the last node as it had to process each node in the document until it found a match. A seek() method on the XMLReader class would obviously be useful here to skip unwanted nodes.</p>
<h4>Use cases</h4>
<p>For simple parsing such as RSS feed handling and small XML documents SimpleXML is definitely the way to go. It&#8217;s easy access to document nodes is a great advantage.<br />
For larger document importing, XMLReader wins hands-down due to its ability to read the document node by node with limited impact on system memory, in fact you can parse XML documents with XMLReader that are larger than the available system memory.</p>
<p>One final tip: avoid building large data structures while processing large XML documents with XMLReader as it defeats the purpose of using XMLReader in the first place &#8212; just grab the data needed to perform an operation and skip to the next iteration.</p>
<h4>Other Resources</h4>
<ul>
<li><a href="http://www.ibm.com/developerworks/library/x-pullparsingphp.html">Pull parsing XML in PHP</a></li>
<li><a href="http://php.net/simplexml">SimpleXML documentation</a></li>
<li><a href="http://php.net/xmlreader">XMLReader documentation</a></li>
<li><a href="http://blog.lib.umn.edu/fenne035/academe2.0/2007/04/speed_reading_xml_with_php_xml.html">Speed reading XML with XMLReader</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.codem.com.au/streams/2009/web-development/consuming-xml-fast-with-php-and-xmlreader.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>providing patches in feature-based web development</title>
		<link>http://www.codem.com.au/streams/2009/web-development/providing-patches-in-feature-based-web-development.html</link>
		<comments>http://www.codem.com.au/streams/2009/web-development/providing-patches-in-feature-based-web-development.html#comments</comments>
		<pubDate>Fri, 27 Feb 2009 06:46:22 +0000</pubDate>
		<dc:creator>James Ellis</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[bazaar]]></category>
		<category><![CDATA[sydphp]]></category>
		<category><![CDATA[version control]]></category>

		<guid isPermaLink="false">http://developments.customr.net/?p=24</guid>
		<description><![CDATA[A while back, I did a presentation to the Sydney PHP Group on feature based web development using Bazaar, a distributed version control system. At the time is was quite interesting to see the number of attendees who a) didn&#8217;t know about or use version control or b) were using CVS (the instant coffee of [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://sydphp.org/2008/05/11/presentation-feature-based-web-development-with-bazaar/">A while back</a>, I did a presentation to the <a href="http://sydphp.org">Sydney PHP Group</a> <a href="http://sydphp.org/2008/05/11/presentation-feature-based-web-development-with-bazaar/">on feature based web development</a> using <a href="http://bazaar-vcs.org">Bazaar</a>, a distributed version control system. At the time is was quite interesting to see the number of attendees who a) didn&#8217;t know about or use version control or b) were using CVS (the instant coffee of version control).</p>
<p>If you are doing web development amongst a team and want a really solid branching system without headache inducing conflict/merge issues then Bazaar is a really valuable tool. One of the best things about patching in Bazaar is the <em>send</em> command:</p>
<pre>
$ bzr help send
Purpose: Mail or create a merge-directive for submitting changes.
Usage:   bzr send [SUBMIT_BRANCH] [PUBLIC_BRANCH]
</pre>
<p>The send command enables you by default to mail a patch file to the patch manager, who can then test and merge it into a centralised mainline branch. If you don&#8217;t want to mail patches they can be uploaded to the remote server in one go, even though <em>send</em> doesn&#8217;t as yet support saving to remote locations.<br />
The trick is to provide &#8216;-&#8217; (stdout) as the output file then pipe it to ssh for upload to your remote directives location.</p>
<pre>
bzr send -o - sftp://me@someserver/path/to/remote/branch | ssh me@someserver "cat > /path/to/directives/my.patch"
</pre>
<p>After bzr does it&#8217;s stuff and you&#8217;ve logged in to the remote server, a patch file is available (my.patch) that can be applied, tested and either reverted or committed using bzr merge, pull, commit and revert.</p>
<p>Tip 1: if you don&#8217;t have SSH access to your server <a href="https://launchpad.net/bzr-upload">try the bzr upload plugin</a><br />
Tip 2: storing your public ssh key on the remote server will allow you to perform the send without password prompts.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codem.com.au/streams/2009/web-development/providing-patches-in-feature-based-web-development.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

