Skip to content

Instantly share code, notes, and snippets.

View amotl's full-sized avatar

Andreas Motl amotl

  • $PYTHONPATH
View GitHub Profile
@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 / 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 / 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-dm.py
Last active July 26, 2022 02:28
Example demonstrating usage of Python's "deepmerge" package. Enjoy!
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Merge dictionaries in a smart way using the "deepmerge" package.
# Works with Python2 and Python3.
# See also https://gist.github.com/amotl/cacde4c62b191a649a21dda48c4ac1fd
# https://pypi.org/project/deepmerge/
# pip install deepmerge
from deepmerge import Merger
@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 / README.rst
Last active February 17, 2024 15:27
Conjugate German verbs into past participle

Example for natural language processing with Python

About

Conjugate verbs. Here: past participle in German grammar.

The lexicon for verb conjugation provided by the fine "Pattern" package contains about 2,000 common German verbs. For unknown verbs it will fall

@amotl
amotl / httpd-reflector.py
Last active March 26, 2024 08:04 — forked from 1kastner/reflect.py
A simple HTTP server reflecting HTTP requests for inspection
#!/usr/bin/env python3
"""
httpd-reflector
A simple HTTP server reflecting HTTP requests for inspection.
It will print the contents of incoming HTTP requests to STDOUT
making it suitable for development and debugging purposes.
- Written by Nathan Hamiel (2010)
https://gist.github.com/huyng/814831