Skip to content

Instantly share code, notes, and snippets.

View ten0s's full-sized avatar

Dmitry Klionsky ten0s

View GitHub Profile
@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: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: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 / hello.erl
Last active October 27, 2015 14:45
Nif from HEX (from http://tryerl.seriyps.ru/)
% -*- coding: utf8 -*-
% Example of Nif testing.
% This one only works with erlang 17.4 and 17.3
%
% $ cat hello.c
% #include "erl_nif.h"
%
% static ERL_NIF_TERM say(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
% {
% return enif_make_string(env, "Hello world!", ERL_NIF_LATIN1);
@ten0s
ten0s / gist:9ed2bd65b362e4defa50
Created October 26, 2015 12:25
TypeError: argument of type 'StrictUndefined' is not iterable
Ansible template
template: src={{item}}.j2 dest=/etc/nginx/conf.d/{{item}}
with_items:
- server.conf
notify: Restart Nginx
fails with:
fatal: [test] => {'msg': "TypeError: argument of type 'StrictUndefined' is not iterable", 'failed': True}
@ten0s
ten0s / gist:b9a18344aa046ca3ee3c
Last active October 21, 2015 15:46
Install vagrant env and build the project
1. Download and Install VirtuaBox 4.3.20
----------------------------------------
Windows
http://download.virtualbox.org/virtualbox/4.3.20/VirtualBox-4.3.20-96997-Win.exe
Linux
https://www.virtualbox.org/wiki/Linux_Downloads
2. Start Virtualbox UI and make sure you are able to create 64-bit guests
-------------------------------------------------------------------------
Enable virtualization in BIOS otherwise.
vagrant init ubuntu/precise32
vagrant up
vagrant ssh
Deps
----
sudo apt-get update
sudo apt-get install build-essential curl dos2unix gdb emacs git htop mc wget libwxgtk2.8-dev libglu-dev xsltproc libssl-dev libncurses5-dev fop unixodbc-dev default-jdk libtk-img-dev
cd
lists:foldr(fun(B, {I, Acc}) -> {I+1, B*trunc(math:pow(2, I))+Acc} end, {0,0}, [I || <<I:1>> <= <<$h>>]).