Skip to content

Instantly share code, notes, and snippets.

View felixhummel's full-sized avatar

Felix Hummel felixhummel

View GitHub Profile
@felixhummel
felixhummel / useless.py
Last active October 27, 2018 22:18
You go figure it out. :P
import string
import sys
print (lambda c: (string.letters + string.digits) * (c/len((string.letters + string.digits))) + (string.letters + string.digits)[:c-len((string.letters + string.digits) * (c/len((string.letters + string.digits))))])(int(sys.argv[1]))
@felixhummel
felixhummel / disk-inspect.sh
Created March 22, 2018 22:21
list physical disks and their partitions
#!/bin/bash
set -euo pipefail
# major device number 7 is loop
# grep loop /proc/devices
#disks=$(lsblk --raw --noheadings -o type,name | grep ^disk | awk '{ print "/dev/"$2 }')
# weird though: "--exclude 252" (device-mapper) does not work...
lsblk -o MAJ:MIN,UUID,SIZE,LABEL,NAME,MOUNTPOINT,FSTYPE --exclude 7 | grep -v ^252
@felixhummel
felixhummel / README.md
Created February 18, 2018 03:53
opendkim salt

Generate the key-pair:

salt-call state.apply postfix.opendkim_genkey

Get the public key and set it on your DNS server:

salt-call file.read /etc/opendkim/keys/felixhummel.de/mail.txt
@felixhummel
felixhummel / srv__pillar__mine.sls
Created February 18, 2018 03:42
mine function to expose opendkim public keys
mine_functions:
dkim_pubkey:
- mine_function: file.read
- /etc/opendkim/foo/keys/bar.pub
@felixhummel
felixhummel / ssh_config
Last active November 2, 2017 11:37
Useful defaults and example for ~/.ssh/config
# keep connections alive
ServerAliveInterval 60
# re-use connections to the same host
ControlMaster auto
# leave connection open in background
ControlPersist 4h
ControlPath /tmp/%r@%h:%p
# use `ssh -o ControlPath=none` to disable this temporarily
# and to close this: `ssh -O exit`
#!/usr/bin/env python
# vim: set fileencoding=utf-8 filetype=python :
"""
Prints the expiration time of a domain as seen from the host this is run on.
Example Output:
felixhummel.de (37.200.98.98): 3055 sec (about 50 min)
"""
from __future__ import print_function
@felixhummel
felixhummel / log_example.py
Created December 7, 2016 16:55
simple configurable logging for one-off scripts
#!/usr/bin/env python
# encoding: utf-8
"""
Call me like this::
python log_example.py
To set the log level::
LOGLEVEL=INFO log_example.py
@felixhummel
felixhummel / info.php
Created September 7, 2012 18:26
fastcgi nginx php test
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index info.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDjah5JBLHIUshsVHW6qx/dift2JrRC84a1yXav7ksOQ0joAIgJnCCni84HN6FPzcXVox/f4TG7KIgqqM/46bmixGmCl2qeq4oBCGize8OVfhMRVnWiYBSmYOkGAZKk9iji7Z4E6l6qiXjNM7mu4Gxl+CN3kCHvgiyukcIFoiPLepA86Kj9CPPJclhSPlef0Apvil+dJ9R0LYMRKVeKHvuauqy2JoMreZIw3tM7/+JhxzYKVRJCfZ2GNHazX4xYjNDWDytwHtyjZ6kUD9cJCwk2nRwJ+PrR3bIG0UGlF1gcUBcQTCsjoG9sFfxZ3GCRzMTqFo3hh54XRq1h0QZnQFX30gs/ApLyimF6PDzQex7cH2Sj21OVsdBOmQT1hj8620c41zn85Mmk5r6lWwNRcQBNTXDCsU7sEK6YlgQGS9H1umQFFuAhAm2teNExOtcy8VryWnX97IkXuC64jb8KCLMF3Tkj87rBPsdz1zOH8OBYLavwV5Mbg1XZdwJe8pRKJ84lF7wXXu1UBlmk/OKFmFDe0CdmygFbrJE7nz/21OtjQKzi0SOgMrxAt0dGg1Yp1I0pka7N9cqc57BhShWy3LXMDoFEZjUcYvHZP24KsAaX0erkIsyOX+4x6WZLamoIfvYnYGVQMgw1zTxiccxtNNNG3GnibX5t7OtaYXVDtdylqQ== felix@port
#!/bin/bash
[[ $1 == 'skip' ]] || wget -c http://dir.xiph.org/yp.xml
python<<'EOF'
from lxml import etree
t = etree.parse(open('yp.xml'))
def urls_by_genre(genre):