Skip to content

Instantly share code, notes, and snippets.

Avatar

Louis Warren louisswarren

View GitHub Profile
@louisswarren
louisswarren / Makefile
Last active Mar 4, 2021
Svg files from python
View Makefile
n = 24
$(n).mp4: stringart.py
$(MAKE) -j 4 $$(for i in $$(seq -w 1 $n); do echo -n "$n-$$i.png "; done)
ffmpeg -r 2 -f image2 -s 800x800 -i $(n)-%02d.png -vcodec libx264 -crf 25 -pix_fmt yuv420p $@
%.png: %.svg
convert $^ $@
$(n)-%.svg: stringart.py
@louisswarren
louisswarren / Makefile
Last active Mar 4, 2021
Cellular automata
View Makefile
.PHONY: test
test: 027.png
.PHONY: all
all:
$(MAKE) -j 4 $$(for i in $$(seq -w 0 255); do echo -n "$$i.png "; done)
%.png: %.svg
convert $^ $@
@louisswarren
louisswarren / Makefile
Last active Mar 4, 2021
Generate svg grids
View Makefile
.PHONY: test
test: grid6.svg grid7.svg grid8.svg grid9.svg grid6.png grid7.png grid8.png grid9.png
grid%.svg: grid.py
python3 $^ $* > $@
%.png: %.svg
convert $^ $@
.PHONY: clean
@louisswarren
louisswarren / Makefile
Last active Feb 23, 2021
Register machine
View Makefile
.PHONY: test test2
test: aprog.rma assembler
./assembler < $<
test2: register prog.rm
echo 'Hello, world!' | ./register
aprog.rm: aprog.rma assembler
./assembler < $< > $@
@louisswarren
louisswarren / Makefile
Created Feb 3, 2021
Generate two versions of the same latex document
View Makefile
.PHONY: all
all: tutorial.pdf tutorial-solns.pdf
%.pdf: %.tex
pdflatex $^
%-solns.pdf: %.tex
pdflatex -jobname $(basename $@) '\def\SOLUTIONS{} \input{$^}'
.PHONY: clean
View inventory.tex
\documentclass[a5paper]{article}
\usepackage[a5paper,margin=1cm]{geometry}
\usepackage{array}
\usepackage{multirow}
\usepackage{graphicx}
\pagenumbering{gobble}
\begin{document}
\begin{center}
\section*{Freezer inventory}
@louisswarren
louisswarren / mfwpp
Last active Nov 25, 2020
Mutex files with preprocessing
View mfwpp
#!/bin/sh
# Generate all .m4 file outputs - being lazy and just re-running the script
# with an argument. To be safe AND lazy, add a useless argument just to make
# sure this doesn't fork bomb me some day if I change how this is done.
if [ -z "$1" ]; then
exec find $(dirname -- "$0") -name '*.m4' -exec "./$0" '{}' 'safety' \;
fi
# Generate $1 from its .m4 file.
@louisswarren
louisswarren / Makefile
Last active Oct 23, 2020
Tiny library for PPM output
View Makefile
.PHONY: test test-video
test: nz.png
sxiv $^
test-video: fire
./fire | mpv --no-correct-pts --fps=30 --scale=oversample -
%.png: %.ppm
convert $< $@
@louisswarren
louisswarren / bench.py
Created Oct 14, 2020
Python benchmarker
View bench.py
from time import time, sleep
def runtime(f, retcont):
t = time()
r = f()
tt = time()
if retcont == []:
retcont.append(r)
elif retcont is not None:
assert(r == retcont[0])