To Do List

Remember the Milk is todo list software, much better than tadalist and all the other products I’ve looked at.

Some of the great features: free (as in beer), amazing usability, unlimited lists/reminders/entries, email/SMS/instant messenger reminders, atom feeds, keyboard shortcuts for everything, submit tasks via email, support for recurring tasks and tasks with a specific time (appointments) and many other features besides.

Tomcat 4.1 and Apache 2 on Ubuntu Linux

Short Version.

  • Install java (JDK not JRE). (Download binary from java.sun.com, add executable permission, run, move resulting directory to /usr/local or similar.)
  • Install apache2.
  • Get Tomcat binary from tomcat.apache.org and extract to /usr/local/
  • Set an environment variable CATALINA_HOME to the path of the directory into which you have installed Tomcat 4.0. And another JAVA_HOME to the path of the directory into which you have installed Java.
  • Execute the shell command: $CATALINA_HOME/bin/startup.sh
  • Check Tomcat works on port 8080
  • Install jk2 connector (sudo apt-get libapache2-mod-jk2)
  • Copy /usr/share/doc/libapache2-mod-jk2/examples/workers2.properties.minimal to /etc/apache2/workers2.properties adding in your own config
  • Uncomment line in /etc/apache2/mods-available/jk2.conf
  • Place your Tomcat-related code in CATALINA_HOME/webapps/ROOT or other appropriate directory. Restart everything.

Internet Commandline

yubnub.org is a commandline for the web. Better than that, it’s collaborative. This means you don’t need to create the command to subscribe to a feed at bloglines, it’s already been done (it’s called blub).

It’s like one shell shared by thousands so that every contribution can build on all the others. Like so much on the web it’s messy and somewhat fragile but it’s brilliant nonetheless. Check it out.

Accessing X Clipboard with Vim

You can access the X clipboard in Vim by using the ‘+’ buffer.

So to paste from your system clipboard into Vim use:

"+p

And to copy the current line to system clipboard use:

"+Y

On Ubuntu 5.10 (“Breezy Badger”) this only works (in both vim and gvim) once you have installed gvim:

sudo apt-get install gnome-vim

169.254.0.0 Address Causes Confusion

I got a very intriguing email yesterday. It read:

Mr Baker,

I wonder if you can throw any light on the fact that my virus killer has warned me that there is a new internet connection on my router.

The IP address is 169.254.0.0

As you are a computer programmer I would like you to explain to me how you came to get a web address through my router when it is securely firewalled and why you would wish to do so?.

On selecting the address I was sent to the Bluebones.net website.

Your IP address should not be anywher near my computer system and I wish to know from you why it is before making any further judgements or decisions on what to do about it. I should be glad if you would proffer an explanation as urgent.

For a moment I thought I must have some horrible virus that was using my machine to go out and infect others. Then I thought about it for a minute and I realised what must have happened.

169.254.0.0 is not a valid IP address. It is part of a block reserved by IANA for showing errors in getting DHCP addresses.

So the browser of my “victim” must have tried to visit 169.254.0.0, failed to find a machine on that address and automatically taken him to the top search result for “169.254.0.0” which must have just happened to be my post, ‘Network Client Assigned 169.154 Address

Mystery solved. Probably.

Use SCRIPT_NAME not PATH_INFO in PHP

You should use

$_SERVER['SCRIPT_NAME']

not

$_SERVER['PATH_INFO']

in PHP. PATH_INFO has been monkeyed with in some versions (and when running as FastCGI?) so sometimes it appears as PATH_INFO and other times as ORIG_PATH_INFO and PATH_INFO does not exist in the $_SERVER array. SCRIPT_NAME seems to have had a far less chequered history. Sometimes I think there could be a new beautiful version of PHP without little gotchas like this, but then that wouldn’t really be PHP would it?

International Marketing Calls

“Hello, may I speak with the person there with responsibility for the telephone?”

Hang on, aren’t I registered with the wonderful Telephone Preference Service making any cold callers liable to a £20,000 fine? Yes, I am but this man does not sound English and this is a terribly odd sounding line if it is coming from inside the UK. Oh dear, I think I’ve just come face to face with a new phenomenon.

I guess voice-over-ip (internet telephone calls) means that it is now possible for companies not based in the UK to start cold calling into the UK. So now we need an international agreement on spam telephone calls?

All Possible Subsets

All possible subsets of a set is called a “powerset”. So, for the set { 1, 2, 3 } the powerset is:

{}, { 1 }, { 2 }, { 3 }, { 1, 2 }, { 1, 3 }, { 2, 3 } and { 1, 2, 3 }

One way to generate this set of sets is with the following recursive algorithm:

If S isn't empty: 
    pick the first element and call it "head" 
    call the rest of S "tail" 
    for each element e of the powerset of tail: 
        one element of the powerset of S is e 
        another is e plus head

Some code to generate this in PHP (apart from the empty set) is:

function powerset($stack, $set) {
    if (! $set) {
        return array();
    }
    $new_stack = $stack;
    $tail = $set;
    $head = array_shift($tail);
    $powerset_of_tail = powerset($new_stack, $tail);
    foreach ($powerset_of_tail as $e) {
        array_push($new_stack, $e);
        array_push($new_stack, array_merge($e, array($head)));
    }
    array_push($new_stack, array($head));
    return $new_stack;
}

We can add in the empty set and wrap the recursive code in a convenience function:

function get_powerset($set) {
    $powerset = powerset(array(), $set);
    array_push($powerset, array());
    return $powerset;
}

$set = array(1, 2, 3);
$powerset = get_powerset($set);