Skip to content

Instantly share code, notes, and snippets.

- (void)testSparkInspectorCompatibility {
PSPDFDocument *document = [[PSPDFTestAssetLoader new] documentWithName:@"Testcase_Metadata.pdf"];
// Spark swizzles this method and calls description on the target. Let's simulate this for this test case, and then clean up.
id<Aspect> token = [NSNotificationCenter aspect_hookSelector:@selector(addObserver:selector:name:object:) withOptions:0 usingBlock:^(id instance, NSArray *args) {
[args.firstObject description];
} error:NULL];
// Load the document. This failed because of side effects in description when called during init.
UIImage *image = [document imageForPage:0 size:CGSizeMake(100, 100) clippedToRect:CGRectZero annotations:nil options:nil receipt:NULL error:NULL];
@NSExceptional
NSExceptional / AutoLayout.md
Last active December 8, 2021 06:19
The best damn AutoLayout guide I've ever seen

Edit Feb 4 5:16 PM: Skip to the bottom if you just want the article

It has been brought to my attention that rehosting someone else's content without asking them — even if you link to the original content — is not exactly polite. I did not ask the author before I rehosted his article, and while I feel I should have known better than to that, it just didn't occurr to me. It's not exactly plagarism, but it's still wrong on some level. I have reached out to him now about hosting it here publically, and if he says it's alright, I'll put it back.

You can find the original article here, on his site, and on his Medium page.

@steipete
steipete / gist:3933090
Created October 22, 2012 18:13
Simple main thread usage detector that I'm using in PSPDFKit to find performance problems early on.
// Smart little helper to find main thread hangs. Enable in appDidFinishLaunching.
// Only available with source code in DEBUG mode.
@interface PSPDFHangDetector : NSObject
+ (void)startHangDetector;
@end
@implementation PSPDFHangDetector
+ (void)startHangDetector {
#ifdef DEBUG
@sekati
sekati / xcode-build-bump.sh
Created July 24, 2012 20:44
Xcode Auto-increment Build & Version Numbers
# xcode-build-bump.sh
# @desc Auto-increment the build number every time the project is run.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Drag the "Run Script" below "Link Binaries With Libraries"
# 6. Insure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0)
@maciekish
maciekish / resetXcode.sh
Created August 10, 2016 10:13
Reset Xcode. Clean, clear module cache, Derived Data and Xcode Caches. You can thank me later.
#!/bin/bash
killall Xcode
xcrun -k
xcodebuild -alltargets clean
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache"
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang.$(whoami)/ModuleCache"
rm -rf ~/Library/Developer/Xcode/DerivedData/*
rm -rf ~/Library/Caches/com.apple.dt.Xcode/*
open /Applications/Xcode.app
@steipete
steipete / PSPDFUIKitMainThreadGuard.m
Last active March 10, 2024 19:23
This is a guard that tracks down UIKit access on threads other than main. This snippet is taken from the commercial iOS PDF framework http://pspdfkit.com, but relicensed under MIT. Works because a lot of calls internally call setNeedsDisplay or setNeedsLayout. Won't catch everything, but it's very lightweight and usually does the job.You might n…
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
// PLEASE DUPE rdar://27192338 (https://openradar.appspot.com/27192338) if you would like to see this in UIKit.
#import <objc/runtime.h>
#import <objc/message.h>
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this: