- Python 3
- Pip 3
$ brew install python3
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) | |
} |
extension Optional where Wrapped: Collection { | |
var isNilOrEmpty: Bool { | |
return self?.isEmpty ?? true | |
} | |
} |
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) | |
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 |
struct Identifier: Hashable { | |
let string: String | |
} | |
extension Identifier: ExpressibleByStringLiteral { | |
init(stringLiteral value: String) { | |
string = value | |
} | |
} |
#!/bin/bash | |
set -o nounset | |
set -o errexit | |
set -o verbose | |
set -o xtrace | |
log() { | |
local prefix="[$(date +%Y/%m/%d\ %H:%M:%S)]:" | |
echo "${prefix} $@" >&2 | |
} |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool | |
{ | |
let timeline = TimelineViewController() | |
let navigation = UINavigationController(rootViewController: timeline) | |
let frame = UIScreen.main.bounds | |
window = UIWindow(frame: frame) | |
window!.rootViewController = navigation | |
window!.makeKeyAndVisible() |
// https://www.vadimbulavin.com/advanced-guide-to-userdefaults-in-swift/ | |
// what is the difference between WWDC2019 https://devstreaming-cdn.apple.com/videos/wwdc/2019/402fd460n3p3w5c/402/402_whats_new_in_swift.pdf | |
// The marker protocol | |
protocol PropertyListValue {} | |
extension Data: PropertyListValue {} | |
extension String: PropertyListValue {} | |
extension Date: PropertyListValue {} | |
extension Bool: PropertyListValue {} | |
extension Int: PropertyListValue {} |