inessential by Brent Simmons

December 2009

3 laws

The Three Laws of iPhone apps:

  1. An app must not allocate memory or, through inaction, allow memory to be allocated.

  2. An app must obey all didReceiveMemoryWarnings given to it by the system, except where such orders would conflict with the First Law.

  3. An app must continue to run and not crash as long as such running does not conflict with the First or Second Law.

Commentary…

#1 is a bit stringent, but it’s always worth keeping in mind as a paradisiacal condition to strive for, however impossible.

With #2 there shouldn’t be such a conflict, obviously. But possibly worth spelling out anyway.

#3 seems to be just right.

But #1 is my favorite, the one I keep replaying in my head.



Are there any non-geeks in the audience? If so, allow me to point to the Three Laws of Robotics.

Update 12:12 am: I’ve had some questions about this. Obviously, you have to allocate memory. To suggest you shouldn’t is pure hyperbole. My point is just that allocating memory is expensive, and sometimes it can be avoided.

When you run into trouble, use Shark and Instruments to find out what’s going on.

Directory listing colors in Terminal

I like to have colors in my directory listings when in Terminal. Blue for folders, red for executable, etc. I’ve been doing this for years, and I always forget it’s not the default.

I use tcsh (still, yes), so I have the following in my .tcsh file:

setenv LSCOLORS "exfxcxdxbxegedabagacad"

Gibbery, yes. But it specifies colors for ls listings.

If you use bash, the following in .bash_profile should work:

export LSCOLORS="exfxcxdxbxegedabagacad"

(Remember to do a source .tcsh or source .bash_profile after editing the file.)

If it doesn’t work, you might still have to set CLICOLOR to true, and possibly set TERM to xterm-color.

And of course you can change the colors — do a man ls for more info.

My theory about Lieberman

I’ve been trying to understand Joe Lieberman’s behavior — and not quite getting it. What’s the point of opposing positions he’s long supported publicly (Medicare buy-in) using a tool (the filibuster) that he’s long been against?

My theory sets Lieberman aside at first and starts here: it says that John McCain has a theory.

John McCain’s theory (my theory says) is that he lost to Obama because he listened to Bill Kristol and picked Sarah Palin, and she’s responsible for his electoral loss. John McCain wanted to pick Joe Lieberman, but was persuaded not to.

John McCain thinks (I think) that he would have won with Lieberman.

My theory continues with these speculations: Lieberman agrees with McCain. And McCain has told Lieberman he will run in 2012. And McCain has told Lieberman he’ll do it right this time.

So Lieberman knows he has a couple years to make himself palatable to the country’s Republicans. But he can’t just become one, because he’d lose his (very important to his credentials) Homeland Security Committee chairmanship.

Consider that McCain would run on national security and fiscal prudence. Lieberman would fit that story, and he’d bring some demographic balance: suburban pro-choice voters might be able to vote for McCain if his running-mate is more socially liberal. Or so says my theory of McCain’s theory. (And Lieberman really is more socially liberal than just about every Republican in Congress. But I don’t believe he’d actually help expand the pool of McCain voters.)

And my theory extends to this: Lieberman thinks McCain may be right, that a McCain/Lieberman ticket could win in 2012. And, well, Lieberman wouldn’t mind being vice-president — especially with an older president and with the precedence of Dick Cheney to show what kind of power a vice-president can actually wield.

So that’s my theory: McCain/Lieberman 2012 is the plan. Whether spoken or not, agreed-to out loud or not, Lieberman is preparing.

Or… or… I dunno. I have no other explanation.

Update 9:35 PM: I should have made this more clear: my theory assumes that both McCain and Lieberman are delusional.

Weekend mode for Twitter clients

I love weekends because (usually) I can get more work done because there are fewer emails, tweets, news items, IMs, and so on to distract me from writing code.

I actually keep my Twitter clients turned off on the weekends.

But I still check Twitter from time to time in case there’s a mention I should reply to, or in case there’s something that people are linking to that I should know about.

What I’d love to have is a “weekend mode” in my client. (Or it could even be a separate client.) The weekend mode would show me only mentions, direct messages, and items with links. However, the items-with-links would not include yfrog and similar links: if it’s just a picture of someone’s sushi or their wacky goldfish, I can skip it.

It should do Growl notifications for mentions and direct messages. Items-with-links wouldn’t trigger a notification, but perhaps there would be an unread count in the Dock icon for the app.

Also, importantly, all shortened URLs would be lengthened for display, since that helps me decide if a link is worth looking at. If it’s at YouTube, probably not, but if it’s at CNN, it might be important news. (There might even be a blacklist — filter out links to certain sites, or filter out based on type of site. If I could tell the app I don’t care about photos, I wouldn’t see links to Flickr, SmugMug, and so on.)

Anyway — it could be just me who’d like and use weekend mode. Maybe everybody else wants the regular thing all the time. So don’t nobody add this feature or write this app unless you’re convinced that other people would like it too.

But I’d probably use it for more than just weekends. Nights too, and any days when I’m busier than normal.