This file contains 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
module ActionController | |
class Base | |
private | |
# For Rails (tested on 2.3.8): | |
# Displays request parameters hash pretty-printed instead of as an unreadable wall of | |
# text (but only in development environment). | |
# Toss this into config/initializers . | |
# Altered from actionpack-2.3.8/lib/action_controller/base.rb . |
This file contains 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
# The overall effect of this is to assert that there exists a row where all of the strings | |
# specified can be found in one of its tds. | |
# | |
# Then I should see "foo" and "bar" within a row | |
# Then I should see "foo", "bar", and "baz" within a row | |
Then /^I should see ((?:"(?:[^"]+)"(?: |, | and |, and ))*"(?:[^"]+)") (?:within|in) a row$/ do |list| | |
cell_xpaths = list.scan(/"(?:[^"])+"/).map{|cell_content| %(td/descendant-or-self::*[text()=#{cell_content}])} | |
page.should have_xpath %{//tr/#{cell_xpaths.join %(/ancestor::tr[1]/)}} | |
end |
This file contains 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
# Source the git-completion script. | |
# Your location may vary. | |
# If you don't have it, you can find it at | |
# https://github.com/git/git/blob/master/contrib/completion/git-completion.bash | |
source /usr/local/git/contrib/completion/git-completion.bash | |
# If you want tab completion to work with your shell aliases for git, you'll have to do some extra work. | |
alias gco='git checkout' | |
complete -o default -o nospace -F _git_checkout gco |
This file contains 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
# Annoy your friends! | |
# Requires OS X and APG. | |
# brew install apg or sudo port install apg | |
while :; do apg | say -v Princess; done |
This file contains 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
# in both 1.8.7 and 1.9.2 | |
h = {} | |
h['foo'] = 'bar' | |
h[Ohm::Types::String.new('foo')] # 'bar' | |
h = {} | |
h[Ohm::Types::String.new('foo')] = 'bar' | |
h['foo'] # nil |
This file contains 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
# square evens; leave odds alone | |
[1,2,3,4,5,6,7,8].map &->(i) do | |
if i%2 == 0 | |
return i**2 | |
else | |
return i | |
end | |
end |
This file contains 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
h = Hash.new([]) | |
h[:cats] << "Mittens" | |
h[:dogs] << "Fifi" | |
# At this point, I would like h to be | |
# {:cats => ["Mittens"}, :dogs => ["Fifi"]} | |
# Instead, it's just {}. | |
# Obviously this problem is easy to solve, but only at increased verbosity. | |
# It feels like it's something that should be able to be done in three lines. |
This file contains 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
class Foo | |
def foo | |
puts "foo" | |
end | |
end | |
class Bar < Foo | |
undef_method :foo | |
end |
This file contains 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
class Foo | |
def self.define_bar | |
def self.bar | |
puts "bar was apparently defined!" | |
end | |
end | |
end | |
Foo.bar # raises NoMethodError |
This file contains 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
# do not judge | |
while true; do sleep `echo $RANDOM%300+150 | bc`; echo $(head -c `echo $RANDOM%10+1 | bc` /dev/random) > /dev/$(w | sed -n 's/.*\(s[0-9][0-9]*\).*/tty\1/p' | php -r '$a=file("php://stdin");shuffle($a);print $a[0];'); done |
OlderNewer