Skip to content

Instantly share code, notes, and snippets.

View n8henrie's full-sized avatar

Nathan Henrie n8henrie

View GitHub Profile
n8henrie / iphone_cannot_be_played.js
Last active October 17, 2023 22:50
Automatically click "ok" on the dozens of error notifications I get when syncing with MacOS
#!/usr/bin/osascript -l JavaScript
function click_ok() {
const sys = Application('System Events')
const finder = sys.processes["Finder"]
try {
let sheets ={name: "NatePhone"}).sheets().flat()
let message = "cannot be played on this iPhone."
let error_sheet = sheets.filter(sheet => {
n8henrie / nix-darwin-linux-builder-example.nix
Created September 25, 2023 21:33
How to use darwin-builder to build linux nix packages on darwin
description = "Example use of nixpkgs#darwin-builder";
# First, read through
# and add yourself to `extra-trusted-users`, verify with `nix show-config | grep -i trusted-users`
# Copy this flake somewhere and run:
# ```console
# $ nix build --builders '' .#packages.aarch64-darwin.default
n8henrie / pbcopy
Created September 13, 2023 18:35
pbopy: copy over ssh to a MacOS host's clipboard
set -Eeuf -o pipefail
readonly SSH_PORT=1234
readonly USERNAME=me
readonly SSH_KEY=/home/"${USERNAME}"/.ssh/my_key_id_rsa
readonly DEST=my_machine_name
main() {
#!/usr/bin/osascript -l JavaScript
'use strict'
const Safari = Application("Safari")
const Chrome = Application("Google Chrome")
const Brave = Application("Brave Browser")
const SystemEvents = Application("System Events")
const Firefox = Application("firefox")
const DefaultBrowser = Firefox
#!/usr/bin/env python3
""" :: Compares a LastPass export to your Bitwarden vault.
Python >=3.10, no third party Python libraries / dependencies.
Outputs BW logins that may have been compromised in the recent LastPass hack
based on matching domain and password.
It would probably make sense to cast an even wider net by using something like
n8henrie / OpenTerminalToFinderWindow.js
Last active August 10, 2023 17:39
JXA to open a Terminal window to the frontmost Finder window
#!/usr/bin/osascript -l JavaScript
'use strict';
const DEBUG = false;
(function () {
const terminal = Application("Terminal")
// A few seconds to focus the appropriate Finder window
Well, this ended up being easier than I'd expected to implement with coreutils.
Wrapped it up into a little script that sorts by count and removes anything with only 1 result (like files).
Should be pretty easy to also add in a `du -sh` to get sizes if one wanted. Currently it runs in <2s on that 500,000 line file on my M1 Mac. Sharing in case useful for anyone else.
#!/usr/bin/env bash
n8henrie /
Last active September 2, 2022 14:07
Make alacritty into a pop-up scratchpad
#!/usr/bin/env bash
set -Eeuf -o pipefail
shopt -s inherit_errexit
log() {
echo "$*" > /dev/stderr
err() {