Skip to content

Instantly share code, notes, and snippets.

View maxiimilian's full-sized avatar

Maximilian maxiimilian

  • TU Delft
View GitHub Profile
"""
Download data from KNMI API.
Copyright (C) 2024 Maximilian Pierzyna, except when indicated otherwise
in the docstring of the functions.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
@maxiimilian
maxiimilian / pasta.sh
Created June 30, 2022 15:53
Companion script for microbin server. Pipe everything to `pasta.sh` to quickly create pastas. The link will be returned to stdout.
#!/bin/bash
# Set microbin server URL here
BASE_URL=xxxxxxxx
# Take expiration time as input and default to 10 minutes.
if [[ "$1" == "" ]]; then
expiration=10min
else
expiration=$1
fi
@maxiimilian
maxiimilian / Makefile
Created March 8, 2022 20:10
Latex Makefile
.PHONY: pdf clean todo preflight figures nomenclature snapshot
TEX_FILES := $(wildcard *.tex)
TEX_FILES_EXCEPT_MAIN := $(filter-out main.tex, $(TEX_FILES))
PYTHON := ~/.virtualenvs/MA/bin/python
SNAPSHOT_DIR := ../latex_snapshots
pdf: literature.bib
latexmk -pdf main.tex
@maxiimilian
maxiimilian / multi_root.py
Last active January 4, 2024 01:20
Function to look for all roots within given interval/bracket based on scipy's `root_scalar`. Resolution `n` of this function only needs to be high enough so that all sign changes of roots are covered.
import warnings
from typing import Callable, Iterable
import numpy as np
from scipy.optimize import root_scalar
def multi_root(f: Callable, bracket: Iterable[float], args: Iterable = (), n: int = 30) -> np.ndarray:
""" Find all roots of f in `bracket`, given that resolution `n` covers the sign change.
Fine-grained root finding is performed with `scipy.optimize.root_scalar`.
@maxiimilian
maxiimilian / ws2812srv.service
Created November 24, 2019 16:39
Systemd Service file to run ws2812 Server as daemon.
[Unit]
Description=WS2812 Server (socket)
After=network.target
[Service]
# Change this to match your install directory
# Send stdout and stderr to /dev/null because RAM might overflow otherwise
ExecStart=/opt/rpi-ws2812-server/ws2812svr -tcp 9999 > /dev/null 2&>1
Restart=on-failure
User=root
@maxiimilian
maxiimilian / Makefile
Created April 1, 2018 14:02
Dockerized Node.js with Makefile for easy access
SHELL=/bin/bash
.PHONY: start dev shell build
start:
@docker-compose ps web | grep -q "Up" || docker-compose start
dev: start
docker-compose logs -f
shell: start
@maxiimilian
maxiimilian / make-mega-adblock-hostsfile.sh
Created January 27, 2018 12:32
Create Mega Adblock Hostsfile for use with Dnsmasq (Modified from Pi-hole)
#!/bin/bash
# Modified Pi-hole script to generate a generic hosts file
# for use with dnsmasq's addn-hosts configuration
# original : https://github.com/jacobsalmela/pi-hole/blob/master/gravity-adv.sh
# Address to send ads to. This could possibily be removed, but may be useful for debugging purposes?
destinationIP="0.0.0.0"
outlist='./final_blocklist.txt'
tempoutlist="$outlist.tmp"
@maxiimilian
maxiimilian / disable.sh
Created October 9, 2017 08:12
Disable bunch of #$!@ in Sierra (Version 2.1)
#!/bin/bash
# IMPORTANT: You will need to disable SIP aka Rootless in order to fully execute this script, you can reenable it after.
# WARNING: It might disable things that you may not like. Please double check the services in the TODISABLE vars.
# Disable SIP (System Integrity Protection) like this:
# 1. Reboot into recovery mode (Cmd + R)
# 2. Open Terminal
# 3. Type `csrutil disable`
# 4. Reboot