<?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>Flipflops.org</title>
	<atom:link href="http://www.flipflops.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.flipflops.org</link>
	<description>Flipflops.org is about web development and fairly conceptual art</description>
	<lastBuildDate>Tue, 31 Jan 2012 23:26:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>I miss the old Streetview</title>
		<link>http://www.flipflops.org/2012/02/01/i-miss-the-old-streetview/</link>
		<comments>http://www.flipflops.org/2012/02/01/i-miss-the-old-streetview/#comments</comments>
		<pubDate>Tue, 31 Jan 2012 23:26:16 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
				<category><![CDATA[Google]]></category>
		<category><![CDATA[googlemaps]]></category>
		<category><![CDATA[streetview]]></category>
		<category><![CDATA[v2]]></category>
		<category><![CDATA[v3]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/?p=425</guid>
		<description><![CDATA[Recently I&#8217;ve been updating a site with some quite complex map related functionality from Google maps v2 to Google maps v3. All in all it has been straight forward and worth doing. The one disappointment IMO has been Streetview &#8211; the old version was so much slicker. The new version is easier to implement, but [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I&#8217;ve been updating a site with some quite complex map related functionality from Google maps v2 to Google maps v3. All in all it has been straight forward and worth doing.</p>
<p>The one disappointment IMO has been Streetview &#8211; the old version was so much slicker. The new version is easier to implement, but that is as positive as I can be. I miss being able to click in the distance and zoom down the road; I miss the swoosh as you move from position to position; I miss built in Full Screen.</p>
<p>On the flip side we now the have <a href="http://code.google.com/apis/maps/documentation/streetview/">API for static streetview images</a>  &#8211; I&#8217;ve been using <a href="http://jamiethompson.co.uk/web/2010/05/15/google-streetview-static-api/">Jamie Thompson&#8217;s</a> brilliant work on getting static map images up until now, but it is time to move on.</p>
<p>Slightly irritating is the fact you need to convert old (v2) Streetview panorama locations (if you have them saved) to show the locations as static images or as saved Streetview panoramas.</p>
<p>To convert a v2 panorama to a v3 panorama:</p>
<ul>
<li>&#8216;yaw&#8217; has become &#8216;heading&#8217;</li>
<li>change the sign of &#8216;pitch&#8217; e.g. -1.80999 becomes 1.80999</li>
<li>add 1 to your &#8216;zoom&#8217; level</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2012/02/01/i-miss-the-old-streetview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Speed matters</title>
		<link>http://www.flipflops.org/2012/01/13/speed-matters/</link>
		<comments>http://www.flipflops.org/2012/01/13/speed-matters/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 21:48:13 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
				<category><![CDATA[Google]]></category>
		<category><![CDATA[Web Things]]></category>
		<category><![CDATA[seo]]></category>
		<category><![CDATA[servers]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/?p=411</guid>
		<description><![CDATA[To my unending amazement, many people I&#8217;ve worked with simply don&#8217;t believe that speed matters as a factor in Search Engine rankings. I don&#8217;t understand why. It&#8217;s not like Google (and lets face it, we are talking about Google) are being coy about it. (see links) When you work in an office with stupidly fast [...]]]></description>
			<content:encoded><![CDATA[<p>To my unending amazement, many people I&#8217;ve worked with simply don&#8217;t believe that speed matters as a factor in Search Engine rankings. I don&#8217;t understand why. It&#8217;s not like Google (and lets face it, we are talking about Google) are being coy about it. (see links)</p>
<p>When you work in an office with stupidly fast broadband, maybe you just forget? But you shouldn&#8217;t assume that the people looking at your websites do.</p>
<p>The bit that really bugs me is this peculiar &#8216;head in the sand&#8217; attitude. It does take more than a few minutes of thinking to come up with any number plausible reasons why speed is important for Search Engine Optimisation (aside from the fact the Google say it is). Try it, take a few seconds to think.</p>
<p>For me though the reasons that scream out at me are User Experience and Money.</p>
<h2>User experience</h2>
<p>First off &#8211; I admit this isn&#8217;t really an SEO factor, is it? People are busy, they don&#8217;t want to spend valuable time waiting for a web page to load, at least I know I don&#8217;t. I have better things to do, and I&#8217;m not that weird.</p>
<p>But why would Google care? I can rationalise that they want people to look at Ads. And then click on them.  Probably a good idea to make websites faster so people don&#8217;t get bored and do something else, or find the bit of content they are looking for before the ads have loaded (because the ads come last).</p>
<h2>Time = Money</h2>
<p>Google must index billions of pages per day. It stands to reason that the faster a site loads, the faster it can be indexed. I&#8217;m guessing that it costs about the same to run a server whether it is indexing million pages per day or 10 million &#8211; but if your business is based on data the faster you can chew through data the better &#8211; and therefore it also makes sense for Google to promote an internet that lets them index more, faster.</p>
<h2>But we don&#8217;t have the time, it&#8217;s to hard&#8230;</h2>
<p>No it isn&#8217;t. Of course, as with any work there is optimum point in terms of cost vs. benefit (and that will be different for every site).</p>
<p>My gut feeling (and I don&#8217;t have any firm evidence for this) is that speed becomes more important the more traffic you get. If you&#8217;re site gets 50 visitors per day, then in a sense it is what it is &#8211; what you need to focus on is link building and content. However if your site gets 5000 visitors per day, then the chances are you&#8217;ve got quality links and good content &#8211; so how do you improve? I think the answer is the speed and user experience.</p>
<p>A fast website either means no traffic, no load on your server, no pictures, no javascript &#8211; in short a bit of old school html text&#8230; or it if is a big site, it means you care. It means that you have taken the time to think about users, you&#8217;ve spent a bit of money on hardware or code. It means that you are a quality business and therefore it is a good bet that you have better quality data on your site. It means that people will pay more to be associated with your site.</p>
<h2>How to make your site fast</h2>
<p>Hell, that&#8217;s a bold statement. It&#8217;s different for everybody. Think about the usual suspects, too much JavaScript, un-optimised images, sloooow queries with no indexes.</p>
<p>There are a myriad of solutions, and you don&#8217;t have to have Prototype, Jquery and Mootools all running on the same page, choose a single framework at a time &#8211; you will be amazed.</p>
<ul>
<li>Use a CDN. </li>
<li>Use a cache server like <a href="https://www.varnish-cache.org/">Varnish</a>.</li>
<li>If you&#8217;re a bit lazy &#8211; try out <a href="http://code.google.com/speed/page-speed/docs/module.html">mod_pagespeed</a> (sometimes it&#8217;s fab, sometimes it&#8217;ll melt your server)</li>
<li>Be brave, leave the Apache comfort zone and use <a href="http://nginx.org/">Nginx</a> or <a href="http://www.lighttpd.net/">Lighttpd</a></li>
<li>Use <a href="http://code.google.com/p/minify/">minify</a></li>
</ul>
<h2>Fringe benefits</h2>
<p>Chances are you&#8217;ll end up using some kind of caching and you&#8217;ll start setting sensible expires headers for your static content. But just think you&#8217;ll never have to tell somebody at the end of the phone to clear their browser cache again. And remember, the client is not an idiot because their browser hasn&#8217;t magically detected that a style sheet or an image has changed, and the website they have paid for looks a bit rubbish.</p>
<p>(by the way I don&#8217;t always practice what I&#8217;ve just preached, but at least I feel bad about it)</p>
<p><a href="http://googlewebmastercentral.blogspot.com/2010/04/using-site-speed-in-web-search-ranking.html">http://googlewebmastercentral.blogspot.com/2010/04/using-site-speed-in-web-search-ranking.html</a><br />
<a href="http://www.mattcutts.com/blog/site-speed/">http://www.mattcutts.com/blog/site-speed/</a><br />
<a href="http://www.google.co.uk/search?sourceid=chrome&#038;ie=UTF-8&#038;q=google+speed+as+factor+in+search+engine+ranking" title="google speed as factor in search engine ranking">etc.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2012/01/13/speed-matters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XPath to the rescue. Again?</title>
		<link>http://www.flipflops.org/2011/09/24/xpath-to-the-rescue-again/</link>
		<comments>http://www.flipflops.org/2011/09/24/xpath-to-the-rescue-again/#comments</comments>
		<pubDate>Sat, 24 Sep 2011 20:33:07 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[XPath]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/?p=408</guid>
		<description><![CDATA[It&#8217;s odd. I don&#8217;t think about think about XPath from one month to the next. But once in a while, when my usual solutions have all come up blank. Ta-Da XPath to the rescue! Recently as part of a site I was working on, the design basically required that I inject a block of content [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s odd. I don&#8217;t think about think about XPath from one month to the next. But once in a while, when my usual solutions have all come up blank. Ta-Da XPath to the rescue!</p>
<p>Recently as part of a site I was working on, the design basically required that I inject a block of content into a nested list (part of an elaborate menu actually) &#8211; bit of a fiddle because modifying the code that generated the list was not an option.</p>
<p>My first avenues of attack were just simple str_replace() and a regex replace, but I just couldn&#8217;t get it work consistently &#8211; there were two many variables &#8211; additional attributes, white-space etc. The two constants were that the code fragment validated as xhtml (hence xml) and I would always have a class that I could use as a hook.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #666666; font-style: italic;">// $menu - fragment of html consisting of nested UL's </span>
&nbsp;
<span style="color: #000088;">$xml</span> <span style="color: #339933;">=</span> <span style="color: #990000;">simplexml_load_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$menu</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$nodes</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">xpath</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'//*[@class = &quot;current&quot;]'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$nodes</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000088;">$nodes</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addChild</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'div'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'text_to_replace'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$menu</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">asXML</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'text_to_replace'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$str</span><span style="color: #339933;">,</span> <span style="color: #000088;">$menu</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$menu</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><code>//*[@class = "current"]</code> finds nodes at any level with where the class attribute contains &#8216;current&#8217;.</p>
<p><code>node[0]</code> is the first instance of a node with this attribute and inject some place-holder text.</p>
<p><code>$menu = $xml->asXML();</code> our modified list.</p>
<p>Hey presto!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2011/09/24/xpath-to-the-rescue-again/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Looking for stock photos?</title>
		<link>http://www.flipflops.org/2011/09/24/looking-for-stock-photos/</link>
		<comments>http://www.flipflops.org/2011/09/24/looking-for-stock-photos/#comments</comments>
		<pubDate>Sat, 24 Sep 2011 20:06:27 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
				<category><![CDATA[Photography]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[stock photography]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/?p=406</guid>
		<description><![CDATA[To tell the truth I do very little design work. I always find it particularly irritating when my shockingly expensive credits expire before I have a chance to use them. So it was very nice when earlier this I was offered the chance to try out Fotolia for 1 month for free. Ironically I was [...]]]></description>
			<content:encoded><![CDATA[<p>To tell the truth I do very little design work. I always find it particularly irritating when my shockingly expensive credits expire before I have a chance to use them.</p>
<p>So it was very nice when earlier this I was offered the chance to try out <a href="https://en.fotolia.com/">Fotolia</a> for 1 month for free. Ironically I was so busy that I didn&#8217;t get around to actually signing up for ages. Eventually I did though, and to be honest it&#8217;s great. The website is fast, the search is good, and most importantly there is an extremely wide range of images and illustrations. </p>
<p>Obviously <em>this is</em> a shameless plug, but the next time I need to buy any stock images, Fotolia is actually going to be the first place I look. Good images and very good value (particularly the vector stuff).</p>
<p>For bloggers et al there is also an info microsite <a href="http://fotolianews.com/">http://fotolianews.com/</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2011/09/24/looking-for-stock-photos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Four pieces</title>
		<link>http://www.flipflops.org/2011/06/14/four-pieces/</link>
		<comments>http://www.flipflops.org/2011/06/14/four-pieces/#comments</comments>
		<pubDate>Mon, 13 Jun 2011 23:10:01 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
				<category><![CDATA[Art]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/?p=393</guid>
		<description><![CDATA[It&#8217;s been a while since I exhibited anything, but I&#8217;ve got three new pieces and one old one in the summer show at the Redearth gallery (currently without a decent website unfortunately)]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a while since I exhibited anything, but I&#8217;ve got three new pieces and one old one in the summer show at the <a href="http://www.redearth-art.com/">Redearth gallery</a> (currently without a decent website unfortunately)</p>
<p><img src="http://www.flipflops.org/wp-content/uploads/2011/06/smile-281x300.jpg" alt="" title="smile" width="281" height="300" class="aligncenter size-medium wp-image-397" /></p>
<p><img src="http://www.flipflops.org/wp-content/uploads/2011/06/glow-278x300.jpg" alt="" title="glow" width="278" height="300" class="aligncenter size-medium wp-image-396" /></p>
<p><img src="http://www.flipflops.org/wp-content/uploads/2011/06/untitled-2011-1-281x300.jpg" alt="" title="untitled-2011-1" width="281" height="300" class="aligncenter size-medium wp-image-395" /></p>
<p><img src="http://www.flipflops.org/wp-content/uploads/2011/06/untitled-2007-3-282x300.jpg" alt="" title="untitled-2007-3" width="282" height="300" class="aligncenter size-medium wp-image-394" /></p>
<p><a href="http://www.flipflops.org/wp-content/uploads/2011/06/summer.gif"><img src="http://www.flipflops.org/wp-content/uploads/2011/06/summer-300x256.gif" alt="" title="summer" width="300" height="256" class="aligncenter size-medium wp-image-399" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2011/06/14/four-pieces/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick debug function</title>
		<link>http://www.flipflops.org/2011/06/13/quick-debug-function/</link>
		<comments>http://www.flipflops.org/2011/06/13/quick-debug-function/#comments</comments>
		<pubDate>Mon, 13 Jun 2011 22:55:07 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Stuff]]></category>
		<category><![CDATA[Web Things]]></category>
		<category><![CDATA[debug]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/?p=383</guid>
		<description><![CDATA[It&#8217;s not pretty and it&#8217;s not elegant, but we&#8217;ve all got a bag of quick and dirty functions that help make life just a little bit easier. This is a simple print_r() but I finally got fed up of loosing my quick debug statements and so added the line name and file number from a [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s not pretty and it&#8217;s not elegant, but we&#8217;ve all got a bag of quick and dirty functions that help make life just a little bit easier.</p>
<p>This is a simple <code>print_r()</code> but I finally got fed up of loosing my quick debug statements and so added the line name and file number from a stack trace (substitute var_export() to taste).</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> pr<span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;pre&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;/pre &gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$d</span> <span style="color: #339933;">=</span> <span style="color: #990000;">debug_backtrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$d</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'file'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;br /&gt;Line: &lt;b&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$d</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'line'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/b&gt;'</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;hr /&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2011/06/13/quick-debug-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Beer loving blog</title>
		<link>http://www.flipflops.org/2011/04/15/beer-loving-blog/</link>
		<comments>http://www.flipflops.org/2011/04/15/beer-loving-blog/#comments</comments>
		<pubDate>Fri, 15 Apr 2011 13:44:23 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
				<category><![CDATA[Stuff]]></category>
		<category><![CDATA[beer]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[food for free]]></category>
		<category><![CDATA[pubs]]></category>
		<category><![CDATA[stinging nettles]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/?p=381</guid>
		<description><![CDATA[Useyourlocal.com (great website if you&#8217;re away for the weekend and need to get a drink in a decent pub fast) have just started a blog with the highly imaginative name of blog. Anyway they&#8217;ve just written an article about beer made from weird stuff like stinging nettles. I&#8217;ve had omlettes made from nettles and also [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.useyourlocal.com">Useyourlocal.com</a> (great website if you&#8217;re away for the weekend and need to get a drink in a decent pub fast) have just started a blog with the highly imaginative name of blog.</p>
<p>Anyway they&#8217;ve just written an article about <a href="http://www.useyourlocal.com/blog/2011/04/prickly-pints/">beer made from weird stuff like stinging nettles</a>. I&#8217;ve had omlettes made from nettles and also nettle and wild garlic soup &#8211; but never nettle beer. <a href="http://www.foodforfree.org/">Food for free</a> is one thing (great) &#8211; beer for free must be even better.</p>
<p>I think they could be onto a winner. Now that summer is coming and my various sheds have risen above freezing, I might give this home brewing lark a go. There are certainly plenty of nettles round me&#8230; and I bet I could do something good with dandelions.</p>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2011/04/15/beer-loving-blog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The bathroom crocodile</title>
		<link>http://www.flipflops.org/2011/03/08/the-bathroom-crocodile/</link>
		<comments>http://www.flipflops.org/2011/03/08/the-bathroom-crocodile/#comments</comments>
		<pubDate>Tue, 08 Mar 2011 14:08:15 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
				<category><![CDATA[Stuff]]></category>
		<category><![CDATA[teeth parenting]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/2011/03/08/the-bathroom-crocodile/</guid>
		<description><![CDATA[Telling your a child that if they don&#8217;t brush their teeth, then all their teeth will fall out, and / or the dentist will cause them a great deal of pain doesn&#8217;t really cut it with a three year old (and is also a questionable approach) At home we&#8217;ve come up with a new strategy. [...]]]></description>
			<content:encoded><![CDATA[<p>Telling your a child that if they don&#8217;t brush their teeth, then all their teeth will fall out, and / or the dentist will cause them a great deal of pain doesn&#8217;t really cut it with a three year old (and is also a questionable approach)</p>
<p>At home we&#8217;ve come up with a new strategy. In our bathroom we have a very hungry crocodile, but fortunately he doesn&#8217;t like to eat children with clean teeth.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2011/03/08/the-bathroom-crocodile/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reorder a nested HTML list in PHP</title>
		<link>http://www.flipflops.org/2011/02/13/reorder-a-nested-html-list-in-php/</link>
		<comments>http://www.flipflops.org/2011/02/13/reorder-a-nested-html-list-in-php/#comments</comments>
		<pubDate>Sat, 12 Feb 2011 23:11:52 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Things]]></category>
		<category><![CDATA[simpleXML]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[XMLDom]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/?p=374</guid>
		<description><![CDATA[Recently I was working on website where I had to re-order a nested list (part of a navigation menu) &#8211; unfortunately I only had access to fragment of HTML so I couldn&#8217;t just manipulate the arrays from which it was built. The menu was compiled from various arrays and months within years sometimes came out [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I was working on website where I had to re-order a nested list (part of a navigation menu) &#8211; unfortunately I only had access to fragment of HTML so I couldn&#8217;t just manipulate the arrays from which it was built. The menu was compiled from various arrays and months within years sometimes came out all wrong.</p>
<p>So I thought, I&#8217;d just treat it as a bit of XML (which obviously it is) and re-order it using PHPs native XML handling classes. XML is one of those things that I use frequently, but never really do anything with, and finding a solution took me rather longer than I had expected. It is a mixture of simpleXML and XMLDom.</p>
<p>One of the main problems was the lack any real examples.</p>
<p>If anyone can suggest a more elegant solution, I would love to hear it.</p>
<p>Here is my code:</p>
<h3>The UL to re-order</h3>
<p>As you can see the month names are in the wrong order</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;ul id=&quot;menu&quot;&gt;
    &lt;li class=&quot;first&quot;&gt;&lt;a href=&quot;/news/q/date/2011/&quot;&gt;2011&lt;/a&gt;&lt;/li&gt;
    &lt;li class=&quot;current last&quot;&gt;
        &lt;a href=&quot;/news/q/date/2010/&quot;&gt;2010&lt;/a&gt;
            &lt;ul&gt;
                &lt;li class=&quot;&quot;&gt;&lt;a href=&quot;/news/q/date/2010/07/&quot;&gt;July&lt;/a&gt;&lt;/li&gt;
                &lt;li class=&quot;&quot;&gt;&lt;a href=&quot;/news/q/date/2010/06/&quot;&gt;June&lt;/a&gt;&lt;/li&gt;    
                &lt;li class=&quot;&quot;&gt;&lt;a href=&quot;/news/q/date/2010/11/&quot;&gt;November&lt;/a&gt;&lt;/li&gt;
                &lt;li class=&quot; last&quot;&gt;&lt;a href=&quot;/news/q/date/2010/10/&quot;&gt;October&lt;/a&gt;&lt;/li&gt;
                &lt;li class=&quot;&quot;&gt;&lt;a href=&quot;/news/q/date/2010/09/&quot;&gt;September&lt;/a&gt;&lt;/li&gt;
                &lt;li class=&quot;&quot;&gt;&lt;a href=&quot;/news/q/date/2010/08/&quot;&gt;August&lt;/a&gt;&lt;/li&gt;
                &lt;li class=&quot;first&quot;&gt;&lt;a href=&quot;/news/q/date/2010/12/&quot;&gt;December&lt;/a&gt;&lt;/li&gt;
                &lt;li class=&quot;&quot;&gt;&lt;a href=&quot;/news/q/date/2010/05/&quot;&gt;May&lt;/a&gt;&lt;/li&gt;
           &lt;/ul&gt;
    &lt;/li&gt;
&lt;/ul&gt;</pre></td></tr></table></div>

<h3>My (woeful) solution</h3>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000088;">$xml</span> <span style="color: #339933;">=</span> <span style="color: #990000;">simplexml_load_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// pull a node tree as an Array out using simpleXML xpath</span>
<span style="color: #000088;">$trees</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">xpath</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/ul/li/ul'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$array</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$order</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// we only need to delve into XML if there are any nested &lt;ul&gt;s</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$trees</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$trees</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$var</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// store each node in an indexed array</span>
		<span style="color: #000088;">$array</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$var</span><span style="color: #339933;">;</span> 
		<span style="color: #666666; font-style: italic;">// store the month number in an index array</span>
		<span style="color: #666666; font-style: italic;">// based on the text node value of the &lt;a&gt; tag</span>
		<span style="color: #000088;">$order</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'m'</span><span style="color: #339933;">,</span> <span style="color: #990000;">strtotime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>string<span style="color: #009900;">&#41;</span> <span style="color: #000088;">$var</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">a</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
		<span style="color: #000088;">$i</span><span style="color: #339933;">++;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// sort the month number array descending, but maintaining the keys</span>
	<span style="color: #990000;">arsort</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$order</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
	<span style="color: #666666; font-style: italic;">// create a new XML Dom object to manipulate stuff</span>
	<span style="color: #000088;">$dom</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DomDocument<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">// create a holder node &lt;ul&gt;</span>
	<span style="color: #000088;">$ul</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$dom</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ul'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// iterate through the array of simpleXML objects </span>
	<span style="color: #666666; font-style: italic;">// based on the order in which their keys appear in the re-ordered array</span>
	<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$order</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// get the simpleXML objects into a string</span>
		<span style="color: #000088;">$node</span> <span style="color: #339933;">=</span> <span style="color: #990000;">dom_import_simplexml</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">// get the string into an actual DOM node</span>
		<span style="color: #000088;">$node</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$dom</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">importNode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$node</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">// append</span>
		<span style="color: #000088;">$ul</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendChild</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$node</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//$dom-&gt;appendChild($ul);</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// unset the contents of the original &lt;ul&gt; node that we have resorted</span>
	<span style="color: #000088;">$parent</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$trees</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">xpath</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'parent::*'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$parent</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ul</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// turn our simpleXML object into a DOM object</span>
	<span style="color: #000088;">$ixml</span> <span style="color: #339933;">=</span> <span style="color: #990000;">dom_import_simplexml</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$xml</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$new</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DOMDocument<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'1.0'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$ixml</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$new</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">importNode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ixml</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$ixml</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$new</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendChild</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ixml</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// fire up a DOM xpath object</span>
	<span style="color: #000088;">$xpath</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DomXpath<span style="color: #009900;">&#40;</span><span style="color: #000088;">$new</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">// pull a node tree out using simpleXML xpath</span>
	<span style="color: #000088;">$tree</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$xpath</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/ul/li/ul'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// add our newly created DOM node conatining the re-ordered &lt;ul&gt; after the existing node</span>
	<span style="color: #000088;">$tree</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">item</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">parentNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendChild</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$new</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">importNode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ul</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">// delete the original empty node</span>
	<span style="color: #000088;">$tree</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">item</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">parentNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">removeChild</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tree</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">item</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$new</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">saveHTML</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$string</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2011/02/13/reorder-a-nested-html-list-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Favourite new piece of software of the week</title>
		<link>http://www.flipflops.org/2011/02/12/favourite-new-piece-of-software-of-the-week/</link>
		<comments>http://www.flipflops.org/2011/02/12/favourite-new-piece-of-software-of-the-week/#comments</comments>
		<pubDate>Sat, 12 Feb 2011 20:28:45 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
				<category><![CDATA[Stuff]]></category>
		<category><![CDATA[Thoughtful]]></category>
		<category><![CDATA[notes]]></category>
		<category><![CDATA[osX]]></category>
		<category><![CDATA[productivity tools]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/?p=372</guid>
		<description><![CDATA[This week came across Scratch Pad http://www.apple.com/downloads/macosx/productivity_tools/scratchpad_benjaminseifert.html It fills a gap for just that a bit of notepad / jotting pad / scratch pad that has bugged me for a while &#8211; I have been using either notepad++ or text wrangler (depending on whether I&#8217;m on PC or Mac) &#8211; neither of which was quite [...]]]></description>
			<content:encoded><![CDATA[<p>This week came across Scratch Pad <a href="http://www.apple.com/downloads/macosx/productivity_tools/scratchpad_benjaminseifert.html">http://www.apple.com/downloads/macosx/productivity_tools/scratchpad_benjaminseifert.html</a></p>
<p>It fills a gap for just that a bit of notepad / jotting pad / scratch pad that has bugged me for a while &#8211; I have been using either notepad++ or text wrangler (depending on whether I&#8217;m on PC or Mac) &#8211; neither of which was quite what I wanted.</p>
<p>My only irritation is that <em>I don&#8217;t think</em> I can transparently share my jottings across platforms.</p>
<p>Time will tell.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2011/02/12/favourite-new-piece-of-software-of-the-week/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

