Skip to content

Instantly share code, notes, and snippets.

@mazuhl
mazuhl / gist:2965652
Created June 21, 2012 13:09
Cut columns from file, reorder and show only unique values
cut -d ',' -f11,9 file.txt | ruby -ne 'puts $_.split(",")[1].chomp + "," + $_.split(",")[0].chomp' | sort | uniq
@mazuhl
mazuhl / gist:2871038
Created June 4, 2012 21:46
Make a fullscreen, decent-sized browser window on iPhone
<meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>
@mazuhl
mazuhl / gist:2851284
Created June 1, 2012 11:12
Archive and remove files older than X days
cd /your/directory
/usr/bin/find *.csv -mtime +7 | gzip > /your/directory/backups/files_`date "+%Y-%m-%d"`.gz
/usr/bin/find *.csv -mtime +7 -delete
@mazuhl
mazuhl / gist:2710607
Created May 16, 2012 14:07
Git - get files deleted since specific tag
git log v1.0.9.. --pretty='format:' --name-status | grep -e ^[D][[:space:]] | cut -c 3-
@mazuhl
mazuhl / gist:2710595
Created May 16, 2012 14:06
Git - get second most recent tag
git for-each-ref --format='%(taggerdate:iso8601) %(refname:short)' refs/tags | grep -v '^ ' | sort | cut -d ' ' -f4- | tail -2 | head -1
@mazuhl
mazuhl / gist:2710590
Created May 16, 2012 14:06
Git - get tags in chronological order
git for-each-ref --format='%(taggerdate:iso8601) %(refname:short)' refs/tags | grep -v '^ ' | sort | cut -d ' ' -f4-
@mazuhl
mazuhl / gist:2350243
Created April 10, 2012 10:35
Check if we need to bundle install
# this is from a Zach Holman slide
require 'digest/md5'
md5 = Digest::MD5.new()
md5 << File.read('Gemfile')
checksum = md5.hexdigest
installed = File.read('.bundle/checksum').strip
@mazuhl
mazuhl / gist:1362978
Created November 14, 2011 00:38
Generate HTTP expires header for date 1 year from now
ruby -e "puts (Time.now + 52*7*24*60*60).strftime('%a, %d %b %Y 23:59:00 GMT')"
@mazuhl
mazuhl / gist:1360968
Created November 12, 2011 19:11
Quick Ruby countdown script - give me four 7.5 minute sets
ruby -e "4.times{ sleep(7.5*60); 5.times {puts 7.chr; sleep(0.3)}}"
@mazuhl
mazuhl / gist:1229140
Created September 20, 2011 14:04
Give me all my Cucumber step definitions
cucumber -d -f stepdefs | grep '/^'