Skip to content

Instantly share code, notes, and snippets.

View kaqu's full-sized avatar

Kacper kaqu

View GitHub Profile
@kaqu
kaqu / Future.swift
Last active March 9, 2019 18:34
PasteIn Future implementation
#if os(Linux)
import Glibc
#else
import Darwin
#endif
public final class Future<Value> {
public typealias Handler = (Value) -> Void
public typealias Executor = (@escaping () -> Void) -> Void
@kaqu
kaqu / RawHTTP.swift
Created January 26, 2019 17:20
Swift HTTP over Network framework
import Network
let host: NWEndpoint.Host = .init("httpbin.org")
let port: NWEndpoint.Port = .https
let tlsConfig: NWProtocolTLS.Options = .init()
let parameters: NWParameters = .init(tls: tlsConfig)
let connection: NWConnection = .init(host: host, port: port, using: parameters)
connection.stateUpdateHandler = { state in
print("State Update: \(state)")
}
protocol Buildable {
init(dict: [AnyKeyPath: Any]) throws
}
struct BuilderError : Error {
let reason: String
}
struct SomeBuildable : Buildable {
let field1: String