Skip to content

Instantly share code, notes, and snippets.

View stlehmann's full-sized avatar
:bowtie:

Stefan Lehmann stlehmann

:bowtie:
View GitHub Profile
@stlehmann
stlehmann / netset.py
Created March 8, 2017 16:07
fast switching between network configurations
#! c:\miniconda\python
from collections import namedtuple
import time
import sys
import click
import wmi
TIMEOUT_SECONDS = 20
# static configuration
@stlehmann
stlehmann / .pdbrc.py
Created November 29, 2016 07:46 — forked from justinabrahms/.pdbrc.py
default pdbpp to start with sticky enabled
import pdb
class Config(pdb.DefaultConfig):
sticky_by_default = True
@stlehmann
stlehmann / mysyslog-ng.conf
Created November 7, 2016 10:45
additional config file for syslog-ng. Put into /etc/syslog/conf.d/ folder.
# log alls ssh events in ssh.log
destination sshd { file("/var/log/ssh.log"); };
filter sshd { program("ssh"); };
log { source(s_src); filter(sshd); destination(sshd); flags(final); };
@stlehmann
stlehmann / .mybashrc
Last active November 5, 2016 16:14
my personal .bashrc file
# ----------------------------------------------
# command prefix
# ----------------------------------------------
export PS1="\[\033[0;32m\]\h:\w$\[\033[0m\] "
# ----------------------------------------------
# aliases
# ----------------------------------------------
alias venv='source venv/bin/activate'
@stlehmann
stlehmann / foo.log
Created October 20, 2016 13:14 — forked from ibeex/foo.log
Flask logging example
A warning occurred (42 apples)
An error occurred
@stlehmann
stlehmann / create_venv_pyqt5.bat
Created August 19, 2016 06:35
Batch script for creating a virtual environment with Anaconda containing PyQt5 and dependencies. Note: PyQt5 must be installed in the root environment.
@echo off
echo Creating new conda environment with PyQt5 installed...
conda create -n %1 python pyqt5 -y
echo Copying Qt binaries in virtual environment...
cp -R c:\miniconda3\Lib\site-packages\pyqt5\Qt c:\miniconda3\envs\%1\Lib\site-packages\PyQt5\
echo Activating new virtual environment...
activate %1
@stlehmann
stlehmann / hook-numpy.py
Created July 20, 2016 12:19
PyInstaller hook for numpy (Windows)
import os
from PyInstaller import log as logging
from PyInstaller import compat
from os import listdir
libdir = compat.base_prefix + "/Lib/site-packages/numpy/core"
mkllib = filter(lambda x: x.startswith('mkl_'), listdir(libdir))
other_libs = ['libiomp5md.dll']
if mkllib != []:
#!/bin/bash
# Ports: Hier eintragen welche Ports geöffnet werden sollen
SERVICES_UDP="1194" #freigegebene UDP-Ports
SERVICES_TCP="22 25 1883 8080 8883 22044 80 5000 443 943" #freigegebene TCP-Ports (Hier sshd und http)
# Delete all chains
iptables -F # flush all chains (delete rules one by one) on default table
iptables -t nat -F # flush all chains on nat table
iptables -t mangle -F # flush all chains on mangle table
@stlehmann
stlehmann / supervisor
Last active June 25, 2016 15:25
Supervisor init script
#! /bin/sh
### BEGIN INIT INFO
# Provides: supervisord
# Required-Start: $local_fs $remote_fs $networking
# Required-Stop: $local_fs $remote_fs $networking
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts supervisord - see http://supervisord.org
# Description: Starts and stops supervisord as needed - see http://supervisord.org
### END INIT INFO
@stlehmann
stlehmann / provision.sh
Last active June 28, 2016 16:20
Webserver Provisioning script
#! /usr/bin/sh
apt-get -y update
apt-get -y upgrade
echo -e "\n--- Install dev tools ---\n"
apt-get -y install mc htop vim git nginx
echo -e "\n--- Clone vim settings ---\n"
git clone --recursive https://github.com/MrLeeh/.vim.git
ln -s .vim/.vimrc .vimrc