Skip to content

Instantly share code, notes, and snippets.

Chris McGraw mitgr81

  • SONIFI Solutions
  • Sioux Falls, SD
Block or report user

Report or block mitgr81

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
View gist:5554ca310bf8e9015726
percentify = lambda number, percentage: float(number) * (percentage / 100)
restaraunt_tax_percentage = 6.75
tip_percentage = 15
meal = float(input("How much was the meal? $") or 44.50)
restaraunt_tax = percentify(meal, restaraunt_tax_percentage)
tip = percentify(meal + restaraunt_tax, tip_percentage)
print("Your tip should be ${:.2f}".format(tip))
View pytz==2014.1.stderr
Downloading/unpacking pytz==2014.1 (from mymodule==0.0.2-dev->-r requirements-ci.txt (line 6))
Running (path:/Users/buildbot/.virtualenvs/wonderboom_acceptance_happenings/build/pytz/ egg_info for package pytz
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/Users/buildbot/.virtualenvs/wonderboom_acceptance_happenings/build/pytz/", line 30, in <module>
File "/Users/buildbot/.virtualenvs/wonderboom_acceptance_happenings/bin/../lib/python3.3/encodings/", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 14839: ordinal not in range(128)
Complete output from command python egg_info:
View Output
in upload handler
in file close
Ran 2 tests in 0.021s
class Parent(object):
def __new__(cls, to, *args, **kwargs):
if hasattr(to, 'something'):
return object.__new__(Child)
return object.__new__(Parent)
def send(self):
raise RuntimeError('You must override the send method for this Parent subclass')
mitgr81 /
Created Oct 3, 2013
Simple flask app that kills itself after storing and returning a value.
from multiprocessing import Process
import flask
app = flask.Flask(__name__)
autokill_time = 0
thing_i_was_sent = ''
from flask import make_response
def protect_http_call(func):
Decorator that handles all standard and fall-through exceptions for a REST view. Protect will swallow all exceptions.
func: Function to be wrapped and protected from raising
mitgr81 /
Last active Dec 21, 2015
Unit testing sqlalchemy filters
#...somewhere above self.model = some SQLAlchemy model
def shoes(self):
filter1 = self.model.shoe == 'donkey'
def shoes2(self):
filters = []
# filters.append(self.model.shoe <= 'donkey')
filters.append(getattr(operator, 'le')(self.model.shoe, 'donkey'))
filters.append(getattr(operator, 'eq')(self.model.donkey, 'shoe'))
View sublime_settings.json
"color_scheme": "Packages/Color Scheme - Default/Twilight.tmTheme",
"font_size": 17,
"highlight_line": true,
"scroll_past_end": true,
#!/usr/bin/env python
class BaseClass(object):
bar = 'baz'
class PantsMixin(object):
class Singleton(type):
_instances = {}
def __call__(cls, *args, **kwargs):
if cls not in cls._instances:
cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
return cls._instances[cls]
You can’t perform that action at this time.