Skip to content

Instantly share code, notes, and snippets.

View coryalder's full-sized avatar

Cory Alder coryalder

View GitHub Profile
@coryalder
coryalder / keybase proof
Created March 7, 2014 21:46
keybase proof
### Keybase proof
I hereby claim:
* I am coryalder on github.
* I am ca (https://keybase.io/ca) on keybase.
* I have a public key whose fingerprint is ADB2 34A2 549E BC4B 4EB5 0276 819C 75BF 9A12 6635
To claim this, I am signing this object:
@coryalder
coryalder / gist:b5405b9abac79013c791
Last active August 29, 2015 14:12
Solving Protocol issue using an abstract class
// Playground - noun: a place where people can play
import UIKit
class MyItem { /* some model properties */ }
protocol ItemViewProtocol: class {
// some protocol methods (e.g. updateWithItem(), etc)
func setupItem(item: MyItem)
init(String)
@coryalder
coryalder / gist:0ca6c03fdf29b55498cb
Created January 15, 2015 03:13
adventure game psuedocode
row1 = 0,0 1,0 2,0 3,0
row2 = 0,1 1,1 2,1 3,1
row3 = 0,2 1,2 2,2 3,2
char str[100];
fgets (str, 100, stdin);
NSString *inputString = [[NSString alloc] initWithUTF8String:str];
inputString = [inputString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSLog(@"Input was %@", inputString);
func traverse(keyPath: [String], dict: Dictionary<String, AnyObject>?) -> AnyObject? {
if dict == nil {
return nil
}
var paths = keyPath
let next = paths.first!
// What's the best syntax for this:
// no trailing-closures
// explicit about what's happening, but those ()'s aren't needed... can we do better?
throwActions.filter({ $0.direction == dir }).map({ $0.action() })
// all trailing closures
// weirdly looks like we're mapping the block, rather than the result of filtering throwActions using that block.
-(void)viewDidAppear:(BOOL)animated {
UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:(CGRect){-50,-50,100,100}];
// 0, 0 is center
CAShapeLayer *shapeLayer = [[CAShapeLayer alloc] init];
@coryalder
coryalder / IntroToSwift.swift
Created July 20, 2015 16:47
a quick intro to some of the language features of swift
//: Playground - noun: a place where people can play
import Cocoa
// basic strings
var str: String = "Hello,"
let helloWorld = str + " world"
@coryalder
coryalder / protocol_id.m
Created July 31, 2015 21:49
id and protocol conformance
// when specify id as the type, you can use NSObject methods.
// when you specify as a custom protocol, you cannot.
// UNLESS you say that your custom protocol includes <NSObject>
#import <Foundation/Foundation.h>
@protocol CustomProtocol // <NSObject> // uncommenting <NSObject> fixes the issue
@end
// extends http://johnehartzog.com/2009/10/easy-to-create-buttons-with-cocos2d/
// give you a button that toggles between two images
// uses cocos2d 0.9, so all the classes are called CCMenuItem instead of MenuItem.
// other than that it should work with older versions of cocos2d
+ (id)buttonWithImage:(NSString*)file
andImage:(NSString *)otherFile
atPosition:(CGPoint)position
target:(id)target
selector:(SEL)selector