- A = [xA, yA] is a point on the 2D plane. Same for B, C, ...
- lengths are in any unit (ex: pixels)
- code snippets are in JavaScript
angleRad = angleDeg * Math.PI / 180;
| codecov: | |
| token: uuid # Your private repository token | |
| url: "http" # for Codecov Enterprise customers | |
| slug: "owner/repo" # for Codecov Enterprise customers | |
| branch: master # override the default branch | |
| bot: username # set user whom will be the consumer of oauth requests | |
| ci: # Custom CI domains if Codecov does not identify them automatically | |
| - ci.domain.com | |
| - !provider # ignore these providers when checking if CI passed | |
| # ex. You may test on Travis, Circle, and AppVeyor, but only need |
| import WatchConnectivity | |
| class WatchSessionManager: NSObject, WCSessionDelegate { | |
| static let sharedManager = WatchSessionManager() | |
| private override init() { | |
| super.init() | |
| } | |
| private let session: WCSession? = WCSession.isSupported() ? WCSession.default : nil |
| // | |
| // NotificationCenter+ObserveOnce.swift | |
| // | |
| // Created by Felix Mau on 18.10.20. | |
| // Copyright © 2020 Felix Mau. All rights reserved. | |
| // | |
| import UIKit | |
| extension NotificationCenter { |
| // | |
| // Redux.playground | |
| // | |
| // Created by Felix Mau on 25.06.20. | |
| // Copyright © 2020 Felix Mau. All rights reserved. | |
| // | |
| import PlaygroundSupport | |
| import Combine | |
| import SwiftUI |
| // Adapted from Stack Overflow answer by David Crow http://stackoverflow.com/a/43235 | |
| // Question: Algorithm to randomly generate an aesthetically-pleasing color palette by Brian Gianforcaro | |
| // Method randomly generates a pastel color, and optionally mixes it with another color | |
| func generateRandomPastelColor(withMixedColor mixColor: UIColor?) -> UIColor { | |
| // Randomly generate number in closure | |
| let randomColorGenerator = { ()-> CGFloat in | |
| CGFloat(arc4random() % 256 ) / 256 | |
| } | |
| var red: CGFloat = randomColorGenerator() |
| /// This heavily based on the work done at RxGRDB | |
| import GRDB | |
| import ReactiveSwift | |
| extension DatabasePool: ReactiveExtensionsProvider {} | |
| extension DatabaseQueue: ReactiveExtensionsProvider {} | |
| extension ValueObservation: ReactiveExtensionsProvider {} | |
| extension DatabaseRegionObservation: ReactiveExtensionsProvider {} |
| extension Collection { | |
| /// Returns an array of subsequences of maximum size `chunkSize`. | |
| /// | |
| /// For example: | |
| /// | |
| /// // ["ABCD", "EFGH", "IJ"] | |
| /// "ABCDEFGHIJ".split(chunkSize: 4) | |
| /// | |
| /// - parameter chunkSize: the maximum size of the returned subsequences. | |
| /// - precondition: chunkSize > 0 |
| import PlaygroundSupport | |
| import Foundation | |
| class Worker { | |
| private let queue = DispatchQueue.global(qos: .background) | |
| private let serialQueue = DispatchQueue(label: "com.acme.serial") | |
| public private(set) var count = 0 | |
| func incrementCount() { |
| class ThreadSafeCollection<Element> { | |
| // Concurrent synchronization queue | |
| private let queue = DispatchQueue(label: "ThreadSafeCollection.queue", attributes: .concurrent) | |
| private var _elements: [Element] = [] | |
| var elements: [Element] { | |
| var result: [Element] = [] | |