Skip to content

Instantly share code, notes, and snippets.

@knewter
knewter / unexpected.md
Created May 29, 2013 17:04
Can't make second command die when parent shell dies

When I execute the following:

su - deployer -c "ls; sleep 250"

It outputs the ls and then sleeps for a few minutes. If I hit Ctrl+C, I get this output:

Session terminated, terminating shell... ...killed.
@knewter
knewter / .rvmrc
Last active December 18, 2015 17:19
Simultaneous Read Write hanging with sslsocket in celluloid-io in jruby
rvm jruby-1.7.4@celluloid_jruby_ssl_repro --create
#rvm ruby-1.9.3@celluloid_jruby_ssl_repro --create
--(jadams@aye-seven)-(33/pts/22)-(1747/19-Jun-13)--
--($:~/ruby/celluloid-io)(simultaneous-read-write-debug)jruby-1.7.2@celluloid_io--
$ bundle exec rspec spec/celluloid/io/ssl_socket_spec.rb:84
[Coveralls] Set up the SimpleCov formatter.
[Coveralls] Using SimpleCov's default settings.
/home/jadams/.rvm/gems/jruby-1.7.2@celluloid_io/gems/simplecov-0.7.1/lib/simplecov.rb:34 warning: tracing (e.g. set_trace_func) will not capture all events without --debug flag
Run options: include {:locations=>{"./spec/celluloid/io/ssl_socket_spec.rb"=>[84]}}
Celluloid::IO::SSLSocket
inside Celluloid::IO
Eshell V5.10.2 (abort with ^G)
1> c(chatserver).
chatserver.erl:2: Warning: undefined callback function handle_cast/2 (behaviour 'gen_server')
chatserver.erl:18: Warning: variable 'From' is unused
chatserver.erl:18: Warning: variable 'State' is unused
chatserver.erl:18: Warning: variable 'Username' is unused
chatserver.erl:20: Warning: variable 'From' is unused
chatserver.erl:22: Warning: variable 'From' is unused
chatserver.erl:22: Warning: variable 'S' is unused
chatserver.erl:29: Warning: variable 'State' is unused
11> chatserver:join(Pid, "knewter").
** exception exit: {noproc,{gen_server,call,[<0.46.0>,{join,"knewter"}]}}
in function gen_server:call/2 (gen_server.erl, line 180)
@knewter
knewter / gist:6328807
Created August 24, 2013 15:39
Elixir anonymous function recursion
calculate_bill = fn
{:item, price} -> price
[h|t] -> calculate_bill.(h) + calculate_bill.(t)
end
calculate_bill.([{:item, 20}, {:item, 10}])
calculate_bill.({:item, 35})
# It should also work with a list of more than two elements:
calculate_bill.([{:item, 20}, {:item, 10}, {:item, 35}])
--(jadams@jibbajabba)-(190/pts/7)-(2229/25-Aug-13)--
--($:~/erlang/chromechat)(master)ruby-2.0.0-p0--
$ git push jadams master
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 279 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)
-----> Building chromechat ...
remote: WARNING: IPv4 forwarding is disabled.
iex(2)> :application.start(:gproc)
:ok
iex(3)> :gproc.reg(:foo, :bar)
** (ArgumentError) argument error
src/gproc.erl:922: :gproc.reg(:foo, :bar)
erl_eval.erl:569: :erl_eval.do_apply/6
src/elixir.erl:138: :elixir.eval_forms/3
iex(1)> :application.start(:gproc)
:ok
iex(2)> :application.start(:gproc)
{:error, {:already_started, :gproc}}
iex(3)> :gproc.reg({:n, :l, 'foo'}, 'bar')
true
iex(4)> :gproc.get_value({:n, :l, 'foo'})
'bar'
iex(5)> :gproc.get_value({:n, :l, 'foos'})
** (ArgumentError) argument error
$ dialyzer ec_math.erl
Checking whether the PLT /home/jadams/.dialyzer_plt is up-to-date...
dialyzer: Not a regular file: /usr/lib/erlang/lib/erts-5.10.2/ebin/erl_prim_loader.beam