Skip to content

Instantly share code, notes, and snippets.

View ten0s's full-sized avatar

Dmitry Klionsky ten0s

View GitHub Profile
@ten0s
ten0s / ipython_graphviz.ipynb
Created July 23, 2016 13:32
Display graphviz dot in Jupyter using IPython2
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ten0s
ten0s / ibash_graphviz.ipynb
Last active July 23, 2016 13:31
Display graphviz dot in Jupyter using IBash kernel
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ten0s
ten0s / git-sshurl
Created May 20, 2014 13:00
Replace github's https url with ssh
function git-sshurl() {
local OldUrl=`git remote -v | sed -E -n 's/origin\s*(.*) \(push\)/\1/p'`
local NewUrl=`echo $OldUrl | sed -E 's#https://(.*)/(.*)/(.*)#git@\1:\2/\3#'`
echo "old url:" $OldUrl
echo "new url:" $NewUrl
git remote set-url origin $NewUrl
}
@ten0s
ten0s / gist:0831975562253510a0f322ba1baeaad7
Created May 24, 2016 12:19
Check Erlang node is distributed
pong = net_adm:ping(node()).
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?
%?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: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: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: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