Sunday, April 19, 2015

"Why Won't Mobile Safari Write Cookies for My Web Site?"

Probably because, as I was, you're triggering your cookie Javascript with "onunload" or "onbeforeunload." That won't work on Safari for iPad or iPhone.

Modern browsers work differently from older ones -- they want to save your page off-screen, or "cache" it, rather than unload it completely. In some browsers, your use of "onunload" or "onbeforeunload" rules out caching, leading to slower performance for your site. Safari on iOS, on the other hand, caches the page anyway and just ignores your script!

The solution is simple. In place of "onunload" or "onbeforeunload," use "onpagehide." That's right, just substitute that one term for either of the other two. Then your script will be triggered whenever the page is unloaded OR just cached. Not only will Safari now write your cookies, but this will speed up navigation back to your page in all other modern browsers!

By the same token, you may want to replace "onload" with "onpageshow." But not always. "Onpageshow" will trigger whenever a page is loaded OR just retrieved from cache. But if the page is just retrieved, it returns in its previous state, so onload functions may not be needed or wanted. In that case, you should leave those functions in "onload," while moving any others to "onpageshow."

The biggest disadvantage to using the new triggers is that older browsers won't recognize them. That includes Internet Explorer before version 11. If that's important to you, you can design your JavaScript to revert to the older triggers for older browsers. (But I haven't bothered.)

Sunday, March 22, 2015

"Why Do I Lose Email Messages When I Import Mailboxes from Thunderbird or Postbox to Apple Mail?"

Apple Mail uses a more restrictive standard than Thunderbird or Postbox do when looking for the start of a new message, so it simply misses many or most of them. On one attempted mailbox import, I saw the message count drop about 95%! The scary part is, if I hadn't checked the count in Postbox against the count in Mail, I might not even have realized I'd lost anything.

Eudora Mailbox Cleaner, a commonly recommended solution for importing from Thunderbird to Mail, did exactly the same thing, for the exact same message count. (I ran it on Snow Leopard Server in a virtual machine.)

So, how do you import without loss? I'm going to make this very simple for you. Use Weird Kid Software's Emailchemy, a brilliant app for converting from one email format to another. In the Preferences, on the "Standard mbox" tab, select "Relaxed" for "Compliance to mbox standard when reading." I also suggest you choose "UNIX and Mac OS X: LF" for "Output Newline Characters."

Then just choose to convert your mailboxes from "Thunderbird" to "Apple Mail 1.0." On the same mailbox I mentioned above, with almost 9,000 messages, Emailchemy recognized all but three, and Apple Mail showed that same number after import. Good enough!

Tuesday, March 10, 2015

"Why Is BBEdit Corrupting My Thunderbird or Postbox Mailboxes?"

Instructions for repairing your mailboxes commonly tell you to edit the files in a text editor, and BBEdit is usually recommended for the Mac. Unfortunately, for Thunderbird or Postbox mailboxes, this is about the worst advice you can get. More often than not, merely editing and saving the file in BBEdit will seriously corrupt the mailbox.

Why is that? The problem lies in how both the text editor and the email apps work, and in how those ways interact. Thunderbird and Postbox store received email messages with Unix line endings -- "LF" or "line feed" -- as they should. But when you compose a message, those apps create and store it with Windows line endings -- "CRLF" or "carriage return, line feed." So, unless you keep your sent and received messages in separate mailboxes, you get mixed line endings in the same file. (Postbox was built on Thunderbird code, so the similarities should be no surprise.)

As the folks at BBEdit explained it to me, some text editors are good at handling mixed line endings in files, while others are more interested in helping you "normalize" line endings -- make them consistent. Apple's TextEdit and Notepad++ on Windows are examples of the former. BBEdit is one of the latter.

When BBEdit opens a file, it looks at the beginning to decide what kind of line ending it's using. If that file is a Thunderbird or Postbox mailbox and starts with a received message, then BBEdit decides on Unix line endings. And it expects to find those same line endings throughout the file -- as would be common in a text file.

The problem comes when BBEdit reaches a sent message with its Windows line endings. Because it expects single-character Unix line endings, it interprets the two-character combination of carriage return and line feed as _two_ line endings, and puts two line feeds in their place. In other words, it inserts a blank line between each line of text. And of course, it never warns you.

So, what happens when you next try to view that mailbox's messages in Thunderbird or Postbox? Both of those apps expect to find each message's headers in a set of single-spaced lines at the top. When they instead find double-spaced lines, they don't recognize the headers. All the messages you've sent are still listed, but they appear without subject, sender, or recipient, and with the current date replacing the original! The data is still safe in your mailbox, but Thunderbird and Postbox can't read it.

Is there any way to use BBEdit on a mailbox that doesn't damage it like that? Yes. You can open the file with the Open command on the File menu, unchecking the option to "Translate line breaks." After the file opens -- which can take a long time -- use the Normalize Line Endings command on the Text menu. Then, if you need to, at the bottom of the window, change the file's line endings from "Classic Mac (CR)" or "Windows (CRLF)" to "Unix (LF)."

You can then edit as you like, and Thunderbird or Postbox will have no problem. But this won't stop those apps from inserting more messages with Windows line endings -- so if you need to reedit, you'll likely have to go through the whole procedure again. Really, it's probably simpler to edit the mailbox in TextEdit instead.

What if you've already corrupted the file? If you can't replace from a backup, you'll have to remove the double spacing. To do that, you can reopen the file in BBEdit, find the double-spaced messages, and remove the extra blank lines by replacing each pair of line endings with a single one. (Yes, it's safe to edit the file like that.) The correct header info will then magically reappear in Thunderbird or Postbox. To make the repair quicker and easier, you can probably first use the email app to move all the mailbox's corrupted messages to a new mailbox by themselves.

