Nik's Blog

Geekery, witty insights, software (of dubious quality) and more!

General Geekery

Tech news and observations

Generate Rich Text in AppleScripts and Shell Scripts

Normally, AppleScript absolutely mangles rich text once it comes in to the system. I have recently discovered a workaround for this, which is the “pbcopy” terminal command. Anything piped to this command will be copied to the clipboard. Normally, this is done only as plain text, but if the incoming data is rich text (has an RTF header), it will come in as rich text. The second part of this is the use of the “textutil” command, which can take text of various formats and output them in, among other formats, rich text. Now, even if you’re limited to only plain text (as in AppleScript), textutil will happily accept HTML, so if you can generate formatted HTML, you can pipe it through textutil and end up with lovely rich text in your clipboard, and it even retains links!

So from the shell, your command is something like:

% echo [html text] | textutil -stdin -stdout -format html -convert rtf | pbcopy

Just make sure that your HTML text is properly escaped.

If you want to do this from AppleScript, you can simply encapsulate the whole thing in a “do shell script” command.

BONUS: You can also put Markdown or MultiMarkdown in the mix to take Markdown-formatted content and convert it to rich text on the clipboard. The following is an example of how this would work with MultiMarkdown:

% echo [markdown text] | mmd | textutil -stdin -stdout -format html -convert rtf | pbcopy

Don't Like Facebook's API? Wait Five Minutes...

Had to update a set of Facebook applications for WCM. (Yup, still freelancing a little for them.) This is the third time these applications have needed a major upgrade to meet Facebook’s ever-changing API – once to migrate from FBML to FBJS, and again to move to Oauth, and no again to meet Oauth 2.0 as iFrame tabs and apps.

Facebook, being the 800 pound gorilla, can do whatever it wants, and the developers who have invested so much in the platform will, ultimately, get in line or just fail entirely. But this really hurts the small developers with modest projects, especially as some of the standby Facebook apps like Static FBML die out and paid services start charging “enterprise” prices.

To Facebook’s credit, they’ve put effort into sunsetting APIs cleanly, with advance warning (sometimes as little as 4 weeks, but usually quite a bit better) and even letting old APIs continue to work… for a while. But they haven’t handled QA at all well, which is exactly where this problem hit.

In the case of this client of WCM, they have a handful of custom, fan-gated tabs, as well as a full blown contest application, which was custom designed to meet their jurisdiction’s gaming regulations. (Otherwise, they could probably get away with any of the other contest apps out there.) When Oauth 2.0 was introduced, Facebook accidentally introduced a boatload of bugs into the supposedly still-supported legacy authorization API, which meant that in the middle of a major promotion, the contest stopped working entirely. This led to a crunch day of moving to the new APIs, which were still buggy as heck and not nearly as feature-rich as the old APIs.

Due to these holes in the API, a great deal of the work had to be custom built using curl commands and manual decoding of returned data, and other nonsense that really shouldn’t have been necessary since Facebook’s published PHP library ought to handle that sort of thing. Luckily, the tab-based apps weren’t affected (they didn’t need to authorize visitors); and since the new API, inexplicably, couldn’t handle fan-gating, they weren’t transitioned.

So now Facebook has killed support for the old API entirely, and requires tabs to move to iFrames (just like applications always have). Because of this, the fan-gating on the tabs (remember, they COULDN’T transition to the new API when it was first released!) broke, and again, WCM was in a crunch with the client since they were in the middle of a major Facebook promotion.

This much is good: The new API, iFrame tabs, and Oauth 2.0, now that they’re mature, are a lot easier to code for than the old system, so the old apps were fairly easy to set up, even though one of them (due to its reliance on non-iFrame-compatible FacebookJS) had to be entirely re-written from the ground up. Everything was no longer on fire within 3 or 4 hours. But there are, of course, lingering bugs due to the major changes in how an iFrame app needs to be managed, which present a substantial challenge to fix, since Facebook’s documentation in regard to these little bugs is limited to the old API – entirely useless.

Okay, enough of my bitching. The end result here is that in order to be a Facebook developer, you need to be on the cutting edge of their API at all times, but only RELEASE when Facebook gets around to making the new API stable and complete, which sometimes doesn’t happen until after they’ve broken your app. Meantime, you’re praying that your clients don’t get stuck with something that just plain doesn’t work because Facebook accidentally introduces bugs/improvements into their legacy API.

