Skip to content

Instantly share code, notes, and snippets.

View cokecoffe's full-sized avatar
💭
I may be slow to respond.

cokecoffe cokecoffe

💭
I may be slow to respond.
View GitHub Profile
@cokecoffe
cokecoffe / .gitignore
Last active August 29, 2015 14:11 — forked from adamgit/.gitignore
#########################
# .gitignore file for Xcode4 and Xcode5 Source projects
#
# Apple bugs, waiting for Apple to fix/respond:
#
# 15564624 - what does the xccheckout file in Xcode5 do? Where's the documentation?
#
# Version 2.3
# For latest version, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
#
@cokecoffe
cokecoffe / gist:c560263d274cb254fc28
Created September 4, 2014 07:10
NSDictionary (SafeObjectForKey)
@interface NSDictionary (SafeObjectForKey)
- (id) safeObjectForKey:(id)aKey;
@end
@implementation NSDictionary (SafeObjectForKey)
- (id) safeObjectForKey:(id)aKey
{
id obj = [self objectForKey: aKey];
+ (NSString *)md5:(NSString *)str
{
const char *cStr = [str UTF8String];
unsigned char result[16];
CC_MD5(cStr, strlen(cStr), result); // This is the md5 call
return [NSString stringWithFormat:
@"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
result[0], result[1], result[2], result[3],
result[4], result[5], result[6], result[7],
result[8], result[9], result[10], result[11],
@cokecoffe
cokecoffe / version auto
Created March 20, 2014 13:28
iOS/Xcode/build script
1.把TODO,FIXME等注释转化为编译结果中的警告
#!/bin/sh
# 把TODO,FIXME等注释转化为编译结果中的警告
# by Kellen Styler
# via: http://d3signerd.com/turn-fixme-todo-and-comments-into-compiler-warnings/
KEYWORDS="TODO:|FIXME:|\?\?\?:|\!\!\!:"
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/ warning: \$1/"
2.编译时自增构建数
#!/bin/sh
@cokecoffe
cokecoffe / GUID
Created March 14, 2014 08:29
生成唯一标识,可以作为文件或路径名。
+ (NSString *)GUID
{
CFUUIDRef theUUID = CFUUIDCreate(NULL);
CFStringRef theString = CFUUIDCreateString(NULL, theUUID);
NSString *unique = [NSString stringWithString:(__bridge id)theString];
CFRelease(theString); CFRelease(theUUID); // Cleanup CF objects
#import <Foundation/Foundation.h>
@interface MyCalendar : NSObject
+ (void)requestAccess:(void (^)(BOOL granted, NSError *error))success;
+ (BOOL)addEventAt:(NSDate*)eventDate withTitle:(NSString*)title inLocation:(NSString*)location;
@end
@cokecoffe
cokecoffe / DateCompare
Created December 24, 2013 14:50
DateCompare
#import <Foundation/Foundation.h>
@interface NSDate (Between)
- (BOOL)isBetweenDate:(NSDate*)beginDate andDate:(NSDate*)endDate;
- (BOOL)isEarlyThanDate:(NSDate*)date;
- (BOOL)isLaterThanDate:(NSDate*)date;
@end
@cokecoffe
cokecoffe / tableviewcell border
Created July 10, 2013 07:25
remove border of tableviewcell (group style)
//去掉group cell的边框
UIView *tempView = [[[UIView alloc] init] autorelease];
[self.photoCell setBackgroundView:tempView];
[self.photoCell setBackgroundColor:[UIColor clearColor]];
@cokecoffe
cokecoffe / versionHelper
Last active December 18, 2015 16:29
Version check Tools
//将版本字符串转换为数字
+(int)getVersionNumber:(NSString*)version
{
int versionNo = 0;
NSArray *arr = [version componetsSeparateByString:@"."];
int count = arr.count;
for(NSString *no in arr)
{
#if NS_BLOCKS_AVAILABLE
typedef void (^CompletionBlock)(NSString* result);
typedef void (^FailedBlock)(NSError* error);
#endif
@interface ImageUploader : NSObject {
NSData *theImage;
CompletionBlock completeblock;
FailedBlock failedblock;
}