Skip to content

Instantly share code, notes, and snippets.

require 'rack'
autoload 'Iconv', 'iconv'
module Rack
class IconvVerifier
def initialize(encoding = 'UTF-8')
@encoding = encoding
end
Person(Me) my name
- should == "moro"
Person(Me) my fullname
- should == "MOROHASHI Kyosuke"
Finished in 0.003083 seconds
2 examples, 0 failures
#!/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
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
# 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'
-# vim:set ft=haml:
%h2 東京Ruby忘年会 2009
%p
Rubyistのみなさま、2009年もお疲れ様でした。
振り返って見れば、今年もRubyにまつわるニュースが目白押しでした。いろんなことがありましたね。
%ul
%li 新年早々 待望のRuby 1.9.1リリース
%li 日本Ruby会議2009開催。日本Rubyの会 高橋会長による基調講演
# 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}}
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
@moro
moro / taptree.rb
Created September 28, 2010 02:09
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)
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