Skip to content

Instantly share code, notes, and snippets.

@mbrengel
mbrengel / logging_example.py
Last active January 17, 2024 11:30
Python Logging Setup
#!/usr/bin/env python3
import logging
from logging.handlers import RotatingFileHandler
import sys
import colorama
def configure_logging():
# enable cross-platform colored output
colorama.init()
@mbrengel
mbrengel / mnist_nn.py
Last active March 5, 2020 11:41
Bare-bones hard-coded vanilla shallow feedforward neural network (sigmoid activation, cross entropy cost function, stochastic gradient descent, backpropagation, regularization) for the MNIST dataset yielding ~98% accuracy.
#!/usr/bin/env python3
import gzip
import io
import numpy as np
import random
import requests
# reproducibility
np.random.seed(1337)
@mbrengel
mbrengel / archvbox.bat
Last active September 20, 2022 12:21
Unattended Arch Linux VM installation script for VirtualBox on Windows hosts + a toolchain for building and modifying the script.
@echo off
if NOT EXIST %HOMEDRIVE%%HOMEPATH%\vmshare (
echo shared vm folder %HOMEDRIVE%%HOMEPATH%\vmshare does not exist
exit /B
)
if NOT EXIST %HOMEDRIVE%%HOMEPATH%\arch.iso (
echo arch linux iso %HOMEDRIVE%%HOMEPATH%\arch.iso does not exist
exit /B
)
where vboxmanage > nul 2>&1
@mbrengel
mbrengel / clustering.py
Last active September 27, 2019 12:14
Hierarchical Agglomerative Clustering
#!/usr/bin/env python3.7
from scipy.cluster import hierarchy
from matplotlib import pyplot as plt
import numpy as np
class ClusteringItem:
def __init__(self, label, features):
self.label = label
self.features = features