Skip to content

Instantly share code, notes, and snippets.

View frenchtoast747's full-sized avatar

Aaron Boman frenchtoast747

View GitHub Profile
@frenchtoast747
frenchtoast747 / decorator.py
Last active July 4, 2019 17:13
A Python decorator that preserves everything about the original function being decorated.
import types
class decorator(object):
"""
When using a decorator, the function that is being decorated
loses its __name__, docstring, and signature.
For example, consider the generic decorator ``my_decorator``:
def my_decorator(fn):
@frenchtoast747
frenchtoast747 / keybase.md
Created June 20, 2014 02:48
My Keybase MD Thingy

Keybase proof

I hereby claim:

  • I am frenchtoast747 on github.
  • I am aaronboman (https://keybase.io/aaronboman) on keybase.
  • I have a public key whose fingerprint is 76FE 51F0 06E2 D3B8 E44A 4FD9 9DA7 6491 A438 940D

To claim this, I am signing this object:

app.directive('backButton', ['$window', function($window) {
return {
restrict: 'A',
link: function (scope, elem, attrs) {
elem.bind('click', function () {
$window.history.back();
});
}
};
}]);
@frenchtoast747
frenchtoast747 / importing.py
Created October 4, 2015 00:22
Lazy Importing
class lazy_import(object):
"""
The main purpose for this is to make module level coverage work :(
If/When nose2 figures out how to fix the coverage problem, or if
a new test discovery method or loader is used, this should be removed
in favor of real imports.
"""
def __init__(self, python_path):
self.python_path = python_path
self._obj = None
@frenchtoast747
frenchtoast747 / flag_per_function.py
Created September 11, 2017 18:51
Flag per function - Argparse
import argparse
class c1(object):
def cleanup(self):
print 'c1'
class c2(object):
def cleanup(self):