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 OSLog | |
extension StaticString: Hashable { | |
public static func == (lhs: StaticString, rhs: StaticString) -> Bool { | |
if lhs.hasPointerRepresentation || rhs.hasPointerRepresentation { | |
guard lhs.hasPointerRepresentation && rhs.hasPointerRepresentation else { | |
return false | |
} | |
return strcmp(lhs.utf8Start, rhs.utf8Start) == 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
import ERWeakLink | |
@objc protocol SZExtractorDelegate: NSObjectProtocol { | |
@objc(setExtractionProgress:) func progress(changedTo percent: Double) | |
@objc(extractionCompleteAtArchivePath:) func extraction(completedAt archivePath: String) | |
@objc(extractionEnteredPassThroughMode) func extractionEnteredPassThroughMode() | |
} | |
typealias SZExtractorPrepCompletion = @convention(block) (UInt64, NSError?) -> () | |
typealias SZExtractorStreamCompletion = @convention(block) (NSError?, Bool) -> () |
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 DispatchQueue { | |
private static let dispatch_get_current_queue = dlsym(dlopen(nil, RTLD_GLOBAL), "dispatch_get_current_queue") | |
static var current: DispatchQueue { | |
dispatch_get_current_queue.map { | |
unsafeBitCast($0, to: (@convention(c) () -> Unmanaged<DispatchQueue>).self)().takeUnretainedValue() | |
} ?? .global(qos: .background) | |
} | |
} |
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 class XCTHarness { | |
private typealias XCTestMainType = @convention(c) (_ something: AnyObject?) -> () | |
private static func dlsymcast<T>(_ handle: UnsafeMutableRawPointer!, _ symbol: UnsafePointer<CChar>) -> T! { | |
dlsym(handle, symbol).map { | |
if T.self is AnyObject.Type { | |
return $0 as! T | |
} else { | |
return unsafeBitCast($0, to: T.self) | |
} |
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
// | |
// main.swift | |
// | |
// Created by Eric Rabil on 3/3/22. | |
// | |
import Foundation | |
import Combine | |
let foo = CurrentValueSubject<String, Never>("bar") |
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
@_transparent private func CFDictionaryGetValue(_ dictionary: CFDictionary, _ key: CFString) -> UnsafeRawPointer? { | |
CFDictionaryGetValue(dictionary, Unmanaged.passUnretained(key).toOpaque()) | |
} | |
@_transparent private func CFDictionaryUnwrap(_ type: CFTypeRef) -> CFDictionary? { | |
guard CFGetTypeID(type) == CFDictionaryGetTypeID() else { | |
return nil | |
} | |
return unsafeBitCast(type, to: CFDictionary.self) | |
} |
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 Hasher { | |
static func randomSeed() -> [UInt8] { | |
Array(unsafeUninitializedCapacity: 32) { pointer, initializedCount in | |
for i in 0..<32 { | |
pointer[i] = UInt8(arc4random()) | |
} | |
initializedCount = 32 | |
} | |
} |
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
#include <atomic> | |
#include <cstddef> // for nullptr_t | |
#include <stdint.h> | |
#include <assert.h> | |
#include <iterator> | |
#include <functional> | |
// MARK: - Defines | |
#if __LP64__ |
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
# sip | |
csrutil disable | |
csrutil authenticated-root disable |
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
/** | |
Accepts three functions, where the sole argument of the first two functions is a closure which each accept some ephemeral value and return some value. | |
The third function accepts two parameters, the first parameter being the parameter of function A, and the second belonging to B. It's combinant value is returned. | |
- Parameter sourceA: The first function to zip | |
- Parameter sourceB: The second function to zip | |
- Parameter combiner: The third function to receive the argument of both A and B | |
- Returns: The return value | |
*/ | |
@discardableResult |
NewerOlder