Skip to content

Instantly share code, notes, and snippets.


Marius Gedminas mgedmin

View GitHub Profile
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
Python 2.7.14 (default, Sep 23 2017, 22:06:14)
[GCC 7.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> class Wat(object):
... __slots__ = ('a', 'b')
... a = 42
>>> x = Wat()
mgedmin / roles-letsencrypt-tasks-main.yml
Created Apr 16, 2018
Upgrading all certbot dependencies given pip >= 10
View roles-letsencrypt-tasks-main.yml
- name: install letsencrypt
name: "{{ item }}"
virtualenv: /opt/letsencrypt
state: "{{ 'present' if ansible_check_mode else 'latest' }}"
extra_args: >-
{% if 'pip' not in item and not ansible_check_mode -%}
{%- endif %}
View gist:0d5f8cadac30270a997c3a7b3bd69bf6
mg@platonas: ~ $ docker run --rm -it ubuntu:xenial
root@c197c14c8a8d:/# apt update -qq && apt install -qqy virtualenv git python
30 packages can be upgraded. Run 'apt list --upgradable' to see them.
The following additional packages will be installed:
ca-certificates dh-python file git-man ifupdown iproute2 isc-dhcp-client isc-dhcp-common krb5-locales less libasn1-8-heimdal libatm1
libbsd0 libcurl3-gnutls libdns-export162 libedit2 liberror-perl libexpat1 libffi6 libgdbm3 libgmp10 libgnutls30 libgssapi-krb5-2
libgssapi3-heimdal libhcrypto4-heimdal libheimbase1-heimdal libheimntlm0-heimdal libhogweed4 libhx509-5-heimdal libidn11
libisc-export160 libk5crypto3 libkeyutils1 libkrb5-26-heimdal libkrb5-3 libkrb5support0 libldap-2.4-2 libmagic1 libmnl0 libmpdec2
libnettle6 libp11-kit0 libperl5.22 libpopt0 libpython-stdlib libpython2.7-minimal libpython2.7-stdlib libpython3-stdlib
libpython3.5-minimal libpython3.5-stdlib libroken18-heimdal librtmp1 libsasl2-2 libsasl2-modules libsasl2-modules-db libsqlite3