Skip to content

Instantly share code, notes, and snippets.

View CreatureSurvive's full-sized avatar
:octocat:
melting an ancient GPU in Unity3d

Dana Buehre CreatureSurvive

:octocat:
melting an ancient GPU in Unity3d
View GitHub Profile
@saiday
saiday / gist:e8ea1a5165ca469baee4
Created July 14, 2015 07:59
Update UICollectionView with animation
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
{
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
[coordinator animateAlongsideTransition:nil completion:^(id<UIViewControllerTransitionCoordinatorContext> context) {
[self.collectionView performBatchUpdates:^{
[self.collectionView setCollectionViewLayout:self.collectionView.collectionViewLayout animated:YES];
} completion:nil];
}];
}
@kishikawakatsumi
kishikawakatsumi / gist:be87a6bf6992f815aa18
Created March 31, 2015 09:08
Register custom download font
#import "ViewController.h"
@import CoreText;
@interface ViewController ()
@end
@implementation ViewController
@eoghain
eoghain / UICollectionViewFlowLayout+NoFade.m
Created March 5, 2014 00:16
When adding/removing/reloading cells in a UICollectionView using the FlowLayout the cells fade in/out. When doing things like updating a progress bar you get a lot of annoying flashing because of this, this category will prevent that. As an added benefit rotation animations will now show the cells moving into position.
//
// UICollectionViewFlowLayout+NoFade.m
//
// Created by Rob Booth on 3/4/14.
#import "UICollectionViewFlowLayout+NoFade.h"
#import <objc/runtime.h>
@implementation UICollectionViewFlowLayout (NoFade)
@oliverfoggin
oliverfoggin / MyImageDownloader.h
Created November 7, 2013 09:43
NSURLConnection download with progress callbacks
@protocol MyImageDownloaderDelegate <NSObject>
- (void)downloadFailed;
- (void)imageDownloadFinished:(UIImage *)image;
- (void)progressUpdated:(CGFloat)progress;
@end
@interface MyImageDownloader : NSObject
@barbuza
barbuza / UILabel+TextTouch.h
Last active June 24, 2017 03:49
who said there is no links support in UILabel with attributed string?
#import <UIKit/UIKit.h>
@interface UILabel (TextTouch)
- (NSInteger)stringIndexUnder:(CGPoint)point;
@end
@leeprobert
leeprobert / NSUserDefaults+registerDefaultsFromSettingsBundle.m
Last active June 9, 2017 16:23
Thanks to http://ijure.org/wp/archives/179 for this code that registers the Settings bundle defaults with the NSUserDefaults class.
- (void)registerDefaultsFromSettingsBundle
{
NSLog(@"Registering default values from Settings.bundle");
NSUserDefaults * defs = [NSUserDefaults standardUserDefaults];
[defs synchronize];
NSString *settingsBundle = [[NSBundle mainBundle] pathForResource:@"Settings" ofType:@"bundle"];
if(!settingsBundle)
{
@mayoff
mayoff / makeAnimatedGif.m
Created February 16, 2013 23:00
Example of creating an animated GIF on iOS, with no 3rd-party code required. This should also be easy to port to OS X.
#import <UIKit/UIKit.h>
#import <ImageIO/ImageIO.h>
#import <MobileCoreServices/MobileCoreServices.h>
static UIImage *frameImage(CGSize size, CGFloat radians) {
UIGraphicsBeginImageContextWithOptions(size, YES, 1); {
[[UIColor whiteColor] setFill];
UIRectFill(CGRectInfinite);
CGContextRef gc = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(gc, size.width / 2, size.height / 2);
@derektu
derektu / ArchiveHelper.h
Last active June 9, 2017 16:27
Helper functions for doing object serialization (to plist file)
// ArchiveHelper.h
//
@interface ArchiveHelper : NSObject
+ (id)loadObjectFromFile:(NSString*)filePath withKey:(NSString*)key;
+ (void)saveObject:(id)object toFile:(NSString*)filePath withKey:(NSString*)key;
@end
@twobitlabs
twobitlabs / gist:4226365
Created December 6, 2012 17:35
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:
@nfarina
nfarina / UIView+FrameAdditions.h
Created August 21, 2012 06:40
UIView Frame helper getter/setter category methods
#import <UIKit/UIKit.h>
@interface UIView (SMFrameAdditions)
@property (nonatomic, assign) CGPoint $origin;
@property (nonatomic, assign) CGSize $size;
@property (nonatomic, assign) CGFloat $x, $y, $width, $height; // normal rect properties
@property (nonatomic, assign) CGFloat $left, $top, $right, $bottom; // these will stretch the rect
@end