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
ruby-1.8.7-p302 > tree_printer.call tree | |
Exception | |
IRB::Abort | |
NoMemoryError | |
ScriptError | |
LoadError | |
NotImplementedError | |
SyntaxError | |
SignalException | |
Interrupt |
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
# | |
# = Hash Recursive Merge | |
# | |
# Merges a Ruby Hash recursively, Also known as deep merge. | |
# Recursive version of Hash#merge and Hash#merge!. | |
# | |
# Category:: Ruby | |
# Package:: Hash | |
# Author:: Simone Carletti <weppos@weppos.net> | |
# Copyright:: 2007-2008 The Authors |
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
# see https://github.com/rails/rails/blob/v2.0.2/railties/builtin/rails_info/rails/info.rb | |
@properties = { | |
:ruby => "#{RUBY_VERSION} (#{RUBY_PLATFORM})", | |
:rubygem => Gem::RubyGemsVersion, | |
:rails => Rails::VERSION::STRING, | |
:app_root => File.expand_path(RAILS_ROOT), | |
:env => RAILS_ENV, | |
:db_adapter => ActiveRecord::Base.configurations[RAILS_ENV]['adapter'], | |
:db_schema_version => (ActiveRecord::Migrator.current_version || 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
.wrap-words { | |
word-wrap: break-word; | |
} |
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
console.log("%o", window.location); |
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
# From http://nathansjslessons.appspot.com/lesson?id=1080 | |
counter = ( -> | |
count = 0 # cannot be accessed as it's tied to the closure | |
f = -> | |
count += 1 | |
f | |
)() | |
console.log counter() # 1 |
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
# set-option -g prefix C-a | |
bind-key C-b last-window | |
unbind % # Remove default binding since we’re replacing | |
bind | split-window -h | |
bind - split-window -v | |
# Set status bar | |
set -g status-bg black | |
set -g status-fg white |
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
def some_method(other_method, args) | |
puts "before" | |
other_method.call args | |
puts "after" | |
end | |
def other_method(stuff) | |
puts "other_method called with #{stuff.inspect}" | |
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
# From http://weblog.jamisbuck.org/2007/3/7/raising-the-right-exception | |
exceptions = [] | |
tree = {} | |
ObjectSpace.each_object(Class) do |cls| | |
next unless cls.ancestors.include? Exception | |
next if exceptions.include? cls | |
next if cls.superclass == SystemCallError # avoid dumping Errno's | |
exceptions << cls | |
cls.ancestors.delete_if {|e| [Object, Kernel].include? e }.reverse.inject(tree) {|memo,cls| memo[cls] ||= {}} |
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
before_script: "bundle exec rake db:migrate" |