George King Nichols


George King Nichols

George King Nichols, September 4, 1925 - September 26, 2013


Walking Through the Next Generation


Part of my current lifestyle hack is walking. We bought a treadmill last year and since early this spring I’ve been walking 5 or 6 days a week on it. I’ve been using Star Trek: The Next Generation episodes as entertainment while I walk. Each episode is 45 minutes long and there are 178 episodes total. At a walking pace of 3 miles per hour I get 2.25 miles in for each episode. I’m almost through season 5 now. By the time I finish the series I’ll have 400 miles accumulated.

Of course then I’ll have to start Deep Space Nine, followed by Voyager and then Enterprise.


How to Delete Your Quarantine Download History


On Mac OS X, Launch Services keeps a list of everything you’ve ever downloaded. Launch services quarantine is what triggers the warning about opening files downloaded from the Internet, consequently it has a list of everything you’ve downloaded.

This command will list all the files in your quarantine list.

sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'select LSQuarantineDataURLString from LSQuarantineEvent'

You should see something that ends up looking like this.

Quarantine image

You can also append | sort to the end of the command to sort the output. And if you are confident with SQL you can write more advanced queries to explore your download history.

To clear your history run this command.

sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'delete from LSQuarantineEvent'


Various Defaults Write Commands


Here are a few interesting defaults write commands that I have applied to my Apple Macintosh computers.

##Finder settings

$ defaults write com.apple.finder AppleShowAllFiles TRUE - show hidden files

This command turns on the display of hidden files in the Finder. This is particularly useful when dealing with so called “dotfiles” or configuration files that are normally hidden.

$ defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES 

This setting causes the full path of the currently displayed directory to be shown in the title bar of the Finder window.

##iTunes settings

$ defaults write com.apple.iTunes allow-half-stars -bool TRUE

With this setting enabled you can click on the rating for a track in iTunes and slide until you have a 1/2 rating.

##Safari settings

$ defaults write com.apple.Safari IncludeDebugMenu 1

Turns the Debug menu on.

$ defaults write com.apple.Safari TargetedClicksCreateTabs -bool TRUE

Enabling this option forces all links that have a target to open in a new tab rather than in a new window.


Recursively Find and Replace a String in All Files


Using an editor it is very easy to find and replace all occurrences of a string within the file you are editing. Some editors even make it relatively easy to find and replace a string in all files within a project or set of files. However when the number of files grows to dozens or hundreds or even thousands, using an editor may not be the most efficient solution.

It is very simple to accomplish the same find and replace on the command line using the Unix find command coupled with the -exec option.

$ cd /path/to/directory/containing/files
$ find . -type f -exec perl -pi -e 's/source/target/g' {} \;

A variation on this command would be

$ find . -type f -exec sed -i 's/source/target/g' {} \;

You could even use xargs for the command.

$ find . -type f | xargs perl -pi -e 's/source/target/g'

If you want to see a list of the files containing either the source or target string, you can use this find command.

$ find . -exec grep -l "source" {} \;

Read the friendly man page for find and grep for more information.


iOS Apps on My Home Screen


With an iPhone 5 you have room for 20 apps on your home screen plus four additional apps in the dock at the bottom of the screen. Like many people (I suspect) I organize my apps such that the most frequently used are on my home screen. Here then are my 20 favorite apps.

##Felix Felix is my app.net client of choice. It’s minimal but full-featured, makes great use of taps and swipes for navigation and feature controls and only costs $2.99.

##Twitterrific Twitterrific has long been my favorite Twitter app, both on iOS and Mac OS. The iOS app already has a flattened appearance so I expect it will continue to look good against iOS 7 when that is released. Like Felix its use of gestures is superb. $2.99 for a limited time.

##Check the Weather Easily my favorite weather app, and I have three or four others installed, Check the Weather packs a lot of usable, readable information into its interface. Best of all it includes the Dark Sky precipitation forecast, which provides real-time rain and snow forecasting that actually works. $3.99 from the App Store.

##Clock I make daily use of Apple’s clock app, especially the alarm feature.

##LoseIt! I reviewed this calorie tracking app once before, and mentioned it along with the next three weight loss apps. It’s a great tool for monitoring your diet and activity. LoseIt! is free.

##WeightBot WeightBot is the slickest weight tracking app I have seen. Fun to use, which makes you more likely to track your weight. Just a $1.99.

##Moves Moves is a pedometer for your iPhone. Once setup you never have to interact with it again — it uses the notification center to keep you updated on your activity level. Moves is a free app.

