Skip to content

Instantly share code, notes, and snippets.

@hashmaparraylist
hashmaparraylist / init_empty_git.sh
Created September 7, 2014 08:48
新建一个空的GIT仓库
cd /opt/git
mkdir project.git
cd project.git
git --bare init
@hashmaparraylist
hashmaparraylist / label.m
Created January 11, 2015 13:00
UILabel设置border
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 35)];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 15, 320, 20)];
CALayer *bottomBorder = [CALayer layer];
bottomBorder.frame = CGRectMake(0, 40, 320, .5);
CALayer *rightBorder = [CALayer layer];
rightBorder.frame = CGRectMake(320, 0, 40, .5);
CALayer *topBorder = [CALayer layer];
@hashmaparraylist
hashmaparraylist / location.m
Created May 16, 2015 14:07
iOS 7.0 Location Service授权方法
CLAuthorizationStatus authStatus = [CLLocationManager authorizationStatus];
if (authStatus == kCLAuthorizationStatusNotDetermined) {
// _locationManager is CLLocationManager
[_locationManager requestWhenInUseAuthorization];
return;
} else if (authStatus == kCLAuthorizationStatusDenied || authStatus == kCLAuthorizationStatusRestricted) {
// show location services denied alert
return;
}
@hashmaparraylist
hashmaparraylist / getPhoto.m
Created May 16, 2015 14:54
从相机或是相册选取照片
#pragma mark - UIActionSheetDelegate
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) {
[self takePhoto];
} else if (buttonIndex == 1) {
[self choosePhotoFromLibrary];
}
}
@hashmaparraylist
hashmaparraylist / fxxk.m
Created June 30, 2015 17:08
简直亲妈爆炸。
- (RACSignal *)authorizeToGithubUsingOauth {
__weak GitHubClient *weakSelf = self;
RACSignal *authorizeSignal = [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
CFUUIDRef uuid = CFUUIDCreate(NULL);
NSString *uuidString = CFBridgingRelease(CFUUIDCreateString(NULL, uuid));
CFRelease(uuid);
NSCharacterSet *slashSet = [NSCharacterSet characterSetWithCharactersInString:@"/"];
NSString *baseURLString = [BASE_WEB_URL stringByTrimmingCharactersInSet:slashSet];
@hashmaparraylist
hashmaparraylist / postData.m
Created July 2, 2015 17:00
AFURLSessionManager发送DataTask
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
AFURLSessionManager *sessionManager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];
NSURL *url = [NSURL URLWithString:apiURL];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:method];
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
if (isNeedToken) {
[request setValue:[NSString stringWithFormat:@"token %@", self.token] forHTTPHeaderField:@"Authorization"];
}
import theano
from pylearn2.models import mlp
from pylearn2.training_algorithms import sgd
from pylearn2.termination_criteria import EpochCounter
from pylearn2.datasets.dense_design_matrix import DenseDesignMatrix
import numpy as np
from random import randint
class XOR(DenseDesignMatrix):
@hashmaparraylist
hashmaparraylist / clear_remote_branch.sh
Created August 20, 2015 15:32
清除远程不存在的分支。
git remote prune origin
@hashmaparraylist
hashmaparraylist / shell.sh
Created September 7, 2015 05:35
STOP nginx
sudo service nginx stop
@hashmaparraylist
hashmaparraylist / date.m
Created October 7, 2015 14:14
convert utc to local
NSTimeZone* sourceTimeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"];
NSTimeZone* destinationTimeZone = [NSTimeZone localTimeZone];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:formatter];
[dateFormatter setTimeZone:sourceTimeZone];
NSDate *rawDate = [dateFormatter dateFromString:dateTime];