Making better bricks

It can scarcely be denied that the supreme goal of all theory is to make the irreducible basic elements as simple and as few as possible without having to surrender the adequate representation of a single datum of experience.” – Albert Einstein

I have found the same should be the case for components in a program, each component should have:

  1. A single purpose.
  2. The minimal functionality required to serve its purpose.
  3. The simplest interface possible to successfully use the component.

Keeping the components as simple and focused as possible is the difference between building a model using individual lego bricks or (complete) lego models.  The lego bricks fit together easily due to their singular purpose, simple shape and consistently simple interface.   You can build pretty much anything out of simple lego bricks.  The lego models despite being made out of lego bricks are much harder to build with as you have to compensate for their varied purpose, irregular shape  and correspondingly more complex interface requirements.

By keeping components simple, focused and easy to use we can increase the flexibility and reusability of our software.

Running WordPress on Mac OS X with XAMPP

Experimenting on the theme, layout and widgets on a live WordPress blog is never a great idea as there is always the risk of not being able to roll back to your previous layout and widget configuration.  A lower risk way to experiment is to host and run a copy of your WordPress blog locally on your Mac, this way you can hack away with zero risk to your live blog.  The XAMPP bundle makes this very easy to setup:
  1. Download XAMPP for Mac OS X from
  2. Open the xampp dmg file and copy xampp into the applications folder.
  3. Run the xampp control app and start apache & mysql.
  4. Using your browser, go to http://localhost/xampp/splash.php
  5. Select your language then click phpMyAdmin.
  6. Create a database called ‘wordpress’ using ‘utf8_unicode_ci’ collation.
  7. Download WordPress from
  8. Unzip WordPress into /Applications/XAMPP/htdocs/.
  9. Copy the following details into your wp-config file, and save it as wp-config.php These are the exact details you need for Xampp to work because the default user in phpmyadmin is called ‘root’ and there is no password:
    1. DB_NAME is ‘wordpress’.
    2. DB_USER is ‘root’.
    3. DB_PASSWORD is ”.
    4. DB_HOST is ‘localhost’.
  10. In your browser, go to http://localhost/wordpress/wp-admin/install.php to install WordPress.
  11. Once WordPress installation is complete go to http://localhost/wordpress/ to verify the installation.
  12. To get automatic updates of WordPress and installation/updates of plugins and widgets working do the following:
    1. Make a note of your username e.g. ‘Daniel’.
    2. Open /Applications/XAMPP/etc/httpd.conf as root/admin e.g. “sudo open -e ‘/Applications/XAMPP/etc/httpd.conf'” from terminal.
    3. Find the following lines:
      User nobody
      Group admin
    4. Change the lines to the following:
      User <Your Username>
      Group staf f
    5. Save the file.  Some people are having issues with TextEdit preventing edits to the file due to file ownership, there are two possible work arounds:
      1. Use another text editor like vi to make the required edits the file: “sudo vi ‘/Applications/XAMPP/etc/httpd.conf'”.
      2. Use the chown command to change the file’s ownership: “sudo chown <Your Username> ‘/Applications/XAMPP/etc/httpd.conf'”.
  13. Restart XAMPP and visit http://localhost/wordpress/ you should now have a fully functional WordPress installation you can experiment on without effecting your live blog.

The next step is to mimic the configuration of the live blog on the test blog by:

  1. Importing the posts and comments from the live blog.
  2. Installing the same theme, widgets and plugins.
  3. Configuring the theme, widgets and plugins.

You can now start hacking away on your test blog without worrying about breaking your live site!

Friday Linkage

This weeks interesting links:

John Cleese on creativity

I must admit I never new much about John Cleese before watching this video other than he was in Monty Python and that he is very funny.  I had no idea he was also so analytical or that he had a scientific background.

I have had similar experiences of giving up on solving a problem and going to bed to discover the next day that I have unconsciously solved the solution over night.  Sometimes I don’t even know I have solved the problem until I start debugging the problem with someone else and at which point I tell them the solution before my conscious mind was even aware that I had a solution.

The concept of setting up ‘boundaries of space and time': space from interruptions and periods of time to focus on a task is a very good way of explaining the necessary prerequisites for achieving flow.  I particularly like John’s dig at laptops being distracting followed by the camera panning to two guys in the audience sitting using laptops who seem oblivious to what he just said…

Kindle Skeptic Converted!

I was skeptical about dedicated ebook readers until I bought a second generation Kindle last year.  The convenience of the device: its diminutive size and weight, the massive Amazon catalogue, the epic battery life, the huge internal book storage capacity, built in dictionary, wireless book delivery and the incredibly user friendly reading experience offered by the E-Ink screen combined to rapidly make it the most treasured electronic device I own.

I just received a third generation WiFI Kindle for my birthday and the new device manages to make the older model look completely outdated which is impressive given the iterative nature of the new device.  The first thing that strikes you when you hold the new device is its size: the new device is half an inch shorter and narrower than the previous generation which adds up to an impressive overall size reduction and means the newer device is seventeen percent lighter than the previous model while retaining the same screen size.

Compared to the 3G in the previous model the WiFi is an significantly faster experience: browsing the kindle store or downloading books is now comparable to the speed of the kindle App on my iPhone over WiFi.  I decided to go for the Wifi only model as despite owning a kindle for a year I’ve only ever bought one book when I wasn’t at home so I couldn’t really justify the extra cost for the WiFi & 3G model.  The battery life for the WiFi only Kindle is also significantly longer than the WiFI/3G version (three weeks versus ten days), this is no surprise given the differences in range for WiFi vs 3G: the 3G radio simply needs more juice.

There are several additional tweaks in the new device: the back of the device is now textured so you are less likely to drop it, the screen has 50% more contrast, you can now adjust text line spacing, the screen changes a bit faster and the storage capacity is doubled.  They’ve also moved the power button, headphone jack and volume control to the bottom of the device although I’ve never actually tried out the MP3 or audio capacity of the Kindle.

I would recommend the Kindle to any avid reader, I used to be a binge reader but I have been averaging a book a week since getting a kindle…


WordPress filters for Google Analytics

If you use Google’s excellant Analytics service to track traffic to your WordPress blog you may have noticed that days were you have been doing a lot of administrative work or writing on your blog that you had large traffic spikes.  This is due to Google Analytics recording all your administrative and writing related visits to your site and this can be quite misleading if your trying to improve your traffic.

Fortunately there is a very simple way to configure Google Analytics to prevent administrative pages and post preview pages being recorded as genuine site traffic.

  1. Login into Google Analytics.
  2. Click the ‘Analytics Settings’ option in the top left:
  3. Click the ‘Edit’ option for your blog’s site:
  4. Click the ‘Edit’ option for the ‘Main Website Profile Information’ section:
  5. Enter ‘preview=true|wp-admin’ into the ‘Exclude URL Query Parameters:’ textbox and click ‘Save changes':

Google Analytics will now ignore all visits to WordPress’es administrator pages (which are in the ‘wp-admin’ subfolder on a typical install) and also ignore any page previews (which have ‘preview=true’ in the URL).  You can now administrate your site and write posts without worrying about your actions skewing you site’s traffic data!