Skip to content

Instantly share code, notes, and snippets.

View takkanm's full-sized avatar

Mitsutaka Mimura takkanm

  • Tokyo, Japan
View GitHub Profile
#検証したいUserクラス
class User < ActiveRecord::Base
belongs_to :room
def wait(room)
room.wait
self.room = room
end
end
def gh_link(id_and_name)
name = id_and_name.split('/').last
"<a href='http://github.com/#{id_and_name}'>#{name}</a>"
end
def method_missing(*args)
args[0].to_s
end
p a
$ cat let.rb
describe do
let!(:a) { puts 'first let' }
before { puts 'before' }
let!(:b) { puts 'second let' }
it { true.should be_true }
end
$ rspec let.rb
#! /bin/sh
hub clone https://github.com/dproject21/yaruo_tdd_triangle
hub clone https://github.com/mataki/fast_spork_runner
hub clone https://github.com/randym/axlsx
hub clone https://github.com/todesking/okura
@takkanm
takkanm / amida.rb
Created June 3, 2012 00:58
みなとRuby会議01のソーシャルコーディングのやつ
class Amida
attr_reader :width, :height, :matrix
def initialize(size)
@size = size
@width = size - 1
@height = @width * 2
@matrix = Array.new(@height) { Array.new(@width) }
end
def gen(num)
diff --git a/Headers/iTerm/PTYTextView.h b/Headers/iTerm/PTYTextView.h
index 54c192c..a75f0bc 100644
--- a/Headers/iTerm/PTYTextView.h
+++ b/Headers/iTerm/PTYTextView.h
@@ -100,6 +100,8 @@ typedef struct PTYFontInfo PTYFontInfo;
BOOL CURSOR;
BOOL colorInvertedCursor;
+ BOOL doCommandBySelectorCalled;
+
% cat tmp/define_method_test.rb
class Foo
def foo
:foo
end
define_method(:bar) { :foo }
end
def time(method_name, count, &block)
start = Time.now
ruby-1.9.2-p290 :001 > o = Object.new
=> #<Object:0x007fb4ea0615e8>
ruby-1.9.2-p290 :002 > o.instance_eval {|obj| p obj; p self }
#<Object:0x007fb4ea0615e8>
#<Object:0x007fb4ea0615e8>
=> #<Object:0x007fb4ea0615e8>
ruby-1.9.2-p290 :003 > o.instance_exec {|obj| p obj; p self }
nil
#<Object:0x007fb4ea0615e8>
=> #<Object:0x007fb4ea0615e8>
describe 'メソッドチェーン' do
subject { {a:1, b:2, c:3} }
its('values.sum') { should == 6}
end