Skip to content

Instantly share code, notes, and snippets.

@qianduan
qianduan / auto-renew-lets-encrypt.sh
Last active May 12, 2016 08:15
auto renew let's encrypt certificate
#!/bin/sh
service nginx stop # or whatever your webserver is
/home/soft/letsencrypt.client/letsencrypt-auto renew -nvv --standalone > /var/log/letsencrypt/renew.log 2>&1
LE_STATUS=$?
service nginx start # or whatever your webserver is
if [ "$LE_STATUS" != 0 ]; then
echo Automated renewal failed:
cat /var/log/letsencrypt/renew.log
exit 1
fi
@qianduan
qianduan / GFW_ADBlock.conf
Created February 25, 2016 09:48 — forked from bao3/GFW_ADBlock.conf
由于 Surge for ios 的条目数量不能过大,导致手机内存不足,所以将 GFW 和 广告过滤集中后进行了人工挑选,压缩在 1万条左右,你仍然可以自己添加大约 900条规则,理论上足够你长久使用了,配置文件默认是直连,方便普通国内用户使用。配置文件中,我自己调整过的、有可能有误伤的条目我都放在了前面,方便你自己修改,不过运行自 2016/01 ~ 2016/02 我自己日常没有遇到问题。有误伤不要怕,打开软件可以自己调试添加。
[General]
#我的注释都是 # 开头,所以如果你用 vim,直接 :g/^#/d 就可以一次性清除所有注释
#开头这段skip包含以下几个目的:1,私网IP跳过,提高内网性能;2,苹果的一些服务跳过,比如公共热点wifi要先测试captive.apple.com。可解决很多内网的 TCP毛病,例如 kodi remote软件无法遥控
skip-proxy = 10.0.0.0/8,169.254/16,172.16.0.0/12,192.168.0.0/16,224.0.0.0/4, localhost, *.local,api.smoot.apple.com,configuration.apple.com,xp.apple.com,smp-device-content.apple.com,guzzoni.apple.com,captive.apple.com,*.ess.apple.com,*.push.apple.com,*.push-apple.com.akadns.net
#下面这一段则是完全跳过 Surge,最重要的一个是让 UDP包可以传输,解决很多内网毛病,例如DLNA,NFS或者btsync等组播类/UDP类应用
bypass-tun = 10.0.0.0/8, 169.254.0.0/16, 172.16.0.0/12, 192.168.0.0/16, 224.0.0.0/4, 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, 5
@qianduan
qianduan / nginx.conf
Created December 3, 2015 03:39
nginx config for performance
http {
...
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 60;
gzip on;
@qianduan
qianduan / ghost.conf
Last active December 3, 2015 03:42
nginx http2 ghost config used for https://www.qianduan.net , enabled nginx proxy_cache and maximum browser cache for static resources.
server{
listen 443 ssl http2;
server_name www.qianduan.net;// youdomain.com
ssl on;
keepalive_timeout 300;
charset utf-8;
ssl_certificate /path/to/youdomian.crt;
@qianduan
qianduan / ghost.conf
Last active December 3, 2015 03:43
nginx redrect to https used for www.qianduan.net
server {
listen 80;
server_name qianduan.net www.qianduan.net;
//don't want to use https://qianduan.net, so, derect any http url to https.
return 301 https://www.qianduan.net$request_uri;
}
@qianduan
qianduan / debug.conf
Last active August 29, 2015 14:15
disable x5 cache
#Wed Feb 11 15:27:20 GMT+08:00 2015
setting_froceUseQProxy=false
setting_forceUseSystemWebview=false
@qianduan
qianduan / gist:7939466
Created December 13, 2013 03:38
nginx reverse proxy for node.js
log_format snake.isux.us '$remote_addr - $remote_user [$time_local] $request'
'$status $body_bytes_sent $http_referer'
'$http_user_agent $http_x_forwarded_for';
upstream snake.isux.us{
server 127.0.0.1:3000;
}
server {
listen 80;
server_name snake.isux.us;
@qianduan
qianduan / center.html
Created December 18, 2012 08:46
只是文字的水平和垂直居中
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>只是文字的水平和垂直居中</title>
<style>
html,body{width: 100%;height: 100%;margin: 0;padding: 0}
body{background-color: green;display: table;}
p{line-height: 1.6;text-align: center;padding: 0;margin: 0;display: table-cell;vertical-align: middle;}
</style>
@qianduan
qianduan / gist:3754894
Created September 20, 2012 09:27 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt