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
#define is_iPad ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ) | |
#define is_iPhone ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone ) | |
#define is_iPhone5 ( is_iPhone && [[UIScreen mainScreen] bounds].size.height == 568.0f ) | |
#define is_Retina ( [[UIScreen mainScreen] scale] == 2.0f ) |
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
#define __FILE_NAME__ [[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String] | |
#ifdef DEBUG | |
#define DLog( s, ... ) NSLog( @"%s:%d %s %@", \ | |
__FILE_NAME__, \ | |
__LINE__, \ | |
__PRETTY_FUNCTION__, \ | |
[NSString stringWithFormat:(s), ##__VA_ARGS__] ) |
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 Foundation | |
class HttpClient: NSObject { | |
let logging = true | |
let session = NSURLSession.sharedSession() | |
func makeRequest(request: NSURLRequest, completionHandler: (NSDictionary?, NSURLResponse?, NSError?) -> Void) { | |
logRequest(request) |
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
double d = 2.0f; // Delay | |
dispatch_time_t t = dispatch_time(DISPATCH_TIME_NOW, d * NSEC_PER_SEC); | |
dispatch_after(t, dispatch_get_main_queue(), ^(void){ | |
// Call any function | |
}); |
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 randomHexColor() { | |
var v = ( Math.floor( Math.random() * 0xFFFFFF ) ).toString(16); | |
while ( v.length < 6 ) { v = '0' + v; } | |
return ( '#' + v ); | |
} |
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
// Product of list | |
func product(list: [Double]) -> Double { | |
return list.reduce(1, combine: *) | |
} | |
// Sum of list | |
func sum(list: [Int]) -> Int { | |
return list.reduce(0, combine: +) | |
} |
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
// | |
// String 1.0 | |
// Created by Caleb Hess on 2/22/16. | |
// | |
public extension String { | |
public var count: Int { | |
return self.characters.count | |
} |
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
extension UIImage { | |
convenience init?(color: UIColor, size: CGSize = CGSizeMake(1, 1)) { | |
let rect = CGRectMake(0, 0, size.width, size.height) | |
UIGraphicsBeginImageContextWithOptions(rect.size, false, 0) | |
let context = UIGraphicsGetCurrentContext() | |
CGContextSetFillColorWithColor(context, color.CGColor) | |
CGContextFillRect(context, rect) | |
self.init(CGImage: UIGraphicsGetImageFromCurrentImageContext().CGImage!) | |
UIGraphicsEndImageContext() |
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
// | |
// Swift-KVO | |
// | |
// Created by Jim Correia on 6/5/14. | |
// Copyright (c) 2014-2015 Jim Correia. All rights reserved. | |
// | |
// Update: 6/17/2014 | |
// | |
// KVOContext has gone away; use the same idiom you'd use from Objective-C for the context | |
// |
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
#!/bin/sh | |
if [ -z $1 ]; then | |
echo "Usage: ${0} file" | |
exit -1 | |
fi | |
cat $1 | \ | |
grep .pf- | \ | |
sed -e 's/.pf-//g' | \ |
OlderNewer