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
| class Obfuscator { | |
| // MARK: - Variables | |
| /// The salt used to obfuscate and reveal the string. | |
| private var salt: String | |
| // MARK: - Initialization | |
| init() { |
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
| class Logger { | |
| private static let dateFormatter: DateFormatter = { | |
| let formatter = DateFormatter() | |
| formatter.dateFormat = "yyyy-MM-dd HH:mm:ss" | |
| return formatter | |
| }() | |
| static func info(_ messages: Any?..., file: String = #file, function: String = #function, line: Int = #line) { | |
| printMessage(messages, state: "🟢 INFO", file: file, function: function, line: line) |
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 UIView { | |
| func addSubviews(_ views: UIView...) { | |
| views.forEach{addSubview($0)} | |
| } | |
| } | |
| ##How to Use: | |
| class YourViewController: UIViewController { |
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
| func downsample(imageAt imageURL: URL, to pointSize: CGSize, scale: CGFloat = UIScreen.main.scale) -> UIImage? { | |
| // Create an CGImageSource that represent an image | |
| let imageSourceOptions = [kCGImageSourceShouldCache: false] as CFDictionary | |
| guard let imageSource = CGImageSourceCreateWithURL(imageURL as CFURL, imageSourceOptions) else { | |
| return nil | |
| } | |
| // Calculate the desired dimension | |
| let maxDimensionInPixels = max(pointSize.width, pointSize.height) * scale |
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 UIImageView { | |
| /// Loads image from web asynchronosly and caches it, in case you have to load url | |
| /// again, it will be loaded from cache if available | |
| func load(url: URL, placeholder: UIImage?, cache: URLCache? = nil) { | |
| let cache = cache ?? URLCache.shared | |
| let request = URLRequest(url: url) | |
| if let data = cache.cachedResponse(for: request)?.data, let image = UIImage(data: data) { | |
| self.image = image | |
| } else { | |
| self.image = placeholder |
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
| protocol DefaultSourceValue { | |
| associatedtype Value: Decodable | |
| static var defaultValue: Value {get} | |
| } | |
| enum DefaultValue {} //this will not allow for default init | |
| extension DefaultValue { |
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
| //https://dummyapi.io/ | |
| import PlaygroundSupport | |
| import Foundation | |
| import Combine | |
| // MARK: - Network Controller | |
| protocol NetworkControllerProtocol: class { | |
| typealias Headers = [String: Any] | |
| func get<T>(type: T.Type, |
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
| [merge] | |
| keepBackup = false | |
| tool = p4merge | |
| [mergetool "p4merge"] | |
| cmd = /Applications/p4merge.app/Contents/Resources/launchp4merge "\"$PWD/$BASE\"" "\"$PWD/$REMOTE\"" "\"$PWD/$LOCAL\"" "\"$PWD/$MERGED\"" | |
| keepTemporaries = false | |
| trustExitCode = false | |
| keepBackup = false | |
| [diff] | |
| tool = p4merge |
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 Balance = (add: ((Int) -> Void), get: (() -> Int), print: () -> ()) //Tupple. Tupple is value type but inside tupple we have function with referenc type. | |
| func newBalance() -> Balance { | |
| var balance = 0 | |
| return ( | |
| add: { newValue in balance += newValue }, | |
| get: { return balance }, | |
| print: { print("Your balance is \(balance)") } | |
| ) | |
| } |
NewerOlder