Skip to content

Instantly share code, notes, and snippets.

View fannheyward's full-sized avatar
🎯
Slow to response

Heyward Fann fannheyward

🎯
Slow to response
View GitHub Profile
local redis_c = require "resty.redis"
local ok, new_tab = pcall(require, "table.new")
if not ok or type(new_tab) ~= "function" then
new_tab = function (narr, nrec) return {} end
end
local _M = new_tab(0, 155)
@fannheyward
fannheyward / surf.conf
Created August 25, 2016 04:09 — forked from networkextension/surf.conf
surf.conf
# A.BIG.T rule config
# 用编辑器编辑后,再通过 iTunes, URL, AirDrop 或者 iCloud Drive 复制回 iOS 设备
# Version 2.0
[General]
# 日志等级: error,warning, notify, info, verbose (默认值: info)
loglevel = info
# 跳过某个域名或者 IP 段,这些目标主机将不会由 A.BIG.T 处理。
skip-proxy = 127.0.0.1, 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12, 100.64.0.0/10, localhost, *.local
# 强制使用特定的 DNS 服务器
# 你可以从该 URL 下载这个配置文件: http://surge.run/config-example/ios.conf
# 用编辑器编辑后,再通过 iTunes, URL, AirDrop 或者 iCloud Drive 复制回 iOS 设备
# Version 2.0
[General]
# 日志等级: warning, notify, info, verbose (默认值: notify)
loglevel = notify
# 跳过某个域名或者 IP 段,这些目标主机将不会由 Surge Proxy 处理。(在 macOS
# 版本中,如果启用了 Set as System Proxy, 那么这些值会被写入到系统网络代理
# 设置中.)
// Include https://github.com/steipete/Aspects in your project
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[UIButton aspect_hookSelector:@selector(touchesEnded:withEvent:) withOptions:AspectPositionAfter usingBlock:^(id<AspectInfo> info) {
UIButton *button = [info instance];
UIView *topMostView = button.window.subviews.firstObject;
[self logSubviews:topMostView];
} error:nil];
return YES;
# sniproxy example configuration file
# lines that start with # are comments
# lines with only white space are ignored
user daemon
# PID file
pidfile /var/run/sniproxy.pid
resolver {
NginX/NginX OpenResty的内建及扩展模块的phase先后执行次序:
参考: http://wiki.nginx.org/Phases
http://blog.sina.com.cn/openresty
需要关注的phase有:
-1:http config:
在/usr/local/openresty/nginx/conf/nginx.conf的http段落有可以载入lua的共用函数, 比如:
init_by_lua_file /var/workspace/www/violation_nginx/lf;
0.server selection: server(listen, server_name)
@fannheyward
fannheyward / exclude_file_from_icloud_backup.m
Created January 23, 2014 01:15
exclude_file_from_icloud_backup.m
#include <sys/xattr.h>
if (!&NSURLIsExcludedFromBackupKey) {
// iOS <= 5.0.1
const char *filePath = [[URL path] fileSystemRepresentation];
const char *name = "com.apple.MobileBackup";
u_int8_t value = 1;
int result = setxattr(filePath, name, &value, sizeof(value), 0, 0);
} else {
// iOS >= 5.1
NSArray *array = [[NSUserDefaults standardUserDefaults] valueForKey:@"fontURLs"];
NSMutableArray *fontURLs = [NSMutableArray arrayWithArray:array];
for (NSString *urlString in fontURLs) {
NSURL *url = [NSURL URLWithString:urlString];
CTFontManagerRegisterFontsForURL((__bridge CFURLRef)url, kCTFontManagerScopeProcess, nil);
}
@fannheyward
fannheyward / service.js
Created January 2, 2014 06:34
Angular: make a service with $http.
app.factory('myService', function($http) {
var myService = {
async: function() {
// $http returns a promise, which has a then function, which also returns a promise
var promise = $http.get('test.json').then(function (response) {
// The then function here is an opportunity to modify the response
console.log(response);
// The return value gets picked up by the then in the controller.
return response.data;
});
// Your app's root module...
angular.module('MyModule', [], function($httpProvider)
{
// Use x-www-form-urlencoded Content-Type
$httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
// Override $http service's default transformRequest
$httpProvider.defaults.transformRequest = [function(data)
{
/**