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
class GPolyDecoder(object): | |
def decode(self, encodedString): | |
index = 0 | |
length = len(encodedString) | |
lat = 0 | |
lng = 0 | |
poly_lines = [] | |
while index < length: | |
b = 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
let mirror = reflect(objectInstance) | |
for index in 0 ..< mirror.count { | |
let (childKey, childMirror) = mirror[index] | |
println("key is \(childKey)") | |
println("value is \(childMirror.value)") | |
println("valuetype is \(childMirror.valueType)") | |
} |
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
let kGlobalDateFormatterSharedInstance = GlobalDateFormatterModel() | |
class GlobalDateFormatterModel: NSObject { | |
@lazy var defaultDomainDateFormatter: NSDateFormatter = self.initializeDefaultDomainDateFormatter() | |
class var sharedInstance:GlobalDateFormatterModel { | |
return kGlobalDateFormatterSharedInstance | |
} | |
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
-(void)quickSortArray:(NSMutableArray*)array fromLeftIndex:(NSUInteger)leftIndex toRightIndex:(NSUInteger)rightIndex{ | |
NSUInteger chosenPivot = 0; | |
if (leftIndex == 0 && rightIndex == 0) | |
rightIndex = array.count - 1; | |
chosenPivot = leftIndex + ceil((rightIndex - leftIndex) * 0.5); |
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
-(void)bubbleSortArray:(NSMutableArray*)unsortedArray{ | |
while (TRUE) { | |
BOOL hasSwapped = NO; | |
for (int i=0; i<unsortedArray.count; i++){ | |
/** out of bounds check */ | |
if (i < unsortedArray.count-1){ |
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
#include <QuartzCore/QuartzCore.h> | |
@implementation UIView (Raster) | |
-(UIImage*)getRasterCopy{ | |
/* returns UIImage of any UIView */ | |
UIGraphicsBeginImageContextWithOptions(self.bounds.size, self.opaque, 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
void globalResignKeyboard(void){ | |
UIWindow * window = [[UIApplication sharedApplication] keyWindow]; | |
for (UIView * view in [window subviews]){ | |
resignKeyboardInSubviewsOfView(view); | |
} | |
} | |
void resignKeyboardInSubviewsOfView(UIView* view){ | |
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 isDarkImage(UIImage* inputImage){ | |
BOOL isDark = FALSE; | |
CFDataRef imageData = CGDataProviderCopyData(CGImageGetDataProvider(inputImage.CGImage)); | |
const UInt8 *pixels = CFDataGetBytePtr(imageData); | |
int darkPixels = 0; | |
int length = CFDataGetLength(imageData); |
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
float bottomNonAlphaPixel(UIImage* inputImage){ | |
float bottomNonAlphaPixel = 0; | |
float const neighboringPixelThreshold = 4; | |
CFDataRef imageData = CGDataProviderCopyData(CGImageGetDataProvider(inputImage.CGImage)); | |
const UInt8 *pixels = CFDataGetBytePtr(imageData); | |
UInt8 alphaThreshold = 20; | |
int bytesPerPixel = 4; | |