Wow, it’s been a while. If I’ve been tucked away in your RSS reader it may be a bit of a shock to see me pop up again. Hi!

I had been working for myself since leaving Automattic but recently started working at a Sydney web development company called Red Ant. I feel quite lucky to have landed in yet a another company full of interesting people and work. I like to think that at some point I’ll put up a post here showing off some of the stuff I’ve been working on since bbPress.

I’ve just posted an article over at the Red Ant blog about configuring Nginx to redirect SSL in a way that doesn’t suck an elegant way using maps. Worth reading if you are interested in web server configuration.

I’ll probably be posting a bit more there, so rather than cross-post to here I just suggest that anyone that’s interested may want to follow the Red Ant blog… because you are all really interested right? Right? Hello… is this thing on?

FUD

FUD – source: ckelty at flickr

First a declaration…

I am employed by Automattic but these are my personal opinions and not a statement on behalf of Automattic. More relevantly I am a contributor to WordPress but this is by no means a statement on behalf of that community.

Now, to the point…

I’ve been following the discussion over at pomomusings which follows a post where Adam Cleaveland listed the Thesis theme as one of the top 10 reasons for switching to WordPress. Matt Mullenweg (who can make statements on behalf of WordPress) posted an early comment where he suggested that the WordPress Theme “Thesis” was “hostile to WordPress’ core freedoms and GPL license”. The obligatory GPL debate ensued with Thesis developer Brian Clark refuting the claim. His comments so far have culminated in a statement where he indicated that he suggested to Matt that “we consider a declaratory judgment action” to resolve the question of whether the Thesis theme should by law be distributed under a GPL license.

I’m going to skip over the part of the discussion where Brian seems to get mixed up about derivative works with regard to copyright as opposed to as it is defined in the GPL (that’s intellectual property law versus contract law, conflating the two is erroneous at best and deceptive at worst). Rather I take issue with this notion of taking the whole matter to court. As I see it, the suggestion is a tactic in managing public perception.

Read More

A while ago I wrote up a method for switching between /etc/hosts files. That post is pretty popular and clearly been useful to a few people.

Since then I’ve actually extended this method into a tool that can manage multiple /etc/hosts files. Using this new method you can have a folder that you can add hosts configurations to, and those files become available for switching into /etc/hosts straight away.

There’s no reason why an adaptation of this method wouldn’t work in Linux as well.

Here’s how you do it:

1. Create the host configuration directory

We’ll store all the /etc/hosts type files in /usr/local/share/hs.

You’ll need to do all of this as a root user. So switch to root using sudo -s first (you’ll need to be an administrator to do this).

$ mkdir -p /usr/local/share/hs
$ chmod 755 /usr/local/share/hs

Now to start with, let’s make a copy of the existing /etc/hosts file in this directory.

$ cp /etc/hosts /usr/local/share/hs/hosts.normal
$ chmod 744 /usr/local/share/hs/hosts.normal

Then make the real /etc/hosts a symbolic link to that new file.

$ ln -sf /usr/local/share/hs/hosts.normal /etc/hosts

Any additional host configurations in this folder need to be named using a similar hosts.* pattern.

2. Create the host switching script

Take the following bash script and save it to a file located at /usr/local/bin/hs

#!/bin/bash

if [ $1 ]; then
	HFILE=hosts.$1
else
	HFILE=hosts.normal
fi

# Change this if you put your host files elsewhere
HPATH="/usr/local/share/hs/"

echo "Attempting to switch host file to $HPATH$HFILE"

if [ ! -e $HPATH$HFILE ]; then
	echo "--> File does not exist!"
	echo "--> Exiting with status 1"
	exit 1
fi

if [ -d $HPATH$HFILE ]; then
	echo "--> File is a directory!"
	echo "--> Exiting with status 2"
	exit 2
fi

if [ -h $HPATH$HFILE ]; then
	echo "--> File is a symbolic link!"
	echo "--> Exiting with status 3"
	exit 3
fi

if [ ! -h /etc/hosts ]; then
	echo "--> Current hosts file is a real file!"
	echo "--> Exiting with status 4"
	exit 4
fi

# Link it up
sudo ln -sf $HPATH$HFILE /etc/hosts

