Skip to content

Instantly share code, notes, and snippets.

Avatar

Louis Warren louisswarren

View GitHub Profile
View gistclone.py
#!/usr/bin/env python3
import itertools
import json
import subprocess
import sys
import urllib.request
user = 'louisswarren'
@louisswarren
louisswarren / encrypt.patch
Last active Mar 25, 2021
Patch for the encrypt hook for supporting disabling of workqueue
View encrypt.patch
--- encrypt 2021-03-26 11:18:21.981072579 +1300
+++ encrypt.no-workqueue 2021-03-26 11:18:21.981072579 +1300
@@ -62,6 +62,12 @@
allow-discards)
cryptargs="${cryptargs} --allow-discards"
;;
+ no-read-workqueue)
+ cryptargs="${cryptargs} --perf-no_read_workqueue"
+ ;;
+ no-write-workqueue)
View powermethod.py
class LinearMap:
def __init__(self, matrix):
self.domain_dimension = len(matrix[0])
self.range_dimension = len(matrix)
self.matrix = matrix
# def shifted(self, c):
# return LinearMap(tuple(tuple(r - c if i == j else r
# for j, r in enumerate(row))
# for i, row in enumerate(self.matrix)))
@louisswarren
louisswarren / word.c
Last active Mar 17, 2021
That's 65% more word per word
View word.c
#include <stdint.h>
#include <stdio.h>
uint64_t
strtoword(char *s)
{
uint64_t word = 0;
word |= ((uint64_t) *(s++) & 0x1f) << 55;
word |= ((uint64_t) *(s++) & 0x1f) << 50;
word |= ((uint64_t) *(s++) & 0x1f) << 45;
@louisswarren
louisswarren / natded.tex
Last active Mar 11, 2021
Natural deduction with handy latex commands
View natded.tex
\documentclass[a4paper]{article}
\usepackage{bussproofs}
\usepackage{savetrees}
\usepackage{amsmath}
\newcommand{\using}[2]{\AxiomC{}\RightLabel{#1}\UnaryInfC{#2}}
\newcommand{\assume}[1]{\AxiomC{#1}}
\newcommand{\closed}[2]{\AxiomC{$\left[\text{#2}\right]^\text{#1}$}}
@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