Skip to content

Instantly share code, notes, and snippets.


Marius Gedminas mgedmin

View GitHub Profile
mgedmin / .pythonrc
Created Dec 30, 2010
snippets for export PYTHONSTARTUP=~/.pythonrc
View .pythonrc
# This is the actual file that combines all of the other snippets
# I've been using it for a while, so it's officially Bug Free (TM)
# Python startup script. vim: set ft=python :
# from
# also see Tarek Ziade's _Expert_Pythom_Programming_ page 19
import os, sys
# Coloured prompt
if os.getenv('TERM') in ('xterm', 'vt100', 'rxvt', 'Eterm', 'putty'):
mgedmin /
Last active Mar 25, 2022
Script to show all 256 colors supported by xterms
"""Print a swatch using all 256 colors of 256-color-capable terminals."""
__author__ = "Marius Gedminas <>"
__url__ = ""
__version__ = '2.0'
def hrun(start, width, padding=0):
Produce a disk inventory for fridge:
- how many hard disks and how large
- how are they partitioned
- how are the RAID devices defined
- where are they mounted
- how much space is used and how much is free
mgedmin /
Last active Jan 13, 2022
Mirror all my github repositories and gists
#!/usr/bin/env python3
# See
# You can find the latest version of this script at
import os
import sys
import json
import urllib.request
import subprocess
mgedmin / gist:9547214
Created Mar 14, 2014
Setting up a Jenkins slave on Linux
View gist:9547214
# This is how you add a Jenkins slave
# On master:
sudo -u jenkins -H ssh-keygen
# On slave
adduser --system --group --home=/var/lib/jenkins-slave --no-create-home --disabled-password --quiet --shell /bin/bash jenkins-slave
install -d -o jenkins-slave -g jenkins-slave /var/lib/jenkins-slave
mgedmin /
Last active Nov 3, 2021
Free SSL certificate HOWTO

How to get a free SSL certificate

I'm writing this up from memory, so errors may appear.

This has been updated to use SHA256 certificates.


  1. Go to
  2. Click on 'Control Panel'
mgedmin /
Created Jan 14, 2012
Script to convert netstat -tln output into pretty HTML
Update TCP port assignments page in /var/www/HOSTNAME/ports/index.html.
import datetime
import optparse
import os
import pwd
import socket
mgedmin /
Created Jul 22, 2013
HOWTO add "Show on GitHub" and "Edit on GitHub" links to the Sphinx sidebar

Edit on GitHub links for Sphinx

Create _ext/ and _templates/ subdirectories.

Move into the _ext/ subdirectory.

Move sourcelink.html into the _templates/ subdirectory.

Add the following after the import sys, os line

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):