This file contains 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 String | |
def method_missing(method) | |
return "#{self}: get #{$1}!" if method.to_s =~ /^get_(.*)_method$/ | |
"Hello, method_missing! (you call '#{method}' method)" | |
# super | |
end | |
end | |
puts "hoge".get_foo_method | |
puts "hoge".moge |
This file contains 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
public class HelloWorld { | |
public static void main (String[] args) { | |
System.out.println("Hello, World!"); | |
} | |
} |
This file contains 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
def fibbuzz(to) | |
fib = [0, 1] | |
fib << fib[-1] + fib[-2] while fib.last < to | |
result = [] | |
1.upto(to) do |x| | |
output = x | |
output = 'Fib' if fib.include?(x) | |
output = 'Buzz' if x % 5 == 0 | |
output = 'FibBuzz' if fib.include?(x) && x % 5 == 0 |
This file contains 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 './fibbuzz' | |
describe 'fibbuzz' do | |
before do | |
@expected = ['Fib', 'Fib', 'Fib', 4, 'FibBuzz', 6, 7, 'Fib', 9, 'Buzz', 11, 12, 'Fib', 14, 'Buzz', 16] | |
end | |
subject {fibbuzz(16)} | |
it {should eql @expected} | |
end |
This file contains 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_relative '../spec_helper' | |
require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper") | |
# http://stackoverflow.com/questions/5045867/ruby-debug-no-such-file-to-load-spec-helper |
This file contains 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
a = 1 | |
b = 2 | |
a, b = b, a | |
puts a, b |
This file contains 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
`ls .gems/gems/`.split.each {|gem| $LOAD_PATH.push(".gems/gems/#{gem}/lib")} |
This file contains 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
p $LOAD_PATH.push('.') |
This file contains 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
# 一ヶ月以上前のログを削除 | |
WatchLog.delete_all(["created_at < ?", 1.month.ago]) |
This file contains 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
export PATH=/usr/local/bin:$PATH | |
alias sudo="sudo env PATH=$PATH" |
OlderNewer