Skip to content

Instantly share code, notes, and snippets.

@ajorg
ajorg / find_rm_corrupt.py
Last active May 5, 2024 20:17
Find corrupt pages on a reMarkable tablet
# Author: Andrew Jorgensen
# SPDX-License-Identifier: MIT-0
import os
from glob import glob
from json import dumps, load
from os.path import exists, getmtime, getsize, join, split
from subprocess import run
HEADER_5 = b"reMarkable .lines file, version=5"
HEADER_6 = b"reMarkable .lines file, version=6"
@ajorg
ajorg / wire.py
Last active October 25, 2023 02:02
Wire copies something off the Internet into S3, in a Lambda function
# Copyright Andrew Jorgensen
# SPDX-License-Identifier: MIT
"""Copies data from a URL sources to S3 objects"""
import hashlib
import json
import os
from base64 import b64encode
from decimal import Decimal
from urllib.parse import urlparse
from urllib.request import Request, urlopen
@ajorg
ajorg / indice.py
Created April 17, 2021 17:21
Copies index.html to / in S3
# Copyright Andrew Jorgensen
# SPDX-License-Identifier: MIT
import json
from os import environ
import boto3
MAP = json.loads(environ.get("MAP", '{"index.html":"/"}'))
CLIENT = boto3.client("s3")
# Copyright Andrew Jorgensen
# SPDX-License-Identifier: MIT
"""Receive SNS events in Lambda and POST to a JSON Webhook.
Environment variables required:
* URL - The Webhook URL to POST to (including any required keys)
* TEMPLATE (default: {}) - The JSON data template to POST to the Webhook
* MESSAGE_KEY (default: text) - Key to set to the SNS Message
* TOPIC_KEY (optional) - Key to set to the Topic name from the SNS event
"""
@ajorg
ajorg / ad-nsupdate.sh
Last active February 20, 2024 18:24
Update Active Directory DNS host records using machine / host / computer credentials and nsupdate
#!/bin/bash -e
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0
fqdn="$(hostname -f)"
address="$(/sbin/ip addr show dev eth1 | awk -F'( +|/)' '/inet / {print $3}')"
if [[ "${address}" == "$(dig +short "${fqdn}")" && "${fqdn}." == "$(dig +short -x "${address}")" ]]
then
exit 0
fi
TTL=21600 # 6 hours
@ajorg
ajorg / dmr-fullname-chars.txt
Last active November 15, 2019 15:41
Frequency of characters in full names in DMR ID database
1 `
1 [
1 }
1 #
1 í
2 ]
2 {
4 =
4 ,
4 *
@ajorg
ajorg / certbot-s3front-deploy-renewed.sh
Last active November 9, 2019 19:36
Deploys a certificate renewed by certbot-s3front
# Copyright (c) Andrew Jorgensen. All rights reserved.
# SPDX-License-Identifier: MIT-0
# Requires jq and assumes AWS CLI --output json
DISTRIBUTION_ID="<YOUR DISTRIBUTION ID>"
DISTRIBUTION_CONFIG="$(
aws cloudfront get-distribution-config \
--id "${DISTRIBUTION_ID}" \
| jq -c .)"

Keybase proof

I hereby claim:

  • I am ajorg on github.
  • I am ajorg (https://keybase.io/ajorg) on keybase.
  • I have a public key whose fingerprint is 797E 1821 C777 2E76 F6E3 FBBB 1EFE 5EA5 89A4 BC1A

To claim this, I am signing this object:

@ajorg
ajorg / gist:dc1890d0ffa86aad9f64
Created April 19, 2015 17:22
Occurrence of characters in DMR-MARC names
1 &
1 ¤
1 ©
1 ¶
1 Ñ
1 ñ
1 ú
2 /
2 _
2 ¨
%build
# The plugin requires a complete build of it's own mono
pushd ../mono-%{included_mono}
# We have not determined which --enable-minimal options might be safe
# so please do not use any of them
./configure --prefix=%{_builddir}/install \
--with-mcs-docs=no \
--with-ikvm-native=no
%{__make} EXTERNAL_MCS=false EXTERNAL_RUNTIME=false #%{?jobs:-j%jobs} # mono is not strictly -j safe
# This gets installed in the build dir so that it gets wiped away