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
# Performs normal match and returns MatchData object from $~ or nil. | |
def match(str) | |
unless str | |
Regexp.last_match = nil | |
return nil | |
end | |
str = StringValue(str) | |
Regexp.last_match = search_region(str, 0, str.size, true) |
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
# Performs normal match and returns MatchData object from $~ or nil. | |
def match(str) | |
unless str | |
Regexp.last_match = nil | |
return nil | |
end | |
str = StringValue(str) | |
Regexp.last_match = search_region(str, 0, str.size, true) |
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 foo | |
puts "before: '#{$~}'" | |
/foo/ =~ 'foo' | |
puts "after: '#{$~}'" | |
clear_last_match | |
puts "after call: '#{$~}' (should still be set)" | |
end | |
def clear_last_match | |
$~ = nil |
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
ruby-1.9.2-p180 :008 > z = Fiber.new{Thread.current}.resume | |
=> #<Thread:0x00000100887678 run> | |
ruby-1.9.2-p180 :009 > Thread.current | |
=> #<Thread:0x00000100887678 run> | |
ruby-1.9.2-p180 :010 > z = Fiber.new{Thread.current.object_id}.resume | |
=> 2151955260 | |
ruby-1.9.2-p180 :011 > Thread.current.object_id | |
=> 2151955260 |
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
$ RBXOPT=-Xprofile\ -Xprofiler.graph\ -Xprofiler.full_report rbx -S rspec spec -f p &>foo | |
bash-3.2$ vim foo | |
bash-3.2$ grep Array#map foo | |
0.00 0.22 1 Array#map [74] | |
[74] 0.3 0.00 0.22 1 Array#map [74] | |
0.00 0.22 1 Array#map [74] | |
0.00 0.22 4 Array#map [76] | |
[76] 0.3 0.00 0.22 4 Array#map [76] | |
0.00 0.22 4 Array#map [76] | |
0.00 0.22 1 Array#map [80] |
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
#include <stdio.h> | |
/* prints 78.882004 */ | |
int main(int argc, char** argv) { | |
float f = 78.882; | |
printf("%f\n", f); | |
return 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
#!/usr/bin/ruby | |
# Set two thread locals | |
Thread.current["foo"] = "fooval" | |
Thread.current["bar"] = "barval" | |
puts [Thread.current["foo"], Thread.current["bar"]] | |
# prints: | |
# fooval | |
# barval |
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
____ ____ | |
| | | |
|__ \ / __| | |
| / \ | | |
|____ ____| |
I hereby claim:
- I am dwaite on github.
- I am dwaite (https://keybase.io/dwaite) on keybase.
- I have a public key whose fingerprint is B6E6 30B2 71A7 1FF9 393E 4E6C 5E52 A11A 5979 897C
To claim this, I am signing this object: