Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
set -eu
# macOS
find . -type f \( -iname \*.cs \) -exec perl -e 's/\xef\xbb\xbf//;' -pi.bak {} \; -exec rm {}.bak \;
!/usr/bin/env sh
set -eu
git diff master..HEAD | grep -B 2 -A 2 "${@}"
import sys
simple_table = {
":encoded1:" : "a",
":encoded2:" : "b",
":encoded3:" : "c",
":encoded4:" : "d",
":encoded5:" : "e",
":encoded6:" : "f",
":encoded7:" : "g",
import sys
pair_table = {
"a" : ("", 1),
"b" : ("", 2),
"c" : ("", 3),
"d" : ("", 4),
"e" : ("", 5),
"f" : ("", 6),
"g" : ("", 7),
@steverichey
steverichey / delete_git_submodule.md
Last active January 26, 2021 14:43 — forked from myusuf3/delete_git_submodule.md
How to effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes: git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path/to/submodule (no trailing slash).
  • Run rm -rf .git/modules/path/to/submodule (no trailing slash).
  • Commit git commit -m "Removed submodule <name>"
  • Delete the now untracked submodule files: rm -rf path/to/submodule
@steverichey
steverichey / PerformOnExit.cs
Created May 14, 2020 14:02
A C# class to call a method when the object goes out of scope.
/// <summary>
/// Performs an action when disposed.
/// <code>
/// using (new PerformOnExit(Foo))
/// {
/// Bar();
/// }
/// </code>
/// </summary>
public sealed class PerformOnExit : IDisposable
@steverichey
steverichey / LittleTyper.swift
Created May 4, 2020 15:22
A Swift playground for the beginning of the book, The Little Typer
import Cocoa
import Foundation
protocol AtomType {}
struct Atom: AtomType {}
func == <Atom1, Atom2> (lhs: Atom1, rhs: Atom2) -> Bool where Atom1: AtomType, Atom2: AtomType {
return type(of: lhs) == type(of: rhs) // maybe
}
@steverichey
steverichey / pw
Created October 25, 2019 21:54
Simple password generator, version 2
#!/usr/bin/env sh
set -eur
generate()
{
allowed_characters="${1}"
number_of_characters="${2}"
cat /dev/random | env LC_CTYPE=C tr -cd "${allowed_characters}" | head -c "${number_of_characters}"
}
@steverichey
steverichey / imagenet_labels.txt
Created March 29, 2019 19:39
Just the ImageNet labels used by ResNet.
tench
goldfish
great_white_shark
tiger_shark
hammerhead
electric_ray
stingray
cock
hen
ostrich
@steverichey
steverichey / pw
Created November 21, 2018 03:52
Password generation script
#!/bin/sh
set -e
# generate allowed_characters number_of_characters
generate()
{
cat /dev/random | env LC_CTYPE=C tr -cd $1 | head -c $2
}