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
View flask_socketio.py
from flask import Flask
from flask_socketio import SocketIO
import talisker.flask
app = Flask(__name__)
talisker.flask.register(app)
socketio = SocketIO(app)
View update-juju-lxd-images.sh
#!/bin/bash
#
# 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
View setup-lxd-profile.sh
#!/bin/bash
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
View check.py
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 = self.app(request.environ, nagios_start)
View wsgi_extract.py
# 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
pass
View Makefile
.ONESHELL:
python: private SHELL=python
python:
for i in range(10):
print('OMG!')
def f(x):
print(x)
f('this is awesome')
View extras.py
...
tests_requires = [
'flake8>=2.4.1',
'pytest>=2.9.1',
'freezegun>=0.3.6',
'coverage>=4.0',
]
devel_requires = test_requires + ['detox']
docs_requires = [
'Sphinx==1.4',
@bloodearnest
bloodearnest / selfsigned.py
Last active Oct 27, 2019
Create a self-signed x509 certificate with python cryptography library
View selfsigned.py
# 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
vars:
an_int: 3
some_dict:
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?
View md5_check.py
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.