Skip to content

Instantly share code, notes, and snippets.

View ioggstream's full-sized avatar

Roberto Polli ioggstream

View GitHub Profile
@ioggstream
ioggstream / omprog-twisted-sample.py
Created September 2, 2014 20:05
omprog-twisted-sample.py
#!/usr/bin/env python
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.
"""
Example using stdio, LineReceiver, ClientFactory and twisted.web.client.
This could be used with rsyslog omprog module to forward messages to
different servers
@ioggstream
ioggstream / gist:3a6cb1b0f3cf319a5431
Last active August 29, 2015 14:06
maven-cheatsheet.xml
<!-- disable some repository from a catch-all mirror -->
<mirrors>
<mirror>
<id>insideFirewallRepo</id>
<mirrorOf>!nexus-repo-releases,!nexus-repo-snapshots,*</mirrorOf>
<name>Mirror of the world outside.</name>
<url>http://nexus_url/nexus/content/groups/public/</url>
</mirror>
</mirrors>
@ioggstream
ioggstream / arquillian-maven-profiles.xml
Created November 27, 2014 15:17
arquillian-maven-profiles.xml
<!-- Those profiles enables arquillian integration tests under
* src/it/java
* src/it/resources
To run them, use eg.
# mvn -Darquillian=true -Parq-eap6-managed
They rely on src/it/resources/arquillian.xml containing the
container qualifiers named:
* eap6-managed
@ioggstream
ioggstream / 20-test.conf
Created December 3, 2014 22:14
Use rsyslog to separate log levels (eg. for twisted apps)
#cat /etc/rsyslog.d/20-test.conf
# Define a new template to trace syslogseverity
$template TwistedTmpl,"%TIMESTAMP% %syslogtag% %syslogseverity-text%:%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n"
# Then split critical, error, warning, notice in test-rsyslog...
if $programname == 'twisted' and $syslogseverity <= 4 then /var/log/test-rsyslog.log;TwistedTmpl
& ~
# and debug, info in test-rsyslog-debug
if $programname == 'twisted' and $syslogseverity > 4 then /var/log/test-rsyslog-debug.log;TwistedTmpl
@ioggstream
ioggstream / srt-align.py
Created April 25, 2015 14:42
Align subtitles to video file
from __future__ import print_function, division
from time import gmtime,localtime,strptime,strftime,mktime
from sys import argv
@ioggstream
ioggstream / my-example.cnf
Last active August 29, 2015 14:21
Sample My.cnf
#
# A set of default configurations for MySQL
#
[mysql]
socket=/var/lib/mysql/mysql.sock
#
# Configurazione per mysql enterprise backup
#
[mysqlbackup]
SELECT constraint_name, constraint_type, column_name
from user_constraints natural join user_cons_columns
where table_name = "my_table_name";
@ioggstream
ioggstream / 99-docker.sh
Created November 19, 2015 15:05
Docker shell profile.
dip(){
# Show docker ips
local arg=${1}
if [ -z "$arg" ]; then
arg=$(docker ps -q)
fi
/bin/docker inspect --format ' {{.Name}} {{.NetworkSettings.IPAddress}}' $arg
}
from multiprocessing import Pool
import mysql.connector # works with pypy
import logging
mysql_config = {}
def initializer(mysql_config):
""" One connection per process, setup by Pool()."""
global cnx
global cur
@ioggstream
ioggstream / create-swarm-virtualbox.sh
Created August 31, 2015 15:49
Create a swarm with overlay network - virtualbox.
unset DOCKER_HOST DOCKER_MACHINE_NAME DOCKER_MACHINE_NAME DOCKER_TLS_VERIFY DOCKER_CERT_PATH
export SWARM_TOKEN=$(cat swarm.token)
echo $SWARM_TOKEN
CONSUL_IP=$(docker-machine ip consul)
_cluster="A"
_master=${_cluster}-0
_cert_home="$HOME/.docker/machine/machines/${_master}"