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
| // FizzBuzz は時代遅れらしいので FibBuzz はどうでしょう #fibbuzz | cod.note : http://codnote.net/2011/10/13/fibbuzz/ | |
| // 163bytes | |
| val x:BigInt=1 | |
| val f:Stream[BigInt]=x#::f.scanLeft(x){(a,b)=>a+b} | |
| for(i<-f take 100;j=i-1)println(if(i%3*i%5>0)i else"Fizz"*(j%3/2).toInt+"Buzz"*(j%5/4).toInt) | |
| //152bytes | |
| val x:BigInt=1 | |
| for((i,_)<-(0 to 98).scanLeft((x,x)){case((b,c),a)=>(c,b+c)};j=i-1)println(if(i%3*i%5>0)i else"Fizz"*(j%3/2).toInt+"Buzz"*(j%5/4).toInt) |
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
| scala> trait Term { def night = () } | |
| defined trait Term | |
| scala> object Zero extends Term | |
| defined module Zero | |
| scala> object stay extends Term | |
| defined module stay | |
| scala> object Fate { |
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
| Scanning . repo | |
| Found 12 bugfix commits, with 43 hotspots: | |
| Fixes: | |
| - fixed Author at tips diplays commiter. | |
| - fixed #5 Rendered duplicate commit node. | |
| - fixed #4 related branche's commit are too many and rendering are too slow. | |
| - fixed for #3 script error occurred when commit message includes double quote. | |
| - fixed the issue link's string lacked '#'. | |
| - fixed XHRequest had been sent to the server when the branch node was clicked. |
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
| # rspecのlet(:name)で定義したオブジェクトのto_sとinspectの値を、:nameに変更する | |
| # | |
| # named_let(:foo){ Object.new } ってやると、 | |
| # foo.to_sが"foo"になる | |
| # | |
| # named_let(:foo,"label for display"){ ... } って第二引数に別名を渡すと、 | |
| # その別名が、to_s/inspectの値になる | |
| # | |
| # subject should == fooとか書いたときの出力が | |
| # ふつうは |
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
| def connect = { | |
| import LogOps._ | |
| log("connect") { implicit ctx => // connect start | |
| // ... 何かの処理 ... | |
| println("in connect") | |
| log("login") { implicit ctx => // connect : login start | |
| // ... 何かの処理 ... | |
| println("in login") |
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
| # Rspec用のCustom Matcher | |
| # | |
| # attributesメソッドを持つオブジェクト同士やHashを再帰的にmatchさせる | |
| # | |
| # ActiveRecord/ActiveModel/ActiveResrouce/Hashなどをゆるふわく | |
| # 一致するか調べる。例えば、StringとSymbolは区別しないし、[]や{}やnilは同一視する。 | |
| # | |
| # it { should have_same_attributes(hash) } | |
| # it { should have_same_attributes(:foo => 1,:bar => 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
| #!/usr/bin/env ruby | |
| # RubyでOGNL(Object Notation Graph Language)っぽく、 | |
| # 文字列で表現されたプロパティにアクセスするための | |
| # 適当なナニか。 | |
| # | |
| # | |
| # Ognl.new('foo_string').apply(foo) | |
| # => object notation graph language!! | |
| # |
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
| # This class extends Hash, it'll be able to access value like attribute acccessors. | |
| # | |
| # examples) | |
| # | |
| # hash = { :foo => "oppai", :bar => "ヽ(*゚д゚)ノ<カイバー" } | |
| # => {:bar=>"ヽ(*゚д゚)ノ<カイバー", :foo=>"oppai"} | |
| # | |
| # phash = hash.propertiate | |
| # => {"foo"=>"oppai", "bar"=>"ヽ(*゚д゚)ノ<カイバー"} | |
| # |
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
| [1] pry(main)> class Foo; end | |
| => nil | |
| [4] pry(main)> module FooMixin | |
| [4] pry(main)* def self.included(base) | |
| [4] pry(main)* raise TypeError unless base <= Foo | |
| [4] pry(main)* end | |
| [4] pry(main)* end | |
| => nil | |
| [5] pry(main)> class Bar < Foo | |
| [5] pry(main)* include FooMixin |
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 Foo | |
| def public_send_to_self(method_name) | |
| self.public_send(method_name) | |
| end | |
| def send_to_self(method_name) | |
| self.send(method_name) | |
| end | |
| def call_hoge |