Skip to content

Instantly share code, notes, and snippets.

View dscherger's full-sized avatar

Derek Scherger dscherger

View GitHub Profile
@ciphergoth
ciphergoth / selbyshuf.py
Last active March 15, 2019 05:38
Alex Selby's trick for iterating over all permutations of an array
#!/usr/bin/env python3
# Selby Shuffle
# The mathematician Alex Selby showed me this wonderful way to iterate over all
# permutations of an array in SJT order. It is so much cleaner and more concise
# than any other way of doing this I've seen online - while being perfectly
# efficient - that I had to share it.
# https://en.wikipedia.org/wiki/Steinhaus%E2%80%93Johnson%E2%80%93Trotter_algorithm
# Alex: https://gist.github.com/alex1770/eeef97869441912d6ca1b80b082a7297#file-gent-cpp-L31
@ryao
ryao / enter-container.sh
Last active February 3, 2016 04:57
A script to simplify entering a "chroot"-style container in the Gentoo install process
#!/bin/sh
HOSTNAME=
BIND=
SHELL=bash
while getopts "b:h:s:" opt; do
case $opt in
b)
BIND="${BIND} ${OPTARG}"