Skip to content

Instantly share code, notes, and snippets.

View xnzacc's full-sized avatar

Zac Z. xnzacc

  • UK
View GitHub Profile
@xnzacc
xnzacc / add_to_zshrc.sh
Created March 6, 2026 04:43 — forked from karpathy/add_to_zshrc.sh
Git Commit Message AI
# -----------------------------------------------------------------------------
# AI-powered Git Commit Function
# Copy paste this gist into your ~/.bashrc or ~/.zshrc to gain the `gcm` command. It:
# 1) gets the current staged changed diff
# 2) sends them to an LLM to write the git commit message
# 3) allows you to easily accept, edit, regenerate, cancel
# But - just read and edit the code however you like
# the `llm` CLI util is awesome, can get it here: https://llm.datasette.io/en/stable/
gcm() {
@xnzacc
xnzacc / microgpt.py
Created March 6, 2026 04:42 — forked from karpathy/microgpt.py
microgpt
"""
The most atomic way to train and run inference for a GPT in pure, dependency-free Python.
This file is the complete algorithm.
Everything else is just efficiency.
@karpathy
"""
import os # os.path.exists
import math # math.log, math.exp
@xnzacc
xnzacc / nvm-v0.39.3-install.sh
Created April 20, 2023 05:48
nvm-sh/nvm/v0.39.3/install.sh on Apr 20th 2023
#!/usr/bin/env bash
{ # this ensures the entire script is downloaded #
nvm_has() {
type "$1" > /dev/null 2>&1
}
nvm_echo() {
command printf %s\\n "$*" 2>/dev/null
@xnzacc
xnzacc / get-ghcup.sh
Created March 29, 2023 10:52
get-ghcup.haskell.org on Mar 29th 2023
#!/bin/sh
# This script downloads the 'ghcup' binary into '~/.ghcup/bin/' and then runs an interactive
# installation that lets you choose various options. Below is a list of environment variables
# that affect the installation procedure.
# Main settings:
# * BOOTSTRAP_HASKELL_NONINTERACTIVE - any nonzero value for noninteractive installation
# * BOOTSTRAP_HASKELL_NO_UPGRADE - any nonzero value to not trigger the upgrade
# * BOOTSTRAP_HASKELL_MINIMAL - any nonzero value to only install ghcup
#!/bin/sh
set -ue
# (c) Copyright Fabrice Le Fessant INRIA/OCamlPro 2013
# (c) Copyright Louis Gesbert OCamlPro 2014-2017
VERSION='2.1.4'
DEV_VERSION='2.1.4'
DEFAULT_BINDIR=/usr/local/bin
@xnzacc
xnzacc / sh.rustup.rs.sh
Created March 29, 2023 08:23
sh.rustup.rs on Mar 29th 2023
#!/bin/sh
# shellcheck shell=dash
# This is just a little script that can be downloaded from the internet to
# install rustup. It just does platform detection, downloads the installer
# and runs it.
# It runs on Unix shells like {a,ba,da,k,z}sh. It uses the common `local`
# extension. Note: Most shells limit `local` to 1 var per line, contra bash.
@xnzacc
xnzacc / nodesource-setup_lts.sh
Last active March 29, 2023 08:35
deb.nodesource setup_lts for Node.js 18.x
#!/bin/bash
# Discussion, issues and change requests at:
# https://github.com/nodesource/distributions
#
# Script to install the NodeSource Node.js 18.x repo onto a
# Debian or Ubuntu system.
#
# Run as root or insert `sudo -E` before `bash`:
#
@xnzacc
xnzacc / How-to-create-bootable-USB-stick-on-OSX
Created April 11, 2022 08:01
Howto: create bootable USB stick on Mac OS X
How-To: create bootable USB-stick from ISO image:
=================================================
1. Download ISO image file:
wget -o ~/Desktop/mini.iso http://ftp.nl.debian.org/debian/dists/wheezy/main/installer-amd64/current/images/netboot/mini.iso
2. Convert ISO file to DMG format using hdiutil:
hdiutil convert -format UDRW -o Desktop/mini.img Desktop/mini.iso
@xnzacc
xnzacc / be_hash_matching.rb
Created July 22, 2014 17:58
RSpec2 custom matcher for DiffMatcher gem
require 'diff_matcher'
RSpec::Matchers.define :be_hash_matching do |expected|
match do |actual|
opts = {:color_enabled=>RSpec::configuration.color_enabled?}
@difference = DiffMatcher::Difference.new(expected, actual, opts)
@difference.matching?
end
failure_message_for_should do |actual|
@xnzacc
xnzacc / gist:b6d8eddfe60042168d36
Created June 30, 2014 07:36
bundle_install_taobao.sh
# Simple script to replace first line of Gemfile with taobao's rubygem mirror url
# save as ~/bin/bundle_install_taobao.sh
# create alias in ~/.zsh_alias: alias bi='bash ~/bin/bundle_install_taobao.sh'
# run 'bi' from project folder
echo "Copying Gemfile to Gemfile_taobao using ruby.taobao.org"
echo
taobao="'source http\:\/\/ruby.taobao.org'"
sed "1s/.*/$taobao/" Gemfile > Gemfile_taobao