Skip to content

Instantly share code, notes, and snippets.

@czwen
czwen / gist:562325eeb8f376f9ba50be0ed1116993
Created April 25, 2017 02:29
iOS app icon content.json
{
"images" : [
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "Icon-Spotlight-40.png",
"scale" : "2x"
},
{
"size" : "20x20",
while (YES)
{
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
}
@czwen
czwen / gist:25e5f581c3c12f7d86e76b3a9c73b822
Created November 18, 2016 07:00
use a version of cocoapods to pod install
You can do the following to use different versions:
pod _0.34.4_ install
or
pod _0.34.1_ install
@czwen
czwen / gist:9f59d06b943c795b993596f718fdfaa9
Created October 27, 2016 10:40
Set Custom User-Agent Of UIWebView
- (void)setDefaultWebViewUserAgent
{
// Get Default UserAgent.
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectZero];
NSString *agent = [webView stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"];
// Save it.
NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"%@;my user-agent", agent], @"UserAgent", nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:dictionary];
}
@czwen
czwen / gist:8eff9d6bffca031d5f0dfdc29d8011a4
Created August 10, 2016 03:47
- (UIViewController*)getViewController;
- (UIViewController*)getViewController
{
for (UIView* next = [self superview]; next; next = next.superview)
{
UIResponder* nextResponder = [next nextResponder];
if ([nextResponder isKindOfClass:[UIViewController class]])
{
return (UIViewController*)nextResponder;
}
#replace {domain} such as test.com
#replace {port} such as 8392
#replace {password} such as fjadoisv122
[Proxy]
🇯🇵5⃣️ = custom,jp.e.{domain},{port},rc4-md5,{password},http://nat.pw/ss.module
🇺🇸2⃣️ = custom,us.b.{domain},{port},rc4-md5,{password},http://nat.pw/ss.module
@czwen
czwen / gist:567f731173b2e33add720424a3ce836e
Created July 1, 2016 07:41
inject dylib into simulator
xcrun simctl spawn booted launchctl debug system/com.apple.SpringBoard --environment DYLD_INSERT_LIBRARIES=/Applications/Reveal.app/Contents/SharedSupport/iOS-Libraries/libReveal.dylib
xcrun simctl spawn booted launchctl stop com.apple.SpringBoard
Build Settings > Preprocessor Macros
#if AD_HOC
#endif
#if DEBUG
#endif
#if APP_STORE
#endif
@czwen
czwen / UIButton content center
Created June 1, 2016 06:40
make uibutton image and title center
[button sizeToFit];
CGFloat  button_centerX =CGRectGetMidX(button.bounds);// bounds!!
CGFloat titleLabel_centerX =CGRectGetMidX(button.titleLabel.frame);
CGFloat imageView_centerX =CGRectGetMidX(button.imageView.frame);
button.imageEdgeInsets = UIEdgeInsetsMake(0,0 + (button_centerX - imageView_centerX),0,0 - (button_centerX - imageView_centerX));
@czwen
czwen / surge.config
Created May 27, 2016 15:57
surge.config
# replace @host@ with my host
# replace @port@ with my port
# replace @pw@ with my password
[General]
skip-proxy = 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12, localhost, *.local
bypass-tun = 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12
dns-server = 8.8.8.8,223.5.5.5