Skip to content

Instantly share code, notes, and snippets.

View sosoyososo's full-sized avatar

Karsa.Wang sosoyososo

View GitHub Profile
@sosoyososo
sosoyososo / gist:5193123
Created March 19, 2013 02:05
Objective-C 使用AFHttpWorking进行OAuth2.0 的 github 认证
AFHTTPClient *post = [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:@"https://api.github.com"]];
[post setAuthorizationHeaderWithUsername:@"" password:@""];
post.parameterEncoding = AFJSONParameterEncoding;
[post postPath:@"authorizations"
parameters:@{@"Scopes":@[@"public_repo",@"repo"],@"note":@"admin script"}
success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSString *responseStr = [[NSString alloc] initWithData:responseObject encoding:4];
NSLog(@"success : %@", responseStr);
}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
@sosoyososo
sosoyososo / gist:5418189
Created April 19, 2013 04:41
catch NSException and output info
void handleException(NSException *exception) {
NSString *exceptionString = [NSString stringWithFormat:@"NSException : %@", [exception description]];
NSArray *arrsy = [exception callStackSymbols];
NSLog(@"//////////////////////////////////////////////////////////////////////////////////////////");
NSLog (@"%@ : %@", exceptionString, arrsy);
NSLog(@"//////////////////////////////////////////////////////////////////////////////////////////");
}
@sosoyososo
sosoyososo / gist:6085275
Last active December 20, 2015 06:19
查询一个目录下面所有.h.m.mm文件中class的对应关系,理出类的层次
#1.遍历某个路径的子目录
#2.按行读取头文件和源文件
#3.找到对应关系行
#4.判断是否在注释范围内
#5.分析并存储关系
import os, os.path, re, sys
_g_relations = {}
_g_graphRelations = {}
@sosoyososo
sosoyososo / gist:6137793
Created August 2, 2013 06:03
立方体旋转的动画代码
CATransition *animation = [CATransition animation];
animation.duration = 2.0;
animation.type = @"cube";
animation.subtype = kCATransitionFromRight;
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
[sender removeFromSuperview];
if ([sender isEqual:self.button1]) {
[self.animationView addSubview:self.button2];
} else {
[self.animationView addSubview:self.button1];
@sosoyososo
sosoyososo / gist:6152825
Last active December 20, 2015 15:18
随着触点移动画图
- (CGFloat)strokeWidth {
if (_strokeWidth < 0.0001) {
_strokeWidth = 5.f;
}
return _strokeWidth;
}
- (UIColor *)strokeColor {
if (!_strokeColor) {
_strokeColor = [UIColor redColor];
@sosoyososo
sosoyososo / gist:6610716
Created September 18, 2013 15:18
python:递归输出一个数组的全排列
def pickOne (array1, array2) :
length = len (array2)
if length == 0 :
return
for i in range (0, length) :
tempArray1 = array1[:]
tempArray2 = array2[:]
moveArrayItem (tempArray1, tempArray2, i)
print (tempArray1)
pickOne (tempArray1, tempArray2)
@sosoyososo
sosoyososo / gist:6610758
Created September 18, 2013 15:21
python : 遍历一个目录下所有.h/.m/.mm 文件,并整理出来类的继承关系
#1.遍历某个路径的子目录
#2.按行读取头文件和源文件
#3.找到对应关系行
#4.判断是否在注释范围内
#5.分析并存储关系
import os, os.path, re, sys
_g_relations = {}
_g_graphRelations = {}
@sosoyososo
sosoyososo / gist:6611926
Created September 18, 2013 16:43
python:生成一个graph中的节点,并建立各个节点之间的关系,实现对graph的遍历,对graph的copy#def Graph struct
class Node():
index = 0
neighbors = []
def __init__(self, arg):
self.index = arg
def description(self):
out = []
out.append (self.index)
for item in self.neighbors:
out.append(item.index)
@sosoyososo
sosoyososo / gist:6619980
Last active December 23, 2015 10:09
python:对graph新的copy方法
class Node():
index = 0
neighbors = []
def __init__ (self, arg) :
self.index = arg
def description(self):
out = []
out.append (self.index)
for item in self.neighbors:
@sosoyososo
sosoyososo / gist:6620318
Created September 19, 2013 07:55
python:回文数字判断
i = 1281854581821
def getMax(num):
if num < 10:
return num
return getMax(num/10)
def isLastEqualFirst (num) :
if num < 10 :
return YES