Skip to content

Instantly share code, notes, and snippets.


Stefan Midjich stemid

View GitHub Profile
stemid /
Created Jun 25, 2018
Backup script for my personal laptop
#!/usr/bin/env bash
# Simple backup script for borg.
# Install on Fedora: sudo dnf install borgbackup
# Configure BORG_REPO below to match some path on your own system. In my case
# it points to an autofs mount on my network backup device.
# Configure your own borg_excludes.
# by Stefan Midjich <swehack at gmail dot com>
export BORG_REPO="/media/nas/backups/$(hostname -s)-borgbackup"
stemid / defaults.cfg
Last active Jun 7, 2018
Boilerplate logging class I use in most my applications
View defaults.cfg
# AppLogger specific config.
log_format = %(asctime)s %(name)s[%(process)s] %(levelname)s: %(message)s
log_debug = True
log_level = INFO
# Handler can be one of file, stdout or syslog
log_handler = stdout
# Can use this to log directly to another server if need be
stemid /
Last active Jul 11, 2019
Ansible inventory script for Siptrack (
#!/usr/bin/env python
# Siptrack dynamic inventory script for Ansible.
# Depends on siptracklib
# *
# by Stefan Midjich <swehack at gmail dot com>

Keybase proof

I hereby claim:

  • I am stemid on github.
  • I am stemid ( on keybase.
  • I have a public key ASD1nmKQzW0A_OGRdxfATEZL8ZAy55k5LulsWPfC2Iz2cAo

To claim this, I am signing this object:

#!/usr/bin/env bash
# {{ ansible_managed }}
# vim: set filetype=bash
# WARNING: Have you run first?
# WARNING: You must know what you're doing or the backup will be ruined!
shopt -s nullglob
stemid /
Last active Dec 22, 2016
Recursively compress files with xz using multiple threads
# With Bash 4.3 I'd rather use wait -n to keep N
# processes running at all times. As it is now you
# unfortunately have to wait for the last process
# to finish.
# Recursively compress all files in $dir
compress () {
#!/usr/bin/env python
from __future__ import print_function
from configparser import RawConfigParser
except ImportError:
from ConfigParser import RawConfigParser
from json import dumps
from argparse import ArgumentParser, FileType
#!/usr/bin/env python3
# This was a failed PoC to try and use socket files as ssh_config file. :)
# by Stefan Midjich
import os
import functools
import asyncio
def set_socket_permission(socket_file):
View bootstrap_sftp.bash
#!/usr/bin/env bash
test $(id -u $PAM_USER) -gt 500 || exit 1
grep ^{{chroot_openssh_group}} /etc/group | grep -q $PAM_USER || exit 1
_HOME=$(getent passwd $PAM_USER 2>/dev/null | cut -d: -f6 2>/dev/null)
if [ -z "$_HOME" ]; then
View VMDK-orphaned.ps1
add-pssnapin VMware.VimAutomation.Core
Set-PowerCLIConfiguration -invalidCertificateAction 'ignore' -confirm:$false -Scope Session
Connect-VIServer -Server -Protocol https
$report = @()
$daysAgo = (Get-Date).AddDays(-14)
$arrUsedDisks = Get-View -ViewType VirtualMachine | % {$_.Layout} | % {$_.Disk} | % {$_.DiskFile}
$arrDS = Get-Datastore | Sort-Object -property Name
foreach ($strDatastore in $arrDS) {
$ds = Get-Datastore -Name $strDatastore.Name | % {Get-View $_.Id}