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
| //===----------------------------------------------------------------------===// | |
| // | |
| // This source file is part of the Swift open source project | |
| // | |
| // Copyright (c) 2023 Apple Inc. and the Swift project authors. | |
| // Licensed under Apache License v2.0 with Runtime Library Exception | |
| // | |
| // See https://swift.org/LICENSE.txt for license information | |
| // | |
| //===----------------------------------------------------------------------===// |
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
| /* ESPNOW Example | |
| This example code is in the Public Domain (or CC0 licensed, at your option.) | |
| Unless required by applicable law or agreed to in writing, this | |
| software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | |
| CONDITIONS OF ANY KIND, either express or implied. | |
| */ | |
| /* |
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
| @available(macOS 14, iOS 13.0, watchOS 6.0, tvOS 13.0, *) | |
| final class DispatchSerialExecutor: SerialExecutor { | |
| let queue: DispatchQueue | |
| init(queue: DispatchQueue) { | |
| self.queue = queue | |
| } | |
| init() { | |
| self.queue = DispatchQueue( |
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 SwiftUI | |
| @MainActor class ViewModel: ObservableObject { | |
| private let events = AsyncStream<AwaitableEvent>.makeStream() | |
| struct AwaitableEvent { | |
| let event: Event | |
| let continuation: CheckedContinuation<Void, Never> | |
| } |
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
| final class NetworkUsers: URLRepresentable { | |
| let apiVersion: APIVersion | |
| let network: String | |
| init(apiVersion: APIVersion, network: String) { | |
| self.apiVersion = apiVersion | |
| self.network = network | |
| } | |
| func makeURL() throws -> URL { |
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 MeowVapor | |
| import JWT | |
| final class CMSContext: Service { | |
| struct Value { | |
| public let meow: Meow.Context | |
| public let token: AdministrativeUserToken? | |
| public let user: AdministrativeUser? | |
| } | |
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
| // https://github.com/vapor/vapor | |
| import Vapor | |
| // https://github.com/Ikiga/IkigaJSON | |
| import IkigaJSON | |
| public struct JSONSafetyMiddleware: Middleware { | |
| public init() {} | |
| public func respond(to request: Request, chainingTo next: Responder) throws -> EventLoopFuture<Response> { |
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 encoder = JSONEncoder() | |
| let decoder = JSONDecoder() | |
| struct User: Codable { | |
| let id: Int | |
| let name: String | |
| let age: Double | |
| let roles: [String] | |
| let awesome: Bool | |
| } |
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 | |
| let date = Date() | |
| var array = [Any]() | |
| for _ in 0..<100_000 { | |
| array.append("Hello, world") | |
| } |
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 Vapor | |
| import Leopard | |
| import Lynx | |
| import Sockets | |
| import HTTP | |
| public final class LynxServer : ServerProtocol, AsyncRouter { | |
| public func register(at path: [String], method: Lynx.Method?, isFallbackHandler: Bool, handler: @escaping RequestHandler) { | |
| router.register(at: path, method: method, isFallbackHandler: isFallbackHandler, handler: handler) | |
| } |
NewerOlder