Skip to content

Instantly share code, notes, and snippets.

View amotl's full-sized avatar

Andreas Motl amotl

  • $PYTHONPATH
View GitHub Profile
@amotl
amotl / xen-lvm-dump-partitions
Created August 18, 2014 21:17
Dumps proper lvcreate, mkfs and mkswap commands for cloning the filesystem layout of Xen guests
#!/usr/bin/env python
import os
import re
import sys
import shlex
import subprocess
# clone filesystem layout of Xen guests
# TODO:
@amotl
amotl / README.rst
Created February 12, 2012 23:16
memmem-fix for tor-0.2.3.12-alpha on mac os x < 10.7

Problem

./tor --version
Tor version 0.2.3.11-alpha-dev (git-5d763b3d0bf8898e).

Tor compiled on Mac OS X 10.7 (Lion), but running on 10.6.8 (Snow Leopard):

@amotl
amotl / hours.pl
Last active October 1, 2015 11:07
hours.pl - calculates hour summary from textfile with certain formatting
#!/usr/bin/env perl
# -*- coding: utf-8 -*-
# hours.pl
# calculates hour summary from textfile with certain formatting
#
# (c) 2007,2008,2010 Andreas Motl <andreas.motl@ilo.de>
=pod
@amotl
amotl / specific_daemon
Created August 19, 2012 21:22
/usr/share/uwsgi/init/specific_daemon
# This is shell script, (indirectly) sourced by uWSGI init.d script
. /usr/share/uwsgi/init/snippets
# Return:
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
do_start_specific_daemon()
{
@amotl
amotl / letsencrypt-autorenew
Last active May 28, 2016 20:17
letsencrypt-autorenew is a blueprint for convenient automatic certificate renewal and service reloading
#!/bin/bash
#
# letsencrypt-autorenew is a best practice blueprint for
# convenient automatic certificate renewal and service reloading.
#
# Copyright (C) 2016 Andreas Motl, Elmyra UG
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
@amotl
amotl / 40.influxdb
Last active December 5, 2017 20:26
InfluxDB backup handler for Backupninja
##
## Configuration file for InfluxDB backups
## For installation, copy this file to /etc/backup.d/40.influxdb
##
## The snapshots are made with InfluxDB's backup mechanisms.
## See also:
## https://docs.influxdata.com/influxdb/v0.9/administration/backup_and_restore/
##
## Please stop your influxd instance before restoring backups.
##
@amotl
amotl / dictmerge-du.py
Last active September 12, 2018 10:13
Example demonstrating usage of Python3's "dictionary unpacking" feature. Enjoy!
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Merge dictionaries using Python3's "dictionary unpacking" feature.
# However, this does not do smart things like appropriately merging lists.
# See also https://gist.github.com/amotl/88ea2073d6265e115fe4b14e818549b1
def merge_dicts(defaults, user):
"""
@amotl
amotl / one-minor-glitch.rst
Last active November 8, 2018 23:38
Issues with HTTP PUT file uploads from Shaka Packager to Nginx

One minor glitch

Problem

While everything seems to be fine with .m3u8 and .aac uploads, all .ts video files end up on the server with zero length.

Investigation

@amotl
amotl / 01-requests-only.txt
Last active January 31, 2019 02:51
Shaka Packager HTTP upload logs showing unordered output
[0130/005457:VERBOSE1:http_file.cc(170)] Sending request to URL http://media.example.org/upload/6029-video-480-0024.ts
[0130/005502:VERBOSE1:http_file.cc(170)] Sending request to URL http://media.example.org/upload/6029-video-720.m3u8
[0130/005502:VERBOSE1:http_file.cc(170)] Sending request to URL http://media.example.org/upload/6029.m3u8
[0130/005503:VERBOSE1:http_file.cc(170)] Sending request to URL http://media.example.org/upload/6029-video-720-0017.ts
[0130/005510:VERBOSE1:http_file.cc(170)] Sending request to URL http://media.example.org/upload/6029-video-480.m3u8
[0130/005510:VERBOSE1:http_file.cc(170)] Sending request to URL http://media.example.org/upload/6029.m3u8
[0130/005511:VERBOSE1:http_file.cc(170)] Sending request to URL http://media.example.org/upload/6029-video-480-0025.ts
[0130/005514:VERBOSE1:http_file.cc(170)] Sending request to URL http://media.example.org/upload/6029-video-480.m3u8
[0130/005515:VERBOSE1:http_file.cc(170)] Sending request to URL http://media.example.org/upload/6029.m3u8
[
@amotl
amotl / dynamic-callable.py
Created March 11, 2019 18:21
Dynamic method callable with Python
#!/usr/bin/env python
class Acme:
def add_foo(self):
print("Adding foo")
def add_bar(self):
print("Adding bar")