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 | |
struct MeterTable { | |
private let minDecibels: Double | |
private let scaleFactor: Double | |
private let table: [Double] | |
init(minDB: Double = -80, tableSize: Int = 400, root: Double = 2) { | |
self.minDecibels = minDB |
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 LeafKit | |
final class JSONifyTag: UnsafeUnescapedLeafTag { | |
func render(_ ctx: LeafContext) throws -> LeafData { | |
guard let param = ctx.parameters.first else { | |
throw "no parameter provided to JSONify" | |
} | |
return LeafData.string(param.jsonString) | |
} |
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 | |
import Fluent | |
protocol DynamicQueryable { | |
static func dynamicMapping<DB: Database, QB: QueryBuilder<DB, Self>>() -> [String: (DynamicFilter, QB) throws -> QB] | |
} | |
protocol DynamicSortable { | |
static var dynamicFieldMapping: [String: FluentProperty] { get } | |
} |
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 | |
struct Property: Encodable { | |
let name: String | |
@AnyEncodable | |
var value: Encodable | |
} | |
@propertyWrapper struct AnyEncodable: Encodable { | |
let wrappedValue: Encodable |
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 Vapor | |
import IkigaJSON | |
extension IkigaJSONEncoder: ContentEncoder { | |
public func encode<E: Encodable>( | |
_ encodable: E, | |
to body: inout ByteBuffer, | |
headers: inout HTTPHeaders | |
) throws { | |
headers.contentType = .json |
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 | |
import ObjectiveC | |
import UIKit | |
private var eventSubjectKey = "viewcontroller_lifecycle_subject" | |
private var swizzlingPerformed = false | |
private final class LifecycleSubjectBag: NSObject { | |
let viewDidLoadSubject = PassthroughSubject<Void, Never>() | |
let viewWillAppearSubject = PassthroughSubject<Bool, Never>() |
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 | |
import ObjectiveC | |
import UIKit | |
typealias TraitCollectionChange = (UITraitCollection, previous: UITraitCollection?) | |
private typealias TraitChangeSubject = PassthroughSubject<TraitCollectionChange, Never> | |
private var traitSubjectKey = "_voodoo_trait_subject" | |
private var swizzlingPerformed = false |
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
#!/bin/bash | |
if [ -f "/opt/swift/bin/swift" ]; then | |
echo ====== Swift is already installed at /opt/swift, exiting! | |
exit 1 | |
fi | |
for i in "$@" | |
do | |
case $i in |
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 | |
import Vapor | |
struct AppInfo: Codable { | |
let averageUserRating: Double | |
let userRatingCount: Int | |
} | |
enum AppleAppLookupError: Error { | |
case notFound |
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
// This is a direct port of https://github.com/download13/uuidv5 to Swift | |
import Foundation | |
import Crypto | |
public extension UUID { | |
enum Namespace { | |
case dns | |
case url | |
case oid |
NewerOlder