Skip to content

Instantly share code, notes, and snippets.

@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'))
@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 / 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
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
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 / chroot.sh
Last active August 29, 2015 14:00
mounting host chroot pseudo filesystem
bindir=$(dirname $0)
root_dir=$bindir/root_dir
montePointsPourChroot() {
sudo echo -ne « mounting pseudo filesystems: »
for pseudo in dev proc sys
do
sudo mount –bind /$pseudo $root_dir/$pseudo
echo -ne » $pseudo »
done
@bamthomas
bamthomas / test_docker.sh
Last active August 29, 2015 13:56
Playing with docker
# install with ubuntu 13.10 64 bits - warning with 32bits apt wont find the package
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
sudo sh -c "echo deb http://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"
sudo apt-get update
sudo apt-get install lxc-docker
# check install ok
sudo docker ps -a
# lets play with containers
@bamthomas
bamthomas / gist:8210776
Last active January 1, 2016 22:29
chroot with peudo-devices
sudo mount /dev/sda1 /mnt
sudo mount --bind /dev /mnt/dev
sudo mount --bind /dev/pts /mnt/dev/pts
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys
sudo chroot /mnt
@bamthomas
bamthomas / gist:7970938
Last active December 31, 2015 10:09
OpenSCAD mug
$fn = 200;
tasse(160, 120);
rotate([90, 0, 0])
translate([65, 80, 0])
anse_ronde();
module tasse(hauteur, diametre) {
difference() {
@bamthomas
bamthomas / myzip.py
Last active December 29, 2015 00:49
in memory zip with python
from zipfile import ZipFile
def append_file(memory_stream, file_name, file_content):
with ZipFile(memory_stream, 'a') as zf:
zf.writestr(file_name, file_content)