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 UIImage { | |
| /** | |
| Resizes the image to width x height and converts it to an RGB CVPixelBuffer. | |
| */ | |
| public func pixelBuffer(width: Int, height: Int) -> CVPixelBuffer? { | |
| var maybePixelBuffer: CVPixelBuffer? | |
| let attrs = [kCVPixelBufferCGImageCompatibilityKey: kCFBooleanTrue, | |
| kCVPixelBufferCGBitmapContextCompatibilityKey: kCFBooleanTrue] |
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 | |
| extension Date { | |
| typealias FormattedString = (DateFormatter) -> String | |
| func formatted(by format: String) -> FormattedString { | |
| return { formatter in | |
| formatter.dateFormat = format | |
| return formatter.string(from: self) | |
| } |
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
| @dynamicMemberLookup | |
| class Person { | |
| let name: String | |
| let age: Int | |
| private let details: [String: String] | |
| init(name: String, age: Int, details: [String: String]) { | |
| self.name = name | |
| self.age = age | |
| self.details = details |
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 NSObjectProtocol where Self: NSObject { | |
| func observe<Value>(_ keyPath: KeyPath<Self, Value>, onChange: @escaping (Value) -> ()) -> NSKeyValueObservation { | |
| return observe(keyPath, options: [.initial, .new]) { _, change in | |
| // TODO: change.newValue should never be `nil`, but when observing an optional property that's set to `nil`, then change.newValue is `nil` instead of `Optional(nil)`. This is the bug report for this: https://bugs.swift.org/browse/SR-6066 | |
| guard let newValue = change.newValue else { return } | |
| onChange(newValue) | |
| } | |
| } | |
| func bind<Value, Target>(_ sourceKeyPath: KeyPath<Self, Value>, to target: Target, at targetKeyPath: ReferenceWritableKeyPath<Target, Value>) -> NSKeyValueObservation { |
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 | |
| import PlaygroundSupport | |
| enum CoreError: Error, LocalizedError { | |
| case unknown | |
| var errorDescription: String? { | |
| switch self { | |
| case .unknown: | |
| return "Unknown error occured" |
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 | |
| import PlaygroundSupport | |
| public class InfinityLoader: UIView { | |
| let anim = CAAnimationGroup() | |
| //// Drawing Methods | |
| lazy var path: UIBezierPath = { |
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 | |
| struct LocationData: Codable { | |
| var city: String | |
| var country: String | |
| var address: String? | |
| } | |
| struct Item: Codable { | |
| var name: String |
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
| var fetchedResultsProcessingOperations: [NSBlockOperation] = [] | |
| private func addFetchedResultsProcessingBlock(processingBlock:(Void)->Void) { | |
| fetchedResultsProcessingOperations.append(NSBlockOperation(block: processingBlock)) | |
| } | |
| func controller(controller: NSFetchedResultsController, didChangeObject anObject: AnyObject, atIndexPath indexPath: NSIndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: NSIndexPath?) { | |
| switch type { | |
| case .Insert: |
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 | |
| import RxSwift | |
| import RxCocoa | |
| import RxDataSources | |
| class ViewController: BaseCollectionViewController { | |
| ... | |
| typealias Section = AnimatableSectionModel<String, CellStyle> |
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
| #set the shell to /bin/sh | |
| TAGS="TODO:|FIXME:" | |
| find "${SRCROOT}" \( -name "*.swift" \) -type f -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($TAGS).*\$" | perl -p -e "s/($TAGS)/ warning: \$1/" |