Skip to content

Instantly share code, notes, and snippets.

View ardnew's full-sized avatar
🤕
cracking skulls

ardnew

🤕
cracking skulls
View GitHub Profile
@ardnew
ardnew / adobe-cc-fonts.bash
Last active March 17, 2025 17:34
Extract font files installed by Adobe Creative Cloud
#!/usr/bin/env bash
# This script extracts the locally-cached font files installed by
# Adobe Creative Cloud.
#
# The extracted fonts can then be used in other applications.
#
# See --help|-h for usage information.
usage() {
@ardnew
ardnew / .runas
Created February 24, 2025 21:45
Run as Administrator from WSL
#!/bin/bash
#
# == SUMMARY ===================================================================
#
# This script is used to invoke a native Windows program (.exe) or batch script
# (.bat, .cmd, .com) — referred to as COMMAND below — as an Administrator.
#
# It is intended to be used from a WSL shell session, where the target program
# runs in the parent Windows environment with elevated privileges.
#
@ardnew
ardnew / code.py
Last active May 3, 2025 00:24
Adafruit Macropad - HID Keyboard - Unlock screen with password(s) on Windows Domain
"""
Password Macropad - Unlock Windows workstations with obnoxious
domain password requirements using only a PIN
No user account information is stored plain-text in the sources —
it is all AES encrypted and decrypted at runtime on-demand.
See secrets.py.
Each entry in secrets['accounts'] appears as a single row on the
Macropad. Pressing the key in the first column will simulate
@ardnew
ardnew / capslock.c
Created January 10, 2025 23:39
C command-line utility to control/query the state of Caps-Lock in X11
// capslock.c - Andrew Shultzabarger (9 Jan 2025)
//
// Command-line utility to control/query the state of Caps-Lock in X11.
//
// To compile:
// gcc -g -Wall -std=gnu99 -o capslock -lX11 capslock.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ardnew
ardnew / prepath.zsh
Created June 3, 2024 21:18
prepend or remove elements in a delimited string list with zsh
#!/bin/zsh
# ------------------------------------------------------------------------------
#
# prepath: prepend or remove elements in a delimited string list
#
# examples:
#
# #| this example demonstrates:
# #| - the default list delimiter is ":"
# #| - the variable to modify is given by name, not value
@ardnew
ardnew / gpg2ssh
Created March 5, 2024 20:39
Extract or recreate original SSH private key added to GPG2 keyring
$ gpg2 --list-secret-keys --keyid-format short
/home/user/.gnupg/pubring.kbx
-------------------------------
sec rsa4096/53C2371D 2020-06-18 [SC]
47009EB0BA7E95211A217130D77BCDBD8340250A
uid [ultimate] User Name <[email protected]>
ssb rsa4096/53AF00DS 2020-06-18 [E]
ssb rsa4096/CA7F00DS 2021-02-18 [A]
# Notice I'm not using the primary key, but instead the first subkey with
@ardnew
ardnew / bash-completion-alias.bash
Created February 2, 2024 22:31
bash-completion for alias of full command line (with subcommands)
#!/bin/bash
# ==============================================================================
# |#
# |# Example aliases with bash-completion support
# |#
#
#complete-alias sc systemctl # sc <tab> => systemctl <tab>
#complete-alias scs systemctl status # scs <tab> => systemctl status <tab>
#
@ardnew
ardnew / gh-copilot.bash
Last active April 14, 2024 20:09
bash functions to abbreviate github/gh-copilot commands
#!/opt/bash/bin/bash
if ghbin=$( type -P gh ); then
copilot="github/gh-copilot"
if "${ghbin}" extension list 2>&1 | cut -s -f2 | grep -q "^${copilot}$"; then
function ? {
[[ ${#} -gt 0 ]] || set -- --help
@ardnew
ardnew / go-mod-local
Created October 29, 2022 09:23
Shell script to add go.mod replace directives when working with multiple local modules
#!/bin/bash
usage() {
cat <<__usage__
-- DESCRIPTION -----------------------------------------------------------------
Insert a 'replace' directive into each given Go module (default: PWD) that
defines a local file path of a Go package to import instead of the published
package named in any of the given modules' import lists.