Skip to content

Instantly share code, notes, and snippets.

@tierpod
tierpod / systemd-nspawn-add-machine.sh
Created Jun 6, 2019
Example: add systemd-nspawn machine, install packages, add user
View systemd-nspawn-add-machine.sh
#!/bin/bash
# Add systemd-nspawn machine, install base packages, create builder user
set -eu
if [ $# -ne 1 ]; then
echo "usage: $0 MACHINE"
exit 1
fi
@tierpod
tierpod / setupLog.go
Created Nov 28, 2018
Configure logger in go with logutils
View setupLog.go
func setupLog(debug, datetime bool) {
filter := &logutils.LevelFilter{
Levels: []logutils.LogLevel{"DEBUG", "INFO", "WARN", "ERROR"},
MinLevel: logutils.LogLevel("INFO"),
Writer: os.Stdout,
}
if debug {
filter.MinLevel = logutils.LogLevel("DEBUG")
}
@tierpod
tierpod / json-to-class.py
Created Feb 7, 2018
json to python class example
View json-to-class.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
import os.path
def md5sum():
return "test"
class File(object):
View example-buf.go
logger.Print("fetch metatile data to buffer")
var buf bytes.Buffer
err = mt.FetchEncodeTo(url, &buf)
if err != nil {
logger.Fatal(err)
}
logger.Print("write buffer to cache")
err = c.Write(t, &buf)
if err != nil {
@tierpod
tierpod / systemd-notify-wrapper.py
Last active Dec 8, 2017
Example for wrapper around ExecStart= for success/failed service notifications
View systemd-notify-wrapper.py
#!/usr/bin/python3
# try this for long-running processes:
#
# $ cat example.service
# ...
# Type=simple
# ExecStart=systemd-notify-wrapper.py "/opt/scripts/long-running.sh -a -b FLAG" "%n"
# ...
#
# send "successful complete" notification if exit code valid
@tierpod
tierpod / transfer-files.md
Last active Jan 19, 2016
Transfer a huge number of files over ssh
View transfer-files.md

rsync

#!/bin/sh

RSYNC='ionice -c 3 nice -n 17 rsync'

$RSYNC --inplace --bwlimit=2000 -Wvr [-pgo] [--progress] --log-file=/tmp/rsync.log \
    --rsync-path="$RSYNC" src dest
@tierpod
tierpod / docopt-normalize.py
Last active Aug 29, 2015
python docopt arguments normalize: lowercase, remove '-'
View docopt-normalize.py
'''
args: {'--append': True, 'FILE1': 'test', 'normal': 'normal'}
cfg: {'append': True, 'file1': 'test', 'normal': 'normal'}
'''
# simple way
cfg = {}
for arg in args:
cfg[arg.lower().replace('-','')] = args[arg]
@tierpod
tierpod / markdown.coder
Created Aug 19, 2014
AkelPad markdown syntax highlight (coder plugin)
View markdown.coder
;----------------------------------------------;
; Coder plugin syntax file ;
;----------------------------------------------;
;Author: wisgest
;===============
;Colors
; Color need to be in #RRGGBB format.
; If color equal to zero, then color ignored.
@tierpod
tierpod / lightdm-custom-settings.conf
Last active Aug 29, 2015
Lightdm custom settings
View lightdm-custom-settings.conf
[SeatDefaults]
allow-guest=false
# user=root, run on greeter start
greeter-setup-script=/usr/bin/numlockx on
# user=user, run on session start
# session-setup-script=/usr/local/bin/resolution.sh
#greeter-hide-users=true
#greeter-show-manual-login=true
You can’t perform that action at this time.