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
//
// UIView+DEFrameAdditions.h
//
// Copyright (c) 2011-2013 Double Encore, Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
// Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
// Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the distribution. Neither the name of the Double Encore Inc. nor the names of its
// contributors may be used to endorse or promote products derived from this software without specific prior written permission.
@cokecoffe
cokecoffe / Bee_Singleton.h
Created March 26, 2013 12:49
Oc Singleton define
//
// ______ ______ ______
// /\ __ \ /\ ___\ /\ ___\
// \ \ __< \ \ __\_ \ \ __\_
// \ \_____\ \ \_____\ \ \_____\
// \/_____/ \/_____/ \/_____/
//
// Copyright (c) 2012 BEE creators
// http://www.whatsbug.com
//
@cokecoffe
cokecoffe / gist:5139744
Created March 12, 2013 02:13
dispatch queue demo
//
// UXAppDelegate.m
// Dispatch_queue
//
// Created by wang keke on 13-3-11.
// Copyright (c) 2013年 uxin. All rights reserved.
//
#import "UXAppDelegate.h"
@cokecoffe
cokecoffe / gist:5028073
Last active December 14, 2015 04:28
Save and Load UIImage in Documents directory on iPhone
//The following function saves UIImage in test.png file in the user Document folder:
- (void)saveImage: (UIImage*)image
{
if (image != nil)
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString* path = [documentsDirectory stringByAppendingPathComponent:
[NSString stringWithString: @"test.png"] ];
#import <Foundation/Foundation.h>
#import "AFHTTPClient.h"
@interface APIClient : AFHTTPClient
+ (APIClient *)sharedClient;
@end
@cokecoffe
cokecoffe / gist:4592912
Last active December 11, 2015 11:18
GCD
//创建一个下载队列
dispatch_queue_t downloadQueue = dispatch_queue_create("flickr downloader", NULL);
dispatch_async(downloadQueue, ^{
//在这里做一些需要资源的任务
//分发两个行队列,分别执行do_first_work,do_second_work
dispatch_group_t group = dispatch_group_create();
dispatch_group_async(group,dispatch_get_global_queue(0,0),^{
do_frist_work();