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 | |
| /// One-parameter currying from two arguments function | |
| typealias EscapingClosure<A, B> = (A) -> B | |
| func curry<A, B, C>(_ f: @escaping (A, B) -> C) -> EscapingClosure<A, (B) -> C> { | |
| return { (a: A) -> ((_ b: B) -> C) in | |
| return { (b: B) -> C in f(a, b) } | |
| } | |
| } |
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 | |
| public protocol EnumerableEnum: RawRepresentable where RawValue == Int { | |
| static var firstIndex: Int { get } | |
| } | |
| public extension EnumerableEnum { |
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 | |
| @IBDesignable | |
| class UIRoundedImageView: UIImageView { | |
| @IBInspectable var isRoundedCorners: Bool = false { | |
| didSet { setNeedsLayout() } | |
| } | |
| override func layoutSubviews() { |
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 | |
| extension UIColor { | |
| convenience public init(hexRGB: CUnsignedLongLong) { | |
| let red: CGFloat = CGFloat((hexRGB & 0xFF0000) >> 16) / CGFloat(255) | |
| let green: CGFloat = CGFloat((hexRGB & 0xFF00) >> 8) / CGFloat(255) | |
| let blue: CGFloat = CGFloat(hexRGB & 0xFF) / CGFloat(255) | |
| self.init(red:red, green:green, blue:blue, alpha:1.0) |
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 | |
| import PromiseKit | |
| // MARK: - URLSession Data Promise | |
| extension URLSession { | |
| func dataPromise(with request: URLRequest) -> Promise<Data> { | |
| return Promise { resolver in | |
| let dataTask = self.dataTask(with: request) { (data, response, error) 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
| import UIKit | |
| import CoreBluetooth | |
| enum BluetoothState: CustomStringConvertible { | |
| case off, on, unknown | |
| init(bluetoothState: CBManagerState) { | |
| switch bluetoothState { | |
| case .poweredOff: self = .off | |
| case .poweredOn: self = .on |
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
| // - Playgorund code here | |
| // - This code generates all (private/public) method titles which stored within EAAccessoryManager class | |
| import Foundation | |
| import ExternalAccessory | |
| import PlaygroundSupport | |
| PlaygroundPage.current.needsIndefiniteExecution = true | |
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 Cocoa | |
| extension Array where Element: Equatable { | |
| mutating func remove(_ element: Element) { | |
| if let index = self.index(of: element) { | |
| self.remove(at: index) | |
| } | |
| } | |
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
| #include<iostream> | |
| #include<fstream> | |
| #include<sstream> | |
| #include<streambuf> | |
| #include<cstdlib> | |
| #include<string> | |
| #include<vector> | |
| using std::string; |
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: Model | |
| protocol ModelType { | |
| init(value: Int) | |
| } | |
| class Model: ModelType { | |
| var value: Int |