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
private let drawingCache = NSCache() | |
public extension UIImage { | |
public class func imageForSize(size: CGSize, opaque: Bool = false, drawingBlock: () -> Void) -> UIImage { | |
assert(size != CGSize.zeroSize) | |
UIGraphicsBeginImageContextWithOptions(size, opaque, 0.0) | |
drawingBlock() | |
let image = UIGraphicsGetImageFromCurrentImageContext() | |
UIGraphicsEndImageContext(); |
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
echo -e 'build/\n*.pbxuser\n!default.pbxuser\n*.mode1v3\n!default.mode1v3\n*.mode2v3\n!default.mode2v3\n*.perspectivev3\n!default.perspectivev3\nxcuserdata\n*.xccheckout\n*.moved-aside\nDerivedData\n*.hmap\n*.ipa\n*.xcuserstate\n.DS_Store\n\nCarthage/Build' > .gitignore |
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
internal extension Array { | |
internal func get(index: Int) -> Element? { | |
return index >= 0 && index < self.count ? self[index] : nil | |
} | |
internal func at(indexes: [Int]) -> [Element] { | |
var result: [Element] = [] | |
for index in indexes { | |
result.append(self[index]) | |
} |
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 class Box<T> { | |
public let value: T | |
public init(_ value: T) { | |
self.value = value | |
} | |
} | |
public enum Result<T> { | |
case Success(Box<T>) |
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
// | |
// KeyboardListener.swift | |
// KeyboardListener | |
// | |
// Created by Jānis Kiršteins on 15/03/15. | |
// Copyright (c) 2015 Jānis Kiršteins. All rights reserved. | |
// | |
import UIKit |
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 initalArray = [1, 2, 3] | |
let pointer: UnsafeMutablePointer<Int> = UnsafeMutablePointer(initalArray) | |
let arrary = Array(UnsafeBufferPointer(start: pointer, count: initalArray.count)) |
NewerOlder