Skip to content

Instantly share code, notes, and snippets.

@barretron
barretron / GameScene.swift
Created March 23, 2015 18:57
Swift Closure EXC_BAD_ACCESS
class GameScene: SKScene {
var points: Int = 0
var timeLeft: Int = 60
override func didMoveToView(view: SKView) {
let timerAction = SKAction.resizeToHeight(CGFloat(0), duration: NSTimeInterval(timeLeft))
timeGraphic.runAction(timerAction, completion: self.endGame)
@barretron
barretron / arr_max.coffee
Last active August 29, 2015 14:04
A Python-like implementation of max() using nested arrays in CoffeeScript.
arr_max = (arrlist) ->
# Check to make sure arrlist is an array of arrays, else throw error
throw "Error: argument to arr_max must be an array of arrays" unless arrlist instanceof Array and arrlist[0] instanceof Array
# Set current max to first array element
curr_max = arrlist[0]
# This value will be set every time a larger value is found
# in each level of arr_max_rec
curr_max_val = -Infinity
@barretron
barretron / chatty.coffee
Last active August 29, 2015 14:03 — forked from Twipped/chatty.js
net = require 'net'
clients = []
total = 0
net.createServer (socket) ->
clients.push socket
++total
id = clients.length - 1
name = "User #{total}"
@barretron
barretron / gist:11396531
Last active August 29, 2015 14:00
Possible CS Generator Syntax
koa = require 'koa'
app = koa()
generator firstn
initialize: (limit) ->
num = 0
while num < limit
yield num
num += 1