Skip to content

Instantly share code, notes, and snippets.

View pake007's full-sized avatar

Jimmy Huang pake007

View GitHub Profile
@schacon
schacon / gist:942899
Created April 26, 2011 19:19
delete all remote branches that have already been merged into master
$ git branch -r --merged |
grep origin |
grep -v '>' |
grep -v master |
xargs -L1 |
awk '{split($0,a,"/"); print a[2]}' |
xargs git push origin --delete
@wincent
wincent / gist:659344
Created November 2, 2010 07:13
mass_assignment.rb
module RSpec
module Matchers
class AllowMassAssignmentOf # :nodoc:
def initialize hash = nil
raise if hash.nil?
raise unless hash.kind_of? Hash
raise unless hash.length > 0
@attributes = hash
end
@Burgestrand
Burgestrand / download-progress.rb
Created June 27, 2010 13:55
Ruby HTTP file download with progress measurement
require 'net/http'
require 'uri'
def download(url)
Thread.new do
thread = Thread.current
body = thread[:body] = []
url = URI.parse url
Net::HTTP.new(url.host, url.port).request_get(url.path) do |response|
module VarAccessor
Sass::Script::Functions.send :include, self
def self.variables
@variables ||= {}
end
def self.set(values = {})
variables.merge! values
end
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')