Skip to content

Instantly share code, notes, and snippets.

@nagachika
nagachika / gist:6549187
Last active December 22, 2015 23:49
reproduce code for Refinements bug.
module M
refine(Fixnum) do
def foo
:foo
end
end
end
using M
p([0].map{|i| i.foo})
@nagachika
nagachika / gist:8018565
Last active December 31, 2015 17:09
diff of generated Makefile between r44256 and r44257
68,69c68,69
< CPPFLAGS = -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -I/usr/local/include $(DEFS) ${cppflags} $(INCFLAGS)
< LDFLAGS = $(CFLAGS) -L. -fstack-protector -L/usr/local/lib
---
> CPPFLAGS = -Idummy/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT $(DEFS) ${cppflags} $(INCFLAGS)
> LDFLAGS = $(CFLAGS) -L. -fstack-protector
76c76
< DLDFLAGS = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -L/usr/local/lib $(XLDFLAGS) $(ARCH_FLAG)
---
> DLDFLAGS = $(XLDFLAGS) $(ARCH_FLAG)
TestRubyOptions#test_kanji = 0.05 s
1) Failure:
TestRubyOptions#test_kanji [/Users/nagachika/opt/ruby-trunk/src/ruby/test/ruby/test_rubyoptions.rb:131]:
<["EUC-JP"]> expected but was
<[]>.
---
<[]> expected but was
<["/Users/nagachika/opt/ruby-trunk/src/ruby/lib/rubygems/specification.rb:710:in `[]': invalid byte sequence in EUC-JP (ArgumentError)",
"\tfrom /Users/nagachika/opt/ruby-trunk/src/ruby/lib/rubygems/specification.rb:710:in `block in each_gemspec'",
"\tfrom /Users/nagachika/opt/ruby-trunk/src/ruby/lib/rubygems/specification.rb:709:in `each'",
p "in bar.rb"
@nagachika
nagachika / Gemfile
Last active August 29, 2015 14:02
ActiveSupport::Dependencies and const_get(const, false)
source "https://rubygems.org"
#gem "activesupport", "~> 3.2.18"
gem "activesupport", "~> 4.1.1"
@nagachika
nagachika / a.rb
Created July 7, 2014 14:50
ruby constant lookup
module A
class << self
def foo
p B
end
end
B = "A::B"
end
% make prereq
making srcs under enc
make[1]: Nothing to be done for `srcs'.
generating transdb.h
transdb.h unchanged
generating ../ruby/ext/ripper/ripper.c
extracting ripper.y from ../../parse.y
id.h not found in ["../.."]
make[1]: *** [ripper.y] Error 1
make: *** [../ruby/ext/ripper/ripper.c] Error 2
class A
Const = lambda{ p [ :in_lambda, self, @foo ] }
define_method(:meth) do
p [:in_method, self, @foo]
Const.call
end
def initialize
@foo = 72
@nagachika
nagachika / reproduce.rb
Created January 22, 2015 04:54
weird behavior of psych with activesupport on 2.2.0/2.1.5
gem 'activesupport'
require "psych"
p Psych.respond_to?(:load_file) # => should print "true" but print "false" when psych-2.0.11.gem was installed
@nagachika
nagachika / Gemfile
Created March 24, 2015 09:49
workaround for Google Cloud Pub/Sub via google-api-client.gem
source "https://rubygems.org"
gem "google-api-client", "0.8.3"