Skip to content

Instantly share code, notes, and snippets.

View gfontenot's full-sized avatar
football

Gordon Fontenot gfontenot

football
View GitHub Profile
SpecBegin(TTUser)
describe(@"TTUser", ^{
__block TTUser *user;
__block NSDictionary *userDict;
before(^{
userDict = @{ @"name" : @"Hormell Ansley", @"email" : @"[email protected]", @"id" : @1 };
});
2013-10-02 19:48:30.386 collection[8782:70b] Cell center.y: 1610.000000
2013-10-02 19:48:30.386 collection[8782:70b] ScrollView center.y: 284.000000
2013-10-02 19:48:30.387 collection[8782:70b] fucking math: 1326.000000
2013-10-02 19:48:30.387 collection[8782:70b] Cell center.y: 1280.000000
2013-10-02 19:48:30.387 collection[8782:70b] ScrollView center.y: 284.000000
2013-10-02 19:48:30.388 collection[8782:70b] fucking math: 996.000000
2013-10-02 19:48:30.388 collection[8782:70b] Cell center.y: 1500.000000
2013-10-02 19:48:30.388 collection[8782:70b] ScrollView center.y: 284.000000
2013-10-02 19:48:30.388 collection[8782:70b] fucking math: 1216.000000
2013-10-02 19:48:30.389 collection[8782:70b] Cell center.y: 1170.000000
- (NSMapTable *)stringMap
{
NSMapTable _map = [[NSMapTable alloc] init]
[_map setObject:@"some string" forKey:@(MyLoginAction0)];
[_map setObject:@"some other string" forKey:@(MyLoginAction1)];
[_map setObject:@"some final string" forKey:@(MyLoginAction3)];
return _map
}
textLabel.text = [self stringMap][@(self.postLoginAction)]
@gfontenot
gfontenot / 0_reuse_code.js
Created January 30, 2014 00:53
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
### Keybase proof
I hereby claim:
* I am gfontenot on github.
* I am gfontenot (https://keybase.io/gfontenot) on keybase.
* I have a public key whose fingerprint is FC96 877D E91A C0B4 381D D33A 0BF4 A6C7 2DA8 F9CE
To claim this, I am signing this object:
import Foundation
class DispatchGroup {
private var blocks: [dispatch_block_t] = []
private let dispatch_queue = dispatch_queue_create("com.dispatch_group.foo", DISPATCH_QUEUE_CONCURRENT)
private let dispatch_group = dispatch_group_create()
func andThen(block: dispatch_block_t) -> Group {
blocks += [block]
return self
import Foundation
infix operator >>- { associativity left precedence 150 }
public func >>-<T, U>(a: T?, f: T -> U?) -> U? {
return a.flatMap(f)
}
extension Optional {
func flatMap<U>(f: T -> U?) -> U? {
switch self {
@gfontenot
gfontenot / decodeDict.swift
Created February 19, 2015 15:38
example of decoding dictionary objects with Argo/FP
import Argo
import Runes
func +<T, V>(lhs: [T: V], rhs: [T: V]) -> [T: V] {
var dict = lhs
for (key, val) in rhs {
dict[key] = val
}
return dict
// Original implementation with multiple returns:
class func fromId(id: String) -> Office? {
let officesData = JSONData.load("offices") as? [[String: String]] ?? []
let officeData = officesData.filter { $0["id"] == id }.first
if let office = officeData {
return decode(JSONValue.parse(office))
}
// stored property, no default value
let foo: String
// stored property, default value
let foo: String = "foo"
// or
let foo = "foo"
// computed property, no custom setter
var foo: String {