This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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)) | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Returning a function here, instead of a fully realized object | |
extension Company: Decodable { | |
static func decode(j: JSON) -> Decoded<[People] -> Company> { | |
return create | |
<^> j <| "id" | |
<*> j <| ["attributes", "name"] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# encoding: utf-8 | |
""" | |
CleanDB.py | |
Created by Gordon on 2010-06-03. | |
Copyright (c) 2010 Gordon Fontenot. All rights reserved. | |
""" | |
import sys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "UIImageManipulator.h" | |
@implementation UIImageManipulator | |
static void addRoundedRectToPath(CGContextRef context, CGRect rect, float ovalWidth, float ovalHeight) | |
{ | |
float fw, fh; | |
if (ovalWidth == 0 || ovalHeight == 0) { | |
CGContextAddRect(context, rect); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ([url isEqualToString:@"http://www.facebook.com/login.php"]) { | |
[cookies setCookie:testCookie]; // Create the test_cookie as required by login.php | |
} else if ([url isEqualToString:@"http://www.facebook.com/connect/prompt_permission.php"]) { | |
NSArray *cookieJar = [cookies cookies]; | |
for (id aCookie in cookieJar) { | |
[cookies deleteCookie:aCookie]; | |
} | |
} |
OlderNewer