adium-logo.pngOne missing feature from Adium that’s been bugging me for ages is a way for the file transfer window to auto close.
There doesn’t seem to be any such future for this feature, so I thought I’d knock up a little AppleScript to do the work for me.

Simply drop this into the AppleScript editor of your choice and save it somewhere on your mac, then follow the instructions underneath.

tell application "Adium"
	tell window "File Transfers"
		set visible to false
	end tell
end tell
  • Open Adium Preferences and click on the Events icon.
  • Find File transfer completed successfully, select it and then click Edit in the bottom right corner.
  • Under the action drop down box choose Run an AppleScript.
  • Browse to the AppleScript you’ve just saved.
  • Apply those settings and you’re done!

You could also add the same AppleScript to the other file transfer events, but that’s up to you. I’m trying to work out a way for the AppleScript to clear the download list, but I’m not getting anywhere at the moment!


I’ve decided to switch off the www portion of my website. Following in the no-www.org spirit I implemented the code to force redirects to the non-www version a couple of days back.
Here’s the code that they recommend on their website.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]

However, there’s a problem with that code. If some of your URL’s have query strings after them (page.php?this=that&number=200) the parameters won’t be passed over to the new URL. Here’s the correct code to use as is running here.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.sdjl\.co\.uk$ [NC]
RewriteRule ^(.*)$ http://sdjl.co.uk/$1 [QSA,L,R=301]

The only difference being the QSA option at the end of the last line. Simple!


One of the websites I host and operate ran into some problems today with the image upload facility. For some reason it wouldn’t resize any images with an error showing that too much memory was being used. Uploading the same image via a different website I host worked fine, which I found a little strange.

To cut a long story short I managed to get things working again by switching from the inbuilt GD library to Imagick, the PHP extension to ImageMagick. Here’s the code I used to make a thumnail based on the image uploaded.

function create_thumbnail($file, $new_name, $max_side) {
 
	$image = new Imagick($file);
	// Providing 0 forces thumbnailImage to
	// maintain aspect ratio
	$image->thumbnailImage($max_side,0);
 
	$thumbnail = $image->writeImage($new_name);
	$image->destroy(); // Free resources
	if($thumbnail == true) {
		return true;
	} else {
		return "Imagick Error!";
	}
}

It went from about 50 lines of code, to just 13. A pretty good improvement considering it does the same thing!


I’ve lost count how many times I’ve needed to recompile a new version of APC for PHP on my server, so this mainly serves as a reminder on how to do it for next time.

  1. Go to http://pecl.php.net/package/APC and find the latest download link at the time.
  2. Login via SSH and go into root login via
    su -
  3. Navigate to the source folder:
    cd /usr/local/src
  4. wget the latest download from the PHP pecl link above. (i.e. wget http://pecl.php.net/get/APC-3.0.15.tgz)
  5. Unzip the archive like so:
    gunzip -c APC-3.0.15.tgz | tar xf -
  6. Navigate to the APC folder:
    cd APC-3.0.15
  7. phpize the APC folder to make the correct configuration file: /usr/bin/phpize
  8. Make the configuration file:
    ./configure --enable-apc --enable-apc-mmap --with-apxs --with-php-config=/usr/bin/php-config
  9. Start the compile:
    make
  10. Finish and install:
    make install
  11. Edit the php.ini file to enable the APC module based on the location provided from the previous command:
    pico -w /usr/lib/php.ini
  12. Finally restart apache to see the changes:
    service httpd restart

The important bits you need to put inside php.ini are the extension call like so:

extension = "apc.so"

You then also need to enable and configure APC to your liking. Here’s my setup:

apc.enabled = 1
apc.shm_size = 64
apc.ttl = 3600
apc.user_ttl = 3600
apc.optimization = 0
apc.filters = "-Gallery.*\.class, wp-cache-config, -mint.php"
apc.include_once_override=1
apc.write_lock=1

Other things you need to take into account is your PHP extension_dir setting. This needs to be set right to be able to load the module correctly above.
You should also bear in mind that /usr/bin/phpize and /usr/bin/php-config could be different for your system setup.


Yesterday a compromised server was used to attempt to get into my box. Thankfully I have an operationally mod_security and a damn fine firewall, that monitors mod_security alerts. This is a vital thing to have, especially if you have any compromisable software running. I do daily and weekly checks of my server to make sure there aren’t any things on here that shouldn’t be.

Read the rest of this entry »

lotsa emails this way!