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 Boggle | |
| @@tree = Marshal.load(File.read('tree.marshal')) | |
| def initialize(grid) | |
| @grid = grid | |
| end | |
| def word_list | |
| list = [] |
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 Object | |
| def rtry(sym) | |
| self.respond_to?(sym) ? self.send(sym) : nil | |
| end | |
| def barbar(o) | |
| lval = (self.rtry(:blank?) or self.rtry(:empty?)) ? nil : self | |
| rval = (o.rtry(:blank?) or o.rtry(:empty?)) ? nil : o | |
| lval || rval |
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 project_precmd() { | |
| if [ -z $1 ]; then | |
| export PROJECT_ROOT=$(cd $(project_precmd .); pwd -P) | |
| else | |
| if [[ -d $1/.git || -f $1/Rakefile || -f $1/Makefile ]]; then | |
| echo $1 | |
| else | |
| if [[ $(cd $1; pwd -P) == / ]]; then | |
| echo . | |
| 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
| # Not exactly efficient or legible. Fun though :) -- wtb inject.with_index. | |
| def parentmodules(mod) | |
| mods = mod.split("::") | |
| i=-1 | |
| mods.inject([[]]*mods.size) { |a,v| | |
| i += 1 | |
| a.zip([mods[i]]*(mods.size-i)) | |
| }.map { |e| e.flatten.compact.join("::") } | |
| 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
| # doesn't really work :( | |
| x = ObjectSpace.each_object.to_a | |
| class Foo | |
| def blah | |
| :asdf | |
| end | |
| end | |
| STATE=:zxcv | |
| blah="asdf" |
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
| ~/src/ruby-1.8.7-p248 ✖ ❼ ▸ rvm ruby -e 'x=[*(1..10000).map{|e|[1,e]}].sort{|x,y| x[0] <=> y[0]}; y=x.sort; puts y==x' | |
| jruby-1.4.0: jruby 1.4.0 (ruby 1.8.7 patchlevel 174) (2009-11-02 69fbfa3) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_15) [x86_64-java] | |
| true | |
| macruby-nightly: MacRuby version 0.6 (ruby 1.9.0) [universal-darwin10.0, x86_64] | |
| false |
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
| ~/src/ruby-1.8.7-p248 ✖ ❼ ▸ rvm ruby -e 'x=[[1,20],*(1..10000).map{|e|[1,e]}].sort{|x,y| x[0] <=> y[0]}; y=x.sort; puts y==x' | |
| jruby-1.4.0: jruby 1.4.0 (ruby 1.8.7 patchlevel 174) (2009-11-02 69fbfa3) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_15) [x86_64-java] | |
| false | |
| macruby-nightly: MacRuby version 0.6 (ruby 1.9.0) [universal-darwin10.0, x86_64] | |
| false |
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
| ~/src/ruby-1.8.7-p248 ✖ ❼ ▸ rvm ruby -e 'x=[[5,5,5,5],*(1..10000).map{|e|[1,e]}].sort{|x,y| x[0] <=> y[0]}; y=x.sort; puts y==x' | |
| jruby-1.4.0: jruby 1.4.0 (ruby 1.8.7 patchlevel 174) (2009-11-02 69fbfa3) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_15) [x86_64-java] | |
| true | |
| macruby-nightly: MacRuby version 0.6 (ruby 1.9.0) [universal-darwin10.0, x86_64] | |
| false |
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 Person | |
| attr_reader :salutation, :first_name, :last_name | |
| def initialize(s,f,l) | |
| @salutation = s | |
| @first_name = f | |
| @last_name = l | |
| 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 'active_support/core_ext/proc' | |
| class Migration | |
| def initialize | |
| end | |
| def dsl(&block) | |
| block.bind(self).call |