Skip to content

Instantly share code, notes, and snippets.

n8gray /
Created Jun 29, 2020
Delete branches that have been merged to the branch of your choice. Works with regular merges and squash merges.
set -eo pipefail
if [[ $1 == "-d" ]]; then
n8gray / git-details
Last active Oct 26, 2017
Git: Show the details of a commit and all its parents
View git-details
# Shows the raw details of a commit and all its parents
if [[ $# < 1 ]]; then
n8gray / git-submodule-of-commit
Created Sep 19, 2016
Shows a list of submodules that exist at the given commit, along with their corresponding submodule commits.
View git-submodule-of-commit
if [[ $# != 1 ]]; then
echo "usage: $0 SHA"
echo " Shows a list of submodules that exist at the given commit, along with their corresponding"
echo " submodule commits."
exit 1
(* This is the original function. It works fine, but makes extra calls to check_left and check_right. *)
let sorting_hat id =
if not (base_case id) then Dead
if check_left id && check_right id then Central
else if check_left id then Left
else if check_right id then Right
else Dead
n8gray /
Last active Aug 29, 2015 — forked from buscarini/
Remove Xcode duplicated simulators
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
from subprocess import Popen, PIPE
from subprocess import call
# Change this to True to see what will be deleted without deleting anything
DRY_RUN = False
n8gray / hahahaha.m
Created Jun 25, 2014
No Jerry, I'm not fucking with you
View hahahaha.m
// At some point I thought this was very clever
// Six months later I was like, why the hell is the tag on this view 1008017??!?!
[super awakeFromNib];
int tag = [self tag];
if (tag > 1000000) {
int residue = tag - (tag / 1000000) * 1000000;
n8gray / OptionalFail.swift
Created Jun 18, 2014
This is why Optionals should not be allowed in if statement tests
View OptionalFail.swift
val shouldLaunchMissiles : Bool? = false
// A million lines later, programmer forgets that shouldLaunchMissiles is an optional
if shouldLaunchMissiles {
println("The only way to win is not to play")
} else {
println("Let there be peace on Earth")
n8gray /
Created Jun 9, 2014
Xcode 6: Make a symlink to each iOS simulator's data directory
n8gray / MonadTest.swift
Last active Aug 29, 2015
Demonstrates using a cell to work around Swift compiler limitations.
View MonadTest.swift
It appears that the Swift code generator requires fixed layout in a lot of contexts
where one might reasonably desire to use generics. Trying to do so gets you a
lovely error of this sort:
LLVM ERROR: unimplemented IRGen feature! non-fixed multi-payload enum layout
This is my hacky solution to that problem. I use a cell to encapsulate the generic
as a fixed-layout value. I've provided a prefix * operator to retrieve the value
(how retro!) in order to minimize the syntactic overhead of using the cell class.
n8gray / ArrayTest.swift
Created Jun 7, 2014
Testing Swift array variance
View ArrayTest.swift
// ArrayTest.swift
// SwiftTest
// Swift array subtyping semantics test
// Created by Nathan Gray on 6/7/14.
// Copyright (c) 2014 Mellmo. All rights reserved.