Skip to content

Instantly share code, notes, and snippets.

View ten0s's full-sized avatar

Dmitry Klionsky ten0s

View GitHub Profile
@ten0s
ten0s / gist:691a0cecebacfdaa7a1d
Last active August 29, 2015 14:17
make/setup tsung
cd ~/tmp
curl -O http://tsung.erlang-projects.org/dist/tsung-1.5.1.tar.gz
tar xfz tsung-1.5.1.tar.gz
cd tsung-1.5.1
./configure --prefix=/opt/tsung-1.5.1
make
sudo make install
for f in `ls /opt/tsung-1.5.1/bin`; do sudo ln -s /opt/tsung-1.5.1/bin/$f /usr/local/bin/$f; done
for f in `ls /opt/tsung-1.5.1/lib/tsung/bin`; do sudo ln -s /opt/tsung-1.5.1/lib/tsung/bin/$f /usr/local/bin/$f; done
cd ..
@ten0s
ten0s / gist:6fb14f22a511128691c3
Created April 10, 2015 13:09
Install YUM 3rd party repos
# from https://github.com/akishin/ansible-playbooks/blob/master/snippets/add_third_party_repositories_for_yum.yml
---
- hosts: all
user: root
vars:
gpg_keys:
- http://apt.sw.be/RPM-GPG-KEY.dag.txt
- http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6
- http://rpms.famillecollet.com/RPM-GPG-KEY-remi
repo_rpms:
git tag | grep -E '^[0-9]{1,}\.[0-9]{1,}\.[0-9]{1,}' | awk -F. 'END { printf("%d.%d.%d", $1, $2, $3+1); }'
@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...
@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: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']"
lists:foldr(fun(B, {I, Acc}) -> {I+1, B*trunc(math:pow(2, I))+Acc} end, {0,0}, [I || <<I:1>> <= <<$h>>]).
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
@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 / 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);