Daylight Savings Time Misconfigurations between Computers Can Lead to Cumulative Data Errors

Symptom: my web app starting losing a day whenever I edited some data records. This app was working fine for a while, then, in March, it started losing time. Because my time was quantized to days, it looked like I was losing a day every time I saved the record.

The environment was a shared web hosting account, with PHP for the app, and a MySQL database behind it, on a separate machine.

According to a new law, starting in 2007, DST starts three weeks earlier than it has in the past.

I suspected that the problem is that one machine has the old style DST timezones, while the other machine has the new DST settings. So I created a test script to simulate the effect of multiple edits on a record.

Object-Oriented Parser for iCalendar

Been working on a parser for ICS files, and it's done in an OO style - so that parts of the data become instantiated as objects, and the parse tree is a hierarchy of objects.

Freelancers: they Vote but lack Health Insurance

The Freelancers Union says... 56,000 members, 48,000 in NYC. 92% registered to vote, 87% have voted, in high 60%s in local elections. They have a hard time stabilizing their income, and lack health insurance. Freelancer's Union
National Association of the Self Employed

MS Access: Inserting and Deleting Contact Items With VBA

Gripe: VBA syntax is difficult. The object system is a little confusing too. It's just very hard to use. To make things even more difficult, the sample code out there is kind of *weird*. Maybe there's some good reasons for doing things their way, but, it just seems verbose, error prone, and hard to write, to me.

Here's some code that is the start of a library to work with Outlook's folders. It's based on some code samples from the web, refactored into something resembling a library.

MS Access: Printing a "Dictionary Header" on a Report

I wanted to print a report that indicated the first and last item on each page, just like a dictionary has. You know: "Azeri - Babcock", "Milk - Minder". It makes it easier to flip through printouts.

This is how to do it. It will put the range in the footer. I haven't figured out how to do one in the header, which is what I originally wanted, but found too difficult to do. (There is probably a way.)

First, take your report, and add an unbound field to your report. Rename it to "Range". See the picture below.

MS Access: Log Messages to a Table and Know What's Happening When Your User is Stuck

Here's some code to help you log messages to a table. First, make a table called tblLog, with at least these columns: Timestamp, User, Computer, Message. (You don't need a primary key.)

Set the default value of Timestamp to NOW().

Copy the following code into a code module.

Also, add a reference to "Active DS Type something or other".

MS Access: A Hack to Print Blank Rows in a Report

This is a way to insert empty or empty-like rows into a list of "seats" that contains not only reservations, but a number saying how many seats a group of people have. If the number is greater than the number of seats, this adds new blank rows for empty seats.

Sub insertBlankRows()
    Dim dbs As Database, qdf As QueryDef, strSQL As String
    Dim rst As Recordset
    Set dbs = CurrentDb
    strSQL = "SELECT tblSeats.OrganizationId, [MaxOfSeats]-Count([OrganizationId]) AS Difference, " & _

MS Access:Automatically Requery to Update a Combo Box

In MS Access, when you want a form containing a foreign key, you typically use a combo box that's populated with data from the foreign table. The underlying field is the fkey's value, but the combo box displays another column from that table that is easier for people to read. For example:

The Foo table has an fkey, PeopleID, that refers to the tblPeople table.
TblPeople has a field, Name, that is the person's name - a human comprehensible value.
The frmFoo form has a combo box that's bound to the PeopleID fkey.

Watchdog: Restarting WiFi on OpenWRT if the Link Goes Away

I put my WRT54G into a noisy electrical environment, and it seems to cause the wifi to fade out a couple times a week, sometimes permanently. (I did this after using a USB adapter on Windows proved too unstable.)

After some experimentation, this script below seems to do a reasonable job of keeping it up. Save it, and put it into the crontab. (You have to install the crond package.) The gateway is at

#! /bin/sh

# Checks if the wifi conn is up.  If not, it tries to restart
# the wifi.  If that fails, then reboot.

if ping -c 1 > /dev/null

Gentrification Perspective

I was researching gentrification, and came up on a ton of interesting articles, but this one was particularly interesting because it's from someone who identifies with the displaced.

Brown Kingdom

He sites the origin of gentrification in the decline of locally owned business. True enough, I suppose, but even locally owned businesses tend to spawn remotely owned ones, over time, when the second generations of owners move away to fancier areas, and sell out to ever-larger entities.

The blog is good, with a lot of interesting historical information and opinion.

Help Speed Up a MySQL Query by Helping the Optimizer

Here's a noob-to-noob optimization trick. Suppose you have a database table with, say, 200,000 records, and you regularly select on multiple criteria. The rule for selection is to put the most specific WHERE clause first, and the least specific last. The goal is to cut down the search set to something small, and then search through the smaller set. Get all the queries using this order, then create a composite index over the keys to speed up the search even more.

Here are some before and after shots, based on real queries (from sf-active):


Moving Your Linux Root Partition

*[This article is somewhat obsolete because we can use UIDs to identify disks.]*

I had a pretty fast IDE drive, but finally got a much faster SATA drive. I partitioned it with a large /home, and a smaller empty partition. The intention was to load the latest, new version of Ubuntu onto the empty partition on the SATA drive (and mounted as root), and retain the /home partition already on the SATA drive. Unfortunately, Ubuntu's installer would not install onto the empty partition without formatting both partitions. The installer will upgrade a system in-place; it'll reformat a new system; but it won't install into an empty partition, leaving the other partitions intact.

Participate: Social Networking Software

This is a social network that was written back around 2004. My friends were doing a distributed anti-war protest. It was basically not that well attended, because people weren't really aware that the President was a liar, and that he would eventually suspend habeas corpus. On top of that, it was in competition with another demo, and that really killed it. The software did so-so, but it got taken down after the demos, because I got paranoid about the cops subpoenaing the entire database.

Also, the software was kind of hard to use. A lot of features were basically implicit, and you had to be pretty savvy to "get" it. Still, a lot of Friendster features were ripped off, and a couple features, like the double-blind email-based contact system were cool.

Cleanup Your HTML: A Tag Closing Function

User-submitted HTML often contains small markup errors that can affect other parts of the page. The most common are unclosed tags that cause text to be bolded, italicized, or linked all the way down the page. The visual effect is catastrophic, though the error is really minor.

The html_close_tags() function scans HTML code, and generates a string that will close all the open tags. An easy way to use it is like this:

  $html = $html.html_close_tags($html);
Syndicate content