As a long-term solution, we can hope that the developers of these apps make some changes. BBEdit's developers tell me there are changes coming down the line that may help with mixed line endings. And maybe Thunderbird's or Postbox's developers will wake up and realize there is no place for Windows line endings in a Mac app.

By the way, you'll notice I haven't discussed what happens in BBEdit when it opens a mailbox starting with Windows line endings but with Unix endings mixed in later. I'm afraid you'll have to work that out for yourself!

Saturday, March 7, 2015

"How Do I Cancel/Close/Delete My WordPress.com or Gravatar Account?"

Well, you can't, but you can nuke them so they're as good as closed. In the spirit of overkill, here's how to do it with Gravatar, which is actually a feature of WordPress.

1. Go to Gravatar and sign in.

2. Delete your image.

3. Find your Gravatar profile, and click "Hide" at the bottom right.

4. Go to WordPress.com and sign in.

5. Click on the personal settings icon at upper right. (It looks like a head and shoulders in a circle.)

6. Go to the Security tab.

7. Under "Connected Applications," remove Gravatar.

For your WordPress.com account:

1. Sign in to WordPress.com.

2. Click on "My Site" at upper left and then on "WP Admin" to find the Dashboard for your blog.

3. In the Dashboard sidebar, click on Tools > Delete, and follow instructions.

4. Click on the personal settings icon at upper right.

5. Delete or change everything you want, including in your profile. (You can't delete the Public Display Name -- it will just come back -- but you can change it to "None" or something similar.)

6. Get a free throwaway address from a site like Mail.com.

7. Back at WordPress.com, go to the Account tab of your personal settings and change the email address to your new throwaway address. WordPress.com will send a verification email to that address.

8. Back at your throwaway email host, open the WordPress.com email and click the embedded link to verify the address. After that, you can delete the throwaway email account or leave it.

9. Back at WordPress.com, change the password to one that doesn't match any you use for other accounts. Optional: Make it a password you won't remember yourself.

10. Also optional: Under Account, change your username.

11. Sign out.

Saturday, February 28, 2015

Why Can't I Uninstall Dropbox on My Mac?

It's easy to find instructions on the Web for removing Dropbox from a Mac. But they all seem to leave out the crucial first steps -- and without them, you may not be able to remove a file. Here are those steps:

1. With Dropbox running, call up the app's preferences. In version 3, you can find them by clicking on the Dropbox menu bar icon and using the gear menu at lower right.

2. On the General tab, uncheck all the following:
"Show desktop notifications."
"Start Dropbox on system startup."
"Enable Finder integration."

3. Close the preferences and restart your computer.

You should now be able to remove any Dropbox file or folder with no trouble. My own way was to use TinkerTool to show all normally invisible files and folders, then to search for "dropbox" with EasyFind and use its contextual menu to "Reveal in Finder."

Lesson: Think twice about installing an app that doesn't supply its own uninstaller. (And there's no real reason to install the Dropbox app anyway, since you can easily upload and download your files from the Web site.)

Saturday, February 14, 2015

"Why Does Adobe Photoshop's Save for Web Give Me an 'Unknown Operating System Error' Message?"

Recently, after updating my Mac from Snow Leopard to Yosemite, I was chagrined to find that Adobe Photoshop's Save for Web -- a feature I rely on heavily -- would not save a file. Every time I tried it, I got the message, "Could not complete this operation. An unknown operating system error has occurred."

Scouting around the Web, I found that the common solution was to delete the two Adobe Photoshop Save for Web preference files. Sometimes that worked for people, and sometimes it didn't, and it certainly didn't for me. But digging into my system, I found why: There are three possible locations for Adobe Photoshop Save for Web preference files, not two! And once I knew that, I fixed it easily.

So, for a guaranteed fix, close Photoshop and delete all the following files and folders, and any others that look like them -- for different versions or even different Adobe apps.

Users/[Username]/Library/Preferences/Adobe Save For Web 13.0 Prefs

Users/[Username]/Library/Preferences/Adobe/Plugins/Adobe Save for Web CC

Users/[Username]/Library/Preferences/Adobe Photoshop CC Settings/Save for Web Prefs.psp