Skip to content

Instantly share code, notes, and snippets.

View apsun's full-sized avatar

Andrew Sun apsun

View GitHub Profile
@apsun
apsun / win7iso.md
Last active December 16, 2023 06:19

Windows 7 install ISO with slipstreamed updates

Preparation

Create three directories. For the sake of this tutorial, they will be:

  • c:\image - holds the contents of the ISO file
  • c:\mount - mount point for the install.wim file
  • c:\updates - holds the update files
@apsun
apsun / wg0-client.conf
Last active February 21, 2022 06:22
Example WireGuard configuration
[Interface]
PrivateKey = <REDACTED>
Address = 10.19.84.2/32,fd07:d3fc:8a02::2/128
DNS = 10.19.84.1,fd07:d3fc:8a02::1
MTU = 1280
[Peer]
PublicKey = <REDACTED>
PresharedKey = <REDACTED>
AllowedIPs = 0.0.0.0/0,::/0
@apsun
apsun / duplicity-backup.md
Last active September 2, 2023 19:40
Backup files using duplicity to Backblaze B2

duplicity -> Backblaze B2

Daily systemd timer to backup the contents of my filesystem to Backblaze B2. As-written, it will keep up to a year's worth of backups, performing one full backup every month. This script was tested with duplicity 2.1.0.

Configure the script

Create a B2 bucket and an application key with read/write permissions to that bucket. Configure object lock with a sufficiently long period (I use 3x the full backup period) to ensure that ransomware won't be able to nuke your backups. Also ensure the 'list all bucket names' option is enabled (unless you want to use the

T450s Arch Linux installation

This documents how to install Arch Linux on a ThinkPad T450s, with full disk encryption and UEFI secure boot. It assumes you're familiar with installing Arch Linux, but new to encryption/secure boot. It does not install a bootloader (UEFI comes with one built in), and assumes you are not going to dual boot another OS.

(The instructions here should work fine for other devices too - just ignore the ThinkPad-specific bits)

Wipe the hard drive (optional)

My T450s has issues with using hdparm to wipe the disk, so instead we will use the drive erase utility provided by Lenovo. This section is mostly copied from this tutorial.

@apsun
apsun / cleantags.py
Last active March 6, 2022 06:20
Normalize ID3 tags from filename
#!/usr/bin/env python3
import re
import os
import sys
import mutagen.id3
def main(filepath):
print(filepath)
# Save original mtime
@apsun
apsun / build.gradle.kts
Last active October 14, 2023 05:55
Documented build.gradle for publishing an Android library to Maven Central
// This is a documented version of the build.gradle file from RemotePreferences:
// https://github.com/apsun/RemotePreferences/blob/master/library/build.gradle.kts
//
// It aims to explain exactly WTF is going on when you inevitably copy-paste
// someone's build.gradle from the internet and can't figure out why it's not
// working.
//
// It contains, to the best of my knowledge, the best practices as of Oct 2023 for
// building an Android library and publishing it to OSSRH (Maven Central).
//
#!/bin/sh
#
# Sync photos from iPhone to Linux using libimobiledevice + ifuse
set -euo pipefail
if [ $# -ne 1 ]; then
echo "usage: $0 <dest dir>"
exit 1
fi

iOS notes

Just some random stuff I'm learning as I make my first iOS app.

UIViewController: present vs show

present() will always show the view controller modally, whereas with show() it will bubble up the chain where it can be handled by some parent view controller.

#!/bin/sh
#
# Sync music from Linux to iPhone using libimobiledevice + ifuse
# Only works with apps that can read songs from iTunes file sharing (e.g. Doppi)
set -euo pipefail
if [ $# -ne 1 ]; then
echo "usage: $0 <src dir>"
exit 1
// Converts images into PNG format with the top-left corner transparent.
// Signal treats images sent via the keyboard with a transparent top-left
// corner as actual stickers, skipping one button click. This script
// automates batch conversion into this "sticker" format, for use with
// uSticker. Currently doesn't work with animated GIFs.
package main
import (
"flag"