As Good As We Can Be


Today’s announcement that President Barack Obama has been named the 2009 Nobel Peace Prize winner no doubt shocked many people, including President Obama. In a way this award is borrowed from the future. It represents what I hope will be the Obama administration’s legacy.

When I was active in the dojo we used to tell karate-ka something when they had been awarded a new rank. We used to say, “this rank does not represent how good you are but rather how good you can be.”

Mr. Obama, the Nobel prize represents our hope, America’s hope, the world’s hope, that you can be that good. That you can create an atmosphere of openness and cooperation and brotherhood in America and across the world. You presented yourself on the American politica stage and said, “I can lead. I can make a difference to America and the world.” America heard you and has given you the chance to lead. The world has heard you and is waiting for you to mend old ills and forge new beginnings.

The Nobel Peace prize is the world’s way of saying, “We, too, believe. We, too, want hope, want change, want peace.”

This prize is not how good you are or have been until now. This prize is how good we hope, and need, you to be.


Managing ssh keys


Earlier this evening, while not paying close enough attention to what I was doing, I managed to delete some semi-important files on my desktop at work. The error happened because I was remotely logged in via the command line and wasn’t paying attention to which machine I was actually working against. My error is recoverable but it gives me new respect for the working environment system administrators live in day in and day out.

The files I deleted where the public and private key pair that uniquely identify my work desktop, and the list of public keys my work desktop has added to its authorized keys list. No real harm done except that now when I try to remotely login to that computer I have to enter the password. I decided to start over and document the process so I can perform it again in the future, if need be.

Step One

Generate a key pair on each machine you regularly use. In my case I have two work computers, a desktop called Palantir and a laptop called Orthanc, and two personal computers, both laptops, called Eeyore and Tigger. On Unix based systems run the ssh-keygen command to create a new public and private key pair. Like this:

$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/mhn/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/mhn/.ssh/id_rsa.
Your public key has been saved in /Users/mhn/.ssh/id_rsa.pub.
The id_rsa file is my identification and private key. The id_rsa.pub file is my public key. In order to make copying the public key to other machines easier I made a copy of the id_rsa.pub file on each machine, using the machine’s name as a unique identifier.
$ cp id_rsa.pub machineName.pub

Step Two

Next I copied the public keys from each machine into a folder in my Dropbox:

$ cp .pub ~/Dropbox/public_keys/
Since I can access my Dropbox from all of my machines, and since the key files are named for the machine they represent, this is a elegant way to house them centrally. You could also use scp (secure copy) to accomplish the same thing:
$ scp machineName.pub you@othermahince.com:~/.ssh

Step Three

Once you have the key files on the remote machine or in  your Dropbox, ssh (secure shell) into that machine and change to the .ssh directory.

$ ssh you@remoteMachine.com
Password:
$ cd .ssh
Make sure the authorized_keys file exists in the .ssh directory using the touch command.
$ touch authorized_keys
Concatenate the public key from the other machine to the authorized_keys file,
$ cat machineName.pub >> authorized_keys
Repeat the concatenation for each machine you want access this computer from remotely.

Step Four

There is no step four. You’re done.

Step Five

I also used the named public key files to allow password-less access to my bitbucket account.

NB: These steps worked for me. You should probably read more about ssh keys, scp, and ssh before attempting to follow them. Especially if you’ve never done this before.


Suggestions, please


Like a lot of bloggers I tend to write erratically and about topics that are of interest to me. Sometimes my topics strike a chord with the blog reading public and I generate lots of page views and gain new regular readers. Toward that end I am experimenting with a suggestion service.

Click on the “Suggestions?” tab which is hopefully visibly at the bottom left of my site, and fill in the form with any topic that you’d like me to write about. I can’t guarantee that I’ll write about every suggestion I receive, but I will write about those that seem to be popular or that strike a chord with me.

For those of you who are interested, I’m using Skribit to provide this suggestion service.


Deleting Email Accounts


My first Internet email account was with AOL around March 1993. This was soon followed by an Internet Service Provider (ISP) account in late 1994. In February 1996 I acquired this domain and had my first domain email address. I still have that address, although I don’t use it actively any more. Like a lot of Internet nerds I have been collecting email accounts ever since.

Between Hotmail, Yahoo! Mail, and Gmail, and several domains, I think I’ve had as many as 11 or 12 accounts active at one time, not counting various employer supplied accounts. The oldest of these dates back to 1996 and it was heavily used for USENET postings, and appeared proudly in my email signature for years, before doing that was a guaranteed way to increase your incoming spam numbers.

