Skip to content

Instantly share code, notes, and snippets.

View brookinc's full-sized avatar

Brook McEachern brookinc

View GitHub Profile
brookinc / wordle-solutions.txt
Created May 1, 2023 10:21
The original "solutions.txt" Wordle / WordleBot data file as hosted on
View wordle-solutions.txt
# current contents:
# Hello! WordleBot previously had a data file called solutions.txt that it once used for certain calculations. It was no longer used, and no longer accurate. We decided to empty this outdated file so it's not confused with any kind of an official solutions list.
# If you're looking for an alternative, you can use a search engine to find many third-party tools and lists that can help you identify words to guess in Wordle, using a variety of techniques and criteria.
# original data:
brookinc / ffmpeg-concat.zsh
Last active April 18, 2022 17:23
Script to concatenate a directory of mp4 files into one
View ffmpeg-concat.zsh
# requires ffmpeg:
# clear the file list
echo "" > ./output.txt
# recursively find all mp4 files in the current directory and subdirectories
# (will preserve alphabetical order by full path)
for entry in ./**/*.mp4
brookinc / PushBackEmplaceBack.cpp
Created July 31, 2019 17:15
Comparison of various push_back() / emplace_back() approaches.
View PushBackEmplaceBack.cpp
#include <iostream>
#include <utility>
#include <vector>
int main()
brookinc /
Created June 27, 2019 01:14
Google Apps Script that adds a "Format Code" menu option for documents.
// Source:
// Docs:
// Add new menu item
function onOpen() {
.addItem('Format Code', 'formatCode')
brookinc / ExifTag.swift
Created December 30, 2018 07:26
Apply macOS file system tags based on EXIF metadata.
View ExifTag.swift
// ExifTag.swift
// Scans files in the given directory and any subdirectories for EXIF metadata and applies
// macOS tags based on the results.
// Usage:
// swift ExifTag.swift [options] path
// or...
// chmod +x ExifTag.swift
brookinc /
Last active November 17, 2021 16:04
Google Apps Script that archives Gmail threads with a given label.
// ArchiveInboxThreads
// This Google Apps Script moves all threads containing any label in the labelsToArchive list out of the
// user's inbox, except for threads that also have a label from the labelsToPreserve list.
// If numInboxThreadsToProcess is set to a value greater than 0, the script will only examine that number
// of the most recent inbox threads when it runs; otherwise, it will examine every thread in the inbox.
// To use this script, visit and click "New script",
// then paste this code into the text editor area and edit the "labelsToArchive" and "labelsToPreserve"
brookinc / .gitconfig
Last active February 22, 2023 16:16
Git config settings that I like to reuse.
View .gitconfig
add-branch = "!f(){ git fetch origin $1 && git branch $1 FETCH_HEAD && git checkout $1; }; f"
alias = "!f(){ git config --global alias.$1 \"$2\"; }; f"
aliases = config --get-regexp ^alias\\.
aliasverbose = "!sh -c '[ $# = 2 ] && git config --global alias.\"$1\" \"$2\" && exit 0 || echo \"usage: git alias <new alias> <original command>\" >&2 && exit 1' -"
br = branch --contains
cherry-pick-external = "!f(){ git --git-dir=$1/.git format-patch -k -1 --stdout $2 | git am -3 -k; }; f"
cleanup = gc
cleanup-slow = gc --aggressive
curr-branch = symbolic-ref --short HEAD
brookinc / -shell.swift
Last active December 29, 2018 05:43
A simple script to demonstrate some basics of Swift scripting.
View -shell.swift
// shell.swift
// A simple script to demonstrate some basics of Swift scripting.
import Foundation
// Docs:
// ...and:
extension CommandLine {
brookinc / -ECS.swift
Last active December 29, 2018 05:42
A simple Entity-Component System experiment in Swift.
View -ECS.swift
import Foundation
#if swift(>=4.2)
// no shim necessary
// add shims for swift-4.2-style random(in:) methods
// NOTE: unlike Swift 4.2's implementations, these versions are prone to modulo bias,
// are not cryptographically secure, and don't support the full range of Int64 values
#if os(Linux)
brookinc / gifsicle.bat
Last active June 14, 2018 18:41
An interactive batch file that simplifies resizing and compressing GIFs with gifsicle.
View gifsicle.bat
@echo off
set /p filename="Enter GIF filename (without .gif extension) to resize: "
set /p scale="Enter scale to resize by (eg. 0.5): "
set /p colors="Enter color palette size to use (between 2 and 256): "
@echo on
gifsicle-1.89-win64\gifsicle.exe --scale %scale% --colors %colors% -O3 --no-extensions %filename%.gif > %filename%-%scale%-%colors%.gif
@echo off