Please no more Red Book CDs

The Red Book standard defined how audio was to be encoded on a CD, and it was great for 1980, but it, well, kinda sucks now.

1. The error correction is too minimal to withstand real-world abuse (cars, friends, etc.).
2. Tracking is pretty loose, and a lot of players have trouble seeking to the exact beginning of a track. And, of course, skipping is a drag.
3. Uncompressed PCM isn’t space efficient for audio.
4. Ripping is painfully slow if you want it done well, thanks to the first two.

A better (if not ideal) solution is obvious: compressed files on CD-ROM. The CD-ROM standard has a lot more error correction and tracking data built-in, and the space eaten by that that data is minimal compared to what can be saved through modern compression.

For the audiophiles, start with FLACs, then fill the remaining half of the disc with a few grades of mp3s, or license-free formats. Order the folders by increasing compression ratio so that, when you pop it in a player, you get the highest quality your player will support.

Average direction in SQL

Given a column of polar directions in degrees, this is a single SQL expression to compute their average, for use in a GROUP BY query. Some functions may be MySQL-specific.

IF(DEGREES(ATAN2(
        -AVG(SIN(RADIANS(direction_deg)))
        ,-AVG(COS(RADIANS(direction_deg))))
    ) < 180
    ,DEGREES(ATAN2(
        -AVG(SIN(RADIANS(direction_deg)))
        ,-AVG(COS(RADIANS(direction_deg))))
    ) + 180
    ,DEGREES(ATAN2(
        -AVG(SIN(RADIANS(direction_deg)))
        ,-AVG(COS(RADIANS(direction_deg))))
    ) - 180
)

Thought someone might like to run across this.