Skip to content

Instantly share code, notes, and snippets.

View bloodearnest's full-sized avatar

Simon Davy bloodearnest

View GitHub Profile
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)
# 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
.ONESHELL:
python: private SHELL=python
python:
for i in range(10):
print('OMG!')
def f(x):
print(x)
f('this is awesome')
...
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 October 30, 2025 13:42
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
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?
@bloodearnest
bloodearnest / md5_check.py
Created August 4, 2014 16:32
md5_check.py
import os
import hashlib
class FilterModule(object):
def filters(self):
return {
'md5_check': self.md5_check,
}
wavy@shredder:~/canonical/dev/sso$ cat ~/bin/juju-sync-charm
#!/bin/bash
if [ -z "$1" ]
then
echo "You must provide a unit name" >&2
exit 1
fi
UNIT=$1
DIR=${2:-.}
@bloodearnest
bloodearnest / gist:554fa5552a0dea8b5605
Created June 24, 2014 13:17
Building off a base image for dev/prod images
GOAL: Use docker to build some images:
- a base image
- a dev image, from base, with extra dev deps, and the source code mounted as a host volume
- a prod image, from base, with src explicitly ADDed into the image as a stand alone executable
SUBGOALS:
- make use of docker's cache for faster building
A base image:
$ cat base.docker
@bloodearnest
bloodearnest / keybase.md
Created March 7, 2014 10:26
keybase.md

Keybase proof

I hereby claim:

  • I am bloodearnest on github.
  • I am bloodearnest (https://keybase.io/bloodearnest) on keybase.
  • I have a public key whose fingerprint is 8B91 F3C0 BE8F 7977 F9DF 6EC2 44A2 9F57 B63A 5F44

To claim this, I am signing this object: