Skip to content

Instantly share code, notes, and snippets.

@moliyadi
moliyadi / 0_reuse_code.js
Last active August 29, 2015 14:26
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@moliyadi
moliyadi / VDLPlaybackViewController.m
Last active November 16, 2015 07:11
iOS vlc编译相关代码修改
/* setup gesture recognizer to toggle controls' visibility */
//_movieView.userInteractionEnabled = NO;
UITapGestureRecognizer *tapOnVideoRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(toggleControlsVisible)];
tapOnVideoRecognizer.delegate = self;
//[self.view addGestureRecognizer:tapOnVideoRecognizer]; //mabiao
[self.movieView addGestureRecognizer:tapOnVideoRecognizer];

Just add this block of code in applicationdidFinishLaunchingWithOptionslaunchOptions method in app delegate file, and it will create a log file in app Document Directory on iphone which logs all console log events. You need to import this file from itunes to see all console events.

if (!isatty(STDERR_FILENO)) {
        //判断控制台是否已连接,http://stackoverflow.com/questions/9619708/nslog-to-both-console-and-file
        //将控制台内容写入文件,http://stackoverflow.com/questions/2634929/objective-c-iphone-can-we-view-console-log-on-device
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
        
        NSString *documentsDirectory = [paths objectAtIndex:0];
        
 NSString *fileName =[NSString stringWithFormat:@"%@.log",[NSDate date]];
@moliyadi
moliyadi / DeviceUID.m
Created February 23, 2016 08:43 — forked from miguelcma/DeviceUID.m
iOS Unique Device ID that persists between app reinstalls
/* DeviceUID.h
#import <Foundation/Foundation.h>
@interface DeviceUID : NSObject
+ (NSString *)uid;
@end
*/
// Device.m
@moliyadi
moliyadi / surge_main.conf
Created March 26, 2016 07:25 — forked from jason5ng32/surge.conf
Surge Configs ( Both 2 files are needed )
[General]
loglevel = notify
skip-proxy = 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12,127.0.0.0/24,100.64.0.0/10
bypass-tun = 0.0.0.0/8, 1.0.0.0/9, 1.160.0.0/11, 1.192.0.0/11, 10.0.0.0/8, 14.0.0.0/11, 14.96.0.0/11, 14.128.0.0/11, 14.192.0.0/11, 27.0.0.0/10, 27.96.0.0/11, 27.128.0.0/9, 36.0.0.0/10, 36.96.0.0/11, 36.128.0.0/9, 39.0.0.0/11, 39.64.0.0/10, 39.128.0.0/10, 42.0.0.0/8, 43.224.0.0/11, 45.64.0.0/10, 47.64.0.0/10, 49.0.0.0/9, 49.128.0.0/11, 49.192.0.0/10, 54.192.0.0/11, 58.0.0.0/9, 58.128.0.0/11, 58.192.0.0/10, 59.32.0.0/11, 59.64.0.0/10, 59.128.0.0/9, 60.0.0.0/10, 60.160.0.0/11, 60.192.0.0/10, 61.0.0.0/10, 61.64.0.0/11, 61.128.0.0/10, 61.224.0.0/11, 100.64.0.0/10, 101.0.0.0/9, 101.128.0.0/11, 101.192.0.0/10, 103.0.0.0/10, 103.192.0.0/10, 106.0.0.0/9, 106.224.0.0/11, 110.0.0.0/7, 112.0.0.0/9, 112.128.0.0/11, 112.192.0.0/10, 113.0.0.0/9, 113.128.0.0/11, 113.192.0.0/10, 114.0.0.0/9, 114.128.0.0/11, 114.192.0.0/10, 115.0.0.0/8, 116.0.0.0/8, 117.0.0.0/9, 117.128.0.0/10, 118.0.0.0/11, 118.64.0.0/10, 118.128.0.0
@moliyadi
moliyadi / convert.sh
Last active March 27, 2018 07:28 — forked from akost/convert.sh
批量转换当前目录下所有文件的编码格式 GBK --> utf-8
#!/bin/bash
# Recursive file convertion GBK --> utf-8
# Place this file in the root of your site, add execute permission and run
# Converts *.php, *.html, *.css, *.js files.
# To add file type by extension, e.g. *.cgi, add '-o -name "*.cgi"' to the find command
find . -type f |
# find ./ -name "*.php" -o -name "*.html" -o -name "*.css" -o -name "*.js" -type f |
while read file