Skip to content

Instantly share code, notes, and snippets.


Matthew McEachen mceachen

View GitHub Profile
mceachen / git-restage
Created Sep 20, 2022
git-restage: Ensure all diffs in currently staged files are staged.
View git-restage
# 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 / thenCollect.ts
Created Jul 11, 2020
Serial collection of a SyncOrAsync array applied against a function
View thenCollect.ts
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 / Example.ts
Last active Jul 4, 2020
TypeScript enumerations
View Example.ts
export const Directions = strEnum("North", "South", "East", "West")
export type Direction = StrEnumKeys<typeof Directions>
mceachen / library-settings.toml
Created Jan 8, 2020
PhotoStructure settings snapshots
View library-settings.toml
# Hello!
# These are settings for PhotoStructure, and are formatted using TOML. See
# <>.
# NOTE: Please shut down PhotoStructure before editing this file.
# Most settings have reasonable defaults, which are provided after the
mceachen /
Created Dec 13, 2019
PhotoStructure for Node installation instructions
sudo -u photostructure bash
cd ~photostructure
git clone
mceachen / fe.ts
Created Dec 12, 2019
Add title with URL for browsers that hide the URL on hover
View fe.ts
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
mceachen /
Created Oct 28, 2019
TypeScript implementation of Optional/Some/None

MIT License

Copyright (c) 2016-2019 Matthew McEachen

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

mceachen / etc > network > if-post-down.d > shutdown
Last active Jun 28, 2019
Gracefully shut down when the network shuts down.
View etc > network > if-post-down.d > shutdown
# This should be placed in /etc/network/if-post-down.d/shutdown, and set as executable.
/sbin/shutdown -h now
View gist:519371a832228397bbb8a12029aa0ac0
### Keybase proof
I hereby claim:
* I am mceachen on github.
* I am mrmceachen ( on keybase.
* I have a public key ASCBWP-ugfBxlKdzBnWZgKVkGVm0WZ3mt7x8Y2OCB-hJfwo
To claim this, I am signing this object:
View gist:dcabad5476fea0e0c92dafe4869a0057
mrm@hack:~/src/exiftool-vendored.js (master *)$ DEBUG="mocha:*" yarn mocha --opts .mocha.opts
yarn run v1.13.0
$ /home/mrm/src/exiftool-vendored.js/node_modules/.bin/mocha --opts .mocha.opts
mocha:cli:options no config found in /home/mrm/src/exiftool-vendored.js/package.json +0ms
mocha:cli:options read .mocha.opts +2ms
mocha:cli:options .mocha.opts parsed succesfully +1ms
mocha:cli:mocha loaded opts { _: [],
opts: false,
config: false,
package: false,