Skip to content

Instantly share code, notes, and snippets.

@ansemjo
ansemjo / singlevue.html
Created Jan 29, 2021
an absolutely minimal vue app example with everything in one file (except for vue itself)
View singlevue.html
<!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
Created Oct 31, 2020
Clean up unwanted packages on a fresh installation of Ubuntu 20.04 LTS
View ubuntu-cleaner
#!/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 Sep 30, 2020
parse a humble book bundle downloads page and output a more useful json for bulk downloading
View humbleparser.py
#!/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 Jun 11, 2020
yet another script to add wireguard client peers on an openwrt router from ssh
View addwgpeer.sh
#!/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
@ansemjo
ansemjo / botoput.py
Created May 27, 2020
pipe files to s3 with boto3. you should probably use pure bash/curl s3put.sh instead: https://gist.github.com/ansemjo/cc113ced5d133c018e95079ddb003bb0
View botoput.py
#!/usr/bin/env python3
#
# botoput is a simple Python script to upload files to an S3-
# compatible endpoint by piping data to stdin:
#
# echo 'Hello, World!' | ./botoput -c s3.ini bucket/hello.txt
#
# Example configuration file:
#
# [s3]
@ansemjo
ansemjo / s3put.sh
Last active Oct 14, 2020 — forked from chrismdp/s3.sh
uploading files to S3 in shell with a little bit of curl and openssl
View s3put.sh
#!/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
concatenate letsencrypt certificates on a plesk host for the psa installer
View psa-installer-certupdate@.service
[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
minimal blink exmaple for the otterpill with platformio and the stm32cube-hal
View Otterpill-Blink.md
@ansemjo
ansemjo / encrypted-dvd.md
Last active May 12, 2021
create an encrypted dvd with squashfs and luks
View encrypted-dvd.md

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 Apr 10, 2020
an example of a vanilla WebSocket-based chat with Python's aiohttp server
View SimpleSocketChat.py
from aiohttp import web
import os, binascii
import asyncio
import weakref
import datetime
app = web.Application()
app["ws"] = weakref.WeakSet()
routes = web.RouteTableDef()