Skip to content

Instantly share code, notes, and snippets.

#!/bin/env python3
# run doing `./archlinux_mirror_list_updater > /etc/pacman.d/mirrorlist`
import urllib.request
import re
import time
import sys
@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}}
(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 / 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
@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 / README.md
Last active February 22, 2018 03:30
Midi to g-code

Convert Midi files to g-code and build customized plates

My idea is to convert a midi file, which can be written in any time and even contain a mix of times or use notes at the half way points (1/8th time), and convert it into g-code that can be run the router (CNC) and build custom plates.

Advantages

  1. Music can be in any time that it wants as long as it divides the wheel and avoids the breaks between plates
  2. Easily convert songs written on the computer into the marble machine (just fill in all the wholes that were drilled on the programming wheel)

Disadvantages

  1. Each song will require its own custom plate
@matthewfl
matthewfl / pytorch hogwild.py
Last active December 9, 2020 16:18
pytorch hogwild
import torch
import torch.multiprocessing as mp
import queue
import resource
import os
class SimpleSGD(torch.optim.Optimizer):
def __init__(self, params, lr=.01):
@matthewfl
matthewfl / latexc.py
Last active May 25, 2021 21:17
Get a notification when latexmk fails
#!/usr/bin/env python3
import subprocess
import sys
def main():
proc = subprocess.Popen(['latexmk', '-pvc'] + sys.argv[1:],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
import random
import sys
def run(n=100):
a = 0
c = 0
while a < n:
c += 1
if a % 2 == 0:
d = 1
@matthewfl
matthewfl / order-align.patch
Created January 8, 2015 07:23
patch for the linux kernel to change the way alignments for large memory request from pci devices are handled
diff -Naur linux-3.10.0-123.13.2.el7.mfl.x86_64/drivers/pci/setup-bus.c linux-3.10.0-123.13.2.el7.mfl.x86_64-patched/drivers/pci/setup-bus.c
--- linux-3.10.0-123.13.2.el7.mfl.x86_64/drivers/pci/setup-bus.c 2014-12-12 16:14:08.000000000 -0800
+++ linux-3.10.0-123.13.2.el7.mfl.x86_64-patched/drivers/pci/setup-bus.c 2015-01-05 01:05:16.111882902 -0800
@@ -962,8 +962,7 @@
dev_warn(&dev->dev, "disabling BAR %d: %pR "
"(bad alignment %#llx)\n", i, r,
(unsigned long long) align);
- r->flags = 0;
- continue;
+ order = 11;