Skip to content

Instantly share code, notes, and snippets.

View cwillmor's full-sized avatar

Chris Willmore cwillmor

View GitHub Profile
@cwillmor
cwillmor / unfold.pde
Created January 30, 2021 22:31
unfold animation
// unfold animation https://twitter.com/cwillmore/status/1355644262835122176
// developed in processing 3.5.4
static final int FRAME_RATE = 30;
static final float ITER_DURATION = 2.0; // seconds
static final int TOTAL_FRAMES = (int)(FRAME_RATE * ITER_DURATION);
static final int WIDTH = 500;
static final int HEIGHT = 500;
static final boolean SAVE_FRAMES = false;
@cwillmor
cwillmor / ells.pde
Created January 25, 2021 02:50
ells.pde (L-tiling clock in processing)
// ell clock https://twitter.com/cwillmore/status/1353435612636803073
// developed with processing 3.5.4 (processing.org)
// TODO:
// - motion blur
// - ripple update of ells - one only starts rotating when it has room to (<< ... <> ... >>)
static final int DEPTH = 3;
static final int N = 1 << (DEPTH + 1);
static final int FRAME_RATE = 30;
static final float DT = 1 / (float)FRAME_RATE;
@cwillmor
cwillmor / gist:495551359a2fae83110084712feff1e8
Created July 1, 2020 07:52
regex that matches multiples of 7
^([70]*|([18]|[70]*[18])(5?|4[70]*[18])*(4|4[70]*)|([92]|[70]*[92]|([18]|[70]*[1
8])(5?|4[70]*[18])*(6|4[70]*[92]))(3?|[18][70]*[92]|([92]|[18][70]*[18])(5?|4[70
]*[18])*(6|4[70]*[92]))*([18]|[18][70]*|([92]|[18][70]*[18])(5?|4[70]*[18])*(4|4
[70]*))|(3|[70]*3|([18]|[70]*[18])(5?|4[70]*[18])*([70]|4[70]*3)|([92]|[70]*[92]
|([18]|[70]*[18])(5?|4[70]*[18])*(6|4[70]*[92]))(3?|[18][70]*[92]|([92]|[18][70]
*[18])(5?|4[70]*[18])*(6|4[70]*[92]))*(4|[18][70]*3|([92]|[18][70]*[18])(5?|4[70
]*[18])*([70]|4[70]*3)))([18]?|5[70]*3|(6|5[70]*[18])(5?|4[70]*[18])*([70]|4[70]
*3)|([70]|5[70]*[92]|(6|5[70]*[18])(5?|4[70]*[18])*(6|4[70]*[92]))(3?|[18][70]*[
92]|([92]|[18][70]*[18])(5?|4[70]*[18])*(6|4[70]*[92]))*(4|[18][70]*3|([92]|[18]
[70]*[18])(5?|4[70]*[18])*([70]|4[70]*3)))*(5|5[70]*|(6|5[70]*[18])(5?|4[70]*[18
@cwillmor
cwillmor / keypad.py
Created November 8, 2019 22:38
keypad path enumeration
#!/usr/bin/env python3
# https://twitter.com/cwillmore/status/1192927454429511680
neighbors1 = [[0, 1], [0, 1, 2], [1, 2]]
def neighbors(i, j):
"""Enumerate all the buttons that are adjacent to button (i, j)."""
for ii in neighbors1[i]:
for jj in neighbors1[j]:
if i != ii or j != jj:
yield (ii, jj)
@cwillmor
cwillmor / draw.py
Created June 13, 2018 05:24
program for drawing @Cwillmore banner
# 05/02/18 04:46 PM
# program to draw twitter background
# might be a good foundation for beesandbombs-style animation?
from PIL import Image, ImageDraw
import os
import aggdraw
import random
import math
@cwillmor
cwillmor / rand_unit.py
Created December 10, 2011 01:34
Random unit vector generation
import random
import math
def random_unit_vector(n):
"""Return the components of a random unit vector in 'n' dimensions."""
result = [random.gauss(0, 1) for i in xrange(n)]
norm = math.sqrt(sum(x**2 for x in result))
result = [x / norm for x in result]
return result
@cwillmor
cwillmor / parse_numbers.py
Created June 9, 2011 06:36
Python function for parsing English numbers
"""
parse_number.py
Utilities for parsing English numbers into integers.
Author: pmdboi @ reddit (see
<http://www.reddit.com/r/Python/comments/hv8rp/can_anyone_suggest_a_library_for_converting/>)
"""
import re