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
// only keep screen on | |
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); | |
// disable KeyGuard and turn screen on | |
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); | |
// disable KeyGuard then turn screen on and keep screen on | |
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); |
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 ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) { | |
SEL selector = NSSelectorFromString(@"setOrientation:"); | |
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]]; | |
[invocation setSelector:selector]; | |
[invocation setTarget:[UIDevice currentDevice]]; | |
int val = UIInterfaceOrientationPortrait; | |
[invocation setArgument:&val atIndex:2]; | |
[invocation invoke]; | |
} |
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
/* | |
* System Versioning Preprocessor Macros | |
*/ | |
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame) | |
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending) | |
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) | |
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending) | |
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending) |
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)load | |
{ | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
Class class = [self class]; | |
SEL originalSelector = @selector(<#Original Selector#>); | |
SEL swizzledSelector = @selector(<#Swizzled Selector#>); | |
Method originalMethod = class_getInstanceMethod(class, originalSelector); |
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
// https://github.com/AFNetworking/AFNetworking/issues/393 | |
- (void)downloadFileRetryingNumberOfTimes:(NSUInteger)ntimes | |
success:(void (^)(id responseObject))success | |
failure:(void (^)(NSError *error))failure | |
{ | |
if (ntimes <= 0) { | |
if (failure) { | |
NSError *error = ...; | |
failure(error); | |
} |
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
NSShadow *textShadow = [[NSShadow alloc] init]; | |
textShadow.shadowColor = [UIColor darkGrayColor]; | |
textShadow.shadowBlurRadius = 1.2; | |
textShadow.shadowOffset = CGSizeMake(1,1); | |
NSDictionary *attributes = @{NSForegroundColorAttributeName: [UIColor blackColor], | |
NSShadowAttributeName: textShadow | |
}; | |
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
//: Playground - noun: a place where people can play | |
import UIKit | |
var randomNumbers = [42, 12, 88, 62, 63, 56, 1, 77, 88, 97, 97, 20, 45, 91, 62, 2, 15, 31, 59, 5] | |
func partition(inout v: [Int], left: Int, right: Int) -> Int { | |
var i = left | |
for j in (left + 1) ... right { | |
if v[j] < v[left] { |
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
require_relative "../config.rb" | |
gem 'xcodeproj', '>=0.19.4' | |
require 'xcodeproj' | |
PROJECT = 'Unity-iPhone' | |
TARGET = 'Unity-iPhone' | |
LIBRARY = 'Libraries' | |
### Export | |
def exportUnityProject |
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
# First install tmux | |
brew install tmux | |
# For mouse support (for switching panes and windows) | |
# Only needed if you are using Terminal.app (iTerm has mouse support) | |
Install http://www.culater.net/software/SIMBL/SIMBL.php | |
Then install https://bitheap.org/mouseterm/ | |
# More on mouse support http://floriancrouzat.net/2010/07/run-tmux-with-mouse-support-in-mac-os-x-terminal-app/ |
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
ACTION = build | |
AD_HOC_CODE_SIGNING_ALLOWED = NO | |
ALTERNATE_GROUP = staff | |
ALTERNATE_MODE = u+w,go-w,a+rX | |
ALTERNATE_OWNER = grantdavis | |
ALWAYS_SEARCH_USER_PATHS = NO | |
ALWAYS_USE_SEPARATE_HEADERMAPS = YES | |
APPLE_INTERNAL_DEVELOPER_DIR = /AppleInternal/Developer | |
APPLE_INTERNAL_DIR = /AppleInternal | |
APPLE_INTERNAL_DOCUMENTATION_DIR = /AppleInternal/Documentation |
OlderNewer