Skip to content

Instantly share code, notes, and snippets.

View honno's full-sized avatar
🛰️

Matthew Barber honno

🛰️
  • Hexegic
  • Southend-on-Sea
  • 05:03 (UTC)
View GitHub Profile
@honno
honno / org_minted_export.elisp
Created July 12, 2020 11:37
Quick fix for org not exporting minted latex correctly
(setq org-latex-listings 'minted
org-latex-packages-alist '(("" "minted"))
org-latex-pdf-process
'("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
"pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"))
@honno
honno / time-sheet.svg
Created July 12, 2020 12:17
Sheet I use for time management
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@honno
honno / scotland_ yard.tex
Last active July 12, 2020 14:29
Old coursework submission
\title{Representing Scotland Yard with data structures, and using Computational Thinking to determine Mr X's location}
\author{Matthew Barber\\
160056525}
\date{\today}
\documentclass{article}
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{calc}
@honno
honno / data.txt
Last active July 13, 2020 09:06
Example random data
1
0
1
0
1
0
1
1
1
0
@honno
honno / berlekamp_massey.py
Last active September 30, 2020 17:25
GF(2) variant of the Berlekamp-Massey algorithm, i.e. for binary sequences (a list of zero and one integers)
from copy import copy
def berlekamp_massey(sequence: List[int]) -> int:
n = len(sequence)
error_locator = [0 for _ in range(n)]
error_locator[0] = 1
error_locator_prev = copy(error_locator)
@honno
honno / store.py
Created October 22, 2020 07:31
coinflip's old store module
"""Store functionality for the CLI
Notes
-----
A store is an abstraction for a folder in the user's local data directory
which pertains to a specific dataset that comprises of RNG output. The store can
subsequently store test results and report markup for said results.
"""
import pickle
import shelve
@honno
honno / randtests_refimpl.py
Created November 14, 2020 14:25
Reference implementation of the SP800-22 randomness tests
from collections import Counter
from collections import defaultdict
from itertools import accumulate
from itertools import product
from math import erfc
from math import floor
from math import log
from math import log2
from math import sqrt
from typing import Iterator
@honno
honno / bins.py
Last active November 22, 2020 13:38
Reference implementation of the data binning container "Bins"
from collections.abc import MutableMapping
from bisect import bisect_left
class Bins(MutableMapping):
def __init__(self, intervals):
empty_bins = {interval: 0 for interval in intervals}
self._dict = empty_bins
def __getitem__(self, key):
interval = self._roundkey(key)
@honno
honno / defaultlist.py
Last active December 8, 2020 10:04
Reference implementation of the list with defaults, defaultlist
from collections import defaultdict
from collections.abc import Sequence, MutableSequence
class defaultlist(MutableSequence):
def __init__(self, default_factory=None):
self._ddict = defaultdict(default_factory or defaultlist._none_factory)
@staticmethod
def _none_factory():
return None
@honno
honno / mersenne_twister.py
Last active February 8, 2021 16:56
Stupid simple Mersenne Twister.
class Mersenne:
def __init__(self, seed=1234):
self.seed = seed
self.j = 2 ** 31 - 1
self.k = 16807
self.period = 2 ** 30
def __iter__(self):
return self