As Facebook looks to extend the Facebook platform outside of Facebook, this becomes untenable. If I’m relying on Facebook for users to register for my site, it simply has to work 100% of the time. I cannot be required to update substantial portions of my applications and websites multiple times each year. Doing so doesn’t make me any money, so unless I’m Wildfire or another company that can spread that cost over a large number of clients, it ends up being a drag on resources and revenue. This, of course, is why Buddy Media and the rest can start jacking up their prices from hundreds of dollars each month to thousands, leaving smaller companies to use the low cost tools which end up falling behind the API… same problems. (Ironically, even Facebook’s cut-and-paste social plugins have fallen behind the API and required instant upgrades to new code.)

So what am I doing? Well, nothing at all that’s mission-critical is ever going to be integrated with Facebook. I know there are benefits in hooking these things up, but I can’t afford maintaining these things or losing functionality because I overlooked a blog post. For clients, it’s going to have to be a program built by one of the major Facebook app companies, and they’ll have to cover the cost.

It’s a shame, too. My clients have seen awesome results using some clever custom applications, but if I can’t guarantee a modicum of reliability and uptime, the hit on my reputation will far outweigh a handful of successful campaigns.

Quick Tip: How to Figure Out if You've Already Purchased an App from iTunes

The iTunes App Store will let you re-download an application that you've already purchased. What it does not do, is let you see in advance whether you're going to be charged for it. If you make a mistake, you'll end up purchasing an app that you thought you were downloading for free!

The work-around is simple, but not obvious: Click on "Write a Review" on the app's listing. You can only write a review if you've already purchased the app!

Hope that saves you some money! Thanks to Jmalley on the Whirlpool.net.au forums for this great trick!

Backup doesn't get better than CrashPlan 3

I wrote some time ago about metadata and the state of metadata management with existing file copying and backup utilities. At that time, ChronoSync and SuperDuper were the only games in town for automated backup and copying -- and neither are proper backup/archiving programs.

However, the lovely folks at CrashPlan have released a new version that gets through the metadata test suite with flying colors. In fact, the only failure it had against Nate Gray's Backup Bouncer suite was that it failed to preserve extended attributes on symbolic links. (I'm fairly certain nothing currently stores metadata on symlinks, but just in case, I've submitted a support request with CrashPlan)

