November 2010

Cowboy Christmas 2010 comes to Las Vegas

Thanksgiving is past and Christmas is just a few weeks away which means Las Vegas turns into the city of the National Finals Rodeo. Whether you have tickets for the rodeo or just want to do some shopping Cowboy Christmas is one of the best times you can have in Las Vegas. Contrary to what the ads say this part of what happens in Vegas doesn't stay in Vegas.

Even if you're not going to make it to Las Vegas this go-round you can follow the action from the NFR list on Twitter.

Here's a round-up of the various major gift-shows and sales going on:

Thankful

ThanksgivingThis past weekend was the annual American celebration of the Thanksgiving holiday. I was quite fortunate to spend the early part of last week with a recent immigrant celebrating their first Thanksgiving. Seeing this uniquely American holiday through fresh eyes was a wonderful experience. The weekend also provided a break to think about the fantastic opportunities and experiences that brought us so far.

Nothing can compare to the feeling of being asked each night to rock one's little ones to sleep. Knowing in some intellectual way that these days won't last forever makes the heart desire to squeeze every extra moment out of these quiet times.

Scrubbing Drupal databases for development

A couple of weeks ago I delivered a webinar on how to manage the process of moving Drupal websites from development to staging and production. The presentation gives an overview of the process including a few key points for the key pieces. Here are the key points:

  • Manage sites in code (keep configuration and updates in code)
  • Have an effective version control system
  • Test, test and run more Tests

In the presentation I covered a pair of scripts that form the basis of creating a scrubbed database for use on development machines. This is a good practice for several reasons including making sure that a development server doesn't send emails or data to Google Analytics for example.

The first piece is a shell script like this:

#!/bin/bash
# Use as ./sql_scrub_dump.sh local_db_user local_db_pass dump_file.gz

# Creates a scrubbed version of a database dump using the local database defined below as the intermediary.
# note: the dump file will be gzip compressed, as will te resulting file.

local_db=6000_temp_scrub

function db_query() {
    sql=${1}
    mysql -u${local_user} -p${local_pass} -e "$sql" ${local_db}
}

local_user=${1}
local_pass=${2}
dump_file=${3}
new_dump_file=scrubbed-${3}

mysql -u${1} -p${2} -e "DROP DATABASE IF EXISTS $local_db"
mysql -u${1} -p${2} -e "CREATE DATABASE $local_db"
gunzip -c $dump_file | mysql -u${1} -p${2} $local_db

mysql -u${1} -p${2} $local_db < scrub.sql
mysql -u${1} -p${2} $local_db < live_to_dev_scrub.sql

# Here we make sure that all the tables are InnoDB.

mysql -u${1} -p${2} -e "SHOW TABLES" $local_db \
  | grep --invert-match '^Tables' \
  | sed -e 's/\(.*\)/ALTER TABLE `\1` ENGINE = innodb;/' \
  | mysql -u${1} -p${2} $local_db

# Dump the scrubbed version and drop the temporary DB.

mysqldump -u${1} -p${2} $local_db | gzip > $new_dump_file
mysql -u${1} -p${2} -e "DROP DATABASE IF EXISTS $local_db"

If you look through what this shell script does it dumps a copy of the database and creates a new database from that dump. In the new, temporary, copy of the database transformations are performed to clean up the data. The cleaning actually happens in this line:

Photographing the White House

Last week brought a great Open for Questions session with Pete Souza the White House photographer. It is one of my favorite sorts of pieces giving a nice look into what working at a place as unique as the White House and how still images can do so much to show the human side of what such a revered place.

So here's a look at this great talk: