Skip to content

Instantly share code, notes, and snippets.

@n8gray
n8gray / configure-ios
Created Jan 19, 2012
A script to configure autotools software for iOS
View configure-ios
#!/bin/bash
################################################################################
#
# Copyright (c) 2008-2009 Christopher J. Stawarz
#
# Modified by Nathaniel Gray in 2012 to support Clang, custom dev tool locations,
# and armv7. Also removed "make install" phase, since that can easily be done by
# hand.
#
@n8gray
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.
//
@n8gray
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
n8gray / link-simulators.sh
Created Jun 9, 2014
Xcode 6: Make a symlink to each iOS simulator's data directory
View link-simulators.sh
@n8gray
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")
missiles.launch()
} else {
println("Let there be peace on Earth")
kittens.release()
}
@n8gray
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??!?!
-(void)awakeFromNib
{
[super awakeFromNib];
int tag = [self tag];
if (tag > 1000000) {
int residue = tag - (tag / 1000000) * 1000000;
@n8gray
n8gray / remove_sim_dups.py
Last active Aug 29, 2015 — forked from buscarini/remove_sim_dups.py
Remove Xcode duplicated simulators
View remove_sim_dups.py
#!/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
View sample.ml
(* 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
else
begin
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
end
@n8gray
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
#!/bin/sh
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
else
SHA=$1
fi
@n8gray
n8gray / git-details
Last active Oct 26, 2017
Git: Show the details of a commit and all its parents
View git-details
#!/bin/zsh
#
# Shows the raw details of a commit and all its parents
#
if [[ $# < 1 ]]; then
SHA=HEAD
else
SHA=$1