Skip to content

Instantly share code, notes, and snippets.

View jdmallen's full-sized avatar

J.D. Mallen jdmallen

View GitHub Profile
@jdmallen
jdmallen / .zsh__aliases.zsh
Created September 7, 2026 03:10
My optimized .zshrc file, plus a couple files that get loaded from the `~/.zsh/` dir. The `cached_init` stuff I had Claude help me out with to speed up the shell. Works like a charm!
# clipboard
alias pbcopy='xclip -selection clipboard -i'
alias pbfilter='xclip -selection clipboard -f'
alias pbpaste='xclip -selection clipboard -o'
# tool replacements
alias top="htop"
if command -v batcat >/dev/null 2>&1; then
alias bat="batcat"
@jdmallen
jdmallen / AccessibleText.vue
Created July 14, 2026 22:35
Saving some functions that might be useful for accessibility later
<script setup lang="ts">
import { ref, onMounted, onUnmounted } from 'vue';
// Convert HSL to RGB
const hslToRgb = (h: number, s: number, l: number): number[] => {
s /= 100;
l /= 100;
const c = (1 - Math.abs(2 * l - 1)) * s;
const x = c * (1 - Math.abs((h / 60) % 2 - 1));
const m = l - c / 2;
version: 1
directus: 11.12.0
vendor: postgres
collections:
- collection: cast_crew
meta:
accountability: all
archive_app_filter: true
archive_field: null
archive_value: null
@jdmallen
jdmallen / toggle-primary-mouse-button.desktop
Created February 4, 2025 14:38
GNOME desktop shortcut to switch primary mouse button (I'm ambidextrous and switch often), written for Ubuntu 24.04.1
# Place in ~/Desktop
[Desktop Entry]
Type=Application
Name=Toggle Mouse Button
Exec=zsh -c "~/bin/toggle-primary-mouse-button.zsh"
Icon=/usr/share/icons/Adwaita/scalable/devices/input-mouse.svg
Terminal=false
Categories=Utility
@jdmallen
jdmallen / ssh_agent_check.zsh
Last active December 19, 2024 17:41
How I load a common SSH agent for git in Linux with ZSH shell in Ubuntu
#!/bin/zsh
# Install keychain via `sudo apt update && sudo apt install keychain`
# Add space-delimited SSH and GPG keynames you want to load on line 7.
# They will persist across terminals.
keychain -q -k others --nogui --agents gpg,ssh \
id_rsa AB44DF0C6FEC01F2B396AE0429410408D95E08AA
[ -z "$HOSTNAME" ] && HOSTNAME=`uname -n`
[ -f $HOME/.keychain/$HOSTNAME-sh ] && \
. $HOME/.keychain/$HOSTNAME-sh
@jdmallen
jdmallen / .bashrc (Windows)
Last active December 19, 2024 17:10
My .bashrc file that I use in Windows alongside the PowerShell profile, which loads a common SSH agent for git
# Starts an SSH agent for use with git.
# I designed this to share the same agent between PowerShell and Git Bash.
# Make sure you set $GIT_SSH at the User or System level to point to
# whichever ssh-agent.exe PowerShell is using, or else this won't work.
function start_agent {
/c/Windows/System32/OpenSSH/ssh-agent.exe > /dev/null
# Output agent's PID to file
ps -W | grep ssh-agent | awk '{print $4}' | head -n 1 > ~/.ssh/pid
/c/Windows/System32/OpenSSH/ssh-add.exe ~/.ssh/id_rsa.pri # or wherever your private keys are
@jdmallen
jdmallen / profile.ps1
Last active July 5, 2024 12:02
My personal PowerShell profile-- think of it as a `.bashrc` file for PS-- that loads a common SSH agent for git
# Gives me git info in the shell when in git directories
Import-Module posh-git
# Simple function to tell me if I'm in an admin window or not
Function Test-Elevated
{
$wid = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$prp = New-Object System.Security.Principal.WindowsPrincipal($wid)
$adm = [System.Security.Principal.WindowsBuiltInRole]::Administrator
$prp.IsInRole($adm)
@jdmallen
jdmallen / openssl_sample_config.cnf
Last active October 17, 2023 12:32
An anonymized version of the configuration file I often use with OpenSSL
# OpenSSL root CA configuration file.
[ ca ]
# `man ca`
default_ca = ICA_default
[ CA_default ]
# Directory and file locations.
dir = ./ca # Where everything is kept
certs = $dir/certs # Where the issued certs are kept
@jdmallen
jdmallen / openssl_command_examples.md
Last active October 17, 2023 12:37
Sample commands for OpenSSL, assuming you have an external openssl.cfg file to use (see other gist)

Generate private RSA key with AES encryption

openssl genrsa -out .\path\to\my_cert_encrypted.key -aes256 4096

Generate private RSA key without encryption

openssl genrsa -out .\path\to\my_cert.key 4096
@jdmallen
jdmallen / check_admin_or_root.cs
Created May 15, 2021 18:03
Check if .NET Core/5+ app is running elevated
// To check if you are running as root on Unix:
// 1. Add a PackageReference to Mono.Posix.NETStandard
// 2. Change IsAdminstrator to the following:
public static bool IsAdministrator =>
RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
? new WindowsPrincipal(WindowsIdentity.GetCurrent())
.IsInRole(WindowsBuiltInRole.Administrator)
: Mono.Unix.Native.Syscall.geteuid() == 0;