Author: Chris Lattner
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
// | |
// DebugDevice.swift | |
// | |
// Copyright 2022 • Sidetrack Tech Limited | |
// | |
import Foundation | |
// This must be called on the main-thread. | |
var isDebugProfileInstalled: 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 UIKit | |
/// A validation rule for text input. | |
public enum TextValidationRule { | |
/// Any input is valid, including an empty string. | |
case noRestriction | |
/// The input must not be empty. | |
case nonEmpty | |
/// The enitre input must match a regular expression. A matching substring is not enough. | |
case regularExpression(NSRegularExpression) |
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 func boot(_ app: Application) throws { | |
let config = URLSessionConfiguration.default | |
config.requestCachePolicy = URLRequest.CachePolicy.reloadIgnoringLocalCacheData | |
config.connectionProxyDictionary = [AnyHashable: Any]() | |
config.connectionProxyDictionary?[kCFNetworkProxiesHTTPEnable as String] = 1 | |
config.connectionProxyDictionary?[kCFNetworkProxiesHTTPProxy as String] = "proxy-server.com" | |
config.connectionProxyDictionary?[kCFNetworkProxiesHTTPPort as String] = 8080 | |
let session = URLSession.init(configuration: config) | |
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
/* | |
pluralForm(28, forms: ["год", "года", "лет"]) | |
output: "лет" | |
*/ | |
func pluralForm(number: Int, forms: [String]) -> String { | |
return number % 10 == 1 && number % 100 != 11 ? forms[0] : | |
(number % 10 >= 2 && number % 10 <= 4 && (number % 100 < 10 || number % 100 >= 20) ? forms[1] : forms[2]) | |
} |