Category Things I’ve Learned

Removing Accents in Strings

I’ve been ripping and encoding a bunch of music. Since I’m a hacker, naturally I have scripts that take a file with artist, album title, and track titles, and finds the corresponding .wav or .aiff source files, encodes them as MP3 and tags them.

A lot of the music I have is in French or German (and some Spanish and Russian), so there are accented letters in names and titles. My input files are in UTF-8 format, so that’s cool. But one problem is that of generating a filename for the MP3 files: if I want to play the song “Diogène série 87” by H.F. Thiéfaine on his album “Météo für nada”, I don’t want to have to figure out how to type those accents in the file and directory names. I want the script to pick filenames that use only ASCII characters.

Read More

How Do You Spell the Names of the Months?

One construct that I’ve seen (and used) a lot in Perl is a hash that maps month abbreviations to numeric values that can be fed to POSIX::strftime:

our %months = (
    "jan" => 0, "feb" => 1, "mar" => 3, ...
);

This is useful for parsing log files and such. It works, it’s quick and easy, and it doesn’t require a whole tree of dependent modules (which are always on the wrong side of the Internet) to be installed.

But what’s always bugged me is that this is the sort of thing that the machine ought to know already. And besides, it’s US-centric: what if the person running the script is in a non-English-speaking country?

Fortunately, I18N::Langinfo knows the names of the months. Read More

iTunes Podcast Problem Solved

I’d been having an annoying problem in iTunes 7.0.2: although I’d set the podcast preferences to “Keep: Last 5 episodes”, it was still keeping old episodes around, long after they should have been deleted.

After rooting around in Apple’s discussion fora, the solution turned out to be:

  1. Select “Podcasts” in the left bar
  2. Select everything with Apple-A
  3. Right-click (or Ctrl-click, for a one-button mouse) on the mass of selected episodes, and select “Allow Auto Delete”

When I next updated the podcasts, it deleted the old episodes, just as it should have. Presumably some podcasts or episodes got marked as “Do Not Auto Delete” somehow, perhaps when I upgraded iTunes, or moved stuff from the old Mac.

The annoying part is that there’s no indication in iTunes that Auto Delete has been disabled. That seems like just the sort of UI thing that Apple would have added, given that there are a zillion other status indicators.

Update, Dec. 2, 2006: Apparently when you click the “Get” button to manually download a podcast episode, it is automatically (and invisibly) marked as “do no auto delete”.

Typically this happens to me when I subscribe to a new podcast: iTunes downloads the latest episode automatically, but I normally download several more, in case I like it. Those episodes don’t get deleted automatically.

Kohlberg’s Moral Stages

I just ran across a reference to Lawrence Kohlberg’s stages of moral development, and was immediately intrigued enough to spend my attention span learning just enough to mistakenly be sure that I know something about the subject.

Read More

Word O’ the Day

The first definition the OED gives of scumbag is “condom”, from “scum” meaning “foam” or “froth”, and by extension “semen”. This usage dates back to 1967. “Scumbag” as an insult shows up in 1971.

Word O’ the Day

Ultracrepidarianism:
Giving opinions on matters outside of one’s knowledge.

(HT Pinky and the Brain on DVD; checked at the OED.)

Ajax == Emacs: the Next Generation

I’ve started learning this

thing. which allows you to do cool things like
Google Maps
and the
U Wisconsin directory search.

Read More

Fun With CSS: Large Capitals

One thing I’ve always liked about books is the way typesetters sometimes render the first letter differently from the others, usually several times larger, and with the paragraph flowing around it. Sometimes, the first line or the first few words of the first paragraph are also rendered in small caps. I’ve finally figured out how to do this with CSS:

/weblog/files/css-capitals.html

Read More