I'm using CrashPlan (and the online "CrashPlan Central" service -- similar to Carbonite/Mozy/BackBlaze/etc.) for a few weeks now, and I like it a lot. It manages backups from computer-to-computer (even over the Internet!), to hard disks or folders, network drives, and to their aforementioned online service. It does a great job, provides block level, de-duplicated backups, too, so your years of archives take only a minuscule amount of additional space. (Unlike, say, Time Machine, which keeps an extra copy of a file each time you change it -- hence the trouble with VMWare images and Entourage's mail archive.) It also keeps differentials going back forever, has "real time backup" for constant backups (more or less like Time Machine), encrypts the bejeezus out of everything (yes, you can have your own private encryption keys and passwords without sharing ANYTHING with CrashPlan), and (thank goodness!) automatically checks the fidelity of the backup. In other words, enterprise-grade backup for $25/year. (Or free if you don't mind missing a few features and can put up with ads)

So now I have to give my nod to a single backup tool to use for anything other than imaging. CrashPlan cannot make a bootable clone of a drive, nor can it handle a "bare metal" restore. For that, you'll want something like SuperDuper, Carbon Copy Cloner or (my favorite) ChronoSync. CrashPlan also cannot back up to optical media or drive sets, just logical drives. Given the price of drives and the size of files, I don't see this as a problem. Internet backup is quickly taking the place of shuttling around optical media.

OnStar: Yet Another Example of Why GM Can't Compete

I recently purchased a Pontiac (rip) Vibe. I’m not a fan of domestic cars, but in this case, I made an exception, since the Vibe’s really a Toyota Matrix with a different logo.

The car came with a three month trial of OnStar, GM’s all purpose safety service that will help you out if your keys are locked in the car, you get in a wreck and are unresponsive, or if you need a tow or a tank of gas. Think high-tech triple-A. You can also use it as a phone, provided you’re willing to pay in the ballpark of $1.20 per minute.

I’ve been playing with OnStar since I got it, and I gotta say, it’s nothing but proof that GM doesn’t have their poop in a group.

Here’s the thing: All OnStar is, is a built in cell phone that has a one-touch dial to a call center just outside of Detroit. Plus a GPS and some sensors. That’s it. When your car wrecks (identified by sensors noticing frame damage or the airbags deploying), it places a call, and they check in to see if you need help. If you need a tow, you make the call yourself. Keys locked in the car? You call them on your mobile phone and they take care of you. They’ll even give you directions if you’re lost.

Now don’t get me wrong, this is a pretty good hack. All they did was install a phone, and pay the salary of a bunch of phone jockeys, and they can sell it as a high tech safety service. But it’s a hack. This would work fine in 2003, but these days, we expect automation, computer screens, and immediate service. I’ve got better technology in my pants. (Don’t look at me that way… I’m talking about my iPhone!)

Here’s my experience with OnStar:

Scenario 1: Keys Locked in Car

I call OnStar. Phone tree asks for my home phone number (my ID with OnStar), and walks me through a phone tree. Yes, I need emergency services. beep (This counts as an emergency, as opposed to billing questions or customer service) Okay, yes, my car’s locked. beep No, there aren’t any animals or people locked in the car. beep Please hold…

After a very brief wait (I’ve never experienced more than 30 seconds on hold, they’ve got that down pat.), I get a nice lady on the phone, who asks me for the same information I gave through the phone tree, then sends the unlock signal, and waits on the phone until I confirm the car’s unlocked – which happens almost instantly. She then asks me how my service was, how I’m doing, etc.. Finally I get her off the phone, lock my car, and go back into the house.

This is a cool trick, and it’ll be a real life saver for me one of these days. I’m terrible about locking up my keys. That said, why did I need to talk to a person? Why not punch in my ID, my secret code, and press 1 to unlock my car. Then there’s no hold time (presumably that’s why they ask whether there’s a living creature trapped in the car – to put you at the front of the queue), and no need for pleasantries. (I’m a geek, I’d rather not talk to people.)

All in all, great service, but the execution needs polish.

Scenario 2: Make a Phone Call

My OnStar system also works as a speaker phone. Keep in mind, that’s all it really is. It doesn’t, however, work with MY phone, so I have to buy minutes at exorbitant fees (over $1.20 per minute!), and call from an entirely different phone number from usual. Here’s how it goes.

beep! OnStar Activated

Me: “Call Number”

Car: “I didn’t understand that.”

Me: “Call Number”

Car: “Virtual Assistant. Say yes or no.”

Me: “No”

Car: “Please repeat that.”

Me: “NO!” (shouting)

Car: “Please repeat that.”

beep (I manually hang up)

blee boop (I hold down the big button on my iPhone)

Me: “Call [My Wife’s Name] Mobile”

iPhone: “Calling [My Wife’s Name, mis-pronounced], Mobile”

In other words, awful. Awful in every way. Yeah, maybe it’s worth having a spare phone in an emergency, but this isn’t worth ten cents a minute. For my $100 to buy minutes, I can get a swell bluetooth speakerphone and call it a day.

Scenario 3: Voice Guided Directions

For my trial period, I get directions. Now, I was expecting turn-by-turn GPS stuff, but as with everything OnStar, what I actually got was a nice phone receptionist… eventually.

beep! OnStar Ready! Connecting to OnStar advisor!

Advisor: “Thank you for calling OnStar”

Me: “Hi. I need directions to Coopersmith’s pub in Fort Collins, Colorado.”

Advisor: “What?”

Me: “I need directions to Coopersmith’s in Fort Collins.”

Advisor: “Huh?”

Me (shouting): “I WANT DIRECTIONS TO COOPERSMITHS PUB IN FORT COLLINS COLORADO!”

Advisor: “Okay… Let me look that up.”

(typing sounds)

Advisor: “Is that a business name?”

Me: “Yes.”

Advisor: “What?”

Me (shouting): “YES, IT IS A BUSINESS NAME!”

(at this point, I decide to always shout, since obviously the speaker can’t keep up with the road noise as I drive down I-25)

Advisor: “Okay, I think I’ve found it.” (“I think”???)

Me: “OKAY…”

beep! beep! beep!

WTF??? This is the standard OnStar hold sound. Maybe he’s loading up my GPS or something. I wait.

Advisor (a different one): “Did you need directions?”

Me: “YES! I’M TRYING TO GET TO COOPERSMITH’S IN FORT COLLINS!”

Advisor: “Okay… That’s Super…? What?”

Me (screaming at the top of my lungs): “COOPERSMITHS! C-O-O-P-E-R-S-M-I-T-H-S!”

Advisor: “Okay… Just a second…”

beep! Your OnStar call has ended.

At this point, I was just curious whether I’d ever get directions. I clicked the button again and quickly got an advisor. I’ll skip the details, but she seemed to hear me okay (I was still yelling) and quickly looked up the business.

Advisor: “I can’t get a street address for that. Do you know if it’s at the intersection of Linden and Walnut?”

Me: “Yes, it is.” (I guess. I’m actually not sure those roads intersect.)

Advisor: “Great. It’s just a few turns, but if you’d like, you can download them to your car.”

Me: “Sounds good.”

Advisor: “Press the blue button.”

beep

Me: “Done.”

Advisor: “Here are the directions…” (she reads them)

Advisor: “Now you can press the button again.”

beep

Me: “Done.”

Advisor: “Great. To play back the directions, press the phone button, then say ‘Virtual Advisor’ and then say ‘Play.’ If you need to pause it, just press the phone button. When you call up the virtual advisor again, it will ask if you want to play, which starts over, or resume.”

Me: “Great! Thanks.”

Advisor: “Have a great day. Call us back if you need anything or have trouble finding it.”

beep! Your OnStar call has ended!

Me: “Virtual Advisor”

Car: “I don’t understand…”

etc…

All told, this took me 20 miles to complete. Good thing I was getting directions to a place that was 40 miles away, or else I would have shot past it an hour before.

Once again, OnStar proves the limitations of just being a phone. Well, a phone that can record your call. My turn by turn navigation is playing back a recording and stopping it after every turn until the next one comes up, and then hitting “play” again.

Are you serious?

This whole package, not including phone minutes, is $30/month. That’s pretty darn steep, but possibly worth it just for the emergency services. (Which costs $20 without the directions service) But overall, it’s a sad statement on GM’s technological capabilities.

I can see two ways to go with this service. One option is to just make it cheaper, and treat it like a triple-A subscription. Emergency services, $100/year. Or whatever. It would probably be worth it.

The other approach would be to just use the OnStar Advisors as what they are, people with computers that are one button away. Let them help you with more than just directions and phone numbers (for while, I have it on good authority, they just use Google Maps), and just look stuff up on the Internet, or even make some phone calls for you to find a laundromat that can press your suit before the wedding you’re attending.

Would I pay for that service? You bet! It would be a GM Concierge. Sure, it’ll require a GM car, but it would give everyone the admin assistant they’ve always wanted.

In the meantime, I’ll drive my Pontiyota (Toyotiac?), which I like a lot, and I know my wife will sleep easier knowing that if my airbags deploy, I’ll get emergency service promptly and automatically, even if I’m knocked out cold. But I have to say that it galls me to pay so much for so little.

Pages

Subscribe to RSS - General Geekery

@inik

inik: I love Dropbox because it's indispensible on an iPhone. Was the top of the list of things I recommended to my bro. http://t.co/AnMAp1K4 >
inik: RT @alexismadrigal: Yup, @Salon cut the number of stories they post, increased their quality, and got a 40% traffic boost. http://t.co/X ... >
inik: RT @mikememoli: "The NFL: We're working on that whole brain injury thing." >
inik: I am a sucker for dog ads. Add Ponda Baba and it's like bliss. >
inik: Live stream only available to Verizon customers. Wonder how much that cost them. Anyone know? #superbowl >

Google+

I love Seth's quote at the top. I think that's my new motto.. ; )

Powered by Plu.sr
>
Griping about OS X Lion? Here's two nifty tools that replace a variety of poorly supported third party tools: Command-line and Automator access to video and audio conversion. Super easy to use, and very flexible and supports any format that Quicktime can encode/decode. (So Perian is a must-install if you want to handle DivX/3viX, etc.)

Yes, ffmpeg, Handbrake and...
>
Fix Google Reader's horrible new interface with this user script! Now it fits nicely on my MacBook's small screen. >
Happy 11/11/11 11:11:11! >
What makes this ad awesome is not the true-to-life irony, because the idea is hardly innovative, but rather the excellent execution. Reminds me a bit of that excellent Nutri-Grain spec commercial. Quick delivery, good actors, hit all the high notes. Love it. >