Tips with iWork Pages

If you’re writing a book, new chapters need to start on the top of the next right page.

To do this in openoffice, you Insert > Break, choose “Page”, then hidden under the “Styles” menu there’s a “Right Page”.

To do this in Apple’s iWork Pages, you insert a new section break — and at the bottom of the section inspector there’s a “Section starts on:” pulldown.

Free and Easy Encrypted Storage for Mac OS X and MobileMe or DropBox

Online storage services like iDisk (part of MobileMe) or DropBox are very convenient for sharing and backing up files–but when you put files into the cloud you’re assuming that:

  • those companies, and
  • all their employees, and
  • all their contractors, and
  • all their collocation facility employees

will be morally upstanding. And that they will securely erase old drives. And that their systems will never be cracked. Ever.

My point is that sensitive stuff, like tax documents and passwords, must be encrypted before storing them in the cloud.

The solution? Make an encrypted file on your computer that can be mounted as a “secure hard drive”.

(Update August 2009): TrueCrypt is an easy-to-use and cross-platform solution to this issue. The following is a tutorial that is a Mac OS X specific alternative to TrueCrypt.

Example disk image

Example disk image

Using the disk image is easy — when you double click your encrypted disk image, you’ll be prompted for the image’s password, and then the image will be mounted, looking just like another hard drive was attached to your computer. (With TrueCrypt you must “mount” the file using the TrueCrypt software, so it isn’t quite as user-friendly).

You can drag-and-drop private files into the disk image, and even edit them just like a normal disk. When you’re done, eject the drive, and your files won’t be readable until the image’s password is re-entered.

The disk image can be stored on your MobileMe drive for backups, but you make sure you un-mount/eject the drive before you lose your network connection to prevent the disk image from losing your most recent changes.

So — here’s how to create one of these encrypted disk images.

Mac OS X Disk Utility

Mac OS X Disk Utility

  1. Open Disk Utility (found in /Applications/Utilities/)
  2. Click “New Image” in the toolbar
  3. The “Save As:” field will be the name of the disk image file, so it should be something like “secret.dmg” or “private.dmg.”
  4. The “Volume Name:” is what the name of the disk will be when it’s mounted.
  5. A volume size of 100 MB should be fine if you’re just storing documents–and you can resize the image later if you need to.
  6. Choose Mac OS Extended (Case-sensitive, Journaled)
  7. Choose 256-bit AES encryption
  8. Choose No partition map
  9. Choose read/write disk image
  10. And finally click Create
Settings in Disk Utility to create an encrypted disk image

Settings in Disk Utility to create an encrypted disk image

I’d recommend NOT storing the password in your keychain, so when asked for the password for the disk image, unselect that option, and make sure you remember the password to your new image–because you can’t open it without the password.

Disk Utility will automatically mount the disk image as soon as it’s created. Remember to eject it when you’re done (by right-clicking on the disk image and choosing “Eject”). In the future double-click the image to re-mount it and get access to your secret files again.

java.beans.XMLEncoder Considered Harmful

To all java engineers out there:

Before you even think about using java.beans.XMLEncoder and it’s sibling, XMLDecoder, make sure you verify two things:

Are you OK with your application running single-threaded? XMLEncoding hits a static synchronized helper method. Expect to see blocked threads.

Are you OK with forcing your JVM to process an obscene amount of object garbage? A 1 hour stress test generated more than 1.2 Tb of object garbage. While the stress test was running, the JVM was between 50 and 80% devoted to garbage collection.

After switching to xstream, the GC problems are gone, there aren’t any blocked threads, my whites are whiter, my coat is a whole lot more glossy, and cherubs are flying by with banners that say “Huzzah.”

Make “ps -ef” work in a shell on Mac OS X

If you’re used to SunOS or BSD, you’ll be at home with Mac OS X’s “ps -aux” to get a process list from a shell prompt.

If you’ve been using any other recent unix, though, your fingers will want to type ps -ef instead. Rather than hack an alias to wrap ps to make this happen, it turns out there’s an easy way to return to the ps promised lands.

By default on Mac OS X 10.5.2, the shell environment’s COMMAND_MODE is set to legacy. If you set it to unix2003, you’ll get your ps -ef. Just add

export COMMAND_MODE=unix2003
alias zcat='gunzip -c'

to your ~/.bashrc to make it be set automatically.

The alias of zcat to gunzip -c fixes a “feature” in unix2003 mode — it removes gzip support from zcat. If you’re used to using zcat for both compressed .Z files as well as gzipped .gz files, you want the alias line as a workaround.