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
func update(_ arg: inout String) { | |
arg = "UPDATED \(arg)" | |
} | |
let mainQueue = DispatchQueue.init(label: "mainQueue", qos: .userInitiated, attributes: [], autoreleaseFrequency: .workItem, target: nil) | |
let workerQueue = DispatchQueue.init(label: "workerQueue", qos: .userInitiated, attributes: [.concurrent], autoreleaseFrequency: .workItem, target: nil) | |
let systemQueue = DispatchQueue.init(label: "systemQueue", qos: .userInitiated, attributes: [], autoreleaseFrequency: .workItem, target: nil) | |
print("Sample Started") |
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
extension Date { | |
var asTimespec: timespec { | |
let delta = timeIntervalSince1970 | |
let seconds = delta.rounded(.down) | |
let ns = (delta - seconds) * 1_000_000_000 | |
return timespec(tv_sec: Int(seconds), tv_nsec: Int(ns)) | |
} | |
} |
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
let dict = UserDefaults.standard.dictionary(forKey: String(key)) ?? [:] | |
var result = Dictionary<Int,Bool>(minimumCapacity: dict.count) | |
for (key, value) in dict { | |
guard let intKey = key as? Int, | |
let boolValue = value as? Bool | |
else { continue } | |
result[intKey] = boolValue | |
} | |
return result |
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 Root {} | |
extension Root { | |
class Sub {} | |
} | |
extension Root.Sub { | |
func foo() { print("foo!") } | |
} |
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
# ... | |
command script import ~/path/to/viewControllers.py | |
# ... |
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
var LIBIRC_ERR_ACCEPT: Swift.Int32 { | |
get {} | |
} | |
var LIBIRC_ERR_CLOSED: Swift.Int32 { | |
get {} | |
} | |
var LIBIRC_ERR_CONNECT: Swift.Int32 { | |
get {} | |
} | |
var LIBIRC_ERR_CONNECT_SSL_FAILED: Swift.Int32 { |
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
{ | |
/* basic text manipulation */ | |
"^u" = "deleteToBeginningOfParagraph:"; | |
/* Modifier keys: start with C-m */ | |
"^m" = { | |
"^e" = ("insertText:", "\U21A9"); /* C-e return */ | |
"e" = ("insertText:", "\U2305"); /* e enter */ | |
"^t" = ("insertText:", "\U21E5"); /* C-t tab */ | |
"t" = ("insertText:", "\U21E4"); /* t backtab */ |
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
[ | |
["f", "Show next/latest diffs", "setProposedRevRanges()"], | |
[null, "Next unreviewed file", "nextUnreviewedFile()"], | |
[null, "Previous unreviewed file", "prevUnreviewedFile()"], | |
["n", "Next personally unreviewed file", "nextPersonallyUnreviewedFile()"], | |
["p", "Previous personally unreviewed file", "prevPersonallyUnreviewedFile()"], | |
["shift+n", "Next changed file", "nextChangedFile()"], | |
["shift+p", "Previous changed file", "prevChangedFile()"], | |
[null, "Next visible file", "nextVisibleFile()"], |
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 | |
extension Collection { | |
subscript(first: Index, second: Index, rest: Index...) -> [Iterator.Element] { | |
var results: [Iterator.Element] = [] | |
results.reserveCapacity(rest.count + 2) | |
results.append(self[first]) | |
results.append(self[second]) | |
results.append(contentsOf: rest.lazy.map({ self[$0] })) | |
return results |
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 Darwin.Mach.mach_time | |
/// Benchmarks a function and prints the results to stdout. | |
func benchmark<T,R>(label: String, @noescape setup: () -> T, @noescape f: T -> R) { | |
// get a ballpark time estimate | |
let estimateInput = setup() | |
let estimateStart = get_current_ns() | |
let _ = blackBox(f, args: estimateInput) | |
let estimateEnd = get_current_ns() | |
let estimate = estimateEnd - estimateStart |