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
#if os(OSX) | |
import Cocoa | |
#else | |
import Foundation | |
#endif | |
/** | |
resolves a host names ip address for the specified family | |
- parameters: | |
- name: the host name to resolve |
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 | |
import Network | |
class ExternIP: ObservableObject { | |
@Published var address: String = "unknown" | |
@Published var isV6Supported: Bool = false | |
init() { | |
queue = DispatchQueue(label: "monitor") | |
monitor = NWPathMonitor() |
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 Cocoa | |
let given = "{\n\t\"test\": \"this 😃 \\ \",\n\r\t\"\'testing\': 1\r\n}\\ \0 \\" | |
let expected = #"{\n\t\"test\": \"this 😃 \\ \",\n\r\t\"\'testing\': 1\r\n}\\ \0 \\"# | |
let expectedAscii = #"{\n\t\"test\": \"this \u{0001F603} \\ \",\n\r\t\"\'testing\': 1\r\n}\\ \0 \\"# | |
extension String { | |
private static let escapedChars = [ | |
(#"\0"#, "\0"), | |
(#"\t"#, "\t"), | |
(#"\n"#, "\n"), |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 LotsOfStuff: Codable { | |
let x: Int | |
let y: Int | |
let z: Double | |
let a: [String] | |
let b: String | |
let c: String | |
let less: LessStuff |
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 | |
protocol Invokable { | |
var order: Int { get } | |
func invoke() | |
} | |
class A: Invokable { | |
var order = 0 | |
func invoke() { print("A") } |
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 | |
/** | |
Class to make "Toast," like in Android, for iOS in Swift 4.x. | |
example: | |
``` | |
Toast.backgroundColor = UIColor.init(red: 0.0, green: 1.0, blue: 0.0, alpha: 0.6) | |
Toast.textColor = UIColor.init(red: 1.0, green: 0.0, blue: 0.0, alpha: 0.6) | |
Toast.textAlignment = .center | |
Toast.font = UIFont.systemFont(ofSize: 14.0) |
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 | |
extension UIImage { | |
/// will load an image from a remote URL | |
/// - parameter fromURL: url to load from | |
/// - parameter completionHandler: completion handler for when the image is done loading. | |
/// - parameter image: UIImage? that was retrieved, or nil on error | |
/// - parameter error: LocalizedError? that is nil on success, or an error message on failure. | |
/// example | |
/// ``` |
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
class TLDList { | |
static let tlds = [ | |
"*.aaa", | |
"*.aarp", | |
"*.abarth", | |
"*.abb", | |
"*.abbott", | |
"*.abbvie", | |
"*.abc", | |
"*.able", |
NewerOlder