This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This aims to reproduce the State pattern using MicroMachine. | |
# We're just implementing the example from http://github.com/dcadenas/state_pattern | |
require "micromachine" | |
module Stop | |
def self.color | |
"red" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "ffaker" | |
class ActiveRecord::Base | |
def self.define_factory(name=nil, parent=nil, &block) | |
name = [name, "factory"].compact.join("_") | |
scope name, lambda { |overrides={}| | |
parent ||= scoped | |
attributes = instance_eval(&block).merge(overrides) | |
parent.where(attributes) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ -x ~/.bash_completion.d/_transcript ]; then | |
complete -C ~/.bash_completion.d/_transcript -o default transcript | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ruby-1.9.2-rc2 > a = [1, 2, 3] | |
=> [1, 2, 3] | |
ruby-1.9.2-rc2 > a[3, 0] | |
=> [] | |
ruby-1.9.2-rc2 > a[4, 0] | |
=> nil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
abort "You need to provide a string as the last argument" if ARGV.empty? | |
$debug = true if (ARGV & %w(-d -v --debug --verbose)).any? | |
def ruler_for(used) | |
size = used.map(&:size).inject(:+) + used.size - 1 | |
"-" * size | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby -w | |
def ps(command, command_size=3) | |
capture = (5...5+command_size).map {|c| "$#{c}" }.join(' " " ') | |
%Q(ps x | grep #{command} | grep -v 'grep #{command}' | awk '{ print #{capture} }') | |
end | |
def ssh(server, command) | |
%Q(ssh #{server} #{command}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
o1 = Object.new | |
o2 = Object.new | |
def (1 > 2 ? o1 : o2).blah | |
puts "blah" | |
end | |
o2.blah #=> puts "blah" | |
o1.blah #=> NoMethodError |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Started by user anonymous | |
Checkout:workspace / /var/lib/jenkins/jobs/Test/workspace - hudson.remoting.LocalChannel@13d7254 | |
Using strategy: Default | |
Last Built Revision: Revision 6352919e95820aac6c5fd4a2302231d3ec84ab3f (origin/master) | |
Checkout:workspace / /var/lib/jenkins/jobs/Test/workspace - hudson.remoting.LocalChannel@13d7254 | |
Fetching changes from the remote Git repository | |
Fetching upstream changes from git://github.com/foca/moody.git | |
Seen branch in repository origin/master | |
Commencing build of Revision 6352919e95820aac6c5fd4a2302231d3ec84ab3f (origin/master) | |
Checking out Revision 6352919e95820aac6c5fd4a2302231d3ec84ab3f (origin/master) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(window).bind("statechange", function() { | |
var state = History.getState(); | |
load(state.url, false); | |
}); | |
function load(url, push) { | |
if (push === true || push === undefined) | |
History.pushState(null, null, url); | |
$.ajax({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cd into a matching gem directory. Pass a grep compatible | |
# regular expression. If you don't pass anything, it goes | |
# to the root gem directory. | |
cdgem () | |
{ | |
local gempath=$(gem env gemdir)/gems; | |
if [[ $1 == "" ]]; then | |
cd $gempath; | |
return; | |
fi; |