This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), { | |
// do some task(s) on a separate thread from UI | |
dispatch_async(dispatch_get_main_queue()) { | |
// update some UI on the UI thread | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(NSString *) reverseString: stringToReverse { | |
NSMutableString *reversedString = [NSMutableString string]; | |
NSInteger charIndex = [stringToReverse length]; | |
while (charIndex > 0) { | |
charIndex--; | |
NSRange subStrRange = NSMakeRange(charIndex, 1); | |
[reversedString appendString:[stringToReverse substringWithRange:subStrRange]]; | |
} | |
return reversedString |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
@class SomeViewController; | |
@protocol SomeViewControllerDelegate <NSObject> | |
-(void)delegateMethodName: (SomeViewController *) controller; | |
@end | |
@interface SomeViewController : UIViewController |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(BOOL) isValidEmail:(NSString *)checkString | |
{ | |
BOOL stricterFilter = NO; // Discussion http://blog.logichigh.com/2010/09/02/validating-an-e-mail-address/ | |
NSString *stricterFilterString = @"[A-Z0-9a-z\\._%+-]+@([A-Za-z0-9-]+\\.)+[A-Za-z]{2,4}"; | |
NSString *laxString = @".+@([A-Za-z0-9-]+\\.)+[A-Za-z]{2}[A-Za-z]*"; | |
NSString *emailRegex = stricterFilter ? stricterFilterString : laxString; | |
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex]; | |
return [emailTest evaluateWithObject:checkString]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function convertBase64toImage(id, image64) { | |
var canvas = document.createElement(id); | |
var context = canvas..getContext('2d'); | |
var baseImage = new Image(); | |
baseImage.onload() = function() { | |
context.drawImage(baseImage, 0, 0); | |
}; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function convertImgToBase64(id, outputFormat){ | |
var canvas = document.createElement(id); | |
var imageDataURL = canvas.toDataURL(outputFormat || 'image/png'); | |
return imageDataURL; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
// using $.fn.extend allows us to expand on jquery | |
$.fn.extend({pluginName:function(options){ | |
// save a link to your instance | |
var plugin = this; | |
var defaultOptions = { | |
// add what you know are default values for your options | |
}; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Created by Dennis White | |
// Copyright (c) 2014 dniswhite. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
@interface SingletonManager : NSObject | |
+(id) sharedSingletonManager; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Timer(callback, delay) { | |
if (!isNaN(delay) && callback) { | |
if (delay < 1000) delay = 1000; | |
this.delay = delay; | |
this.callback = callback; | |
var running = false; | |
this.ticker = function (a) { |