Skip to content

Instantly share code, notes, and snippets.

@markschabacker
markschabacker / post_run_script.rb
Created December 7, 2012 21:32
Xcode 4.5 Command Line Unit Tests
# Run iOS Unit Tests from the command line with Xcode 4.5 and iOS 6
# Adapted from Scott Thompson at http://stackoverflow.com/a/10823483/1359212
#
# Steps:
# 1. Create a new Xcode Scheme for the Tests target
# 2. Edit the Tests Scheme so that the "Run" checkbox is checked for the Tests target
# 3. Use this script as the Test Target's "Run Script" entry on the "Build Phases" tab
# 4. Run tests from the command line with:
# xcodebuild -sdk iphonesimulator -scheme 'TestSchemeName' build SL_RUN_UNIT_TESTS=YES
@steipete
steipete / PSPDFViewController.h
Last active June 6, 2017 03:56
This method will help to prevent a lot of emails about "weird bugs".
// Defines a yet undocumented method to add a warning if super isn't called.
#ifndef NS_REQUIRES_SUPER
#if __has_attribute(objc_requires_super)
#define NS_REQUIRES_SUPER __attribute((objc_requires_super))
#else
#define NS_REQUIRES_SUPER
#endif
#endif
@interface UIViewController (SubclassingWarnings)
@interface NSIndexSet (Operations)
// http://en.wikipedia.org/wiki/Union_(set_theory)
- (NSIndexSet *)unionWith:(NSIndexSet *)other;
// http://en.wikipedia.org/wiki/Intersection_(set_theory)
- (NSIndexSet *)intersectionWith:(NSIndexSet *)other;
// http://en.wikipedia.org/wiki/Complement_(set_theory)#Relative_complement
- (NSIndexSet *)relativeComplementIn:(NSIndexSet *)universe;
@lsloan
lsloan / Open Selected Finder Folder in iTerm
Last active September 13, 2017 06:10 — forked from al3xandru/gist:1156476
Use the selected folder in Finder to open a shell in iTerm and go to its directory.
Gist title: "Open Selected Finder Folder in iTerm"
Summary: Use the selected folder in Finder to open a shell in iTerm and go to its directory.
See also: https://gitlab.com/gnachman/iterm2/issues/3552
@steipete
steipete / CallOncePerRunloopHelper.m
Last active February 2, 2018 07:32
To work around rdar://19810773, I need a helper that can filter multiple calls to the same method during the same runloop. This is my first attempt on it.
/// Performs `block` immediately and ignores subsequent calls during the same runloop.
#define pspdf_ensureCalledOnlyOncePerRunloop(block) do { \
static const char __onceKey; _pspdf_ensureCalledOnlyOncePerRunloop(self, &__onceKey, block); } while(0)
extern void _pspdf_ensureCalledOnlyOncePerRunloop(id self, const void *key, dispatch_block_t block);
void _pspdf_ensureCalledOnlyOncePerRunloop(id self, const void *key, dispatch_block_t block) {
NSCParameterAssert(block);
NSCParameterAssert(self);
PSPDFAssertOnMainThread(); // run loop needs the main thread.
@smirn0v
smirn0v / gist:0b4fefcb5d2452f716b1
Last active February 12, 2018 15:54
Debugserver
$ cd /Applications/Xcode6-Beta5.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/
# choose your platform
$ cd 7.1
# mount developer disk image
$ hdiutil attach DeveloperDiskImage.dmg
# copy debugserver
$ cp /Volumes/DeveloperDiskImage/usr/bin/debugserver ~/
$ cd ~/
# prepare entitlements
$ cat > entitlements.plist << 'EOF'
import lldb
import re
import shlex
# This script allows Xcode to selectively ignore Obj-C exceptions
# based on any selector on the NSException instance
def getRegister(target):
if target.triple.startswith('x86_64'):
return "rdi"
@mikeash
mikeash / gist:5172803
Created March 15, 2013 20:18
Main thread watchdog
- (void)watchdog {
NSTimeInterval pingInterval = 1.0/60.0;
NSTimeInterval watchdogInterval = 1.0/30.0;
__block NSTimeInterval lastPing = 0;
NSProcessInfo *pi = [NSProcessInfo processInfo];
dispatch_source_t timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, dispatch_get_main_queue());
dispatch_source_set_timer(timer, DISPATCH_TIME_NOW, pingInterval * NSEC_PER_SEC, 0);
@marmoy
marmoy / DictionaryEncoder.swift
Created April 2, 2018 09:48
A DictionaryEncoder to be used with the Encodable protocol, based on the default PropertyListEncoder from the Swift project
//===----------------------------------------------------------------------===//
//
// This source file is a modification of the PropertyListEncoder from the Swift project.
// The modification consists of skipping the final serialization into binary format (in the encode function) and instead returning the dictionary representation of the object to be encoded.
//
//===----------------------------------------------------------------------===//
import Foundation
//===----------------------------------------------------------------------===//
@mackuba
mackuba / wwdc15.md
Last active August 6, 2022 17:28
New stuff from WWDC 2015

Here's my own list of the interesting stuff announced during this year's WWDC, collected from the keynotes, various Apple docs, blog posts and tweets.

If you're planning to watch the videos, I really recommend this Mac app that helps you download and watch them: https://github.com/insidegui/WWDC.

OS X El Capitan

http://www.apple.com/osx/elcapitan-preview/

  • split view - two apps side by side on full screen