Skip to content

Instantly share code, notes, and snippets.

@mvliet
mvliet / daemon.py
Created November 25, 2013 22:08
Python Daemon Example
#!/usr/bin/env python
# Based off of code written by Sander Marechal, which was released into public
# domiain.
# http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/
#
import sys, os, time, atexit
import logging
from signal import SIGTERM
@mvliet
mvliet / flock_decorator.py
Created June 5, 2013 17:34
A python decorator that blocks execution by getting an exclusive lock on the specified file.
import sys
import os
from fcntl import LOCK_EX
from fcntl import LOCK_NB
from fcntl import flock
from time import sleep
NO_BLOCK = 'nb'
BLOCK = 'block'
@mvliet
mvliet / lti_signer.py
Last active December 14, 2015 13:18
Simple command line script that creates an LTI signed url based on input params. Useful for generating utls to test an LTI provider.
#!/usr/bin/env python
import sys
import argparse
import requests
from oauth2 import Consumer
from oauth2 import Request
from oauth2 import SignatureMethod_HMAC_SHA1
from oauth2 import generate_nonce