It saddens me in a way that the three oldest active email accounts I have, all belonging to this domain, get nothing but spam these days. Thousands and thousands of spams each day. When Google Mail started allowing you to read other accounts I set up a proxy account with GMail that reads these three old accounts, and I consume the proxy account via IMAP. It’s been a couple of years since I set the proxy up, with the intention of monitoring the old accounts for someone who hadn’t gotten the message about my GMail address.

In the past week the number of spam has suddenly increased dramatically, and I am ready to throw in the towel. I am ready to delete the oldest of my email accounts. Which is surprisingly hard to do. I own the domain and can always recreate them, but, like having a domain that will be 14 years old in a few months, having an email address that is that old pleases me. I feel bad enough for having abandoned it to the vagaries of spam for so long, deleting it now feels like adding insult to injury.

Still, it must be done. The torrent of spam isn’t going to stop and I’m ready to have much less of it in my life. GMail hides spam away without my having to do anything, deleting these accounts frees me from having to keep the digital dikes shored up and functioning. Not only will I reduce the influx of negativity into my life, I’ll reduce the amount of time and effort spent wading around in that muck.


Installing PostgreSQL on Mac 10.6 (Snow Leopard)


These steps will install PostgreSQL in /usr/local.

To stop a server running in the background you can type:

/usr/local/pgsql/bin/pg_ctl stop
Now you can create a database. Make sure you are operating as the postgres user, and issue the createdb command.
$ su postgres
Password:
bash-3.2$ cd
bash-3.2$ pwd
/usr/local/pgsql
bash-3.2$ createdb testdb
bash-3.2$
Connect to the database, and start experimenting with SQL commands.
bash-3.2$ psql testdb
psql (8.4.0)
Type "help" for help.

testdb=#

The postgres user account will appear in the fast user switching (FUS) list and as an account on the login screen. To hide the account on the login screen run the following command:

To unhide all accounts:


Using CRON to Control TimeMachine Backups


My office setup includes two Macintosh computers, a Mac Pro and a MacBook Pro. I have a 500 GB FireWire drive attached to the Mac Pro that I use for TimeMachine backups. Through the power of a DNS entry for the Mac Pro, and this article on Network Time Machine backups to another Mac, I am able to backup the MacBook Pro, wirelessly, to the TimeMachine drive on the Mac Pro.

The only problem with this arrangement is that the MacBook Pro attempts to back itself up regardless of my location. When I’m at home at it is connected to our home network it can locate my work computer (via the DNS entry) and it tries to use our less-than-significant upload bandwidth to backup once an hour. The simple solution is to turn TimeMachine off when I am at home. Of course that means remembering to turn it back on again the next day I’m at work. On occasion the simple solution has meant the MacBook Pros backups are a week or more behind.

A better solution would be a script or automated action that would turn TimeMachine on or off. Since I work relatively stable hours a cron job coupled with code to activate or deactivate TimeMachine would suffice.

You can turn TimeMachine on or off via Terminal using this defaults command:

defaults write /Library/Preferences/com.apple.TimeMachine AutoBackup -boolean [YES|NO]
I created two bash scripts, one to turn TimeMachine on:
#!/bin/bash
defaults write /Library/Preferences/com.apple.TimeMachine AutoBackup -boolean YES
And another to turn it off:
#!/bin/bash
defaults write /Library/Preferences/com.apple.TimeMachine AutoBackup -boolean NO
The final step is to create two cron entries, one for 8 am Monday through Friday to run the “on” script from above. And the second for 5 pm Monday through Friday to run the “off” script from above. Crontab entries are in this order: minute hour day-of-month month day-of-week what-to-do. The day-of-week entry uses either 0 or 7 for Sunday, with Monday as 1, Tuesday as 2, and so forth. So the “on” script entry would look like this: 0 8 * * 1-5 ~/bin/timeMachineon.sh and the “off” script entry would look like this: 0 8 * * 1-5 ~/bin/timeMachineoff.sh.

Here’s my completed crontab:

# minute hour day-of-month month day-of-week what

# activate TimeMachine zero minutes past 8 am M-F
0 8 * * 1-5 ~/bin/timeMachineon.sh

# deactivate TimeMachine zero minutes past 5 pm (17) M-F
0 17 * * 1-5 ~/bin/timeMachineoff.sh
Now TimeMachine only runs during working hours when I am (presumably) on the work network.

