Skip to content

Instantly share code, notes, and snippets.


Matthew Barber honno

View GitHub Profile
rhettinger /
Created Nov 18, 2021
Type annotated pure python implementation of the builtin max() function
'Emulate max() as fully as possible in pure Python.'
from typing import TypeVar, Any, Iterator, Iterable, Optional
from typing import Union, Protocol, Callable, cast, Tuple, overload
class SupportsGT(Protocol):
tonyfast / 2021-09-20-pandas-one-liner.ipynb
Created Sep 20, 2021
pandas one liner demonstrating apply pandas Series patterns
View 2021-09-20-pandas-one-liner.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
pouyatafti / moomin.c
Last active Aug 18, 2020
Linux process Moomin ASCII art (via ps x)
View moomin.c
#include <string.h>
#include <unistd.h>
char *moomin[] = {
" . ,",
"ASCII art (c) Maija Haavisto (@DiamonDie)",
" \"._.' `' mh/VK",
" `. `, `. .'",
" . .' `. `' ;",
merlinmann /
Last active Jan 13, 2023
bios - Merlin likes to change his Twitter bio for some reason. #runx

good twitter bios runx


The bar is in the globe.

This is a factory, not a circus.

I weigh less than a slice of bread.

dannvix /
Last active Dec 20, 2022
Intuitive impementation of discrete Fourier transform (and inverse DFT) in Python (without numpy)
#!/usr/bin/env python3
import math
# >> Discrete Fourier transform for sampled signals
# x [in]: sampled signals, a list of magnitudes (real numbers)
# yr [out]: real parts of the sinusoids
# yi [out]: imaginary parts of the sinusoids
def dft(x):
N, yr, yi = len(x), [], []
StuartGordonReid /
Last active Jul 13, 2022
Python implementation of the linear complexity cryptographic test for randomness. This includes the Berklekamp Massey algorithm.
def linear_complexity(self, bin_data, block_size=500):
Note that this description is taken from the NIST documentation [1]
The focus of this test is the length of a linear feedback shift register (LFSR). The purpose of this test is to
determine whether or not the sequence is complex enough to be considered random. Random sequences are
characterized by longer LFSRs. An LFSR that is too short implies non-randomness.
:param bin_data: a binary string
ma-ric /
Created May 21, 2015
Python; recursive flatten of nested iterables, with proper handling of string elements
#!/usr/bin/env python3
def flatten(t):
Generator flattening the structure
>>> list(flatten([2, [2, "test", (4, 5, [7], [2, [6, 2, 6, [6], 4]], 6)]]))
[2, 2, "test", 4, 5, 7, 2, 6, 2, 6, 6, 4, 6]
from import Iterable
View cheatsheet.rst
myusuf3 /
Created Nov 3, 2014
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule