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
[log] V:[a(==b)] | |
VALID | |
[log] V:|-(7)-[a]-(7)-| | |
VALID | |
[log] V:|-20@750-[a]-10@45-| | |
VALID | |
[log] V:|-m-[a(n)]-(>=o)-[b] | |
Unable to parse constraint format: | |
Options mask required views to be aligned on a vertical edge, which is not allowed for layout that is also vertical. | |
V:|-m-[a(n)]-(>=o)-[b] |
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 Value : Equatable { | |
} | |
protocol Smashable { | |
typealias TargetValue : Value | |
func valueBySmashingOtherValue<SomeOtherValue : Value>(value: SomeOtherValue) -> TargetValue | |
} | |
struct Bar : 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
protocol Value { | |
} | |
protocol Smashable { | |
typealias V : Value | |
func valueBySmashingOtherValue(value: V) -> V | |
} | |
struct Bar : 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
import Foundation | |
class Hrm { | |
@objc func objcFunc() { | |
} | |
dynamic func dynamicFunc() { | |
} | |
func normalFunc() { |
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 | |
var backing = NSMutableArray() | |
func pop()->Int? { | |
return backing.firstObject.map { $0.integerValue } | |
} | |
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
- (NSImage *)templateImageByMappingWhiteToClear:(NSImage *)image { | |
NSImage *output = [NSImage imageWithSize:[image size] flipped:NO drawingHandler:^BOOL(NSRect dstRect) { | |
CGImageRef srcCGImage = [image CGImageForProposedRect:&dstRect context:[NSGraphicsContext currentContext] hints:nil]; | |
CGRect bounds = CGRectMake(0, 0, CGImageGetWidth(srcCGImage), CGImageGetHeight(srcCGImage)); | |
CGContextRef maskCtx = CGBitmapContextCreate(NULL, bounds.size.width, bounds.size.height, 8, 0, CGColorSpaceCreateDeviceGray(), 0); | |
CGContextDrawImage(maskCtx, bounds, srcCGImage); | |
CGImageRef mask = CGBitmapContextCreateImage(maskCtx); | |
CFRelease(maskCtx); | |
CGContextRef ctx = [[NSGraphicsContext currentContext] graphicsPort]; |
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 | |
protocol MyProtocol { | |
func myFunc() | |
} | |
class MyView : NSView, MyProtocol { | |
func myFunc() { | |
} | |
} |
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
var s : NSString = String(count: n, repeatedValue: Character(".")) | |
let r = NSRegularExpression(pattern: "^(..+?)\\1+$", options: nil, error: nil)! | |
var l = s.length | |
var re = [Int]() | |
while let m = r.firstMatchInString(s, options:nil, range:NSRange(0..<l)) { | |
let p = m.rangeAtIndex(1).length | |
re += [p] | |
l /= p | |
s = s.substringToIndex(l) | |
} |
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
ken@Nepheli-20 /tmp> | |
~/bin/clang/bin/clang -O3 -g -fsanitize=address -isysroot /Volumes/Data/Users/ken/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -framework Foundation /tmp/asanBarf.m | |
ken@Nepheli-20 /tmp> ./a.out | |
================================================================= | |
==91531==ERROR: AddressSanitizer: global-buffer-overflow on address 0x00010caf8f1f at pc 0x00010caf8dc2 bp 0x7fff531077a0 sp 0x7fff53107798 | |
READ of size 32 at 0x00010caf8f1f thread T0 | |
#0 0x10caf8dc1 (/private/tmp/./a.out+0x100000dc1) | |
#1 0x10caf8de4 (/private/tmp/./a.out+0x100000de4) | |
#2 0x7fff8cdc25c8 (/usr/lib/system/libdyld.dylib+0x35c8) | |
#3 0x0 (<unknown module>) |
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> | |
#import <mach/mach_time.h> | |
#import <simd/simd.h> | |
NSTimeInterval SecondsFromMachTimeInterval(uint64_t machTimeInterval) { | |
static double timeScaleSeconds = 0.0; | |
if (timeScaleSeconds == 0.0) { |
NewerOlder