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 | |
/// `CachedValue` provides a strongly typed interface to UserDefaults. | |
/// It can cache any ``Codable`` type. | |
/// | |
/// Usage: | |
/// 1. Make a struct conforming to `CachedValue` | |
/// * Add a `typealias ValueType = YourType` | |
/// * Optionally add a `static var defaultValue: YourType = YourInstance`. (Your `value` accessor will then be non-optional.) | |
/// * Optionally add a `static var cacheKey: String = "a-very-specific-string-key"`. (By default your key will be your CachedValue conforming type's name.) |
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 QuartzCore | |
import os.log | |
extension OSLog { | |
private static var subsystem = Bundle.main.bundleIdentifier! | |
fileprivate static let osLogCategoryString = "StartupTimerEvents" | |
static let startupTimer = OSLog(subsystem: subsystem, category: osLogCategoryString) | |
} |
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 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
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
import UIKit | |
public extension UIColor { | |
private static var randomLightness: CGFloat { | |
Double.random(in: 0...1) | |
} | |
private static var randomRGB: UIColor { | |
UIColor( |
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
#!/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/bash | |
function unln { | |
eval 'cd "$(pwd -P)"' | |
} |