Skip to content

Instantly share code, notes, and snippets.

@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.
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();
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
//
// 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
//
//
// 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.
//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;
using UnityEngine;
using System.Collections;
namespace UnityAssets
{
public class DualDisplay : MonoBehaviour
{
public Camera mainCamera, controlsCamera;
public bool autoEnable = true;
@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:
@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:3290457
Created August 7, 2012 23:19
some snippets of a routine to create a dynamically drawn on 2d texture in unity
Dynamic drawing to a texture in Unity3d basic. This is not complete working code but pieces cut out of working code so you'll have to look up the documentation for the functions called to get specific parameters and such.
static function CreateFooTexture ( ... )
{
// create texture:
var tex : Texture2D = new Texture2D(512, 512, TextureFormat.ARGB32, false);
// get the pixels