Skip to content

Instantly share code, notes, and snippets.

View patrickt's full-sized avatar
🍉

Patrick Thomson patrickt

🍉
View GitHub Profile
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
include Dispatch
class Future
def initialize(&block)
@@queue ||= Queue.new("org.macruby.futures")
@group = Group.new
@@queue.async(@group) { @value = block[] }
end
def value
def do_it
yield
end
def whatever
do_it { yield }
end
whatever { p 'hi' }
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
#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 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
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; }
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)
#!/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}`
# 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.