Skip to content

Instantly share code, notes, and snippets.

Dmitry Klionsky ten0s

Block or report user

Report or block ten0s

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:06e2fdc13123d21f7945c787cfbd40e2
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?
View gist:8f67551fe7c3ac32501c20f7b7a39c6f
dropbox stop
#
# Pretent Dropbox is running
# See 'is_dropbox_running' function
# Simulate 'dropbox' string in /proc/%d/cmdline
#
bash -c 'read dropbox' &
6103
View gist:ede7eea028798c22df51c66723446b9e
%?ERROR("ERROR: load_lrn(nil, Opts)~n", [Action, Opts]),
@ten0s
ten0s / gist:0b5458b50ba6c9655e6af827c8b8af30
Created May 6, 2016
Distributed publish using gproc w/o gen_leader
View gist:0b5458b50ba6c9655e6af827c8b8af30
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 Apr 13, 2016
Quick timed evaluation of erlang function call
View gist:1d7c426e7d59ef938c74e16eb19f9b0b
-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 Feb 29, 2016
Run an erlang script without global erlang installed, but with a release's erts
View gist:4cd1050aebf7054008ac
LOCAL
=====
$ scp util.es remote:/home/user/
REMOTE
======
$ pwd
/home/user
$ ./util.es
@ten0s
ten0s / main.es
Last active Feb 18, 2016
Erlang escript + signal handling
View main.es
$ ./main.sh
erl: started.
erl: working...
erl: working...
erl: working...
^Cerl: working...
erl: stopped.
@ten0s
ten0s / gist:5cab692c2e935312874c
Created Feb 16, 2016
Add a dot to standard input
View gist:5cab692c2e935312874c
awk '{ print $0 } END { print "." }'
View gist:ea19610f94ae1f1803e8
$ 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 Mar 16, 2016
Setup the default browser in Ubuntu/Mint
View gist:0c4ee92260242786e4af
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
You can’t perform that action at this time.