Skip to content

Instantly share code, notes, and snippets.

@matthewfl
matthewfl / simplex.py
Created December 1, 2018 17:55
Simple implementation of the Simplex Method
import numpy as np
from scipy.optimize import linprog
class simplex(object):
def __init__(self, A, b, c):
self.make_tableau(A, b, c)
self.nvars = c.shape[0]
# self.run_simplex()
@matthewfl
matthewfl / Makefile
Created January 10, 2019 07:48
Guile running a webserver from a makefile
define WEBSERVER:=
(define (handler req reqb) (values '((content-type . (text/plain) )) "Hello world from a makefile!!!") )
(use-modules (web server))
(use-modules (web http))
(run-server handler 'http '(#:port 9999))
endef
(defprotocol my-protocol-1
(my-func-1 [this value]))
(deftype my-type-1 [x]
my-protocol-1
(my-func-1 [this value]
(* value 2)))
(def z1 (my-type-1. 123))
@matthewfl
matthewfl / fix-hyperref-footnote.tex
Created December 10, 2023 20:01
Fix hyperref linking footnotes to the first page
\NewCommandCopy\originalfootnotetext\footnotetext
\NewCommandCopy\originalfootnotemark\footnotemark
\renewcommand{\footnotemark}{%
\stepcounter{footnote}%
\textsuperscript{\hyperref[footnotebody:\thefootnote]{\thefootnote}}}
\renewcommand{\footnotetext}[1]{%
\originalfootnotetext{\phantomsection\label{footnotebody:\thefootnote}#1}}
#!/bin/env python3
# run doing `./archlinux_mirror_list_updater > /etc/pacman.d/mirrorlist`
import urllib.request
import re
import time
import sys
@matthewfl
matthewfl / picklesqldict.py
Created April 20, 2025 17:24
Pickle SQL dict for python
import sqlite3
import zlib
import pickle
class PickleSQLDict:
def __init__(self, filename):
self._filename = filename
self.__db = None
@matthewfl
matthewfl / listing_config.tex
Created August 21, 2025 15:40
Matthew Francis-Landau dissertation configuration for lstlisting
\usepackage{listings}
%\usepackage{fancyvrb} % because everything sucks sometimes
\usepackage{fvextra}
\usepackage{longtable}
\usepackage{multirow}
% \usepackage{multicol}
\usepackage{framed}
\usepackage{mdframed}
@matthewfl
matthewfl / wait-for
Created March 4, 2026 17:01
Wait for a command to finish
#!/bin/bash
WAITNAME=$0
SNAME=$1
if [ -z "$SNAME" ]; then
echo "use wait-for 'proc-search-string'"
exit 1
fi