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:utf-8 | |
# vim:set ft=ruby: | |
require 'rubygems' | |
gem 'thin', '1.0.0' | |
require 'rack/adapter/rails'# provided by thin. | |
prefix = "/myapp" | |
start = Time.now |
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
run "rm public/index.html" | |
run "haml --rails ." | |
generate :rspec | |
generate :cucumber | |
generate :i18n,"--locale", "ja" | |
inside("public/stylesheets") do | |
Dir.mkdir("sass") | |
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
Spec::Example::ExampleMethods.module_eval do | |
def description | |
if description = @_proxy.description || ::Spec::Matchers.generated_description | |
description | |
else | |
"(no description supplied at %s)" % @_proxy.location | |
end | |
end | |
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
# -*- coding: utf-8 -*- | |
$: << File.expand_path('../lib', File.dirname(__FILE__)) | |
require 'lru_hash' | |
describe LRUHash do | |
describe "ハッシュのように使えて、キー:fooに'hoge'を追加した場合" do | |
before do | |
@hash = LRUHash.new | |
@hash[:foo] = "hoge" | |
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
require 'forwardable' | |
class LRUHash | |
extend Forwardable | |
attr_reader :max_size | |
rb_hash_has_key = %w[has_key? include? key? member?] | |
def_delegators '@storage', :size, *rb_hash_has_key | |
def initialize(max_size=16) |
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 'pathname' | |
class DumpRequst | |
def initialize(app, dir, &out_strategy) | |
@app = app | |
@dir = dir | |
@out_strategy = out_strategy | |
Pathname.new(dir).mkpath unless File.directory?(dir) | |
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
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 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
Array.class_eval do | |
def to_proc | |
first, *rest = self | |
Proc.new{|o| o.send(first, *rest) } | |
end | |
end | |
# p (1..10).map{|i|i.divmod(2)} | |
p (1..10).map(&[:divmod,2]) |
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 Foo | |
def foobar | |
p:hello | |
end | |
module_function :foobar | |
def foobar | |
Foo.foobar | |
end | |
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
From 61b68702748ff7da4fbc97a2bdf00c39a71e63ab Mon Sep 17 00:00:00 2001 | |
From: moro <[email protected]> | |
Date: Thu, 1 Oct 2009 20:58:39 +0900 | |
Subject: [PATCH] impl. rack middleware to block invalid chars. | |
block invalid chars, which is redundant UTF-8 chars for example, | |
to come into Rails app world. | |
--- | |
actionpack/lib/action_controller.rb | 1 + | |
.../lib/action_controller/invalid_char_blocker.rb | 49 +++++++++ |