Skip to content

Instantly share code, notes, and snippets.

View coryalder's full-sized avatar

Cory Alder coryalder

View GitHub Profile
<table>
<tr><td>hi</td><td>hello</td></tr>
<tr><td>howdy</td><td>hi hi</td></tr>
<tr><td>bye</td><td>goodbye</td></tr>
</table>
@coryalder
coryalder / .bash_profile
Created May 20, 2013 02:01
wopen, an Xcode project/workspace opening script
function wopen { # via https://gist.github.com/coryalder/5609996
WORKSPACE="${PWD##*/}.xcworkspace"
PROJECT="${PWD##*/}.xcodeproj"
if [ -a $WORKSPACE ]; then
open $WORKSPACE;
elif [ -a $PROJECT ]; then
open $PROJECT;
else
echo "No workspace or project found.";
fi
@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 / AmazonProduct.swift
Last active October 23, 2019 08:47
Amazon Product Advertising API + Alamofire
//
// AmazonProduct.swift
// Requires SHXMLParser for parsing Amazon's XML responses (https://github.com/simhanature/SHXMLParser)
//
// Created by Cory Alder on 2015-01-11.
// Copyright (c) 2015 Davander Mobile Corporation. All rights reserved.
//
// partly inspired by RWMAmazonProductAdvertisingManager
import Alamofire
@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!
@coryalder
coryalder / UIImage+Invert.swift
Created March 12, 2015 05:42
Invert a UIImage at runtime using Core Image CIFilter + CIContext
extension UIImage {
func invertedImage() -> UIImage? {
let img = CoreImage.CIImage(CGImage: self.CGImage)
let filter = CIFilter(name: "CIColorInvert")
filter.setDefaults()
filter.setValue(img, forKey: "inputImage")
// 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.