Skip to content

Instantly share code, notes, and snippets.

@alistair-broomhead
alistair-broomhead / common.py
Last active February 23, 2018 15:48
Minimal async testcase runner
import asyncio
import functools
import unittest
class AsyncTest(unittest.TestCase):
def __getattribute__(self, name):
""" Hack to run async tests in the AsyncIO event loop """
original = super().__getattribute__(name)
@alistair-broomhead
alistair-broomhead / byte_utils.py
Last active August 14, 2017 14:53
Python3 Byte Utils
def until_bytes(input_bytes, ending):
"""
Yields bytes from input up to and including a given ending.
This can be used to seek to the end of a pattern if your
input_bytes object is an iterator.
"""
position = 0
length = len(ending)
[user]
email = alistair.broomhead@gmail.com
name = Alistair Broomhead
[push]
default = current
[core]
autocrlf = input
excludesfile = /home/al/.gitignore_global
[alias]
pushf = push --force-with-lease
@alistair-broomhead
alistair-broomhead / example.py
Created December 3, 2015 23:32
An example of using a generator expression
import csv
def email_next(seq):
for address in seq:
try:
email(address)
except Exception as ex:
print('Could not email {}, moving onto the next: {}'
.format(address, ex))
else:
@alistair-broomhead
alistair-broomhead / pip_async.py
Created February 11, 2015 12:46
Written by fgh@4gh.tv
import asyncio
import aiohttp
import json
from pip.utils import get_installed_distributions
#from pip.commands.search import compare_versions
from distutils.version import StrictVersion, LooseVersion
def package_url(name):
return "http://pypi.python.org/pypi/%s/json/" % name
@alistair-broomhead
alistair-broomhead / tp_mashup_column_headings
Created October 3, 2014 15:51
Remove To Do Planned and Done from column headings
// name: Remove To Do Planned and Done from column headings
// placeholder: restui_board
tau.mashups
.addDependency('tau/core/bus.reg')
.addModule('BusListeners', function(reg){
function Listener(bus, event, func){
this.bus = bus
this.event = event