Skip to content

Instantly share code, notes, and snippets.

@ansemjo
ansemjo / s3put.sh
Last active November 25, 2022 07:18 — forked from chrismdp/s3.sh
uploading files to S3 in shell with a little bit of curl and openssl
#!/usr/bin/env bash
# https://gist.github.com/ansemjo/cc113ced5d133c018e95079ddb003bb0
set -e -o pipefail
usage() { cat >&2 <<USAGE
usage: s3put [-a acl] [-p pinnedkey] [-h] endpoint file objectpath
-a acl : use a different acl for uploaded files
-p pinnedkey : sha256 pinned public key for certificate validation
-h : display this help
endpoint : endpoint url, e.g. https://s3.exmaple.com:9000
@ansemjo
ansemjo / psa-installer-certupdate@.service
Created May 7, 2020 09:37
concatenate letsencrypt certificates on a plesk host for the psa installer
[Unit]
Description=Update Plesk Installer TLS Certificate with %i's LetsEncrypt chain
[Service]
Type=oneshot
User=root
PrivateTmp=true
PrivateDevices=true
ProtectSystem=full
ProtectHome=true
@ansemjo
ansemjo / Otterpill-Blink.md
Last active May 26, 2020 16:16
minimal blink exmaple for the otterpill with platformio and the stm32cube-hal
@ansemjo
ansemjo / encrypted-dvd.md
Last active February 13, 2024 11:25
create an encrypted dvd with squashfs and luks

1. Create compressed squashfs image

Use mksquashfs to create a compressed image from a directory. Depending on how compressible the files are you could put on much more than 4.7 GB on a single disc.

mksquashfs /path/to/my/directory image.sqfs

You can use a different compression algorithm with e.g. -comp zstd or append multiple times to one archive to fill it up to almost the allowable size.

2. Reencrypt the image to wrap it in a LUKS container

@ansemjo
ansemjo / SimpleSocketChat.py
Created April 10, 2020 18:32
an example of a vanilla WebSocket-based chat with Python's aiohttp server
from aiohttp import web
import os, binascii
import asyncio
import weakref
import datetime
app = web.Application()
app["ws"] = weakref.WeakSet()
routes = web.RouteTableDef()
@ansemjo
ansemjo / FT232H_DotStar.md
Last active January 27, 2020 20:57
Stupid simple library to use APA102 DotStar LEDs with an Adafruit FT232H breakout

Adafruit DotStar + FT232H library

Simple library to drive APA102 LED strips with an Adafruit FT232H breakout board over its SPI pins.

The packed format for the pixels is known from an exploration of the APA102 LEDs on Tim's Blog.

Example Usage

  • Connect the LED strip to the first four pins: 5V, GND, D0 (CLK --> CI), D1 (MOSI --> DI)
  • Follow the Adafruit guide to install adafruit-blinka and set BLINKA_FT232H=1 in your environment
@ansemjo
ansemjo / trends.gplot
Created October 17, 2019 15:22
gnuplot script to plot data from Google Trends for embedding in LaTeX
@ansemjo
ansemjo / openwrtbuilder
Last active May 16, 2022 06:20
OpenWRT builder - using the imagebuilder to compile a custom image
#!/usr/bin/env bash
set -e
RELEASE="snapshot"
TARGET="ar71xx/generic"
PROFILE="archer-c7-v2"
PACKAGES="-ppp -ppp-mod-pppoe luci-ssl wireguard"
DESTINATION=~/Downloads
LISTONLY=no
@ansemjo
ansemjo / container-systemd-autologin.conf
Created April 26, 2019 10:53
enable root autologin when starting a container with systemd init
# drop-in override to fix and enable autologin in rootless containers with systemd init
# e.g.:
#
# podman run --rm -it \
# -v .../container-systemd-autologin.conf:/etc/systemd/system/console-getty.service.d/override.conf:ro \
# centos:latest /usr/lib/systemd/systemd
[Service]
ExecStart=
ExecStartPre=-/usr/bin/sed -i '/pam_loginuid.so/d' /etc/pam.d/login
@ansemjo
ansemjo / aur-package-hooks.md
Last active May 11, 2022 19:44
Git hooks for AUR package repositories to test your PKGBUILD before pushing.

AUR package hooks

These hooks are meant to be used in Git repositories that track PKGBUILD files for the Arch User Repository. Place them in .git/hooks/pre-{commit|push} and make sure they're executable.

pre-commit

This hook simply updates the .SRCINFO before every commit by running: