Skip to content

Instantly share code, notes, and snippets.

View brixen's full-sized avatar

Brian Shirai brixen

View GitHub Profile
@brixen
brixen / kw.rb
Last active August 29, 2015 14:02
$ ruby -v kw.rb
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
=> let's try with m(o)
#<Object:0x007f88219791d0>
=> and with m(**o)
--- to_hash ---
{:a=>1}
70111327930320
#<Object:0x007f88219791d0>
=> how about mk(o)
vagrant@precise64:~/test/rubinius/2.2.8/gems/bin$ ls -l
total 36
-rwxr-xr-x 1 vagrant vagrant 495 Jun 10 21:04 bundle
-rwxr-xr-x 1 vagrant vagrant 496 Jun 10 21:04 bundler
-rwxr-xr-x 1 vagrant vagrant 501 Jun 10 21:05 irb
-rwxr-xr-x 1 vagrant vagrant 484 Jun 10 21:04 racc
-rwxr-xr-x 1 vagrant vagrant 486 Jun 10 21:04 racc2y
-rwxr-xr-x 1 vagrant vagrant 484 Jun 10 21:04 rake
-rwxr-xr-x 1 vagrant vagrant 484 Jun 10 21:04 rdoc
-rwxr-xr-x 1 vagrant vagrant 482 Jun 10 21:04 ri
while a
b[x] ||=
(
break if c
d
)
end
f = open "/dev/null"
f.close_on_exec = false
f.autoclose = false
system("ls", "-l", "/proc/self/fd/#{f.fileno}")
p f.closed?
rubinius 2.2.10.n178 (2.1.0 18751108 2014-06-27 D) [x86_64-darwin13.2.0]
An exception occurred running foo.rb:
protected method `hash' called on an instance of User. (NoMethodError)
Backtrace:
Kernel(User)#hash (method_missing) at kernel/delta/kernel.rb:78
Rubinius::IdentityMap#insert at kernel/common/identity_map.rb:45
{ } in Rubinius::IdentityMap#load at kernel/common/identity_map.rb:255
$ ruby -v -e 'p lambda { |a, | a }.([1, 2])'
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
[1, 2]
$ ruby -v -e 'def m(a) yield a end; p m([1, 2]) { |a, | a }'
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
1
$ ruby -v -e 'def m(a) yield a end; l = lambda { |a, | a }; p l.([1, 2]); p m([1, 2], &l)'
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
[1, 2]
[1, 2]
{"prefix"=>"/Users/bshirai/.rubies/rbx-2.2.10",
"install_prefix"=>"",
"DLEXT"=>"bundle",
"EXEEXT"=>"",
"ruby_install_name"=>"rbx",
"RUBY_INSTALL_NAME"=>"rbx",
"exec_prefix"=>"/Users/bshirai/.rubies/rbx-2.2.10",
"bindir"=>"/Users/bshirai/.rubies/rbx-2.2.10/bin",
"sbindir"=>"/Users/bshirai/.rubies/rbx-2.2.10/sbin",
"libexecdir"=>"/Users/bshirai/.rubies/rbx-2.2.10/libexec",
CLM-bshirai:examples bshirai$ gem install celluloid
Fetching: timers-1.1.0.gem (100%)
Successfully installed timers-1.1.0
Fetching: celluloid-0.15.2.gem (100%)
Successfully installed celluloid-0.15.2
2 gems installed
CLM-bshirai:examples bshirai$ ruby -v pool.rb
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
/source/celluloid/celluloid/lib/celluloid.rb:513: warning: global variable `$CELLULOID_TEST' not initialized
/source/celluloid/celluloid/lib/celluloid.rb:138: warning: instance variable @shutdown_registered not initialized
CLM-bshirai:examples bshirai$ time ruby -v pool.rb
rubinius 2.2.10 (2.1.0 bf61ae2e 2014-06-27 JI) [x86_64-darwin13.2.0]
Megahashing!
Since you're using a Ruby with parallel thread execution, this should light up all your cores
["ec246002d95931b28a23b33e026d8567bf9441968466c914e7c15a9c41caccec5336cbacfcc3e9d0506e139d24d533ed064b1dddc62d5148df4f43d3db5908db", "bf99b9548623e75c888f1c537d1d0a885c6f93005522f963937cb48a8502e53e7ccb30edfc2f74b0164e91551e0c540af254feaab81b41a662e760ddbe59a032", "acb0d67ed57ba72a8a93f199a09213c0e8c3f227909f8fda468ffbc513869dae6300845b062a402965dd47605ba08e7c88846fb69720f7af3165f284bb01d1bb", "8683e53234b98d0d797c3b8668174f1e62e859fcacb23f028c687434df3b9f0a640e06983a3c5e8568a07af1136c6d985408b7d76a586bbf31dcabd3023cc90e", "05c11f52104c16171928c3af9a5133e00fc456755d94bb3c3030304d753d8f0078e4c28ebf52728dc28b925a04a7127edfb27b603d94fde97a8df250bda90f92", "09d66b02d24b2798c913bcb2f6bdf4bf74f13d3877fe5b11a09a3e40acbf64f27b2601a5762502c337e8f6c3e03f187c3a3c79230ff5773968a608ff85de0edf", "3d4
[75 of 76] Compiling Distribution.Client.Sandbox ( Distribution/Client/Sandbox.hs, dist/build/cabal/cabal-tmp/Distribution/Client/Sandbox.o )
[76 of 76] Compiling Main ( Main.hs, dist/build/cabal/cabal-tmp/Main.o )
Linking dist/build/cabal/cabal ...
Installing executable(s) in /Users/bshirai/.cabal/bin
Installed cabal-install-1.20.0.3
clm-bshirai:~ bshirai$ cabal update
Downloading the latest package list from hackage.haskell.org
Note: there is a new version of cabal-install available.
To upgrade, run: cabal install cabal-install
clm-bshirai:~ bshirai$ cabal install cabal-install