Skip to content

Instantly share code, notes, and snippets.

View jebai0521's full-sized avatar
🎯
Focusing

Chen Ming jebai0521

🎯
Focusing
View GitHub Profile
ALAssetsLibrary* library = [[ALAssetsLibrary alloc] init];
[library addAssetsGroupAlbumWithName:@"Custom Card" resultBlock:^(ALAssetsGroup *group) {
NSLog(@"create success");
} failureBlock:^(NSError *error) {
NSLog(@"create fanilure");
}];
@jebai0521
jebai0521 / index.js
Created January 13, 2014 08:50 — forked from FokkeZB/index.js
function doClick(e) {
alert('Clicked!');
}
// Remove the event listener like this:
// $.myWidget.off("click", doClick);
$.index.open();
@jebai0521
jebai0521 / gist:9975293
Created April 4, 2014 13:59
tomcat 自签发ssl 证书
1. 生成keystore
注册在填写名子与姓氏时需要填写tomcat的主机ip地址
keytool -genkey -v -alias tomcat -keyalg RSA -keystore tomcat.keystore -validity 365
2. 准备生成 CA 的key
openssl genrsa -out myCA.key 2048
3. 生成 CA
openssl req -x509 -new -key myCA.key -out myCA.cer -days 730 -subj /CN="Sencloudx Custom CA"
4. 准备从 CA 请求认证的请求文件
keytool -certreq -alias tomcat -keystore tomcat.keystore -file server.csr
5. 从CA请求认证
@jebai0521
jebai0521 / gist:db683e7dcd6e6219729c
Created October 27, 2014 13:58
Create a UIImage from sample buffer data
// Create a UIImage from sample buffer data
- (UIImage *) imageFromSampleBuffer:(CMSampleBufferRef) sampleBuffer
{
// Get a CMSampleBuffer's Core Video image buffer for the media data
CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
// Lock the base address of the pixel buffer
CVPixelBufferLockBaseAddress(imageBuffer, 0);
// Get the number of bytes per row for the pixel buffer
NSNumber* old = @(600);
NSNumber* new = @(300);
NSString* oldStr = [NSString stringWithFormat:@"¥%@ ", old];
NSString* newStr = [NSString stringWithFormat:@"¥%@ ", new];
NSAttributedString* oldAttrStr = [[NSAttributedString alloc] initWithString:oldStr attributes:@{NSStrikethroughStyleAttributeName:@(NSUnderlineStyleNone), NSForegroundColorAttributeName:[UIColor blackColor], NSFontAttributeName:[UIFont boldSystemFontOfSize:20]}];
NSAttributedString* newAttrStr = [[NSAttributedString alloc] initWithString:newStr attributes:@{NSStrikethroughStyleAttributeName:@(NSUnderlineStyleSingle), NSForegroundColorAttributeName:[UIColor grayColor], NSFontAttributeName:[UIFont boldSystemFontOfSize:20]}];
@interface LocationMgr () <CLLocationManagerDelegate>
@property (strong, nonatomic) CLLocationManager* locationManager;
@property (strong, nonatomic) CLGeocoder* geocoder;
@property (assign, nonatomic, getter=isRunning) BOOL running;
@end
@implementation LocationMgr
@jebai0521
jebai0521 / gist:5598932b77ddf264a709
Last active August 29, 2015 14:08
mac 访问局域网共享
有时候在Finder右侧的远程共享内看不到局域网内已经共享的主机,可用如下方法连接
1. 知道ip地址可以直接用在Finder窗口中使用苹果+k连,
输入windows的用户和密码即可(有的版本的windows默认关闭了共享帐号登录的)。
2. 也可以这样:smb://pc的ip或者机器名/
http://www.macx.cn/thread-496138-1-1.html
@jebai0521
jebai0521 / gist:e252833c562d04b75c0b
Created November 5, 2014 02:32
property to synthesize
print "@synthesize "$NF" = _"$NF
cat tmp2.txt | awk '{print $NF}' | awk -F';' '{print "@synthesize "$1" = _"$1";"}'
方法1
1. 构造AVURLAsset
2. 请求key
3. 准备播放--检查请求结果
4. 准备播放--检查可否播放
/**
* Link against MobileGestalt
*/
OBJC_EXTERN CFStringRef MGCopyAnswer(CFStringRef property) WEAK_IMPORT_ATTRIBUTE;
void someFunction() {
CFStringRef udid = MGCopyAnswer(CFSTR("UniqueDeviceID"));
/*