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
protocol Numeric: SignedNumberType | |
{ | |
func * (lhs: Self, rhs: Self) -> Self | |
func + (lhs: Self, rhs: Self) -> Self | |
func - (lhs: Self, rhs: Self) -> Self | |
func / (lhs: Self, rhs: Self) -> Self | |
} | |
extension Numeric | |
{ |
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
// | |
// String+Score | |
// | |
// Created by Dominik Felber on 07.04.2016. | |
// Copyright (c) 2016 Dominik Felber. All rights reserved. | |
// | |
// Based on the Objective-C implementation of Nicholas Bruning https://github.com/thetron/StringScore | |
// and the original JavaScript implementation of Joshaven Potter https://github.com/joshaven/string_score | |
// |
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 | |
import UIKit | |
@IBDesignable | |
class PatternImageView: UIImageView | |
{ | |
@IBInspectable var repeats: Bool = true | |
{ | |
didSet { |
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 | |
for family: String in UIFont.familyNames() { | |
print("\(family)") | |
for names: String in UIFont.fontNamesForFamilyName(family) { | |
print("\t\(names)") | |
} | |
print("") |
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 | |
import XCPlayground | |
let someView = UIView(frame: CGRect(x: 0, y: 0, width: 200, height: 200)) | |
XCPlaygroundPage.currentPage.liveView = someView |
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 AppKit | |
typealias Color = NSColor | |
#elseif os(iOS) || os(tvOS) | |
import UIKit | |
typealias Color = UIColor | |
#endif | |
extension Color |
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 CoreTelephony | |
let info: CTTelephonyNetworkInfo = CTTelephonyNetworkInfo() | |
guard let carrier: CTCarrier = info.subscriberCellularProvider else { | |
// No carrier info available | |
return | |
} | |
print(carrier.carrierName) | |
print(carrier.mobileCountryCode) |
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
public func <(a: NSDate, b: NSDate) -> Bool { | |
return a.compare(b) == NSComparisonResult.OrderedAscending | |
} | |
public func >(a: NSDate, b: NSDate) -> Bool { | |
return a.compare(b) == NSComparisonResult.OrderedDescending | |
} | |
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 Array { | |
func randomValue() -> Element? { | |
guard self.isEmpty == false else { | |
return nil | |
} | |
let idx = Int(arc4random() % UInt32(count)) | |
return self[idx] | |
} | |
} |
OlderNewer