Skip to content

Instantly share code, notes, and snippets.

View aa65535's full-sized avatar
💭
I may be slow to respond.

Jian Chang aa65535

💭
I may be slow to respond.
View GitHub Profile
@aa65535
aa65535 / mysql_db_backup.sh
Last active August 29, 2015 14:00
Shell script to backup MySql database.
#!/bin/bash
# Shell script to backup MySql database.
# Usage: dbbackup db_name / dbbackup "db_name1 db_name2 db_name3"
# --------------------------------------------------------------------
MyUSER="user" # USERNAME
MyPASS="pwd" # PASSWORD
MyHOST="localhost" # HOSTNAME
# Backup Dest directory, change this if you have someother location
@aa65535
aa65535 / ip_ads.php
Last active August 29, 2015 14:00
中国IP地址段 - China Ip Addresses Range
<?php
$ip_ads = array(
array(16777472, 16778239),
array(16779264, 16781311),
array(16785408, 16793599),
array(16842752, 16843007),
array(16843264, 16859135),
array(16908288, 16909055),
array(16909312, 16910335),
array(16910592, 16941055),
@aa65535
aa65535 / css-filter.html
Created June 4, 2014 09:22
删除CSS中指定的选择器属性
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<textarea id="css" style="margin: 2px; width: 400px; height: 429px;"></textarea>
<textarea id="rules" style="margin: 2px; width: 400px; height: 429px;"></textarea>
<button id="submit">submit</button>
@aa65535
aa65535 / calcMask.js
Last active August 29, 2015 14:02
IP计算
function ip2long(IP) {
var i = 0;
IP = IP.match(/^([1-9]\d*|0[0-7]*|0x[\da-f]+)(?:\.([1-9]\d*|0[0-7]*|0x[\da-f]+))?(?:\.([1-9]\d*|0[0-7]*|0x[\da-f]+))?(?:\.([1-9]\d*|0[0-7]*|0x[\da-f]+))?$/i);
if (!IP) {
return false;
}
IP[0] = 0;
for (i = 1; i < 5; i += 1) {
IP[0] += !!((IP[i] || '').length);
IP[i] = parseInt(IP[i]) || 0;
@aa65535
aa65535 / Transmission.sh
Last active August 29, 2015 14:02
Transmission CentOS安装脚本
#!/bin/bash
yum -y install gcc gcc-c++ m4 make automake libtool gettext openssl-devel pkgconfig perl-libwww-perl perl-XML-Parser curl curl-devel libevent-devel libevent libidn-devel zlib-devel
yum -y update
cd /root
wget https://downloads.sourceforge.net/project/transmissionbt/intltool-0.40.6.tar.gz
wget https://downloads.sourceforge.net/project/transmissionbt/libevent-2.0.14-stable.tar.gz
wget https://transmission.cachefly.net/transmission-2.84.tar.xz
@aa65535
aa65535 / autoindex_name_length.patch
Last active August 29, 2015 14:04
Nginx 打开目录浏览功能后, 可设置文件名显示长度(宽度), 选项名: `autoindex_name_length`, 值为整数 默认: 50. https://github.com/aa65535/Private-Mixed/tree/master/nginx-patch
--- a/ngx_http_autoindex_module.c Tue Aug 5 19:18:36 2014
+++ b/ngx_http_autoindex_module.c Wed Aug 20 14:17:28 2014
@@ -40,13 +40,12 @@
ngx_flag_t enable;
ngx_flag_t localtime;
ngx_flag_t exact_size;
+ ngx_uint_t name_length;
} ngx_http_autoindex_loc_conf_t;
@aa65535
aa65535 / ss-rules
Created October 8, 2014 01:31
blacklist mode
#!/bin/sh
# Get argument
getopts :c: opt && CONFIG=$OPTARG
getopts :i: opt && IGNORE=$OPTARG
# Check argument
[ -z $CONFIG ] || [ -z $IGNORE ] && {
echo "Missing argument"
exit 128
@aa65535
aa65535 / systatus.sh
Created November 29, 2014 12:15
rpi systatus scrip
#!/bin/bash
DELAY=5
PID_FILE=/tmp/systatus.pid
OUT_FILE=/tmp/systatus.json
RX_FILE=/sys/class/net/eth0/statistics/rx_bytes
TX_FILE=/sys/class/net/eth0/statistics/tx_bytes
TEMP_FILE=/sys/class/thermal/thermal_zone0/temp
if [ "stop" = "$1" ]; then
@aa65535
aa65535 / iptab_r.sh
Created December 24, 2014 11:43
SHADOWSOCKS DNAT
iptab_r() {
local LOCAL_IP BODY
LOCAL_IP=$(uci get network.lan.ipaddr 2>/dev/null)
BODY=$(echo -e "$IPLIST" | \
awk '$1 ~ /^([0-9]{1,3}\.){3}[0-9]{1,3}/ \
{printf("-A SHADOWSOCKS -d %s -j RETURN\n", $1)}')
iptables-restore -n <<-EOF
*nat
:SHADOWSOCKS - [0:0]
@aa65535
aa65535 / cidr_match.html
Last active August 29, 2015 14:14
Use CIDR match given two ip address.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CIDR Match</title>
</head>
<body>
<table>
<tbody>
<tr>