Skip to content

Instantly share code, notes, and snippets.

@leo-pfeiffer
leo-pfeiffer / roc.py
Last active May 10, 2021 13:17
ROC curve calculation and plot
import argparse
from decimal import Decimal
import matplotlib.pyplot as plt
from numpy import trapz
def create_roc_values(thresholds, scores, true_values):
"""
Calculate the points on a roc curve
"""
assert len(scores) == len(true_values)
@leo-pfeiffer
leo-pfeiffer / purity.py
Last active May 12, 2021 16:24
Calculate the gini index and entropy for a list of classes
import argparse
from decimal import *
from functools import reduce, partial
import math
def _class_count(dic, x):
"""
Callback function to count elements in a list.
"""
@leo-pfeiffer
leo-pfeiffer / logging_decorator.py
Last active July 9, 2021 08:25
Logging decorator
"""
Simple logging decorator.
Usage:
@log()
def foo():
# raise an exception
return 1 / 0
By default, the exception is logged and then raised.
@leo-pfeiffer
leo-pfeiffer / Makefile
Last active August 1, 2021 10:26
Auto help command for Makefile
## https://stackoverflow.com/a/35730928/12168211
## Automatic help command
## Comment directly before target name used as help
.PHONY: help
# Show this help.
help:
@awk '/^#/{c=substr($$0,3);next}c&&/^[[:alpha:]][[:alnum:]_-]+:/{print substr($$1,1,index($$1,":")),c}1{c=0}' $(MAKEFILE_LIST) | column -s: -t
@leo-pfeiffer
leo-pfeiffer / docker-compose-workflow.yml
Created August 1, 2021 14:25 — forked from cecilemuller/example.yml
Run Docker Compose + in Github Action
name: Test
on:
push:
branches:
- main
- features/**
- dependabot/**
pull_request:
branches:
@leo-pfeiffer
leo-pfeiffer / background_processes.sh
Last active August 14, 2021 20:04
Shell script for starting multiple processes
#!/bin/bash
# first process
cd ~/Desktop/folder1
# start your first process with nohup
# (the `&` is important)
nohup python proc1.py > proc1.out 2>&1 &
echo "proc2.py PID:" $!
@leo-pfeiffer
leo-pfeiffer / install_spin.sh
Last active October 16, 2024 10:32
Install Spin and iSpin on Mac
#!/bin/bash
# Install Spin and iSpin on MacOS
# adapted from https://philenius.github.io/software%20quality/2020/04/09/installing-spin-on-ubuntu-19.html
# (requires developer tools to be installed; to install them, run `xcode-select --install`)
# Install in a new directory
INSTALL_DIR=Spin
mkdir $INSTALL_DIR
cd $INSTALL_DIR
@leo-pfeiffer
leo-pfeiffer / adskip.js
Created February 14, 2022 14:39
YouTube Ad Skipper Script for Tampermonkey
// ==UserScript==
// @name YouTube Ad Skipper
// @namespace https://github.com/leo-pfeiffer
// @version 0.1
// @description Skip ads on youtube
// @match *://www.youtube.com/*
// ==/UserScript==
(function() {

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@leo-pfeiffer
leo-pfeiffer / TryDoobie.scala
Last active March 11, 2022 09:15 — forked from isyufu/TryDoobie.scala
Doobie with SQLite
/**
lazy val doobieVersion = "1.0.0-RC1"
libraryDependencies ++= Seq(
"org.xerial" % "sqlite-jdbc" % "3.36.0.2",
"org.tpolecat" %% "doobie-core" % doobieVersion,
"org.tpolecat" %% "doobie-hikari" % doobieVersion,
"org.tpolecat" %% "doobie-scalatest" % doobieVersion % Test,
)
*/