Skip to content

Instantly share code, notes, and snippets.

View ten0s's full-sized avatar

Dmitry Klionsky ten0s

View GitHub Profile
for i in `seq 1 5`; do erl -sname n${i} -noshell -eval 'io:format("~p~n", [erlang:md5(term_to_binary(lists:foldl(fun(I, Acc) -> Acc#{{abc, I} => I} end, #{}, lists:seq(1,100))))]), init:stop().' ; done
<<22,221,123,219,72,54,94,163,81,131,119,45,111,211,168,96>>
<<208,100,35,243,94,225,254,14,159,222,67,32,242,134,182,171>>
<<22,221,123,219,72,54,94,163,81,131,119,45,111,211,168,96>>
<<22,221,123,219,72,54,94,163,81,131,119,45,111,211,168,96>>
<<22,221,123,219,72,54,94,163,81,131,119,45,111,211,168,96>>
What's up?
@ten0s
ten0s / gist:8f67551fe7c3ac32501c20f7b7a39c6f
Last active September 30, 2016 01:04
Dropbox protocol
dropbox stop
#
# Pretent Dropbox is running
# See 'is_dropbox_running' function
# Simulate 'dropbox' string in /proc/%d/cmdline
#
bash -c 'read dropbox' &
6103
%?ERROR("ERROR: load_lrn(nil, Opts)~n", [Action, Opts]),
@ten0s
ten0s / gist:0b5458b50ba6c9655e6af827c8b8af30
Created May 6, 2016 09:38
Distributed publish using gproc w/o gen_leader
Re: [erlang-questions] gproc and gen_event
Of course, for a distributed pub/sub, you don't really need to turn on
the distributed parts of gproc. Running a local gproc instance on each
node, you can publish like so:
publish(Event, Data) ->
rpc:eval_everywhere(
gproc, send,
[{p, l, {?MODULE, Event}}, {?MODULE, Event, Data}]).
@ten0s
ten0s / gist:1d7c426e7d59ef938c74e16eb19f9b0b
Last active April 13, 2016 14:37
Quick timed evaluation of erlang function call
-define(TIME(Call),
(fun() ->
{Time, Value} = timer:tc(fun() -> Call end),
io:format("Call: ~s took: ~p ms~n", [??Call, Time/1000]),
Value
end)()
).
In the code:
...
@ten0s
ten0s / gist:4cd1050aebf7054008ac
Created February 29, 2016 15:15
Run an erlang script without global erlang installed, but with a release's erts
LOCAL
=====
$ scp util.es remote:/home/user/
REMOTE
======
$ pwd
/home/user
$ ./util.es
@ten0s
ten0s / main.es
Last active February 18, 2016 11:59
Erlang escript + signal handling
$ ./main.sh
erl: started.
erl: working...
erl: working...
erl: working...
^Cerl: working...
erl: stopped.
@ten0s
ten0s / gist:5cab692c2e935312874c
Created February 16, 2016 15:45
Add a dot to standard input
awk '{ print $0 } END { print "." }'
@ten0s
ten0s / gist:ea19610f94ae1f1803e8
Last active April 19, 2016 11:02
Install Google Fonts (https://www.google.com/fonts) into Linux
$ fc-match "open sans"
DejaVuSans.ttf: "DejaVu Sans" "Book"
$ mkdir -p ~/.fonts
$ cd ~/.fonts
# download google fonts downloader, make it executable
$ wget https://raw.githubusercontent.com/neverpanic/google-font-download/master/google-font-download
$ chmod +x google-font-download
@ten0s
ten0s / gist:0c4ee92260242786e4af
Last active March 16, 2016 08:30
Setup the default browser in Ubuntu/Mint
sudo update-alternatives --config x-www-browser
credits:
http://ubuntuforums.org/showthread.php?t=201430
gvfs-mime --query x-scheme-handler/http
gvfs-mime --query x-scheme-handler/https
gvfs-mime --set x-scheme-handler/http google-chrome.desktop | firefox.desktop
gvfs-mime --set x-scheme-handler/https google-chrome.desktop | firefox.desktop