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
@interface UIView (MPAdditions) | |
@end | |
@implementation UIView (MPAdditions) | |
- (id)debugQuickLookObject { | |
if (self.bounds.size.width < 0.0f || self.bounds.size.height < 0.0f) { | |
return nil; | |
} | |
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
typedef NS_ENUM(NSInteger, kErrorCode) { | |
kErrorCodeInternal = 431432, | |
}; | |
//! generate error and log it. | |
extern NSError *pixle_NSErrorMake(NSString *message, NSUInteger code, NSDictionary *aUserInfo, SEL selector); | |
#define AssertTrueOrReturnBlock(condition, block) do{ NSAssert((condition), @"Invalid condition not satisfying: %s", #condition);\ | |
if(!(condition)) { block(pixle_NSErrorMake([NSString stringWithFormat:@"Invalid condition not satisfying: %s", #condition], kErrorCodeInternal, nil, _cmd)); return;} }while(0) | |
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
static void PSPDFFixCenteringInPrinterBrowserViewController(void) { | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
// Patch the `UIPrinterSearchingView` class so we get a sane label placement in iOS 7. | |
Class printerSearchingViewClass = NSClassFromString([NSString stringWithFormat:@"UI%@Searching%@", @"Printer", @"View"]); | |
if (printerSearchingViewClass) { | |
SEL customLayoutSubviewsSEL = NSSelectorFromString(@"pspdf_layoutSubviews"); | |
id customLayoutSubviews = ^(UIView *_self) { | |
((void( *)(id, SEL))objc_msgSend)(_self, customLayoutSubviewsSEL); // call original. | |
@try { |
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
#! /bin/sh | |
### BEGIN INIT INFO | |
# Provides: delayed_job | |
# Required-Start: $all | |
# Required-Stop: | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: | |
### END INIT INFO |
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
KEYWORDS="TODO:|FIXME:|\?\?\?:|\!\!\!:" | |
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/ warning: \$1/" |
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
extension NSFetchedResultsController { | |
func registerForCommitsToContext(context: NSManagedObjectContext, notificationCenter: NSNotificationCenter? = nil) -> NSObjectProtocol? { | |
guard self.managedObjectContext != context else { | |
return nil | |
} | |
let center = notificationCenter ?? NSNotificationCenter.defaultCenter() | |
return center.addObserverForName(NSManagedObjectContextDidSaveNotification, object: context, queue: nil) { [weak self] notification in | |
guard let strongSelf = self else { | |
return | |
} |
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 | |
extension Array { | |
func indexOfObject(object : AnyObject) -> NSInteger { | |
return (self as NSArray).indexOfObject(object) | |
} | |
mutating func removeObject(object : AnyObject) { | |
for var index = self.indexOfObject(object); index != NSNotFound; index = self.indexOfObject(object) { | |
self.removeAtIndex(index) |
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
BOOL isDarkImage(UIImage* inputImage){ | |
BOOL isDark = FALSE; | |
CFDataRef imageData = CGDataProviderCopyData(CGImageGetDataProvider(inputImage.CGImage)); | |
const UInt8 *pixels = CFDataGetBytePtr(imageData); | |
int darkPixels = 0; | |
int length = CFDataGetLength(imageData); |
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
static NSString *youTubeVideoHTML = @"<!DOCTYPE html><html><body><div id=\"player\"><script>var tag = document.createElement('script');tag.src = \"http://www.youtube.com/iframe_api\";var firstScriptTag = document.getElementsByTagName('script')[0];firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);var player;function onYouTubeIframeAPIReady() { player = new YT.Player('player', { height: '%0.0f', width: '%0.0f', videoId: '%@', events: { 'onReady': onPlayerReady, }, playerVars: { playsinline: 1 } }); } function onPlayerReady(event) { event.target.playVideo(); }</script></body></html>"; | |
- (void)playVideoWithId:(NSString *)videoId | |
{ | |
self.myWebView.allowsInlineMediaPlayback = YES; | |
self.myWebView.mediaPlaybackRequiresUserAction = NO; | |
NSString *html = [NSString stringWithFormat:youTubeVideoHTML, | |
self.myWebView.frame.size.height, | |
self.myWebView.frame.size.width, |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<Bucket | |
type = "2" | |
version = "2.0"> | |
<Breakpoints> | |
<BreakpointProxy | |
BreakpointExtensionID = "Xcode.Breakpoint.SymbolicBreakpoint"> | |
<BreakpointContent | |
shouldBeEnabled = "Yes" | |
ignoreCount = "0" |
OlderNewer