Skip to content

Instantly share code, notes, and snippets.

View Stefan-Code's full-sized avatar

Stefan Kuntz Stefan-Code

View GitHub Profile
#!/usr/bin/env python2
import argparse
from ws4py.client.threadedclient import WebSocketClient
import time
import threading
import sys
import urllib
import Queue
import json
@Stefan-Code
Stefan-Code / bacula-backup.sh
Created February 14, 2017 12:14
Backup bacula database and encrypt it with openssl
#Encrypt
pg_dump -d bacula -Z 5 | openssl smime -encrypt -binary -aes-256-cbc -out /var/db/bacula/bacula.sql.gzip.enc -outform DER /usr/local/etc/bacula/fd.pem /usr/local/etc/bacula/master.cert
#Decrypt
openssl smime -decrypt -in bacula.sql.gzip.enc -inform DER -binary -inkey master.key | gunzip > bacula.sql
@Stefan-Code
Stefan-Code / chio-bacula
Created November 22, 2016 20:51
Script for Bacula autochanger barcode handling on FreeBSD
#!/bin/sh
#
# Bacula interface to FreeBSD chio autoloader command with
# multiple drive support
# (By Lars K�ller, lars+bacula@koellers.net, 2004)
#
# If you set in your Device resource
#
# Changer Command = "path-to-this-script/chio-bacula" %c %o %S %a
# you will have the following input to this script:
@Stefan-Code
Stefan-Code / 41-usbtiny.rules
Created June 1, 2016 08:34
udev rule for usbtiny AVR programmer (on linux)
SUBSYSTEM=="usb", ATTR{idVendor}=="1781", ATTR{idProduct}=="0c9f", GROUP="plugdev", MODE="0666"
alert('XSS')
@Stefan-Code
Stefan-Code / disk-snapshot.md
Last active September 21, 2016 16:28
Hard Drive snapshot command

The following command creates a complete compressed disk snapshot of /dev/sda. Replace 500107862016 with the size of the media to be backed up so pv shows progress information. Runs at a speed of about 30MB/s for me. When using pigz instead of gzip for compression I can achieve speeds of around ~150MB/s (using SSDs).

dd if=/dev/sda conv=sync,noerror bs=64M | pv -s 500107862016 -pera | pigz -c > /media/user/backup.gz

@Stefan-Code
Stefan-Code / 50-synaptics.conf
Created April 25, 2016 18:59
xorg config for lenovo x240
Section "InputClass"
Identifier "Clickpad"
MatchIsTouchpad "on"
MatchDevicePath "/dev/input/event*"
Driver "evdev"
# Synaptics options come here.
Option "Clickpad" "true"
option "EmulatedMidButtonTime" "0"
Option "SoftButtonAreas" "65% 0 0 40% 42% 65% 0 40%"
Option "AreaBottomEdge" "0%"
@Stefan-Code
Stefan-Code / 10-quirks.conf
Created April 25, 2016 18:59
xorg config for lenovo x240
# Collection of quirks and blacklist/whitelists for specific devices.
# Accelerometer device, posts data through ABS_X/ABS_Y, making X unusable
# http://bugs.freedesktop.org/show_bug.cgi?id=22442
Section "InputClass"
Identifier "ThinkPad HDAPS accelerometer blacklist"
MatchProduct "ThinkPad HDAPS accelerometer data"
Option "Ignore" "on"
EndSection
@Stefan-Code
Stefan-Code / bash.bashrc
Created January 7, 2016 14:25
/etc/bash.bashrc including colored git branch highlighting in command prompt
# System-wide .bashrc file for interactive bash(1) shells.
# To enable the settings / commands in this file for login shells as well,
# this file has to be sourced in /etc/profile.
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
@Stefan-Code
Stefan-Code / SympySymbolicMath.py
Last active January 5, 2016 17:39
Sympy symbolic math boilerplate for iPython notebook
from sympy import *
from sympy.matrices import *
import seaborn as sns # seaborn for pretty graphs
import numpy as np # numpy for numerical stuff
init_session()
init_printing(use_latex='mathjax')
# now you're good to go.
#Example:
diff(2**x)