Skip to content

Instantly share code, notes, and snippets.

View szapp's full-sized avatar

Sören Zapp szapp

View GitHub Profile
@szapp
szapp / matlab_remove_trailing_whitespace
Last active September 22, 2016 09:22 — forked from hmaarrfk/matlab_remove_trailing_whitespace
Improved to replace the text only if it was changed to prevent the "unsaved" asterisk
% To remove a Matlab trailing whitespace in the editor
% Original Author: Sam Roberts
% http://stackoverflow.com/questions/19770347/how-to-auto-remove-trailing-whitespaces-on-save-in-matlab
% Modified by Mark Harfouche to remember cursor location
%
%
% Temp variable for shortcut. Give it an unusual name so it's unlikely to
% conflict with anything in the workspace.
shtcutwh__ = struct;
@szapp
szapp / createreport.sh
Created July 9, 2018 15:30
Jupyter HTML template for "html_with_lenvs" for local viewing
#!/bin/bash
# Create report from juptyer notebook for local viewing (no internet)
# with support for the nbextensions
# - latex_envs
# - hide_input
#
# Download the following javascript projects and place them
# into the destination directory with macthing directory names.
# - font-awesome-4.7.0
# - jquery-2.0.3
@szapp
szapp / ejectUSB.sh
Last active October 11, 2019 08:49
Safely eject removable devices from command line (linux)
#!/bin/bash
# Equivalent to safely removing devices
# The parameter is (part of) the mountpoint
mountpoint=$1
if [[ -z "$mountpoint" ]] || [[ "$mountpoint" == "--help" ]] ; then
echo "Usage: ${0##*/} mountpoint"
exit 1
fi
@szapp
szapp / cell07.ipynb
Created December 4, 2018 14:01
Attempt to recreate figure 3 from Maheswaranathan et al, 2018
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@szapp
szapp / smarterbounds.py
Last active December 10, 2019 15:12
Smarter bounds for matplotlib.spines.Spine
"""
Smarter bounds
This function emulates set_smart_bounds of matplotlib.spines.Spine,
but correctly sets the extent of the axes.
"""
def smarterbounds(ax, which='both'):
"""
@szapp
szapp / quickplot.py
Created December 10, 2019 15:13
Quick plotting functions
"""
Quick plotting for testing and preliminary data visualization
"""
from matplotlib import pyplot as plt
from matplotlib.colors import LinearSegmentedColormap
import numpy as np
__all__ = [
'imshow',
]
@szapp
szapp / restore_from_history.py
Last active August 3, 2025 14:55
Renames files copied from Windows FileHistory to match the original file names. Requires uv.
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.13"
# dependencies = [
# "cyclopts",
# "pytest",
# ]
# ///
"""Usage from command line:
`./restore_from_history.py --help` or `uv run --script restore_from_history.py --help`
@szapp
szapp / dynamic.svg
Last active August 5, 2025 19:27
Demo of dynamic SVG files that change appearance based on the presence of each other.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@szapp
szapp / Filen S3 (HTTP).cyberduckprofile
Created August 6, 2025 15:30
A profile for Cyberduck for the use of a Filen S3 server including basic settings to get it working an an icon.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Protocol</key>
<string>s3</string>
<key>Vendor</key>
<string>filen-s3-http</string>
<key>Scheme</key>
<string>http</string>
@szapp
szapp / machine-code-to-daedalus.py
Created August 7, 2025 21:20
Format hexadecimal machine code bytes into Daedalus conform recipes. Run with `uv run machine-code-to-daedalus.py`.
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.13"
# dependencies = [
# "cyclopts",
# ]
# ///
import logging
import re