Skip to content

Instantly share code, notes, and snippets.

View Stefan-Code's full-sized avatar

Stefan Kuntz Stefan-Code

View GitHub Profile
@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"
@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, [email protected], 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 / 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
#!/usr/bin/env python2
import argparse
from ws4py.client.threadedclient import WebSocketClient
import time
import threading
import sys
import urllib
import Queue
import json
#removes first audio stream without transcoding
ffmpeg -i file.mp4 -map 0:0 -map 0:2 -acodec copy -vcodec copy new_file.mp4
#!/bin/bash
for name in *.mkv; do
ffmpeg -i "$name" -map 0:0 -map 0:2 -acodec copy -vcodec copy "converted/$name"
done
@Stefan-Code
Stefan-Code / ubuntu-provisioning.py
Last active December 10, 2017 20:17
Provisioning script to setup a Ubuntu VM from a template. Most importantly, this will ensure SSH keys are unique.
#! /usr/bin/env python3
import os
import locale
import subprocess
import sys
import shutil
from dialog import Dialog
# systemctl edit getty@tty1
[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin user --noclear %I $TERM
# creates a LaTeX representation of the math for a scipy linregress straight line fit object
def fit_latex(fit, precision=2, xname='x', yname='y', xunit='', yunit='', stats_precision=4, show_R2=True, show_standard_error=True):
return '${y}={slope}{x}{unit_conversion} {sign} {intercept}{yunit}${stats}'.format(slope=round(fit.slope, precision),
intercept=round(abs(fit.intercept), precision),
x=xname,
y=yname,
sign='+' if fit.intercept >= 0 else '-',
yunit=r'\,\mathrm{{{}}}'.format(yunit) if yunit else '',
unit_conversion=r'\,\frac{{\mathrm{{{yunit}}}}}{{\mathrm{{{xunit}}}}}'.format(yunit=yunit, xunit=xunit) if xunit or yuni
# choco list --local-only --id-only
# Chocolatey v0.10.11
7zip
7zip.install
adb
adobereader
android-sdk
astrogrep
audacity
autohotkey.portable
#!/bin/bash
exitcode=1
mountpoints="/run/user/1000/gvfs"
#do check if the correct usb mtp device is mounted
for mountpoint in $mountpoints/mtp*/;
do
echo "Testing $mountpoint"
sync_folder="$mountpoint/Internal shared storage"
#if the device contains a .sync_boox file in internal storage, proceed
if test -e "$sync_folder/.sync_boox";then