Skip to content

Instantly share code, notes, and snippets.

View sivsushruth's full-sized avatar

Sushruth Sivaramakrishnan sivsushruth

View GitHub Profile
sivsushruth@ubuntu:~/barrel/embed-v3/barrel-embed$ iex -S mix
Erlang/OTP 18 [erts-7.3] [source] [64-bit] [smp:4:4] [async-threads:10] [kernel-poll:false]
00:44:59.469 [info] Application lager started on node nonode@nohost
00:44:59.469 [info] Application logger started on node nonode@nohost
00:44:59.469 [info] Application barrel_ex_logger started on node nonode@nohost
=PROGRESS REPORT==== 18-Jun-2016::00:44:59 ===
supervisor: {local,sasl_safe_sup}
started: [{pid,<0.363.0>},
@sivsushruth
sivsushruth / barrel_log_event.erl
Created April 8, 2016 08:37
Barrel Log Event Handler
-module(barrel_log_event).
-behaviour(gen_server).
% public API
-export([start_link/0, stop/0]).
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]).
start_link() ->
@sivsushruth
sivsushruth / Error Log
Created April 5, 2016 11:55
barre_futon added to rebar3.config and in the apps folder
(barrel@127.0.0.1)1> [<0.334.0>] [error] Uncaught error in HTTP request: {error,undef}
[<0.334.0>] [info] Stacktrace: [{couch_httpd_request,method,[{httpd,{mochiweb_request,[#Port<0.5377>,[{recbuf,8192}],'GET',"/_utils/",{1,1},{10,{"host",{'Host',"localhost:4444"},{"connection",{'Connection',"keep-alive"},{"cache-control",{'Cache-Control',"max-age=0"},{"accept",{'Accept',"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"},nil,{"accept-encoding",{'Accept-Encoding',"gzip, deflate, sdch"},nil,{"accept-language",{'Accept-Language',"en-GB,en-US;q=0.8,en;q=0.6"},nil,nil}}},nil},
{"cookie",{'Cookie',"4444_recent=demo"},nil,nil}},{"upgrade-insecure-requests",{"Upgrade-Insecure-Requests","1"},{"if-modified-since",{'If-Modified-Since',"Tue, 05 Apr 2016 11:48:11 GMT"},nil,nil},{"user-agent",{'User-Agent',"Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36"},nil,nil}}}}]},"127.0.0.1",'GET',[<<"_utils">>],[<<"_utils">>],{dict,9,16,16,8,80
defmodule HeyJude do
@lines [["make it bad", "be afraid", "let me down"], ["Take a sad song and make it better", "You were made to go out and get her", "You have found her, now go and get her"]]
def lyrics do
[intro]
|> verse(0)
|> verse(1)
|> chorus(0)
|> verse(2)
|> chorus(1)
@sivsushruth
sivsushruth / barrel-1.14.1
Created March 12, 2016 18:33
Support for elixir view in BarrelDB
#Relevent part
find_erts_dir
export ROOTDIR="$RELEASE_ROOT_DIR"
export BINDIR="$ERTS_DIR/bin"
export EMU="beam"
export PROGNAME="erl"
export ERL_LIBS="/usr/local/lib/elixir/lib"
export LD_LIBRARY_PATH="$ERTS_DIR/lib:$LD_LIBRARY_PATH"
ERTS_LIB_DIR="$ERTS_DIR/../lib"
fun({Doc}) ->
DocId = couch_util:get_value(<<"_id">>, Doc, null),
Emit(DocId, null)
end.
[<0.354.0>] [error] gen_server <0.354.0> terminated with reason: {'module could not be loaded',[{'Elixir.Code',compile_string,[<<"fn Doc -> IO.puts
\"test puts\" end">>],[]},{'Elixir.CouchElixirUtils',to_erlang,1,[{file,"apps/couch/src/couch_elixir_utils.ex"},{line,4}]},{couch_elixir_process,makefun,2,[{file,"/home/sivsushruth/gsoc/barrel-platform/_build/default/lib/couch/src/couch_elixir_process.erl"},{line,326}]},{couch_elixir_process,run,2,[{file,"/home/sivsushruth/gsoc/barrel-platform/_build/default/lib/couch/src/couch_elixir_process.erl"},{line,143}]},...]}
[<0.354.0>] [error] CRASH REPORT Process <0.354.0> with 4 neighbours exited with reason: call to undefined function 'Elixir.Code':compile_string(<<"fn Doc -> IO.puts \"test puts\" end">>) in gen_server:terminate/7 line 826
[<0.184.0>] [error] CRASH REPORT Process <0.184.0> with 0 neighbours crashed with reason: bad argument in call to erlang:list_to_binary([{'Elixir.Code',compile_string,[<<"fn Doc -> IO.puts \"test puts\" end">>],[]},{'Elixir.CouchEli
{doc,<<"45dcf16026bd4574436d3604e6d36024">>,
{0,[]},
{[{<<"language">>,<<"elixir">>},
{<<"options">>,{[]}},
{<<"views">>,
{[{<<"temp">>,
{[{<<"map">>,
<<"%native query start\nfun({Doc}) ->\n DocId = couch_util:get_value(<<\"_id\">>, Doc, null),\n Emit(DocId, null)\nend.\n%native query end">>}]}}]}}]},
[],false,[]}
@sivsushruth
sivsushruth / couch_elixir.ex
Last active March 11, 2016 21:33
calling elixir compiled from erlang
defmodule CouchElixir do
def main(args) do
"sample return"
end
end
sivsushruth@fafa-server:~/barrel-platform$ sudo DEBUG=1 ./rebar3 compile
===> Evaluating config script "rebar.config.script"
===> Expanded command sequence to be run: [{default,app_discovery},
{default,install_deps},
{default,lock},
{default,compile}]
===> Evaluating config script "/home/sivsushruth/barrel-platform/_build/default/lib/gproc/rebar.config.script"
===> Evaluating config script "/home/sivsushruth/barrel-platform/_build/default/lib/hackney/rebar.config.script"
===> Verifying dependencies...
===> Evaluating config script "/home/sivsushruth/barrel-platform/_build/default/lib/gproc/rebar.config.script"