# Flush the system-wide DNS cache
if [ -x /usr/bin/dscacheutil ]; then
	# Mac OS X 10.5
	/usr/bin/dscacheutil -flushcache
elif [ -x /usr/bin/lookupd ]; then
	# Mac OS X Less than 10.5
	/usr/bin/lookupd -flushcache
elif [ -x /usr/sbin/lookupd ]; then
	# Mac OS X Less than 10.5 (alternative)
	/usr/sbin/lookupd -flushcache
fi

echo "--> Done"

The script does some basic validity checking on the file and also makes sure that /etc/hosts is just a symbolic link and not a real file.

You will need to adjust the permissions on this script so that only admins can run it.

$ chmod 750 /usr/local/bin/hs

You also need to make sure that /usr/local/bin is in your PATH so that the hs command can be found. We can test that.

$ echo $PATH

… will output something like …

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

If it’s not there then you need to add it in your users ~/.profile file. Add the following line to that file, you can create the file if it isn’t there.

export PATH=/usr/local/bin:$PATH

Now reload your profile and the hs command should be available.

$ . ~/.profile

You could also just close and open your terminal window to reload your profile.

3. Trying it out

The hs command takes one argument. The argument is used to specify the hosts configuration file to be loaded from /usr/local/share/hs. If no argument is given, then the assumed file is hosts.normal.

So for our first test we should add another hosts configuration.

$ cp /usr/local/share/hs/hosts.normal /usr/local/share/hs/hosts.test

Edit the new hosts configuration file to your liking.

Now we can try the switching command to switch to that configuration. You will need to supply your password if you are not already running as root.

$ hs test
Attempting to switch host file to /usr/local/share/hs/hosts.test
Password:
--> Done

The symbolic link at /etc/hosts should now be pointing to /usr/local/share/hs/hosts.test.

$ ls -l /etc/hosts
/etc/hosts -> /usr/local/share/hs/hosts.test

Now try switching back to your normal configuration.

$ hs
Attempting to switch host file to /usr/local/share/hs/hosts.normal
Password:
--> Done

Any more configurations that you add to /usr/local/share/hs are available this way.

Neat, huh?

4. Fancy schmancy tab completion

So that’s all great until you have 10 different hosts config files and you can’t remember their names.

The simple solution is to register additional commands so that command line tab completion can be used. The following additional script registers all the available hosts configs as separate commands. So instead of typing hs test we can type hstest. More importantly we can type hs then hit the “tab” key twice and get a full list of all available commands (one per configuration file).

Hard to explain, easier to just do. Add the following lines of code to the end of your ~/.profile file.

