Archive for November, 2004

Reef girls 9

This has to be the best promotion of a brand I've ever seen.

Bums are great. Maggie has a lovely bum.

Summer to remember 0

Things are looking pretty busy this summer. We've got Science Fiction kicking things off this Saturday night, and Carrie's party the night before. We've got Sunshine People, and Summadaze early in the new year. I have tickets for Sci-Fi and Sunshine Peeps, but need to get Summadaze ones.

Plus we have all the usual frivolity with Christmas, New Years Eve and my birthday.

Sci Fi is at Belmont Race Park, Sunshine People is at Mullberry Farm again and Summadaze is in the Supreme Court Gardens. Talk about great locations...

I have added the necessary countdowns to the left of this site; I love the feel of summer in the air!

Suspended! 10

For a little while now I've run Debian on my laptop (as indeed all of us at The Frontier Group do ;) and it's meant that some of the little things that you take for granted with Windows has needed some attention. I don't mean random crashes and lockups, but rather things like software suspend.

ACPI is generally considered experimental under Linux, but APM is fairly well developed. I've been running acpid for power management, including the dynamic throttling of the CPU.

The short version is that I've now removed acpid and run apmd which means that I don't scale the CPU (but I'm on AC all the time, so who cares?) but I do get software suspend which is 100 times more useful.

Also, I needed to "suid" the apm binary (chmod +s /usr/bin/apm) so that I could run apm -s as a normal user. Now I right-click on the battery panel and select "Suspend Computer..." and it halts. Closing the laptop lid and reopening it kicks it out of suspend too, and the power button seemed to cause it to lock up.

The best bit is that everything appears to have worked after the unsuspend. No more 3 minute boot times as I travel between home and the office!

Include directories 7

When we develop large web applications we often have an "include" directory which contains several files, each with their own functions. To include any of these files, we normally have an includes.php which contains something like this:

<?php
    include('includes/one.php');
    include('includes/two.php');
?>

This means that to add a new file, you first have to place it in the includes directory, and then modify the main include file to reference it. Wouldn't it be easier if includes.php automatically read all the files in the includes directory and pulled them in?

Yes.

<?php
$dir = "./includes/";
if (is_dir($dir)) {
   if ($dh = opendir($dir)) {
       while (($file = readdir($dh)) !== false) {
            if ((filetype($dir . $file) == "file") && (preg_match('/php$/', $dir . $file))) {
                $code = "require_once("$dir$file");";
                eval($code);
            }
       }
       closedir($dh);
   }
}

The two interesting bits are the eval() line, which interprets the $code varible as PHP and processes it, and the preg_match() which uses regular expressions to make sure we don't include any files that don't end in ".php". This means that "somefile.php.swp", a vim swap file, won't be included just because it has "php" in its name.

This code will be reused in quite a lot of our development I expect. It's not Earth-shattering, but it's really useful. Hopefully you'll agree.

Subway, again 3

The rumours are true: Subway in East Perth is a 24hr store. It's tucked away on the corner of Plain and Royal streets and is dishing up foot-long-goodness to the max.

I think she confused 1000 Island with mega hot and spicy sauces though. It was amusing driving along Wellington where they're laying the new rail subway, when my destination was Subway.

« Previous PageNext Page »