Skip to content

Instantly share code, notes, and snippets.

@sshrpe
sshrpe / FileUpload.html
Created September 20, 2011 10:44
Javascript File upload preview
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>File Upload Preview Test</title>
<script type="text/javascript">
if (window.FileReader) {
var reader = new FileReader(), rFilter = /^(image\/bmp|image\/cis-cod|image\/gif|image\/ief|image\/jpeg|image\/jpeg|image\/jpeg|image\/pipeg|image\/png|image\/svg\+xml|image\/tiff|image\/x-cmu-raster|image\/x-cmx|image\/x-icon|image\/x-portable-anymap|image\/x-portable-bitmap|image\/x-portable-graymap|image\/x-portable-pixmap|image\/x-rgb|image\/x-xbitmap|image\/x-xpixmap|image\/x-xwindowdump)$/i;
@sshrpe
sshrpe / NSArray+ CaptainRedmuffExtensions.m
Created September 9, 2011 11:23
@CaptainRedmuff's Extensions to NSArray
// Created by Stuart Sharpe on 09/09/2011.
#import "NSArray+CaptainRedmuffExtensions.h"
@implementation NSArray (CaptainRedmuffExtensions)
- (id)firstObject;
{
if (![self count]) {
@sshrpe
sshrpe / gist:1080532
Created July 13, 2011 15:31
dateWithRFCString
static NSDateFormatter *rfcDateFormatter = nil;
+(NSDate *)dateWithRFCDate:(NSString *)rfcDate;
{
if (!rfcDateFormatter) {
rfcDateFormatter = [[NSDateFormatter alloc] init];
NSLocale *enUSPOSIXLocale = [[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"] autorelease];
[rfcDateFormatter setLocale:enUSPOSIXLocale];
[rfcDateFormatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'"];
@sshrpe
sshrpe / SMSBackgroundImageView.h
Created May 10, 2011 11:24
Background Image View, for creating views with textured backgrounds without using UIColor's memory-hogging colorWithPatternImage:
//SMSBackgroundImageView.h
#import <UIKit/UIKit.h>
@interface SMSBackgroundImageView : UIView {
}
@property (nonatomic, retain) UIImage *backgroundImage;