This file contains 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 AppKit | |
public extension NSBezierPath { | |
public var CGPath: CGPath { | |
let path = CGMutablePath() | |
var points = [CGPoint](repeating: .zero, count: 3) | |
for i in 0 ..< self.elementCount { | |
let type = self.element(at: i, associatedPoints: &points) | |
switch type { |
This file contains 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.TargetConditionals; | |
#if TARGET_OS_IPHONE | |
@import UIKit; | |
#else | |
@import AppKit; | |
#endif | |
/// Concrete text storage intended to be subclassed. | |
@interface BaseTextStorage : NSTextStorage |
This file contains 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, const char **argv) { | |
@autoreleasepool { | |
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ | |
dispatch_sync(dispatch_get_main_queue(), ^{ | |
NSLog(@"is main thread? %i", (int)[NSThread isMainThread]); | |
}); | |
}); |
This file contains 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
// | |
// OPTestKeyLoopView.m | |
// | |
// Copyright (c) 2013 AgileBits Inc. | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal | |
// in the Software without restriction, including without limitation the rights | |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
// copies of the Software, and to permit persons to whom the Software is furnished |
This file contains 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
// | |
// OPTestKeyLoopView.h | |
// | |
// Copyright (c) 2013 AgileBits Inc. | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal | |
// in the Software without restriction, including without limitation the rights | |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
// copies of the Software, and to permit persons to whom the Software is furnished |
This file contains 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
//PRHFrameGrabber grabs frame images from the movie. | |
//It wraps a couple of AVAssetImageGenerators, one of which is allowed to round to a more convenient time (e.g., a keyframe). | |
//Thus, the temporally lax generator will return an image first, while we wait for the temporally strict generator, which may take a significant fraction of a second. | |
//PRHFrameGrabber is also an NSPasteboardWriter. It's what the movie view feeds to the dragging session when the user tries to drag a frame; the frame grabber fulfills its NSPasteboardWriter duties by returning the grabbed frame. | |
@interface PRHFrameGrabber () | |
@property(readwrite, copy) NSImage *image; | |
@end | |
@implementation PRHFrameGrabber |
This file contains 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
NSString *const PSPDFApplicationDidReceiveMemoryWarningNotification = @"PSPDFApplicationDidReceiveMemoryWarningNotification"; | |
// Test with sudo memory_pressure -l critical. Don't forget to re-set afterwards! | |
__attribute__((constructor)) static void PSPDFInstallLowMemoryNotificationWarningMac(void) { | |
static dispatch_source_t source; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
source = dispatch_source_create(DISPATCH_SOURCE_TYPE_MEMORYPRESSURE, 0, DISPATCH_MEMORYPRESSURE_WARN|DISPATCH_MEMORYPRESSURE_CRITICAL, dispatch_get_main_queue()); | |
dispatch_source_set_event_handler(source, ^{ | |
dispatch_source_memorypressure_flags_t pressureLevel = dispatch_source_get_data(source); |
This file contains 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
/// Observes a run loop to detect any stalling or blocking that occurs. | |
/// | |
/// This class is thread-safe. | |
@interface GHRunLoopWatchdog : NSObject | |
/// Initializes the receiver to watch the specified run loop, using a default | |
/// stalling threshold. | |
- (id)initWithRunLoop:(CFRunLoopRef)runLoop; | |
/// Initializes the receiver to detect when the specified run loop blocks for |
This file contains 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
// | |
// CollectionViewDataSource.swift | |
// Khan Academy | |
// | |
// Created by Andy Matuschak on 10/14/14. | |
// Copyright (c) 2014 Khan Academy. All rights reserved. | |
// | |
import UIKit |
This file contains 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
# Set the build number to the current git commit count. | |
# | |
# Permanent home: | |
# https://gist.github.com/jaredsinclair/af6898f93674ee5923f3 | |
# | |
# Based on: http://w3facility.info/question/how-do-i-force-xcode-to-rebuild-the-info-plist-file-in-my-project-every-time-i-build-the-project/ | |
# Updated with dSYM handling from http://yellowfeather.co.uk/blog/auto-incrementing-build-number-in-xcode-revisited/ | |
git=`sh /etc/profile; which git` | |
appBuild=`"$git" rev-list HEAD --count` |