Skip to content

Instantly share code, notes, and snippets.

Will McGugan willmcgugan

Block or report user

Report or block willmcgugan

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
@willmcgugan
willmcgugan / template example
Created Feb 15, 2015
A demonstration of how to render a parsed template
View template example
#!/usr/bin/env python
class Node(object):
def __init__(self, params, children):
self.params = params
self.children = children
class IfNode(Node):
View Moya logging FileHandler
class MoyaFileHandler(logging.Handler):
def __init__(self, filename):
self._filename = filename
super(MoyaFileHandler, self).__init__()
def emit(self, record):
text = self.format(record)
with io.open(self._filename, 'at', encoding="utf-8") as f:
f.write(text + '\n')
View gist:2948552
from contextlib import contextmanager
from time import time, mktime
from datetime import datetime
@contextmanager
def timer(msg="elapsed", ms=False, write_file=None):
now = datetime.now()
start = time()
yield
taken = (time() - start)
You can’t perform that action at this time.