Skip to content

Instantly share code, notes, and snippets.

View wjessop's full-sized avatar
🤖

Will Jessop wjessop

🤖
View GitHub Profile
def initialize
@server = self
@callback_server = Sinatra.new do
post '/callback' do
puts "Sinatra got request with params #{params.inspect}"
settings.this.update_queue << { :blah }
end
end
@callback_server.port = callback_port
# Fails with:
# $ ruby test.rb
# /Users/will/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/thread.rb:189:in `sleep': deadlock detected (fatal)
# from /Users/will/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/thread.rb:189:in `block in pop'
# from <internal:prelude>:10:in `synchronize'
# from /Users/will/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/thread.rb:184:in `pop'
# from test.rb:27:in `<main>'
require 'thread'
@wjessop
wjessop / foo.rb
Created September 27, 2012 14:33
module Category
def to_tree
{
'category' => self,
'children' => self.children.map { |c| c.to_tree }
}
end
end
class Categories
$ rbx -X18 -e '"".match /[^\u{20}-\u{7E}]/'
An exception occurred evaluating command line code
empty range in char class: [^\u{20}-\u{7E}] (RegexpError)
Backtrace:
Regexp#initialize at kernel/common/regexp18.rb:27
Class#new at kernel/alpha.rb:96
{ } in Object#__script__ at -e:1
Rubinius::BlockEnvironment#call_on_instance at kernel/common/block_environment.rb:75
Kernel(Rubinius::Loader)#eval at kernel/common/eval.rb:75
1.9.3p286 :003 > a = [1,2,3]
=> [1, 2, 3]
1.9.3p286 :004 > a.shift
=> 1
1.9.3p286 :005 > a
=> [2, 3]
[1.9.3] ~ $ ruby -e 'one = two = "something".gsub "o", "0"'
[1.9.3] ~ $
CRASH: A fatal error has occurred.
Backtrace:
0 rbx 0x000000010a29e4d0 _ZN8rubiniusL12segv_handlerEi + 544
1 libsystem_c.dylib 0x00007fff8f5b98ea _sigtramp + 26
2 ??? 0x000000010b9efab8 0x0 + 4489935544
3 rbx 0x000000010a3b90b2 _ZN8rubinius12CompiledCode4Info4markEPNS_6ObjectERNS_10ObjectMarkE + 318
4 rbx 0x000000010a44fa0e _ZN8rubinius16GarbageCollector11scan_objectEPNS_6ObjectE + 456
5 rbx 0x000000010a44d42b _ZN8rubinius7BakerGC7collectERNS_6GCDataEPNS_17YoungCollectStatsE + 107
6 rbx 0x000000010a374189 _ZN8rubinius12ObjectMemory13collect_youngERNS_6GCDataEPNS_17YoungCollectStatsE + 67
[1.9.3] ~/www/demo $ curl -v -d auth_token=8ygqnnCEyVvj9qkdX63W http://localhost:3000/foo.json
* About to connect() to localhost port 3000 (#0)
* Trying ::1...
* Connection refused
* Trying 127.0.0.1...
* connected
* Connected to localhost (127.0.0.1) port 3000 (#0)
> POST /foo.json HTTP/1.1
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5
> Host: localhost:3000
[1.9.3] ~/www/demo $ curl -v -d auth_token=8ygqnnCEyVvj9qkdX63W http://localhost:3000/foo.json
* About to connect() to localhost port 3000 (#0)
* Trying ::1...
* Connection refused
* Trying 127.0.0.1...
* connected
* Connected to localhost (127.0.0.1) port 3000 (#0)
> POST /foo.json HTTP/1.1
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5
> Host: localhost:3000
I saw C++ coming and read the book - or at least tried to read the book -
there's a dent
in the wall behind my piano, where the book hit the wall - Improvements to
C should make things
easier not more complicated, I thought.
-- Joe Armstrong, http://erlang.org/pipermail/erlang-questions/2013-January/071949.html