August 24th, 2010 — 11:42pm
Have you ever tried to use SELECT…INTO OUTFILE in MySQL and come across the following error?
"Can’t create/write to file ‘/path/to/folder/filename’ (Errcode: 2)"
I was having this problem the other day and, after checking that file permissions weren’t the cause of the problem, I came across the following post on the MySQL forums:
"The problem was not in MySQL but in AppArmor on Ubuntu. I had to add the directories I wanted to write into to my /etc/apparmor.d/usr.sbin.mysqld and restart apparmor.d."
So, one sudo vim /etc/apparmor.d/usr.sbin.mysqld later and I’d added the path/to/folder I needed to be able to write to (not forgetting to add the trailing comma ‘,’ to the end of the line, which is always required, even for the last line).
All that was left to do was to restart AppArmor with:
$ sudo /etc/init.d/apparmor restart
After that, SELECT…INTO OUTFILE worked like a charm
Comment » | web
August 18th, 2010 — 10:05pm
Recently I made a few amends to some Greasemonkey scripts I wrote a while back and, since I’ve been using git quite a bit recently, it made sense to me to move my Greasemonkey scripts onto GitHub.
So I did
And here they are:
Comment » | javascript, web
August 5th, 2010 — 11:43pm
Being fairly new to Drupal, I was interested to know whether it had anything built in that let you know, or detect, when a user was logging in for the first time e.g. to show them a welcome message.
As far as I know, there’s no method in the API to detect this. However, after checking the global $user object's properties to see what we had to play with, it turns out it wasn't all that tricky:
- the
$global user contains 3 timestamp properties: created, access and login
- when a user logs in for the first time, all 3 of these timestamps are equal
This means we can check whether a user is logging in for the first time with something like this:
function is_first_time_login($user) {
return ($user->created == $user->login) &&
($user->login == $user->access);
}
Now we can call that function where we need to in our elsewhere in our code. For example:
function foo() {
global $user;
...
if (is_first_time_login($user)) {
drupal_set_message(WELCOME_MSG);
}
...
}
So far, this approach seems to be working quite well
Comment » | web
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
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
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
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:
- Installing PHP via
sudo apt-get install php5 installs the latest version from the repositories (version 5.3 at the time of writing)
- 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).
- 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:
- Go to http://xdebug.org/find-binary.php, paste in the HTML from your
phpinfo() output and submit the form
- You’ll get a nice summary and some instructions to follow

Summary

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
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
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:
- You search Flickr by entering a tag
- The JSONP callback function then displays the first few photos returned using the Notifications API
- 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:

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

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
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