Updating the cover of the Swift iBook

Apple updated the cover of The Swift Programming Language to match the new book in the series, but deleting and redownloading the book within iBooks in OS X Mavericks didn’t update the cover — it continued to display the original cover.

The solution was to quit iBooks, delete the iBooks cache located at ~/Library/Containers/com.apple.iBooksX/Data/Library/Caches/com.apple.iBooksX, and restart iBooks.

You’re welcome, Internet.

Posted in Apple, Macintosh, Programming | 1 Comment

Improved cwd restoration in tcsh

My previous post illustrating a technique for restoring the current working directory in Apple’s Terminal for tcsh users was discovered by Khoo Yit Phang, who suggested an improved version down in the comments. I’m reproducing it here for greater visibility:

if ("$?TERM_PROGRAM") then
  if ("$TERM_PROGRAM" == "Apple_Terminal") then
    alias cwdcmd '( set echo_style = both; echo -n "\033]7;file://${host}${cwd:ags/ /%20/}\a" )'
    cwdcmd
  endif
endif

Compared to my approach, it has two improvements: (1) by using cwdcmd (of which I was previously unaware) rather than precmd, it only runs when you actually change directories; and (2) by using a suitably configured echo, it avoids running an external command (printf is not built into tcsh, but is present in /usr/bin).

Thanks, Yit.

Update: Of course, with this technique you have to explicitly run the command once, to restore the working directory to the title bar for the first time when you start up. Fixed above.

Posted in Macintosh, Programming | Leave a comment

Current working directory restoration in Mavericks Terminal with tcsh

In John Siracusa’s excellent review of OS X Mavericks, he (originally) mentioned that the Terminal application is able to restore the current working directory of open shells across launches.

However, this section has subsequently disappeared from the online version, perhaps for the reasons given below (update: see below). Try looking here for a cached version of the original; scroll down to page/slide number 94. Sorry, John. Please purchase the full review on the iBooks store or the Amazon Kindle store to support John’s work.

Of course I was excited to try this out as, in the course of my work as a software developer, I often have several shell windows open in specific directories. So I tried it, and it didn’t work. It turns out the built-in support supplied by Apple assumes that you’re using the bash shell, but as an old-timer I’m stuck on tcsh instead:

Well, that’s no good, I thought. So I looked in the supporting code’s implementation (/etc/bashrc), and figured out how to do the same thing in tcsh. Simply place the following in your .tcshrc file:

if ("$?TERM_PROGRAM") then
 if ("$TERM_PROGRAM" == "Apple_Terminal") then
  alias precmd 'printf "\033]7;%s\a" "file://$host$cwd:ags/ /%20/"'
 endif
endif

This uses the appropriate escape sequence to send the URL of the current working directory to the terminal before each command; Terminal detects this information and uses it to update the state of the window (including a proxy icon in the window’s title bar for the corresponding folder). It turns out that the key is doing it using precmd (tcsh’s equivalent of PROMPT_COMMAND), and not sending the sequence in the prompt string itself as one might think. (The outer if statement is necessary to avoid an error when remotely logging in, as with ssh. It has to be a separate statement because of the variable expansion rules in tcsh.)

I’ve notified John via Twitter, so perhaps he add restore this information back to his review. In any case, it’s documented here for future generations. Drop me a note below if you have any issues with it.

Update: It turns out John removed it because he discovered it was a feature in Mountain Lion as well, which had happened not to work on his machine:

If you listen to John’s podcasts, you’ll realize that makes sense: he wouldn’t let something not new in Mavericks stand in the Mavericks review. Regardless, I wasn’t aware of the feature before and it still wouldn’t have worked in tcsh, so this post is presumably still useful. (Note that I haven’t tried it on Mountain Lion, and I’ve already upgraded my working machines to Mavericks; I don’t know why this technique wouldn’t work on Mountain Lion, but use it at your own risk.)

Update 2: OK, so it turns out the feature was first implemented in Lion, and other people have already figured out how to port it to other shells; see here for an implementation in zsh, for example. How did I manage to not learn about this for the last two years? Oh, well…

Posted in Macintosh, Programming | 5 Comments

“Regime Change” at Apple

Matt Drance nails it:

There’s a long-standing pattern of separating watershed products important to the company’s future. The Mac and Apple teams. Mac OS X and Classic. The iPod division. iOS and Mac OS X. Suddenly, Tim Cook has pulled the reins in. Federighi owns software. Ive owns design. Cue owns services. Period.

Apple’s insane growth has pushed the situation over the edge. Too much size and separation inevitably bring politics, chaos, dropped balls, and finger pointing. None of those things are good for Apple’s products or customers.

