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 Foundation | |
| func machToNanoseconds(_ mach: UInt64) -> Double { | |
| struct Static { | |
| static var info: mach_timebase_info = { | |
| var info = mach_timebase_info() | |
| mach_timebase_info(&info) | |
| return info | |
| }() | |
| } |
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
| protocol P { | |
| func f() | |
| } | |
| struct S<T> {} | |
| extension S: P where T: P { | |
| func f() { | |
| print(T.self) |
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 | |
| var count: UInt32 = 0 | |
| let ptr = objc_copyClassList(&count)! | |
| let strings = (0 ..< Int(count)).flatMap({ | |
| if class_getSuperclass(ptr[$0]) == nil { | |
| return String(cString: class_getName(ptr[$0])) | |
| } else { |
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
| protocol TSDKey { | |
| associatedtype Value | |
| static var defaultValue: Value { get } | |
| } | |
| struct TSD { | |
| private var storage: [ObjectIdentifier: Any] = [:] | |
| subscript<Key: TSDKey>(key: Key.Type) -> Key.Value { |
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
| // SCROLL DOWN // | |
| import Foundation | |
| protocol TSUD { | |
| associatedtype Value: Codable | |
| init() | |
| static var defaultValue: Value { get } |
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 Foundation | |
| class MutableBox<T> { | |
| var value: T | |
| init(_ initialValue: T) { | |
| value = initialValue | |
| } | |
| } |
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
| /*usr/bin/true | |
| clang -framework Cocoa -g compile-time-class.m && ./a.out | |
| exit;*/ | |
| #import <Foundation/Foundation.h> | |
| #define COMPILE_TIME_CLASS(name) ^{ \ | |
| extern void *OBJC_CLASS_$_ ## 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
| #!/bin/bash | |
| # Exit the script immediately on error | |
| set -e | |
| # We'll work in /tmp | |
| cd /tmp | |
| # Clone mach_override unless we already have it | |
| if [ ! -d mach_override ]; then |
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
| // xcrun -sdk iphoneos clang -O3 -arch arm64 -S test.c | |
| #import <stdarg.h> | |
| #import <stdio.h> | |
| void normal(int a, int b, int c, int d, int e, int f, int g, int h) { | |
| printf("%d %d %d %d %d %d %d %d", a, b, c, d, e, f, g, h); | |
| } | |
| void normal_target(int a, int b, int c, int d, int e, int f, int g, int h); |
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 Darwin | |
| typealias a = (UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, UInt32, U |