Skip to content

Instantly share code, notes, and snippets.

@haikusw
haikusw / NSObject+RFExtensions.h
Created October 8, 2012 06:35 — forked from bsneed/NSObject+RFExtensions.h
perform a block in a background thread, and call a completion block on the main thread when its done.
//
// NSObject+RFExtensions.h
//
// Created by brandon on 10/5/12.
// Copyright (c) 2012 redf.net. All rights reserved.
//
#import <Foundation/Foundation.h>
typedef void (^NSObjectPerformBlock)(id userObject);
@haikusw
haikusw / gist:4247009
Created December 9, 2012 21:05 — forked from twobitlabs/gist:4226365
Blocks cheat sheet
// http://cocoawithlove.com/2009/10/ugly-side-of-blocks-explicit.html has a nice breakdown of the syntax--it helps to think of the ^ as similar to a pointer dereference symbol *
// block typedef:
typedef void(^Block)();
typedef void(^ConditionalBlock)(BOOL);
typedef NSString*(^BlockThatReturnsString)();
typedef NSString*(^ConditionalBlockThatReturnsString)(BOOL);
// block property with typedef:
using UnityEngine;
using System.Collections;
namespace UnityAssets
{
public class DualDisplay : MonoBehaviour
{
public Camera mainCamera, controlsCamera;
public bool autoEnable = true;
//Based on a brilliant idea by Matthew Wegner - https://twitter.com/mwegner/status/355147544818495488
//My implementation is super lazy with magic numbers everywhere! :D
#if UNITY_EDITOR
using System;
using UnityEngine;
using System.Collections.Generic;
using UnityEditor;
using System.Reflection;
//
// SDMacros.h
// walmart
//
// Created by Brandon Sneed on 7/11/13.
// Copyright (c) 2013 Walmart. All rights reserved.
//
/**
The __deprecated__ macro saves a little bit of typing around marking classes and methods as deprecated.
//
// SDMacros.h
//
// Created by Brandon Sneed on 7/11/13.
// Copyright (c) 2013 SetDirection. All rights reserved.
//
//
// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
// Version 2, December 2004
//
using System;
using System.Collections.Generic;
using UnityEngine;
public class Scroller
{
public float maxDragSpeed = 20.0f; //maximum drag speed
public float edgeSquish = 60.0f; //how far to go past the end
public float edgeBounce = 0.19f; //how much force to use to bounce back
public float strongFriction = 0.75f; //used to bring it to a stop quicker
extern uint32_t dyld_get_program_sdk_version() WEAK_IMPORT_ATTRIBUTE;
extern BOOL DZApplicationUsesLegacyUI(void)
{
static dispatch_once_t onceToken;
static BOOL legacyUI = NO;
dispatch_once(&onceToken, ^{
uint32_t sdk = __IPHONE_OS_VERSION_MIN_REQUIRED;
if (dyld_get_program_sdk_version != NULL) {
sdk = dyld_get_program_sdk_version();
@interface DDDelegateProxy : NSProxy
+ (id)proxyForDelegate:(id)delegate conformingToProtocol:(Protocol *)protocol;
@property (weak, readonly) id delegate;
@property (strong, readonly) Protocol *protocol;
/*!
* Set a default return value for a method on the delegate's protocol.
* \param value This must be a block that returns the default value. Bad Things will happen if it's not.
static BOOL PSPDFIsDevelopmentBuild(void) {
#if TARGET_IPHONE_SIMULATOR
return YES;
#else
static BOOL isDevelopment = NO;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
// There is no provisioning profile in AppStore Apps.
NSData *data = [NSData dataWithContentsOfFile:[NSBundle.mainBundle pathForResource:@"embedded" ofType:@"mobileprovision"]];
if (data) {