Skip to content

Instantly share code, notes, and snippets.

@nilstoedtmann
nilstoedtmann / .Xmodmap-AddUmlauts
Last active January 25, 2017 16:25
Add German umlauts and currency signs to current key map
!
! Add German diaereses (Umlauts) and some currency signs to current keymap
! as <AltGr> alternatives to related English letter keys, e.g.
!
! <AltGr>-<A> = ä
! <AltGr>-<Shift>-<A> = Ä
!
! Load with "xmodmap .Xmodmap-AddUmlauts"
!
! ----------------------------------------------------------------
@nilstoedtmann
nilstoedtmann / deng
Last active August 3, 2021 22:31
Add German letters (diaereses/umlaut) and currency signs to English X11 keyboard layouts
// Nils Toedtmann https://github.com/nilstoedtmann 2017-01-25
//
// Add German letters (diaereses/umlauts and Eszett) and currency
// signs to selected English keyboard layouts on level3 (<AltGr>)
//
// Save as /usr/share/X11/xkb/symbols/deng. To load:
//
// setxkbmap deng # US-based
// setxkbmap 'deng(gb)' # UK-based
//
@nilstoedtmann
nilstoedtmann / test-stdout-buffering.py
Last active April 13, 2020 15:09
Test buffering behaviour of print(), sys.stdout.write() and logging without TTY (PIPE mode)
'''Test behaviour various printing methonds without TTY.
If you run it with a TTY, all is as expected: print() and sys.stdout flush
thir buffers after each NewLine '\n':
python test-stdout-buffering.py
However, if you take the TTY away and run it in PIPE mode, then Python's
buffers much more agressively across '\n'!
@nilstoedtmann
nilstoedtmann / mailgun_bounces.py
Created April 21, 2020 19:46
Retrieve and parse MailGun bounces & suppressions via MailGun API
#!/usr/bin/env python
'''Retrieve and parse MailGun bounces & suppressions via MailGun API.
Set MAILGUN_API_KEY and MAILGUN_DOMAIN as env vars.
See https://documentation.mailgun.com/en/latest/api-suppressions.html#view-all-bounces
'''
import os, sys, json, logging, requests, datetime
@nilstoedtmann
nilstoedtmann / logtest.py
Last active May 2, 2020 22:57
Test multiple Python processes logging to same file
'''Write 1000 log messages; wait 1-10ms inbetween.'''
# See also:
# - https://stackoverflow.com/q/15096090
# - https://stackoverflow.com/q/38219512
# To test, fork 1000 concurrent processes:
# for i in {1..1000} ; do ( python logtest.py & ) ; done
import logging, random, time, os