Floating upstream and downstream

I had a lot of fun recording the Revolver episode of Inquisitive that Myke Hurley released earlier this week.

Revolver

I even enjoyed listening to it, except for a few goofy misstatements I made along the way:

  1. The Beatles went to Rishikesh to visit the Maharishi, not the Maharaja. I will say, though, that they would have been better off if they’d made a pilgrimage to study at the feet of Oscar Peterson. I’m sure they’d’ve gotten more out of it than Dick Cavett did.

  2. The George song I expect to hear coming out of “Eleanor Rigby” is “Love You To,” not “For No One.” I have no idea what made me give the name of a Paul song, but at least it was a Paul song on this album. Chances are, I also called George’s song “Love To You” at least once because that’s what the lyrics are. That mistake is not age-related; I’ve been saying “Love To You” instead of “Love You To” since I was a teenager.

  3. The artist who make Revolver’s cover is, of course, Klaus Voorman, not John Voorman. I did at least have the grace to call him Klaus every time other than when I first mentioned him. Although I said that Klaus was a friend of the Beatles from their Hamburg days, I forgot to say that he was also a friend of Astrid Kirchherr, whose photographs of the boys are so well known (including the cover of John’s Rock ’n’ Roll album) and who gave the boys their first Beatle haircuts.
  4. Not actually a misstatement, but as I was trying to remember the names of Donovan songs, I completely forgot “Mellow Yellow,” which probably wouldn’t have meant anything to Myke anyway. If he, or anyone in the UK, wants to bone up on the Scottish psychedelic folk singer, there’s a tour coming up in October and early November. Special VIP tickets, including lunch with Donovan, are only £2,500. Quite rightly.

One last thing: Myke and I talked a little after the show about the Yesterday and Today album, which is where the three John songs that were cut from the American release of Revolver ended up. He didn’t know anything about that album, so I told him to Google “Beatles butcher cover.” The sounds of disgust that came over Skype were delightful.


Two problems

As I read Jason Snell’s commentary on my Patterns post, I realized that no one—not on Twitter, not in email—had sent me Jamie Zawinski’s famous saying about regular expressions:

Some people, when confronted with a problem, think “I know, I’ll use regular expressions.” Now they have two problems.

Zawinski was making tweet-sized aphorisms long before Twitter.

Jeffrey Friedl, he of the definitive book on regular expressions, wrote a much-updated post on the origin of this saying and its antecedents. I recommend it if you have any interest in regexes, programming, or Unix. The comments are nearly as fun as the post itself.

Literal-minded people take Zawinski’s gibe too seriously and either parrot it as great wisdom or get into long arguments on how it’s wrong. I agree with Friedl and Jeff Atwood that Zawinski’s real target was not regexes themselves, but their overuse, which he saw as a bad programming practice encouraged by Perl. It may be hard to believe now, but back in the 90s, Perl was being used everywhere. In his post, Friedl includes this other Zawinski quote:

The heavy use of regexps in Perl is due to them being far and away the most obvious hammer in the box.

This strikes me as exactly right and not hyperbolic in the least. When I switched from Perl to Python, the hardest thing to get used to was Python’s more verbose way of handling regexes. Regular expressions are so easy to use in Perl, and so intimately woven into the language, that I had gotten into the habit of using them everywhere. It wasn’t until I had been programming for a while in Python, where I preferred not to import re unless necessary, that I realized how much I had been overusing regexes. Judicious slicing combined with literal string searches and splits commonly work just as well as regexes on simple input, and proper parsing into data structures is almost always the better choice for highly organized data formats.

Even so, regexes are so often exactly what’s needed that I’m glad I have Patterns in my toolbox.


Bring out your dead

Speaking of toxic hellstew, I gave Apple’s Podcasts app another try. I lasted nearly 24 hours.

Podcasts app icon

While I admit it was a foolish thing to do, I had my reasons, which have to do with listening to podcasts as I ride my bike to work. I don’t like riding while listening to my iPhone. Even back when I had a nice armband for it, I felt uncomfortable using it. Part of it was how the iPhone would shift around during my ride, part of it was the impossibility of controlling playback through a touchscreen while on the move, part of it was the annoyance of moving the phone into and out of its pouch, and part of it was my fear of damaging the phone during even the lightest and spottiest rain. After my wife borrowed the armband on a permanent basis, I rode with the phone in a pocket of my bike shorts, and that was even worse. The earbud cords would occasionally catch on flap of material as I was riding and pull the buds out of my ears.

So I decided to return to using my old 5th generation iPod nano. That meant resubscribing to podcasts in iTunes and syncing the iPod via cable, Not a big deal, but because I still intend to listen through the iPhone, I thought it would be better to switch away from Overcast and use the Apple’s Podcasts app to take advantage of its integration with iTunes.

This shows how out of touch I am with the current state of the software I have hidden away in the “Apple Junk” folder on my last home page. (You know that folder; I bet you have one, too.)

Apple Junk folder

