Skip to content

Instantly share code, notes, and snippets.

View rec's full-sized avatar
🥝
coding

Tom Ritchford rec

🥝
coding
View GitHub Profile
f(factorial)(10)
def synonym_queries(synonym_words, queries):
'''
synonym_words: iterable of pairs of strings representing synonymous words
queries: iterable of pairs of strings representing queries to be tested for
synonymous-ness
'''
synonyms = defaultdict(set)
for w1, w2 in synonym_words:
synonyms[w1].add(w2)
shape: 50
animation:
typename: mixer
levels: [1, 0, 0]
animations: [$bpa.strip.Wave, $bpa.strip.HalvesRainbow, $bpa.strip.PartyMode]
controls:
typename: midi
extractor:
@rec
rec / scroll.py
Last active August 28, 2017 10:14
scroll an animation
from bibliopixel.animation import BaseAnimation
from bibliopixel import colors
# This is using the default 32x32 simpixel display -
# so this is a list of 16 * 64 = 1024 colors.
BASE = [
colors.Black, colors.Black, colors.Black, colors.Black,
colors.Green, colors.Green, colors.Green, colors.Green,
colors.Blue, colors.Blue, colors.Blue, colors.Blue,
colors.White, colors.White, colors.White, colors.White,
{
"layout": "matrix",
"animation": "matrix_test",
"run": {
"threaded": true
}
}
{
"driver": "simpixel",
"layout": "strip",
"animation": {
"typename": "BiblioPixelAnimations.strip.LarsonScanners.LarsonScanner",
"color": [255,0,0],
"tail": 1,
"start": 0,
"end": -1
@rec
rec / future-of-bibliopixel.md
Last active June 22, 2017 11:27
The Future of BiblioPixel

After 3.0! A long-term roadmamp for BiblioPixel

Now that 3.0 is ready, it's time to look forward to the long-term - because without a long-term plan with something really exciting at the end, this is just a maintenance exercise.

BiblioPixel has three types of components: animations, layouts and drivers.

And our long-term goals are solving six problems:

  1. sharing: to reuse components and share them with others.
@rec
rec / which_is_prime.py
Last active April 26, 2017 09:25
Which is prime?
from math import sqrt
from itertools import count, islice
CANDIDATES = (15485867, 15485917, 15485927, 15485933, 15485941,
15485957, 15485989, 15485993, 15486013, 15486041)
def is_prime(n):
# from http://stackoverflow.com/a/27946768/43839
return n > 1 and all(n % i for i in islice(count(2), int(sqrt(n) - 1)))
@rec
rec / lambda.py
Last active February 15, 2017 19:16
def identity(x):
return x
identity2 = lambda x: x
def add(x, y):
return x + y
adds = lambda x, y: x + y
def do_it(dog='Oliver', cat='X10'):
return 1, 'a', True, dog, cat
x, y, z, *animals = do_it()
print(x)
print(y)
print(z)
print(animals)