Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Will McGugan willmcgugan

🏠
Working from home
View GitHub Profile
@willmcgugan
willmcgugan / fizzbuzz.py
Created Apr 10, 2021
Fizz Buzz in Python
View fizzbuzz.py
print((0x310A320A46697A7A0A340A42757A7A0A46697A7A0A370A380A46697A7A0A42757A7A0A31310A46697A7A0A31330A31340A46697A7A42757A7A0A31360A31370A46697A7A0A31390A42757A7A0A46697A7A0A32320A32330A46697A7A0A42757A7A0A32360A46697A7A0A32380A32390A46697A7A42757A7A0A33310A33320A46697A7A0A33340A42757A7A0A46697A7A0A33370A33380A46697A7A0A42757A7A0A34310A46697A7A0A34330A34340A46697A7A42757A7A0A34360A34370A46697A7A0A34390A42757A7A0A46697A7A0A35320A35330A46697A7A0A42757A7A0A35360A46697A7A0A35380A35390A46697A7A42757A7A0A36310A36320A46697A7A0A36340A42757A7A0A46697A7A0A36370A36380A46697A7A0A42757A7A0A37310A46697A7A0A37330A37340A46697A7A42757A7A0A37360A37370A46697A7A0A37390A42757A7A0A46697A7A0A38320A38330A46697A7A0A42757A7A0A38360A46697A7A0A38380A38390A46697A7A42757A7A0A39310A39320A46697A7A0A39340A42757A7A0A46697A7A0A39370A39380A46697A7A0A42757A7A).to_bytes(412, "big").decode())
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)