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
// https://stackoverflow.com/a/45777692/5536516 | |
import Foundation | |
struct MemoryAddress<T>: CustomStringConvertible { | |
let intValue: Int | |
var description: String { | |
let length = 2 + 2 * MemoryLayout<UnsafeRawPointer>.size |
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 Sequence { | |
func grouped<T: Hashable>(by keyPath: KeyPath<Element, T>) -> [T: [Element]] { | |
return .init(grouping: self, by: { $0[keyPath: keyPath] }) | |
} | |
} |
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 | |
import p2_OAuth2 | |
protocol AuthManagerProtocol { | |
var userLoggedIn: Bool { get } | |
func login(username: String, password: String, completion: @escaping Completion<Void>) | |
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 | |
@objc protocol KeyboardObserving: class { | |
@objc optional func handleKeyboardWillShow(notification: Notification, keyboardSize: CGSize) | |
@objc optional func handleKeyboardWillHide(notification: Notification, keyboardSize: CGSize) | |
@objc optional func handleKeyboardWillChangeFrame(notification: Notification, keyboardSize: CGSize) | |
@objc optional func handleKeyboardDidChangeFrame(notification: Notification, keyboardSize: CGSize) | |
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 | |
import AVFoundation | |
extension AVAsset { | |
func cropVideoTrack(at index: Int, cropRect: CGRect, outputURL: URL, completion: @escaping (Result<Void, Swift.Error>) -> Void) { | |
enum Orientation { | |
case up, down, right, left |
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 | |
import MapKit | |
extension MKMapView { | |
/// Region with MIN possible zoom level, such that self.centerCoordinate == center | |
func region(center: CLLocationCoordinate2D) -> MKCoordinateRegion { | |
var oldRegion: MKCoordinateRegion? | |
var newRegion: MKCoordinateRegion? | |