Skip to content

Instantly share code, notes, and snippets.

@nathggns
nathggns / brainfuck.ts
Created June 7, 2015 04:24
brainfuck in typescript
declare function require(module:string):any;
declare var process:any;
var readline = require('readline');
var fs = require('fs');
type brainfuckDone = (char : string) => void;
type brainfuckInput = (done : brainfuckDone) => void;
function brainfuck(tokens : string[], inp : brainfuckInput) {
@nathggns
nathggns / await.es6.js
Last active August 29, 2015 14:22
Await implemented in ES6.
function await(generatorFunction) {
let gen = generatorFunction();
/**
* @param {any?} err The error to throw in the generator, where yield was last called.
* @param {any?} result The result to pass to the genarator for the last call to yield
*/
function next(err, result) {
// If the last promise that was yielded was rejected,
// trigger an error inside the generator where yield was last called
@CodaFi
CodaFi / Sections.swift
Last active August 29, 2015 14:10
Operator sections for the Swift STL.
/// Sectional Sale
prefix operator >> {}
postfix operator >> {}
public prefix func >>(rhs: UInt16) -> UInt16 -> UInt16 {
return { lhs in lhs >> rhs }
}
public postfix func >>(lhs: UInt16) -> UInt16 -> UInt16 {
@rnapier
rnapier / gist:8eda179689d9d61c2bfb
Last active August 29, 2015 14:04
And autoclosure saves(?) the day for generic recursive enums
// Creating a generic recursive data structure with autoclosure. (READ ALL NOTES; THIS MAY NOT DO WHAT YOU WANT.)
// Closures are reference types, so the size is known (? I think ?)
// Note that this is just because of unimplemented features in the compiler in Beta5
// There's no reason to think this is a long-term requirement.
// IMPORTANT: the closure will run every time you access this value, so if that has
// side effects, this won't work. It's only possible on pure value types.
// But the fact that this works as expected is actually kind of incredible.
// Think about what is required for it to work out the type for NestedList.Elem("first").
@matthiasplappert
matthiasplappert / gist:9493050
Last active August 29, 2015 13:57
QuickLook Debugging for `UIView`
@interface UIView (MPAdditions)
@end
@implementation UIView (MPAdditions)
- (id)debugQuickLookObject {
if (self.bounds.size.width < 0.0f || self.bounds.size.height < 0.0f) {
return nil;
}