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 Random { | |
class func randomInt() -> Int { | |
return Int(arc4random()); | |
} | |
class func randomIntFrom(from: Int) -> Int { |
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 | |
public func arc4random <T: IntegerLiteralConvertible> (type: T.Type) -> T { | |
var r: T = 0 | |
arc4random_buf(&r, UInt(sizeof(T))) | |
return r | |
} | |
public extension UInt { | |
public static func random(lower: UInt = min, upper: UInt = max) -> UInt { |
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 String { | |
func NSRangeOfString(string: String) -> NSRange { | |
let range = self.rangeOfString(string) | |
if (range != nil) { | |
let first: Int = self.startIndex.distanceTo(range!.startIndex) | |
let length: Int = range!.startIndex.distanceTo(range!.endIndex) | |
return NSMakeRange(first, length) | |
} | |
return NSMakeRange(NSNotFound, 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
ScrollView { | |
Group { | |
Rectangle().fill(Color(UIColor.systemRed)).frame(width: 100, height: 100) | |
Rectangle().fill(Color(UIColor.systemBackground)).frame(width: 100, height: 100) | |
Rectangle().fill(Color(UIColor.secondarySystemBackground)).frame(width: 100, height: 100) | |
Rectangle().fill(Color(UIColor.tertiarySystemBackground)).frame(width: 100, height: 100) | |
Rectangle().fill(Color(UIColor.systemFill)).frame(width: 100, height: 100) | |
Rectangle().fill(Color(UIColor.secondarySystemFill)).frame(width: 100, height: 100) | |
Rectangle().fill(Color(UIColor.tertiarySystemFill)).frame(width: 100, height: 100) |
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
const handler = { | |
get: function(_, prop) { | |
return (obj) => { | |
return obj.map((entry) => entry[prop]); | |
} | |
} | |
}; | |
const MapTo = new Proxy({}, handler); |