Skip to content

Instantly share code, notes, and snippets.

View mceachen's full-sized avatar

Matthew McEachen mceachen

View GitHub Profile
@mceachen
mceachen / claude_code_compromise_check.py
Last active October 30, 2026 17:49
Read-only check for Claude Code 2.1.313 extension backdoor indicators (Cursor marketplace; macOS, Windows, Linux)
#!/usr/bin/env python3
"""Read-only check for the Claude Code extension 2.1.313 backdoor indicators.
Run: python3 claude_code_compromise_check.py
Works with Python 3.8+ on macOS, Windows, and Linux. Checks the current user.
Exit codes: 2 = indicator found; 1 = no indicator found but a check failed;
0 = no indicator found in the locations checked.
Sources: https://cursor.com/blog/claude-code-extension-security-notice
https://phorion.io/blog/offical-claude-code-vsx-compromise/
@mceachen
mceachen / responsive-image.html
Created October 26, 2026 04:27
Hugo partial: <picture> with WebP and JPEG srcsets for hero images
{{/*
Responsive Image Partial - Full Width Hero Headers
Generates a <picture> with WebP and JPEG srcsets for full-width hero headers.
Only processes images with "-2000w" in the filename.
Other images are used as-is from static directory.
Usage: {{ partial "func/responsive-image.html" . }}
Generates sizes: 400w, 800w, 1200w, 1600w, 2000w
@mceachen
mceachen / gist:9038d2358622241ddc91c45017fc3b17
Created September 26, 2025 22:06
Gemini 2.5 Pro + Copilot
This is a valid and important code review comment. The current implementation has a potential flaw that could lead to incorrect path normalization, and the suggested solution is much more robust.
Here's my thinking:
The Problem is Real: The current code uses indexOf("/photostructure/src/") to find what it assumes is the project's source directory. If a user's library path was something like /media/nas/photos/my-photostructure/src/, the code would incorrectly shorten the path, which could lead to unexpected behavior or errors.
The Solution is Sound: The suggestion to use a method that reliably finds the repository root and then calculates the relative path from there is the correct approach. It avoids making assumptions about the directory structure outside of the project itself.
I will now implement the suggested change. I'll start by creating a plan to address this.
@mceachen
mceachen / git-addgrep
Created November 29, 2023 04:11
git addgrep: stage all diff hunks that match a given regexp
#!/bin/bash -e
# Renamed a file or method? Use this to add all files matching that regex pattern.
# Assumes this file lives in $ROOT/bin, so we need to hop up a level (the `/..` bit)
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. >/dev/null 2>&1 && pwd)"
cd "$ROOT"
# Ignore calls to `git add` that have no filenames:
git config advice.addEmptyPathspec false
@mceachen
mceachen / git-restage
Last active December 27, 2025 06:03
git-restage: Ensure all diffs in currently staged files are staged.
#!/bin/sh
# Stage all diffs found in currently staged files
# This is useful if you've got a set of files ready to commit, but edited one
# or more of them (via prettier, delinting, deleting debug statements, adding
# more tests, ...), and want to make sure those changes are included.
# Usage: `git restage`
@mceachen
mceachen / thenCollect.ts
Created July 11, 2020 21:14
Serial collection of a SyncOrAsync array applied against a function
export type SyncOrAsync<T> = T | Promise<T>
export type Maybe<T> = T | undefined
export type MaybeSyncOrAsync<T> = Maybe<SyncOrAsync<Maybe<T>>>
/**
* Serialized promise gathering and compaction
*/
export async function thenCollect<T1, T2>(
arr: MaybeSyncOrAsync<MaybeSyncOrAsync<T1>[]>,
f: (t: T1) => MaybeSyncOrAsync<T2>
@mceachen
mceachen / Example.ts
Last active July 4, 2020 22:14
TypeScript enumerations
export const Directions = strEnum("North", "South", "East", "West")
export type Direction = StrEnumKeys<typeof Directions>
@mceachen
mceachen / library-settings.toml
Created January 8, 2020 18:00
PhotoStructure settings snapshots
#
# Hello!
#
# These are settings for PhotoStructure, and are formatted using TOML. See
# <https://github.com/toml-lang/toml>.
#
# NOTE: Please shut down PhotoStructure before editing this file.
#
# Most settings have reasonable defaults, which are provided after the
@mceachen
mceachen / clone.sh
Created December 13, 2019 23:59
PhotoStructure for Node installation instructions
sudo -u photostructure bash
cd ~photostructure
git clone https://github.com/photostructure/photostructure-for-servers.git
@mceachen
mceachen / fe.ts
Created December 12, 2019 23:38
Add title with URL for browsers that hide the URL on hover
export function $$<T extends HTMLElement = HTMLElement>(selector: string) {
return document.querySelectorAll<T>(selector)
}
export function blank(o: any): o is undefined {
if (o == null) return true
const s = String(o)
return s.length === 0 || s.trim().length === 0
}