Happy Birthday Bash Script

29th October 2012 - 1 minute read time

Following on from the PHP script to print happy birthday I wanted do the same in a bash script. I don't really use bash for much more than stringing together commands so I had to figure out how to do loops and if statements using the simple bash syntax. I also wanted to pass the name of the person as an argument, rather than hard code it into the script. This is what I came up with.

Happy Birthday PHP Script

29th October 2012 - 1 minute read time

When posting happy birthday messages to developers over social media I like to write it in code, just to be geeky. The following code will print the happy birthday song using PHP.

PHPNW12: A Review

20th October 2012 - 48 minutes read time

The annual PHPNW conference gets better every year, and this year was no exception. I have been going to the PHPNW conference since their inception in 2008 and this year I was lucky enough to be involved in some of the pre-conference organising and helping out over the event.

When the call for papers ended in June I spent a weekend reading abstracts and bios of speakers to try and reduce the 169 talk submissions to around 32 sessions. I then sat down with Jeremy Coates, Rick Ogden and Jenny Wong to select which talks would be included in the final selection. Once the sessions were complete I sat down and started working on a blog schedule and wrote a few blog posts to garner attention.

Why I Went For A Macbook Pro

13th September 2012 - 7 minutes read time

I very recently took delivery a 15 inch MacBook Pro (my first Apple computer) and I thought I would write about my reasoning behind it. Normally, people don't tend to ask why you bought a computer, but with Apple products it seems to be different. I think I have stated my reasons to a few different people already, so I thought it would make a good blog post.

Using Zend Framework In Drupal

14th August 2012 - 4 minutes read time

If you want to use Zend Framework in Drupal then most of the time you can use the Zend module. This takes a little configuration but will include the framework and instantiate the Zend_Loader_Autoloader class so that everything is ready to run.

The Zend module has a number of different strategies to including the framework, which is handy if you do or don't want to use the Libraries module. The module uses the hook_init() hook to include and instantiate the Zend_Loader_Autoloader object, which meant that this was done on every page load; even if the framework isn't being used.

Using Python To Beat The 2012 Olympic Google Doodles

11th August 2012 - 5 minutes read time

The other day I was inspired by a story on Reddit about a guy who had created a Python script to automatically play the olympic hurdles Google Doodle. The Python script just passed the correct keyboard commands to the game so that the game was finished in 1.5 seconds, earning a gold medal. The problem was that his script was specifically for Windows, so I set about trying to create a Linux version that I could run on Kubuntu.

After a bit of research I found a decent plugin that sends keyboard commands through Python called uinput. To get this installed I had to add the following lines to /etc/apt/sources.list.

Testing Websites With Selenium And PHP

16th July 2012 - 6 minutes read time

Selenium is an application that allows automated testing of websites through a browser and consists of a number of different components. It allows the creation of browser tests that perform certain actions, which can then be run again at a later date. Three components are required to allow Selenium to run tests through PHP. These are as follows:

Mimicking Data Provider Functionality In Drupal SimpleTest

10th July 2012 - 5 minutes read time

Although Drupal SimpleTest is an extremely useful module it doesn't currently support data providers, which is a shame as I use that feature quite a bit in other testing frameworks. A data provider is a mechanism that allows you to call a single test case multiple times with different arguments so that you can ensure the correct output each time. This is useful because testing a single function once is fine, but testing it with a variety of different values can otherwise mean having multiple test cases.

To mimic this functionality in Drupal SimpleTest you can create a data provider method that returns an array, which is then used to test a particular function.

For example, let's say I have the following (trivial) function in a Drupal module.

LAMP And Beyond: A Review

3rd July 2012 - 4 minutes read time

Saturday 30th June saw a one off event organised by the PHPNW community called LAMP and Beyond. The idea was that it would bring together people of differing abilities with the aim of sharing skills and experience with servers, programming, source control, or whatever happened to be of interest at the time.

With 30 or so people signed up to the event we filled the top floor of MadLab in Manchester and got started (after a bit of coffee first). Taking some post-it notes we wrote down what we wanted to know about and what we could teach about onto a board and then broke off into groups where people's interest matched.

Find The Size Of Files And Directories In Linux With The du Command

29th June 2012 - 6 minutes read time

The du (or 'disk usage') command is a Linux command that can print a list of the files within a directory including their sizes and even summarize this information. It is useful if you want to see how large a group of files is and provides more information about directories than the ls command does.

Using du within a directory will show you the size (in bytes) of all files and directories under that directory, including the size of the current directory. To make du produce more readable results just use the -h flag to make the file sizes into a human readable format. You can also use the -c flag to produce a grand total of all of the sizes found, and the -s flag to display only a total. The -a flag can be used to display all files as well as directories, leave this out to just display directories.