Skip to content

Instantly share code, notes, and snippets.

View apsun's full-sized avatar

Andrew Sun apsun

View GitHub Profile
#!/bin/bash
#
# generates a database containing all amateur radio entities from the FCC
# documentation: https://www.fcc.gov/wireless/data/public-access-files-database-downloads
#
# example usage:
# find all 1x3 callsigns with suffix ABC
# select call_sign, license_status from HD where call_sign like '__ABC';
#
# find all callsigns registered in zip code 98005
#!/bin/bash
set -euo pipefail
GPG_KEY_ID='<[email protected]>'
DEVICE_NAME='yourhostname'
# mount
d=$(mktemp -d)
ifuse --documents me.mssun.passforios "$d"
#!/bin/sh
set -euo pipefail
if [ $# -ne 2 ]; then
echo >&1 "usage: $0 <index> <hostname>"
exit 1
fi
index="$1"
hostname="$2"

I recently purchased a Framework 13 and a ThinkPad P14s Gen 5 AMD. I thought I would write down my impressions after using them for a week and see how they stack up against a modern MacBook. (No performance comparisons, as I got the 7640U in the Framework vs. the 8840HS in the ThinkPad, so it wouldn't be a fair fight)

Framework 13 AMD ($845 laptop + $80 RAM + $80 SSD)

Build quality

  • expansion cards have significant gaps, one port misaligned slightly
  • shell feels like plastic, not very premium (very thin aluminum)
  • screen flex is quite significant when bent from a corner
  • hinge is stiff but very wobbly, can open with one hand
  • bezel not very secure, peels up when opening screen all the way

I recently decided to upgrade the headlight on my Brompton Electric bike to the Cyo Premium E. I followed https://www.youtube.com/watch?v=osCbgMQwlY0 but found the video lacking in detail, so this guide goes into more depth on the parts and procedure needed.

The main difficulty with this upgrade is that the Cyo headlight does not come with the Molex connector used on the stock Brompton headlight, so you'll need to either install the connector on the new light yourself, or remove both sides of the original connector and solder the wires together. I went with the former approach, as I found it a bit "cleaner", and avoids modifying the battery side of the wiring.

Requirements

Modding the Kinesis Advantage2

I recently became the owner of a Kinesis Advantage360, and thought it would be fun to replace the awful Cherry MX Browns in my old Advantage2 keyboard with some decent switches. I had read online that you could purchase replacement empty PCBs from Kinesis, but when I contacted them I was told that they stopped selling them years ago :-(

Well then, guess I'll have to do it myself!

Tools required

  • Phillips-head screwdriver
  • Soldering iron (I used the Pinecil, but any decent iron will do)
@apsun
apsun / repl.py
Last active December 22, 2023 06:12
One-liner to drop into a Python REPL
__import__("code").InteractiveConsole({**globals(), **locals()}).interact()
@apsun
apsun / ios-exif-rename.sh
Last active November 21, 2023 20:18
Rename iOS photos/videos using file metadata
#!/bin/bash
#
# A note on timezone handling: this script uses the local timezone in which
# the photo/video was originally taken.
#
# "CreateDate" stores the local time on images, but UTC on videos.
# "CreationDate" stores the full timestamp with timezone, but is only
# available on videos.
shopt -s nullglob

Windows 10 on an existing UEFI Linux setup

I will assume that we are starting from a Linux-only setup with free space available on the disk, e.g. by following everything at https://gist.github.com/apsun/1f7b1da40b028a9ed1e0409ca8c3b3cc.

Starting out, the disk should look like:

/dev/sda
  sda1 <-- ESP
  sda2 <-- Linux
@apsun
apsun / cpp_exceptions_tldr.md
Last active April 26, 2022 04:09
C++ Itanium ABI for exception handling

This aims to be a brief introduction to how C++ exceptions are implemented on Linux. It's based on an afternoon of reading and may contain serious inaccuracies, so read at your own risk.

We start from the point where an exception is thrown. First, we allocate an exception object on the heap using __cxa_allocate_exception. This exception object contains:

  • the actual object you're throwing (hereafter referred to as the "user exception")
  • a C++ exception library header (__cxa_exception) which contains:
    • the std::type_info and destructor of the user exception
    • a reference count for the exception
    • some other stuff which I'll gloss over for the sake of brevity
  • a language-agnostic unwind library header (_Unwind_Exception) which contains:
  • a tag specifying whether this is a C++ exception (it is!)