The fundamentals of testing

A Blog Post by

This is the summary and notes from my talk at the JHB Drupal meetup this this month. It’s the first of a 3 part talk I’m doing on testing.

This is a very top level view of the concepts behind testing your code, as language/framework agnostic possible.

The Joke.

Developer: There is no I in TEAM

Tester: We cannot spell BUGS without U

Created: Thu, 13/02/2014 - 16:49

Debugging the Drupal cron

A Blog Post by

Debugging the Drupal cron can be a pain. I covered a few techniques in the Drupal debugging like a pro post, but I wanted to focus on cron specifically for this one.

So you have a site and the cron gets stuck and you get error messages like these:

  • "Attempting to re-run cron while it is already running."
  • "Cron run failed."
  • "Cron run exceeded the time limit and was aborted."

Now first things first.. you need to unstick the cron if it's stuck. You can do this by removing the cron semaphore variable in the database.

Created: Tue, 09/10/2012 - 17:16

Some handy PHPStorm shortcuts everyone should know

A Blog Post by

I'm a fan of the JetBrains' PhpStorm IDE. It's the best PHP IDE out there at the moment.

Although PhpStorm requires a payed license.. it won't break the bank and is worth every cent.

So some handy shortcuts:


Ctrl + Shift + Enter  // Complete line
Ctrl + W/Ctrl + Shift + W  // Incremental select
Ctrl + "/"  // Line comment // example
Ctrl + Shift + "/"  // Block comment /* example */
Alt + Left/Right  // Move through open files
Alt + Up/Down  // Move through open file functions
Ctrl + Shift + Up/Down  // Move statement up/down
Created: Mon, 03/09/2012 - 20:22

Using variables in a Regex MongoDB query in Node.js

A Blog Post by

I was busy writing a Node.js application with MongoDB integration when I came across this little problem with Regular expressions and MongoDB calls.
The following code will just return nothing:

var search = 'Joe';
db.users.find(name: /^search/);
db.users.find(name: {$regex: /^search/});
db.users.find(name: {$regex: "/^" + search + "/"});

The solution to this little problem is quite simple:

db.users.find(name: new RegExp(search));

I hate little issues like these.. so hope this helps someone else.

Created: Wed, 29/08/2012 - 18:19

Adding your Node.JS app as a service in Ubuntu

A Blog Post by

Adding a Node.js application as a service on your Ubuntu server is pretty easy using Ubuntu's Upstart. Just create a config file at /etc/init/myapp.conf with the following:

description "Your app name here"
author "This would be you"

# Start the service after everything loaded
start on (local-filesystems and net-device-up IFACE=eth0)
stop on shutdown

# Automatically restart service
respawn limit 99 5

# Navigate to your app directory
cd /path/to/myapp/

Created: Mon, 20/08/2012 - 18:15

Prevent browser zoom in iOS

A Blog Post by

Every now-and-then you get a page that iOS Safari just goes and zooms in on your text, which isn't ideal for the overall look, navigation etc.

You can easily prevent this from happening by adding the following line to your page header:

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
Created: Mon, 20/08/2012 - 17:54

Hiding the browser bars in iOS for your web app

A Blog Post by

Ever liked a mobile website so much that you want to add it to your home screen? And who doesn't want to do that with one of their own apps?

Now when the pesky iOS browser bars are bugging you, you can easily remove them by adding the following snippet to your web page head:

<meta name="apple-mobile-web-app-capable" content="yes" />
Created: Mon, 20/08/2012 - 17:25

Getting AngularJS to work within a Drupal install

A Blog Post by

To embed AngularJS (1.0.1) in a Drupal (6.x) site won't work out of the box. To get AngularJS to function you need to upgrade your jQuery to the latest 1.7.x version as the packaged jQuery and jquery update (1.3.2) will break AngularJS.

Now for the solution:
1. Install the latest dev version of jQuery Update and make your default jQuery 1.7.
This That removed some errors but didn't quite cut it.

Created: Mon, 30/07/2012 - 18:47