Skip to content

Instantly share code, notes, and snippets.

View a-c-m's full-sized avatar

Alex McFadyen a-c-m

View GitHub Profile
@a-c-m
a-c-m / git-stats.sh
Created June 13, 2025 11:04
Git stats per dev (LOC) with delta and comparison
#!/bin/bash
# --- Config ---
EXCLUDE_EXTENSIONS="sql|log|csv|tsv|json|png|jpg|jpeg|gif|bmp|svg|mp4|mp3|zip|gz|tar|pdf|xlsx?|docx?"
WEEKS=4
COMPARE=false
# --- Args ---
for arg in "$@"; do
if [[ "$arg" == "--compare" ]]; then
COMPARE=true
@a-c-m
a-c-m / reflection.md
Last active June 20, 2025 14:18
reflection.md - a way to have claude-code self improve its context.

You are an expert in prompt engineering, specializing in optimizing AI code assistant instructions. Your task is to analyze and improve the instructions for Claude Code. Follow these steps carefully:

  1. Analysis Phase: Review the chat history in your context window.

Then, examine the current Claude instructions, commands and config <claude_instructions> /CLAUDE.md /.claude/commands/*

@a-c-m
a-c-m / autocomplete.sql
Last active January 29, 2025 18:50
PG function to autocomplete fields
CREATE OR REPLACE FUNCTION dynamic_autocomplete(
table_name TEXT,
field_name TEXT,
search_input TEXT
) RETURNS TABLE(count INT, value TEXT)
LANGUAGE plpgsql AS
$$
DECLARE
query TEXT;
BEGIN
import { Box, TextField, Autocomplete } from '@mui/material';
interface CountryType {
code: string;
label: string;
search?: string;
}
interface CountrySelectProps {
value?: CountryType | null;
@a-c-m
a-c-m / measure-node_modules.sh
Created December 15, 2023 10:14
Measures the sizes of your root node_modules folders.
#!/bin/bash
# Find all top-level node_modules directories and calculate their total size
total_size=0
for dir in $(find . -name "node_modules" -type d -not -path "*/node_modules/*"); do
size=$(du -sk "$dir" | cut -f1)
total_size=$(($total_size + $size))
done
# Convert total size to human-readable format
@a-c-m
a-c-m / rm-node_modules.sh
Created December 13, 2023 17:50
A nicer rm all node modules
#!/bin/bash
# Define the directory from where to start searching for node_modules directories
START_DIR="."
# Find all node_modules directories and count them
NODE_MODULES_DIRS=$(find $START_DIR -name 'node_modules' -type d -prune)
TOTAL_DIRS=$(echo "$NODE_MODULES_DIRS" | wc -l)
# Check if there are any directories to remove
@a-c-m
a-c-m / caret-or-tilde.js
Last active December 13, 2023 15:05
caret-or-tilde.js (estlint
/*
Custom ESLint rule to disallow the use of '^' or '~' in dependencies' versions in package.json files.
(--fix works and will remove the '^' or '~' characters from the package.json file!)
eslint-plugin-package-json-dependencies/index.js
module.exports = {
rules: {
'caret-or-tilde': require('./caret-or-tilde'),
},
};
/*
Quick and dirty script to help catch package.json missmatches in large projects / mono repros.
Created with PHIND.COM as a pair programmer ;)
Usage:
node scripts/find-versions-missmatches.js [--fix] [--latest]
--fix - Update all packages to the latest version (local)
--latest - Update all packages to the latest version (npm)
Script will parse all package.json files in the current directory and sub-directories and
@a-c-m
a-c-m / prepare-commit-msg
Last active September 27, 2023 11:28
git/hooks/prepare-commit-msg (auto prefix ticketID)
#!/bin/bash
# Idea is mine (@a_c_m), code it ChatGPT-4, don't forget to `chmod +x .git/hooks/prepare-commit-msg`
# Automatically adds the ticket ID to the commit message, or warns how to do it.
# Get the current branch name
BRANCH_NAME=$(git symbolic-ref --short HEAD)
# Parse arguments
COMMIT_MSG_FILE="$1"
@a-c-m
a-c-m / zoom-auto-close-tab.user.js
Last active April 27, 2020 08:44 — forked from jeremy-w/zoom-auto-close-tab.user.js
Zoom: Auto-Close App Bouncer Tab #userscript
// ==UserScript==
// @name Zoom: Auto-Close App Bouncer Tab
// @namespace https://bignerdranch.com/
// @version 1.1
// @description Close the tab Zoom uses to redirect to its app after several seconds.
// @author Jeremy W. Sherman <[email protected]>
// @author Alex McFadyen <[email protected]>
// @downloadURL https://gist.github.com/a-c-m/86a10ad240e23f778b2564a459238df8/raw/zoom-auto-close-tab.user.js
// @match https://zoom.us/j/*
// @match https://*.zoom.us/j/*