Skip to content

Instantly share code, notes, and snippets.

@pH14
pH14 / ll_test.rb
Last active December 23, 2015 22:39 — forked from pwnall/ll_test.rb
class LabeledString < String
def +(other)
LabeledString.new original_plus(other)
end
end
class String
alias_method :original_plus, :+
def +(other)
@pH14
pH14 / match_spec.rb output
Last active December 27, 2015 05:39
Rubinius failing String#match spec
pwh-argon:rubinius pwh$ rvm use ruby
Using /Users/pwh/.rvm/gems/ruby-2.0.0-p247
pwh-argon:rubinius pwh$ bin/mspec -tr core/string/match_spec.rb
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.3.0]
......................
Finished in 0.003534 seconds
1 file, 22 examples, 37 expectations, 0 failures, 0 errors
@pH14
pH14 / rubinius string#match example
Created November 2, 2013 05:31
Example of differing behavior in MRI2.0.0 vs Rubinius2.1.1
class RegexpSub < Regexp
def match *args
"regexp_match"
end
end
reg = RegexpSub.new("he")
p "hello".match(reg) == "regexp_match"
@pH14
pH14 / rubinius backreferences class
Created November 14, 2013 01:10
In Rubinius 2.1.1 the $`, $', $+, $&, $1-$9 backreferences don't maintain the class of the original matched string. The $~ MatchData will return the correct class.
class LabeledString < String
end
s1 = LabeledString.new("Secret Name")
/n(a)(m)e/i =~ s1
p [$1, $1.class, LabeledString]
p [$2, $2.class, LabeledString]
p [$`, $`.class, LabeledString]
/**
EasyVR Tester
Dump contents of attached EasyVR module
and exercise it with playback and recognition.
Serial monitor can be used to send a few basic commands:
'c' - cycles through available command groups
'b' - cycles through built-in word sets
's123.' - play back sound 123 if available (or beep)
class TaintContext
attr_accessor :tainted
@@simple_methods =
["b", "byteslice", "capitalize", "center",
"chomp", "chop", "clone", "crypt", "delete",
"downcase", "dump", "dup", "element_set",
"encode", "find_character", "find_string",
"find_string_reverse", "gsub", "insert",
"ljust", "lstrip", "modulo", "multiply",
@pH14
pH14 / gist:9fc547aacdd98da15426
Created December 11, 2014 18:16
rubininus bundle install with seven
Your Gemfile lists the gem thin (>= 1.6.2) more than once.
You should probably keep only one of them.
While it's not a problem now, it could cause errors if you change the version of just one of them later.
Using rake 10.4.2
Using Ascii85 1.0.2
Using RedCloth 4.2.9
Using i18n 0.6.11
Using json 1.8.1
Using minitest 5.4.3
Using thread_safe 0.3.4
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.4
- RUBY VERSION: 2.1.0 (2014-12-11 patchlevel 0) [x86_64-darwin14.0.0]
- INSTALLATION DIRECTORY: /Users/pwh/.rbenv/versions/rbx-raw-build/gems
- RUBY EXECUTABLE: /Users/pwh/.rbenv/versions/rbx-raw-build/bin/rbx
- EXECUTABLE DIRECTORY: /Users/pwh/.rbenv/versions/rbx-raw-build/gems/bin
- SPEC CACHE DIRECTORY: /Users/pwh/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/pwh/.rbenv/versions/rbx-raw-build/etc
- RUBYGEMS PLATFORMS:
- ruby
@pH14
pH14 / gist:32fc5e28887d39b43f60
Created December 11, 2014 19:05
gem update --system
Updating rubygems-update
Fetching: rubygems-update-2.4.5.gem (100%)
Successfully installed rubygems-update-2.4.5
Parsing documentation for rubygems-update-2.4.5
Installing ri documentation for rubygems-update-2.4.5
Installing darkfish documentation for rubygems-update-2.4.5
Done installing documentation for rubygems-update after 4 seconds
Parsing documentation for rubygems-update-2.4.5
Done installing documentation for rubygems-update after 0 seconds
Installing RubyGems 2.4.5
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.5
- RUBY VERSION: 2.1.0 (2014-12-11 patchlevel 0) [x86_64-darwin14.0.0]
- INSTALLATION DIRECTORY: /Users/pwh/.rbenv/versions/rbx-raw-build/gems
- RUBY EXECUTABLE: /Users/pwh/.rbenv/versions/rbx-raw-build/bin/rbx
- EXECUTABLE DIRECTORY: /Users/pwh/.rbenv/versions/rbx-raw-build/gems/bin
- SPEC CACHE DIRECTORY: /Users/pwh/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/pwh/.rbenv/versions/rbx-raw-build/etc
- RUBYGEMS PLATFORMS:
- ruby