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
diff --git a/lib/e2mmap.rb b/lib/e2mmap.rb | |
index b8d1d44..d9be1ff 100644 | |
--- a/lib/e2mmap.rb | |
+++ b/lib/e2mmap.rb | |
@@ -54,6 +54,11 @@ module Exception2MessageMapper | |
def E2MM.extend_object(cl) | |
super | |
+ unless cl.respond_to? :bind | |
+ class << cl |
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 Dispatch | |
class Future | |
def initialize(&block) | |
@@queue ||= Queue.new("org.macruby.futures") | |
@group = Group.new | |
@@queue.async(@group) { @value = block[] } | |
end | |
def value |
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 do_it | |
yield | |
end | |
def whatever | |
do_it { yield } | |
end | |
whatever { p 'hi' } |
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
x = {} | |
x['foo'] = 'bar' | |
p x['foo'].class # prints String, as it should | |
x.setObject:'baz', forKey:'foo' | |
p x['foo'].class # prints Symbol?! | |
p x.to_s |
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 "ruby/ruby.h" | |
#include "ruby/node.h" | |
#include "vm.h" | |
static VALUE rb_cContinuation; | |
#define GET_THREAD() GetThreadPtr(rb_vm_current_thread()) | |
#define GetContPtr(obj, ptr) \ | |
Data_Get_Struct(obj, rb_vm_context_t, ptr) |
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
-- this is almost exactly the code that implements booleans in haskell | |
data Bool = True | False | |
and :: Bool -> Bool -> Bool | |
and True x = x | |
and False _ = False -- the underscore means the parameter is not used |
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
program = - value+ EOF? | |
integer = < numeric > - { $$ = number_from_long(atol(yytext)); } | |
float = < numeric? '.' numeric > - { $$ = number_from_double(atof(yytext)) } | |
boolean = "true" - { $$ = TRUE_V; } | |
| "false" - { $$ = FALSE_V; } |
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
Index: encoding.c | |
=================================================================== | |
--- encoding.c (revision 4140) | |
+++ encoding.c (working copy) | |
@@ -146,6 +146,32 @@ mr_enc_dummy_p(VALUE self, SEL sel) | |
return Qfalse; | |
} | |
+// For UTF-[8, 16, 32] it's /uFFFD, and for others it's '?' | |
+rb_str_t *replacement_string_for_encoding(rb_encoding_t* destination) |
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 | |
if ARGV.size < 1 | |
puts "#{$0} folder1 [folder2 [folder3 ...]]" | |
exit 1 | |
end | |
ARGV.each do |folder| | |
`find #{folder} -name '*.txt'`.each do |f| | |
file = f.chomp | |
content = `grep critical #{file}` |
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
# Here's the current version, taken from core/encoding/converter/convpath_spec.rb | |
it "returns multiple encoding pairs when direct conversion is impossible" do | |
ec = Encoding::Converter.new('ascii','Big5') | |
ec.convpath.size.should == 2 | |
ec.convpath.first.should == [Encoding::US_ASCII, Encoding::UTF_8] | |
ec.convpath.last.should == [Encoding::UTF_8, Encoding::Big5] | |
end | |
# That spec seems to imply that the internal encoding for Strings is UTF-8, | |
# which is the case on MRI but not on other implementations. |