Skip to content

Instantly share code, notes, and snippets.

View yourtion's full-sized avatar
🎯
Focusing

郭宇翔 yourtion

🎯
Focusing
View GitHub Profile
@yourtion
yourtion / isHTTPEnable.m
Last active June 12, 2016 04:33
Is http enable
- (BOOL)needTransportSecurity {
#if TARGET_OS_IPHONE
if([[[UIDevice currentDevice] systemVersion] compare:@"9.0" options:NSNumericSearch] != NSOrderedAscending){
return YES;
}
#elif TARGET_OS_MAC
NSDictionary *systemVersionDictionary = [NSDictionary dictionaryWithContentsOfFile:@"/System/Library/CoreServices/SystemVersion.plist"];
if([[systemVersionDictionary objectForKey:@"ProductVersion"] compare:@"10.11" options:NSNumericSearch] != NSOrderedAscending){
return YES;
}
@yourtion
yourtion / NSLayoutConstraint+ViewHierarchy.h
Created June 7, 2016 05:51
NSLayoutConstraint+ViewHierarchy
#if TARGET_OS_IPHONE
@compatibility_alias VIEW_CLASS UIView;
#elif TARGET_OS_MAC
@compatibility_alias VIEW_CLASS NSView;
#endif
@interface NSLayoutConstraint(ViewHierarchy)
@property(nonatomic, readonly) VIEW_CLASS *firstView;
@property(nonatomic, readonly) VIEW_CLASS *secondView;
@yourtion
yourtion / getList.js
Created April 30, 2016 11:19
O'Reilly Ebook
// http://www.oreilly.com/programming/free/
$.map($('body > article:nth-child(4) > div > section > div > a'), function(e){return e.href.replace(/free/, "free/files").replace(/csp.*/, "pdf")})
@yourtion
yourtion / parseEmoji.js
Created March 28, 2016 06:27
parseWeiChatWebEmoji
function parseEmoji(input) {
return input.replace(/(<span class="emoji emoji([a-z0-9A-Z]+)"><\/span>)/g, function (_, _, s) {
return String.fromCodePoint(parseInt(s, 16));
});
}
@yourtion
yourtion / oclntTest.sh
Created February 19, 2016 05:24
Oclnt test in terminal
#!/bin/sh
# Check if xctool and oclint are installed
if ! which -s xctool
then
echo 'error: xctool not found, install e.g. with homebrew'
exit 1
fi
if ! which -s oclint-json-compilation-database
@yourtion
yourtion / GetPNGimage.m
Created January 21, 2016 11:27
GetPNGimage.m
-(UIImage *)imageToPNG:(UIImage *)image {
return [UIImage imageWithData:UIImagePNGRepresentation(image)];
}
@yourtion
yourtion / NS_ENUM_To_NSString.m
Created December 23, 2015 04:40
convert NS_ENUM to NSString
typedef NS_ENUM(NSInteger, JHAlcoholCategory) {
JHAlcoholCategoryWhiteSpirit = 1,
JHAlcoholCategoryChampagne = 11,
JHAlcoholCategoryWine = 12,
JHAlcoholCategoryLiquer = 16,
JHAlcoholCategoryBeer = 17,
JHAlcoholCategoryWineset = 19,
JHAlcoholCategoryGift = 18,
JHAlcoholCategorySet = 20,
JHAlcoholCategoryOneKey = 21,
@yourtion
yourtion / UIImage+fixOrientation.h
Last active November 13, 2015 04:01
使用UIImage的imageOrientation属性修正图片方向 http://feihu.me/blog/2015/how-to-handle-image-orientation-on-iOS/
@interface UIImage (fixOrientation)
-(UIImage *)fixOrientation;
@end
@yourtion
yourtion / BaiduBcdReader.java
Last active June 28, 2019 09:30
词库文件导出 (搜狗拼音输入法SCEL词库文件解析 、QQ拼音qpyd词库文件解析 、百度拼音输入法BCD词库文件解析 、Lingoes灵格斯电子词典LD2(LDF)文件解析)
/* 百度拼音输入法BCD词库文件解析
* Copyright (c) 2010 Xiaoyun Zhu
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
@yourtion
yourtion / report_memory.m
Created September 17, 2015 06:11
ios_report_memory
void report_memory(void) {
static unsigned last_resident_size=0;
static unsigned greatest = 0;
static unsigned last_greatest = 0;
struct task_basic_info info;
mach_msg_type_number_t size = sizeof(info);
kern_return_t kerr = task_info(mach_task_self(),
TASK_BASIC_INFO,
(task_info_t)&info,