# Setup hs* commands
HSPATH=/usr/local/share/hs
if [ -d $HSPATH ]; then
	HSFILES=(`ls $HSPATH`)
	HSCOUNT=${#HSFILES[*]}
	for (( HSI=0 ; $HSI < $HSCOUNT ; HSI=$HSI+1 )); do
		HSFILE=${HSFILES[HSI]}
		HSFILE=${HSFILE:6}
		alias hs$HSFILE='hs '$HSFILE
	done
fi
unset HSPATH HSFILES HSCOUNT HSI HSFILE

This script loops through all the files in /usr/local/share/hs and adds a command for each. Once that is added, reload your profile to make the script work.

$ . ~/.profile

Now you should be able to type hs then hit the “tab” key twice and get a list of the available commands.

$ hs TAB TAB
hs            hsnormal      hstest

If you add any new configuration files to /usr/local/share/hs you need to reload your profile for it to turn up as a new command (or just relaunch your terminal window).

Enjoy!

For any web developers out there who long for the good old days of table-based layout stuffed full of transparent GIF spacers – here’s a reality check from an old website I wrote back in my ASP* days…

browser = ucase(request.servervariables ("HTTP_USER_AGENT"))

inputwidth = "24"
textareawidth = "26"
fontsize = "9pt"
displayfontsize = "24pt"

if left(browser,12) = "MOZILLA/4.08"
or left(browser,12) = "MOZILLA/4.73" then
	inputwidth = "12"
	textareawidth = "12"
	fontsize = "9pt"
	displayfontsize = "24pt"
end if

if (left(browser,12) = "MOZILLA/4.73"
or left(browser,11) = "MOZILLA/4.0"
or left(browser,12) = "MOZILLA/4.61")
and right(browser,4) = "PPC)" then
	inputwidth = "24"
	textareawidth = "20"
	fontsize = "12pt"
	displayfontsize = "32pt"
end if

if left(browser,12) = "MOZILLA/4.61"
and right(browser,4) = "PPC)" then
	inputwidth = "24"
	textareawidth = "20"
	fontsize = "12pt"
	displayfontsize = "32pt"
end if

if left(browser,16) = "MOZILLA/4.0 (COM"
and right(browser,17) = "5.0; MAC_POWERPC)" then
	inputwidth = "29"
	textareawidth = "26"
	fontsize = "9pt"
	displayfontsize = "24pt"
end if

if left(browser,16) = "MOZILLA/4.0 (COM"
and right(browser,17) = "4.5; MAC_POWERPC)" then
	inputwidth = "17"
	textareawidth = "15"
	fontsize = "12pt"
	displayfontsize = "32pt"
end if

From the same site code I’m also finding the following gems:

  • MMMMMMacromedia inline JavaScript – onMouseOut="MM_swapImgRestore();MM_displayStatusMsg('');return document.MM_returnValue"
  • Weird indenting due to white-space randomly screwing up the layout.
  • Quite a few of these <br>&nbsp;<br>&nbsp;

Yummy.

* ASP not ASP.NET – .NET didn’t even exist so I refuse to call it ASP Classic.

WordCamp Australia website screenshot

After a long time as a boring old Kubrick blog, the WordCamp Australia site is now flying it’s full colours.

Many thanks to Dan Callaghan for getting the theme finished for us.

Also now available on the site is more information about the actual conference including a speakers list.

If you are in Australia or New Zealand are are looking for a good time in late November, you should give WordCamp Australia 2008 a look.

Photo of my WordCamp 2008 presentation by Sheila Ellen

I’ve just finished my hastily re-factored presentation for WordCamp San Francisco and I promised a few people afterwards that I would make it available online in some form.

The presentation was titled “Hassle-free upgrades for WordPress”. I kind of shoe-horned in a large chunk of my presentation from WordCamp UK on Upgrading WordPress using Subversion into the end. I’ve removed that last part of the presentation in the file here and uploaded the more detailed presentation from WordCamp UK as well.

That’s about as clear as mud…

Here are the presentations converted to PDF.

Hassle-free upgrades for WordPress

Managing a WordPress 2.6 installation with Subversion

Thanks to Sheila Ellen for the photo and for taking it during one of my prettier slides.

WordPress Logo in United Kingdom Coat of Arms

WordCamp UK 2008

WordCamp UK is on Saturday the 19th and Sunday the 20th of July, 2008 and the organisers have made it “over the hump” after some indecision about the venue. They have ended up with a very appropriate venue in Birmingham, enough generous sponsors to secure the event financially and a decent programme too.

You can buy tickets online now.

I’ll be there presenting two topics:

Not sure I’ll need a full hour for either, maybe I can give everyone early marks when I’m done.

I’ll also be on a discussion panel. Attendees should be well sick of me by the end of the conference.

WordPress Logo in United States Great Seal

WordCamp San Francisco 2008

WordCamp San Francisco is on Saturday the 16th of August, 2008. [Update: It’s only one day but contains two tracks]

This is the original WordCamp on it’s third time around, but it will be my first. Should be a hoot. I’ll possibly be presenting one or both of the topics I’m preparing for WordCamp UK.

It’s looking like it will be pretty popular again this year if Upcoming is any indication.

WordPress Logo in United States Coat of Arms

WordCamp Australia 2008

The first WordCamp Australia has just had it’s dates announced. It will be held on Saturday the 6th and Sunday the 7th of December, 2008, somewhere in Sydney.

It’s early days yet, but you can register your interest on Upcoming now.

If you are flying in from out of town it is a good idea to book flights sooner rather than later.

Star Soup

I’ve been sitting on this one for a few years. Mind you, for most of that time I thought I had lost it amongst my many backups and migrations from machine to machine.

This is a Quartz Composer… um… composition that I put together back when Quartz Composer was only new. Today I fired it up under Leopard’s newer shinier Quartz Composer and it still seems to work. I played with it for a minute or two and then added a couple of extra settings for people to play with.

Click “Read More” to see some screen-shots and videos showing what various tweaks to these settings can do.

Read More