Skip to content

Instantly share code, notes, and snippets.

@xxd
xxd / system.rb
Last active August 29, 2015 13:55 — forked from SaitoWu/runable.rb
#0> non-block call
Thread.new do
blahbla...
end
#1> 4 simple ways to call shell or cmd
`ps aux`
#####################
# JENKINS step #1
# add to it's own execute shell section
#####################
export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer
xcodebuild -target GuildBrowserLogicTests \
-sdk iphonesimulator \
-configuration Debug \
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
@xxd
xxd / .gitignore
Created June 12, 2012 07:59
some gitignores, the one for Pod need to change YOUR_PROJECT_NAME
# Xcode
build/*
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
@xxd
xxd / CoreLocation.m
Created June 7, 2012 07:19
CoreLocation
//1.位置定位(最简单就是当前应用所有者所持设备的地理位置),主要用到的API类 CLLicationManager。
//iOS提供了一个叫作CoreLocation.framework的框架。使用他可以取到自己的定位信息(经纬度)。请参考下面代码片段
self.locationManager = [[CLLocationManager alloc]init];
if([CLLocationManager locationServicesEnabled]){
//设置代理
[self.locationManager setDelegate:self];
//设置精准度,
[self.locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[self.locationManager startUpdatingLocation];
}
@xxd
xxd / NLvsHash.rb
Created June 3, 2012 02:41
NLvsHash.rb
def intersect1(a, b)
result = []
for x in a
for y in b
result.push(x) if x == y
end
end
return result
end
@xxd
xxd / [Oracle]测试联合主键得唯一性.sql
Created May 28, 2012 15:06
[Oracle]测试联合主键得唯一性.sql
create table test1 ( col1 integer not null, col2 integer );
create index test1_col1_ix on test1 (col1);
alter table test1
add constraint test1_pk primary key (col1)
using index test1_col1_ix;
insert into test1 values (1,1);
@xxd
xxd / gist:2774188
Created May 23, 2012 09:20
performSelector -> _cmd -> objc_msgSend -> id (*IMP) (id, SEL, …)
//普通的
- (NSInteger)fibonacci:(NSInteger)n {
if (n > 2) {
return [self fibonacci:n - 1] + [self fibonacci:n - 2];
}
return n > 0 ? 1 : 0;
}
//改成用_cmd实现就变成了这样:
- (NSInteger)fibonacci:(NSInteger)n {
@xxd
xxd / NSBundle.m
Created May 17, 2012 07:04
iOS SDK控件:UITableView,UITextView,NSTimer,UISwitch,NSBundle,UIButton,UINavigation,UIImage,Segue
//*******************
// NSBundle ofType
//*******************
NSString *textUrl = [[NSBundle mainBundle] pathForResource:@"myText" ofType:@"txt"];
textView.text = [NSString stringWithContentsOfFile:textUrl encoding:NSUTF8StringEncoding error:nil];
@xxd
xxd / AZDelegationDemo.m
Created May 15, 2012 10:05
Objc语法纪录:NSSet,UIAlert&switch,Fast_Enumeration,NSString,NSArray,Delegate,ternary
// AZDelegationDemo.h
// Created by Aladdin Zhang on 8/24/11.
#import
@protocol AZDelegationDemoDelegate;
@interface AZDelegationDemo : NSObject{
idAZDelegationDemoDelegate > delegate;
NSMutableArray * shoppingList;
}
@property (nonatomic,assign) idAZDelegationDemoDelegate > delegate;