Skip to content

Instantly share code, notes, and snippets.

@zernel
zernel / phone_regex.csv
Created December 29, 2022 03:45
主要国家地区电话号码的格式
areaName checkKey countryCode phoneCode
中国大陆 ^(86){0,1}1\\d{10}$ CN 86
中国香港 ^(00){0,1}(852){1}0{0,1}[1,5,6,9,4](?:\\d{7}|\\d{8}|\\d{12})$ HK 852
中国澳门 ^(00){0,1}(853){1}6\\d{7}$ MO 853
中国台湾 ^(00){0,1}(886){1}0{0,1}[6,7,9](?:\\d{7}|\\d{8}|\\d{10})$ TW 886
韩国 ^(00){0,1}(82){1}0{0,1}[7,1](?:\\d{8}|\\d{9})$ KR 82
日本 ^(00){0,1}(81){1}0{0,1}[7,8,9](?:\\d{8}|\\d{9})$ JP 81
美国 ^(00){0,1}(1){1}\\d{10,12}$ US 1
加拿大 ^(00){0,1}(1){1}\\d{10}$ CA 1
英国 ^(00){0,1}(44){1}[347-9](\\d{8,9}|\\d{11,12})$ GB 44
# Idea taken from https://gist.github.com/jackcarter/d86808449f0d95060a40
# This script requires python lib: requests
# You can install by: `python -m pip install requests`
import time
import codecs
import requests
reader = codecs.getreader("utf-8")
@zernel
zernel / psql-with-gzip-cheatsheet.sh
Created August 18, 2018 03:00 — forked from brock/psql-with-gzip-cheatsheet.sh
Exporting and Importing Postgres Databases using gzip
# This is just a cheat sheet:
# On production
sudo -u postgres pg_dump database | gzip -9 > database.sql.gz
# On local
scp -C production:~/database.sql.gz
dropdb database && createdb database
gunzip < database.sql.gz | psql database
@zernel
zernel / rails-puma.conf
Last active July 3, 2018 08:23
Nginx Conf
upstream my_app {
# server unix:///apps/my_app/tmp/sockets/puma.sock fail_timeout=0;
server unix:///apps/my_app/tmp/sockets/puma.sock fail_timeout=0;
}
server {
listen 80;
server_name my_appms.example.com;
root /apps/my_app/public;
@zernel
zernel / install.sh
Last active March 6, 2018 05:52 — forked from chuyik/install.sh
Bandwagon(搬瓦工) CentOS 7 安装 shadowsocks-libev 和 kcptun
######################
## shadowsocks-libev
######################
# install dependencies
yum install epel-release -y
yum install gcc gettext autoconf libtool automake make pcre-devel asciidoc xmlto udns-devel libev-devel -y
# install shadowsocks-libev
cd /etc/yum.repos.d/
@zernel
zernel / Caddyfile
Created November 18, 2017 01:35 — forked from bendo01/Caddyfile
Caddy Web Server As Service on Centos 7
#cd /etc/caddy/Caddyfile
example.com {
root /usr/share/nginx/html
gzip
log /var/log/caddy/access.log
#fastcgi / unix:/var/run/php-fpm/php-fpm.sock php # Fast CGI php interpreter
#fastcgi / fastcgi / 127.0.0.1:9000 php # Fast CGI php interpreter
#using with laravel
fastcgi / unix:/var/run/php-fpm/php-fpm.sock php {
index index.php
@zernel
zernel / Caddyfile
Created November 17, 2017 09:21
Rails Deployment (Puma + Nginx/Cathy)
https://domain {
gzip
root /apps/app/public
log dev.access.log
proxy / unix:///apps/app/tmp/sockets/puma.sock {
fail_timeout 300s
transparent
header_upstream X-Forwarded-Ssl on
except /assets /fonts /robots.txt /favicon.ico /404.html /422.html /500.html
# Why do we need KudeURI? Because the URI.join method doing something stupid:
#
# URI.join('http://example.com/subpath', 'hello', '?token=secret')
# => “http://example.com/hello?token=secret”
#
# But what I expected is “http://example.com/subpath/hello?token=secret", the subpath is gone.
# By using SmartURI, you can handle the case above gracefully:
#
# SmartURI.join('http://example.com/subpath', 'hello', query: { token: secret })
# => "http://example.com/subpath/hello?token=secret"
@zernel
zernel / surge.conf
Created June 30, 2016 06:39
📦 Surge 安装步骤导览 | http://bit.ly/292EJz3
# 规则配置仅供参考,适用于 Surge iOS & Mac;
# 包含 Proxy Group、URL Rewrite 特性
# 包含 Reject 规则,用于拦截广告、行为分析、数据统计
# 屏蔽 Hao123、百度联盟广告以及部分运营商网页漂浮广告
# 部分特性可能仅适用于最新的 TestFlight 版本
[General]
# warning, notify, info, verbose
loglevel = notify
ipv6 = true
@zernel
zernel / surge.conf
Created November 30, 2015 08:28
Surge Config Sample
[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 = 119.29.29.29, 223.5.5.5, 114.114.114.114
loglevel = notify
[Proxy]
Proxy = custom,hk2.iss.tf,8989,aes-256-cfb,40997300,http://surge.pm/ss.module
[Rule]