Skip to content

Instantly share code, notes, and snippets.


Marius Gedminas mgedmin

View GitHub Profile
mgedmin / letsencrypt.yml
Created Jun 14, 2021
Example of an Ansible playbook that uses group_by
View letsencrypt.yml
- hosts: all
- group_by: key="{{ 'using_letsencrypt' if letsencrypt_certs|default([]) else 'not_using_letsencrypt' }}"
changed_when: no
tags: always
- group_by: key="{{ ansible_distribution.lower() ~ '_' ~ ansible_distribution_release }}"
changed_when: no
tags: always
import os
from units.compat import mock
from units.compat import unittest
from ansible.modules import apt_key
class AptKeyTestCase(unittest.TestCase):
mgedmin /
Created Jun 9, 2021
prune unused vagrant-libvirt images
Script to remove unused libvirt images left lying around by libvirt-vagrant.
This is a workaround for
import argparse
import functools
mgedmin /
Created Sep 9, 2020
How to get a pytest progress bar in xterm title
# Put this in your top-level
class XTermProgress:
def __init__(self, stdout=sys.stdout):
self.session = None
self.reported = set()
self.args = []
mgedmin / interfaces
Created May 11, 2020
/etc/network/interfaces with static IPv6
View interfaces
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address X.X.X.X
pointopoint X.X.X.Y
gateway X.X.X.Y
dns-nameservers A.B.C.D A.B.C.E A.B.C.F
mgedmin /
Created Oct 8, 2019
How to make your desktop open different URLs in different browsers, depending on the URL

How to make your desktop open different URLs in different browsers, depending on the URL

  • vim ~/bin/open-the-right-browser

    case "$1" in
      **) browser=firefox;;
      *) browser=chromium-browser;;

exec $browser "$@"

mgedmin /
Created Sep 6, 2019
A script we use to compare a bunch of PDFs pairwise
#!/usr/bin/env python
Compare PDF reports pixel-wise.
When reportgen functional tests fail, you may want to see visually what
exactly changed. To do that:
(1) set your changes aside, e.g.
git stash
View gist:fbbe7cc70951a5ba45d9b33867b30246
mg@platonas: /tmp/experiment $ tree
├── roles
│   └── common
│   └── tasks
│   ├── generate_confi1g.yml
│   ├── main.yml
│   └── sync_rules.yml
└── test.yml
mgedmin / full-report.txt
Created Nov 19, 2018
cd ~/src/zopefoundation && check-python-versions *
View full-report.txt
AccessControl: says: 2.7, 3.5, 3.6, 3.7
tox.ini says: 2.7, 3.5, 3.6, 3.7
.travis.yml says: 2.7, 3.5, 3.6, 3.7
appveyor.yml says: 2.7, 3.5, 3.6
mgedmin / gist:78ceb2081ea2a76a40d3f8fc505a61fc
Created Sep 27, 2018
Python exception chaining dot jpg
View gist:78ceb2081ea2a76a40d3f8fc505a61fc
Traceback (most recent call last):
File "/home/mg/src/zodbbrowser/.tox/py37/lib/python3.7/site-packages/zope/configuration/", line 817, in toargs
args[str(name)] = field.fromUnicode(s)
File "/home/mg/src/zodbbrowser/.tox/py37/lib/python3.7/site-packages/zope/configuration/", line 85, in fromUnicode
File "/home/mg/src/zodbbrowser/.tox/py37/lib/python3.7/site-packages/zope/schema/", line 291, in validate
File "/home/mg/src/zodbbrowser/.tox/py37/lib/python3.7/site-packages/zope/schema/", line 670, in _validate
raise InvalidDottedName(value).with_field_and_value(self, value)
zope.schema.interfaces.InvalidDottedName: .systemerror.SystemErrorView