Skip to content

Instantly share code, notes, and snippets.

View redspider's full-sized avatar

Richard Clark redspider

  • Red Spider Limited
  • Wellington, New Zealand
View GitHub Profile
import wave
from itertools import zip_longest
START = 1500
END = 1500 + 86 * 11
def grouper(n, iterable, fillvalue=None):
args = [iter(iterable)] * n
return zip_longest(fillvalue=fillvalue, *args)
def generator(start, factor, multiple = 1):
previous = start
while True:
n = previous * factor % 2147483647
previous = n
if n % multiple == 0:
yield n
A = generator(116, 16807, 4)
B = generator(299, 48271, 8)
function phnInjectMultiStyleHeader() {
if (document.getElementById('phn-multi-style-header')) {
return;
}
const HEAD = document.getElementsByTagName('head')[0];
const STYLE = HEAD.appendChild(document.createElement('style'));
STYLE.setAttribute('id', 'phn-multi-stye-header');
@redspider
redspider / figure2png.py
Last active December 14, 2016 21:43
Pull and resize a Figure.NZ chart
import re
import math
import requests
from lxml import etree
import os
import sys
import cairosvg
url = sys.argv[1]
url = url.replace('png','svg')

Keybase proof

I hereby claim:

  • I am redspider on github.
  • I am phirate (https://keybase.io/phirate) on keybase.
  • I have a public key whose fingerprint is 5786 1353 E629 C8DF 69E7 A591 F406 DFEC 48E9 ACFD

To claim this, I am signing this object:

"""
If you choose an answer to this question at random,
what is the chance you will be correct?
A) 25%
B) 50%
C) 60%
D) 25%
"""
class Email(Document):
created = QuantumField(required=True, default=quantum.now)
status = StringField(required=True, choices=['pending', 'sending', 'paused', 'sent'], default='pending')
progress = IntField(default=0)
processed = QuantumField()
template = StringField()
tplvars = DictField()
dispensation = ReferenceField('Dispensation')
comment = StringField()
subject = StringField(required=True)
d = threadframe.dict()
for tid in d.keys():
st_list = traceback.format_stack(d[tid])
st = ''.join(st_list)
if not "waiter.acquire()" in st_list[-1]:
stack += "\nThread %d\n" % tid
stack += st
def create():
class Form(IForm):
name = wtf.TextField(_('Library Name'), [wtf.Required(), wtf.Length(max=80)])
form = Form()
if form.validate_on_submit():
library = m.Library(
name = form.name.data,
)
@blueprint.route('/<library_id>/upload', methods=['GET', 'POST'], auth=auth.admin)
@render_html()
def upload(library_id):
try:
library = m.Library.objects.get(id=library_id)
except m.DoesNotExist:
abort(404)
class Form(IForm):
name = wtf.TextField(_('Item name'), [wtf.Required(), wtf.Length(max=80)])