ck's Weblog: Everything, Misrepresented


Now Playing:

Bash on Ubuntu on Windows

Thursday, March 23 2017

I've been playing with Bash on Ubuntu on Windows and it's pretty cool. Microsoft has written a shim layer to translate between Linux and Windows kernel API calls, so native Linux binaries can run within Windows.

A few tips for anyone getting started:

  1. Add umask 0022 (or even better, 0027) to your .bashrc -- the Ubuntu environment defaults to umask 0000 and that's not cool.
  2. Git can't interact with HTTPS repos. As far as I can tell, the Ubuntu maintainers have known it's broken for four years and have elected to continue shipping broken software as a way to protest OpenSSL using a different open source license. The recommended workaround appears to be to build your own package linked against a working crypto library. I don't like that.
  3. The version of awscli provided through apt is way out of date, but installing the current version with pip in a virtualenv works just fine.

[Update] I shouldn't be surprised that the git issue has had a community fix for years.


Thanks Obama

Friday, January 20 2017

Seriously, thank you.


NBA Jam Glory Days

Thursday, August 11 2016

Back in 1995, I won a Nintendo Power contest for biggest blowout with the rookie team in NBA Jam: Tournament Edition on the Super Nintendo:

Nintendo Power volume 74 page 101

There was a fair bit of strategy and planning that went into my high score, since NBA Jam has a lot of (legal to use) options and codes that can be combined in interesting ways. I think it's finally safe to share my strategy:


  1. Time Speed: 1 (slowest/longest game)
  2. Drone Difficulty: 1 (easiest opponents)
  3. Hot Spots: On (making shots from randomly-placed circles gives 4-8 points)


  1. Dunk from Anywhere (specifically, dunk from hot spots)
  2. Super Shoves (opponents always drop the ball when pushed)
  3. Prince Charles (secret players can't be injured, which otherwise slows you down)

With those in place, the game was pretty tedious. I'd run to the hot spot, dunk for extra points, then shove the opponent as soon as they received the inbound pass, pick up the ball, and dunk from the next hot spot. Sometimes I'd miss the shove and let the computer score quickly. Repeat until time expires.

Bonus trivia: the game's stats counters max out at 255.


Multi-Cloud Database Backups

Tuesday, August 9 2016

It's been two years since the last script and I've read the docs on how to use highlight.js, so I may as well share the new version of my database backups. This one encrypts the backups and keeps a copy in Google Drive as well as Amazon S3.


DATE=`date --iso-8601`
DAYOFWEEK=`date +%u`
TMPDIR=`mktemp -d`


# Parent directory IDs for Google Drive.

for DB in `mysql -ss -e 'SHOW DATABASES' | grep -v _schema`; do
        mysqldump --events ${DB} | xz - | gpg -r <redacted> --encrypt - > ${FILE}

        # Copy this backup the clouds for durable external storage.
        aws s3 cp ${FILE} ${S3_PATH}/nightly/ > /dev/null
        gdrive upload --parent ${DRIVE_NIGHTLY} ${FILE} > /dev/null

        # If it's Sunday, do a weekly backup as well.
        if [ $DAYOFWEEK = 7 ]; then
                aws s3 cp ${FILE} ${S3_PATH}/weekly/ > /dev/null
                gdrive upload --parent ${DRIVE_WEEKLY} ${FILE} > /dev/null

        rm ${FILE}

rmdir ${TMPDIR}

# The S3 backups get cleaned out automatically by lifecycle scripts. Google
# Drive needs that to be done manually. Nightly backups have a two-week
# retention period.
DELETE_DATE=`date --rfc-3339='seconds' --date='2 weeks ago' | sed -e 's/ /T/'`
for ID in `gdrive list -q "'${DRIVE_NIGHTLY}' in parents and modifiedTime < '${DELETE_DATE}'" | tail -n +2 | awk '{print $1}'`; do
	gdrive delete ${ID} > /dev/null
# Weekly backups can stay around for a year.
DELETE_DATE=`date --rfc-3339='seconds' --date='1 year ago' | sed -e 's/ /T/'`
for ID in `gdrive list -q "'${DRIVE_WEEKLY}' in parents and modifiedTime < '${DELETE_DATE}'" | tail -n +2 | awk '{print $1}'`; do
	gdrive delete ${ID} > /dev/null



Wednesday, August 3 2016

It's been 12 years, 4 months, and 18 days since we bought a house. As of today, we own it.


Copyright © 2001-2017 Chris Kuehn