Skip to content

Instantly share code, notes, and snippets.

View takaokouji's full-sized avatar

Kouji Takao takaokouji

View GitHub Profile
q_default = Dispatch::Queue.concurrent
q_sum = Dispatch::Queue.new("com.example.sum")
sum = 0
q_default.apply(10) do |i|
puts("i: #{i}")
sleep(1)
x = i + 1
q_sum.dispatch(false, &lambda {
puts("x: #{x}")
@takaokouji
takaokouji / rb_define_method-for-macruby.patch
Created November 12, 2009 22:58
This is the patch for MacRuby that is implemented rb_define_method. But not support to call method with blocks.
diff --git a/class.c b/class.c
index ed7ccaf..e4bdceb 100644
--- a/class.c
+++ b/class.c
@@ -1003,7 +1003,7 @@ name_to_sel(const char *name, const int arity)
return sel_registerName(name);
}
-static void
+static rb_vm_method_node_t *
@takaokouji
takaokouji / support-compiling-only-one.patch
Created November 13, 2009 15:11
The patch for MacRuby. $ /usr/bin/rake extensions EXTS=readline
diff --git a/rakelib/builder.rake b/rakelib/builder.rake
index 79e3e41..e3f2ecb 100644
--- a/rakelib/builder.rake
+++ b/rakelib/builder.rake
@@ -328,7 +328,8 @@ INSTRUBY_ARGS = "#{SCRIPT_ARGS} --data-mode=0644 --prog-mode=0755 --installed-li
EXTENSIONS = ['ripper', 'digest', 'etc', 'readline', 'libyaml', 'fcntl', 'socket', 'zlib', 'bigdecimal', 'openssl'].sort
def perform_extensions_target(target)
- EXTENSIONS.map { |x| File.join('ext', x) }.each do |ext_dir|
+ target_extensions = (ENV['EXTS'] && ENV['EXTS'].split or EXTENSIONS)
(load "time-stamp")
(defun insert-time-stamp ()
(interactive)
(insert (time-stamp-string)))
(defun my-insert-time ()
(interactive)
(insert (format-time-string "%Y-%m-%d %H:%M:%S")))
(global-set-key "\C-c\C-t" 'my-insert-time)
diff --git a/array.c b/array.c
index 7cf2d4a..3f70acc 100644
--- a/array.c
+++ b/array.c
@@ -50,7 +50,7 @@ rary_reserve(VALUE ary, size_t newlen)
for (size_t i = 0; i < rary->len; i++) {
GC_WB(&new_elements[i], rary->elements[i]);
}
- GC_WB(&ary->elements, new_elements);
+ GC_WB(&rary->elements, new_elements);
diff --git a/signal.c b/signal.c
index 12b25f1..4d891b5 100644
--- a/signal.c
+++ b/signal.c
@@ -20,8 +20,10 @@
#include "vm.h"
#include <signal.h>
#include <stdio.h>
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
#include <dispatch/dispatch.h>
cymric$ /usr/bin/rake
(in /Users/kouji/work/MacRuby/MacRuby-git)
/usr/bin/ruby tool/compile_prelude.rb prelude.rb miniprelude.c.new
./miniruby -I. -I./lib bin/rubyc --internal --arch i386 --arch x86_64 -C "rbconfig.rb" -o "./rbconfig.rbo"
unknown: [BUG] Segmentation fault
MacRuby version 0.6 (ruby 1.9.0) [universal-darwin9.0, x86_64]
class String
def -(val)
if TIME_RE =~ self && TIME_RE =~ val
if self.length == 8 || val.length == 8
with_sec = true
end
require "time"
d = Time.parse(self) - Time.parse(val)
sec = d % 60
min = (d / 60) % 60
@takaokouji
takaokouji / add-xcode-templates.patch
Created January 8, 2011 02:33
MacRuby class templates for Xcode 3
diff --git a/misc/xcode-templates/File Templates/MacRuby/Ruby File.pbfiletemplate/TemplateInfo.plist b/misc/xcode-templates/File Templates/MacRuby/Ruby File.pbfiletemplate/TemplateInfo.plist
new file mode 100644
index 0000000..7ad506c
--- /dev/null
+++ b/misc/xcode-templates/File Templates/MacRuby/Ruby File.pbfiletemplate/TemplateInfo.plist
@@ -0,0 +1,4 @@
+{
+ MainTemplateFile = "file.rb";
+ Description = "An empty Ruby file.";
+}
@takaokouji
takaokouji / gist:770531
Created January 8, 2011 03:58
Ruby study for Matsue(Japan) junior high school before afternoon.
----- main.rb
require 'dxruby'
require './player'
player = Player.new
Window.loop do
break if Input.keyPush?(K_ESCAPE)
player.move