Skip to content

Instantly share code, notes, and snippets.

View troystribling's full-sized avatar

Troy Stribling troystribling

  • San Francisco, CA
View GitHub Profile
@troystribling
troystribling / UIImage+Extensions.h
Created May 28, 2012 00:18
Blank UIImage with Specified Color
#import <Foundation/Foundation.h>
@interface UIImage (Extensions)
+ (UIImage*)blankImage:(CGSize)_size;
+ (UIImage*)blankImage:(CGSize)_size withColor:(UIColor*)_color;
@end
@troystribling
troystribling / DataManager.h
Created November 19, 2012 03:12
Simple Core Data wrapper. Supports background access.
#import <Foundation/Foundation.h>
#import "NSManagedObject+DataManager.h"
@interface DataManager : NSObject
@property (nonatomic, strong, readonly) NSManagedObjectModel* managedObjectModel;
@property (nonatomic, strong, readonly) NSManagedObjectContext* managedObjectContext;
@property (nonatomic, strong, readonly) NSPersistentStoreCoordinator* persistentStoreCoordinator;
@property (nonatomic, strong) NSURL* modelURL;
@property (nonatomic, strong) NSString* persistantStoreName;
@troystribling
troystribling / gist:2941424
Created June 16, 2012 14:10
GPUImage Blending Mode example
- (UIImage*)blendedImage {
GPUImagePicture* bluredImage = [[GPUImagePicture alloc] initWithImage:self.filterImage];
GPUImageFilterGroup* blurFilterGroup = [[GPUImageFilterGroup alloc] init];
GPUImageFilter* colorOverlayfilter = [[GPUImageFilter alloc] initWithFragmentShaderFromFile:@"WhiteColorOverlay"];
GPUImageGaussianBlurFilter* gaussainBlur = [[GPUImageGaussianBlurFilter alloc] init];
[gaussainBlur setBlurSize:3.0f];
[blurFilterGroup addFilter:colorOverlayfilter];
[blurFilterGroup addFilter:gaussainBlur];
@troystribling
troystribling / gist:2936763
Created June 15, 2012 14:33
Set Title of Terminal Window
function settitle() { echo -ne "\e]2;$@\a\e]1;$@\a"; }
@troystribling
troystribling / ParameterSliderView.h
Created May 26, 2012 22:11
UIPanGesture Slider Control
#import <UIKit/UIKit.h>
@protocol ParameterSliderViewDelegate;
@interface ParameterSliderView : UIView
@property(nonatomic, weak) id<ParameterSliderViewDelegate> delegate;
@property(nonatomic, strong) UIView* parameterView;
@property(nonatomic, strong) UIView* parameterViewBorder;
@property(nonatomic, strong) UIPanGestureRecognizer* panGesture;
@troystribling
troystribling / gist:2603949
Created May 5, 2012 16:47
Load UIView from NIB
#import "NSObject+Extensions.h"
@interface UIView (Extensions)
+ (UIView*)loadView:(Class)_viewClass;
@end
@implementation UIView (Extensions)
@troystribling
troystribling / gist:2603108
Created May 5, 2012 15:01
Objective C Class Name as String
#import <objc/runtime.h>
@interface NSObject (Extensions)
- (NSString*)className;
@end
@implementation NSObject (Extensions)
@troystribling
troystribling / gist:2491439
Created April 25, 2012 17:18
Objective C Array Map
@interface NSArray (Extensions)
- (NSArray *)mapObjectsUsingBlock:(id (^)(id obj, NSUInteger idx))block;
@end
@implementation NSArray (Extensions)
- (NSArray *)mapObjectsUsingBlock:(id (^)(id obj, NSUInteger idx))block {
NSMutableArray *result = [NSMutableArray arrayWithCapacity:[self count]];
@troystribling
troystribling / symbolize_keys.rb
Created January 11, 2012 20:43
Recursive symbolize_keys
def symbolize_keys!(thing)
case thing
when Array
thing.each{|v| symbolize_keys!(v)}
when Hash
thing.symbolize_keys!
thing.values.each{|v| symbolize_keys!(v)}
end
end
@troystribling
troystribling / ebs_snap.rb
Created December 30, 2011 16:57
Take snaps of EBS volumes with Fog
#!/usr/bin/env ruby
require 'rubygems'
require 'fog'
config = YAML.load(File.read(ARGV[0]))
volumes_to_snap = YAML.load(File.read(ARGV[1]))
time = Time.now
puts "\nCreating snaps #{time.to_s}"