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
class DependencyContainer { | |
static let shared = DependencyContainer() | |
private var types: [String: Any] = [:] | |
func registerType<T: Any>(_ type: T.Type, named name: String? = nil, creator: @escaping (String) -> T) { | |
let key = name ?? String(describing: type) | |
types[key] = creator | |
} |
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 | |
public protocol Observable: class { | |
associatedtype ObservableTarget = AnyObject | |
func add(observer: ObservableTarget) | |
func remove(observer: ObservableTarget) | |
func dispatch(_ handler: (ObservableTarget) -> ()) | |
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 ReSwift | |
public protocol MiddlewareProcessor { | |
typealias GetStateFunction = () -> Any? | |
func preprocess(dispatch: DispatchFunction, action: Action, getState: GetStateFunction) | |
func postprocess(dispatch: DispatchFunction, action: Action, getState: GetStateFunction) | |
} | |
public extension MiddlewareProcessor { | |
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 XCTest | |
struct SampleCodable: Codable { | |
let sampleVariable1: String | |
let sampleVariable2: String | |
let cAPPEDVariable3: String | |
let sample: String | |
} | |
class PascalJSONCoding: XCTestCase { |
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
extension Sequence { | |
func walk(_ childSelector: (Element) -> [Element], handler: (Element) -> Void) { | |
for item in self { | |
handler(item) | |
let children = childSelector(item) | |
if children.count > 0 { | |
children.walk(childSelector, handler: handler) | |
} | |
} |
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
extension Sequence { | |
func recursiveFlatten(_ childSelector: (Element) -> [Element]) -> [Element] { | |
var output: [Element] = [] | |
for item in self { | |
output.append(item) | |
let newItems = childSelector(item) | |
if newItems.count > 0 { | |
output += newItems.recursiveFlatten(childSelector) | |
} |
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 | |
extension UIApplication { | |
var build: String { | |
return NSBundle.mainBundle().infoDictionary!["CFBundleVersion"] as! String | |
} | |
var version: String { | |
return NSBundle.mainBundle().infoDictionary!["CFBundleShortVersionString"] as! 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
#!/usr/bin/python | |
import os | |
import argparse | |
import xlrd | |
import json | |
def create_json_object(args): | |
workbook = xlrd.open_workbook(args.input) | |
sheet = workbook.sheet_by_index(0) | |
json_array = [] |
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/Foundation.h> | |
@interface NSURLRequestFileInfo : NSObject | |
@property NSData *data; | |
@property NSString *name; | |
@property NSString *key; | |
+ (NSURLRequestFileInfo *)fileInfoWithData:(NSData *)data key:(NSString *)key andName:(NSString *)name; | |
@end | |
@interface NSURLRequest (FileAdditions) |
NewerOlder