I'm cross-posting this (with permission) from another corner of the internet. ALL CREDIT FOR THE WORK INVOLVED GOES TO  @_R_