Skip to content

Instantly share code, notes, and snippets.

View ten0s's full-sized avatar

Dmitry Klionsky ten0s

View GitHub Profile
@ten0s
ten0s / gist:bee2d4f64c9f51671228
Created November 5, 2015 19:17
vpnc: no response from target
router MT-PON-AT-4
Security -> Enable ALG -> Enable IPSEC ALG
@ten0s
ten0s / gist:6543dd2fbacd76f41f46
Last active November 20, 2015 13:31
Export vagrant cluster
http://docs.vagrantup.com/v2/cli/package.html
http://stackoverflow.com/questions/19094024/is-there-any-way-to-clone-a-vagrant-box-that-is-already-installed?answertab=active#tab-top
cd /home/ten0s/projects/ansible/vagrant/cluster
VBoxManage list vms
"cluster_arbiter_1434442130502_70811" {e8fd64da-b59f-4377-8ddf-5c5d660867a1}
"cluster_arbiter2_1434442190803_23274" {a4beff52-3a11-40e2-885f-b09722a09f85}
"cluster_node1_1434442012780_7672" {73c70448-4333-4932-bdd9-ac774532f591}
"cluster_node2_1442485877717_61624" {633d5855-9f19-427b-af29-8041f8d69829}
@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
@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:5cab692c2e935312874c
Created February 16, 2016 15:45
Add a dot to standard input
awk '{ print $0 } END { print "." }'
@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: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 / 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: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}]).
%?ERROR("ERROR: load_lrn(nil, Opts)~n", [Action, Opts]),