Skip to content

Instantly share code, notes, and snippets.

@ansemjo
ansemjo / .00_webtransport_quic_issue.txt
Last active April 10, 2024 17:03
WebTransport error reproducer
This is a reproducer for https://github.com/quic-go/webtransport-go/issues/84
USAGE
git clone https://gist.github.com/72e1fc95a8c6e19cabfa750e45eae185.git
cd 72e1fc95a8c6e19cabfa750e45eae185/
bash gencerts.sh
go run main.go
Now open https://localhost:7443/ in Firefox.
open the developer console with ctrl-shift-K
@ansemjo
ansemjo / dcpsqldump.sh
Last active November 15, 2022 08:52
Create external backup of artfiles.de databases via phpMyAdmin panel behind DCP login.
#!/usr/bin/env bash
# Script to backup an artfiles database via phpMyAdmin behind DCP.
# This is mainly useful for their "Private Web medium" plan because the
# next larger plan includes SSH access, so you can just use mysqldump directly.
# The exported SQL is piped to stdout and must be saved to a file or
# piped further for compression, encryption, etc.
# $ ./dcpsqldump.sh > database_$(date +%F).sql
set -eu -o pipefail
# -------- <TODO> --------
@ansemjo
ansemjo / systemd_service_hardening.md
Created May 20, 2022 14:36 — forked from ageis/systemd_service_hardening.md
Options for hardening systemd service units

security and hardening options for systemd service units

A common and reliable pattern in service unit files is thus:

NoNewPrivileges=yes
PrivateTmp=yes
PrivateDevices=yes
DevicePolicy=closed
ProtectSystem=strict
@ansemjo
ansemjo / complete.py
Created May 3, 2022 16:37
generate complete graphs where all nodes are connected with each other using graph-tool
#!/usr/bin/env -S docker run --rm -it -v "${PWD}:/host" -w /host tiagopeixoto/graph-tool python complete.py
# https://graph-tool.skewed.de/static/doc/generation.html#graph_tool.generation.complete_graph
# usage: $ ./complete.py 64 && convert -density 300 complete-64.{pdf,png}
from sys import argv
n = int(argv.pop())
print(f"Generate complete-{n} ...")
from graph_tool import generation, draw
gr = generation.complete_graph(n)
@ansemjo
ansemjo / corefuse.py
Last active January 29, 2022 11:36
FUSE driver to interface with Jussi Kilpelainen's core memory shield. This gives you a four byte file to store all your precious memories in.
#!/usr/bin/env python3
"""
FUSE driver to interface with Jussi Kilpelainen's core memory shield [0].
This gives you a four byte file to store all your precious memories in.
Get the Arduino code on his homepage [1]. I used the 2019-10-31 version.
0: https://www.tindie.com/products/kilpelaj/core-memory-shield-for-arduino/
1: https://jussikilpelainen.kapsi.fi/wordpress/?p=213
"""
@ansemjo
ansemjo / taskgathering.py
Last active July 31, 2021 19:31
print progress information while waiting for a number of async tasks to finish
#!/usr/bin/env python3
# This is free and unencumbered software released into the public domain.
# Please refer to the terms of the "Unlicense" at https://spdx.org/licenses/Unlicense.html
# demo: https://asciinema.org/a/FubNfdJELHAL80xcAJl0RA7OW
import asyncio, random
# random time with some gauss distribution
@ansemjo
ansemjo / singlevue.html
Created January 29, 2021 15:56
an absolutely minimal vue app example with everything in one file (except for vue itself)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>SingleVue</title>
</head>
<body>
<noscript>
@ansemjo
ansemjo / ubuntu-cleaner.sh
Last active May 10, 2023 09:51
Clean up unwanted packages on a fresh installation of Ubuntu 20.04 LTS
#!/usr/bin/env bash
set -eu
# mark a few packages as explicitly installed
mark-wanted() {
apt install -y \
bash git tmux vim htop \
unattended-upgrades \
software-properties-common;
}
@ansemjo
ansemjo / humbleparser.py
Created September 30, 2020 18:38
parse a humble book bundle downloads page and output a more useful json for bulk downloading
#!/usr/bin/env python3
# download multiple books from a humblebundle books page at once
# the "bulk download" button on their site is useless ...
# you *might* need to copy / export the page html from developer tools
from pyquery import PyQuery as pq
import sys, json
# read in page html from stdin
@ansemjo
ansemjo / addwgpeer.sh
Created June 11, 2020 11:13
yet another script to add wireguard client peers on an openwrt router from ssh
#!/bin/bash
set -eu -o pipefail
# MIT License
#
# Copyright (c) 2020 Anton Semjonov
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights