This file contains hidden or 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 'rack' | |
autoload 'Iconv', 'iconv' | |
module Rack | |
class IconvVerifier | |
def initialize(encoding = 'UTF-8') | |
@encoding = encoding | |
end |
This file contains hidden or 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
Person(Me) my name | |
- should == "moro" | |
Person(Me) my fullname | |
- should == "MOROHASHI Kyosuke" | |
Finished in 0.003083 seconds | |
2 examples, 0 failures |
This file contains hidden or 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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'RMagick' | |
def gen_image(name, width, height) | |
img = Magick::Image.new(width, height) do |i| | |
i.background_color = Magick::Pixel.new(rand(Magick::MaxRGB), rand(Magick::MaxRGB), rand(Magick::MaxRGB), 0) | |
end | |
point_size = width / 8 |
This file contains hidden or 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
Time#to_param | |
- should == "Fri Nov 06 12:34:56 +0900 2009" | |
Time#to_param UTC | |
- should == "Fri Nov 06 03:34:56 UTC 2009" | |
Finished in 0.003786 seconds | |
2 examples, 0 failures |
This file contains hidden or 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:utf8 | |
p [ENV['LC_ALL'], ENV['LC_TIME'], ENV['LANG']] | |
t = Time.now | |
puts t.to_s | |
require 'rubygems' | |
puts t.to_s | |
require 'rmagick' |
This file contains hidden or 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
-# vim:set ft=haml: | |
%h2 東京Ruby忘年会 2009 | |
%p | |
Rubyistのみなさま、2009年もお疲れ様でした。 | |
振り返って見れば、今年もRubyにまつわるニュースが目白押しでした。いろんなことがありましたね。 | |
%ul | |
%li 新年早々 待望のRuby 1.9.1リリース | |
%li 日本Ruby会議2009開催。日本Rubyの会 高橋会長による基調講演 |
This file contains hidden or 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
# encoding: utf-8 | |
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths")) | |
Given /^"([^\"]*)"ページを表示している$/ do |page_name| | |
Given %{I am on #{page_name}} | |
end | |
When /^"([^\"]*)"ページを表示する$/ do |page_name| | |
Given %{I go to #{page_name}} |
This file contains hidden or 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
function! s:RunRspec (opts) | |
let rails_spec_path_re = '\<spec/\(models\|controllers\|views\|helpers\)/.*_spec\.rb$' | |
if( expand('%') =~ rails_spec_path_re && filereadable('script/spec') ) | |
let spec_command = '!ruby script/spec ' | |
" let spec_command = '!spec ' | |
if filereadable('tmp/pids/spec_server.pid') | |
let spec_command = spec_command . ' --drb ' | |
endif | |
else |
This file contains hidden or 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 TapTree | |
module Adapter | |
def taptree(n = nil, filter = nil) | |
tap{|x| TapTree.new(x, filter).display(n) } | |
end | |
end | |
IGNORE = [TapTree::Adapter] | |
COLS = 100 | |
def initialize(obj, filter_re = nil) |
This file contains hidden or 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 Enumerable | |
def detect_by(method, val) | |
detect{|obj| val == obj.__send__(method) } | |
end | |
end | |
p %w[a aa aaa aaaa aaaaa].detect_by(:length, 3) | |
# => aaa | |
# long example. Message.belongs_to :user |