Skip to content

Instantly share code, notes, and snippets.

//
// NSObject+subscripts.h
// Created by Martin Santiago on 7/26/12.
//
#import <Foundation/Foundation.h>
// Add support for subscripting to the iOS 5 SDK.
#if __IPHONE_OS_VERSION_MAX_ALLOWED < 60000
@interface NSObject (subscripts)
@codeswimmer
codeswimmer / gist:3374678
Created August 17, 2012 00:03
TCP Streaming for iOS
#import <UIKit/UIKit.h>
@interface TESTStreamDelegate : NSObject <NSStreamDelegate>
@property (strong, nonatomic) NSInputStream *inputStream;
@property (strong, nonatomic) NSOutputStream *outputStream;
- (void) request;
@end
@codeswimmer
codeswimmer / CRTransparentSearchFieldCell.h
Created August 15, 2012 19:54 — forked from dchest/CRTransparentSearchFieldCell.h
CRTransparentSearchFieldCell -- transparent search field cell
#import <Cocoa/Cocoa.h>
@interface CRTransparentSearchFieldCell : NSSearchFieldCell {
BOOL _hasText;
}
@end
@codeswimmer
codeswimmer / shake.m
Created August 15, 2012 18:24 — forked from localshred/gist:3362147
View shake
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"];
[animation setDuration:0.08];
[animation setRepeatCount:3];
[animation setAutoreverses:YES];
[animation setFromValue:[NSValue valueWithCGPoint:
CGPointMake([formContainer center].x - 20.0f, [formContainer center].y)]];
animation setToValue:[NSValue valueWithCGPoint:
CGPointMake([formContainer center].x + 20.0f, [formContainer center].y)]];
[[formContainer layer] addAnimation:animation forKey:@"position"];
@codeswimmer
codeswimmer / gist:3360314
Created August 15, 2012 13:51 — forked from joshavant/gist:3355530
Apple-safe UUID Generation
// requires UICKeyChainStore lib
NSString *uniqueIdentifier;
#if TARGET_IPHONE_SIMULATOR
uniqueIdentifier = @"SIMULATOR";
#else
uniqueIdentifier = [UICKeyChainStore stringForKey:@"UUID" service:@"joshavant"];
if(![uniqueIdentifier length] > 0)
@codeswimmer
codeswimmer / gradient.m
Created August 15, 2012 03:40 — forked from taylortrimble/gradient.m
Radial Gradient
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
const CGFloat components[8] = {0.0, 0.4, 0.0, 1.0,
0.0, 0.4, 0.0, 1.0};
const CGFloat locations[2] = {0.0, 1.0};
CGGradientRef gradient = CGGradientCreateWithColorComponents(colorSpace, components, locations, 2);
@codeswimmer
codeswimmer / NSString+OVSSTimeAdditions.h
Created August 15, 2012 02:04
NSString+OVSSTimeAdditions - A Category on NSString that properly formats durations in hours, minutes, and seconds
//
// NSString+OVSSTimeAdditions.h
//
//
// Created by Owen Voorhees on 3/22/11.
// Copyright 2011 Owen Voorhees. All rights reserved.
//
#import <Foundation/Foundation.h>
@codeswimmer
codeswimmer / gist:3352988
Created August 14, 2012 20:58 — forked from chrisballinger/gist:3352890
Fuzzy string match objective-c (Levenshtein Distance Algorithm)
-(float)compareString:(NSString *)originalString withString:(NSString *)comparisonString
{
// Normalize strings
[originalString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
[comparisonString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
originalString = [originalString lowercaseString];
comparisonString = [comparisonString lowercaseString];
// Step 1 (Steps follow description at http://www.merriampark.com/ld.htm)
@codeswimmer
codeswimmer / zombie.c
Created August 13, 2012 20:51 — forked from akahn/zombie.c
Simulate a zombie process on Linux
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
int main ()
{
pid_t child_pid;
child_pid = fork ();
if (child_pid > 0) {
@codeswimmer
codeswimmer / DE12_800px_infographic.html
Created August 13, 2012 11:56
Developer Economics 2012 - The Rise of the New App Economy - 800px infographic
<p><a href="http://www.visionmobile.com/blog/2012/08/the-rise-of-the-new-app-economy/" mce_href="http://www.visionmobile.com/blog/2012/08/the-rise-of-the-new-app-economy/"><img src="http://www.visionmobile.com/uploads/infographics/8/VMInfographic_DE12_800.png" mce_src="http://www.visionmobile.com/uploads/infographics/8/VMInfographic_DE12_800.png" border="0" alt="Developer Economics 2012 - The Rise of the New App Economy" /></a></p>