I hereby claim:
- I am pitiphong-p on github.
- I am pitiphong_p (https://keybase.io/pitiphong_p) on keybase.
- I have a public key ASCYHTyMo48sHejIeUTR9ynIBNuobg7RegfPzZi9dzBmaQo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| inline NSString * PTPKeyPathForSelectors(SEL selector, ...) { | |
| if (!selector) { | |
| return nil; | |
| } | |
| NSMutableArray *selectors = [NSMutableArray array]; | |
| va_list args; | |
| va_start(args, selector); | |
| SEL arg = selector; | |
| do { |
| extension Array { | |
| func group<Key: Hashable>(by: (Element) -> Key) -> [Key: [Element]] { | |
| var values = [Key: [Element]]() | |
| let keys = self.map(by) | |
| let pairs = zip(keys, self) | |
| pairs.forEach { (key, value) in | |
| var valuesOfKeys = values[key] ?? [] | |
| valuesOfKeys.append(value) | |
| values[key] = valuesOfKeys |
| import Foundation | |
| // See: https://developer.apple.com/swift/blog/?id=15 | |
| struct Error: ErrorType { | |
| var _domain: String {return "com.sadun"} | |
| var _code: Int {return 0} | |
| } | |
| enum MyError : ErrorType { |
| @interface NSIndexSet (NthPosition) | |
| - (NSUInteger)indexAtIndex_ppb:(NSUInteger)position; | |
| @end | |
| @implementation NSIndexSet (NthPosition) | |
| - (NSUInteger)indexAtIndex_ppb:(NSUInteger)position { | |
| __block NSUInteger index = NSNotFound; | |
| if (position < self.count) { | |
| __block NSUInteger count = 0; | |
| [self enumerateRangesUsingBlock:^(NSRange range, BOOL *stop) { |