<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>That Matt</title>
	
	<link>http://that-matt.com</link>
	<description>That one, not this one!</description>
	<lastBuildDate>Tue, 25 Oct 2011 00:57:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/That-matt" /><feedburner:info uri="that-matt" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Upgrading to Magento 1.4.1.1 from 1.4.0</title>
		<link>http://feedproxy.google.com/~r/That-matt/~3/xZJOiSRBSl8/</link>
		<comments>http://that-matt.com/2010/09/upgrading-to-magento-1-4-1-1-from-1-4-0/#comments</comments>
		<pubDate>Sun, 26 Sep 2010 17:18:40 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Web Apps]]></category>
		<category><![CDATA[ecommerce]]></category>
		<category><![CDATA[magento]]></category>
		<category><![CDATA[upgrade]]></category>

		<guid isPermaLink="false">http://that-matt.com/?p=179</guid>
		<description><![CDATA[I recently had to upgrade an installation of magento 1.4.0 to version 1.4.1.1.  As anybody who&#8217;s ever tried to upgrade magento will tell you, the upgrade path is usually less than ideal (For some people the only way to upgrade &#8230; <a href="http://that-matt.com/2010/09/upgrading-to-magento-1-4-1-1-from-1-4-0/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I recently had to upgrade an installation of magento 1.4.0 to version 1.4.1.1.  As anybody who&#8217;s ever tried to upgrade magento will tell you, the upgrade path is usually less than ideal (For some people the only way to upgrade from 1.3 to 1.4 was to manually export / import their data into a new installation)</p>
<p>As strange as it seems, it appears the most reliable way to upgrade an installation is to install the new version over <span style="text-decoration: underline;"><strong>a copy</strong></span> of the old version&#8217;s database. (Note, you should never attempt to install over the production database lest things go wrong!)</p>
<p>Here&#8217;s a quick guide on how I managed to get the installation in question upgraded, hopefully it&#8217;ll work for you too! <img src='http://that-matt.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> <span id="more-179"></span></p>
<h2>Get rid of any coupon codes</h2>
<p>If you try and upgrade magento without doing this then the installer will fail with a &#8220;foreign key constraint fails&#8221; error.  You should make a note of your codes so that you can re-add them to your upgraded store.</p>
<h2>Copy the database</h2>
<p>In my experience the fastest way to get a copy of the database is to use the <em>mysqldump</em> command on the server over ssh.</p>
<pre class="brush:bash">mysqldump -u{username} -p {database_name} &gt; production_backup.sql</pre>
<p>Obviously you should replace {username} and {database_name} with their appropriate values.  You&#8217;ll also be asked for the db user&#8217;s password when the program connects to the mysql server.</p>
<p>If you don&#8217;t have shell access on your server then you can always use another tool such as phpmyadmin, but it&#8217;s slower and less secure.</p>
<h2>Download a fresh copy of Magento 1.4.1.1</h2>
<p>We now need to download a fresh copy of magento and put it in a separate place from the production site (e.g. testing.{yoursite}.com) where we can run the upgrade safely.  See the magento wiki for more info on <a href="http://www.magentocommerce.com/wiki/groups/227/installing_magento_via_shell_ssh">downloading magento from a shell</a>.</p>
<p>From now on I&#8217;ll refer to the directory you extracted the code to as the &#8220;upgrade test&#8221; directory.</p>
<p>You should also create a separate database to run the upgrade on.</p>
<h2>Modify the Magento Installer</h2>
<p>One of the big issues with the installer supplied with magento is that they assume all of the tables it tries to create don&#8217;t exist (which isn&#8217;t the case).  To get around this we run a quick find &amp; replace in the root of the new &#8220;upgrade test&#8221; magento installation:</p>
<pre class="brush:bash">find . \
    -type f -name "*.php" \
    -exec sed -r -i  \
    "s/CREATE TABLE \`?\{([^}]+)\}\`? \(/CREATE TABLE IF NOT EXISTS \`\{\1\}\` \(/g" \
    {} \;</pre>
<p>If you&#8217;re not familiar with sed, this command basically looks in php files for the string &#8220;CREATE TABLE {table_name} (&#8221; and replaces it with &#8220;CREATE TABLE IF NOT EXISTS {table_name} (&#8220;.  You should execute it in your upgrade test directory, not in the production site dir.</p>
<h2>Run the installer</h2>
<p>If you browse to your testing installation (i.e. http://testing.yoursite.com) you should be redirected to the magento web installer, which should allow you to &#8220;install&#8221; magento.  <strong>When it asks you for a security / encryption key make sure you give the same key that your production install is using.</strong></p>
<p>If you can&#8217;t remember what key your production install is using then have a look in app/etc/local.xml in your production installation.  You should see something like:</p>
<pre class="brush:xml">            <![CDATA[fihfw9393rjW3493jwfwfj93jfww]]&gt;</pre>
<p>In this example the key is fihfw9393rjW3493jwfwfj93jfww.</p>
<h2>Chillax!</h2>
<p>At this point you should hopefully have a fully functioning version of 1.4.1, sans custom theme / installed modules / product images.  To migrate the product images remove the media dir and copy the one from your production installation over.</p>
<p>If something broke during the upgrade then you&#8217;ll need to find the cause of the problem and then re-attempt the upgrade afresh.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/That-matt?a=xZJOiSRBSl8:shKhmxwdENs:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/That-matt?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/That-matt?a=xZJOiSRBSl8:shKhmxwdENs:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/That-matt?i=xZJOiSRBSl8:shKhmxwdENs:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/That-matt/~4/xZJOiSRBSl8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://that-matt.com/2010/09/upgrading-to-magento-1-4-1-1-from-1-4-0/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://that-matt.com/2010/09/upgrading-to-magento-1-4-1-1-from-1-4-0/</feedburner:origLink></item>
		<item>
		<title>Puppet: Retrieved certificate does not match private key</title>
		<link>http://feedproxy.google.com/~r/That-matt/~3/LFuoGBYzOUk/</link>
		<comments>http://that-matt.com/2010/08/puppet-retrieved-certificate-does-not-match-private-key/#comments</comments>
		<pubDate>Sat, 07 Aug 2010 22:08:52 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Virtualisation]]></category>
		<category><![CDATA[Web Servers]]></category>
		<category><![CDATA[puppet]]></category>
		<category><![CDATA[server provisioning]]></category>

		<guid isPermaLink="false">http://that-matt.com/?p=163</guid>
		<description><![CDATA[I&#8217;ve been playing around with puppet recently and while trying to start up a client and get it to talk to the server I ran into this error: err: Could not request certificate: Retrieved certificate does not match private key; &#8230; <a href="http://that-matt.com/2010/08/puppet-retrieved-certificate-does-not-match-private-key/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been playing around with puppet recently and while trying to start up a client and get it to talk to the server I ran into this error:</p>
<pre class="brush:bash">err: Could not request certificate: Retrieved certificate does not match private key; please remove certificate from server and regenerate it with the current key</pre>
<p>Apparently the root cause of this error is that the client&#8217;s ssl certificates have been messed up.</p>
<p>To fix it you have to remove all of the client&#8217;s ssl stuff &#8211; cd into the directory containing all the ssl info &#8211; /etc/puppet/ssl for me running a manual install of puppet 2.6 &#8211; and remove all files, in all sub-directories, apart from &#8216;ca/serial&#8217;, which should contain 0000.</p>
<p>Then on the server revoke the client&#8217;s ssl certificate using:</p>
<pre class="brush:bash">sudo pupetca --clean {client hostname}</pre>
<p>Then restart the client, resign it on the server and you&#8217;re good to go!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/That-matt?a=LFuoGBYzOUk:Dxd5WlbEDow:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/That-matt?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/That-matt?a=LFuoGBYzOUk:Dxd5WlbEDow:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/That-matt?i=LFuoGBYzOUk:Dxd5WlbEDow:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/That-matt/~4/LFuoGBYzOUk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://that-matt.com/2010/08/puppet-retrieved-certificate-does-not-match-private-key/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		<feedburner:origLink>http://that-matt.com/2010/08/puppet-retrieved-certificate-does-not-match-private-key/</feedburner:origLink></item>
		<item>
		<title>Config cache problems with Magento</title>
		<link>http://feedproxy.google.com/~r/That-matt/~3/jutGFLGSa9s/</link>
		<comments>http://that-matt.com/2010/08/config-cache-problems-with-magento/#comments</comments>
		<pubDate>Sun, 01 Aug 2010 19:18:00 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Web Apps]]></category>
		<category><![CDATA[Web Servers]]></category>
		<category><![CDATA[magento]]></category>

		<guid isPermaLink="false">http://that-matt.com/?p=158</guid>
		<description><![CDATA[After having numerous problems upgrading a Magento site 1.4.1.1 on a test server I decided to try and get it working locally before applying the fix(es) to the live server. This is a fairly simple process and there&#8217;s lots of &#8230; <a href="http://that-matt.com/2010/08/config-cache-problems-with-magento/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>After having numerous problems upgrading a Magento site 1.4.1.1 on a test server I decided to try and get it working locally before applying the fix(es) to the live server.</p>
<p>This is a fairly simple process and there&#8217;s <a href="http://blog.chandanweb.com/magento/how-to-change-base-url-in-magento">lots</a> of <a href="http://www.magentocommerce.com/wiki/groups/227/moving_magento_to_another_server">information</a> on how to do it.  The key steps in the process are emptying magento&#8217;s cache directory and updating the base urls in the core_config_data table so that magento will generate correct urls.</p>
<p><span id="more-158"></span></p>
<p>When I setup my copy of the site locally I changed local.xml &amp; deleted the cache before modifying the db, just to make sure that magento was connecting ok.  Once that was done I went off to delete the new cache files from siteroot/var/cache.  Only, there weren&#8217;t any cache files.  I took no note of it figuring magento had just decided not to cache the files and so proceeded to load the site, only for it to redirect me to the live site.</p>
<p>I spent the next few hours trying in vain to work out where magento was getting the idea that it should redirect to the main site.  After wiping the db / files and re-extracting them several times I noticed that it was still redirecting even if the database was empty and the cache dir (var/cache) didn&#8217;t exist.  Obviously this is one helluva wtf, especially as there weren&#8217;t any references to the live site&#8217;s address in the files.  The opinion on IRC was that somehow my local site was talking to the production site&#8217;s db and was using it&#8217;s database instead of my local one, however this couldn&#8217;t be the case as magento started complaining if I dropped the local database entirely.</p>
<p>In a last ditch attempt I tried grepping for the site&#8217;s address across the entire filesystem (using grep -R &#8220;sitedomain.com&#8221; / ) and came across a load of files in /tmp/magento.  After deleting the directory magento started working perfectly again, though it continued to store cache files in /tmp/magento rather than var/cache/ for some reason.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/That-matt?a=jutGFLGSa9s:lqhxRwhWix0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/That-matt?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/That-matt?a=jutGFLGSa9s:lqhxRwhWix0:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/That-matt?i=jutGFLGSa9s:lqhxRwhWix0:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/That-matt/~4/jutGFLGSa9s" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://that-matt.com/2010/08/config-cache-problems-with-magento/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://that-matt.com/2010/08/config-cache-problems-with-magento/</feedburner:origLink></item>
		<item>
		<title>Can’t connect to remote mysql server with php/apache but can through php/cli</title>
		<link>http://feedproxy.google.com/~r/That-matt/~3/ohDsvGaSWAk/</link>
		<comments>http://that-matt.com/2010/07/cant-connect-to-remote-mysql-server-with-phpapache-but-can-through-phpcli/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 21:00:50 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Web Servers]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[selinux]]></category>

		<guid isPermaLink="false">http://that-matt.com/?p=144</guid>
		<description><![CDATA[Today at work we were migrating some sites to a new server infrastructure with the different services (i.e. php, mysql, mail) spread over different servers. One problem we ran into whilst setting this up was that php scripts running through &#8230; <a href="http://that-matt.com/2010/07/cant-connect-to-remote-mysql-server-with-phpapache-but-can-through-phpcli/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Today at work we were migrating some sites to a new server infrastructure with the different services (i.e. php, mysql, mail) spread over different servers.</p>
<p>One problem we ran into whilst setting this up was that php scripts running through apache were having trouble connecting to the mysql server.</p>
<p>What was even stranger though, was the fact that this problem only appeared when the php script(s) were run through apache &#8211; running them through the command line / shell worked absolutely fine.</p>
<p><span id="more-144"></span></p>
<p>After a couple of hours of debugging, head bashing and confusion we found the solution at the bottom of one of those very very long <a href="http://www.experts-exchange.com/Database/MySQL/Q_22606034.html">experts exchange</a> threads.</p>
<p>It turns out that some linux distros has a neat little access control system called SELinux which was blocking communication by apache to remote database servers.</p>
<p>The aforementioned exchange thread suggests disabling SELinux entirely by executing</p>
<pre class="brush:bash">sudo setenforce 0</pre>
<p>but this isn&#8217;t a permanent solution and won&#8217;t persist through a reboot <a href="http://googolflex.com/?p=482">without changing a config file</a>.</p>
<blockquote><p>This can be accomplished by changing a line in /etc/selinux/config. Change the line that says:<br />
<code>SELINUX=enforcing</code><br />
to<br />
<code>SELINUX=disabled</code></p></blockquote>
<p>However, if you&#8217;re willing to do a bit of digging there are <a href="http://www.beginlinux.com/server_training/web-server/976-apache-and-selinux">SEL options</a> you can change to <a href="http://www.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6-Beta/html/Security-Enhanced_Linux/sect-Security-Enhanced_Linux-Booleans-Configuring_Booleans.html">grant apache access to remote database servers</a>, and if you have a few hours to kill, there&#8217;s also <a href="http://docs.fedoraproject.org/en-US/Fedora/13/html/SELinux_FAQ/index.html">the fedora documentation</a>.</p>
<p>Hopefully this&#8217;ll save someone else the headache we had!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/That-matt?a=ohDsvGaSWAk:0dK-xJo48Bw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/That-matt?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/That-matt?a=ohDsvGaSWAk:0dK-xJo48Bw:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/That-matt?i=ohDsvGaSWAk:0dK-xJo48Bw:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/That-matt/~4/ohDsvGaSWAk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://that-matt.com/2010/07/cant-connect-to-remote-mysql-server-with-phpapache-but-can-through-phpcli/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://that-matt.com/2010/07/cant-connect-to-remote-mysql-server-with-phpapache-but-can-through-phpcli/</feedburner:origLink></item>
		<item>
		<title>OSCommerce / Paypoint redirects to payment information after paying</title>
		<link>http://feedproxy.google.com/~r/That-matt/~3/lHm_t8Uhuoc/</link>
		<comments>http://that-matt.com/2010/06/oscommerce-paypoint-redirects-to-payment-information-after-paying/#comments</comments>
		<pubDate>Wed, 30 Jun 2010 19:52:05 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[oscommerce]]></category>
		<category><![CDATA[paypoint]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[secpay]]></category>

		<guid isPermaLink="false">http://sigswitch.com/?p=140</guid>
		<description><![CDATA[I was asked to do some work on an oscommerce site which was accepting payments from paypoint (formally secpay) yet instead of redirecting the user to the &#8220;Thank you for your order&#8221; page it was sending them to the payment &#8230; <a href="http://that-matt.com/2010/06/oscommerce-paypoint-redirects-to-payment-information-after-paying/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I was asked to do some work on an oscommerce site which was accepting payments from <a href="http://paypoint.net">paypoint</a> (formally secpay) yet instead of redirecting the user to the &#8220;Thank you for your order&#8221; page it was sending them to the payment information page, and wasn&#8217;t classing the order as being paid for.</p>
<p>After a bit of debugging it turns out the problem stems from the paypoint-secpay merger and the fact that OSCommerce is a poorly supported hunk of junk.</p>
<p><span id="more-140"></span></p>
<p>During a typical transaction paypoint will ask the user for their card details, and if the details check out it sends a request back to OSCommerce telling it that the transaction was a success.  It will then display to the user whatever your server outputs.  Thus your customers should see the &#8220;Thank you for your order&#8221; page appear under a url of &#8220;https://www.secpay.com/java-bin/ValCard&#8221;.</p>
<p>When oscommerce receives the &#8220;the transaction succeeded&#8221; message from secpay it looks at the ip address the message came from, and tries to resolve it to a hostname to see if it came from secpay.com.</p>
<p>Since the merger the ip address that paypoint are using ﻿(in this case it was 81.93.226.30) doesn&#8217;t resolve to secpay.com, in fact <a href="http://whois.domaintools.com/reverse-ip/?hostname=81.93.226.30">it doesn&#8217;t resolve to anything</a>.  If php can&#8217;t resolve an ip address to a hostname then it gives up and returns the ip, thus oscommerce was trying to check that &#8216;secpay.com&#8217; was the same as &#8217;81.93.226.30&#8242;, which it isn&#8217;t.</p>
<p>To fix this I changed the before_process() method in the secpay payment module to look like so:</p>
<pre class="brush:php">function before_process() {

      if ($_POST['valid'] == 'true') {
          if ($remote_addr = $_SERVER['REMOTE_ADDR']) {
	      // Check that the request came from one of the secpay / paypoint servers
    	      if (strpos($remote_addr, '81.93.226') !== 0) {
        	    tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, tep_session_name() . '=' . $HTTP_POST_VARS[tep_session_name()] . '&amp;payment_error=' . $this-&gt;code, 'SSL', false, false));
          }
        } else {
          tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, tep_session_name() . '=' . $HTTP_POST_VARS[tep_session_name()] . '&amp;payment_error=' . $this-&gt;code, 'SSL', false, false));
        }
      }
    }</pre>
<p>Ignoring for a second the horrible use of php3/php4 conventions, the method now checks to see if the sender&#8217;s ip address begins with 81.93.226, as <a href="http://whois.domaintools.com/81.93.226.30">paypoint seem to own</a> that range.</p>
<p>Hopefully this will save someone else the headache</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/That-matt?a=lHm_t8Uhuoc:CRn8f2QFDe4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/That-matt?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/That-matt?a=lHm_t8Uhuoc:CRn8f2QFDe4:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/That-matt?i=lHm_t8Uhuoc:CRn8f2QFDe4:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/That-matt/~4/lHm_t8Uhuoc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://that-matt.com/2010/06/oscommerce-paypoint-redirects-to-payment-information-after-paying/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://that-matt.com/2010/06/oscommerce-paypoint-redirects-to-payment-information-after-paying/</feedburner:origLink></item>
		<item>
		<title>Updated textarea maxlength with Jquery plugin</title>
		<link>http://feedproxy.google.com/~r/That-matt/~3/QH3kv13g94k/</link>
		<comments>http://that-matt.com/2010/04/updated-textarea-maxlength-with-jquery-plugin/#comments</comments>
		<pubDate>Thu, 08 Apr 2010 15:08:19 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Html]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://sigswitch.com/?p=127</guid>
		<description><![CDATA[When I first wrote the &#8220;Textarea maxlength with jQuery&#8221; plugin last year I had no idea how popular it would be &#8211; over 70% of the visits to my site since then have been people reading that one post. The &#8230; <a href="http://that-matt.com/2010/04/updated-textarea-maxlength-with-jquery-plugin/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When I first wrote the &#8220;Textarea maxlength with jQuery&#8221; plugin last year I had no idea how popular it would be &#8211; over 70% of the visits to my site since then have been people reading that one post.  The problem is, the code there is basically an ugly hack &#8211; you copy and paste and you&#8217;re done.  But if you need to implement the same functionality across a site with slight differences to the functionality, you&#8217;d end up with a lot of copy and paste garbage.  <span id="more-127"></span> So what with it being time for some spring cleaning I thought I&#8217;d begin by refactoring the original code into a jquery plugin:</p>
<pre class="brush:js">jQuery.fn.limitMaxlength = function(options){

	var settings = jQuery.extend({
		attribute: "maxlength",
		onLimit: function(){},
		onEdit: function(){}
	}, options);

	// Event handler to limit the textarea
	var onEdit = function(){
		var textarea = jQuery(this);
		var maxlength = parseInt(textarea.attr(settings.attribute));

		if(textarea.val().length &gt; maxlength){
			textarea.val(textarea.val().substr(0, maxlength));

			// Call the onlimit handler within the scope of the textarea
			jQuery.proxy(settings.onLimit, this)();
		}

		// Call the onEdit handler within the scope of the textarea
		jQuery.proxy(settings.onEdit, this)(maxlength - textarea.val().length);
	}

	this.each(onEdit);

	return this.keyup(onEdit)
				.keydown(onEdit)
				.focus(onEdit)
				.live('input paste', onEdit);
}</pre>
<p>And here&#8217;s an example of it in use, limiting all textareas in the document and updating a p element with the id of charsRemaining with&#8230; the number of characters remaining.  It also sets the textarea bg color to red when the user tries to exceed the maxlength.</p>
<pre class="brush:js">$(document).ready(function(){

	var onEditCallback = function(remaining){
		$(this).siblings('.charsRemaining').text("Characters remaining: " + remaining);

		if(remaining &gt; 0){
			$(this).css('background-color', 'white');
		}
	}

	var onLimitCallback = function(){
		$(this).css('background-color', 'red');
	}

	$('textarea[maxlength]').limitMaxlength({
		onEdit: onEditCallback,
		onLimit: onLimitCallback
	});
});</pre>
<p>And here&#8217;s a <a href="http://jsbin.com/ufuji3/9">jsbin paste with a quick demo</a>.  Although there is a lot more code in this version it&#8217;s a lot more flexible as it allows you to decide how to inform the user of how many characters there&#8217;re remaining.  It also means that it&#8217;ll take any characters already in the textbox into account when the document loads.</p>
<p><strong>Update 2010/04/09:</strong> Fixed a few bugs &amp; typos<br />
<strong>Update 2010/08/01:</strong> Removed problematic comma &amp; added live(&#8216;input paste&#8217;) &#8211; thanks Surya and Len!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/That-matt?a=QH3kv13g94k:LKSnz1BbRhY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/That-matt?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/That-matt?a=QH3kv13g94k:LKSnz1BbRhY:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/That-matt?i=QH3kv13g94k:LKSnz1BbRhY:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/That-matt/~4/QH3kv13g94k" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://that-matt.com/2010/04/updated-textarea-maxlength-with-jquery-plugin/feed/</wfw:commentRss>
		<slash:comments>39</slash:comments>
		<feedburner:origLink>http://that-matt.com/2010/04/updated-textarea-maxlength-with-jquery-plugin/</feedburner:origLink></item>
		<item>
		<title>Testing Kohana3 with PHPUnit</title>
		<link>http://feedproxy.google.com/~r/That-matt/~3/HX7x36LCe40/</link>
		<comments>http://that-matt.com/2009/12/testing-kohana3-with-phpunit/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 21:39:51 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[featured]]></category>
		<category><![CDATA[Kohana]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHPUnit]]></category>
		<category><![CDATA[Unit Testing]]></category>

		<guid isPermaLink="false">http://sigswitch.com/?p=113</guid>
		<description><![CDATA[Unit testing is great, period. It allows you to test different parts of your application independently of the rest of the system.  Any changes that will cause problems elsewhere can be identified almost instantly (if you&#8217;re doing it right!). Up &#8230; <a href="http://that-matt.com/2009/12/testing-kohana3-with-phpunit/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Unit_testing">Unit testing</a> is great, period. It allows you to test different parts of your application independently of the rest of the system.  Any changes that will cause problems elsewhere can be identified almost instantly (if you&#8217;re doing it right!).</p>
<p>Up until recently <a href="http://github.com/kohana/kohana">Kohana3</a> was using a home-grown module for unit testing &#8211; It was ok, but lacked some of the more advanced features of independent testing suites &#8211; however now the project has now adopted PHPUnit as its <a href="http://github.com/kohana/unittest">official test framework</a>!  PHPUnit is one of the more popular testing suites for PHP, it has full support for <a href="http://www.phpunit.de/manual/3.1/en/fixtures.html">Fixtures</a>, <a href="http://www.phpunit.de/manual/3.1/en/mock-objects.html">Mock Objects</a>, <a href="http://www.phpunit.de/manual/3.1/en/code-coverage-analysis.html">Code Coverage</a> and a lot of other <a href="http://seleniumhq.org/">cool stuff</a>.</p>
<p>The module only requires a few changes to the bootstrap in order to integrate Kohana with PHPUnit, and afterwards you can run tests from the cli, IDE or our custom web runner.  All available tests are loaded from Kohana&#8217;s cascading filesystem and can be filtered using PHPUnit&#8217;s &#8211;group switch.</p>
<p>Go and <a href="http://github.com/kohana/unittest">git it</a> while it&#8217;s hot!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/That-matt?a=HX7x36LCe40:hGQTQcTnpxM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/That-matt?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/That-matt?a=HX7x36LCe40:hGQTQcTnpxM:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/That-matt?i=HX7x36LCe40:hGQTQcTnpxM:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/That-matt/~4/HX7x36LCe40" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://that-matt.com/2009/12/testing-kohana3-with-phpunit/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		<feedburner:origLink>http://that-matt.com/2009/12/testing-kohana3-with-phpunit/</feedburner:origLink></item>
		<item>
		<title>How to get Ubuntu to ping a Windows hostname (and vice-versa)</title>
		<link>http://feedproxy.google.com/~r/That-matt/~3/Xi-3JUB6tVc/</link>
		<comments>http://that-matt.com/2009/12/how-to-get-ubuntu-to-ping-a-windows-hostname/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 20:00:28 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[features]]></category>

		<guid isPermaLink="false">http://www.sigswitch.com/?p=47</guid>
		<description><![CDATA[I&#8217;m currently running ubuntu server in a virtual machine on my pc, and one of the annoying problems I&#8217;ve always had with ubuntu is that it never seems to be able to resolve the hostnames of machines running windows. After a little &#8230; <a href="http://that-matt.com/2009/12/how-to-get-ubuntu-to-ping-a-windows-hostname/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently running ubuntu  server in a virtual machine on my pc, and one of the annoying problems I&#8217;ve always had with ubuntu is that it never seems to be able to resolve the hostnames of machines running windows.</p>
<p>After a little bit of digging I found a really simple solution <a href="http://ubuntuforums.org/showthread.php?t=88206">in this forum topic</a></p>
<blockquote><p>All you have to do is:</p>
<pre class="brush:shell">sudo nano /etc/nsswitch.conf</pre>
<p>change the line that says</p>
<pre class="brush:plain">hosts: files dns</pre>
<p>to this:</p>
<pre class="brush:shell">hosts: files wins dns</pre>
<p>(order does matter)</p>
<p>finally, you need to install winbind</p>
<pre class="brush:shell">sudo apt-get install winbind</pre>
</blockquote>
<p>To enable windows to ping ubuntu you then need to install samba:</p>
<pre class="brush:shell">sudo apt-get install samba</pre>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/That-matt?a=Xi-3JUB6tVc:UFStwFu3V8w:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/That-matt?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/That-matt?a=Xi-3JUB6tVc:UFStwFu3V8w:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/That-matt?i=Xi-3JUB6tVc:UFStwFu3V8w:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/That-matt/~4/Xi-3JUB6tVc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://that-matt.com/2009/12/how-to-get-ubuntu-to-ping-a-windows-hostname/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://that-matt.com/2009/12/how-to-get-ubuntu-to-ping-a-windows-hostname/</feedburner:origLink></item>
		<item>
		<title>Virtualbox – 1 differencing child hard disks</title>
		<link>http://feedproxy.google.com/~r/That-matt/~3/5jts9iPb-VM/</link>
		<comments>http://that-matt.com/2009/11/virtualbox-1-differencing-child-hard-disks/#comments</comments>
		<pubDate>Sat, 07 Nov 2009 00:00:06 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Virtualisation]]></category>
		<category><![CDATA[virtual box]]></category>

		<guid isPermaLink="false">http://sigswitch.com/2009/11/virtualbox-1-differencing-child-hard-disks/</guid>
		<description><![CDATA[If you&#8217;re getting an error along the lines of &#8220;{hard disk} cannot be directly attached to the virtual machine because it has 1 differencing child hard disks&#8221; Then the solution is to delete the virtual machine (but not the hard &#8230; <a href="http://that-matt.com/2009/11/virtualbox-1-differencing-child-hard-disks/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re getting an error along the lines of &#8220;{hard disk} cannot be directly attached to the virtual machine because it has 1 differencing child hard disks&#8221;</p>
<p>Then the solution is to delete the virtual machine (but not the hard disk!) and then recreate the machine using the hard disk.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/That-matt?a=5jts9iPb-VM:NVORdcNF-m0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/That-matt?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/That-matt?a=5jts9iPb-VM:NVORdcNF-m0:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/That-matt?i=5jts9iPb-VM:NVORdcNF-m0:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/That-matt/~4/5jts9iPb-VM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://that-matt.com/2009/11/virtualbox-1-differencing-child-hard-disks/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		<feedburner:origLink>http://that-matt.com/2009/11/virtualbox-1-differencing-child-hard-disks/</feedburner:origLink></item>
		<item>
		<title>Stretch wallpaper across multiple monitors on Windows</title>
		<link>http://feedproxy.google.com/~r/That-matt/~3/IJHFnkh1gtE/</link>
		<comments>http://that-matt.com/2009/09/stretch-wallpaper-across-multiple-monitors-on-windows/#comments</comments>
		<pubDate>Sun, 06 Sep 2009 17:35:12 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[backgrounds]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://sigswitch.com/?p=96</guid>
		<description><![CDATA[When I first got a second monitor I looked around for quite a while to try and find a solution for stretching a wallpaper across dual monitors &#8211; Windows was repeating the first half of the wallpaper on both the &#8230; <a href="http://that-matt.com/2009/09/stretch-wallpaper-across-multiple-monitors-on-windows/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When I first got a second monitor I looked around for quite a while to try and find a solution for stretching a wallpaper across dual monitors &#8211; Windows was repeating the first half of the wallpaper on both the monitors.</p>
<p><span id="more-96"></span></p>
<p>I eventually came across <a title="DisplayFusion" href="www.binaryfortress.com/displayfusion/">DisplayFusion</a> which seemed to satisfy the bill &#8211; The free version allows you to stretch wallpapers across your monitors as well as drag maximised windows between screens (an incredibly useful feature).</p>
<p>If you buy the full version it can automatically cycle between pictures from a folder, <a href="http://flickr.com">flickr</a> or <a href="http://vladstudio.com">VladStudio.com</a> and it&#8217;ll also extend the start menu bar onto your other monitor(s).</p>
<p style="text-align: center;"><a href="http://www.sigswitch.com/extras/2009-09-06_1817.png"><img class="aligncenter" title="Display Fusion" src="http://www.sigswitch.com/extras/2009-09-06_1817.png" alt="" width="571" height="421" /></a></p>
<p style="text-align: left;">
<p style="text-align: left;">I was fairly happy with using DisplayFusion to solve the problem, however it seemed odd to me that Microsoft didn&#8217;t include some kind of option in Windows to do this by default.  It actually turns out they did &#8211; When you choose your wallpaper you have to set the &#8220;Position&#8221; option to &#8220;Tile&#8221;.</p>
<p style="text-align: left;"><img class="aligncenter" title="Windows Background Options" src="http://www.sigswitch.com/extras/2009-09-06_1827.png" alt="" width="404" height="455" /></p>
<p style="text-align: left;">
<p style="text-align: left;">It&#8217;s kind of annoying seeing how simple a solution it is having spent quite a while looking for it!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/That-matt?a=IJHFnkh1gtE:c8OeKzdkty8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/That-matt?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/That-matt?a=IJHFnkh1gtE:c8OeKzdkty8:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/That-matt?i=IJHFnkh1gtE:c8OeKzdkty8:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/That-matt/~4/IJHFnkh1gtE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://that-matt.com/2009/09/stretch-wallpaper-across-multiple-monitors-on-windows/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://that-matt.com/2009/09/stretch-wallpaper-across-multiple-monitors-on-windows/</feedburner:origLink></item>
	</channel>
</rss>

