This file contains hidden or 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
// | |
// main.m | |
// 12DaysOfChristmas | |
// | |
// Created by Varindra Hart on 6/4/15. | |
// Copyright (c) 2015 Varindra Hart. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> |
This file contains hidden or 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
// | |
// main.m | |
// variable2 | |
// | |
// Created by Varindra Hart on 6/4/15. | |
// Copyright (c) 2015 Varindra Hart. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> |
This file contains hidden or 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 UIColor { | |
convenience init? (fromHex hex: String) { | |
let hexPattern = try! NSRegularExpression(pattern: "^[0-9a-fA-F]{6}$", | |
options: [.anchorsMatchLines]) | |
let range = NSRange(location: 0, length: hex.characters.count) | |
guard hexPattern.matches(in: hex, | |
options: [], | |
range: range).count == 1 | |
else { return nil } |
This file contains hidden or 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
protocol Drivable { | |
func drive() | |
var numberOfWheels: Int { get } | |
} | |
func startTraveling(with transportation: Drivable) { } | |
func startTraveling<D: Drivable>(with transportation: D) { } | |
This file contains hidden or 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
struct Car: Drivable { | |
let numberOfWheels = 4 | |
func drive() { } | |
} | |
struct Motorcycle: Drivable { | |
let numberOfWheels = 2 | |
let licensePlate = "asdf123" |
This file contains hidden or 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 UIKit | |
import Foundation | |
struct StringLayoutHandler { | |
enum SerializationTokens: String { | |
case tab = "T" | |
case newline = "N" | |
var token: String { return "#" + rawValue } |
This file contains hidden or 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 BasicLogger: NSObject { | |
private static let queue = dispatch_queue_create("com.vhart.BasicLoggerQueue", DISPATCH_QUEUE_SERIAL) | |
private static let dateFormatter = NSDateFormatter() | |
static var filePath: String { | |
return fileUrl.path! | |
} | |
static var fileUrl: NSURL { |
This file contains hidden or 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
/* | |
from console. `po NSHomeDirectory()` | |
from terminal cd to that path | |
cd into Documents | |
LogFile.txt should be there | |
To see content update live run tail -F LogFile.txt | |
*/ | |
public class BasicLogger: NSObject { |
This file contains hidden or 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
enum Result<T, E: Error> { | |
case success(T) | |
case failure(E) | |
} | |
enum NetworkError: Error { | |
case invalidJson | |
case badRequest | |
case timeout | |
} |
This file contains hidden or 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 DeserializerBox<D: JsonDeserializer> { | |
let deserializer: D | |
init(deserializer: D) { | |
self.deserializer = deserializer | |
} | |
} | |
class Session<P>: NetworkSession { | |
typealias Payload = P |
OlderNewer