Skip to content

Instantly share code, notes, and snippets.

View ten0s's full-sized avatar

Dmitry Klionsky ten0s

View GitHub Profile
@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}
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>>]).
@ten0s
ten0s / gist:40ecec1aace02cbc4051
Created September 11, 2015 15:21
How to debug jinja2 templates
In [1]: from jinja2 import Template
In [2]: Template("{{s.split('-')}}").render(s='a-bad-string')
Out[2]: u"['a', 'bad', 'string']"
@ten0s
ten0s / gist:bb3d68f8577855555236
Created June 4, 2015 10:54
Ansible: Install RabbitMQ draft
- name: Import RabbitMQ GPG key
rpm_key: key=http://www.rabbitmq.com/rabbitmq-signing-key-public.asc
state=present
- name: Register RabbitMQ version
command: rpm -q rabbitmq-server
register: rmq
changed_when: false
failed_when: false
@ten0s
ten0s / gist:f6b4f598a46344ab0dfd
Created June 1, 2015 10:21
Fix Vagrant's Authentication failure after re-building the box
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2202
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection timeout. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
git tag | grep -E '^[0-9]{1,}\.[0-9]{1,}\.[0-9]{1,}' | awk -F. 'END { printf("%d.%d.%d", $1, $2, $3+1); }'