Simon Willison’s Weblog

Subscribe

March 2003

March 18, 2003

PHP and Javascript spell checker

Last week I commented that Sam Ruby’s spell checking feature could be made even funkier with the addition of a javascript powered “corrections” menu. I spent a few hours this afternoon playing with the idea, and I’ve now got quite a nice proof of concept:

[... 186 words]

Great new bookmarklets

Via Zeldman, Ian Lloyd (who has recently re-launched his personal blog) has released a pair of invaluable bookmarklets for dissecting the structure of properly marked up pages: Show and label divs with ids and Show and label divs with classes. Combine with Liorean’s ViewStyles and ViewScripts for best effect.

mod_psp

Sterling Hughes (recently blogrolled) has been working on mod_psp, a Python Server Pages module for Apache. He’s up to version 0.2.1 already. Stuart once told me that the toughest problem when embedding Python code in HTML is figuring out how to deal with indentation blocks—PSP appears to handle this by letting the indentation “leak” in to the HTML, which seems a bit of an ugly workaround. Still, if the module ends up being any where near as straight forward to install and use as PHP it could become a very useful tool.

Haunted by old hacks

Paul Hammond is seeking the perfect way of marking up code snippets. He examines several methods, including this interesting specimen:

[... 122 words]

March 19, 2003

Javascript prototypes

Andrew Hayward (a friend from Uni who has recently started blogging) has been playing with javascript’s prototypes. prototype is a value related to a particular class from which all instances of that class are created—only in javascript classes are actually functions... and then it all gets really complicated.

[... 146 words]

Dithered DOM scripts

Dithered.com’s DOM Scripts follow an interesting philosophy:

[... 131 words]

Useful python resources

A bunch of useful Python resources:

[... 68 words]

March 21, 2003

Some PHP notes

I ran an intermediate to advanced PHP session at University today, on behalf of BCSS. The turn out wasn’t particularly impressive, probably because the only lecture today had been cancelled so there were a lot fewer people from our course on campus than I had expected (the session was arranged because a piece of group coursework we are working on at the moment uses PHP). The notes I put together from the course are available online. They were put together in a bit of a hurry, so please tell me if you spot any mistakes. Topics covered include sessions and cookies, classes and objects, references and some brief notes on writing secure code.

Conference woes

Like Stuart, I’m severely tempted by the UK Python conference—as a student it would cost me £85 to go for the first day, not including train fairs. That’s a lot of money (considering I currently have none) for 4 sessions and the opportunity of a BOF meeting, but it’s quite rare for the UK to host a conference on something I’m heavily interested in (I’m yet to go to one). These tips on getting the most out of a conference would certainly come in handy.

[... 129 words]

coWiki uses PHP5

coWiki is the first open source project I have seen being developed with PHP 5, using snapshots from CVS. It looks like a really neat wiki system. Of particular interest for PHP heads is the development log on the front page (sorry, no permalinks) which provides some insight in to the progress of PHP 5’s development.

March 23, 2003

PHP5 info from Sterling Hughes

Sterling Hughes has posted the slides he will be using for his presentation on PHP 5 next week. They provide a great deal of insight in to the new additions to look forward to in PHP 5, including a few I hadn’t heard about before.

[... 209 words]

UltraEdit regular expressions

Every now and then I find myself needing to use a regular expression in UltraEdit, and whenever I do I invariably have to spend five minutes re-reading that section of the manual to remind myself how its syntax differs from more traditional regular expressions. This time, I’m recording the result in the hope that it might jog my memory next time I need to use them.

[... 104 words]

March 24, 2003

Smart scripted URLs

Dan Kalowsky is realising the importance of using a smart scripting technique to generate “nice” URLs:

[... 62 words]

The goodness of binary search

Tim Bray provides an in depth, practical explanation of the binary search algorithm with example code in Java. Great revision material for second year computer scientists like myself.

A PHP Installer

Wez Furlong is working on a generic PHP installation script. If he finds a nice solution to the safe_mode and open_basedir restrictions mentioned in his post this could be a hugely useful tool for the PHP community.

Useful mySQL articles

Paul DuBois, the author of the huge great MySQL Book I have sat on my bookshelf, has a whole bunch of useful MySQL articles published on his site.

March 25, 2003

getElementsByClassName()

More handy javascript from Andy: document.getElementsByClassName.

Freshly Blogrolled

Recent additions to the blogroll:

Date-centric vs Entry-centric

When I started this blog, I made the decision to use days rather than entries as the principle navigation unit of the site. Each day’s entries are grouped under a single heading for that day, archives are arranged by day (with permalinks linking to anchors on those pages) and individual entries come without titles, to emphasise the fact that they are part of a larger whole.

[... 602 words]

getElementsBySelector()

Inspired by Andy, I decided to have a crack at something I’ve been thinking about trying for a long time. document.getElementsBySelector is a javascript function which takes a standard CSS style selector and returns an array of elements objects from the document that match that selector. For example:

[... 172 words]

March 27, 2003

Retrieving all DOM descendants

First observation of the day: IE 5 for Windows doesn’t understand element.getElementsByTagName('*') to retrieve all descendants of an element in the DOM. element.all has the desired effect for that browser. So to retrieve all descendants in a way that will work on standards compliant browsers plus IE 5, the following seems to be the best bet:

[... 71 words]

Attribute selectors now supported

I’ve updated document.getElementsBySelector to support CSS2 and CSS3 attribute selectors, as described here. Attribute selectors allow you to match elements based on any attribute using a variety or different rules including begins-with, ends-with, contains and more. The new version is tested in Mozilla, Phoenix and IE5/Windows (and I’m almost certain it works in IE6). There is a slight bug in Opera 7 preventing the ends-with selector from working which I have been unable to track down—any Opera javascript experts out there?

[... 172 words]

Why XML doesn’t suck

Tim Bray: Why XML Doesn’t Suck (a follow up to XML Is Too Hard For Programmers). I’d quote the best bits but there are just too many—this article clears up all of the loose ends in my understanding of why XML is such an important technology.

March 29, 2003

Sergey Brin interviewed

Jeremy Allaire has posted notes on an interview with Sergey Brin of Google, conducted at the PC Forum conference. Some highlights:

[... 240 words]

Programming concepts

Two interesting reads relating to the Programming Languages course I’m taking at University:

[... 104 words]

Time traveller busted for insider trading

“Time-Traveller” Busted for Insider Trading (via Tony Bowden). This just has to be some kind of early April fools.

[... 242 words]

Ruler bookmarklet

This Ruler bookmarklet is really cool—it shows the current coordinates of the cursor within the browser window and allows you to draw boxes and see how large they are in pixels—invaluable for tweaking CSS layouts.

SmartPHP.net

SmartPHP.net has some useful looking classes, including SmartTemplate (like Smarty but much simpler to use) and SmartCache, a very intelligent caching class that can be used to cache data objects as well as the output from whole pages. The example given caches a database query using the SQL statement as a unique cache key:

[... 108 words]

Usability myths

UIE debunk three usability “myths” (the three click rule, the idea that users give up on slow loading web sites, and the “5 to 8 test subjects should post most usability problems” idea). 37Signals do a pretty good job of debunking the debunkers.

Smarter CSS positioning

Daniel Glazman’s proposal for smarter positioning in CSS (see also this blog entry) makes a lot of sense.

2003 » March

MTWTFSS
     12
3456789
10111213141516
17181920212223
24252627282930
31