Skip to content

Instantly share code, notes, and snippets.

Avatar

Louis Warren louisswarren

View GitHub Profile
View ffmpeg.md

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.

@louisswarren
louisswarren / pool.c
Created May 11, 2021
Linked list pool
View pool.c
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#define POOL_NODE_HEADERS struct pool_node *prev, *next
struct pool_node {
POOL_NODE_HEADERS;
};
@louisswarren
louisswarren / findunicode.c
Last active May 5, 2021
Strip unicode (why was this tricky in php?)
View findunicode.c
#include <stdio.h>
#define BUF_SZ (1 << 16)
size_t
find_unicode(char *p, size_t n)
{
size_t i;
for (i = 0; i < n; ++i) {
if (p[i] & 128)
@louisswarren
louisswarren / Makefile
Last active May 4, 2021
Pipe pattern drawing
View Makefile
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 May 3, 2021
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 / Makefile
Last active Apr 30, 2021
Key expansion
View Makefile
.PHONY: default
default: keys
./keys
keys: CFLAGS += -lcrypto
@louisswarren
louisswarren / wtype.agda
Last active Apr 26, 2021
W-types in agda
View wtype.agda
-- Based on https://mazzo.li/epilogue/index.html%3Fp=324.html
data W (S : Set) (P : S Set) : Set where
_◁_ : (s : S) (P s W S P) W S P
data 𝟘 : Set where
data 𝟙 : Set where
: 𝟙
@louisswarren
louisswarren / Makefile
Last active Apr 26, 2021
Menger sponge sides
View Makefile
.PHONY: default
default: menger8.png
%.png: %.pbm
convert $^ $@
menger%.pbm: menger
./$^ $* > $@
menger%.svg: menger.py
@louisswarren
louisswarren / list.c
Last active Apr 7, 2021
Ordered lists in C
View list.c
#include <stdio.h>
#include <stdlib.h>
struct list_entry {
struct list_entry *next;
int value;
};
struct list {
struct list_entry *head;
View gistclone.py
#!/usr/bin/env python3
import itertools
import json
import subprocess
import sys
import urllib.request
user = 'louisswarren'