(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
/* | |
* Note: You need to build this script before use | |
* Usage: | |
* 1. Build by `swfitc scan_unused_selectors.swift` | |
* 2. Run by `./scan_unused_selectors /path/to/yourMachO` | |
* | |
* How to locate MachO of your APP (`/path/to/yourMachO` in above example)? In your Xcod project navigator, you can find a folder `Products` | |
* In that folder you can see your app (after any build) and right click on it -> "Show In Finder" | |
* You can get your APP's location by drag it into your terminal. Say it's "/path/to/MyApp.app", your MachO path would be "/path/to/MyApp.app/MyApp" | |
*/ |
void Swizzle(Class c, SEL orig, SEL new) { | |
Method origMethod = class_getInstanceMethod(c, orig); | |
Method newMethod = class_getInstanceMethod(c, new); | |
if (class_addMethod(c, orig, method_getImplementation(newMethod), method_getTypeEncoding(newMethod))){ | |
class_replaceMethod(c, new, method_getImplementation(origMethod), method_getTypeEncoding(origMethod)); | |
} else { | |
method_exchangeImplementations(origMethod, newMethod); | |
} | |
} |
static const int target_key; | |
@implementation UIGestureRecognizer (Block) | |
+(instancetype)nvm_gestureRecognizerWithActionBlock:(NVMGestureBlock)block { | |
return [[self alloc]initWithActionBlock:block]; | |
} | |
- (instancetype)initWithActionBlock:(NVMGestureBlock)block { | |
self = [self init]; | |
[self addActionBlock:block]; |
// Release under MIT | |
// Copyright (C) 2015 Xaree Lee | |
#import <Foundation/Foundation.h> | |
/* Get property name for the class (C string or NSSting). */ | |
#define keypathForClass(Klass, PropertyName) \ | |
(((void)(NO && ((void)[Klass _nullObjectForCheckingPropertyName].PropertyName, NO)), # PropertyName)) | |
#define keypathStringForClass(Klass, PropertyName) \ | |
@keypathForClass(Klass, PropertyName) |
tell application "System Events" | |
tell network preferences | |
do shell script "scselect 'Dorm'" | |
do shell script "sudo networksetup -setairportpower AirPort on" user name "用户名" password "密码" with administrator privileges | |
do shell script "open /Applications/Shad**socksX.app" user name “用户名" password "密码" with administrator privileges | |
end tell | |
end tell |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
// How to apply color formatting to your log statements: | |
// | |
// To set the foreground color: | |
// Insert the ESCAPE_SEQ into your string, followed by "fg124,12,255;" where r=124, g=12, b=255. | |
// | |
// To set the background color: | |
// Insert the ESCAPE_SEQ into your string, followed by "bg12,24,36;" where r=12, g=24, b=36. | |
// | |
// To reset the foreground color (to default value): | |
// Insert the ESCAPE_SEQ into your string, followed by "fg;" |
+ (void)describePreferredFonts | |
{ | |
static NSArray *textStyles; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
textStyles = @[UIFontTextStyleHeadline, | |
UIFontTextStyleSubheadline, | |
UIFontTextStyleBody, | |
UIFontTextStyleFootnote, | |
UIFontTextStyleCaption1, |