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
# original: http://blog.udzura.jp/2011/02/08/rack-one-liner-server-simpler/ | |
Rack::Server.new.tap{|a| | |
def a.app | |
Rack::Directory.new(".") | |
end | |
}.start |
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
# url: http://bugs.ruby-lang.org/issues/show/1393 | |
class C | |
def to_a; [1,2]; end | |
def to_ary; [3,4]; end | |
end | |
c = C.new | |
# implicit(暗黙) |
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
grep -rs 'STDERR' ./ | grep -E 'active|action|railties|sinatra|rack' |
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/local/bin/ruby | |
if ARGV.count < 1 || ARGV.count >= 2 | |
raise '引数が不正です!第1引数に比較したいファイル名を指定してください' | |
end | |
file_name = ARGV[0] | |
full_path = {} | |
full_path[:a] = File::expand_path(file_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
<?php | |
class C | |
{ | |
public function foo() { | |
echo "foo"; | |
} | |
} | |
$c = new C(); |
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
find ./ -name 'filename' | |
grep -irs 'query' ./ |
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
ruby -ane 'puts $F[0]' hoge.txt > hoge2.txt |
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 | |
class M1 | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
env = env + '1' | |
res = @app.call(env) |
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
ruby -r pp -e 'pp ENV.to_hash' |
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
ruby -r open-uri -e 'open("http://www.yahoo.co.jp") {|f| puts f.read.scan(/topics.+?>(.+?)</)}' |