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 | |
public final class AnySubject<Output, Failure: Error>: Subject { | |
public typealias Output = Output | |
private let valueFunc: (Output) -> () | |
private let completionFunc: (Subscribers.Completion<Failure>) -> () | |
private let subscriptionFunc: (Subscription) -> () |
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 | |
public struct If { | |
let ifTrue: Optional<Void> | |
public init(_ condition: @autoclosure () -> Bool) { | |
self.ifTrue = condition() ? .some(()) : .none | |
} | |
public func map<T>(_ transform: () -> T) -> T? { |
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
#!/bin/bash | |
function setup() { | |
sudo mv /Library/LaunchDaemons/com.paloaltonetworks.gp.pangpsd.plist /Library/Application\ Support/PaloAltoNetworks/GlobalProtect/ | |
sudo mv /Library/LaunchAgents/com.paloaltonetworks.gp.pangps.plist /Library/Application\ Support/PaloAltoNetworks/GlobalProtect/ | |
sudo mv /Library/LaunchAgents/com.paloaltonetworks.gp.pangpa.plist /Library/Application\ Support/PaloAltoNetworks/GlobalProtect/ | |
} | |
function up() { |
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 | |
public extension Optional { | |
mutating func getOrSet(builder: () -> Wrapped) -> Wrapped { | |
switch self { | |
case .some(let wrapped): | |
return wrapped | |
case .none: | |
let value = builder() | |
self = .some(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 Combine | |
import UIKit | |
extension UIResponder { | |
static let firstResponderPublisherSwizzle: Void = { | |
guard let originalMethod = class_getInstanceMethod(UIResponder.self, #selector(becomeFirstResponder)), | |
let swizzledMethod = class_getInstanceMethod(UIResponder.self, #selector(swizzled_becomeFirstResponder)) | |
else { return } | |
method_exchangeImplementations(originalMethod, swizzledMethod) | |
}() |
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
#!/bin/bash | |
function unln { | |
eval 'cd "$(pwd -P)"' | |
} |
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
#!/bin/zsh | |
function zoxide_print_subdir { | |
echo "$(zoxide query "$(pwd)" "$@")" | |
} | |
function zoxide_subdir { | |
eval 'cd "$(zoxide_print_subdir "$@")"' | |
} |
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
#!/bin/zsh | |
yynn=() | |
function pp { | |
_yyload | |
echo -e ${(j. \033[0;31m≪\033[0m .)yynn} | |
} | |
function _yysave { |
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
{% for type in types.protocols %} | |
/// A type-erased instance of ``{{type.name}}`` | |
{{type.accessLevel}} struct Any{{ type.name }}: {{ type.name }} { | |
{% for var in type.allVariables %} | |
private let {{var.name}}Var: () -> {{var.typeName}} | |
{% endfor %} | |
{% for method in type.allMethods %} | |
private let {{ method.callName }}Func: ({% for param in method.parameters%}{{param.typeName}}{% if not forloop.last%}, {% endif %}{% endfor %}) -> {{ method.returnTypeName }} |
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
@dynamicMemberLookup | |
public struct Mockable<T> { | |
public enum MockField<T> { | |
case property(PartialKeyPath<T>, Any) | |
} | |
enum Wrapped { | |
case value(T) | |
case mock([MockField<T>]) |