Skip to content

Instantly share code, notes, and snippets.

Simon Davy bloodearnest

Block or report user

Report or block bloodearnest

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
from flask import Flask
from flask_socketio import SocketIO
import talisker.flask
app = Flask(__name__)
socketio = SocketIO(app)
# This script will create xenial and trusty lxd images that will be used by the
# lxd provider in juju 2.1+ It is for use with the lxd provider for local
# development and preinstalls a common set of production packages.
# This is important, as between them, basenode and layer-basic install ~111
# packages, before we even get to any packages installed by your charm.
# It also installs some helpful development tools, and pre-downloads some
set -eu
_UID=$(id -u)
GID=$(id -g)
# give lxd permission to map your user/group id through
grep root:$_UID:1 /etc/subuid -qs || sudo usermod --add-subuids ${_UID}-${_UID} --add-subgids ${GID}-${GID} root
# set up a separate key to make sure we can log in automatically via ssh
# with $HOME mounted
def check(self, request):
"""Nagios health check"""
start = {}
def nagios_start(status, headers, exc_info=None):
# save status for inspection
start['status'] = status
start['headers'] = headers
response =, nagios_start)
# standard wsgi middleware
def some_wsgi_middleware(app):
def middleware(environ, start_response)
# here's the trick - set status/headers in the function scope
status = headers = None
def custom_start_response(status, headers, exc_info):
# they get overwritten here from func args
View Makefile
python: private SHELL=python
for i in range(10):
def f(x):
f('this is awesome')
tests_requires = [
devel_requires = test_requires + ['detox']
docs_requires = [
bloodearnest /
Last active Oct 27, 2019
Create a self-signed x509 certificate with python cryptography library
# Copyright 2018 Simon Davy
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
View gist:d5e6e00b299bfaa56db1
an_int: 3
other: "{{ an_int }}"
# this means that some_dict.other is now a string.
# using {{ an_int|int }} doesn't work, of course
# am I missing something?
import os
import hashlib
class FilterModule(object):
def filters(self):
return {
'md5_check': self.md5_check,
You can’t perform that action at this time.