Get the first commit of 2012
$ git log --pretty=format:'%H' --after="2011-12-31" | tail -1
d41d8cd98f00b204e9800998ecf8427e
Count the number of commits since then (inclusive)
$ git rev-list d41d8cd98f00b204e9800998ecf8427e^..HEAD | wc -l
44555
Get the first commit of 2012
$ git log --pretty=format:'%H' --after="2011-12-31" | tail -1
d41d8cd98f00b204e9800998ecf8427e
Count the number of commits since then (inclusive)
$ git rev-list d41d8cd98f00b204e9800998ecf8427e^..HEAD | wc -l
44555
When using Git, I find myself doing a lot of what I call "exploratory merging" into a throwaway local branch. This is to preview what a scary merge might look like master, or to isolate a bug in a staging environment by selectively merging in certain of the branches that have been deployed.
The names of my throwaway branches always start with an underscore, so I can easily see them when I git branch
. Below is a Bash one-liner (aliased as git purge
) that deletes unmerged branches whose names start with "_".
[alias]
purge = !git branch --no-merged | tr -d "* " | grep ^_ | xargs git branch -D
Here are some quick notes on installing Graphite on a Vagrant virtual machine using Chef recipes from GitHub. This more or less assumes you know what you're doing with Vagrant and Chef.
$ leggo 3306 | |
Port 3306 is being used by "mysqld" | |
process 66117 | started 4:53PM | up for 0:01.25 | |
/usr/local/Cellar/mysql/5.5.20/bin/mysqld | |
--basedir=/usr/local/Cellar/mysql/5.5.20 | |
--datadir=/usr/local/var/mysql | |
--plugin-dir=/usr/local/Cellar/mysql/5.5.20/lib/plugin |
# Shell out to the fast and reliable `wc` utility. | |
def lines(path) | |
# output of wc (returned by backticks) is formatted like this: | |
# " 111 filename.ext" | |
`wc -l #{path}`.strip.split(' ').first.to_i | |
end | |
# **/* gets all files and directories in all subdirectories. | |
files = Dir["/path/to/directory/**/*"] |
# First, some variables! | |
a, b = %w(foo bar) | |
# Good old-fashioned string interpolation. | |
"#{a} is not #{b}" #=> "foo is not bar" | |
# Today, I learned that this craziness works! | |
"%s is not %s" % [a, b] #=> "foo is not bar" |
For security reasons, many hosting providers restrict external access to the default MySQL port 3306. But if you have SSH access to the database server, you can access the MySQL server from your local machine by using an SSH tunnel. An SSH tunnel forwards bits back & forth between a port on your machine and a port on the remote machine, all lovingly encrypted with SSH.
Here's how you do it! But first, my assumptions:
Here is the Unix command to open an SSH tunnel to hostname_or_ip
with the user account username
mysqldump --no-data -u root -ppw funky_database > funky_database.sql |
var blinking; | |
function startBlinking() { | |
blinking = setInterval(function() { | |
$('.light').toggleClass('on'); | |
}, 750); | |
} | |
function stopBlinking() { | |
clearInterval(blinking); |
words = ["Life", "Liberty", "and", "the", "pursuit", "of", "Happiness"] | |
words.grep(/^[A-Z]/) | |
#=> ["Life", "Liberty", "Happiness"] | |
words.grep(/^([A-Z])/) { $1 } | |
#=> ["L", "L", "H"] |