At: ashok.org.uk/tags/code

Tags

Code

4 posts tagged with:

Code
Snippets of actual code that might be useful to geeks.

Cascading Test Sheets

Testing Web pages is a pretty complex task. Very often we settle for too little, checking little more than:

  • that our markup validates against the spec
  • that a simple link-checker doesn't find dead links
  • & that some monkey-testing doesn't turn up any glaring errors

Those are good checks to make, but we need to do a lot better.

I want to make some declarative statements about what is expected of different pages, and have them run routinely. For complicated pages, that depend on user-supplied, database-held or offsite data, I'd like to run the tests on any pages I might ever ship, and give the administrators a decent stab at recreating the error and damn-well fixing it.

Thankfully, the CSS people have done a fine job of allowing you to pick out parts of an HTML document and then apply styles to them. Better yet, we've just about reached the point where smart designers can express what they want in CSS, without needing to write anything terribly complicated.

This is a little idea for how to do that. There's no implementation yet, but I'm looking for feedback on doing it this way. The basic idea is to express some useful, human-level tests in a CSS-like language that make sense to more than code-nerds, and use them to test individual Web pages, or entire sites, and be more confident that they do all that you expect, and nothing that you don't.

Update at 11:03 EDT, 8th April 2009 – Minor tweak to the examples.

Tagged: Technology, Code, Web

Posted at 10:48 EDT, 8th April 2009.

No comments.

Wikipedia from the command line

Here's a little script I wrote a while back to quickly pull up a browser at a particular page on Wikipedia.

It's similar to the one I use for Googling from the command-line, but for Wikipedia (or any site that runs on MediaWiki).

Get the script.

Tagged: Code

Posted at 15:05 EDT, 21st March 2009.

No comments.

SFV Check script

Here's a handy little script for checking Simple File Verification (SFV) files. These are commonly used when distributing files over Usenet, where a large file is sliced into many parts and posted separately. It is just a list of checksums of the smaller parts of the file, so doesn't guard against evil-doers, just random errors.

I used to use a GUI program on the Mac, but it started misbehaving and I'm much happier at the command line.

Tagged: Tips, Code

Posted at 07:51 EDT, 26th March 2008.

1 comment.

Command-line Google script

The Mac has a lovely command, open, which you can point at a file or URL and it will do the Right Thing.

Here's a little script that lets you Google from the command line. You can also use it with Gnome by calling gnome-open instead of open at the end of the script.

Tagged: Code

Posted at 06:24 EST, 11th December 2007.

No comments.