Portable encrypted backups

To keep track of the ever-growing array of passwords and private data, I use 1Password, which I could not recommend more.

There’s a problem though: what if I lose access to my database? I’ve toyed with a few options in the past, including uploading it to Dropbox or Google Drive, but these are services for which I’ve enabled multi-factor authentication, and require internet access.

For a few years now, Macbook Pros have included an SD slot for photographers. Or, as it turns out, everybody!

I bought a Transcend SD card with a decently-useful 16GB capacity for about $10. As of OS X 10.8, you can format any disk to be encrypted. Match made in heaven.

Going from the stock card to an encrypted version is easy, but does involve making the disk Mac-only:

  1. Launch Disk Utility from /Applications/Utilities
  2. Select the SD card from the source list and choose “Partition.”
  3. When repartitioning the drive, choose “Options…” and format using GPT.
  4. Erase the newly-created partition with the “Mac OS Extended (Journaled, Encrypted)” option.

With a tiny, portable, encrypted disk, there’s a lot of cool things you can back up. I currently save:

  • My 1Password and system keychains.
  • The database for Authy, which is like Google Authenticator, backed up via iExplorer.
  • Copies of my source code repositories.
  • Public and private SSH keys.

I’ll find more uses as time goes on. Right now it’s a manual process to update, but this is more of an emergency backup: I use Arq for my normal backup needs.

Getting into fantasy

Science fiction has always been my favorite genre. I enjoy imagining possible futures and I’ve never stopped wondering what changes may happen in my lifetime.

The mysterious worlds of the future always held such potential that I rarely strayed from the genre. I started reading simple novels by Isaac Asimov and grew into reading hard sci-fi like Alastair Reynolds where the thick story and technology are enrapturing.

Fantasy is similar, but different. Instead of imagining the future, you’re compelled to imagine something potentially in parallel. It could be our past, our future, or another world entirely, with any kind of supernatural circumstances.

Continue reading “Getting into fantasy”

Custom Kindle Paperwhite fonts

I thought jailbreaking would be required to install custom fonts on the Kindle Paperwhite, but a recent Kindle firmware update silently added support for accessing custom fonts.

This writeup walks through installing custom fonts on a few devices. A few simple steps will get you through it:

  1. Mount the Paperwhite.
  2. Create the file USE_ALT_FONTS in the mounted volume.
  3. Create the folder fonts in the mounted volume, and add fonts consisting of all the following (where Font is the name of your font):
    • Font-Regular.ttf (.otf is also supported for the files)
    • Font-Bold.ttf
    • Font-Italic.ttf
    • Font-BoldItalic.ttf
  4. Restart the device (Hamburger > Settings > Hamburger > Restart)
  5. You may need to clear the font cache by searching on the home screen for ;fc-cache and then restarting.

You can find your Mac’s fonts in one of a few places:

  • /System/Library/Fonts
  • /Library/Fonts
  • ~/Library/Fonts

Although I love reading in Georgia, it doesn’t render wonderfully on the Paperwhite, so the hunt is on for better typography.

Samuel Taylor Coleridge (via Contact):

It is not impossible that to some infinitely superior being the whole universe may be as one plain, the distance between planet and planet being only the pores in a grain of sand, and the spaces between system and system no greater than the intervals between one grain and the grain adjacent.

Preventing Rdio from using discrete graphics

Rdio requires the discrete graphics card on systems which support dynamic switching. This is annoying, since playing audio shouldn’t require intense graphics.

To get around this limitation, we can update the Rdio app’s Info.plist to inform the system that it supports the integrated card. We can accomplish this with the following command:

defaults write /Applications/Rdio.app/Contents/Info.plist NSSupportsAutomaticGraphicsSwitching -bool YES

To revert back to forcing the discrete card, we can remove the key:

defaults delete /Applications/Rdio.app/Contents/Info.plist NSSupportsAutomaticGraphicsSwitching

Incidentally, gfxCardStatus is an excellent tool for monitoring graphics card changes and manually switching between cards.

Incrementing with a bitmask

Bitmasks are fun. There’s lots of little tricks you can do with them. A common situation is checking for the presence of a flag among elements in a linked list, or some similar data structure. I came across a trick a few years ago that makes it drop-dead simple.

Let’s say we needed to check for AUsefulFlag in the flags element of each node, and total how many elements in the linked list had the flag.

uint64_t count = 0;
for(Node *iter = head; iter != NULL; iter = iter->next)
{
    count += !!(iter->flags & AUsefulFlag);
}

After execution, count is the number of items which have AUsefulFlag set.

Double-not (!!) is one of those useful operations which are especially useful with bitmasks. It may require a double-take at first, but it behaves exactly how you’d think.

!! of 1 is 1. !! of 0 is 0. In fact, !! of any true value evaluates to 1, so we can use it to transform something like 0b00001000 to simply 1 and increment by that value.

From Atlas Shrugged​ by Ayn Rand:

James: What are you after?
Francisco: Money.
James: Don’t you have enough?
Francisco: In his lifetime, every one of my ancestors raised the production of d’Anconia Copper by about ten per cent. I intend to raise it by one hundred.
James: What for?
Francisco: When I die, I hope to go to heaven–whatever the hell that is–and I want to be able to afford the price of admission.
James: Virtue is the price of admission.
Francisco: That’s what I mean, James. So I want to be prepared to claim the greatest virtue of all–that I was a man who made money.
James: Any grafter can make money.
Francisco: James, you ought to discover some day that words have an exact meaning.