One Paragraph of project description goes here
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
| /** Throttle wraps a block with throttling logic, guarantueeing that the block will never be called (by enquueing | |
| asynchronously on `queue`) more than once each `interval` seconds. If the wrapper callback is called more than once | |
| in an interval, it will use the most recent call's parameters when eventually calling the wrapped block (after `interval` | |
| has elapsed since the last call to the wrapped function) - i.e. calls are not queued and may get 'lost' by being superseded | |
| by a newer call. */ | |
| public func throttle<P>(interval: TimeInterval, queue: DispatchQueue, _ block: ((P) -> ())) -> ((P) -> ()) { | |
| var lastExecutionTime: TimeInterval? = nil | |
| var scheduledExecutionParameters: P? = nil | |
| let mutex = Mutex() |
| // Associated wrapper by WeZZard : https://wezzard.com/2015/10/09/associated-object-and-swift-struct/ | |
| // Type safe helpers inspired by Tikitu de Jager : https://medium.com/@ttikitu/swift-extensions-can-add-stored-properties-92db66bce6cd#.mx6ekrw16 | |
| public final class AssociatedStruct<T>: NSObject, NSCopying { | |
| public typealias Type = T | |
| public let value: Type | |
| public init(_ value: Type) { self.value = value } | |
| i386 : iPhone Simulator | |
| x86_64 : iPhone Simulator | |
| iPhone1,1 : iPhone | |
| iPhone1,2 : iPhone 3G | |
| iPhone2,1 : iPhone 3GS | |
| iPhone3,1 : iPhone 4 | |
| iPhone3,2 : iPhone 4 GSM Rev A | |
| iPhone3,3 : iPhone 4 CDMA | |
| iPhone4,1 : iPhone 4S | |
| iPhone5,1 : iPhone 5 (GSM) |
| // https://stackoverflow.com/a/45777692/5536516 | |
| import Foundation | |
| struct MemoryAddress<T>: CustomStringConvertible { | |
| let intValue: Int | |
| var description: String { | |
| let length = 2 + 2 * MemoryLayout<UnsafeRawPointer>.size |
| exec > /tmp/${PROJECT_NAME}_archive.log 2>&1 | |
| UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal | |
| if [ "true" == ${ALREADYINVOKED:-false} ] | |
| then | |
| echo "RECURSION: Detected, stopping" | |
| else | |
| export ALREADYINVOKED="true" |
| NSURLConnection | NSURLSession | |
| ------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------- | |
| NSURLConnectionDelegate connectionShouldUseCredentialStorage: | | |
| ------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------- | |
| NSURLConnectionDelegate connection:willSendRequestForAuthenticationChallenge: | NSURLSessionDelegate URLSession:didReceiveChallenge:completionHandler: | |
| | N |
| // MyURLStreamTask.swift | |
| // Demonstrates using an NSURLSessionStreamTask to implement a bidirectional TCP socket connection | |
| // | |
| // by [email protected] 2017-03-07 | |
| // distribution: BSD 2-clause | |
| // | |
| import Foundation | |
| class MyURLStreamTask { |
| // Example: view.round([.TopLeft, .TopRight], radius: 15) | |
| extension UIView { | |
| /** | |
| Rounds the given set of corners to the specified radius | |
| - parameter corners: Corners to round | |
| - parameter radius: Radius to round to | |
| */ | |
| func round(corners: UIRectCorner, radius: CGFloat) { |
| import UIKit | |
| extension UIImage { | |
| subscript (x: Int, y: Int) -> UIColor? { | |
| if x < 0 || x > Int(size.width) || y < 0 || y > Int(size.height) { | |
| return nil | |
| } |