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
require 'ffi' | |
module FFI::Ruby | |
class Value | |
class << self | |
extend ::FFI::Library | |
ffi_lib 'ruby' | |
attach_function :rb_obj_id, [:pointer], :pointer | |
attach_function :rb_num2long, [:pointer], :long |
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
require 'rubygems' | |
require 'ffi-portaudio' | |
def safe | |
r = nil | |
Thread.new { | |
$SAFE = 4 | |
r = yield | |
}.join | |
r |
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
require 'ffi' | |
module FFI::PortAudio | |
module API | |
extend FFI::Library | |
ffi_lib 'portaudio' | |
Int16 = 0x8 | |
FramesPerBufferUnspecified = 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
function! s:syntax(name, ext) | |
let l:separator = "^# ============================================================ " | |
let l:ext = empty(a:ext) ? "" : "¥¥.".a:ext | |
let l:cmd = "syntax region GEBlock".a:name | |
¥." matchgroup=FileLine " | |
¥."start=/".l:separator.".*¥¥v".l:ext."$/ " | |
¥."end=/¥¥(".l:separator.".*$¥¥)¥¥@=¥¥|¥¥%$/ " | |
¥."keepend transparent contains=FileLine" | |
let l:cmd .= empty(a:name) ? "" : ",@".a:name |
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
# $ echo 'class B;end' > b.rb | |
b = Thread.new { p autoload(:B, './b') } | |
sleep 0.00002 | |
b.kill | |
B |
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
--- console.c.orig 2011-09-09 04:59:09.000000000 +0900 | |
+++ console.c 2011-09-09 05:08:30.000000000 +0900 | |
@@ -4,6 +4,9 @@ | |
*/ | |
#include "ruby.h" | |
#include "rubyio.h" | |
+ | |
+#include <errno.h> | |
+ | |
#ifndef HAVE_RB_IO_T |
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/env ruby | |
# -*- coding: UTF-8 -*-; | |
require 'io/console' | |
require 'ansi' | |
class Textbox | |
def initialize(input=$stdin) | |
@input = input | |
end |
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/env ruby | |
require 'open3' | |
EXCLUDE_EXTENTSONS = %w(psd gif jpg png DS_Store tmp JPG PNG swp swf o bundle dylib so) | |
EXCLUDE_FROM_CURRENT = %w(estraier tmp log coverage build) | |
subdirs = Dir.glob("*") | |
subdirs -= EXCLUDE_FROM_CURRENT | |
def process_args(argv, _subdirs, _patterns) |
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
puts (1..100).map{|i|[[i, :Fizz], [:Buzz, :FizzBuzz]][(1 - i**4) % 5][(1 - i**2) % 3]} |
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
# editor.rb | |
# | |
# $ irb -reditor | |
# > Editor.edit("abc") # Edit "abc" with the external editor. | |
# => "abc has changed" | |
# | |
# Author: @nanki / nanki at dotswitch dot net | |
require 'tempfile' |