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
# -*- coding: utf-8 -*- | |
require 'yaml' | |
require 'logger' | |
require 'net/http' | |
require 'twitter' | |
LOG = Logger.new('log') | |
LISTS = [22926920, 22919856, 22917276, 22914957, 22912272, 22898839] | |
USER= 'niku_name' |
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
# -*- coding: utf-8 -*- | |
require 'rspec' | |
describe "stdout" do | |
def substitute_stdout | |
mock = double('stdout') | |
yield mock | |
$stdout = mock | |
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
# -*- coding: utf-8 -*- | |
require 'rspec' | |
class LRUCache | |
attr_reader :order, :capacity | |
def initialize(capacity) | |
@capacity = capacity | |
@order = [] | |
@hash = {} |
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
require 'rspec' | |
class Foo | |
def my_fork | |
fork do | |
p 'forked once' | |
end | |
end | |
def my_fork_double | |
fork do |
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
require 'rspec' | |
class Foo | |
attr_reader :ary | |
def initialize | |
@ary = [] | |
@num = 0 | |
end | |
def update | |
@ary << @num |
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
require 'rspec' | |
class Foo | |
def bar &block | |
block.call(:called) if block | |
:done | |
end | |
end | |
# Foo.new.bar{ |m| p m } |
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
require 'rspec' | |
class Int | |
attr_reader :count | |
def initialize | |
@count = 0 | |
end | |
def increment | |
@count += 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
require 'rspec' | |
class Foo | |
def bar | |
if block_given? | |
yield(1) | |
yield(2) | |
end | |
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
class Foo | |
def block | |
yield if block_given? | |
end | |
def call &b | |
b.call if b | |
end | |
end | |
Foo.new.send(:block) { 'block called' } # => "block called" |
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
/Users/niku% ruby --version | |
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.0] | |
/Users/niku% curl -H host:pow localhost/config.json | |
{"bin":"/Users/niku/Library/Application Support/Pow/Versions/0.3.1/bin/pow","dstPort":80,"httpPort":20559,"dnsPort":20560,"timeout":900,"workers":2,"domains":["dev"],"extDomains":[],"hostRoot":"/Users/niku/Library/Application Support/Pow/Hosts","logRoot":"/Users/niku/Library/Logs/Pow","rvmPath":"/Users/niku/.rvm/scripts/rvm"} | |
/Users/niku% mkdir lint_test | |
/Users/niku% echo "require 'rack'\nrequire 'rack/lobster'\n\nuse Rack::Lint\nrun Rack::Lobster.new\n" > lint_test/config.ru | |
/Users/niku% cat lint_test/config.ru | |
require 'rack' | |
require 'rack/lobster' |