Skip to content

Instantly share code, notes, and snippets.

View malcolmgreaves's full-sized avatar

Malcolm Greaves malcolmgreaves

View GitHub Profile
@malcolmgreaves
malcolmgreaves / ensemble-opinion.md
Created January 19, 2026 23:47 — forked from SilenNaihin/ensemble-opinion.md
Claude Code: Multi-model ensemble opinions (Claude + Gemini + Codex)
description
Get multi-model opinions on a problem (Claude + Gemini + Codex)

You are orchestrating an ensemble of AI models to analyze a problem from multiple angles.

Your Task

  1. Identify the problem from conversation context
  2. Run ALL THREE models in PARALLEL using the Task tool
@malcolmgreaves
malcolmgreaves / debug.md
Created January 19, 2026 23:46 — forked from SilenNaihin/debug.md
Claude Code: Debug command for systematic debugging

Debug

You are stuck on a thorny issue. Take your time. Be comprehensive—thoroughness beats speed here.

Your Approach

  1. Create hypotheses - List all possible causes for what's wrong. Don't jump to conclusions.
  2. Read all related code - Read ALL code that could be related. Take your time. Don't skim.
  3. Add strategic logging - Add console.log statements to verify your assumptions about what's actually happening.
  4. Ultrathink - Think step by step through the problem. Consider edge cases.
@malcolmgreaves
malcolmgreaves / transfer-context.md
Created January 19, 2026 23:42 — forked from SilenNaihin/transfer-context.md
Claude Code: Transfer Context command for new chat sessions

Transfer Context

Prepare context for a new chat session when this one is degraded or hitting limits.

Output Format

## Context Transfer

### Summary
@malcolmgreaves
malcolmgreaves / newtype_valid.rs
Created January 5, 2026 23:28
A macro for a newtype with custom construction validation logic.
#[derive(Debug)]
pub enum Error {
InvalidMarkdown,
InvalidLlmTxtFormat,
Unknown(String),
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "<error>")
@malcolmgreaves
malcolmgreaves / rust_fn_passing_generics.rs
Created March 11, 2025 22:40
Rust function parameter via generics
fn foo() -> impl Fn(i32) -> i32 {
|x| x + 1
}
fn qux<F>(f: F) -> i32
where F: Fn(i32) -> i32 {
f(10)
}
pub fn main() {
@malcolmgreaves
malcolmgreaves / rust_impl_vs_dyn_function_parameter.rs
Created February 18, 2025 19:31
rustc arm assembly code differences for &dyn fn vs. &impl fn: accepting a function parameter
fn foo() -> impl Fn(i32) -> i32 {
|x| x + 1
}
fn bar(f: &impl Fn(i32) -> i32) -> i32 {
f(10)
}
fn baz(f: &dyn Fn(i32) -> i32) -> i32 {
f(10)
@malcolmgreaves
malcolmgreaves / curl.md
Created December 11, 2024 20:24 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@malcolmgreaves
malcolmgreaves / setup_reqs_no_versions_from_txt.py
Created October 7, 2024 23:49
setup.py for getting requirements sans version information from a requirements.txt file for install_requires
from setuptools import setup
if __name__ == "__main__":
def has_requirement(x: str) -> bool:
x = x.strip()
if x.startswith("#"):
return False
return True
@malcolmgreaves
malcolmgreaves / is_literal.py
Created April 29, 2024 21:40
Check if a value is of a literal type.
from typing import Any, Literal
def is_literal(literal_type: type, value: Any) -> bool:
"""Returns True iff the `value` is a variant of the input `literal_type`. False otherwise.
Raises a `ValueError` iff the input `literal_type` is not a `typing.Literal`.
"""
if not hasattr(literal_type, '__origin__') or literal_type.__origin__ != Literal:
raise ValueError(f"Expecting literal type, not {literal_type=}")
@malcolmgreaves
malcolmgreaves / local_temp_dir_rm_exit_trap.sh
Last active April 12, 2024 17:59
Reusable bash functions for creating a local temporary directory with rm exit trap.
#!/usr/bin/env bash
set -euo pipefail
####################################################################
#
# Reusable functions for creating a local temporary directory:
# - [mk_tmp_dir] create local directory with unique name
# - [cleanup] add exit trap to rm this directory