View generate-form.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# This script generates an example HTML form that can directly upload files to | |
# an S3 bucket at cloudscale.ch. | |
# | |
# Based on the following work: | |
# | |
# - http://archive.is/fZdSu | |
# - http://archive.is/NXQno | |
# | |
# Requires Python 3 and boto3 to work: |
View install-suitable-with-mitogen.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
path="$1" | |
set -eu | |
if [ -z "$path" ]; then | |
echo "Please pass an install directory" | |
exit 1 | |
fi |
View migrate_puppet.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. """ |
View app.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" 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): |
View cloudbleed.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
View integration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
View yubikey_otp_to_serial.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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. |
View gist:b72b317db2d679711883
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildout.cfg: | |
[py] | |
recipe = zc.recipe.egg | |
... | |
interpreter = py | |
initialization = | |
import sys, os | |
try: |
View test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import inspect | |
import morepath | |
import os | |
from webob import static | |
class App(morepath.App): | |
@property |
View gist:00cabf7fe4d35f694879
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import inspect | |
import morepath | |
import os | |
class ChameleonApp(morepath.App): | |
@morepath.reify | |
def chameleon_template_paths(self): | |
""" Returns *absolute* paths to chameleon templates. |
NewerOlder