Skip to content

Instantly share code, notes, and snippets.

@bamthomas
bamthomas / Dockerfile
Last active August 29, 2015 14:07
Dev environment UTF-8 fr with bootstrap for ansible
FROM ubuntu:14.04
RUN locale-gen fr_FR.UTF-8
ENV LANG fr_FR.UTF-8
ENV LANGUAGE fr:en
ENV LC_ALL fr_FR.UTF-8
RUN sed -i 's/# deb/deb/' /etc/apt/sources.list
RUN apt-get update && apt-get install -y openssh-server git
RUN mkdir /var/run/sshd
@bamthomas
bamthomas / Dockerfile
Last active August 29, 2015 14:07
docker replicaset node
FROM ubuntu:latest
RUN locale-gen fr_FR.UTF-8
ENV LANG fr_FR.UTF-8
ENV LANGUAGE fr:en
ENV LC_ALL fr_FR.UTF-8
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
RUN echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | tee /etc/apt/sources.list.d/10gen.list
@bamthomas
bamthomas / Dockerfile
Last active August 29, 2015 14:07
docker rethinkdb node
FROM ubuntu:14.04
RUN locale-gen fr_FR.UTF-8
ENV LANG fr_FR.UTF-8
ENV LANGUAGE fr:en
ENV LC_ALL fr_FR.UTF-8
RUN apt-get update
RUN apt-get install -y wget
RUN wget -qO- http://download.rethinkdb.com/apt/pubkey.gpg | sudo apt-key add -
@bamthomas
bamthomas / Dockerfile
Created November 4, 2014 22:01
Dockerfile ejabberd
FROM ubuntu:14.04
RUN apt-get update && apt-get install -y wget
RUN wget http://www.process-one.net/downloads/downloads-action.php?file=/ejabberd/14.07/ejabberd-14.07-linux-x86_64-installer.run -O ejabberd-14.07-linux-x86_64-installer.run
RUN chmod +x ejabberd-14.07-linux-x86_64-installer.run
RUN ./ejabberd-14.07-linux-x86_64-installer.run --mode unattended --adminpw admin
ADD ejabberd.yml /opt/ejabberd-14.07/conf/
EXPOSE 5222 5280
@bamthomas
bamthomas / twisted_xmpp_connect.py
Created November 11, 2014 22:20
Minimum xmpp connexion with twisted
from twisted.internet import reactor
from twisted.python.syslog import startLogging
from twisted.words.protocols.jabber.client import XMPPAuthenticator
from twisted.words.protocols.jabber.jid import JID
from twisted.words.protocols.jabber.xmlstream import XmlStreamFactory
from wokkel.subprotocols import StreamManager, XMPPHandler
startLogging()
factory = XmlStreamFactory(XMPPAuthenticator(JID('user@localhost'), u'pass123'))
def assert_dict_is_in_csv(exported_file_content, expected_line_dict):
lines = exported_file_content.rstrip('\r\n').split('\r\n')
for line in lines:
if all(['%s' % value in line for value in expected_line_dict.values()]):
return
raise AssertionError('%s not in file [%s]' % (expected_line_dict, lines))
@bamthomas
bamthomas / tcpdump_vlan100.sh
Created April 19, 2015 15:35
tcpdump vlan 100 freebox
tcpdump -i eth0 -Uw - | tcpdump -en -r - vlan 100
15:33:48.204734 00:07:cb:c6:5a:d2 > ff:ff:ff:ff:ff:ff, ethertype 802.1Q (0x8100), length 334: vlan 100, p 0, ethertype IPv4, 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:07:cb:c6:5a:d2, length 288
15:33:48.220336 00:07:cb:c6:5a:d2 > ff:ff:ff:ff:ff:ff, ethertype 802.1Q (0x8100), length 346: vlan 100, p 0, ethertype IPv4, 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:07:cb:c6:5a:d2, length 300
15:33:48.928038 00:07:cb:c6:5a:d2 > 33:33:00:00:00:16, ethertype 802.1Q (0x8100), length 94: vlan 100, p 0, ethertype IPv6, :: > ff02::16: HBH ICMP6, multicast listener report v2, 1 group record(s), length 28
15:33:49.088055 00:07:cb:c6:5a:d2 > 33:33:ff:c6:5a:d2, ethertype 802.1Q (0x8100), length 82: vlan 100, p 0, ethertype IPv6, :: > ff02::1:ffc6:5ad2: ICMP6, neighbor solicitation, who has fe80::207:cbff:fec6:5ad2, length 24
15:33:50.088024 00:07:cb:c6:5a:d2 > 33:33:00:00:00:02, ethertype 802.1Q (0x8100), length 74: vlan 100, p 0, ethertyp
@bamthomas
bamthomas / gist:b0f1fc0e1211fb49f155
Created June 12, 2015 22:11
aiomysql exception
Traceback (most recent call last):
File "/home/bruno/src/DomoPyc/venv/lib/python3.4/site-packages/aiomysql/connection.py", line 466, in _read_packet
packet_header = yield from self._reader.readexactly(4)
File "/usr/local/lib/python3.4/asyncio/streams.py", line 482, in readexactly
raise IncompleteReadError(partial, len(partial) + n)
asyncio.streams.IncompleteReadError: 0 bytes read on a total of 4 expected bytes
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
@bamthomas
bamthomas / update_hosts.sh
Last active December 22, 2015 14:21
update /etc/hosts to link with localhost the docker-compose services
#!/bin/bash
# -*- coding: UTF8 -*-
function rm_hosts {
for container_name in $*
do
host=$(docker inspect --format '{{ index .Config.Labels "com.docker.compose.service" }}' $container_name)
remove_line_infile $host /etc/hosts
done
}
@bamthomas
bamthomas / Dockerfile
Created April 1, 2016 08:45
ubuntu 14LTS with docker
FROM ubuntu:14.04
RUN apt-get -y update && apt-get -y install apt-transport-https ca-certificates
RUN apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
RUN echo 'deb https://apt.dockerproject.org/repo ubuntu-trusty main' > /etc/apt/sources.list.d/docker.list
RUN apt-get -y update && apt-get -y install docker-engine