Skip to content

Instantly share code, notes, and snippets.

Denis Krienbühl href

Block or report user

Report or block href

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
@href
href / install-suitable-with-mitogen.sh
Created May 25, 2018
Installs Suitable with Mitogen using Python 2.7 for Testing
View install-suitable-with-mitogen.sh
#!/usr/bin/env bash
path="$1"
set -eu
if [ -z "$path" ]; then
echo "Please pass an install directory"
exit 1
fi
@href
href / migrate_puppet.py
Created May 24, 2018
Example of our internal use of Suitable
View migrate_puppet.py
import click
from suitable import Api
from textwrap import dedent
@click.command()
@click.argument('hostname')
def upgrade_puppet(hostname):
""" Upgrades a puppet client from puppet 3.8 to 4.x. """
@href
href / app.py
Last active Sep 28, 2017
Internal redirects in Morepath
View app.py
""" Simple redirects for renamed paths using a generic redirect model.
For static paths:
@App.path('/old-path')
class OldPathRedirect(Redirect):
to = '/new-path'
For wildcard paths (e.g. /old-pages/my-page to /new-pages/my-page):
@href
href / cloudbleed.py
Last active Feb 24, 2017
Checks exported 1password urls against the domains affected by Cloudbleed.
View cloudbleed.py
#!/usr/bin/python3
""" Checks exported 1password urls against the domains affected by Cloudbleed.
Usage:
1. Export the 1password urls (as csv containing *only* the url column!!).
2. Store the exported file in the current directory as 'export.csv'.
3. Run python3 ./cloudbleed.py
@href
href / integration.py
Created Dec 9, 2016
An exploration of transaction integration for PonyORM
View integration.py
import transaction
from pony.orm import Database, PrimaryKey, Required
from pony.orm.core import DBSessionContextManager
from pony.orm.core import commit, flush, rollback
class CustomDBSessionContextManager(DBSessionContextManager):
def _enter(self, *args, **kwargs):
@href
href / yubikey_otp_to_serial.py
Created Aug 30, 2016
Calculate the Yubikey serial number from the OTP
View yubikey_otp_to_serial.py
# adapted from Java:
# https://github.com/Yubico/yubikey-salesforce-client/blob/
# e38e46ee90296a852374a8b744555e99d16b6ca7/src/classes/Modhex.cls
ALPHABET = 'cbdefghijklnrtuv'
def yubikey_otp_to_serial(otp):
""" Takes a Yubikey OTP and calculates the serial number of the key.
@href
href / gist:b72b317db2d679711883
Last active Aug 29, 2015 — forked from bubenkoff/gist:5764377
pytest-xdist with Buildout on Python 3
View gist:b72b317db2d679711883
buildout.cfg:
[py]
recipe = zc.recipe.egg
...
interpreter = py
initialization =
import sys, os
try:
@href
href / test.py
Last active Aug 29, 2015
Neatly Serve Static Files with Morepath
View test.py
import inspect
import morepath
import os
from webob import static
class App(morepath.App):
@property
@href
href / gist:00cabf7fe4d35f694879
Created Dec 7, 2014
A Stab at Chameleon Integration in Morepath
View gist:00cabf7fe4d35f694879
import inspect
import morepath
import os
class ChameleonApp(morepath.App):
@morepath.reify
def chameleon_template_paths(self):
""" Returns *absolute* paths to chameleon templates.
@href
href / example.py
Created Nov 11, 2014
Virtualhost in Morepath
View example.py
import morepath
import re
from pprint import pprint
class App(morepath.App):
def request(self, environ):
request = super().request(environ)
You can’t perform that action at this time.