This file contains hidden or 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
| typealias AlertActionStyle = UIAlertAction.Style | |
| extension UIAlertController { | |
| static func create( | |
| style: UIAlertController.Style, | |
| title: String?, | |
| message: String?, | |
| actions: [AlertAction] = [], | |
| onDismiss: VoidHandler? = nil | |
| ) -> UIAlertController { |
This file contains hidden or 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 | |
| extension UIViewController { | |
| /// Creates an instance of `ViewControllerType` defined in a storyboard. | |
| /// | |
| /// The setup for this method to work is the following: | |
| /// 1. The storyboard needs to have a single view controller of the type `ViewControllerType` | |
| /// 2. This view controller needs to be set as the initial view controller | |
| /// 3. The name of the view controller needs to match the name of the storyboard and end with "ViewController". | |
| /// e.g. Some.storyboard and SomeViewController |
This file contains hidden or 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
| #!/bin/sh | |
| echo $1 | python3 -c "import sys; from urllib.parse import unquote; print(unquote(sys.stdin.read()));" |
This file contains hidden or 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
| JEKYLL_ENV=production bundle exec jekyll build | |
| firebase deploy |
This file contains hidden or 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 Optional where Wrapped == String { | |
| var isEmptyOrNil: Bool { | |
| return self?.isEmpty != false | |
| } | |
| var isNotEmptyNorNil: Bool { | |
| return !isEmptyOrNil | |
| } | |
| } |
This file contains hidden or 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: Equatable { | |
| func distinctUntilChanged() -> Self { | |
| var resultArray = Self() | |
| for element in self { | |
| if resultArray.last != element { | |
| resultArray.append(element) | |
| } | |
| } | |
| return resultArray | |
| } |
This file contains hidden or 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 { | |
| func tinted(with color: UIColor) -> UIImage? { | |
| let maskImage = cgImage | |
| let bounds = CGRect(origin: .zero, size: size) | |
| let renderer = UIGraphicsImageRenderer(size: size) | |
| // QuartzCore origin .zero is bottom-left, while UIKit's is top-left. | |
| let tintedButFlippedImage = renderer.image { context in | |
| let cgContext = context.cgContext | |
| cgContext.clip(to: bounds, mask: maskImage!) |
This file contains hidden or 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 Optional where Wrapped == String { | |
| var orEmpty: String { | |
| switch self { | |
| case .some(let value): | |
| return value | |
| case .none: | |
| return "" | |
| } | |
| } | |
| } |
This file contains hidden or 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 | |
| /// Extend `NibView` to create a reusable view in a XIB file. | |
| /// The contents of the view are designed in a XIB file. | |
| /// The `NibView` class is responsible for loading the | |
| /// contents of the XIB file and setting it as its subview. | |
| /// File's Owner in the XIB file needs to be set to the | |
| /// view class extending the `NibView`. Any outlets defined | |
| /// in that class need to be connected to the File's Owner. | |
| open class NibView: UIView { |
This file contains hidden or 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 | |
| protocol Repeating { | |
| func startRepeating(withIntervalInSeconds: TimeInterval) | |
| func stopRepeating() | |
| } |