Automatically Compress/Sync Your S3 Hosted Static Website

For those of you that use Amazon Web Services (AWS) Simple Storage Service (S3), you might find yourself wondering how to serve gzip compressed files for better performance. While the instructions available online work well, manually compressing, renaming and editing metadata of all your hosted files can be super tedious; let’s see what we can do about that.

In order to setup, we’re going to need to have installed and configured s3cmd. For OS X users, this is available via Homebrew with simply  brew update && brew install s3cmd && s3cmd --configure .

Once that’s setup, we’re pretty much ready to write the script.

I saved this as a script called  gzsync and put it in my scripts directory (part of my $PATH , chmod a+x ~/.bin/gzsync ).

Now, say we’re in our static website directory that we want to upload to S3.

This would be a clever git post-receive hook to automatically deploy our site, but we’ll save that for next time. For CloudFront users, this would be a good time to invalidate your distribution. We can actually script this, and if you would like to contribute this, that would be great!

If you would like to make any modifications to the script and recontribute them, I have put this up as a GitHub gist.

Sync Google Contacts on Mac OS X with Two Factor Authentication

So you want to synchronize your Google contacts with the contacts in Mac OS X, but you have done the smart thing and enabled two factor authentication for your Google account. Not a problem, here’s how to do it.

Open up and go to Contacts > Preferences… (⌘-,) and go to Accounts, there you will see “On My Mac” as an account option.


Click the “Configure…” button, and you will be prompted for your Google account and password. This is where the two factor authentication trick comes into play.

Visit the Google two factor authentication settings page and scroll down to Application-specific passwords. There you will need to supply a meaningful name to your new key (e.g. “Mac OS X Contacts Sync”) and click Generate password. This will create a random string of characters that you will then copy and paste as your password into the preferences screen.

Once you fill that in, proceed with the prompt on the preferences screen. You should see a symbol in your task bar now which only the option “Sync now”. This will pull all your contacts from your Google account, and you’re set, securely!

Make Desktop Background from Screensaver Defaults in Mac OS X

There are photos in the Mac OS X screensaver that are nicer than those in the default desktop background choices. Naturally, one might want those nice National Geographic photos as their desktop background, and it’s pretty simple to get at them.

Open up the Terminal, and type in the following:

Then just navigate to Change Desktop Background… and add the Wallpapers folder in your Pictures directory.

Change desktop background screenshot