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
//: Playground - noun: a place where people can play | |
// playing with dates | |
import Foundation | |
let date = Date() | |
let myLocale = Locale(identifier: "en_CA") | |
//: ### Setting an application-wide `TimeZone` | |
//: Notice how we use if-let in case the abbreviation is wrong. It will fallback to the default timezone in that case. |
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
find . -path ./Pods -prune -o -name "*.swift" -print0 ! -name "/Pods" | xargs -0 wc -l |
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
ssh-add -K ~/.ssh/id_rsa | |
http://stackoverflow.com/questions/22021378/source-tree-ssh-public-key-denied |
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 UIImageView { | |
func setImage(from url: URL, withPlaceholder placeholder: UIImage? = nil) { | |
self.image = placeholder | |
URLSession.shared.dataTask(with: url) { (data, _, _) | |
if let data = data { | |
let image = UIImage(data: data) | |
DispatchQueue.main.async { | |
self.image = image | |
} | |
} |
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 UIImage { | |
public func imageCenteredInParentWithSize(ratio: CGFloat, backgroundColor: UIColor = UIColor.clear) -> UIImage? { | |
let width = self.size.width | |
let height = width * ratio | |
let frameSize = CGSize(width: width, height: height) | |
UIGraphicsBeginImageContextWithOptions(frameSize, true, UIScreen.main.scale) | |
let context = UIGraphicsGetCurrentContext()! |
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 ErrorPresenting { | |
func presentError(title: String, message: String) | |
} | |
extension ErrorPresenting where Self: UIViewController { | |
func presentError(title: String, message: String) { | |
let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert) | |
let dismissAction = UIAlertAction(title: "OK", style: .default, handler: nil) | |
alertController.addAction(dismissAction) | |
present(alertController, animated: true) |
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
// create header with custom view | |
// create row with custom view | |
// section animation |
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
class EmptyResult: Mappable { | |
required init?(map: Map) {} | |
func mapping(map: Map) { | |
} | |
} | |
class FailableObject<T: Mappable, E: Mappable> : Mappable { | |
var object: T? | |
var error: E? | |
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 UIView { | |
func snapshot() -> UIImage { | |
UIGraphicsBeginImageContextWithOptions(bounds.size, false, UIScreen.main.scale) | |
drawHierarchy(in: bounds, afterScreenUpdates: true) | |
let result = UIGraphicsGetImageFromCurrentImageContext() | |
UIGraphicsEndImageContext() | |
return result! | |
} | |
} |
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 Form: CustomDebugStringConvertible{ | |
public var debugDescription: String { | |
return "\(type(of: self)): \(address(o: self)) \n---------\n\(self.allRows)" | |
} | |
} | |
extension Section: CustomDebugStringConvertible{ | |