Decorator Pattern Implemented Properly In PHP
While working on Backend-PHP I needed to do a proper implementation of the Decorator Pattern in PHP. Just googling PHP decorator pattern will come up with a number of simple solutions, but none of them are usable in a general, robust way that a framework requires. So I extended and tweaked the implementations a bit.…
The Low Hanging Fruit Of Testing
I've been getting more into Testing (specifically Unit Testing) the past few weeks, and although I'm still struggling to firstly get it right, and secondly see the long term benefits, I know that the quality of my code is already better. Let's call it the low hanging fruit of Testing.
…json-encode'ing Private and Protected Properties
When you json_encode an object, it will ignore all protected and private properties if the json_encode isn't called from within the object. Sometimes you want to output the protected and private properties of an object when you're JSON encoding it. Here's how to do it in an easy and elegant way:…
22seven.com - Folly, or Genius?
Promising Product
Last week Christo Davel, founder of the now defunct twenty20 bank, released an online personal accounting service called 22seven.com. It looked like a great product. Something I was looking for for quite a while: A simple online interface that automatically imports my transaction details, and reports on how much I'm spending on what.
I will never use it, though. Why? The app asks for your online banking login details.…
Setting up Puppet on Ubuntu 10.4
I'm trying to use puppet to setup standard dev and (eventually) production environments. As Ubuntu 10.4 is the current LTS release (at least until 12.4), I need to get puppet running on 10.4. The problem is that although the latest stable release for puppet is 2.7.6, puppet in the ubuntu repo is version 0.25.4. Here's how to firstly set it up, and then upgrade it to the latest version.
…Backend-Core: A RESTful MVC PHP Framework
I like frameworks. I like working with them, I like writing them. I wrote Backend-PHP, which I'm using personally and at Branded Internet. Unfortunately it has a number of major flaws: It's not easily unit testable, not really a REST web service, and it doesn't conform to any popular coding standards. So I wrote Backend-Core as the first step towards addressing these issues.…
Why Johnny Died (or, How I Finally Realised Why Singletons And Global Variables Are Bad)
Johnny (an asthma sufferer and fictitious character) died yesterday. He got an asthma attack, but he could not find his inhaler, and sadly passed away. Usually his mother kept it for him and made sure he used it, but on the first day he ventured out alone, he got an asthma attack, realised that he didn't have his inhaler with him, and died. What does this have to do with Singletons or Global variables? Read on...…
A PHP Virtual Host
I hate repetitive work. I love solving a puzzle. So it often happens that I'd spend 2 hours writing a script to solve a repetitive problem, than just taking the 2 minutes to do it manually. Creating apache config files are tedious and boring, so I wrote a PHP script that emulates Virtual Hosting.…
A JavaScript trim function
A simple enough trim function for JavaScript:
function trim(string) {
return string.replace(/^\s*|\s*$/g, '')
}
… Quick Guide To Creating A Website Quickly
The last two weeks I had the privilege of staying in a house on the beach near Mosselbay. This time of the year whales start coming into the bay, and, if you're lucky, you can spot them breaching or displaying their flukes or fins. This inspired me to create WhaleSpotter, a site that uses Twitter to help people spot whales along South Africa's south coast. It took me less than 2 hours to do it. Here's how.…





