Rigidly defined areas of doubt and uncertainty.

Friday, August 04, 2006

It's just a ride

Today's XKCD comic is inspirational:

As I mentioned in my comment on Will's blog, the fact that anything I say or do on the internet can potentially come back to me is always at the back of my mind. I should probably not let that worry me so much and get on with enjoying this moment.

Tuesday, August 01, 2006

Fixing the back button in ajax

I didn't think this was possible, but thanks to Mike Stenhouse's article in the Content With Style blog and the accompanying demo I can now see how to overcome my biggest objection to ajax. The problem, as I mentioned in my last post, is that most ajax sites break the normal user interface conventions of the web by effectively disabling the back button. If you press it on an ajax page such as Google maps you don't undo the last step you made, you exit the application entirely and lose the history of all the clicks since you entered it. I thought this was impossible to fix because to make a new entry in the browser history you need to change the URL of the page, which loads a whole new page for the new URL.

The key insight of Mike's article is that it's possible to change the URL without reloading the page. How? With a page anchor: a link to a particular point in the same page. Changing the URL to point to a different part of the same page doesn't force a page reload, but it does add an entry to the history buffer. By adding '#1', '#2', '#3' etc to the end of the URL you can track every click in an ajax application.

Now, I'm very interested in continuation based web frameworks. The idea was pioneered by Paul Graham, and more recently implemented in Avi Bryant's Seaside framework. Continuation frameworks allow the creation of stateful web applications without using ajax. A continuation is a representation of the state of the whole application at a point in time. When you call a continuation it's like returning to that state. By encoding a reference to a continuation in a URL you can return your application to the state it was in at the time the page was generated. Pressing the back button becomes the equivalent of an undo operation.

My visualisation of a continuation based framework is one where a second dimension of time is added to the URL's first dimension of space. eg http://www.alexfarran.com/#2006-08-01-16:41:53. With ajax now able to track each click I could couple each ajax state to a continuation, and recreate it at any time on any machine. I think that would be cool.

Thursday, July 20, 2006

When ajax attacks

O'Reilly have done something stupid. They've rewritten their Safari online books site as an ajax application, now my back button works only intermittently and the forward button not at all. Plain old HTML is perfect for reading documents online - that's what it's for! Their new ajax based system is harder to use. To regain the usability of the old site they'll have to re-implement the browser history in javascript. And for what benefit? Faster page loads, apparently. Hardly a priority unless you're some kind of demon speed reader.

Really, there are one or two applications where ajax is very useful, but that doesn't mean you have to use it everywhere.

Update: It looks like they've de-ajaxed the chapter select navigation. It doesn't work without javascript turned on, so I think they must be encoding data in the URL that the page then uses to dynamically request it's content from the server.

I mailed O'Reilly support and they told me you can still access the original non-ajax site at http://access.safari.oreilly.com

Monday, June 26, 2006

My wheel

After riding the London to Brighton ride last week my already slightly wobbly rear wheel was looking decidedly out of true. Truing a wheel is in my opinion the trickiest maintenance task you can do with a bike. Every one of the 36 spokes needs it tension minutely adjusted until the wheel is straight and round to millimetre accuracy. It took me a while. I don't have a truing stand, so I used the brakes and a piece of card taped to the frame to as a guide. The procedure is pretty simple:
  • Rotate the wheel to a point where it's to far to the left or right, or a too far in or out.
  • Find the mid point of the imperfection and mark it with a small piece of electrical tape attached to the nearest spoke.
  • Adjust the tension of the surrounding spokes on either or both sides of the wheel.
  • Repeat....
So that's what I did for most of sunday morning Rotate, Mark, Adjust, Rotate, Mark, Adjust. It could have been a frustrating tedious task, but it turned out to be surprisingly rewarding. The simple repetition, the intense focus on tiny adjustments, the slowly improving shape of my rear wheel, and little background music on the CD player just absorbed me. It would be nice if I could make every job feel like that.

Friday, June 16, 2006

