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
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
December 18th, 2009 — 3:04pm
Are you fed up with so called SEO experts extolling the importance of meta “keywords” tags on a site’s Google rank? Me too. I therefore created doesgoogleusethekeywordsmetatag.com.
So the next time anyone moans about their site’s lack of a keywords meta tag, you know where to send them
1 comment » | web
November 25th, 2009 — 12:10am
Having recently read about Jekyll I decided to boot up Ubuntu, install all the bits and pieces and give it a try. However, I fell at the first hurdle when greeted by the following error:
Error installing gemcutter:
gemcutter requires RubyGems version >= 1.3.5
The Synaptic Package Manager reported everything as being up-to-date but only to version 1.3.1. As it turns out, there is another way to update rubygems on Ubuntu, which worked a treat! The rest of the installation was a breeze
If you are interested more info on Jekyll can be found on GitHub.
Comment » | web