Update 1: The evening cron job fails to run when the laptop is closed, i.e., sleeping, when 5 pm rolls around. Cron is a useful tool but it has to be awake to run. I’ve changed the evening cron time to 4 pm, a time I am almost always still at work. I am considering adding a second evening crontab entry, say for 7 or 8 pm in case the 4 o’clock instance is missed for some reason. A better solution would be a network aware triggering of the scripts, running the on script only when the work network is detected, and the off script for all other networks.

Update 2: Here’s the latest solution, based on Josh’s comments.

I created a script called login-hook.sh, which is the target of:

sudo defaults write com.apple.loginwindow LoginHook ~/bin/login-hook.sh
This script tests to see if a TimeMachine control script is running at every login, and starts it if necessary:
#!/bin/bash
# login-hook.sh

if [ "$(ps ax | grep tm-control.sh | grep -vc grep)" -lt 1 ]; then
    sudo -u mhn /Users/mhn/bin/tm-control.sh &
fi
And tm-control.sh runs the Python script Josh supplied every 30 minutes (1800 seconds), in effect simulating a cron job, but leveraging the network awareness of the Python script. Here’s tm-control.sh:
#!/bin/bash
# tm-control.sh

while [ 1 ]; do
    python ~/bin/TM_off_on.py
    sleep 1800
done
Update 3: Getting LoginHook to work is a bit finicky. By using defaults read com.apple.loginwindow LoginHook, you can display the current setting, if any, this attribute has. defaults delete com.apple.loginwindow LoginHook will allow you to remove the setting. Make sure you have your login-hook.sh, and the script it calls in place prior to establishing the hook and you should be okay.


Ausfahrt Freihalten!


In German, Ausfahrt freihalten! means “no parking here!” You see these little signs on garage doors and buildings to warn people from blocking a driveway.

{{ $image := .ResourceGetMatch “2833801044_11cca7531f.jpg” }}

Since moving to Manhattan in January our garage has been too full of boxes to hold a car. Gradually over the seven and a half months we’ve lived here, boxes have been emptied or repacked and combined to take less space. All, or nearly all, of our books are now inside; and we’ve given away some things. The largest objects left in the garage were a kitchen table, a dining room table, and a table made from a door and two metal filing cabinets. One night this week it occurred to me that with some rearranging I could use the door table, and the kitchen table as shelves, and absorb their size functionally. Yesterday morning I put my idea to the test and it worked.

{{ $image := .ResourceGetMatch “2833801044_11cca7531f.jpg” }}

So, we now need a Ausfahrt freihalten! sign on our garage door, as the car is now safely tucked inside.


A Sense of Humor


In addition to great customer service, and fantastically fast shipping, Zappos, it seems, has a sense of humor.

I’ve been wearing my new Timberland shoes indoors only since they are a little tighter than I’d like, and I want to be able to exchange them for the next size larger if necessary. Consequently I swap them with my old shoes at the start and end of each day, and before and after lunch. Toward that end I twittered this yesterday afternoon:


August 12


In any relationship there are dates of significance. Today, August 12, is one such date for Sibylle and I. Three years ago today we met in person for the first time. We had been introduced to each other on eHarmony nineteen days earlier and had already traded well over a hundred emails.

Six months ago today we were married in a quiet, private ceremony.

Both of us are introverts and therefore found the idea of a date terrifying. We had talked about just being in the same place at the same time. Perhaps a bookstore or coffee shop. We could sit together or apart, read or talk or just be together quietly. As it happened our first meeting was in a concourse at the Kansas City International Airport. We sat together and walked. We were quiet, and we talked. We held hands and she gently rested her head on my shoulder.

We have been together ever since.

Happy anniversary, Sibylle, I love you.


Zappos Rocks


Yesterday afternoon, about 1:30 Central time, I ordered a pair of shoes from Zappos.com. The are famous for their customer service, and free shipping plus free returns. Last night I got an email from them stating that my order, while made with the free shipping option, was being bumped up to a faster shipping option.

Today, while at home for lunch, the UPS man appeared, banged on the door twice and left. Sitting on the porch was a Zappos box.

My new shoes were delivered in less than 24 hours, closer to 22 hours actually. Amazing.

Lets hope that this kind of service continues under the new Amazon management, and that some of this kind of shipping goodness spreads from Zappos to Amazon.