Anyway, my ignorance was such that I didn’t realize the integration between Podcasts and iTunes was effectively zero. Oh sure, when you plug your iPhone into your Mac, you can sync the podcasts in iTunes with those in Podcasts, but they don’t stay in sync over the air the way Contacts and Calendars do. At first I thought there was some iCloud setting that I’d forgotten to turn on, but no. Both Podcasts and iTunes will use their internet connections to download episodes but there’s no coordination between the two.

So the one feature that Podcasts could have that would set it apart from third-party podcatchers, the integration of devices and services that Apple touts as its great differentiator, isn’t present. It’s not that it’s poorly implemented, like some other Apple audio service I could mention, it’s not implemented at all.

Which is kind of a relief, because after listening to one and a half podcasts through the Podcasts app, I knew it’d drive me crazy. The overall interface is fine, and the sleep timer is actually quite well done compared to other podcast apps. But it’s missing one feature I find essential when I’m listening in my car: the ability to skip forward and backward within a podcast by turning the Tune knob on the dashboard. This knob works like double- or triple-clicking the center control on a set of earbuds, and most podcast apps have a setting to switch those functions from “next track” and “previous track” to “skip forward X seconds” and “skip back Y seconds.” This is essential when you need to repeat that jumble of noise when everyone was talking at once on The Incomparable. Or, more commonly, when you’re not in the mood to hear again the story of how the guys from Harry’s bought that razor blade factory in Germany.

So I deleted everything from Podcasts and returned to Overcast. Podcasts didn’t even get out of the Apple Junk folder.

But let’s end on a positive note. My 5th generation nano, six years old, worked perfectly with iTunes 12 and is now set up to be my biking iPod. In fact, even my 2nd generation nano, which I grabbed by mistake and plugged into my Mac before I realized it was the wrong one, synced up fine. Its select button is kind of wonky—that’s partly why I got the 5th gen—but otherwise it runs just fine. And it’s nine years old. The only hitch in syncing them was that iTunes didn’t recognize either nano immediately because their batteries were dead dead dead. Once they got a little juice in them, everything went fine.

On the current episode of Upgrade, Jason Snell told how he revitalized an old classic iPod by installing an internal SD card reader to replace the hard drive. Myke Hurley said it was magical how iTunes just updated the iPod’s system software and synced all of Jason’s music to it when the iPod was plugged in. It is magical, but it isn’t surprising. The code that does it was written back when Apple occupied the functional high ground.

Update 7/28/15 11:40 PM
Well, fuck me. Via Twitter, Kyle Seth Gray points me to this Apple support page that explains how to get the syncing I just said doesn’t exist. I had actually done what’s necessary on the iPhone side,

Podcasts sync setting

but I didn’t have it worked out on the Mac. I was sure the setting would be in the iCloud part of Settings, but it’s actually in the Store pane of the iTunes preferences.

iTunes Store preferences

Why the hell would a sync setting be there? Now I have to decide whether syncing is worth the loss of skip forward and skip back.


Patterns again

It’s been a while since I mentioned Patterns, the $3 Mac application that lets you test and tune your regular expressions.

Patterns example

The best thing about Patterns is that it puts your regex testing outside the rest of your program, so you know that any errors are coming from the regex itself, not any other misbehaving part of your code. You can, in theory, do the same thing by writing a little skeleton program that tests your regex, but if you’re anything like me, you don’t have the patience for that. Three bucks is a small price to pay for prebuilt testing environment.

One thing you should know before using Patterns: No matter which language is chosen in the dropdown menu up near the top right corner, Patterns always uses Perl-style references for captured groups in the replacement section, e.g., $1 for the first parenthesized group, $2 for the second, etc. So even if you’re writing in Python, as I usually am, you can’t use Python’s syntax, which uses backslashes instead dollar signs. This is less annoying than you might think—so many languages and utilities use dollar signs, I’m used to switching back and forth between the two styles. For example, the regex above is from my Keyboard Maestro macro for quick image links; Keyboard Maestro uses Perl-style group references.

If you’re not familiar with regular expressions, you should be, especially if you’re interested in automating your work with a computer. They are a sort of mini-language for describing patterns of text, and knowing them will greatly expand your ability to search and replace. I first learned regex syntax back in the mid-90s from the “Searching with Grep” chapter in the BBEdit manual (a chapter written by John Gruber, if I remember correctly). If you don’t own BBEdit, there are millions of regex tutorials on the web. I suggest David Mertz’s short introduction. I have his Text Processing in Python book, and he’s a clear and succinct writer. If you really get into regexes, you can move on to Jeffrey Freidl’s book.

The conveniences that Patterns brings to debugging regexes for us old hands should be even more helpful to those just learning. I wish I’d had it around 20 years ago.

Update 8/1/15 9:20 AM
I am informed by a reliable source that Patrick Woolsey was the original author of the Grep chapter of the BBEdit manual and that John Gruber expanded it when it was revised for Version 6.5. Since BBEdit 6.5 was released in 2001, during my years in the Linux wilderness, it’s Patrick that deserves the credit for my initial regex instruction. Patrick still works at Bare Bones and is likely to be your first line of support when you email for help. Now I understand why his responses are so well written.