Skip to content

Instantly share code, notes, and snippets.

View veritech's full-sized avatar

Jonathan Dalrymple veritech

View GitHub Profile
@veritech
veritech / CertConvertor.sh
Created February 10, 2011 11:42
Simple script to convert p12 files to pem files for use with Apple's push notification service
#!/bin/bash
# Simple script to convert p12 -> pem files
# Depends on openssl
# Params
# $1 Certificate File
# $2 Key File
if [ $# -lt 2 ]
then
echo "Bad number of arguments"
/*
File: GetPathsOperation.m
Abstract: NSOperation code for directory and file enumeration.
Version: 1.2
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
Inc. ("Apple") in consideration of your agreement to the following
terms, and your use, installation, modification or redistribution of
this Apple software constitutes acceptance of these terms. If you do
@veritech
veritech / gist:912338
Created April 10, 2011 13:25
Drawing text with a gradient
UIColor *gradientPattern;
NSString *text;
//The text to draw
text = @"Ultra cool text, the designer insisted on";
//Load the gradient from disk as a color
gradient = [UIColor colorWithPatternImage:[UIImage imageNamed:@"gradient.png"]];
//Draw
@veritech
veritech / gist:912683
Created April 10, 2011 20:09
Getting a full image from a ALAsset
-(UIImage*) imageForAsset:(ALAsset*) aAsset{
ALAssetRepresentation *rep;
rep = [aAsset defaultRepresentation];
return [UIImage imageWithCGImage:[rep fullResolutionImage]];
}
@veritech
veritech / CALayer.m
Created April 12, 2011 12:24
Using CAKeyFrameAnimation to animate images in a CALayer
//Create the layer
layer = [CALayer layer];
//Configure the animation
animation = [CAKeyframeAnimation animationWithKeyPath:@"contents"];
[animation setCalculationMode:kCAAnimationDiscrete];
[animation setDuration:2.0f];
[animation setRepeatCount:HUGE_VALF];
@veritech
veritech / NSManagedObjectContext+blocks.m
Created May 9, 2011 04:21
NSMangedObjectContext async fetch requests
#import <Foundation/Foundation.h>
typedef void (^NSManagedObjectContextFetchCompleteBlock)(NSArray* results);
typedef void (^NSManagedObjectContextFetchFailBlock)(NSError *error);
@interface NSManagedObjectContext (NSManagedObjectContext_blocks)
-(void)executeFetchRequestInBackground:(NSFetchRequest*) aRequest
onComplete:(NSManagedObjectContextFetchCompleteBlock) completeBlock
@veritech
veritech / gist:962050
Created May 9, 2011 04:26
Sample request
[[self managedObjectContext] executeFetchRequestInBackground:request
onComplete:^(NSArray *results){
DebugLog(@"Results %@", results);
}
onError:^(NSError *error){
DebugLog(@"Error %@", error);
}
];
@veritech
veritech / gist:1115226
Created July 30, 2011 05:20
Auto-incrementing versioning numbers
# XCode 4 auto-versioning script for Git
# Inspired by the work of Axel Andersson, Marcus S. Zarra and Matt Long
# http://valthonis.net/u/19
"""
NOTE: Due to its use of build environment variables, this
script will only work from inside XCode's build process!
"""
import os
@veritech
veritech / gist:1200110
Created September 7, 2011 09:06
UIImages with rounded corners
//Create a pill with the given rect
- (CGPathRef) newPathForRoundedRect:(CGRect)rect radius:(CGFloat)radius
{
CGMutablePathRef retPath = CGPathCreateMutable();
CGRect innerRect = CGRectInset(rect, radius, radius);
CGFloat inside_right = innerRect.origin.x + innerRect.size.width;
CGFloat outside_right = rect.origin.x + rect.size.width;
CGFloat inside_bottom = innerRect.origin.y + innerRect.size.height;
@veritech
veritech / gist:1200259
Created September 7, 2011 10:45
Making UIImages with blocks
-(UIImage*) imageWithSize:(CGSize) aSize block:(void(^)(CGContextRef ctx)) aBlock{
CGContextRef context;
void *bitmapData;
CGColorSpaceRef colorSpace;
int bitmapByteCount;
int bitmapBytesPerRow;
CGImageRef image;
UIImage *finalImage;