Skip to content

Instantly share code, notes, and snippets.

Avatar

Steve steverichey

View GitHub Profile
@steverichey
steverichey / delete_git_submodule.md
Last active May 28, 2020 — forked from myusuf3/delete_git_submodule.md
How to effectively delete a git submodule.
View delete_git_submodule.md

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
A C# class to call a method when the object goes out of scope.
View PerformOnExit.cs
/// <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
A Swift playground for the beginning of the book, The Little Typer
View LittleTyper.swift
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 Oct 25, 2019
Simple password generator, version 2
View pw
#!/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 Mar 29, 2019
Just the ImageNet labels used by ResNet.
View imagenet_labels.txt
tench
goldfish
great_white_shark
tiger_shark
hammerhead
electric_ray
stingray
cock
hen
ostrich
@steverichey
steverichey / pw
Created Nov 21, 2018
Password generation script
View pw
#!/bin/sh
set -e
# generate allowed_characters number_of_characters
generate()
{
cat /dev/random | env LC_CTYPE=C tr -cd $1 | head -c $2
}
@steverichey
steverichey / xoshiroPRNG.swift
Created Nov 21, 2018
Not thoroughly tested, needs update for some Random changes in Swift
View xoshiroPRNG.swift
import Foundation
// http://xoshiro.di.unimi.it/xoshiro256starstar.c
protocol PseudoRandomNumberGenerator {
associatedtype ReturnValue
mutating func next() -> ReturnValue
}
struct Arc4Random: PseudoRandomNumberGenerator {
View genie.swift
//: Playground - noun: a place where people can play
import Cocoa
let caseLookup: [Character: Character] = [
"a": "A", "b": "B", "c": "C", "d": "D", "e": "E", "f": "F", "g": "G", "h": "H", "i": "I", "j": "J", "k": "K", "l": "L", "m": "M", "n": "N",
"o": "O", "p": "P", "q": "Q", "r": "R", "s": "S", "t": "T", "u": "U", "v": "V", "w": "W", "x": "X", "y": "Y", "z": "Z"
]
extension Dictionary where Value: Equatable {
@steverichey
steverichey / allow_ios_firewall.sh
Created Jul 30, 2018
In theory, allows the iOS simulator to bypass the firewall. May no longer be needed, or it works so well I no longer get the dialog prompt.
View allow_ios_firewall.sh
#!/bin/sh
# requires sudo
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate off
/usr/libexec/ApplicationFirewall/socketfilterfw --add /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on
@steverichey
steverichey / gifopt.sh
Created Jul 13, 2018
GIF creation with some optimization options
View gifopt.sh
#!/bin/sh
# this was created for an admittedly specialized purpose but has some neat settings i want to remember
palette="/tmp/palette.png"
cropped="/tmp/cropped.mp4"
width="275"
filters="fps=15,scale=${width}:-1:flags=lanczos"
You can’t perform that action at this time.