Skip to content

Instantly share code, notes, and snippets.

Avatar

Marius Gedminas mgedmin

View GitHub Profile
@mgedmin
mgedmin / letsencrypt.yml
Created Jun 14, 2021
Example of an Ansible playbook that uses group_by
View letsencrypt.yml
---
- hosts: all
tasks:
- 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
View test_apt_key.py
import os
from units.compat import mock
from units.compat import unittest
from ansible.modules import apt_key
class AptKeyTestCase(unittest.TestCase):
@mgedmin
mgedmin / prune_libvirt_images.py
Created Jun 9, 2021
prune unused vagrant-libvirt images
View prune_libvirt_images.py
#!/usr/bin/python3
"""
Script to remove unused libvirt images left lying around by libvirt-vagrant.
This is a workaround for
https://github.com/vagrant-libvirt/vagrant-libvirt/issues/85
"""
import argparse
import functools
@mgedmin
mgedmin / StartSSL.md
Last active Jun 2, 2021
Free StartSSL.com SSL certificate HOWTO
View StartSSL.md

How to get a free StartSSL.com SSL certificate

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

This has been updated to use SHA256 certificates.

Start

  1. Go to http://www.startssl.com/
  2. Click on 'Control Panel'
@mgedmin
mgedmin / github_mirror.py
Last active May 31, 2021
Mirror all my github repositories and gists
View github_mirror.py
#!/usr/bin/env python3
# See http://stackoverflow.com/questions/3581031/backup-mirror-github-repositories/13917251#13917251
# You can find the latest version of this script at
# https://gist.github.com/4319265
import os
import sys
import json
import urllib.request
import subprocess
@mgedmin
mgedmin / postfix.py
Last active May 23, 2021
Ansible module for postfix configuration
View postfix.py
#!/usr/bin/python
import subprocess
DOCUMENTATION = '''
---
module: postfix
short_description: changes postfix configuration parameters
description:
- The M(postfix) module changes postfix configuration by invoking 'postconf'.
@mgedmin
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
mgedmin / conf.py.rst
Created Jul 22, 2013
HOWTO add "Show on GitHub" and "Edit on GitHub" links to the Sphinx sidebar
View conf.py.rst

Edit on GitHub links for Sphinx

Create _ext/ and _templates/ subdirectories.

Move edit_on_github.py into the _ext/ subdirectory.

Move sourcelink.html into the _templates/ subdirectory.

Add the following after the import sys, os line

@mgedmin
mgedmin / show-all-256-colors.py
Last active Mar 28, 2021
Script to show all 256 colors supported by xterms
View show-all-256-colors.py
#!/usr/bin/python
"""Print a swatch using all 256 colors of 256-color-capable terminals."""
__author__ = "Marius Gedminas <marius@gedmin.as>"
__url__ = "https://gist.github.com/mgedmin/2762225"
__version__ = '2.0'
def hrun(start, width, padding=0):
@mgedmin
mgedmin / rst-vim.md
Last active Mar 19, 2021
ReStructuredText + vim = ?
View rst-vim.md

A list of interesting GH repos: