- Python 3
- Pip 3
$ brew install python3
struct Identifier: Hashable { | |
let string: String | |
} | |
extension Identifier: ExpressibleByStringLiteral { | |
init(stringLiteral value: String) { | |
string = value | |
} | |
} |
class Observable<Value> { | |
private var value: Value | |
private var observations = [UUID : (Value) -> Void]() | |
init(value: Value) { | |
self.value = value | |
} | |
func update(with value: Value) { | |
self.value = value |
import UIKit | |
import CoreGraphics | |
extension UIView { | |
func createRoundedRectPath(for rect: CGRect, radius: CGFloat) -> CGMutablePath { | |
let path = CGMutablePath() | |
let midTopPoint = CGPoint(x: rect.midX, y: rect.minY) | |
path.move(to: midTopPoint) | |
extension Optional where Wrapped: Collection { | |
var isNilOrEmpty: Bool { | |
return self?.isEmpty ?? true | |
} | |
} |
import QuartzCore | |
public extension CGRect { | |
public init(centre: CGPoint, size: CGSize) { | |
self.init(origin: centre.applying(CGAffineTransform(translationX: size.width / -2, y: size.height / -2)), size: size) | |
} | |
public var centre: CGPoint { | |
return CGPoint(x: midX, y: midY) | |
} |
public extension CGSize { | |
public func rescale(_ scale: CGFloat) -> CGSize { | |
return applying(CGAffineTransform(scaleX: scale, y: scale)) | |
} | |
} |
public extension Collection { | |
/// Returns the element at the specified index if it is within bounds, otherwise nil. | |
subscript (safe index: Index) -> Element? { | |
return indices.contains(index) ? self[index] : nil | |
} | |
} |
import Foundation | |
/// An abstract class that makes building simple asynchronous operations easy. | |
/// Subclasses must implement `execute()` to perform any work and call | |
/// `finish()` when they are done. All `NSOperation` work will be handled | |
/// automatically. | |
open class AsynchronousOperation: Operation { | |
// MARK: - Properties |