Skip to content

Instantly share code, notes, and snippets.

@pratikshabhisikar
pratikshabhisikar / gist:1173386
Created August 26, 2011 13:22
UIView Flip Animation
[UIView beginAnimations:@"FlipAnimation" context:nil];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:myFirstDrillDownView cache:NO];
[UIView setAnimationBeginsFromCurrentState:YES];
[myFirstDrillDownView exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
[UIView commitAnimations];
@seanh
seanh / gist:1217489
Created September 14, 2011 19:14
A -boundingBox method for Cocos2D CCNode subclasses that returns the bounding box of all the bounding boxes of a node's descendants.
-(CGRect) fullBoundingBox
{
NSMutableArray *stack = [[NSMutableArray new] autorelease];
for (CCNode *childNode in self.children)
{
[stack addObject:childNode];
}
float leftmost, highest, rightmost, lowest;
while ([stack count] > 0)
{
@AtomicCat
AtomicCat / gist:1407621
Created November 30, 2011 01:57
UIView (NibLoadingExtension)
@implementation UIView (NibLoadingExtension)
+ (id)viewFromNib
{
static NSMutableDictionary *caches = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
caches = [[NSMutableDictionary dictionary] retain];
});

CocoaPods + Xcode Continuous Integration

Script:

cd ${SRCROOT}
if [ -e "Pods" ]
then
pod install
else
touch Pods
@natelyman
natelyman / NLCachedImageTableViewCell.h
Created January 9, 2012 10:16
Cached UITableViewCell that loads images from a remote source.
//
// NLCachedImageTableViewCell.h
// niners
//
// Created by Lyman, Nathan(nlyman) on 1/9/12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
@Pretz
Pretz / RoundedImageView.java
Created January 10, 2012 02:47
Andround Rounded Image View
package com.yelp.android.ui.widgets;
import com.yelp.android.R;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
@berkus
berkus / memoize.swift
Last active April 2, 2017 19:19
A "fast" memoization generic in Swift
Promised speed:
0.1s https://dl.dropboxusercontent.com/s/bpgountdjrbs17n/2014-06-09%20at%2019.00.png
Actual speed:
575s https://dl.dropboxusercontent.com/s/2kbn5p1g4t03fvl/2014-06-09%20at%2019.00%20%281%29.png
With optimizations:
@haikusw
haikusw / gist:1050447
Created June 28, 2011 03:48
Objective C singleton pattern templates discussion
// Accessorizer's default generated singleton code for class Foo
static Foo *sharedInstance = nil;
+ (void) initialize
{
if (sharedInstance == nil)
sharedInstance = [[self alloc] init];
}
@christophercotton
christophercotton / OpaqueLayer.h
Created January 5, 2012 04:25
Basic Cocos2d Layer to swallow all the touch events on it
// Feel free to use. MIT License
#import <Foundation/Foundation.h>
#import "cocos2d.h"
// Layer that will just capture any touch events on it
@interface OpaqueLayer : CCLayerColor {
}
@interface UIImage (fixOrientation)
- (UIImage *)fixOrientation;
@end