shinyblog

Monday, February 12, 2007

personal geek security pack

I always carry these items, in a tiny Pelican case in my backpack:

  • Prepaid phone card

  • BARTticket (or the local equivalent)

  • Cash. $20, $50, or $100 is all good, but in twenties or smaller denominations.

  • 4 quarters(Think parking meter.)

  • Duct tape, in a flat "roll"

  • Gu Energy Gel! Food goo with caffeine

  • Painkiller of your choice. I like ibuprofen, but if you've got an extra vicodin sitting around, throw that in too. Most 911 first responders can't give you morphine, you know. So if you live the kind of lifestyle where (say) dislocating your shoulder or dropping a couch on your toe is not unlikely, it'd sure be nice to have real painkillers around. Your mileage may vary!

  • LED Flashlight. I use an Inova

  • USB thumb drive with recovery software for your favorite OS's. The Sony USM-H Micro Vault is 1.5cm x 3cm x 2.7mm.

  • Pocketknife. My dad turned me on to Columbia River Knife and Tool. IMHO, a single tough blade beats the leatherman on weight vs utility and volume vs utility for civilized situations. (I don't go to Borneo much, do you? Although it is a pleasure to answer in the affirmative when someone says, "anybody got pliers?" If this matters to you, put a small pocketknife if in the emergency pack, and carry the leatherman in your pocket.)

  • A lighter. When the power goes out, a flashlight is nice, but I dare you to find a lighter in your apartment in the middle of the night aided only by a flashlight. This item pairs with a stock of candles in a well-known location in your apartment.


Don't keep this in your wallet! One of the use cases for this packet is "I lost my wallet." (Or, more likely, "someone stole my wallet.")
Any suggestions for other things to add?

Sunday, February 11, 2007

nullifying backups

While playing with stickam, I decided to demonstrate how I cook dinner to my huge audience. This involved separating frozen meat patties by banging them on the desk. I stopped this maneuver before completion, because my giant external hard drive, also located on the desk, started to whine. Loudly. After cooking and eating my tasty dinner, I returned to the hard drive. I figured the heads had gotten misaligned. With the power off, I tried tapping it gently. I tried tapping it harder. The whine was still there, and prohibitively loud. I figure the medium is probably compromised but I can use it for storage that can be ephemeral. (Damn it.) Today I turned it on again because my iTunes is setup to download podcasts there, and I needed some fresh podcasts. Hey! Writing data to the disk stopped the whining!
So can I ever rely on this disk again?
[UPDATE] No, I can never rely on this disk again, and I should be punished for entertaining the thought that I could. For that matter, I should never rely on a single point of failure for critical data. Time for me to work on my strongspace setup.

Wednesday, February 07, 2007

handy shell tools for finding large files

Heard over and over in development shops everywhere: "We're out of disk space! Who is the spacehog?" "Not me! It must be your project!" "Let's delete temp files | log files | core dumps | stuff that looks old." I will spare you the lecture on the heartbreak of irreplaceable data loss, and instead I provide a few one-line shell goodies to identify where the disk space is going, with human-readable text reports sufficient for mailing to all your co-workers.
The classic command for analyzing disk usage is
$ du -k
which will print something like this
32 Documents/Standards/sac-1.3/doc/org/w3c/css/sac/helpers
568 Documents/Standards/sac-1.3/doc/org/w3c/css/sac
568 Documents/Standards/sac-1.3/doc/org/w3c/css
568 Documents/Standards/sac-1.3/doc/org/w3c
568 Documents/Standards/sac-1.3/doc/org
That lists the size in kilobytes, followed by the file name. Output like this quickly gets unreadable. We can apply some concepts of information visualization to improve this output. Let's put the most important stuff at the end, by adding a sort command:
$ du -k Documents | sort -n
The last few lines of this list the biggest directories and their size in kilobytes:
80180 Documents/Reference/docs/api/java
82924 Documents/Reference/docs/api/javax
110788 Documents/Speed Download 4
205708 Documents/Reference/docs/api
251800 Documents/Reference/docs
254668 Documents/Reference
434216 Documents
Comparing six-digit numbers at a glance requires brain work. To make it easier, get human-readable output from du, by replacing the -k flag with -h. Now a line of output looks like this:
4.1M Documents/Standards
That breaks our sort, though; sort -n is numeric, and 2M is less than 4K. Wrong. Let's just throw out any du output less than 1 mb. I do that by piping the output through sed. I also want to limit how deep we descend into directories, since directories sizes include the summarry of their children's sizes. On the mac, pass in a -d depth flag; on linux, use --maxdepth=depth.
$ du -h -d 3 . | sed -e /\n*[KB]/d | sort -n
Then to get just the highlights, pipe that through a tail command, to select just the last 30 or so big guys:
$ du -h -d 3 . | sort -n | sed -e /\n*[KB]/d | tail -30
But wait, this is kind of stupid; I'm asking sort to sort a whole lot of stuff, then promptly throwing out most of the sorted things. Let's switch the order of the sed and the sort, which will make the sort smaller and faster.
$ du -h -d 3 . | sed -e /\n*[KB]/d | sort -n | tail -30
Props to Unix Power Tools and Jeffrey Friedl's Mastering Regular Expressions. We're just mortals, here, folks, but we're living in a well-documented world.
On the mac, for an easier way to do this, try OmniDiskSweeper.