Skip to content

Instantly share code, notes, and snippets.

@sshao
sshao / output
Created July 20, 2015 16:20
flapping pg_query test with 1.8.7 compatible changes
$ [187_compatible] ~/devel/pg_query ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [i686-darwin13.4.0]
$ [187_compatible] ~/devel/pg_query be rspec spec -e 'PgQuery#truncate omits target list'
Run options: include {:full_description=>/PgQuery\#truncate\ omits\ target\ list/}
F
Failures:
1) PgQuery#truncate omits target list
Failure/Error: expect(described_class.parse(query).truncate(40)).to eq 'SELECT ... FROM xyz WHERE a = b'
$ ruby -v user_marshal.rb
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin13]
user_marshaled object
original obj extends: [Extension, Kernel]
unmarshaled obj extends: [Kernel]
@sshao
sshao / defined_test.rb
Created May 20, 2015 17:02
constant scoping
class Ancestor; end
class Ancestor::DescOne
def self.desc_one_defined?
!!defined?(DescOne)
end
end
# Spork defines Spork::TestFramework::RSpec as:
# Spork::TestFramework::RSpec < Spork::TestFramework
@sshao
sshao / output
Last active August 29, 2015 14:21
$ ruby -v test.rb
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin14]
t.value: accessor-set value. didn't go through the defined method!
Checking gcc: found
Checking g++: found
Detected old configuration settings, forcing a clean build
Checking for 'llvm-config': found! (version 3.0 - api: 300)
Checking sizeof(short): 2 bytes
Checking sizeof(int): 4 bytes
Checking sizeof(void*): 8 bytes
Checking sizeof(size_t): 8 bytes
@sshao
sshao / test.rb
Last active August 29, 2015 14:16
more fun with nil marshal
class User
def _dump(level)
""
end
def self._load(*args)
nil
end
end
@sshao
sshao / rbx_head
Last active August 29, 2015 14:16
An exception occurred running /Users/Sophia/devel/rbx-1.8.7/test.rb:
dump format error (unlinked) (ArgumentError)
Backtrace:
Marshal::State(Marshal::StringState)#construct at kernel/common/marshal.rb:530
{ } in Marshal::State(Marshal::StringState)#construct_hash at kernel/common
/marshal.rb:675
Integer(Fixnum)#times at kernel/common/integer.rb:196
@sshao
sshao / points.md
Last active August 29, 2015 14:14
writing a language on the rbx vm
  • Identifying and explaining general concepts
    • scopes, bindings, environments
    • the background context behind 'running' a file/script/method
  • Compiler stages:
    • how they're organized and how they're chained
    • how to define the first/last stages. Does the first stage have to be the parser? (I tried to implement a 'lexer' stage before then, and couldn't figure out how)
  • Initializing the environment (things like initializing heap size/space) before compilation or execution
  • A high-level overview of how code -> s-expressions -> AST/AST nodes -> bytecode
@sshao
sshao / gist:a97a41866ab05e535846
Created January 27, 2015 17:15
segv in running rbx-1.4.1 specs
The Rubinius process is aborting with signal: SIGSEGV
--- begin system info ---
sysname: Darwin
release: 13.4.0
version: Darwin Kernel Version 13.4.0: Sun Aug 17 19:50:11 PDT 2014; root:xnu-2422.115.4~1/RELEASE_X86_64
machine: x86_64
--- end system info ---
--- begin system backtrace ---
0 rbx 0x000000010c25eb72 _ZN8rubiniusL12segv_handlerEi + 354
1 libsystem_platform.dylib 0x00007fff8c5615aa _sigtramp + 26
ruby 1.8.7 (2012-02-08 patchlevel 358) [x86_64-linux]
/home/cnuapp/.gem/ruby/1.8.7/gems/activesupport-1.4.4.2cnu/lib/active_support/core_ext/enumerable.rb:17: warning: method redefined; discarding old group_by
/home/cnuapp/.gem/ruby/1.8.7/gems/activesupport-1.4.4.2cnu/lib/active_support/core_ext/symbol.rb:9: warning: method redefined; discarding old to_proc
/home/cnuapp/.gem/ruby/1.8.7/gems/activerecord-1.15.6.2cnu/lib/active_record/validations.rb:334: warning: `*' interpreted as argument prefix
/home/cnuapp/.gem/ruby/1.8.7/gems/activerecord-1.15.6.2cnu/lib/active_record/validations.rb:363: warning: `*' interpreted as argument prefix
/home/cnuapp/.gem/ruby/1.8.7/gems/activerecord-1.15.6.2cnu/lib/active_record/migration.rb:226: warning: instance variable @ignore_new_methods not initialized
/home/cnuapp/.gem/ruby/1.8.7/gems/activerecord-1.15.6.2cnu/lib/active_record/migration.rb:226: warning: instance variable @ignore_new_methods not initialized
/home/cnuapp/.gem/ruby/1.8.7/gems/activerecord-1.15.6.2cnu/lib/act