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 NSPathControl { | |
| class func fix() { | |
| let itemClass = NSPathControlItem.self | |
| let superclass: AnyClass = class_getSuperclass(itemClass) | |
| let releaseSelector = Selector("release") | |
| let releaseMethod = class_getInstanceMethod(itemClass, releaseSelector) | |
| let superReleaseIMP = class_getMethodImplementation(superclass, releaseSelector) | |
| if method_getImplementation(releaseMethod) != superReleaseIMP { |
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 Target {} | |
| class WeakHolder { | |
| var strong1: Target? | |
| var strong2: Target? | |
| weak var weak: Target? | |
| } |
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
| struct DecodeResult { | |
| uint32_t codepoint; | |
| uint32_t decodedBytes; | |
| }; | |
| static inline struct DecodeResult DecodeOneUTF8(const uint8_t *utf8) { | |
| static uint8_t byteCountTable[16] = { | |
| // 0xxx | |
| [0x0] = 1, | |
| [0x1] = 1, |
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
| static inline const uint8_t *DecodeOneUTF8(const uint8_t *utf8, uint32_t *outCodepoint) { | |
| uint8_t byteOne = utf8[0]; | |
| uint8_t byteTwo = utf8[1]; | |
| uint8_t byteThree = utf8[2]; | |
| uint8_t byteFour = utf8[3]; | |
| uint8_t bit1 = byteOne >> 7; | |
| // uint8_t bit2 = (byteOne >> 6) & 1; | |
| uint8_t bit3 = (byteOne >> 5) & 1; | |
| uint8_t bit4 = (byteOne >> 4) & 1; |
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 | |
| enum CoroutineState { | |
| case Fresh, Running, Blocked, Canceled, Done | |
| } | |
| struct CoroutineCancellation: ErrorType {} | |
| class CoroutineImpl<InputType, YieldType> { | |
| let body: (yield: YieldType throws -> InputType) throws -> Void |
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 | |
| protocol Initable { | |
| init() | |
| } | |
| extension String: Initable {} | |
| extension Double: Initable {} | |
| protocol AnyValueSettable { |
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
| #define JSON(...) JSONFromString(@#__VA_ARGS__) | |
| id JSONFromString(NSString *string) { | |
| NSData *data = [string dataUsingEncoding: NSUTF8StringEncoding]; | |
| NSError *error; | |
| id result = [NSJSONSerialization JSONObjectWithData: data options: 0 error: &error]; | |
| if(result == nil) { | |
| NSLog(@"Failed to load code-level JSON object, wat: %@", error); | |
| abort(); | |
| } | |
| return result; |
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
| MikeBookPro:~/shell mikeash$ cat test.cpp | |
| volatile int x; | |
| #define DOUBLE(identifier) void identifier ## _() __attribute__((always_inline)) { identifier(); identifier(); } | |
| class y { | |
| void f() __attribute__((always_inline)) { | |
| x++; | |
| } | |
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 | |
| protocol Serializable { | |
| static func deserializeInto(bytePtr: UnsafeMutablePointer<UInt8>, bytes: ArraySlice<UInt8>) -> ArraySlice<UInt8> | |
| } | |
| extension Serializable { | |
| typealias WorkaroundSelf = 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 <Foundation/Foundation.h> | |
| int main(int argc, char **argv) { | |
| @autoreleasepool { | |
| NSFileHandle *stdin = [NSFileHandle fileHandleWithStandardInput]; | |
| NSData *data = [stdin readDataToEndOfFile]; | |
| const char *ptr = [data bytes]; | |
| if(ptr[0] == 'd') { | |
| if(ptr[1] == 'e') { | |
| if(ptr[2] == 'a') { |