BBEdit HTML to Text

This script uses BBEdit to convert HTML to lightly formatted text. Unlike BBEdit’s “Translate” utility, this maintains links, image ALT text, and even formats headers and bold text as all-caps. The formatting is ideal for making plain text versions of HTML email messages – which is the reason I created it in the first place.

For best results, drop this in the BBEdit Scripts folder. (you can open it from BBEdit’s script menu!)

Written on March 31, 2009

Easy Apache Redirects and Site Aliases

Everybody knows about using .htaccess files to redirect, say, foo.com to www.foo.com. There’s lots of cookbooks out there for doing this. But I was in a different situation; I registered foo.com, foo.biz, foo.net, foo.org, foo.mobi, foo.us, and foo.info!

(Note: “Everybody” refers to apache sysadmins, and foo refers to a domain name that I do not want to advertise at this time.)

One way to handle this would be to set up a ServerAlias entry in the httpd.conf file for every one of these domains. While this works, it doesn’t redirect the domain. Instead I end up with duplicate content for every one of these many domains.

I could handle this by writing a .htaccess file that covers every combination of, say, foo.net, foo.org, foo.biz, and so forth for every domain, but that seemed like an awful lot of typing. Yet, for some reason, I couldn’t find much of anything on the web to make this easier.

It turns out this can all be handled in your httpd.conf file using the “Redirect” directive.

What you need to do is set up two virtual hosts. One is for the domain you’re re-directing to, and the other is for any and all domains you want to redirect from. Then you add a “Redirect permanent” directive as appropriate.

Here’s an example, in which I try to route foo.com to www.foo.com:

# This is the master domain

ServerName www.foo.com
DocumentRoot /var/www/foo.com


# Redirect foo.com to www.foo.com

ServerName foo.com
Redirect permanent / http://www.foo.com

Okay, this is actually more text that an .htaccess mod_rewrite statement, but look at what happens when I add ServerAliases to the redirecting virtual server:

# Redirect everything to www.foo.com

ServerName foo.com
ServerAlias *.foo.com
ServerAlias foo.net *.foo.net
ServerAlias foo.org *.foo.org
ServerAlias foo.biz *.foo.biz
[and so on...]
Redirect permanent / http://www.foo.com

I can use the same syntax to do a 302, 303, 401 or any other sort of redirect as well.

If you have a fairly simple array of virtual hosts, you could also use the default “catch all” virtual host to redirect to your main site, thus avoiding any need to explicitly define tons of ServerAlias entries.

Written on January 22, 2009

Sync Hole

Syncing the iPhone is a mess. Apple really dropped the ball by not providing a generalized sync framework to support third party apps.

