Skip to content

Instantly share code, notes, and snippets.

View SiarheiFedartsou's full-sized avatar

Siarhei Fedartsou SiarheiFedartsou

View GitHub Profile
final class Job<R, E: Error> {
private let semaphore = DispatchSemaphore(value: 0)
var result: Result<R, E>? {
didSet {
semaphore.signal()
}
}
func await() throws -> R {
semaphore.wait()
//: Playground - noun: a place where people can play
import UIKit
protocol StageProtocol {
associatedtype StageIn
associatedtype StageOut
}
class Stage<In, Out> : StageProtocol {
let presenter = Presenter(router: dummy())
func dummy<T>() -> T {
let memory = UnsafeMutablePointer<T>.allocate(capacity: 1)
let dummy = memory.pointee
memory.deallocate(capacity: 1)
return dummy
}
func testThatPresenterCallsShowUserNameOnVisualizerOnStart() {
class MockVisualizer : Visualizer {
var userName: String? = nil
func show(userName: String) {
self.userName = userName
}
}
let presenter = Presenter(router: Router(navigationController: UINavigationController()))
protocol Visualizer : class {
func show(userName: String)
}
struct Router {
let navigationController: UINavigationController
func moveToAnotherScreen() {
}
protocol Visualizer : class {
func show(userName: String)
}
struct Router {
let navigationController: UINavigationController
func moveToAnotherScreen() {
// ...
}
HTTP/1.1 200 OK
Server: nginx
Date: Mon, 16 Jan 2017 09:38:31 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Cache-Control: no-cache, must-revalidate
POST /classic/registration/verify HTTP/1.1
Host: dev2.mobitee.com
X-DATE: 2017-01-16 09:25:42 +0000
Accept: */*
X-AUTH: 1661:bdef2231db58c43236bd906dcb9f805f
Accept-Language: en-US;q=1.0, fr-US;q=0.9, it-US;q=0.8, es-US;q=0.7, de-US;q=0.6, en;q=0.5
Accept-Encoding: gzip;q=1.0, compress;q=0.5
Content-Type: application/x-www-form-urlencoded; charset=utf-8
Content-Length: 52
User-Agent: Mobitee Classic/4.0 (com.blrsoft.appname; build:1; iOS 10.1.0) Alamofire/4.2.0
POST //classic/auth/verify HTTP/1.1
Host: dev2.mobitee.com
X-DATE: 2017-01-16 09:17:16 +0000
Accept: */*
X-AUTH: 1661:c8e4f06953f7d1ba450ccca49fd1e1f2
Accept-Language: en-US;q=1.0, fr-US;q=0.9, it-US;q=0.8, es-US;q=0.7, de-US;q=0.6, en;q=0.5
Accept-Encoding: gzip;q=1.0, compress;q=0.5
Content-Type: application/x-www-form-urlencoded; charset=utf-8
Content-Length: 52
User-Agent: Mobitee Classic/4.0 (com.blrsoft.appname; build:1; iOS 10.1.0) Alamofire/4.2.0