Best summary of the significance of the change I’ve heard to date.  This should end up being a net positive for Apple (despite the loss of Forstall’s talent, which was apparently becoming increasingly overshadowed by his interpersonal style).  And, to overuse a cliché, this is now Tim Cook’s Apple.

Posted in Apple | Leave a comment

Debugging software for laymen

Brent Simmons provides what is possibly the best description for laymen of the joy/agony of debugging software that I’ve ever seen:

If it took 10 minutes to reduce memory usage by 96MB, then — were there a linear relationship — it should take under half a minute, less than 30 seconds, to go the rest of the way.

That’s the way things work in the real world, after all. If you have 100 bags of leaves to carry out to the curb, each bag will take about the same amount of time as the others.

Instead, it will probably take me about two hours, maybe more, to get rid of that last 4MB.

It’s almost as if you carried out 96 bags of leaves easily and quickly, then realized you can’t get those last four bags, even though they’re exactly the same as all the others, without pouring a new driveway first.

Which is crazy, right? If the real world operated like that all the time, we’d go completely nuts.

Posted in Programming | Leave a comment

O @comcastcares, hear my plea

As of this evening the TV Guide channel is not displaying the scrolling list of program information — just the mindless “American Idol Rewind” and other programming at the top of the screen. You can usually see an empty space at the bottom where the program listing would fall.

When we called the customer support 800 number, the representative was completely clueless and apparently unable to understand our description of the problem. First she told us to unplug our cable-ready TV set from the cable and plug it back in (we’re still analog here and have no cable box). Predictably that had no effect. After my wife and I tried to explain the problem again, she finally decided that the problem was with the network — that is, the TV Guide Network had chosen to stop sending us program listings. She suggested we contacted the network to complain about the change.

As a result, we have no source of program listings from Comcast. The “Channel Lineup” page on comcast.com has had the message “We are currently working to provide channel lineup information for your area” for at least a year. (Our town straddles multiple counties and has its own cable franchise. Last summer Comcast decided to move everyone in town to the same system, which means that we’re now on the “other” system.)

The CSR dutifully ended the call with “Thank you for choosing Comcast”, which is a joke since our original system (Adelphia) was bought out by Comcast. Oddly we had no problems with Adelphia, but the major impact of Comcast (beside shifting our system) was to repeatedly raise our rates while moving channels from the analog tier to the digital tier.

I personally watch very little television and would ditch cable for over-the-air (and over-the-Internet), but my wife enjoys having the TV on while working in the kitchen, and the kids watch Nickelodeon, Disney Channel, etc. Frankly, Verizon can’t bring FIOS to our town fast enough for me. (Sadly there’s no evidence that they’re even considering this, although they’re hooking up an adjacent county.)

[The six loyal readers of my blog probably couldn't care less about this issue; this post is really just to have something to point Frank Elias (@comcastcares on twitter) toward.]

Edit: In the interest of full disclosure, I got two responses on Twitter the same evening; apparently it was a known issue (involving the digital transition?) and cleared up in a few days.

Posted in General | 1 Comment

Where have you gone, Fake Steve Jobs?

As Fake Steve Jobs, Dan Lyons made a terrific anonymous satirist. As Newsweek’s technology columnist, he leaves something to be desired.

Pass over the Microsoft marketer’s crack about Macs being “washed with unicorn tears” pass by, because, really, that just makes him look like a dick. Move on to Lyons’ observation that Apple is declining to build cheap netbooks and instead, “in January … rolled out that 17-inch laptop with a $2,800 price tag. Talk about tone-deaf.”

Yes, how terribly tone-deaf to introduce a long awaited upgrade to a machine in high demand among Apple’s customer base, on which Apple can continue to make a comfortable profit margin in a difficult economic environment by selling customers with ready money just the machine they want. What could they have possibly been thinking?

Meanwhile, PC manufacturers race to the bottom and wring the last bits of profit from cheaper and cheaper machines. But that’s no skin off Microsoft’s nose, because they (presumably) get the same profit putting Windows on netbooks as they do on high-end workstations.

In fact, Microsoft probably makes more off netbooks, because they typically ship with Windows XP, for which the bulk of Microsoft’s R&D costs have long since been paid.) No wonder they’re “turning the corner.”

Meanwhile, Apple has consistently declined to compete in the low-end market, and yet has continued to flourish financially, to the bewilderment of analysts everywhere. Presumably, unlike doctors, financial analysts are not taught about Willie Sutton.

As for me, I’m looking towards Apple’s next set of financial results, due out on the 22nd of April. I’m also (speculatively) waiting for the day when Apple announces its next low-cost portable computing device, which I predict will (a) not be a “netbook” as we think of one today, (b) cost significantly more than $300, and (c) sell like hotcakes.

I’ll come back to Dan Lyons’ “commentary” then.

(Tip of the hat to Daring Fireball.)

Posted in Apple | Leave a comment