Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Will McGugan willmcgugan

🏠
Working from home
View GitHub Profile
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')
@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 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.