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 Reportable | |
def as_json | |
{:meta => meta, :report => report} | |
end | |
end | |
class ReportPresenter | |
include Reportable | |
def self.column(name, options={}) | |
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
describe Stack do | |
Invariants do | |
If { stack.empty? } | |
Then { stack.depth.should == 0 } | |
Then { stack.should be_pushable } | |
ElseIf { stack.full? } | |
Then { stack.depth.should == stack.max_depth } | |
Then { stack.should_not be_pushable } | |
Else | |
Then { stack.depth.should be > 0 } # not wild about this part |
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 hash_or_array(obj) | |
obj.each do |k,v=k| | |
puts "k: #{k}","v: #{v}" | |
end | |
end | |
hash_or_array([1,2,3]) | |
# k: 1 | |
# v: 1 | |
# k: 2 |
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 Mirror < BasicObject | |
def initialize(target) | |
@target = target | |
end | |
def method_missing(sym, *args) | |
@target.method(sym) rescue nil | |
end | |
def respond_to_missing?(sym, priv=false) |
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
# ~/.tmux.conf | |
# | |
# See the following files: | |
# | |
# /opt/local/share/doc/tmux/t-williams.conf | |
# /opt/local/share/doc/tmux/screen-keys.conf | |
# /opt/local/share/doc/tmux/vim-keys.conf | |
# | |
# URLs to read: | |
# |
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
puts /^(true|false)$/ === "true" #=> puts true | |
class Regexp | |
def ===(o) | |
false | |
end | |
end | |
case "true" | |
when /^(true|false)$/ |
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
# Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. | |
module RX | |
# Records information about subscriptions to and unsubscriptions from observable sequences. | |
class TestSubscription < Struct.new(:subscribe, :unsubscribe) | |
FIXNUM_MAX = (2**(0.size * 8 -2) -1) | |
def initialize(subscribe, unsubscribe = FIXNUM_MAX) |
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 | |
attr_accessor :foo, :bar | |
def initialize(foo, bar) | |
@foo = foo | |
@bar = bar | |
end | |
def ==(other) | |
self.class == other.class && | |
foo == other.foo && |
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
# Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. | |
module RX | |
module Notification | |
class << self | |
def create_on_next(value) | |
OnNextNotification.new value | |
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
def foo(&bar) | |
bar ||= lambda {|a| a} | |
# do something with bar | |
end |