##FitBit The FitBit iOS app works in conjunction with your FitBit tracker. Bluetooth syncing means you can always see daily steps and sleep record. The app is free, the tracker isn’t.

##[HackerNews][1] [1]: https://itunes.apple.com/us/app/hacker-news/id541355312?mt=8 “Hacker News” There are many, many apps for reading YCombinator’s Hacker News site. None are perfect, but this one is far better than most. Best of all it works on both iPhone and iPad. HackerNews is a free app.

##AlienBlue AlienBlue is a reddit client. As with the Hacker News client above there are many reddit clients to choose from. So far this one best meets my needs.

##[Prismatic][2] [2]: https://itunes.apple.com/us/app/prismatic-always-interesting/id551206444?mt=8 “Prismatic” Prismatic is a aggregation site that lets you choose topics or categories of interest. The site then shows you collected articles and stories based on your choices. The app is nicely minimal if a bit slow to update at times. Prismatic is a free service and the app is free too.

##Find Friends My wife and I make heavy use of this Apple app to know the current location of each other.

##Vesper Vesper is the newest addition to my home screen. It is a very minimal note taking app that just works. Best of all it’s consummately designed and implemented. Vesper is $4.99 in the App Store.

##Fantastical My favorite calendar app is Fantastical. New event creation is quite and easy due to the excellent parsing ability the app has, and the daily display of events is exactly what I need. Fantastical is $4.99.

##Photos I really haven’t looked for any other photo management apps as Apple’s does the job for me.

##Flickr The new Flickr for iPhone app is great. My use of Flickr has increased as a result of this new app. Flickr for iPhone is free.

##Clockwork Clockwork is a metronome app. It has an innovative interface with both audible and visual time indications. A variety of “tic” sounds and the ability to devise complex rhythmic patters round out this excellent tool. Clockwork is $0.99.

##Cleartune Cleartune is a sophisticated musical instrument tuner. Perfect for string players as it can tune in violin temperament or equal termperament. Cleartune is $3.99.

##TE Tuner The Tonal Energy Tuner is a suite of apps designed to complement music education. I like the tuner as it has a vibrant display. Every evening whenI practice cello I use this app to tune my instrument. TE Tuner is $3.99.

##Camera The Apple provided camera app suits my picture taking needs wonderfully. I especially like the panorama option and the ability to take videos as well as still pictures.


Using Vimux With Octopress


Using Vim as your editor with Octopress works well enough except that you have to either exit out of the editor or open a second session in order to generate the site to see your new posting. Using Vimux you can run commands in a separate pane without losing focus in your Vim pane. This turns out to be perfect for creating or editing posts for an Octopress site.

First you need to add the Vimux bundle to your Vim configuration. Since I’m using Vundle I just added this line to my .vimrc file.

Bundle 'benmills/vimux'

And then installed the new bundle.

Bundle 'benmills/vimux'
:BundleInstall

The Vimux help (:h vimux) does a great job of explaining the various commands and options provided by the bundle. Here are the settings I added to my .vimrc.

Bundle 'benmills/vimux'
let g:VimuxHeight = "30"
let g:VimuxOrientation = 'v'
let g:VimuxUseNearestPane = 0

The height setting controls what percentage of your current pane will be given over to the Vimux pane. The orientation settings controls whether the new pane is vertically below the current one (v) or horizontally to the right of it (h). The VimuxUseNearestPane when set to true (1) will use the nearest open tmux pane rather than space within the pane containing your Vim session.

With these settings in place I added some general Vimux mappings.

Bundle 'benmills/vimux'
nmap <leader>vp :VimuxPromptCommand<cr>

This brings up a Command? prompt where you can enter any command your shell recognizes.

Bundle 'benmills/vimux'
nmap <leader>vl :VimuxRunLastCommand<cr>

As the name suggests, VimuxRunLastCommand reissues the last command.

Bundle 'benmills/vimux'
nmap <leader>vq :VimuxCloseRunner<cr>

VimuxCloseRunner closes the Vimux pane.

Bundle 'benmills/vimux'
nmap <leader>vx :VimuxInterruptRunner<cr>

The interrupt runner command halts the command in the runner.

Rather than have to bring up the Vimux command prompt with ,vp and then type in my Octopress generate alias, I created some more mappings with Octopress specific commands.

Bundle 'benmills/vimux'
nmap <leader>vg :call VimuxRunCommand("gen")<CR>
nmap <leader>vi :call VimuxRunCommand("ingen")<CR>
nmap <leader>vz :call VimuxRunCommand("dz")<CR>
namp <leader>vd :call VimuxRunCommand("deploy")<CR>

