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
| // The MIT License (MIT) | |
| // | |
| // Copyright (c) 2016 Alexander Grebenyuk (github.com/kean). | |
| import Foundation | |
| public class Promise<T> { | |
| private var state: State<T> = .pending(Handlers<T>()) | |
| private var queue = DispatchQueue(label: "com.github.kean.Promise") | |
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
| fastlane_version "1.99.0" | |
| REQUIRED_XCODE_VERSION = "7.3.1" | |
| default_platform :ios | |
| platform :ios do | |
| before_all do |lane, options| | |
| ENV["SLACK_URL"] = "https://hooks.slack.com/services/???" | |
| end |
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
| //: Playground - noun: a place where people can play | |
| import Cocoa | |
| // I’m trying to figure out how to add a Notification observer in Swift code where the notification name is defined in a .m file. | |
| // | |
| // This playground won’t actually run, because it assumes an NSString named SomeNotification defined in a .m file. So it can’t actually be used to see the errors. It’s just for illustration. | |
| // The errors are listed in the comments. | |
| class MyClass { |
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
| public struct Promise<T> { | |
| typealias Fulfiller = (T) -> (Void) | |
| typealias Rejecter = (Void) -> (Void) | |
| typealias Resolver = (_ fulfill: @escaping Fulfiller, _ reject: @escaping Rejecter) -> (Void) | |
| let resolver: Resolver | |
| init(_ resolver: @escaping Resolver){ | |
| self.resolver = resolver | |
| } | |
| func then<U>(_ execute: @escaping ((T) -> U)) -> Promise<U> { | |
| return Promise<U>({(fulfill, reject) in |
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
| // | |
| // SpinlockTestTests.swift | |
| // SpinlockTestTests | |
| // | |
| // Created by Peter Steinberger on 04/10/2016. | |
| // Copyright © 2016 PSPDFKit GmbH. All rights reserved. | |
| // | |
| import XCTest |
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 Foundation | |
| // | |
| // MARK:- Private | |
| // | |
| class MyAwesomeLogger { | |
| static func log(message: String) { | |
| print(message) | |
| } |
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
| // | |
| // Operators.swift | |
| // FastParsing | |
| // | |
| // Created by Chris Eidhof on 26/12/2016. | |
| // Copyright © 2016 objc.io. All rights reserved. | |
| // | |
| // TODO: give appropriate credit. Many parts were stolen from SwiftParsec. |
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
| // For https://twitter.com/nicklockwood/status/819938181483233285 | |
| protocol Withable { | |
| init() | |
| } | |
| extension Withable { | |
| func with(_ body: (inout Self) -> ()) -> Self { | |
| var copy = self | |
| body(©) |
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
| /** | |
| * Perform a throwing expression, and throw a custom error in case the expression threw | |
| * | |
| * - parameter expression: The expression to execute | |
| * - parameter error: The custom error to throw instead of the expression's error | |
| * - throws: The given error | |
| * - returns: The return value of the given expression | |
| */ | |
| func perform<T>(_ expression: @autoclosure () throws -> T, orThrow errorExpression: @autoclosure () -> Error) throws -> T { | |
| do { |
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
| # So there should be run script which will pass | |
| #./timecheck.py start | |
| #./timecheck.py stop | |
| #!/usr/bin/python | |
| import json,httplib,sys,time,os | |
| from os.path import expanduser | |
| seconds = int(round(time.time())) |