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 | |
//https://en.wikipedia.org/wiki/XML | |
class ValidXMLProperties { | |
static let shared = ValidXMLProperties() | |
static let excludedElementNameCharactersPattern = "!|\"|#|\\$|%|&|\\'|\\(|\\)|\\*|\\+|,|/|;|\\<|=|\\>|\\?|\\@|\\[|\\\\|\\]|\\^|`|\\{|\\||\\}|~" | |
static let excludedElementNameStartCharactersPattern = "-|\\.|[\\d]" |
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 ActivityIndicatorView: UIView { | |
private lazy var gradientLayer: CAGradientLayer = { | |
let gradient = CAGradientLayer() | |
gradient.locations = [0.5, 1] | |
gradient.startPoint = CGPointMake(0.0, 0.0) | |
gradient.endPoint = CGPointMake(1.0, 0.8) |
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 JSONInitable { | |
init(data: JSON) | |
} | |
extension JSON { | |
func to<T where T: JSONInitable>(type: T.Type) -> [T] { | |
return self.arrayValue.map { | |
return T(data: $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
extension Array where Element: Comparable { | |
func mergeSort() -> [Element] { | |
if count <= 1 { return self } | |
else { | |
let left = Array(self[0 ..< count/2]) | |
let right = Array(self[count/2 ..< count]) | |
return merge(left.mergeSort(), right: right.mergeSort()) | |
} | |
} |