This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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")}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function parseEmoji(input) { | |
return input.replace(/(<span class="emoji emoji([a-z0-9A-Z]+)"><\/span>)/g, function (_, _, s) { | |
return String.fromCodePoint(parseInt(s, 16)); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(UIImage *)imageToPNG:(UIImage *)image { | |
return [UIImage imageWithData:UIImagePNGRepresentation(image)]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef NS_ENUM(NSInteger, JHAlcoholCategory) { | |
JHAlcoholCategoryWhiteSpirit = 1, | |
JHAlcoholCategoryChampagne = 11, | |
JHAlcoholCategoryWine = 12, | |
JHAlcoholCategoryLiquer = 16, | |
JHAlcoholCategoryBeer = 17, | |
JHAlcoholCategoryWineset = 19, | |
JHAlcoholCategoryGift = 18, | |
JHAlcoholCategorySet = 20, | |
JHAlcoholCategoryOneKey = 21, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface UIImage (fixOrientation) | |
-(UIImage *)fixOrientation; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 百度拼音输入法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: | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |