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 | |
func generateSecureHash() async -> UUID { | |
print("Generating hash") | |
do { | |
try await Task.sleep(for: .seconds(100)) | |
} catch { | |
print("Sleep: \(error)") | |
} | |
print("Generating hash: done") |
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
// Merged other forks and updated to Swift 2.0. | |
// Original code: | |
// https://gist.github.com/haipham/d169cdea2f28222db7f3 | |
// http://stackoverflow.com/questions/24007129/how-does-one-generate-a-random-number-in-apples-swift-language | |
// https://gist.github.com/pontusarmini/169bc5b3c3fc552a4c3d | |
import Foundation | |
import CoreGraphics | |
// Suppress a warning |
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
// | |
// Original Objective C version: https://gist.github.com/bobmoff/7110052 | |
// | |
// Fix SpriteKit's SKNode bug on iOS 7 & 8: nodes capture touch events | |
// even when userInteractionEnabled is false and the nodes are hidden. | |
// | |
// Details: | |
// http://stackoverflow.com/questions/19511334/sprite-with-userinteractionenabled-set-to-yes-does-not-receive-touches-when-cove | |
// | |
// How to use: |
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
// Playing with router pattern in Swift. Paste to a playground. | |
// | |
// This code is in public domain, feel free to copy/paste. | |
import Cocoa | |
extension NSScanner { | |
func scanUpToString(string: String) -> String? { | |
var result: NSString? = nil | |
if scanUpToString(string, intoString: &result) { |