Skip to content

Instantly share code, notes, and snippets.

@schacon
schacon / stopwatch.rb
Created June 22, 2011 15:59
simple ruby stopwatch
class Stopwatch
attr_writer :splits, :max, :start, :end, :total
def initialize(message)
@message = message
@splits = []
@max = 5
end
@matschaffer
matschaffer / gist:942981
Created April 26, 2011 19:52 — forked from schacon/gist:942899
delete all remote branches that have already been merged into master
$ git branch -r --merged |
sed '/>|master/d;/origin/!d;s:origin/::' |
xargs git push origin --delete
# I think this will work, but I don't know how to get git branch to show me that -> line
@tekkub
tekkub / docx_to_markup.rb
Created November 2, 2010 21:39
Word docx files suck!
#!/usr/bin/env ruby
# Converts those nasty xml documents word likes to create into something
# remotely resembling markdown
# Fun side effect: you'll get every revision of the document!
abort "No file name given" unless filename = ARGV.first
remove_tags = [
'\?xml',
#! /usr/bin/env ruby
# this script takes your current commit, finds all the submodules in it,
# makes them static files in a new tree and updates a branch called 'heroku'
# - this way you can push a project with submodules to heroku easily
# just run this, then run "git push heroku heroku:master"
current_commit = `git rev-parse HEAD`
current_tree = `git rev-parse HEAD^{tree}`
puts "Starting at tree #{current_tree}"
@defunkt
defunkt / murder.sh
Created July 22, 2010 19:20
murder processes matching a pattern
# sh function to murder all running processes matching a pattern
# thanks 3n: http://twitter.com/3n/status/19113206105
murder () {
ps | grep $1 | grep -v grep | awk '{print $1}' | xargs kill -9
}
/tmp/compare/svn$ svn commit -m 'commit me'
Sending what.txt
Transmitting file data .
Committed revision 13.
/tmp/compare/svn$ svn info
Path: .
URL: http://localhost:5203/svn
Repository Root: http://localhost:5203/svn
Repository UUID: 3b9a9e50-8ead-4325-b308-a6ad9b1ac2aa