Skip to content

Instantly share code, notes, and snippets.

View benjamingwynn's full-sized avatar
💡

Benjamin Gwynn benjamingwynn

💡
  • United Kingdom
  • 23:11 (UTC +01:00)
View GitHub Profile
@benjamingwynn
benjamingwynn / root usb luks encryption.nix
Last active August 2, 2026 08:35
NixOS 26.05+ encrypted LUKS from file on USB (systemd init)
# [!!] replace SOME-UUID with the UUID from your boot.initrd.luks.devices.[this] for your root drive
# [!!] replace my-disk-label with either the label of your FAT partition or pick some other consistent identifier
# unlock boot disk with file on usb drive
# falls back to prompting for a password after 10 seconds if unavailable
# see https://nixos.wiki/wiki/Full_Disk_Encryption
# see: https://gist.github.com/benjamingwynn/6c8ba9593f70ed4c9841818b95766ea7
# this needed to be modified because 26.05 introduces systemd init, see https://discourse.nixos.org/t/systemd-initrd-for-usb-based-luks-unlocking-root/59179/4
boot.initrd.kernelModules = ["uas" "usbcore" "usb_storage" "vfat" "nls_cp437" "nls_iso8859_1"];
@benjamingwynn
benjamingwynn / pg42uq.md
Created March 10, 2026 20:24
ASUS PG42UQ Input DDC codes

ASUS PG42UQ Display Inputs IDs

Input name ID
DisplayPort 15
HDMI 1 17
HDMI 2 18

For example: m1ddc display CCDF4573-4E2D-413F-9633-CFFDDAD9153B set input 15

@benjamingwynn
benjamingwynn / current_booted_gen.sh
Created September 15, 2024 20:31
Gets the currently booted nixos generation
#!/usr/bin/env bash
# based on https://github.com/NixOS/nixpkgs/issues/163936#issuecomment-1069797072
resolvesTo=`cat /proc/cmdline | sed -n 's/^.*init=\(.*\)\/init.*$/\1/p'`
directory="/nix/var/nix/profiles/"
for symlink in "$directory"/*; do
if [ -L "$symlink" ]; then
resolved_path=$(readlink -f "$symlink")
if [ "$resolved_path" == "$resolvesTo" ]; then
@benjamingwynn
benjamingwynn / README.md
Created July 11, 2024 23:07 — forked from Gadgetoid/README.md
Raspberry Pi Zero / Windows 10 automatic RNDIS driver install for composite gadgets

Preface

I owe my very rapid learning journey in the world of ConfigFs to several key sources which aren't necessarily relevant to this result, but I feel deserve a mention anyway.

@benjamingwynn
benjamingwynn / index.js
Last active October 19, 2022 13:54
Generate a random hexadecimal colour in Javascript
function generateRandomColour () {
return '#'+(Math.random() * 0xffffff | 0).toString(16).padStart(6, '0')
}
@benjamingwynn
benjamingwynn / location-calc.js
Created October 11, 2020 19:14
Calculate how often Google Location data is recorded/sent to Google using Location History.json from Google Takeout
// use nodejs to load location history.json from your google takeout folder -b
var data=require('./Location History')
var times=data.locations.map(d=>parseInt(d.timestampMs))
var between=times.map((t,i) => times[i-1] ? t-times[i-1] : 0 )
var mean=between.reduce((a,v)=>a+v)/between.length
var meanInMinutes=mean/1000/60
console.log("Google location data reported every " + meanInMinutes + " minutes.")
@benjamingwynn
benjamingwynn / open
Last active March 20, 2023 05:59
macOS open command for WSL (Windows Subsystem for Linux)
#!/bin/bash
# open
# macOS open command for WSL (Windows Subsystem for Linux)
# written by benjamin gwynn (https://benjamingwynn.com)
# get latest version here: https://gist.github.com/benjamingwynn/a778aa6cf2dd461dc18978f245bd90c1
#
# You can run this on WSL wuth no prior setup or changes to host Windows.
#
# See: * https://docs.microsoft.com/en-us/windows/wsl/interop#run-windows-tools-from-linux
# * https://stackoverflow.com/a/501295
@benjamingwynn
benjamingwynn / google-home-bluetooth-windows-10-repair.py
Created May 31, 2020 23:31
Actually gets Google Home's bluetooth to connect reliably on Windows 10. Fixes pairing issues, stuck paired issue and just makes the whole process a lot less awful.
# Actually gets Google Home's bluetooth to connect reliably on Windows 10.
# Unpairs Windows AND Google Home using MAC address, then sets everything up for a one-click connection.
# * Prevents Google Home from getting stuck paried using bttool, which is apparently the only way to fix that?
# * Uses some code from Stack Overflow to get the IP from the MAC address so you don't have to dick around with static IP's
# * Connects reliably by repairing bluetooth on Google Home using the "secret" REST API (https://rithvikvibhu.github.io/GHLocalApi)
# * Opens control legacy panel after setting up Google for pairing
#
# Needs btpair installed first, get it from http://bluetoothinstaller.com/bluetooth-command-line-tools/
/** Image object for WebAppManifest */
declare interface WebAppManifestIcon {
/** A string containing space-separated image dimensions. */
sizes: string,
/** The path to the image file. If src is a relative URL, the base URL will be the URL of the manifest. */
src: string,
/** A hint as to the media type of the image. The purpose of this member is to allow a user agent to quickly ignore images of media types it does not support. */
type: string,
}
@benjamingwynn
benjamingwynn / theme.css
Last active December 5, 2017 14:16
ProtonMail Modern Theme
/**
White modern theme for ProtonMail
Work-in-progress (v2) - Copyright Benjamin Gwynn, 2017 (http://benj.pw)
*/
body {
--font: "Roboto", "Cantarell", "Segoe UI", "Ubuntu", sans-serif;
font-family: var(--font);
}