<?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>Phil Rennie</title>
	<atom:link href="http://philrennie.co.uk/feed/" rel="self" type="application/rss+xml" />
	<link>http://philrennie.co.uk</link>
	<description>Web developer and all round Geek</description>
	<lastBuildDate>Wed, 18 Jan 2012 15:38:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Create CSS gradients from an image file</title>
		<link>http://philrennie.co.uk/blog/tech-tips/create-css-gradients-from-an-image-file/</link>
		<comments>http://philrennie.co.uk/blog/tech-tips/create-css-gradients-from-an-image-file/#comments</comments>
		<pubDate>Tue, 08 Nov 2011 22:12:39 +0000</pubDate>
		<dc:creator>Phil</dc:creator>
				<category><![CDATA[Tech Tips]]></category>

		<guid isPermaLink="false">http://philrennie.co.uk/?p=435</guid>
		<description><![CDATA[This is totally awesomesauce. Look carefully at the options on http://www.colorzilla.com/gradient-editor/ It will let you upload an gradient image file and then it creates the multi browser css to use the gradient as a background.]]></description>
			<content:encoded><![CDATA[<p>This is totally awesomesauce.</p>
<p>Look carefully at the options on<br />
<a href="http://www.colorzilla.com/gradient-editor/ " target="_blank">http://www.colorzilla.com/gradient-editor/ </a><br />
It will let you upload an gradient image file and then it creates the multi browser css to use the gradient as a background.</p>
]]></content:encoded>
			<wfw:commentRss>http://philrennie.co.uk/blog/tech-tips/create-css-gradients-from-an-image-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Happy to help</title>
		<link>http://philrennie.co.uk/blog/happy-to-help/</link>
		<comments>http://philrennie.co.uk/blog/happy-to-help/#comments</comments>
		<pubDate>Sun, 30 Oct 2011 20:28:56 +0000</pubDate>
		<dc:creator>Phil</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://philrennie.co.uk/?p=430</guid>
		<description><![CDATA[I don&#8217;t comment on too many Hacker News articles unless I feel I have something constructive to say. I did however offer a few thoughts here on someone&#8217;s site copy http://news.ycombinator.com/item?id=3171973 And look what happened&#8230;. http://happycolorsapp.com/ That&#8217;s my contribution to &#8230; <a href="http://philrennie.co.uk/blog/happy-to-help/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t comment on too many Hacker News articles unless I feel I have something constructive to say. I did however offer a few thoughts here on someone&#8217;s site copy<br />
<a href="http://news.ycombinator.com/item?id=3171973" target="_blank"> http://news.ycombinator.com/item?id=3171973</a></p>
<p>And look what happened&#8230;. <a href="http://happycolorsapp.com/" target="_blank">http://happycolorsapp.com/</a></p>
<p>That&#8217;s my contribution to the internets for this week <img src='http://philrennie.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://philrennie.co.uk/blog/happy-to-help/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Find your public IP quickly</title>
		<link>http://philrennie.co.uk/blog/tech-tips/find-your-ip-quickly/</link>
		<comments>http://philrennie.co.uk/blog/tech-tips/find-your-ip-quickly/#comments</comments>
		<pubDate>Sat, 29 Oct 2011 22:40:40 +0000</pubDate>
		<dc:creator>Phil</dc:creator>
				<category><![CDATA[Tech Tips]]></category>

		<guid isPermaLink="false">http://philrennie.co.uk/?p=392</guid>
		<description><![CDATA[Pro tip Now you can just search &#8216;ip&#8217; on google to see your public IP address http://www.google.co.uk/search?q=ip]]></description>
			<content:encoded><![CDATA[<p>Pro tip Now you can just search &#8216;ip&#8217; on google to see your public IP address <a href="http://www.google.co.uk/search?q=ip" target="_blank">http://www.google.co.uk/search?q=ip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://philrennie.co.uk/blog/tech-tips/find-your-ip-quickly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>When suddenly you can&#8217;t minimise windows on OS X</title>
		<link>http://philrennie.co.uk/blog/tech-tips/when-suddenly-you-cant-minimise-windows-on-os-x/</link>
		<comments>http://philrennie.co.uk/blog/tech-tips/when-suddenly-you-cant-minimise-windows-on-os-x/#comments</comments>
		<pubDate>Fri, 28 Oct 2011 20:46:35 +0000</pubDate>
		<dc:creator>Phil</dc:creator>
				<category><![CDATA[Tech Tips]]></category>

		<guid isPermaLink="false">http://philrennie.co.uk/?p=369</guid>
		<description><![CDATA[This problem has bugged me for a while. You&#8217;ll happily be working for a day, bouncing between spaces minimising (hiding) and maximising windows when all of a sudden you notice that the yellow minimise button has greyed itself out, and &#8230; <a href="http://philrennie.co.uk/blog/tech-tips/when-suddenly-you-cant-minimise-windows-on-os-x/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This problem has bugged me for a while. You&#8217;ll happily be working for a day, bouncing between spaces minimising (hiding) and maximising windows when all of a sudden you notice that the yellow minimise button has greyed itself out, and the menu option. WTF?<span id="more-369"></span></p>
<p>Well after a little bit of googling and putting together bits and bobs from various forum posts here&#8217;s a simple explanation&#8230;..</p>
<p>When an application such as quicktime or VLC goes into fullscreen mode various events propagate around OS X changing the state of the dock and open windows, and on leaving fullscreen the messages get a little mixed. The result is that windows in spaces other than the one where the fullscreen app was living don&#8217;t get their minimise option re-enabled.</p>
<p>So to fix things,</p>
<p>Move the app you had fullscreen to the same space as application that is affected.</p>
<p>Toggle fullscreen on and back off again and all should be well.</p>
<p>As this problem is fairly intermittent the chances are these steps wont cause the problem to occur on another space, but if they do just rinse and repeat until all is well.</p>
]]></content:encoded>
			<wfw:commentRss>http://philrennie.co.uk/blog/tech-tips/when-suddenly-you-cant-minimise-windows-on-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The story so far.</title>
		<link>http://philrennie.co.uk/blog/coding-life/the-story-so-far/</link>
		<comments>http://philrennie.co.uk/blog/coding-life/the-story-so-far/#comments</comments>
		<pubDate>Fri, 28 Oct 2011 17:26:20 +0000</pubDate>
		<dc:creator>Phil</dc:creator>
				<category><![CDATA[Coding life]]></category>

		<guid isPermaLink="false">http://philrennie.co.uk/?p=351</guid>
		<description><![CDATA[This post is the first in a new strand for this blog talking about my life as a coder, and my approaches to and feelings about coding. I&#8217;m going to try and stay somewhat abstract and not get too technical. &#8230; <a href="http://philrennie.co.uk/blog/coding-life/the-story-so-far/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This post is the first in a new strand for this blog talking about my life as a coder, and my approaches to and feelings about coding. I&#8217;m going to try and stay somewhat abstract and not get too technical. I&#8217;m also trying to improve my long form writing.</p>
<p>So here we go, a quick bringing-up-to-speed and the beginning of several pieces on code frameworks.<span id="more-351"></span></p>
<p>I think it&#8217;s worth mentioning that I like to know how things work. If you leave me alone in a room with your Doodadamatron and a box of screwdrivers there&#8217;s a good chance that on your return it will still work, possibly even slightly better, but your warranty will be worth about as much as the paper it&#8217;s written on.</p>
<p>It&#8217;s also worth noting that whilst I&#8217;m not a fan of certain forms of magic, I do like to see a magician perform illusions. Recently an acquaintance, a Mentalist by trade, revealed that written on a piece of paper he&#8217;d placed on the table before his trick was the number I had apparently just picked at random. I&#8217;m still trying to work out exactly how he led me to choose that number, but that&#8217;s the joy of magic. That said there are other forms of magic of which I am not a fan and we&#8217;ll come back to those in a bit.</p>
<p>So what am I wittering on about and how does it relate to sourcecode and the act of programming? First we take a detour into history.</p>
<p>I began to use PHP a decade ago when I decided that I wanted to be involved in this internet thing. The exact reason I ended up using PHP is a little foggy, but I believe it may have been due to the ease and cost of entrance, .Net magazine and an offer on cheap basic hosting. What followed were a couple of years of a ghastly and permanently unfinished &#8216;homepages&#8217; (note to the kids, we called our websites homepages back then, they were all as ugly as the average MySpace page and were about as informative, often more so in both respects.)</p>
<p>Then I moved on to blogging where a touch of PHP knowledge was useful to install your choice of blogging software and make a few personal adjustments. That blog is unfortunately lost to the mists of time due to a backup drive failure, which is a shame as I&#8217;m sure there was a highly insightful entry about Madonna that is now missing from the world.</p>
<p>My tinkering led to people knowing I &#8216;did the internet&#8217; and slowly I began to build larger and larger sites for friends, family and the acquainted masses. This is where I began my love/hate relationship with code frameworks and their magic.</p>
<p>Building sites often involves repeating yourself. Whilst you aim to make every site look unique, to make navigation better and easy than site Y&#8217;s, and the content more compelling than site X&#8217;s, there are certain fundamentals that are inescapable. People need to be able to administer content which must be created, edited and organised, other people need to be able to react to the content, leaving comments, voting on the cutest kitten and sending emails to their friends informing them of the existence of said kitten (email? Sorry I&#8217;m an old man, I meant click Like buttons.)</p>
<p>Building all that interaction is incredibly dull. Forms need to be created and validated, information needs to be stored in and retrieved from databases, and 100 Like buttons need to be embedded on every page. Once you&#8217;ve done it a couple of times you begin to realise that a large amount of the job of building websites is mind numbingly tedious. It&#8217;s like rebuilding Hadrians wall, whilst you get to stand back and invent an incredibly clever way of bridging an obstructive stream or hiding a cell tower where no-one will notice, in the end it&#8217;s mainly about moving very heavy bricks around. Repeatedly. Until you hate bricks. And walls. And the person who specified the wall.</p>
<p>In order to prevent web developers from rampaging en-masse, cleaving their clients heads asunder with a sharpened Macbook Air in a repetition fuelled zombie rage, we have Code Frameworks. A framework is to the web developer as the forklift truck is to the Hadrians wall rebuilder. You still have to know what you&#8217;re doing, but a lot of the heavy lifting is handled by a tool built for the job.</p>
<p>And so we swing lazily back to somewhere adjacent to my point via a little more history.</p>
<p>I mentioned previously that I have a love hate relationship with code frameworks, and that I&#8217;m not a fan of certain forms of magic. When I initially felt that it was silly to be repeating myself I started to look at the tools available to help and what I began to use were not actually frameworks but Content Management Systems (CMS&#8217;s). A CMS does exactly what it says on the tin, i.e. manage content and for a while that sufficed for my needs.</p>
<p>Most CMS&#8217;s provide a fairly rigid structure for storing and displaying information on a website. There are certain naturally occurring conventions for the content of an average public facing website. Articles, pages of fairly static information, chronological blogs and the categorisation and navigation required to find all the wonderful information your audience is clamouring for. Have a think about the sites you visit just to read, you&#8217;ll find most of them look completely different but are very much organised into sections, subsections and pieces of content within them. A CMS is designed to provide all the functionality to create, store, retrieve and display this content, and manage the rights of the editors and audience to interact with it.</p>
<p>For a while CMS&#8217;s served me nicely, they covered a lot of the dull stuff and they also did some of the things I didn&#8217;t yet have the coding chops to do myself; making input safe for the database and output safe for the viewer, structuring page addresses into pretty URI&#8217;s, and making sure people had the rights to do what they were doing.</p>
<p>As you begin to push the boundaries of the inbuilt functionality of a CMS you need to expand the capabilities of the system and often a CMS will provide interfaces to let you write plugins. Plugins allow you to hook your own code into the existing functionality of the CMS, expanding it to give you the ability to perhaps allow your users to embed youTube videos into their content without having to know any yucky technical stuff or let your audience vote on which photo of a kitten is the cutest and display the results on the front page. At the same time the system should help you leverage it&#8217;s existing code for validation, security and database interaction.</p>
<p>Back when I was initially using CMS&#8217;s the plugin interfaces were often a complete pain in the bum to use (Mambo and Joomla, I&#8217;m looking at you). I&#8217;d find myself having to edit the core framework to expand the hooks provided to my plugin or to create something that it just couldn&#8217;t do. Whenever you change the core code of a CMS or framework you then cannot upgrade it when newer versions are released to fix bugs, close security issues or add functionality, and you find yourself having to re-hack the newer version. This is also very tedious.</p>
<p>Please don&#8217;t think that I am disrespecting any particular CMS systems here, using them taught me many new coding tricks and best practices, and examining and hacking the code of a very many good people has been instrumental in making me a better programmer. As my requirements outgrew the systems I was using I began to realise I had the chops to do it all myself. I could, and would, start to code from the ground up and I would be in charge of everything.</p>
<p>I&#8217;ve been in the (privileged?) position of being the sole coder on every project I&#8217;ve built so far. I get to Do It My Way and no-one else has to deal with the consequences or the nightmare horror that is my code structure. I&#8217;ve slowly learnt how to structure my code and databases sensibly to separate the concerns of data, logic and presentation. I know the pitfalls of validating input to the system to prevent people doing malicious things and I&#8217;ve learnt the in and outs of dealing with the communication between a web browser and a web server at a very low level.</p>
<p>Doing It Myself was fun for a while. I could look at a finished site and know that 90% of the code was my own, bar perhaps a couple of very focused code libraries handling really heavy stuff. When something out of the ordinary had to be added I didn&#8217;t have to work around the constraints of somebody else&#8217;s code (and I could work in crazy exceptions to the normal flow of execution whenever I wanted, but we&#8217;ll come back to that). I didn&#8217;t mind doing the heavy lifting and the dull fiddly bits, it was about saying &#8216;I did that&#8217; and proving to myself that I could until finally, once again, I tired of the dull bits.</p>
<p>A project I have been involved in for several years now is one that I Did My Own Way and I am incredibly proud of it. It&#8217;s not a world changing piece of software, it&#8217;s a system to manage the workflow of a small business. It tracks the process of their work, keeps all the details of every piece of fieldwork they do and stores electronic copies of all their documentation. It&#8217;s hardly facebook, there are about 50 tables in the database with just over a million rows between them, and about 30 gigabytes of scanned documentation. It&#8217;s accessed 9-5 by the office and their clients and, other than downtime caused by datacenter power issues, it has not as yet fallen over. I am rather proud of it.</p>
<p>Before work began on that system I had built a loose collection of utility functions that I would use repeatedly when building sites. You could call it a framework. The point of a software framework is to help reduce the tedium I mentioned before. A good framework provides many small software components that each perform one job well, speaking to the database, rendering an HTML template, receiving data from a form etc.</p>
<p>Frameworks also help to structure the code in consistent manner. Each task, such as handling input from a form, should work the same way every time you do it. Form A and Form B are handled by the same code as Form G will be when it becomes time to create it. This uniformity stops you from going mad in 8 months time when you can no longer remember creating Form A but need to add to it. I&#8217;ve written code that provides consistency to each cycle of browser request through to server response, handles database interaction and separates the logic of working with the data from that of displaying it. It&#8217;s an MVC framework and it&#8217;s consistent. Most of the time. It&#8217;s here that Doing It My Own Way has begun to let me down.</p>
<p>Building my own framework has made me a better coder, in fact I&#8217;d recommend it as part of the career path of anyone who, like me, is entirely self taught. During the course of my career I&#8217;ve spent a lot of time reading up on software design patterns, best practices and data security. The low level intricacies of a web browser asking a web server to show it a page are no mystery, in fact I&#8217;ve learnt how to install and administer the servers themselves, secure them and keep them running.</p>
<p>So how have I let myself down with my own framework? I&#8217;ve painted myself into a corner. Doing things The Right Way often takes more time than you have to spare. Features need to be built into software quickly due to the demands of the real world so you do them quickly. This doesn&#8217;t mean they&#8217;re done badly, they do what they&#8217;re supposed to do and they do them well, but you cut corners on doing it The Right Way. Code that should be built as an extension to your framework, extending it in a way that is re-usable in future, ends up in the wrong place, isn&#8217;t reusable, and sneaks up on you from behind.</p>
<p>When break your own conventions as to how things work every exception to the rules is another thing you have to take in to account in future. When you forget that you&#8217;ve done things differently in one place they cause bugs in future code that, in fixing, costs you all the time you&#8217;d previously saved. When you cut those corners you promise yourself you&#8217;ll come back to Do It Properly later, you probably even leave yourself a TODO, but that time never comes and slowly your code becomes harder and harder to maintain.</p>
<p>There is another downside to Doing It Your Own Way, other people need to cope with it. At the moment I am the sole coder on The Big Project but what happens if I get hit by a bus? I&#8217;m not planning to get hit by a bus, but then two come along at once. Whilst your untimely death will come as a blow to both yourself and your family, once you&#8217;re responsible for the code of a large system you&#8217;re also responsible to the future of the client that uses it. Hopefully the client will mourn your loss but they&#8217;ll need to get someone else looking after your code, probably before you&#8217;re even in the ground.</p>
<p>Here is where the importance of documentation comes to the fore. Someone else should be able to pick up your code, read your documentation, and get on with the job. Documentation is very important. Unfortunately as a solo coder documentation is often dealt with at the same time as your TODO list, during that mythical free time you&#8217;re going to have when this next feature is finished.</p>
<p>And here I am. The code is currently full of annoying exceptions and TODO markers, the documentation which was started in earnest is sadly lacking and if I get hit by a bus the client is not exactly screwed, but the next me has a lot of painful reading through code to do. It&#8217;s finally time to bite the bullet and rewrite the whole thing, catching up with the TODO list, removing all the exceptions and making sure that the documentation is actually useful. It&#8217;s time to use someone else&#8217;s framework. With someone else&#8217;s framework there will already be documentation for how the code works. There will be rules, things will be consistently structured and I&#8217;ll finally be able to write the additional documentation of how the business logic is applied (you know, when I&#8217;ve got some free time after the rewrite is finished.)</p>
<p>&#8216;What the hell has that all got to do with magic?&#8217; you scream. Well, I&#8217;ll get to that. In the next post.</p>
]]></content:encoded>
			<wfw:commentRss>http://philrennie.co.uk/blog/coding-life/the-story-so-far/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.htaccess recursive redirects and the probable simple fix</title>
		<link>http://philrennie.co.uk/blog/tech-tips/htaccess-recursive-redirects-and-the-probable-simple-fix/</link>
		<comments>http://philrennie.co.uk/blog/tech-tips/htaccess-recursive-redirects-and-the-probable-simple-fix/#comments</comments>
		<pubDate>Thu, 27 Oct 2011 17:43:33 +0000</pubDate>
		<dc:creator>Phil</dc:creator>
				<category><![CDATA[Tech Tips]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[modrewrite]]></category>

		<guid isPermaLink="false">http://philrennie.co.uk/?p=343</guid>
		<description><![CDATA[I got caught by this one again, it gets me every couple of years. Simple scenario, you&#8217;re using apache and you&#8217;d like to redirect all requests through your front-controller script and mod_rewrite goes into a recursive loop and starts throwing &#8230; <a href="http://philrennie.co.uk/blog/tech-tips/htaccess-recursive-redirects-and-the-probable-simple-fix/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I got caught by this one again, it gets me every couple of years.</p>
<p>Simple scenario, you&#8217;re using apache and you&#8217;d like to redirect all requests through your front-controller script and mod_rewrite goes into a recursive loop and starts throwing out 500 error status codes.<span id="more-343"></span>If you&#8217;re like me you&#8217;ve add mod_rewrite rules to the .htaccess file for your root directory like so</p>
<pre class="brush: plain; title: ; notranslate">
&lt;IfModule mod_rewrite.c&gt;
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ app_dev.php [QSA,L]
&lt;/IfModule&gt;
</pre>
<p>which looks perfectly fine but ends up giving you a 500 Internal server configuration error, and looking in your apache_error.log you find this lovely error</p>
<pre class="brush: plain; title: ; notranslate">Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.</pre>
<p>Well try this little adjustment to fix it, add RewriteBase&#8230;.</p>
<pre class="brush: plain; title: ; notranslate">
&lt;IfModule mod_rewrite.c&gt;
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ app_dev.php [QSA,L]
&lt;/IfModule&gt;
</pre>
<p>It&#8217;s been the forgotten line/simple solution every time I&#8217;ve been hit with this error. So I&#8217;ve popped it here to remind me, and because one more copy of this answer on the web will hopefully mean one less google query for you.</p>
<p>Good luck out there <img src='http://philrennie.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://philrennie.co.uk/blog/tech-tips/htaccess-recursive-redirects-and-the-probable-simple-fix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding folding to PHP switch case statements in Texmate</title>
		<link>http://philrennie.co.uk/blog/adding-folding-to-php-switch-case-statements-in-texmate/</link>
		<comments>http://philrennie.co.uk/blog/adding-folding-to-php-switch-case-statements-in-texmate/#comments</comments>
		<pubDate>Wed, 09 Mar 2011 18:07:56 +0000</pubDate>
		<dc:creator>Phil</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[textmate]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://philrennie.co.uk/?p=325</guid>
		<description><![CDATA[I love the code folding in textmate, but was slightly bugged by the fact that it wouldn&#8217;t fold the cases in switch statements. Some old code that I was going back to had some massive sections of code held in &#8230; <a href="http://philrennie.co.uk/blog/adding-folding-to-php-switch-case-statements-in-texmate/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I love the code folding in textmate, but was slightly bugged by the fact that it wouldn&#8217;t fold the cases in switch statements.<br />
Some old code that I was going back to had some massive sections of code held in cases and I was going a little mad with all the scrolling so I finally got around to changing the PHP bundle.</p>
<p>To get case folding working open up the bundle editor, find the PHP section and click on the language section called php, it should look like a small grey circle with a white L in it, next to the word php</p>
<p>The folding markers are defined with regular expressions for the start and end text to use as a folded area. by default they look like this&#8230;</p>
<pre class="brush: php; gutter: false; title: ; notranslate">

foldingStartMarker = '(/\*|\{\s*$|&amp;lt;&amp;lt;&amp;lt;HTML)';

foldingStopMarker = '(\*/|^\s*\}|^HTML;)';
</pre>
<p>I&#8217;ve not delved a long way into the documentation, but as far as I can tell each match in the StartMarker has a corresponding match in the StopMarker, e.g.  &#8216;\*&#8217; is the first match, and folding is ended by the first match &#8216;*/&#8217; in StopMarker, then we have the curly brackets with anything in between, and then the definitions from the HTML language bundle.<br />
all I did was change them to include &#8216;case&#8217; for the start and &#8216;break&#8217; for the end</p>
<pre class="brush: php; gutter: false; title: ; notranslate">

foldingStartMarker = '(/\*|\{\s*$|case|&amp;lt;&amp;lt;&amp;lt;HTML)';

foldingStopMarker = '(\*/|^\s*\}|break|^HTML;)';
</pre>
<p>and now the cases inside a switch statement fold.</p>
]]></content:encoded>
			<wfw:commentRss>http://philrennie.co.uk/blog/adding-folding-to-php-switch-case-statements-in-texmate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MAMP running slow? One possible cause</title>
		<link>http://philrennie.co.uk/blog/mamp-running-slow-one-possible-cause/</link>
		<comments>http://philrennie.co.uk/blog/mamp-running-slow-one-possible-cause/#comments</comments>
		<pubDate>Wed, 08 Dec 2010 18:10:23 +0000</pubDate>
		<dc:creator>Phil</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[mamp]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://philrennie.co.uk/?p=307</guid>
		<description><![CDATA[So all of a sudden the local development version of my site, run from MAMP on localhost was taking nearly a minute to load any page, despite there being no setup changes since it was &#8216;last known good&#8217;. It took &#8230; <a href="http://philrennie.co.uk/blog/mamp-running-slow-one-possible-cause/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So all of a sudden the local development version of my site, run from MAMP on localhost was taking nearly a minute to load any page, despite there being no setup changes since it was &#8216;last known good&#8217;.</p>
<p>It took me a (thankfully) few minutes to find it with a little Google first.<br />
First off <a href="http://forum.mamp.info/viewtopic.php?f=2&amp;t=6789" target="_blank">someone on the MAMP forum</a> pointed out that you can check if it is Apache as a whole, or perhaps just MySql running slow, by pulling up <em>http://localhost:8888/MAMP/info.php</em> (or your local equivalent, I use port 80 myself). If the info.php script comes up instantly then Apache and php are fine, and you need to look further under the bonnet.</p>
<p>For my case though even the info.php page was taking the same amount of time to load. A quick check in the logs for Apache and PHP showed no errors that could be related to it. So time to stop and think.</p>
<p>My local development environment consists of an iMac and a macbook pro, I bounce between them depending on where I feel like sitting. Each machine has its own copy of MAMP, and I have wildcard virtual hosts mapped to folders in <em>~/Sites/&lt;tld&gt;/&lt;sitename&gt;/public_html</em> and use dnsmasq on each machine to map a fake tld&#8217;s to them, so the sites on the iMac live at <em>http://&lt;sitename&gt;.bmac</em> and the mbp <em>http://&lt;sitename&gt;.dev</em> . This way I can develop against either machine from either machine. The root of each site is also a git repository, so I can easily push and pull changes back and forth between the machines.</p>
<p>I recently rebuilt the iMac, backing up the entire drive, and installing fresh. Then during the install I used the user migration tool to pull across my setup from the MBP. I love the user migration tool, there was almost nothing from my mbp I needed to install on the iMac that wasn&#8217;t pulled across. A few small tweaks to references to machine names in a few files, copy the old iMac documents folder and mail settings over from the backup, and voila!</p>
<p>However&#8230; I missed one setting in php.ini. That setting was <em>xdebug.remote_host</em> which was still pointing to the macbook and as the macbook was off, instead of a simple knock on it&#8217;s door to see if macGDBp  was running or not, there was a massive delay waiting for the connection attempt to time out.</p>
<p>I guess the sensible value for this should actually be localhost, then I would never have encountered the problem. Have double checked the docs ( http://www.xdebug.org/docs/all_settings#remote_host ) I&#8217;m not certain why I wasn&#8217;t already. As the two machine setup is much newer than the xdebug setup I might try out using <em>xdebug.remote_connect_back</em> as no-one else can access these machines, or at least not anyone scary anyway. <em>xdebug.remote_connect_back</em> will automatically try to create a debug connection with the requesting host, which would probably suit my dev-any-machine host-any-machine setup.</p>
<p>So the moral of the story? Specify localhost when it&#8217;s all you need, and save yourself config hassles if the hostname changes.</p>
<p><em>tl;dr: The culprit? Xdebug.</em><em>remote_host</em><em> setting in php.conf pointed to a machine  that wasn&#8217;t turned on. Massive delay while it tried to check in with an  unreachable address.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://philrennie.co.uk/blog/mamp-running-slow-one-possible-cause/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using MAMP&#8217;s mysql from the command line</title>
		<link>http://philrennie.co.uk/blog/using-mamps-mysql-from-the-command-line/</link>
		<comments>http://philrennie.co.uk/blog/using-mamps-mysql-from-the-command-line/#comments</comments>
		<pubDate>Wed, 06 Oct 2010 10:05:49 +0000</pubDate>
		<dc:creator>Phil</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[mamp]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[os x]]></category>

		<guid isPermaLink="false">http://philrennie.co.uk/?p=280</guid>
		<description><![CDATA[Just a brief post on getting mysql to work at the command line with MAMP under OS X I&#8217;d had quite enough of waiting around for phpMyAdmin to import the latest live copy of a database for a project I&#8217;m &#8230; <a href="http://philrennie.co.uk/blog/using-mamps-mysql-from-the-command-line/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Just a brief post on getting mysql to work at the command line with MAMP under OS X</p>
<p>I&#8217;d had quite enough of waiting around for phpMyAdmin to import the latest live copy of a database for a project I&#8217;m working on at the moment, so I decided to head back to the command line for the first time in ages as import time from there can be measured in seconds rather than minutes.</p>
<p>In order to avoid huge commands like</p>
<pre class="brush: plain; title: ; notranslate">/Applications/MAMP/Library/bin/mysql -uUSER -pPASSWORD -DDATABASE &lt; somefile.sql</pre>
<p>you can either add the MAMP directory to your system path in your .profile file or (my preference) you can symlink to the MAMP version of mysql in /usr/bin which should put it onto the default path.</p>
<pre class="brush: plain; title: ; notranslate">cd /usr/bin
sudo ln -s /Applications/MAMP/Library/bin/mysql mysql</pre>
<p>There&#8217;s a slight gotcha here, you might already have a version of mysql kicking about in /usr/bin, if for some reason you really want to use the MAMP version rather than the existing then just rename the existing copy (to keep it as a backup)</p>
<pre class="brush: plain; title: ; notranslate">mv /usr/bin/mysql /usr/bin/mysql_copy_before_mamp</pre>
<p>(I do like to name my backup files something that I&#8217;ll understand in 6 months time)</p>
<p>There&#8217;s a good chance that running the MAMP copy of mysql via this symlink will result in error like</p>
<blockquote><p><code>ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)</code></p></blockquote>
<p>mysql looks by default for the .sock file in /tmp/mysql.sock whoever MAMP&#8217;s mysql keeps it elsewhere so all we need is another symlink</p>
<pre class="brush: plain; title: ; notranslate">sudo ln-s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock</pre>
<p>and you should be rocking and rolling.</p>
]]></content:encoded>
			<wfw:commentRss>http://philrennie.co.uk/blog/using-mamps-mysql-from-the-command-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PDQit Mailshot</title>
		<link>http://philrennie.co.uk/portfolio/pdqit-mailshot/</link>
		<comments>http://philrennie.co.uk/portfolio/pdqit-mailshot/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 14:07:51 +0000</pubDate>
		<dc:creator>Phil</dc:creator>
				<category><![CDATA[Portfolio]]></category>
		<category><![CDATA[featured]]></category>

		<guid isPermaLink="false">http://philrennie.co.uk/?p=196</guid>
		<description><![CDATA[Web-based postal mailshot creation and fulfillment platform. Sureprint had created a desktop printer driver that sent print jobs to their remote print farm to be printed and posted. They wanted to leverage their existing technology to build a service for &#8230; <a href="http://philrennie.co.uk/portfolio/pdqit-mailshot/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><img class="size-large wp-image-197 alignleft" title="pdqit" src="http://philrennie.co.uk/wp-content/uploads/2010/01/pdqit-600x336.jpg" alt="pdqit" width="360" height="202" /></p>
<p>Web-based postal mailshot creation and fulfillment platform.<br />
<span id="more-196"></span>Sureprint had created a desktop printer driver that sent print jobs to their remote print farm to be printed and posted. They wanted to leverage their existing technology to build a service for creation and delivery of mailshot marketing.</p>
<p>PDQit Mailshot allows users to create an account, credit it via an integrated Paypal gateway, and then upload a word Mail-Merge document and excel spreadsheet of addresses. Once the user has connected the correct columns of the spreadsheet with the merge fields, the system communicates with Sureprint&#8217;s existing print software COM objects and creates a pdf example of a merged document to proof, and once approved their mailshot is printed and mailed.<br />
The system was also built to allow white-labeling by third parties, and I assisted TNT in integrating the system into their TNTit product, creating a TNT branded template and authentication and billing gateways between the two systems user databases and billing software.</p>
<p>Visit the site&#8230;<strong><a title="Link to PDQit.com" href="http://www.pdqit.com" target="_blank"></p>
<p>http://www.pdqit.com</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://philrennie.co.uk/portfolio/pdqit-mailshot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

