Skip to content

Instantly share code, notes, and snippets.

Nobuyoshi Nakada nobu

Block or report user

Report or block nobu

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View with_resource.rb
module WithResources
def self.with(release_method: :close, &block)
vars = []
trace = TracePoint.new(:b_call) do |tp|
trace.disable
b = tp.binding
block.parameters.each do |_, name|
vars << [name, b.local_variable_get(name)]
end
end
View rabbit warnings
2017-08-11 16:12:08.204 ruby-trunk[85918:35170956] *** WARNING: Method userSpaceScaleFactor in class NSView is deprecated on 10.7 and later. It should not be used in new applications. Use convertRectToBacking: instead.
(rabbit:85918): GLib-GIO-CRITICAL **: g_loadable_icon_load: assertion 'G_IS_LOADABLE_ICON (icon)' failed
Gtk-WARNING **: Error loading theme icon 'edit-find' for stock: アイコンの読み込みに失敗しました
from /opt/local/lib/ruby/gems/2.5.0/gems/rabbit-2.2.0/lib/rabbit/command/rabbit.rb:644:in `new'
from /opt/local/lib/ruby/gems/2.5.0/gems/rabbit-2.2.0/lib/rabbit/command/rabbit.rb:644:in `choose_source_file_by_dialog'
from /opt/local/lib/ruby/gems/2.5.0/gems/rabbit-2.2.0/lib/rabbit/command/rabbit.rb:671:in `make_source'
from /opt/local/lib/ruby/gems/2.5.0/gems/rabbit-2.2.0/lib/rabbit/command/rabbit.rb:849:in `do_display'
from /opt/local/lib/ruby/gems/2.5.0/gems/rabbit-2.2.0/lib/rabbit/command/rabbit.rb:61:in `block (2 levels) in run'
from /opt/local/lib/ruby/gems/2.5.0/gems/rabbit-2.2.0/lib/rabbit/command
View rabbit warnings
2017-08-11 16:12:08.204 ruby-trunk[85918:35170956] *** WARNING: Method userSpaceScaleFactor in class NSView is deprecated on 10.7 and later. It should not be used in new applications. Use convertRectToBacking: instead.
(rabbit:85918): GLib-GIO-CRITICAL **: g_loadable_icon_load: assertion 'G_IS_LOADABLE_ICON (icon)' failed
Gtk-WARNING **: Error loading theme icon 'edit-find' for stock: アイコンの読み込みに失敗しました
from /opt/local/lib/ruby/gems/2.5.0/gems/rabbit-2.2.0/lib/rabbit/command/rabbit.rb:644:in `new'
from /opt/local/lib/ruby/gems/2.5.0/gems/rabbit-2.2.0/lib/rabbit/command/rabbit.rb:644:in `choose_source_file_by_dialog'
from /opt/local/lib/ruby/gems/2.5.0/gems/rabbit-2.2.0/lib/rabbit/command/rabbit.rb:671:in `make_source'
from /opt/local/lib/ruby/gems/2.5.0/gems/rabbit-2.2.0/lib/rabbit/command/rabbit.rb:849:in `do_display'
from /opt/local/lib/ruby/gems/2.5.0/gems/rabbit-2.2.0/lib/rabbit/command/rabbit.rb:61:in `block (2 levels) in run'
from /opt/local/lib/ruby/gems/2.5.0/gems/rabbit-2.2.0/lib/rabbit/command
View test log
[48/74] TestThread#test_thread_interrupt_for_killed_thread = 9.01 s
1) Failure:
TestThread#test_thread_interrupt_for_killed_thread [/Users/nobu/src/ruby/trunk/src/test/ruby/test_thread.rb:1203]:
[Bug #8996]
pid 3059 killed by SIGABRT (signal 6)Diagnostic reports:
| Process: ruby [3059]
| Path: /Users/USER/*/ruby
| Identifier: ruby
| Version: 0
| Code Type: X86-64 (Native)
View new.zip.dump
0000000 50 4b 03 04 0a 00 00 00 00 00 68 68 85 4a 00 00 >PK........hh.J..<
0000020 00 00 00 00 00 00 00 00 00 00 1f 00 10 00 e5 90 >..............?.<
0000040 8d e7 a7 b0 e6 9c aa e8 a8 ad e5 ae 9a e3 83 95 >.称?.?設?.?..<
0000060 e3 82 a9 e3 83 ab e3 82 bf e3 82 99 2f 55 58 0c >?.??.??.??../UX.<
0000100 00 84 6c e4 58 84 6c e4 58 f5 01 14 00 50 4b 01 >..l?X.l?X?...PK.<
0000120 02 15 03 0a 00 00 00 00 00 68 68 85 4a 00 00 00 >.........hh.J...<
0000140 00 00 00 00 00 00 00 00 00 1f 00 0c 00 00 00 00 >................<
0000160 00 00 00 00 40 ed 41 00 00 00 00 e5 90 8d e7 a7 >....@?A....?..?<
0000200 b0 e6 9c aa e8 a8 ad e5 ae 9a e3 83 95 e3 82 a9 >??.?設?.?..?.?<
0000220 e3 83 ab e3 82 bf e3 82 99 2f 55 58 08 00 84 6c >?.??.??../UX...l<
View sample.rb
#!/usr/local/bin/ruby
require 'open3'
require 'tempfile'
require 'rbconfig'
require 'fiddle/import'
class Sample
def main
func = RbConfig::CONFIG["SYMBOL_PREFIX"]+"sample_add"
src = <<EOS
View gist:3315f8e9f6073221e3311828b3bd9631
$ ruby -rbenchmark -e 'N=1000_000;a=self;Benchmark.bm{|x| x.report("if") {N.times{a.itself if a}}; x.report("&.") {N.times{a&.itself}}}'
user system total real
if 0.060000 0.010000 0.070000 ( 0.076417)
&. 0.060000 0.000000 0.060000 ( 0.072385)
View extmk.rab
= extmk
: author
中田伸悦
= 拡張ライブラリ
View bm_cachename.rb
#!/usr/local/bin/ruby
require 'benchmark/ips'
require 'base64'
require 'digest'
N=10_000
data = Digest::SHA256.digest("")
Benchmark.ips do |x|
x.report("base64") do
N.times do
View close-called-test.rb
body = Class.new do
def initialize; @is_open = true end
def each; yield "hello" end
def close; @is_open = false end
def call
if @is_open
[500, {}, ["close not called"]]
else
[200, {}, self]
end
You can’t perform that action at this time.