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 FluentPostgresDriver | |
| import FluentSQLiteDriver | |
| // This extension adds transaction support to the Database protocol. | |
| // It has to be specialized for each Database type used by your application, | |
| // since the Database protocol does not support the raw() method. | |
| extension Database { | |
| func transaction(callback: @escaping (Database) -> EventLoopFuture<Void>) -> EventLoopFuture<Void> { | |
| return self.withConnection { (db) -> EventLoopFuture<Void> 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
| @DynamicColor(lightVariant: .black, darkVariant: .white) | |
| static var dynamicLabelColor: UIColor | |
| @propertyWrapper | |
| struct DynamicColor { | |
| let lightVariant: UIColor | |
| let darkVariant: UIColor | |
| var wrappedValue: UIColor { | |
| get { |
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
| // SwiftUI View for getting taps with(!) the tap locations unlike the current tapAction and tapGestures of SwiftUI | |
| // There may be a way easier way to do this, not sure... | |
| /* | |
| Use like so: | |
| TappableView { | |
| (location, taps) in | |
| if taps == 1 { | |
| print("single tap at \(location)") |
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
| let xs = [1, 2, 3, 4, 5] | |
| for (element, index) in zip(xs, xs.indices) { | |
| if index == xs.startIndex { | |
| print("START") | |
| } | |
| print(element) | |
| if index == xs.index(before: xs.endIndex) { |
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
| public struct BoundedSequence<Base>: Sequence, IteratorProtocol where Base: Sequence { | |
| public struct Boundary: Equatable { | |
| public let isStart: Bool | |
| public let isEnd: Bool | |
| } | |
| private var _iterator: Base.Iterator | |
| private var _previous: Base.Element? | |
| private var _current: Base.Element? | |
| private var _next: Base.Element? |
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 | |
| struct AppStoreReceiptValidationRequest: Encodable { | |
| let receiptData: String | |
| let password: String? | |
| let excludeOldTransactions: Bool | |
| private enum CodingKeys: String, CodingKey { | |
| case receiptData = "receipt-data" | |
| case password |
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
| #!/bin/sh | |
| filter='subsystem contains "com.apple.TimeMachine"' | |
| log show --style syslog --info --last 12h --predicate "$filter" | |
| log stream --style syslog --info --predicate "$filter" |
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
| extension Config { | |
| public func setup() throws { | |
| // ... | |
| addConfigurable(middleware: Html5RoutingMiddleware.init, name: "html5") | |
| } | |
| // ... | |
| } |
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 | |
| private let reuseIdentifier = "Cell" | |
| class CollectionViewController: UICollectionViewController { | |
| /* Custom scrollView for paging */ | |
| let pagingScrollView = UIScrollView() | |
| /* Return item size */ |
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
| extension SequenceType where Generator.Element == String { | |
| func commaList() -> String { | |
| var result = joinWithSeparator(", ") | |
| let range = result.rangeOfString(", ", options: .BackwardsSearch) | |
| result.replaceRange(range!, with: " & ") | |
| return result | |
| } | |
| } |