HOWTO: Add libtidy support to PHP5 in Ubuntu.

Oddly, the default PHP5 package on Ubuntu doesn't have support for the HTML tidying library, libtidy (bug #41690). I followed the instructions in the Debian APT Howto and the Ubuntu Document Storage Facility and replaced the installed package with one I compiled myself from the source. On the off chance someone else finds it useful I've posted the steps I took here:

Create a directory for compiling the source code in.

$ mkdir source
$ mkdir source/php5
$ cd source/php5/

Get the source code package from the source repository. (Note you don't need root privileges for this step as you're not installing anything, just downloading the source to your personal directory).

$ apt-get source php5

Install the other packages needed by the source code to compile.

$ sudo apt-get build-dep php5

In the downloaded source code there is a file php5-5.1.2/debian/rules. Add --with-tidy to the end of the list of options in COMMON_CONFIG. Now compile the modified source.

$ cd php5-5.1.2
$ dpkg-buildpackage -rfakeroot -uc -b

and install the newly created packages.

$ cd ..
$ sudo dpkg -i *.deb

Apache is automatically restarted as part of the build process, and a quick check with phpinfo() shows the new compile date and lists the tidy module.

When the package manager next downloads the latest version of php5, your changes will be overwritten. So be careful what boxes you tick when it asks you what to update. To get the latest version with your changes added to it repeat the above process. Easy enough for a simple one line change, but for bigger changes you should create a diff file, or manage your version in svn.

Monday, May 15, 2006

Google is my spam filter

My email and hosting provider's (ukfsn.org) spam filter is not particularly effective any more so I've outsourced the task to Google mail. I like Google's mail app, but I don't want to be reliant on it. I don't want to have to abandon my email address or stop using my favourite email client. Fortunately Google have made gmail flexible enough for me to use it completely transparently. I've configured ukfsn to redirect all my email to my gmail address, and gmail to allow my PC to fetch email over the POP3 protocol. Another useful feature is the 'Send mail as:' option in gmail settings. This means I can log on to gmail and still send email from my preferred email address, rather than the gmail address. Useful when I'm away from my PC.

The spam filter is working nicely. No false positives yet. I just need to import all my filters to gmail to seperate out all the mailing list posts, and at some point I might want to figure out how best to upload my email archive.

Thursday, April 13, 2006

Speed learning tool

I've started using supermemo.net to help me learn Ruby. You take notes in a question and answer format, then the software works out how often you should be asked each question based on how well you answer. I find that taking notes in a Q&A format is a good idea in itself because it exercises active recall rather than passive recognition. The repeat frequency calculations should take some of the drudgery out of memorisation by making the exercise more efficient.

Thursday, March 23, 2006

I heart Ruby

I've been working my way through the Pickaxe book, mostly over a nice coffee and panini at Caffé Nero, and I'm really enjoying what I'm finding out about Ruby. It takes the best ideas from more academic languages such as Lisp and Smalltalk and puts them in a practical setting, with a well designed expressive syntax. It gives me a great feeling of liberation to know I that all these wonderful new toys (full OO, continuations, closures, introspection, metaprogramming) are within easy reach. I can see myself devoting a lot of time to Ruby. I'm sure it's a worthwhile investment.

Friday, February 24, 2006

Analysis Paralysis

Yesterday I was thinking myself into a corner about the best way to refactor some code I'd written. The thoughts just went round and round in my head with no hope of conclusion. This can get pretty tiring after a while, so I went for a short walk. While walking, the facts seemed to order themselves and present me with a couple of simple options to choose from. So now I can just get on with implementing them.

I've just finished reading Blink, and that surprised me with some interesting stories about the power of the unconscious mind. Sometimes consciously thinking about something doesn't work as well as leaving your unconscious to get on with it. I think I might do well to heed Ap Dijksterhuis's advice in this New Scientist article 'Sleeping on it' best for complex decisions
“At some point in our evolution, we started to make decisions consciously, and we’re not very good at it. We should learn to let our unconscious handle the complicated things,”