Skip to content

Instantly share code, notes, and snippets.

@defunkt
defunkt / gist:306838
Created February 17, 2010 17:31
Cherry pick a commit from a GitHub URL
#!/usr/bin/env ruby
# Usage:
# gpick http://github.com/cmelbye/github-services/commit/4f1559a82c9aa710baa3497f913ed3d9a666ced7
if ARGV[0] =~ /github\.com\/([^\/]+)\/.+\/commit\/(.+)/
user = $1
sha = $2
exec "hub remote add -f #$1 && git cherry-pick #$2"
else
abort "Usage: gpick http://github.com/user/repo/commit/sha"
@defunkt
defunkt / carbon.md
Created November 5, 2009 20:45
Reduce your carbon footprint

Vim

autocmd BufWritePre * :%s/\s\+$//e

Emacs

(add-hook 'before-save-hook 'delete-trailing-whitespace)

Textmate

config.action_mailer.smtp_settings = {
:address => "mail.authsmtp.com",
:domain => "famspam.com",
:port => 2525,
:user_name => "user",
:password => "pass",
:authentication => :cram_md5
}
# by bryan helmkamp with slight modification by chris wanstrath
# from http://www.brynary.com/2008/8/3/our-git-deployment-workflow
module GitCommands
extend self
def diff_staging
`git fetch`
puts `git diff origin/production origin/staging`
end
"""A small wrapper file for parsing rST files at Github."""
__author__ = "Jannis Leidel"
__copyright__ = "Copyright (C) 2008 Jannis Leidel"
__license__ = "Public Domain"
__version__ = "0.1"
try:
import locale
locale.setlocale(locale.LC_ALL, '')
# version 2.0 of http://ozmm.org/posts/easy_rails_asset_ids_with_git.html
repo = Grit::Repo.new('/path/to/your/app/shared/cached-copy')
js = repo.log('deploy', 'public/javascripts', :max_count => 1).first
css = repo.log('deploy', 'public/stylesheets', :max_count => 1).first
ENV['RAILS_ASSET_ID'] = js.committed_date > css.committed_date ? js.id : css.id
# deploy to staging from your current topic branch, with ease
set :branch, "origin/#{`git branch`.scan(/^\* (\S+)/)}"
@defunkt
defunkt / god.rb
Created November 18, 2008 18:04 — forked from mojombo/gist:26183
rails_root = "/data/github/current"
20.times do |num|
God.watch do |w|
w.name = "dj-#{num}"
w.group = 'dj'
w.interval = 30.seconds
w.start = "rake -f #{rails_root}/Rakefile production jobs:work"
w.uid = 'git'
# my new favorite bashrc function
# quickly inspect source files in style
function pless {
pygmentize $1 | less -r
}