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
private protocol MutableConfigProtocol: ConfigProtocol { | |
var key1: String { get set } | |
var key2: Int { get set } | |
} | |
private protocol ConfigLayerProtocol { | |
var key1: String? { get } | |
var key2: Int? { get } | |
} |
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 n = 1000.0 | |
let a = (n/2500.0) - 1.0 | |
let b = log10(a) | |
print(b) |
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 n = 1000.0 | |
let a = (n/2500.0) - 1.0 | |
let b = log10(a) | |
print(b) |
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 n = 1000.0 | |
let a = (n/2500.0) - 1.0 | |
let b = log10(a) | |
print(b) |
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 Darwin | |
let Max = 5000.0 | |
func log(_ x: Double, base: Double) -> Double { | |
let result = log(x + 1.0) / log(base + 1.0) | |
print(" log(\(x), base: \(base)) -> \(result)") | |
return result | |
} |
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
extension Data { | |
func encrypt(key: Data) { | |
let ivData = Data.randomBytes(count: kCCKeySizeAES128) | |
var tag = Data(count: kCCKeySizeAES128) | |
var cipherText = Data(count: count) | |
_ = cipherText.withUnsafeMutableBytes { (cipherPtr) in | |
_ = tag.withUnsafeMutableBytes { (tagPtr) in | |
_ = ivData.withUnsafeBytes { (ivPtr) in | |
_ = key.withUnsafeBytes { (keyPtr) in |
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
func createXPCDictionary(_ inDictionary: [String: Any?]) -> xpc_object_t { | |
var keyArray: [UnsafePointer<Int8>] = [] | |
var valueArray: [xpc_object_t?] = [] | |
for (key, value) in inDictionary { | |
keyArray.append(key) | |
let xo: xpc_object_t? = xpc_string_create(value as! String) | |
valueArray.append(xo) | |
} |
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
// FIXME: How do a genericize this to work with any UInt* type? | |
public struct OptionSetIterator<Element: OptionSet>: IteratorProtocol where Element.RawValue == UInt16 { | |
private let value: Element | |
public init(element: Element) { | |
self.value = element | |
} | |
private lazy var remainingBits = value.rawValue | |
private var bitMask: Element.RawValue = 1 |
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
#pragma clang diagnostic push | |
#pragma clang diagnostic warning "-Wnewline-eof" | |
#import <BadFramework/BadHeader.h> | |
#pragma clang diagnostic pop |
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
protocol BaseCommandProtocol { | |
func requestComplete() | |
} | |
extension BaseCommandProtocol { | |
func requestComplete() { | |
// For subclasser overrides | |
print("You should override this") | |
} | |
} |
NewerOlder