Skip to content

Instantly share code, notes, and snippets.

View louisswarren's full-sized avatar

Louis Warren louisswarren

View GitHub Profile
@louisswarren
louisswarren / spiral.py
Last active August 8, 2020 01:49
Spirals of numbers
class Turtle:
directions = [( 0, 1),
(-1, 0),
( 0, -1),
( 1, 0)]
def __init__(self, x=0, y=0, d=0, boundary=lambda x, y: True):
self.x = x
self.y = y
self.d = d
@louisswarren
louisswarren / Makefile
Last active December 24, 2021 03:11
Pipe pattern drawing
CFLAGS += -Ofast
.PHONY: default
default: refactor
.PHONY: refactor
refactor: out.pbm
sha256sum $< | diff -q goal.sum -
refactor-set: out.pbm
@louisswarren
louisswarren / Makefile
Last active July 27, 2020 10:11
Sudoku solver
.PHONY: test
test: seppuku
./seppuku < example.txt
seppuku: seppuku.c
gcc -std=c99 -o $@ $<
import re
from lexer import lex, LexError
def readlines_iter(f):
while (line := f.readline()):
yield line[:-1]
def main(lines):
tok_patterns = {}
@louisswarren
louisswarren / gitdemo-lstree
Last active July 9, 2020 10:01
Scripts for a git demo
#!/bin/sh
git ls-tree -r --name-only ${1:-master}
posts
threads
www
@louisswarren
louisswarren / Makefile
Last active June 15, 2020 06:09
Farbfeld test
CC = gcc
CFLAGS = -fopenmp -lm -std=c99 -pedantic -Wall
TARGETS = abstract.ff
.PHONY: default
default: $(TARGETS) $(TARGETS:.ff=.png)
%.png: %.ff
ff2png < $< > $@
@louisswarren
louisswarren / python-proposals.md
Last active July 6, 2020 03:50
Python proposals

Python Proposals

cast decorator

The common python pattern

def foo():
 tmp = []
from collections import namedtuple
from enum import Enum
import random
compose = lambda f: lambda g: lambda *a, **k: f(g(*a, **k))
class Face(Enum):
ACE = 'A'
TWO = '2'
@louisswarren
louisswarren / ffmpeg.md
Last active May 26, 2021 20:52
ffmpeg notes

ffmpeg notes

I often want to do something that I believe is non-trivial in ffmpeg, only to discover that it is actually very simple, if only I had known how to do it. I even end up writing wrappers to do simple things, because I keep forgetting what to do. However, this file is my new solution: simply write my own documentation for things I would occasionally like to do.