Every time I want to take my iPhone out on the road with me, I need to go through and sync up every application individually: Here’s the song and dance for a full sync:

  1. Open up 1Password on my Mac and on my iPhone, choose Sync from the iPhone, and wait for it to complete. (Sometimes I need to click through some password errors, too.

  2. Open TextGuru on my iPhone and the TextGuru server application on my Mac and copy over any text files I’d like to share between the devices.

  3. Open up Stanza on both my Mac and my phone and then open each book I want to carry with me and send it to the phone; one-by-one.

  4. Load any files I want to take with me into FileMagnet uploader, open the app on my iPhone, and send them over. (Or, if I’m using Briefcase, turn on remote login on my Mac and browse it – I’ll cover file viewers/transfer apps in a later post.)

  5. Open up SpeakEasy Connect to grab any recordings I want on my Mac from my phone.

  6. Sync OmniFocus to .me (and then when I open it on the iPhone, it syncs up, so that’s something at least!)

  7. Open up ByLine to pick up my Google Reader RSS feeds.

  8. Likewise with Instapaper.

  9. Did I mention I don’t use Safari as my main browser? So that’s a trip to BookDog to sync up my bookmarks from OmniWeb to Safari so that I’ll have ‘em on the phone.

  10. Finally I’m ready to sync with iTunes, but to be sure I get the most out of this sync, I’ll check for new podcasts and application updates.

  11. Dangit! I’m out of space for all my new files on my iPhone. Time to trim playlists, swap out movies, etc. I sure wish I could autofill the thing like I could on a shuffle!

And that’s if I happen to be on an available wifi network. Otherwise I also have to deal with Internet Sharing on my Mac!

Yeah, this is a worst-case scenario, of course. I don’t necessarily need to pick up new files or books, and I don’t always need to grab recordings. But if I intend to spend some time on an airplane or otherwise need to keep everything updated, this whole rigamarole can take as much as half an hour of fidding.

But because this is so time consuming, it’s not uncommon for my iPhone to be out of date, so I don’t have my latest passwords from 1Password, or I don’t have the movie I just rented from iTunes or eBook I’ve downloaded. (since I have to transfer it to the one device it lives on – grr!) Likewise, my Mac’s out of date from files I have on my phone. What a drag!

Some of these applications use Mobile Me or some other online service as an intermediary, so that I can sync asynchronously from my Mac or iPhone to a central server. Or ByLine syncs directly with Google Reader, so it acts like a normal RSS reader that way. But if I intend to be outside of wifi range, I have to remember to sync.

Compare this to my Palm handheld (recently retired in favor of my iPhone). I put it in the cradle and pressed the “sync” button. Any e-books or files waiting for transfer would transfer, passwords would be updated, content on the device would push back to my Mac. One click, and I was done. Palm provided a standard framework that developers could use to sync their applications’ data with my Mac and its programs.

Apple has done the same thing in the past, through iSync and Mobile Me/.Mac. However, they failed to extend this to the iPhone. Instead, every developer needs to build their own synchronization solution, with no standards whatsoever. Additionally, since there’s no background processing, there’s no method to keep the desktop and the phone in sync without forcing a manual process of opening every syncing program and doing your business, one program at a time.

Obviously there’s an underlying sync framework in iTunes, which can handle multiple content types (music, photos, email, contacts and calendars) from multiple data sources (Outlook on the PC; iPhoto, Mail, Address Book and iCal on the Mac; Google and Yahoo hosted services; and, of course, video and music through iTunes). And that’s all in addition to the built-in Mobile Me and IMAP services!

Apple dropped the ball on syncing with the iPhone. They need to build a synchronization API for developers, and they need to build it quickly before more programming time goes down the drain building half-assed custom sync solutions.

Written on November 25, 2008

Fix for Software Update "Update could not be saved" error

I’ve occasionally had an error when installing software that goes something like “The update could not be saved… You do not have appropriate access privileges.” I’ve tried deleting the software update caches, fixing permissions, etc., all to no avail.

Well, this Apple discussion thread had the answer. You just have to delete a folder with the same name as your update from /Library/Updates. Or just delete everything, I suppose.

I had to delete the offending folder from the terminal using “sudo” for some reason. I guess it was set as root-owned or something. Weird.

Written on November 21, 2008

Search the Amazon MP3 store from the iTMS

Now you can browse the iTunes Music Store and search for songs you like in the higher-quality, cheaper, and DRM-free Amazon MP3 store!

Just select some songs you like while browsing the iTMS and run this script, and your browser will open up searches for each selected song. If you don’t have any songs selected, it’ll just search for the first song in the list.

Why would you want this? Well, the iTMS has a very nice browser and some convenient integration with your playlist (especially with the new Genius sidebar). This way you can take advantage of that nice browser, but still buy a high quality, DRM free, MP3 version of the songs you want.

It’s kinda like going to Best Buy to try out a computer and then buying the computer on Amazon. Except with music.

Written on September 27, 2008

Who says print is dead?

Well, I may be leaving Penton just in time. On-demand printing has hit the publishing business. Hello, MagCloud.

Or then again, maybe not. A single issue of Windows IT Pro, published via MagCloud, would cost a subscriber $18.20! (84 pages, including front/back cover, at 20¢ per page and $1.40 shipping) And that’s with no markup/profit for the publisher.

Still, it’s a full color magazine, printed on an HP Indigo, so it is probably quite high quality. Full color, and I’m guessing that it’s printed on better paper than the toilet paper most magazines are printed on these days. (We can’t all be National Geographic)

Could be just the ticket for a quarterly journal or other high value publication. But for the low-budget ‘zine-type publisher, you’re still better off investing in a copy machine and a saddle stapler.

Written on June 19, 2008

Cha Cha Cha!

Wouldn’t you like to have Google at your fingertips wherever you go? Wouldn’t it be even cooler if you had a friend standing by to search Google for you, so that you don’t have to spend the time typing on the go? What if it was a complete stranger working for pennies on behalf of a very cool service named ChaCha?

Here’s what you do: Dial 1-800-2CHACHA (or 1-800-224-2242, if you prefer). A friendly automaton will prompt you to ask a question. Ask away, and then resume your daily business. In a minute or two, you’ll get an SMS message with an answer to your question. Pretty darn slick.

There are a few GotChas with ChaCha: Real humans are finding your answers, and they’re paid for their answers in dimes. (But they make it up in volume, I imagine) So don’t expect the sort of service you’d get from a skilled reference librarian with lots of answers at their disposal. Instead you’ll get a reasonably skilled Google/Wikipedia searcher who will be about as accurate as the same sources.

So it’s great for “I’m at this intersection and I want to find a gas station, where’s the closest one?” or “Who played Iron Man in the movie of the same name?” Not so good for “Where did I put my keys?”

Good stuff. I could easily become addicted to this service.

Written on June 17, 2008

Easily back up gigantic files, even with Time Machine

One place where backup programs really fail is in backing up large files. If, say, your run your VMWare machine, thus updating its disk; you add metadata to a high quality ripped DVD video; or you use Microsoft Entourage, so every time you get a new email, your giant Entourage database gets changed.

Some backup programs can handle block-level updates, so that only the chunks of the file that have changed get backed up, but most don’t.

Well, this little trick on MacOS X Hints is genius! Apple’s Disk Utility in 10.5 lets you create “sparse bundle” disk images. These are just like normal disk images, except that they break up the image itself into numerous smallish files, each one is about 8 MB.

So you can take your big ol’ file, put it into a sparse bundle, and poof! You can now handle backups and it’ll only change a handful of 8 MB files.

While the hint I’ve linked to is pretty complicated, you can just have the image and put large files on it and not worry about the rest of it. You can even just make an alias or symbolic link (type “man ls” in the terminal for a how-to) from one folder to another (yes, this does work on the “Microsoft User Data folder), rather than have a complicated script.

Note that, a few programs that generate big files offer similar features. VMWare, for example, lets you split up your VM’s hard disk image into 2 GB chunks. Not quite as minute as these sparse bundle backups, but still quite good (and probably faster, which is a must-have for a VM). Also, if you’re using FileVault, you already have a sparse bundle containing all your files on your hard drive. Nifty!

Written on June 6, 2008