Skip to content

Instantly share code, notes, and snippets.

@cocoajin
cocoajin / no_NSLog_Define.h
Created October 23, 2014 09:23
mac,ios 项目屏蔽日志输出的宏
//其中 __OPTIMIZE__ 为 项目在 release模式下
#ifndef __OPTIMIZE__
# define NSLog(...) NSLog(__VA_ARGS__)
#else
# define NSLog(...) {}
#endif
@cocoajin
cocoajin / urllib2_http_cookielib.py
Last active August 29, 2015 14:06
urllib2 http post 请求,cookie 管理
import urllib
import urllib2
import cookielib
def login():
url = "https://whatever.com/login.php"
opts = {
'email': 'emailaddr',
'pass': 'password',
}
@cocoajin
cocoajin / httplib_http_post_get.py
Last active August 29, 2015 14:06
httplib http post,get, 请求
#coding=utf-8
'''
Created on 2014年9月25日
@author: cocoajin
'''
import httplib,urllib
base='httpbin.org' #不需要添加 "http://"
@cocoajin
cocoajin / httplib_https_post.py
Last active August 29, 2015 14:06
httplib https post 请求
#coding=utf-8
'''
Created on 2014年9月17日
@author: cocoajin
test
'''
@cocoajin
cocoajin / UIAlertView_input.m
Last active August 29, 2015 14:04
限制AlertView输入框输入的字数
// Show a secure text entry alert with two custom buttons.
- (void)showSecureTextEntryAlert {
NSString *title = NSLocalizedString(@"A Short Title Is Best", nil);
NSString *message = NSLocalizedString(@"A message should be a short, complete sentence.", nil);
NSString *cancelButtonTitle = NSLocalizedString(@"Cancel", nil);
NSString *otherButtonTitle = NSLocalizedString(@"OK", nil);
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title message:message delegate:self cancelButtonTitle:cancelButtonTitle otherButtonTitles:otherButtonTitle, nil];
alert.alertViewStyle = UIAlertViewStyleSecureTextInput;
@cocoajin
cocoajin / ios_app_upload_needs_image.txt
Last active December 1, 2017 02:10
iOS 上传所需基本图片尺寸
/*
iOS上传所需基本图片
icon
● Icon.png – 57×57 iPhone应用图标
● Icon@2x.png – 114×114 iPhone Retina显示屏应用图标
● Icon-72.png – 72×72 iPad应用图标
@cocoajin
cocoajin / ASIHTTPRequest_config.txt
Last active February 19, 2017 04:23
ASIHttpRequest配置
/*
安装:配置
1:所需frame.work;
CFNetwork, SystemConfiguration, MobileCoreServices, CoreGraphics and libz.dylib libxml2.dylib
3: 删除 Tests文件夹里面的测试
2: ASI Tests 需要 https://github.com/gh-unit/gh-unit/tree/master 然后导入 :GHUnitIOS.framework
3:bulid setting Header search path 添加 /usr/include/libxml2
4:在 test/ASIDataCompareTest.m中有个 NStask错误,删除文件即可;
5: 如果使用 Test文件加里面的东西,使用 GHUnitIOS.framework http://stackoverflow.com/questions/13925437/ghunitios-ghunit-h-file-not-found-in-xcode
@cocoajin
cocoajin / NSClass_From_NSString.m
Last active December 26, 2015 04:49
创建一个类从NSString字条串
NSString *className = [item[kItemKeyClassPrefix] stringByAppendingString:@"ViewController"];
if (NSClassFromString(className)) {
Class aClass = NSClassFromString(className);
id instance = [[aClass alloc] init];
if ([instance isKindOfClass:[UIViewController class]]) {
[(UIViewController *)instance setTitle:item[kItemKeyTitle]];
@cocoajin
cocoajin / gist:7096055
Created October 22, 2013 06:30
字典数组的[]写法
//字典数组的[]写法
NSArray *aArray = [[NSArray alloc]init];
aArray = @[
//dic 1
@{@"key1": @"object1",
@"key2": @"object2",
},
//dic 2
@{@"key1": @"object1",
@"key2": @"object2",