Author Archive


Setting up Unit Testing in Drupal 6 with PHPUnit

July 23rd, 2010 — 1:34pm

I’ve been using Drupal now for a couple of months, ever since I started my new job, and the other day got my first chance to start writing a custom module.

I was keen to use a TDD approach, but wasn’t sure how well this would play with Drupal. The SimpleTest module looked pretty good but in the end I went with PHPUnit, mainly because I’d used it before.

After a bit of research I came across a this post explaining how to get PHPUnit set up to play nicely with Drupal 6: http://kristiannissen.wordpress.com/2009/12/08/drupal-6-phpunit-testing-setup/

It worked like a charm :) So, just for good measure, I created a project template containing the unittests folder and necessary include files and stuck it on GitHub: http://github.com/ianoxley/drupal-phpunit-template

Comment » | web

Greasemonkey Open Selected Links Script

June 1st, 2010 — 10:02pm

I hadn’t done any monkeying around with Greasemonkey for a while until the other day when I came up with this script: http://github.com/ianoxley/open-selected-links

Any links that are present in the selected text will be opened on the mouseup event, except for the Cached and Similar links you get in Google search results.

If you’ve got and suggestions for improvements, let me know in the comments :)

UPDATE

The script has been updated so that you now have to press the Ctrl or Cmd key while selecting the text, in the same way that you would Ctrl / Cmd + click to open a link in a new tab.

Comment » | javascript

Some Fun with the TARDIS, HTML5 and CSS3

May 19th, 2010 — 10:54pm

Just for fun, I thought I would have a play around with some WebKit CSS transitions and the HTML5 <audio> tag to see if I could simulate the TARDIS landing :)

Here’s what I came up with (currently only works in Safari): TARDIS, HTML5 and CSS3 WebKit Transitions

Comment » | web

Xdebug Tailored Installation Instructions with PHP 5.2 and Ubuntu 10.04

May 18th, 2010 — 10:27pm

I was really impressed with the Xdebug Tailored Installation Instructions earlier today. Setting up a dev machine at my new job wasn’t going quite according to plan because, as nice as Ubuntu 10.04 Lucid Lynx is:

  1. Installing PHP via sudo apt-get install php5 installs the latest version from the repositories (version 5.3 at the time of writing)
  2. We do a lot of work in Drupal, mostly version 6 which isn’t compatible with PHP 5.3 (and quite a few modules that work with Drupal 6 don’t work with Drupal 7 apparently – Drupal 7 plays a lot nicer with PHP 5.3 by all accounts).
  3. So it was necessary to uninstall all the PHP 5.3 packages, add the karmic repositories to the sources.list then reinstall PHP – this time PHP 5.2

Once all this was done, it was time to install Xdebug. The tailored installation instructions seemed the best option as I’d just had to revert to a previous version of PHP. And, it couldn’t have been simpler or more straight-forward to do:

  1. Go to http://xdebug.org/find-binary.php, paste in the HTML from your phpinfo() output and submit the form
  2. You’ll get a nice summary and some instructions to follow :)
    Summary

    Summary

    Instructions

    Instructions

After following the instructions, restart apache and reload your phpinfo() page: if your experience is anything as good as mine you should see all the xdebug configuration options set up nicely and ready to go.

Comment » | devtools

Using Git

April 27th, 2010 — 10:18pm

Since going freelance at the end of last month I made the conscious decision to use Git for my source control on freelance projects. I’d kind of used it a bit when adding stuff to GitHub but hadn’t really used it in anger on anything. Until now. And so far so good.

Quite a nifty little cheatsheet I found was this: http://cheat.errtheblog.com/s/git

I really like the aliases and colour-coding – simple stuff but these save you a lot of typing / keystrokes and make it easier to see at a glance what’s what respectively :)

1 comment » | devtools

JavaScript WebKit Notifications API Demo With Flickr and JSONP

April 24th, 2010 — 10:12pm

I’ve been playing around with the JavaScript Notifications API recently – or to be a bit more specific the WebKit Notifications API – and put together this little demo using Flickr and JSONP:

  1. You search Flickr by entering a tag
  2. The JSONP callback function then displays the first few photos returned using the Notifications API
  3. Each notification is cancelled after 10 seconds (there is no Dismiss button, like there is when you use the API on localhost)

You’ll need to grant notification permissions first to be able to view the notifications – you should see an info bar like the one below the first time you click on Search:

WebKit Notifications API requestPermission screenshot

After that, you should see the notifications stack up in the bottom right-hand corner of your screen:

Screenshot of the notifications

At the time of writing, you’ll need to be using Google Chrome for the demo to work (although I’m pretty sure that support for the Notifications API in Safari is imminent).

And, as an aside, I managed to throw a bit of HTML 5 into the demo as well with some autofocus and placeholder attributes on the <input type="text" /> field, just for good measure :)

Comment » | javascript

Usability Testing of APIs

April 21st, 2010 — 9:10am

Usability testing, as you may well know, involves you watching real users interact with your website or application so you can really see how they interact with it and how you might improve certain areas of it.

Of course, there’s no reason usability testing in software has to be restricted to just websites and applications. In Peter Seibel’s book, Coders at Work, I was interested to read Simon Peyton Jones discussing how Microsoft applies usability testing to API’s:

Well, they also do some interesting work on testing APIs. Steven Clarke and his colleagues at Redmond have made systematic attempts to watch programmers, given a new API, talk through what they’re trying to do. And they get the people who designed the API to sit behind a glass screen and watch them.

And the guys sitting there behind the glass screen say, “No, no, don’t do that! That’s not the right way!” But it’s soundproof. That turns out often to be very instructive. They go and change their API.

from Coders at Work, Chapter 7 – Simon Peyton Jones [p. 253]

If you haven’t yet got a copy of Coders at Work you can buy one from Amazon.

Comment » | ux

That Yellow Highlight Colour in RGB and Hex

March 15th, 2010 — 9:30pm

This is just meant as a reminder for me, as I can never remember the colour values to use when trying to add that yellow highlight colour to some CSS (in fact, even as I’m writing this the WordPress permalink editor is taunting me with that very same colour).

So, without further ado:

  • Hex: background:#FFFBCC;
  • RGB: background:rgb(255, 251, 204);

1 comment » | devtools

A Simple jQuery Print Page Plugin

February 26th, 2010 — 9:25pm

The other day I was after a really simple way to add a print page link to a page to, well, er, print it.  So I came up with my jQuery Print Page plugin and stuck it on GitHub with a demo page: http://github.com/ianoxley/jqueryprintpage

This really is nothing fancy: it’s just a convenient way of adding an <a> tag plus an event-handler to a page to print it. Using it is as simple as, well, using File -> Print. But you can’t style the File menu with CSS so this is much more fun :-)

Comment » | javascript

What Makes a Good Printer Test Page?

January 19th, 2010 — 12:46am

I don’t normally think twice about printer test pages. And, to be honest, who does? But I was setting up a new printer at home the other day on my laptop, which dual boots into Ubuntu 9.10 (Karmic Koala) and Windows 7 and couldn’t help but notice that stark contrast between the Windows 7 printer test page and it’s Ubuntu counterpart:

Windows 7 printer test page

Windows 7 printer test page

Ubuntu 9.10 printer test page

Ubuntu 9.10 printer test page

I know which one I find more useful and informative :)

Comment » | ux

Back to top