The first of these, vg runs my alias for rake generate, building what ever is currently in the source/_posts directory. I make heavy use of rake isolate as my site contains over 2,000 entries and takes more than 8 minutes to generate.

Which explains the next mapping, vi. ingen is my alias that runs a rake integrate followed by a rake generate. Typically I only run this command when a new posting has been proofread and is ready to be published.

I have two Octopress sites, one of which is still on an much older version of Octopress. The rake deploy task for this older version doesn’t handle .htaccess files, so my dz alias chains together the commands necessary to rsync my site and copy the .htaccess files into place.

Finally the vd mapping issues my alias for a regular rake deploy which works for my new Octopress site.

Having Vimux in place allows me to work on a new page or posting, generating the site as I go, without losing focus in my Vim session. It has made creating new content for my sites simpler and more satisfying.


How to Display a Neatly Formatted Path


The following function displays your PATH environment variable using color coding and showing each path entry on its own line.

    path() {
      echo $PATH | tr ":" "\n" | \
        awk "{ sub(\"/usr\",   \"$fg_no_bold[green]/usr$reset_color\"); \
               sub(\"/bin\",   \"$fg_no_bold[blue]/bin$reset_color\"); \
               sub(\"/opt\",   \"$fg_no_bold[cyan]/opt$reset_color\"); \
               sub(\"/sbin\",  \"$fg_no_bold[magenta]/sbin$reset_color\"); \
               sub(\"/local\", \"$fg_no_bold[yellow]/local$reset_color\"); \
               sub(\"/.rvm\",  \"$fg_no_bold[red]/.rvm$reset_color\"); \
               print }"
    }
Here’s a sample of the output:

Image of formatted path

I find this function to be particularly useful when dealing with RVM and Homebrew as they are both particular about where in the PATH they occur.


Using Alfred to Lock Your Computer


Any one who has used a Windows computer knows about using the “three-finger” salute — Ctrl-Alt-Delete — brings up a dialog where you can quickly start the screen saver. Provided the screen saver option is configured to require a password the computer can be locked with a minimum of fuss.

Mac OS X doesn’t provide a simple keyboard shortcut to activate the screen saver and lock the computer. On MacBook laptops you can press the power button briefly which brings up a dialog allowing you to Restart, Sleep, or Shutdown the computer. The sleep option can be selected just by pressing the “S” key.

Recently I discovered that Alfred can be used to activate the screen saver. And, just like on Windows, if the screen saver is configured to require a password to wake the computer, you can lock the computer this way.

My Alfred is set up be activated with Cmd-Space. Once the Alfred dialog is displayed typing “sc” is enough to select “Screen Saver” from the list of matches. So, Cmd-Space, “sc”, and then pressing the “Enter” key activate the screen saver. I find this keystroke combination particularly useful on the iMac I have at work, especially when leaving my desk for few minutes.

Oh, and I recommend downloading Alfred from their web site rather then using the Mac App store as the App store version tends to lag behind in releases.


Learning to Touch Type


When I was in high school I took a typing class one semester. Each student had his or her own manual typewriter and we spent each class period learning how to type through a series of rote exercises. If I recall correctly we were allowed only two mistakes per page and we were not allowed to use erasable paper. I got to retype a lot of assignments as it was hard too keep up with the assignments and not make mistakes. My typing speed by the end of the 18 weeks was in the middle 20 range, perhaps 24 or 25 words per minute.

In college I first programmed on card punch machines and later on terminals. Card punch machines are even less forgiving than typing paper – once you make a mistake the entire card is ruined and you have to re-punch it. I tended to punch slowly so as not to make costly mistakes.

After transitioning to terminals where it was possible to backspace and correct errors my keying speed increased but so did my mistakes. I simply learned to back up and fix them. What I should have done was slow down and learn to touch type. While that had been the goal of my high school class, years of bad habits left me with my own rather unique hunt-and-peck typing style.

I type using only the thumb, fore and middle fingers on my right hand and the fore and middle fingers on my left hand. When writing prose I am able to type without looking at the key board. However when I need to type symbols I sometimes need to look to see where the character is located.

Using a couple of different online typing tests, I tested my typing speed this morning. The average works out to 56 words per minute, usually with several errors.

My goal for the next 30 days is to practice typing at least 30 minutes a day using Peter’s Online Typing Course. I like the breakdown of the lessons there. I am not so much interested in increasing my overall typing speed, but will happily take any increase that occurs. What I am interested in is improving my touch typing ability. I’d like to use all eight fingers properly and to be able to type without looking at the keyboard at all.