This file contains hidden or 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 Cocoa | |
| import MachO | |
| if let handle = dlopen("/Applications/App.app/Contents/MacOS/some.helper.binary", RTLD_LAZY) { | |
| defer { dlclose(handle) } | |
| if let ptr = dlsym(handle, MH_EXECUTE_SYM) { | |
| let mhExecHeaderPtr = ptr.assumingMemoryBound(to: mach_header_64.self) | |
| var size: UInt = 0 |
This file contains hidden or 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
| [package] | |
| name = "udpbind" | |
| version = "0.1.0" | |
| edition = "2024" | |
| [dependencies] | |
| nix = { version = "0.30.1", features = ["net"] } | |
| anyhow = "*" |
This file contains hidden or 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
| fn get_stack_size() -> usize { | |
| let mut low: usize = 0; | |
| let mut high: usize = 0; | |
| unsafe { | |
| windows::Win32::System::Threading::GetCurrentThreadStackLimits( | |
| &mut low as _, | |
| &mut high as _, | |
| ) | |
| }; | |
| high - low |
This file contains hidden or 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
| unsafe fn any_as_u8_slice<T: Sized>(p: &T) -> &[u8] { | |
| ::core::slice::from_raw_parts( | |
| (p as *const T) as *const u8, | |
| ::core::mem::size_of::<T>(), | |
| ) | |
| } | |
| let bytes: &[u8] = unsafe { any_as_u8_slice(&req) }; | |
| for byte in bytes { | |
| print!("{:02x} ", byte); |
This file contains hidden or 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 | |
| import PlaygroundSupport | |
| extension NSAttributedString { | |
| enum MarkdownElement { | |
| case paragraph, bold | |
| } | |
| struct MarkdownStylingOptions { | |
| var font: UIFont |
This file contains hidden or 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 NetworkExtension | |
| extension NetworkExtension.NWPath { | |
| var interfaceName: String? { | |
| let interface = self.value(forKeyPath: "_internalPath.direct") as? nw_interface_t | |
| return interface.map { String(cString: nw_interface_get_name($0)) } | |
| } | |
| } |
This file contains hidden or 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 UIPresentationController { | |
| static let presentationTransitionWillBegin = Notification.Name( | |
| "UIPresentationControllerPresentationTransitionWillBeginNotification" | |
| ) | |
| static let presentationTransitionDidEndNotification = Notification.Name( | |
| "UIPresentationControllerPresentationTransitionDidEndNotification" | |
| ) | |
| static let dismissalTransitionWillBeginNotification = Notification.Name( |
This file contains hidden or 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
| class FormsheetPresentationController: UIPresentationController { | |
| private static let dimmingViewOpacityWhenPresented = 0.5 | |
| private var isPresented = false | |
| private let dimmingView: UIView = { | |
| let dimmingView = UIView() | |
| dimmingView.backgroundColor = .black | |
| return dimmingView | |
| }() |
This file contains hidden or 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
| caffeinate & | |
| CAFFEINATE_PID=$! | |
| for FILE in *.mkv; do | |
| OUTPUT=$(echo $FILE | sed -r "s/[ ]*[\.-\(]?(480p|720p|1080p|WEB|576p|HDTV|Xvid).*(\.[a-z4]+)$/\2/I") | |
| if [ "$OUTPUT" = "$FILE" ]; then | |
| OUTPUT=$(echo $OUTPUT | sed -r "s/(\.[a-z4]+)$/.converted\1/I") | |
| fi |
This file contains hidden or 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
| class UnfairLock: NSLocking { | |
| private var _lock = os_unfair_lock() | |
| func lock() { | |
| os_unfair_lock_lock(&_lock) | |
| } | |
| func unlock() { | |
| os_unfair_lock_unlock(&_lock) | |
| } |
NewerOlder