Skip to content

Instantly share code, notes, and snippets.

Louis Warren louisswarren

View GitHub Profile
@louisswarren
louisswarren / gitdemo-lstree
Last active Jul 9, 2020
Scripts for a git demo
View gitdemo-lstree
#!/bin/sh
git ls-tree -r --name-only ${1:-master}
@louisswarren
louisswarren / Makefile
Last active Jun 15, 2020
Farbfeld test
View Makefile
CC = gcc
CFLAGS = -fopenmp -lm -std=c99 -pedantic -Wall
TARGETS = abstract.ff
.PHONY: default
default: $(TARGETS) $(TARGETS:.ff=.png)
%.png: %.ff
ff2png < $< > $@
View python-proposals.md

Python Proposals

cast decorator

The common python pattern

def foo():
    tmp = []
View blackjack.py
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'
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.

View task.py
import heapq
class Task:
def __init__(self, time):
self.time = time
def __lt__(self, other):
return self.time < other.time
def __repr__(self):
@louisswarren
louisswarren / spite.py
Last active Mar 13, 2020
Spite in python
View spite.py
import curses
SPADE, HEART, DIAMOND, CLUB = '♠♥♦♣'
BOX = {
'light': ('┌───┐',
'│ │',
'│ │',
'└───┘'),
'heavy': ('┏━━━┓',
@louisswarren
louisswarren / cursesexample.py
Last active Mar 7, 2020
Menus with curses in python
View cursesexample.py
import curses
class Menu:
def __init__(self, y, x, options):
self.y = y
self.x = x
self.options = options
self.height = len(options)
self.width = max(len(opt) for opt in options)
self.win = curses.newwin(self.height + 2, self.width + 8, y, x)
@louisswarren
louisswarren / bug-2-6-1.agda
Last active Feb 24, 2020
Bug in Agda version 2.6.0.1.20191219
View bug-2-6-1.agda
-- Agda version 2.6.0.1.20191219
open import Agda.Builtin.Equality
open import Agda.Builtin.Nat renaming (Nat to ℕ)
open import Agda.Builtin.Sigma
ℕ×ℕ : Set
ℕ×ℕ = Σ ℕ λ _
record Cont : Set where
You can’t perform that action at this time.