Software/PHP Scripts
The important bit
These packages are provided as-is and with no implicit or express warranty of any kind. I make no guarantees that these are up-to-date, secure, or even functioning. I don't have the time to offer support for anything you download here. If you don't know what you're doing in PHP, you probably shouldn't be using the code libraries. Have a look at PEAR instead.
Most of these are bits of program I've written for convenience at the office, and decided to release to the public in the hope that some of you will spot holes and help me fill them in. Use my code for good, and not evil. Remember where you got it from, and if using it helps you out, then make me happy and let me know (anything at lazycat.org will get to me eventually).
Python iTunes library and favourite albums tool
A python library to parse the iTunes library XML file. The script that it comes with is one I wrote to list my top albums for the Library section of this website. It only works because I've rated all my music, so your mileage will vary enormously. It's written for python 2.3, and iTunes 4.7, but I've since tested it with python 2.4 and iTunes 6, so it seems to be coping with the mad future of robots, jet-packs and food pills quite nicely. It's a bit slow, and doesn't really tell you anything you don't already know, but I'm perversely proud of it. If you improve the code in any way, do let me know.
Thanks to Adam Twardoch for spotting a minor bug.
Download the python iTunes library and best-albums tool
Fading javascript ticker
I couldn't find a decent script out there that did the whole Web 2.0 'unobtrusive javascript' thing, or that degraded gracefully (in that you'd still get the information in the ticker on unsupported browser setups). Most of the ones I've seen use javascript arrays to build the ticker, which just smells funny to me. This one takes an unordered list of links (you know, <ul>…</ul>) in any div with the class tuiticker and converts it into a fading ticker thing. It doesn't actually fade, due to IE's inability to cope with opacity in a normal way, but it tries to be clever and fade to the background colour of the div it's in. Anyway, it's free and seems to work in Safari, Firefox, and IE, at least for the moment, which is some kind of technological feat in itself. Take it, have a play, change it to do what you want. Don't blame me if it eats your favourite pet.
TuiTicker demo and download page.
PHP WURFL class
Here's a simple, slimline alternative to the official library. I don't know why I don't like the official one; maybe it's just old programmer's hubris kicking in. For those not in the know, WURFL is an open-source directory of mobile phones and their internet capabilities - whether they can do WAP or HTML, in other words, and a whole lot more information besides. The official class is excellent, and very fast, and does more than this version. It's written for PHP 4, but works in version 5 too, and allows you to use patch files and stuff. My version is more compact, and has no bells or whistles, so it's a little bit faster for most simple cases. It also builds an index more quickly, and caches on demand, rather than pre-emptively, so the first time a particular phone connects, it's a bit slower, but not much. The index works on file offsets, and then stores the processed XML in a serialised form, which is a little faster than the official version, which works by generating PHP code (which always makes me cringe on a philosophical level). It also offers an overloaded interface, which means that instead of doing $phone->get('resolution_width'), you can do $phone->resolution_width(), which I find more relaxing, but which (again), might break one day. Use at your own risk. Keep in mind that you'll need to generate the index before it'll work, and recreate it after updating the XML file - there's methods for that in the class. Don't forget to clear the cache too, since the file-offsets will be wrong!
The latest version now has a search method, which tries inexact matches on the user agent - much better at finding phones that have had minor firmware upgrades. Search is the default action on the constructor now, not lookup.
Download TuiWurfl source code. Documentation one day, but not today.
Lazycat Notes
I got thinking about notepads around about the time I finished my fifth or sixth reporter's pad at the office. I use them compulsively, even though I'm sitting in front of a computer all day because it's simply more convenient. But using paper is bad for trees, apparently, and finding old stuff is a pain in the arse. What if I could make an electronic notepad that's as convenient as its paper equivalent, but with enough extra features to make it worth switching? Lazycat Notes is my attempt to do just that.
It's web-based, so you can access it from anywhere. You click, type, hit enter and it's stored. You can also type or click flags to group your notes and make them easier to search. So far, so standard. The clever bits are searching and date-recognition. Type a date and Lazycat Notes will understand it. Write “Bob's birthday is on Monday”, and it'll know which Monday you mean and will store it as a whole date. The advanced search lets you build and save a search as a bookmark, an RSS feed, or an ICS calendar (for iCal or Outlook), so you can find “All birthdays in the next two weeks” or “To-do items that mention this month”.
I wrote it for my personal use, and a couple of other friends have accounts on my version, so the version you can download doesn't have fancy setup tools, or web-based administration. There are a couple of command-line tools for adding users, etc. Your mileage will vary. I'm giving it away because I find it useful and at least a little cool to use. Let me know if you improve it.
You'll need PHP 4 or 5 and mySQL 4. Since this uses PEAR DB, there's a small chance that you can use a different database, but that wasn't a design goal.
Download Lazycat Notes, or see it online
comiCollect 1.5
I read far too many webcomics for my own good, so I wrote comiCollect to put them all on one page for me, and to keep them for a couple of weeks so I don't miss anything when I go on holiday. comiCollect also generates RSS feeds for your favourite comics, so you can view them in your favourite newsreader. I did write it for myself about five years ago, so it's a long way from the best code I've written (in fact it's a long way from being good code at all), but it works okay and it's never given me any problems. All its output has been validated as standards compliant, which is nice - proper, nice RSS 2.0, tidy HTML, and clean CSS.
If you want it to update regularly, the easiest way is to set up a "cron" job to run the collection script at regular intervals (like once or twice a day), but if your web host doesn't give you access to that kind of thing, you can also run it from the web with a secret key. Have a look in collect.php for details on how to do that (and do do that if you're exposing collect.php to the net).
You also need the PHP cURL extension installed, though in my experience most web hosts that provide PHP will provide the cURL extension too (if not, then here's an older version that uses the PEAR HTTP_Request library instead). On the up-side, it doesn't need a database, it runs in PHP safe mode, and it cleans up after itself, so it should never get too big. Please only install this for personal use - support your webcomic authors.
PHP5 Simple Logging
Really simple and lightweight, in fact. Either TLog::getInstance()->Log("Did something here",TLog::DEBUG); or $l = TLog::getInstance(); then $l->Log("Did something here",TLog::DEBUG); wherever necessary. It tries to strip useless crud from the file path, and also tries to use the PHP debug_backtrace command to get the line number, filename and function/method that you're logging from. That said it tries to be fast, not clever, so either of those might break. Change the constant at the top of the file to control what does and doesn't get logged (that way you can put in as many calls to Log() as you like, but it'll only keep the inane debug ones when you're looking for a problem).
NOTE: For it to work right out of the box, put it into the includes/ or classes/ folder of your project, and make a log/ folder one folder up from tlog.php. The alternative is to edit the class and set the paths yourself. I use it during development of classes, and then raise the log threshold to warnings and errors only for production; it's probably too much hassle to use it in other contexts. Remember to trim/rotate your log files every now and then, because this doesn't care about disk-space.
PHP4 Simple Logging
As above, but kludged to work in PHP4. Because PHP 4's object model is so crappy, you need to be careful to use references whenever you
fetch the log object. That is:
$l =& TLog::getInstance(); with an emphasis on the &ersand. The other difference is that PHP 4 doesn't support class constants, so instead of TLog::DEBUG, you need to use TLOG_DEBUG. Other than that it's the same. You'll need a recent version of PHP 4 for this to work because of the backtrace code. A reminder - never log user input without cleaning it first.
ASP Atom Feed Parser
A modification of Francesco Passantino's example ASP Atom Feed Parser, this version produces well-formed HTML, is in the form of a VBScript function rather than a subroutine, and is a little more flexible (but not much). Credit to Francesco for writing it in the first place. Keep an eye on his site, since it's unlikely that I'll modify this ever again.
Add stripes and highlights to tables
We use this on our internal contacts database; just include it in a web page's <head> section, and it'll add styles to certain HTML tables to colour alternate rows, and highlight the row your mouse is hovering over, without messing up your HTML. It's a peculiar hybrid of two javascripts, neither of which are mine, so all credit to them. An example can be found at the bottom of the file.