I bet Nikon and Seagate could totally team up and pull a Gillette. (razor : blades :: camera : harddrive space for all these huge RAW files)
A really good explanation of lots of the changes in HTML5
Copy a dir (c’pressed) via ssh w/o having to make an intermediate tar file: `ssh REMOTE tar cfz - /path/to/copy | tar zxvf -` #commandlinefu
Is there a more concise and idiomatic way to write the following code, which is used to specify default values for optional parameters (in the params/options hash) to a method?
def...
Delete last commit in Git
First, set up this alias:
$ git config --global alias.delete-last-commit "rebase --onto HEAD^ HEAD"
Then you can just do:
$ git delete-last-commit
Since this is actually doing a rebase, the standard cautions apply about not messing with commits you’ve already pushed to a remote. But, for local commits this is quite handy.
I often use this when I realize I’ve been doing work on the wrong branch. For example, if I just made a commit on master that should have been the start of a new topic branch, I do just this:
$ git branch new-topic # creates the new topic branch here, but don't switch to it
$ git delete-last-commit # move master back to where it belongs
$ git checkout new-topic
$ <continue work on new-topic>
And, a nice thing about git is that if you can actually still get the commit back using reflog, if you really need to.
Handy bash commands
I was touching up my bash profile this morning, and thought I’d share a few commands I find useful.
Local Locates: Search for filenames in a given directory tree
I think of these like slocate, but they work in just a specific directory, and don’t rely on the always-out-of-date-every-time-you-really-need-it slocate database.
I have two varieties. The first uses Spotlight, and is generally quicker, but less flexible in that it doesn’t allow for regexes.
llocate () {
if [[ $# = 0 ]]; then
echo
echo "Search for filenames using Spotlight."
echo
echo "usage: $FUNCNAME MATCH_STR [START_DIR]"
echo " MATCH_STR String (not regex) to match in the filename (not in full path)"
echo " START_DIR The dir in which to look (default = CWD)"
return 0
elif [[ $# = 1 ]]; then
startDir='.'
else
startDir="$2"
fi
mdfind -onlyin ${startDir} -name $1 | sort
}
The other uses find and grep, and is nice because it allows for regexes, and also works on Linux. You have to manually exclude scm dirs here, whereas Spotlight ignores hidden files and directories by default, so you don’t have to worry about that in llocate. However, if you are actually looking for hidden files, then you’ll need to use this command.
rlocate () {
if [[ $# = 0 ]]; then
echo
echo "Search for filenames using find + grep (allowing regex)."
echo
echo "usage: $FUNCNAME PATTERN [START_DIR]"
echo " PATTERN Regex to find (matching anywhere in the relative path)"
echo " START_DIR The dir in which to look (default = CWD)"
return 2
elif [[ $# = 1 ]]; then
startDir='.'
else
startDir="$2"
fi
find "${startDir}" \! -path "*/.svn/*" \! -path "*/.git/*" | `which grep` -i "$1"
}
Temporarily Disable Shell Commands
Sometimes you want to temporarily disable a command. For example, if you’re using a computer with an new version of svn, and are in a directory that has an old working copy, and you don’t want to accidentally do a svn status and have it upgrade the working-copy format (thus breaking it for your other computer that is stuck on an old version of svn). With this, you can simply do: disable svn, and then later do enable svn later to get it back.
disable () {
alias $1="echo \"error: $1 is disabled\"; false" # return non-zero exit when it's called
echo "$1 disabled"
}
enable () {
unalias $1
echo "$1 enabled"
}
After a few weeks off, today’s run was limited not by shin splints but by the rest of me struggling through vaguely familiar torture. Yay?
Lesson learned: When a full-face helmet and leather jacket prompts a “How long have you been riding?”, they’re not envisionig a scooter.
Question: What color shirt would one wear to an Angels vs. Red Sox game? (i.e. which guy in red do high five and which do you punch?)
