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)drawNoiseWithOpacity:(CGFloat)opacity inRect:(CGRect)rect{ | |
static UIImage *noiseImage = nil; | |
static dispatch_once_t oncePredicate; | |
dispatch_once(&oncePredicate, ^{ | |
NSUInteger width = 64, height = 64; | |
NSUInteger size = width*height; | |
char *rgba = (char *)malloc(size); srand(124); | |
for(NSUInteger i=0; i < size; ++i){rgba[i] = rand()%256;} | |
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray(); | |
CGContextRef bitmapContext = |
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> | |
@interface SNFadeScrollView : UIScrollView | |
@property (nonatomic) BOOL fadeTop; | |
@property (nonatomic) BOOL fadeBottom; | |
@end |
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 os, sys | |
import shutil, fnmatch | |
root = os.path.dirname(os.path.realpath(__file__)) | |
locations = { | |
'Localizable': os.path.join(root, 'Localization'), | |
'Root': os.path.join(root, 'Settings.bundle'), | |
} |
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 os | |
import re | |
import sys | |
projectRoot = sys.argv[1] | |
imageNamedRegex = re.compile('Named:@"([^"]+)"') | |
resourceRegEx = re.compile('<string key="NSResourceName">([^<]+)</string>') | |
def rootImageName(imageName): | |
imageName = re.sub('.png$', '', imageName) |
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
+ (UIImage *)iconWithFont:(UIFont *)font named:(NSString *)iconNamed forSize:(CGFloat)fontSize{ | |
static NSCache *cache = nil; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
cache = [[NSCache alloc] init]; | |
}); | |
NSString *identifier = [NSString stringWithFormat:@"%@%@%f", font.fontName, iconNamed, fontSize]; | |
UIImage *image = [cache objectForKey:identifier]; | |
if(image == nil){ |
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 sys, os | |
sys.path.insert(0, os.path.join(os.path.dirname( __file__ ), 'ParsePy')) | |
from parse_rest.user import User as PFUser | |
from parse_rest.datatypes import Object as PFObject | |
from parse_rest.installation import Installation as PFInstallation | |
from parse_rest.connection import register as PFRegister | |
from parse_rest.connection import ParseBatcher as PFBatcher | |
PFRegister(PARSE_APPLICATION_ID, PARSE_REST_API_KEY, master_key=PARSE_MASTER_KEY) |
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 os | |
import re | |
import sys | |
projectRoot = sys.argv[1] | |
imageNamedRegex = re.compile('Named:@"([^"]+)"') | |
resourceRegEx = re.compile('<string key="NSResourceName">([^<]+)</string>') | |
def rootImageName(imageName): | |
imageName = re.sub('.png$', '', imageName) |
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
CGFloat distance = 10; | |
// Center two views side-by-side | |
[parentItem addConstraint:[NSLayoutConstraint constraintWithItem:leftItem attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationLessThanOrEqual toItem:parentItem attribute:NSLayoutAttributeCenterX multiplier:1 constant:-distance]]; | |
[parentItem addConstraint:[NSLayoutConstraint constraintWithItem:rightItem attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationLessThanOrEqual toItem:parentItem attribute:NSLayoutAttributeCenterX multiplier:1 constant:distance]]; | |
// Center two views, one ontop of the other | |
[parentItem addConstraint:[NSLayoutConstraint constraintWithItem:topItem attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationLessThanOrEqual toItem:parentItem attribute:NSLayoutAttributeCenterY multiplier:1 constant:-distance]]; | |
[parentItem addConstraint:[NSLayoutConstraint constraintWithItem:bottomItem attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationLessThanOrEqual toItem:parentItem attribute:NSLayoutAttributeCenterY multiplier |
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
#!/usr/bin/env python | |
try: | |
# For Python 3.0 and later | |
from urllib.request import urlopen | |
except ImportError: | |
# Fall back to Python 2's urllib2 | |
from urllib2 import urlopen | |
import json |
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 twitterUser: String? | |
if let data = serverResponse { | |
if let json = try? NSJSONSerialization.JSONObjectWithData(data, options: []) as? [String: AnyObject] { | |
if let user = json?["user"] as? [String: AnyObject] { | |
if let accounts = user["accounts"] as? [AnyObject] { | |
if let twitter = accounts.first as? [String: AnyObject] { | |
twitterUser = twitter["user"] as? String | |
} | |
} | |
} |