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
func turnOffAutoLayoutLogs() { | |
UserDefaults.standard.setValue(false, forKey: "_UIConstraintBasedLayoutLogUnsatisfiable") | |
} | |
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
/* | |
* | |
* If you're using this in UITextView, setting isSelectable or isEditable properties to false will cause the image to not load, | |
* instead set dataDetectorTypes to an empty array if you don't want user to interact with the text view. | |
* | |
*/ | |
import UIKit |
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 os.log | |
import Foundation | |
@propertyWrapper | |
struct Redactable<Value: Codable & Hashable>: Codable, Hashable, CustomLeafReflectable, | |
CustomStringConvertible, CustomDebugStringConvertible, CustomPlaygroundDisplayConvertible { | |
private let value: Value | |
var isRedactionEnabled = 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
import Foundation | |
@propertyWrapper | |
struct Defaults<Value> { | |
let key: Key | |
let defaultValue: Value | |
var wrappedValue: Value { |
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
infix operator ??? | |
func ???<T> (_ value: @autoclosure () -> T?, _ error: @autoclosure () -> Error) throws -> T { | |
guard let value = value() else { | |
throw error() | |
} | |
return value | |
} |
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 | |
class ViewController: UIViewController { | |
private let textView = UITextView() | |
private var beforeNumberOfLines: Int? | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
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: Codable { | |
// works | |
public func encode(to encoder: Encoder) throws { | |
var container = encoder.singleValueContainer() | |
try container.encode(pngData()!) | |
} |
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
/* | |
* | |
* Use this when the publisher only publishes 1 value then stops. | |
* | |
*/ | |
import Combine | |
import Foundation |
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 Combine | |
import Foundation | |
extension Future where Failure == Error { | |
convenience init(promise: @escaping (@escaping (Result<Output, Failure>) -> Void) throws -> Void) { | |
self.init({ (innerPromise) in | |
do { | |
try promise { innerPromise($0) } | |
} catch { | |
innerPromise(.failure(error)) |
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
# !/usr/bin/python3 | |
""" | |
Asset catalogs are not accessible in your Xcode project because they are compiled archive (.car files) so doing | |
something like Bundle.main.url().. won't work. | |
""" | |
""" | |
1. Manually add a file colors.json to your Xcode project on the level ${PROJECT_DIR}/project_name/<here> and |
NewerOlder