git revert {merge SHA} -m 1
ref -m, --mainline <n> parent number
eg.
➜ wendi-mac ~/tmp/demo (master) (ruby-2.0.0-p353)| #!/bin/bash | |
| git filter-branch --force --env-filter ' | |
| if [ "$GIT_COMMITTER_NAME" = "wendi" ]; | |
| then | |
| GIT_COMMITTER_EMAIL="ifyouseewendy@gmail.com"; | |
| GIT_AUTHOR_EMAIL="ifyouseewendy@gmail.com"; | |
| fi' -- --all |
| class Roulette | |
| def method_missing(name, *args) | |
| person = name.to_s.capitalize | |
| super unless %w(Wendi Larry Dapian).include? person | |
| number = 0 | |
| 3.times do | |
| number = rand(10) + 1 | |
| puts "#{number}..." | |
| end | |
| "#{person} got a #{number}" |
| # http://ruby-doc.org/core-2.0/Proc.html#method-i-curry | |
| # | |
| # curry → a_proc | |
| # | |
| # Returns a curried proc. | |
| # | |
| # curry(arity) → a_proc | |
| # | |
| # If the optional arity argument is given, it determines the number of arguments. | |
| # |
| # ruby 2.1.2 | |
| require 'benchmark/ips' | |
| Benchmark.ips do |x| | |
| x.report { (1..100).select { |x| x % 3 == 0 }.select { |x| x % 4 == 0 } } | |
| x.report { (1..100).select { |x| x % 3 == 0 && x % 4 == 0 } } | |
| x.report { (1..100).lazy.select { |x| x % 3 == 0 }.select { |x| x % 4 == 0 }.to_a } | |
| end |
| # catch executes its block. | |
| # If a throw is executed, Ruby searches up its stack for a catch block with a tag corresponding to the throw's tag. | |
| # If found, that block is terminated, and catch returns the value given to throw. | |
| # If throw is not called, the block terminates normally, and the value of catch is the value of the last expression evaluated. | |
| # catch expressions may be nested, and the throw call need not be in lexical scope. | |
| def routine(n) | |
| puts n | |
| throw :done, "I'm the return value" if n <= 0 | |
| routine(n-1) |
| #!/usr/bin/env ruby | |
| require 'date' | |
| require 'fileutils' | |
| app_key = '' | |
| DUMP_HOST = 'localhost' | |
| DUMP_PORT = '27017' |
| use Rack::Auth::Basic, 'app' do |usr, pwd| | |
| usr == 'wendi' && pwd == '123123' | |
| end | |
| # => Request Headers | |
| # Authorization:Basic d2VuZGk6MTIzMTIz | |
| # realm = 'Hello, wrold' | |
| # opaque = '1234567890' | |
| # use Rack::Auth::Digest::MD5, realm, opaque do |password| |
module A
def foo
puts 'foo from A'
super
end
end
module B
def foo| def subclasses_of(superclass) | |
| subclasses = [] | |
| ObjectSpace.each_object(Class) do |k| | |
| next if !k.ancestors.include?(superclass) || superclass == k || k.to_s.include?('::') || subclasses.include?(k.to_s) | |
| subclasses << k.to_s | |
| end | |
| subclasses | |
| end |