This file contains 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
echo 'Preparations' | |
cd ~ | |
mkdir SwiftSetup | |
cd ~/SwiftSetup | |
mkdir Backup | |
echo 'cd to ~/SwiftSetup' | |
echo 'Fetching dependencies: clang, libicu-dev libssl-dev openssl' | |
sudo apt-get install clang libicu-dev libssl-dev openssl |
This file contains 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 | |
func valueForTheme<Value>(light: Value, dark: Value) -> Value { | |
return UITraitCollection.current.userInterfaceStyle == .dark ? dark : light | |
} |
This file contains 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 SwiftUI | |
extension Color { | |
public init(light: Color, dark: Color) { | |
self = valueForTheme(light: light, dark: dark) | |
} | |
} |
This file contains 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 Fluent | |
private struct _Migration<T>: Migration { | |
var preparation: (Database) -> EventLoopFuture<Void> | |
var revertion: (Database) -> EventLoopFuture<Void> | |
func prepare(on database: Database) -> EventLoopFuture<Void> { preparation(database) } | |
func revert(on database: Database) -> EventLoopFuture<Void> { revertion(database) } | |
} | |
public protocol MigrationProvider { |
This file contains 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 | |
extension Sequence where Iterator.Element: Hashable { | |
public func unique() -> OrderedSet<Element> { .init(self) } | |
} | |
public struct OrderedSet<Element: Hashable>: BidirectionalCollection, Equatable, ExpressibleByArrayLiteral { | |
public typealias Index = Int | |
private var set: Set<Element> = [] |
This file contains 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 Combine | |
typealias Reducer<State, Action> = (inout State, Action) -> Void | |
final class Store<State, Action>: ObservableObject { | |
typealias Effect = AnyPublisher<Action, Never> | |
@Published private(set) var state: State | |
private let lock: NSLock = .init() |
This file contains 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 SwiftUI | |
public struct Component<Target, Coordinator, Body: View>: View { | |
private var makeBody: () -> Body | |
public var body: Body { makeBody() } | |
} | |
#if os(macOS) | |
public struct _ViewBody<Target: NSView, Coordinator>: NSViewRepresentable { | |
internal var _makeTarget: (Context) -> Target |
This file contains 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 class CancellablesManager { | |
private let lock = NSLock() | |
public typealias Storage = Set<AnyCancellable> | |
private var cancellables: Storage = [] | |
func store(_ element: AnyCancellable?, _ precondition: Bool = true) { | |
lock.execute { | |
guard precondition, let element = element else { return } | |
cancellables.insert(element) |
This file contains 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 | |
extension Bundle { | |
var id: String { bundleIdentifier ?? "" } | |
} | |
@propertyWrapper | |
public class Scheduled { | |
private static let defaultQueue = DispatchQueue( | |
label: Bundle.main.id.appending(".queues.scheduled"), |
OlderNewer