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
public enum PasswordRule { | |
public enum CharacterClass { | |
case upper | |
case lower | |
case digits | |
case special | |
case asciiPrintable | |
case unicode | |
case custom(Set<Character>) |
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://labbots.com/enabling-touch-id-for-access-on-terminal/ | |
# Edit this file /etc/pam.d/sudo with your favourite editor. | |
sudo vim /etc/pam.d/sudo | |
# Add the following line to the top of the file. | |
auth sufficient pam_tid.so | |
# To enable Touch ID access on Iterm2. You need to do the following. | |
# Go to Prefs -> Advanced -> Allow sessions to survive logging out and back in and set value to no. |
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 | |
var storage = Set<AnyCancellable>() | |
let pub1 = Timer | |
.publish(every: 1, on: .main, in: .default) | |
.autoconnect() | |
let sub = CurrentValueSubject<Int, Never>(0) |
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 URLRequest { | |
func prettyDescription() -> String? { | |
guard | |
let urlString = url?.absoluteString, | |
let methodString = method?.rawValue | |
else { return nil } | |
let headersString = headers.map(\.description).joined(separator: "\n") | |
let bodyString = if let httpBody { | |
String(data: httpBody, encoding: .utf8) ?? "-unknown-body-" |
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 Task where Failure == Error { | |
static func delayed( | |
byTimeInterval delayInterval: TimeInterval, | |
priority: TaskPriority? = nil, | |
@_implicitSelfCapture operation: @escaping @Sendable () async throws -> Success | |
) -> Task { | |
Task(priority: priority) { | |
let delay = UInt64(delayInterval * 1_000_000_000) | |
try await Task<Never, Never>.sleep(nanoseconds: delay) | |
return try await operation() |
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
// MARK: - Publisher Extensions | |
extension Publisher { | |
func unwrap<T>( | |
orThrow error: @escaping @autoclosure () -> Error | |
) -> AnyPublisher<T, Error> where Output == Optional<T> { | |
tryMap { output in | |
guard case .some(let wrapped) = output else { | |
throw 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
struct Animator { | |
typealias Animations = () -> () | |
typealias Completion = (Bool) -> () | |
let perform: (@escaping Animations, Completion?) -> () | |
} | |
extension UIView { | |
static func animate( |
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
protocol P1: Equatable, RawRepresentable<Int> { | |
var p1: Int { get set } | |
} | |
// Extension Method for P1 | |
/* | |
extension P1 { | |
static func == (lhs: Self, rhs: Self) -> Bool { | |
print("P1:", #function) |
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
protocol SimpleProtocol { | |
associatedtype MyType | |
func doSomething() -> MyType | |
} | |
struct SimpleA<T>: SimpleProtocol { | |
typealias MyType = T | |
private let item: T |