Skip to content

Instantly share code, notes, and snippets.

View ardnew's full-sized avatar
🐿️
ah, nuts!

ardnew

🐿️
ah, nuts!
View GitHub Profile
@ardnew
ardnew / code.py
Last active January 17, 2025 19:00
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
"""
# Based on Scramblepad by Adafruit. The original license follows:
#
# | # SPDX-FileCopyrightText: 2021 Anne Barela for Adafruit Industries
# | #
# | # SPDX-License-Identifier: MIT
# |
# | """
@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.