Tuesday, June 2, 2009

Ergonomic keyboard and multi-button mouse for Mac

I decided to connect my employer-supplied MacBook to external monitor, keyboard and mouse at work. So I plugged in my Microsoft Natural Ergonomic Keyboard 4000 and original Microsoft IntelliMouse Explorer (still using V1, wow, these things last).

Obviously there is a need to remap control, alt and windows keys to correct mac positions (namely, swap alt and windows keys to match option and command keys). Things didn't work out that great: although OS X Leopard keyboard preferences allow to remap keys on per-keyboard basis (I don't want to remap all keyboards to keep MacBook keyboard as it is), settings are lost if you unplug keyboard.

Mouse provided another surprise: back and forward buttons didn't work in Firefox.

Things looked gloom, I considered writing Firefox extension to handle mouse buttons and started googling ergonomic keyboards designed specifically for Mac to replace my current keyboard. To my surprise, this Microsoft keyboard consistently came up in result at the ergonomic keyboard used by many people on Mac. It turns out Microsoft provides driver for both mouse and keyboard!

After installing the driver it recognized both mouse and keyboard, and allowed me to configure all setting to my liking. Command and option keys are swapped, volume up/down keys change the volume, mouse back button works. Microsoft, you surprised me, thank you for making my switch to Mac so much nicer (no pun intended).

Monday, September 29, 2008

Using Duplicity on Windows under Cygwin to backup to Amazon S3

1. Install Cygwin. Since setup.exe on homepage is not updated in awhile and doesn't support -P switch grab latest from http://cygwin.com/setup/snapshots/. Run setup in UI mode to set defaults. Then install missing packages:

setup.exe -q -P python
setup.exe -q -P gnupg
setup.exe -q -P gcc
setup.exe -q -P joe #or your other favorite editor, Windows editors produce \r and cygwin bash doesn't like it
setup.exe -q -P librsync-devel
setup.exe -q -P librsync1
setup.exe -q -P wget

There is some magic way to put all packages into one line which I didn't care to master.

(start Cygwin bash shell)

2. Install GnuPGInterface Python module
(download .tar.gz, gunzip, tar -xvf, python setup.py install)

3. Install boto
(same as above)

4. Install Duplicity
(same as above)

5. Start your favorite Unix editor your installed in step 1 and hack away:

#S3 account id
#S3 account access key
#gnupg password for symmetric encryption
export PASSPHRASE=some_password
export TMPDIR=/tmp

duplicity --full-if-older-than 6D --time-separator=. --archive-dir /home/Serge/dup /home/Serge/docs s3+http://uniqued-backet-name


This script forces full backup every week, so if you run it daily you get daily incremental backups and full one every week. I recommend this option for important documents relatively small in size. For photos or something large it's better to do full backup rarely to save bandwidth and S3 costs. For example for 90 days change 6D to 90D.

You may notice that TMPDIR needs to be set explicitly, otherwise python gets confused and goes to Windows temp dir.

Cygwin bash doesn't like default duplicity time separator, hence the option to change it to dot.

--archive-dir is used by duplicity to keep local copy of hashes, it's optional, but makes backup faster and uses less bandwidth.

Bucket name needs to be unique across all buckets for all accounts at Amazon, so you need to come up with something creative.

You need to schedule this script to be run periodically. Cygwin cron or NT at.exe can do the job.

You may notice that I used symmetric encryption for backup files. Some people like to use public/private key combination. The problem with this approach is that you need to backup your private key. This is a non-trivial task by itself, if you don't do it right, then in the case of real catastrophic events you may end up with the S3 backup you can't decrypt. My approach is to use symmetric encryption and choose reasonably long and complex key I still can remember.