sudo yum install -y wget

wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm && sudo rpm -Uvh epel-release-7*.rpm

sudo yum install pptpd.x86_64 -y

sudo vi /etc/pptpd.conf

localip 192.168.9.1
remoteip 192.168.9.11-30

sudo vi /etc/ppp/chap-secrets

# client     server   secret      IP addresses
     test      pptpd    test           *

sudo vi /etc/ppp/options.pptpd

ms-dns 8.8.8.8
ms-dns 8.8.4.4

sudo vi /etc/sysctl.conf

net.ipv4.ip_forward = 1

sudo sysctl -p

sudo iptables -A INPUT -p tcp --dport 1723 -j ACCEPT

sudo iptables -A INPUT -p tcp --dport 47 -j ACCEPT

sudo iptables -A INPUT -p gre -j ACCEPT

sudo iptables -A POSTROUTING -t nat -s 192.168.9.0/24 -o eth0 -j MASQUERADE

sudo iptables -A INPUT -p UDP --dport 53 -j ACCEPT

sudo yum install -y iptables-services

sudo service iptables save

sudo service iptables restart

sudo service pptpd restart

sudo chkconfig pptpd on

via http://zhao.jinhai.de/post/1810.html

via http://sunweiwei.com/1863/

via http://www.photonvps.com/billing/knowledgebase.php?action=displayarticle&id=58

阅读详细 »

少花钱必然多遭罪!!!

vim /etc/my.cnf

log_bin=/a30/mysql/logs/mysql_binlog

general_log=ON
general_log_file=/a30/mysql/logs/mysql.log

vim /a30/mysql/sbin/cut_mysql_log.sh

#!/bin/bash
#this script run in 00:20 everyday
#mysql log path
logs_path="/a30/mysql/logs/"
logs_bak_path="/a30/mysql/logs/"
mkdir -p ${logs_bak_path}$(date -d "yesterday" +"%Y")/$(date -d "yesterday" +"%m")/
cp ${logs_path}mysql.log ${logs_bak_path}$(date -d "yesterday" +"%Y")/$(date -d "yesterday" +"%m")/mysql_$(date -d "yesterday" +"%Y%m%d").log
cp /dev/null ${logs_path}mysql.log
chown -R mysql.mysql ${logs_path}mysql.log

阅读详细 »

Aliyun RDS试用后就好贵了~~~

一、备份

手动:

mysqldump -u root -p databaseName > databaseName_backups.sql

mysqldump -u root -p databaseName | gzip > databaseName_backups.sql.gz

自动:

#!/bin/bash

CMD_MYSQL="$(which mysql)"
CMD_MYSQLDUMP="$(which mysqldump)"
# CMD_CHOWN="$(which chown)"
# CMD_CHMOD="$(which chmod)"
# CMD_GZIP="$(which gzip)"

LOCAL_HOST="$(hostname)"

DB_USERNAME=""
DB_PASSWORD=""
DB_HOSTNAME="localhost"
DB_IGNORE="information_schema"
DB_BACKUPS="$($CMD_MYSQL -u $DB_USERNAME -h $DB_HOSTNAME -p$DB_PASSWORD -Bse 'show databases')"

BACKUP_PATH_ROOT="/a30/backups"
BACKUP_PATH_MYSQL="$BACKUP_PATH_ROOT/mysql"
BACKUP_NAME_TIMESTAMP="$(date +"%Y%m%d%H%M%S")"

# $CHOWN 0.0 -R $DEST
# $CHMOD 0600 $DEST

BACKUP_FILE=""

[ ! -d $BACKUP_PATH_MYSQL ] && mkdir -p $BACKUP_PATH_MYSQL || :

for db in $DB_BACKUPS
do
    skipdb=-1

    if [ "$DB_IGNORE" != "" ] ; then
        for i in $DB_IGNORE
        do
            [ "$db" == "$i" ] && skipdb=1 || :
        done
    fi

    if [ "$skipdb" == "-1" ] ; then
        BACKUP_FILE="$BACKUP_PATH_MYSQL/$db.$LOCAL_HOST.$BACKUP_NAME_TIMESTAMP.sql"
        $CMD_MYSQLDUMP -u$DB_USERNAME -h $DB_HOSTNAME -p$DB_PASSWORD $db > $BACKUP_FILE
    fi
done

二、恢复

mysql -u root -p databaseName < databaseName_backups.sql

gzip < databaseName_backups.sql.gz | mysql -u root -p databaseName

阅读详细 »

阿里云数据库默认参数:

参数名 参数默认值 运行参数值 是否重启 可修改参数值
autocommit 1 1 [0|1]
auto_increment_increment 1 1 [1-65535]
auto_increment_offset 1 1 [1-65535]
back_log 3000 3000 [0-65535]
binlog_cache_size 2097152 256K [4096-16777216]
binlog_checksum CRC32 CRC32 [CRC32|NONE]
binlog_row_image full full [full|minimal]
binlog_stmt_cache_size 32768 32768 [4096-16777216]
character_set_server utf8 utf8 [utf8|latin1|gbk|utf...
concurrent_insert 1 1 [0|1|2]
connect_timeout 10 10 [1-3600]
default_storage_engine InnoDB InnoDB [InnoDB|TokuDB|innod...
default_time_zone SYSTEM SYSTEM [SYSTEM|-12:00|-11:0...
default_week_format 0 0 [0-7]
delayed_insert_limit 100 100 [1-4294967295]
delayed_insert_timeout 300 300 [1-3600]
delayed_queue_size 1000 1000 [1-4294967295]
delay_key_write ON ON [ON|OFF|ALL]
div_precision_increment 4 4 [0-30]
ft_min_word_len 4 4 [1-3600]
ft_query_expansion_limit 20 20 [0-1000]
group_concat_max_len 1024 1024 [4-18446744073709547...
innodb_adaptive_hash_index ON ON [ON|OFF]
innodb_autoinc_lock_mode 1 1 [0|1|2]
innodb_concurrency_tickets 5000 500 [1-4294967295]
innodb_flush_log_at_trx_commit 1 1 [0|1|2]
innodb_ft_max_token_size 84 84 [10-84]
innodb_ft_min_token_size 3 3 [0-16]
innodb_large_prefix OFF 0 [ON|OFF]
innodb_lock_wait_timeout 50 50 [1-1073741824]
innodb_max_dirty_pages_pct 75 75 [50-90]
innodb_old_blocks_pct 37 37 [5-95]
innodb_old_blocks_time 1000 0 [0-1024]
innodb_open_files 3000 300 [1-8192]
innodb_print_all_deadlocks OFF OFF [OFF|ON]
innodb_purge_batch_size 300 20 [1-5000]
innodb_purge_threads 1 1 [1-32]
innodb_read_ahead_threshold 56 56 [0-64]
innodb_read_io_threads 4 4 [1-64]
innodb_rollback_on_timeout OFF OFF [OFF|ON]
innodb_stats_method nulls_equal nulls_equal [nulls_equal|nulls_u...
innodb_stats_on_metadata OFF OFF [ON|OFF]
innodb_stats_sample_pages 8 8 [1-4294967296]
innodb_strict_mode OFF OFF [ON|OFF]
innodb_table_locks ON ON [ON|OFF]
innodb_thread_concurrency 0 0 [0-128]
innodb_thread_sleep_delay 10000 10000 [1-3600000]
innodb_use_native_aio OFF 0 [OFF|ON]
innodb_write_io_threads 4 4 [1-64]
interactive_timeout 7200 7200 [10-86400]
key_cache_age_threshold 300 300 [100-4294967295]
key_cache_block_size 1024 1024 [512-16384]
key_cache_division_limit 100 100 [1-100]
log_queries_not_using_indexes OFF OFF [ON|OFF]
long_query_time 1 1 [0.5-10]
loose_max_statement_time 0 0 [0-4294967295]
loose_rds_max_tmp_disk_space 10737418240 1.07374E+11 [0-1073741824000]
loose_rds_threads_running_high_watermark 50000 50000 [0-50000]
loose_tokudb_buffer_pool_ratio 0 0 [0-100]
low_priority_updates 0 0 [0|1]
max_allowed_packet 1073741824 1024M [16384-1073741824]
max_connect_errors 100 20 [1-4294967295]
max_length_for_sort_data 1024 1024 [0-838860]
myisam_sort_buffer_size 262144 262144 [262144-16777216]
net_read_timeout 30 30 [1-4294967295]
net_retry_count 10 10 [1-4294967295]
net_write_timeout 60 60 [1-4294967295]
open_files_limit 65535 8192 [4000-65535]
performance_schema OFF OFF [ON|OFF]
query_alloc_block_size 8192 8192 [1024-16384]
query_cache_limit 1048576 1048576 [1-1048576]
query_cache_size 0 0 [0-104857600]
query_cache_type 0 1 [0|1|2]
query_prealloc_size 8192 8192 [8192-1048576]
slow_launch_time 2 2 [1-1024]
sql_mode \s \s (\s*|REAL_AS_FLOAT|P...
table_definition_cache 512 512 [400-4048]
table_open_cache 2000 100 [1-524288]
tmp_table_size 2097152 262144 [262144-67108864]
transaction_isolation READ-COMMITTED READ-COMMITTED [READ-COMMITTED|REPE...
wait_timeout 86400 86400 [60-259200]

阅读详细 »

Base on Simditor

Icon Function Use Vendor
H Title Unused Simditor
B Bold 表格标题 Simditor
I Italic 变量 Simditor
U Underline 填空 Simditor
S Strikethrough Simditor
A Font Size Unused Simditor
A Text Color Simditor
123 Ordered List Simditor
000 Unordered List Simditor
Block Quote Simditor
Code Simditor
# Table Simditor
Link Simditor
Image Simditor
- Line Unused,因为文章标题下面会有Line Simditor
Indent Unused Simditor
Outdent Unused Simditor
Alignment Unused Simditor
smileemoji表情Official Extensions
5HTML source code editing查看源码Official Extensions
markmarker penOfficial Extensions
KKeyboard通过键盘输入的内容ShaneKing
CCommand命令/关键字ShaneKing
SSmall(小号文本)ShaneKing
MMore文章内容过长时,文章列表中仅展示More之前的内容ShaneKing

阅读详细 »

一、NODE_PATH

export NODE_PATH=/usr/local/lib/node_modules
export PATH=$PATH:$NODE_PATH

二、安装bower

npm install bower -g

node

require('bower')

三、register or publish

bower register xyz git://github.com/abc/xyz.git
npm adduser
Username:pingfan
Email:(xxx@sinaapp.com)

npm login

npm who am i

npm publish

四、version

^1.2.3 := >=1.2.3 <2.0.0
^0.2.3 := >=0.2.3 <0.3.0
^0.0.3 := >=0.0.3 <0.0.4
~1.2.3 := >=1.2.3 <1.(2+1).0 := >=1.2.3 <1.3.0
~0.2.3 := >=0.2.3 <0.(2+1).0 := >=0.2.3 <0.3.0

阅读详细 »

一、安装(前提已安装Node,Mac自带Node:node -v

npm install -g grunt-cli
npm install -g grunt
npm install -g grunt-contrib-clean
npm install -g grunt-contrib-concat
npm install -g grunt-contrib-uglify
npm install -g grunt-contrib-sass
npm install -g grunt-contrib-cssmin
npm install -g grunt-contrib-jshint
npm install -g grunt-banner
npm install -g grunt-contrib-copy
npm install -g grunt-react
npm install -g grunt-replace

阅读详细 »

一、安装(前提已安装Ruby,Mac自带Ruby:ruby -v

gem install sass

阅读详细 »

一、软件类

system_profiler SPApplicationsDataType:查看已安装app:system_profiler SPApplicationsDataType | grep jdk

pkgutil --pkgs:已安装包:pkgutil --pkgs | grep node

which:查看可执行文件位置:which ruby

阅读详细 »

Date.prototype.fmt = function (format) {
  /*
   * eg:format="yyyy-MM-dd hh:mm:ss";
   */
  var o = {
    "M+": this.getMonth() + 1, // month
    "d+": this.getDate(), // day
    "h+": this.getHours(), // hour
    "m+": this.getMinutes(), // minute
    "s+": this.getSeconds(), // second
    "q+": Math.floor((this.getMonth() + 3) / 3), // quarter
    "S": this.getMilliseconds()
    // millisecond
  }
  if (/(y+)/.test(format)) {
    format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  }
  for (var k in o) {
    if (new RegExp("(" + k + ")").test(format)) {
      format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
    }
  }
  return format;
}
Date.prototype.fmtMdy = function () {
  return this.fmt("MM/dd/yyyy");
}
Date.prototype.fmtSK = function () {
  return this.fmtMdy();
}

阅读详细 »

Oss工具类

public enum Oss
{
    Ali
            {
                public String putObject(File file, String folder)
                {
                    String rtnString = null;
                    InputStream content = null;
                    String key = Strings.nullToEmpty(folder) + file.getName();

                    try
                    {
                        OSSClient client = new OSSClient(propCfg.get(OSS_ALI_END_POINT), propCfg.get(OSS_ALI_ACCESS_KEY_ID), propCfg.get(OSS_ALI_ACCESS_KEY_SECRET));
                        content = new FileInputStream(file);
                        ObjectMetadata meta = new ObjectMetadata();
                        meta.setContentLength(file.length());
                        PutObjectResult result = client.putObject(propCfg.get(OSS_ALI_BUCKET_NAME), key, content, meta);
                        result.getETag();
                        rtnString = getOssDomain() + key;
                    }
                    catch (Exception e)
                    {
                        Log0.error(this.getClass(), e.toString(), e);
                    }
                    finally
                    {
                        Close0.close(content);
                    }

                    return rtnString;

                }

                public String getOssDomain()
                {
                    return propCfg.get(OSS_ALI_DOMAIN_NAME);
                }
            };

    private static final String ALI_OSS_CFG_FILENAME = "alioss.w.Cfg.Azolla.properties";

    private static final String OSS_ALI_ACCESS_KEY_ID     = "OSS_ALI_ACCESS_KEY_ID";
    private static final String OSS_ALI_ACCESS_KEY_SECRET = "OSS_ALI_ACCESS_KEY_SECRET";
    private static final String OSS_ALI_END_POINT         = "OSS_ALI_END_POINT";

    private static final String OSS_ALI_BUCKET_NAME        = "OSS_ALI_BUCKET_NAME";
    private static final String OSS_ALI_MAX_CONNECTIONS    = "OSS_ALI_MAX_CONNECTIONS";
    private static final String OSS_ALI_CONNECTION_TIMEOUT = "OSS_ALI_CONNECTION_TIMEOUT";
    private static final String OSS_ALI_MAX_ERROR_RETRY    = "OSS_ALI_MAX_ERROR_RETRY";
    private static final String OSS_ALI_SOCKET_TIMEOUT     = "OSS_ALI_SOCKET_TIMEOUT";

    private static final String OSS_ALI_DOMAIN_NAME = "OSS_ALI_DOMAIN_NAME";

    PropCfg propCfg = PropCfg.cfg(ALI_OSS_CFG_FILENAME);

    /**
     * @param file
     * @param folder a/b/
     * @return
     */
    public abstract String putObject(File file, String folder);

    public abstract String getOssDomain();

}

阅读详细 »

Swing布局工具类

public class GBC extends GridBagConstraints
{
    private static final long serialVersionUID = 1592514305499234713L;

    /**
     * @see org.azolla.l.sunny.layout.GBC#GBC(int, int, int, int)
     */
    private GBC(int gridx, int gridy)
    {
        this.gridx = gridx;
        this.gridy = gridy;
    }

    /**
    * @param gridx location, default 0, right GridBagConstraints.RELATIVE
    * @param gridy location, default 0, under GridBagConstraints.RELATIVE
    * @param gridwidth cell, default 1, last GridBagConstraints.REMAINDER, second last GridBagConstraints.RELATIVE
    * @param gridheight cell, default 1, last GridBagConstraints.REMAINDER, second last GridBagConstraints.RELATIVE
    */
    private GBC(int gridx, int gridy, int gridwidth, int gridheight)
    {
        this.gridx = gridx;
        this.gridy = gridy;
        this.gridwidth = gridwidth;
        this.gridheight = gridheight;
    }

    /**
     * @see org.azolla.l.sunny.layout.GBC#GBC(int, int)
     */
    public static GBC grid(int gridx, int gridy)
    {
        return new GBC(gridx, gridy);
    }

    /**
     * @see org.azolla.l.sunny.layout.GBC#GBC(int, int, int, int)
     */
    public static GBC grid(int gridx, int gridy, int gridwidth, int gridheight)
    {
        return new GBC(gridx, gridy, gridwidth, gridheight);
    }

    /**
     * @param weightx scale, default 0
     * @param weighty scale, default 0
     * @return GBC
     */
    public GBC weight(double weightx, double weighty)
    {
        this.weightx = weightx;
        this.weighty = weighty;

        return this;
    }

    /**
     * @see org.azolla.l.sunny.layout.GBC#insets(int, int, int, int)
     */
    public GBC insets(int distance)
    {
        return insets(distance, distance, distance, distance);
    }

    /**
     * margin
     * 
     * @param top
     * @param left
     * @param bottom
     * @param right
     * @return GBC
     */
    public GBC insets(int top, int left, int bottom, int right)
    {
        this.insets = new Insets(top, left, bottom, right);

        return this;
    }

    /**
     * padding
     * 
     * @param ipadx padding,default 0
     * @param ipady padding,default 0
     * @return GBC
     */
    public GBC ipad(int ipadx, int ipady)
    {
        this.ipadx = ipadx;
        this.ipady = ipady;

        return this;
    }

    /**
     * location of component small
     * 
     * @param anchor default CENTER,
     *              {Absolute:CENTER,NORTH,NORTHEAST,EAST,SOUTHEAST,SOUTH,SOUTHWEST,WEST,NORTHWEST}
     *              {Direction:PAGE_START,PAGE_END,LINE_START,LINE_END,FIRST_LINE_START,FIRST_LINE_END,LAST_LINE_START}
     *              {Baseline:BASELINE,BASELINE_LEADING,BASELINE_TRAILING,
     *                        ABOVE_BASELINE,ABOVE_BASELINE_LEADING,ABOVE_BASELINE_TRAILING,
     *                        BELOW_BASELINE,BELOW_BASELINE_LEADING,BELOW_BASELINE_TRAILING}
     * @return GBC
     */
    public GBC anchor(int anchor)
    {
        this.anchor = anchor;

        return this;
    }

    /**
     * fill of component small
     * 
     * @param fill default NONE,{NONE,HORIZONTAL,VERTICAL,BOTH}
     * @return GBC
     */
    public GBC fill(int fill)
    {
        this.fill = fill;

        return this;
    }
}

阅读详细 »

Java资源获取方法

public static URL getURL(String path)
    {
        //callerFQC:The wrapper class' fully qualified class.
        URL rtnUrl = Thread.currentThread().getClass().getResource(path);
        if (rtnUrl != null)
        {
            return rtnUrl;
        }
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        if (classLoader != null)
        {
            rtnUrl = classLoader.getResource(path);
            if (rtnUrl != null)
            {
                return rtnUrl;
            }
        }
        return ClassLoader.getSystemResource(path);
    }

阅读详细 »

jQuery Validation是很好的校验控件,错误信息展示也是丰富多彩。

为不影响布局,采用tooltip提示如下:

.jquery-validation-sk_error { border: 1px solid #c33 !important; background-color: #fcc !important; }
$.validator.setDefaults({
    showErrors: function (errorMap, errorList) {
        // Clean up any tooltips for valid elements
        $.each(this.validElements(), function (index, element) {
            var $element = $(element);
            $element.data("title", "") // Clear the title - there is no error associated anymore
                .removeClass("jquery-validation-sk_error")
                .tooltip("destroy");
        });
        // Create new tooltips for invalid elements
        $.each(errorList, function (index, error) {
            var $element = $(error.element);
            $element.tooltip("destroy") // Destroy any pre-existing tooltip so we can repopulate with new tooltip content
                .data("title", error.message)
                .addClass("jquery-validation-sk_error")
                .tooltip(); // Create a new tooltip based on the error messsage we just set in the title
        });
    }
});

阅读详细 »

function skFMoney(s, n) { 
	n = n > 0 && n <= 20 ? n : 2; 
	s = parseFloat((s + "").replace(/[^\d\.-]/g, "")).toFixed(n) + ""; 
	var l = s.split(".")[0].split("").reverse(), r = s.split(".")[1]; 
	t = ""; 
	for (i = 0; i < l.length; i++) { 
		t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? "," : ""); 
	} 
	return t.split("").reverse().join("") + "." + r; 
}
function skRMoney(s) { 
	return parseFloat(s.replace(/[^\d\.-]/g, "")); 
}

阅读详细 »

在JSP页面头部通常会引入:

<%@ page language="java" pageEncoding="utf-8" isELIgnored="false" %>

紧接着再是JSTL标签:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

这些标识有时会合并到一个taglib.jsp文件中,然后再include到页面中:

<%@ include file="/ref/taglib.jsp" %>

如果有contextPath则页面的其他资源,比如jscss等都需要添加contextPath为前缀,这时候就需要定义较短的contextPath变量,因为不想页面中出现太多的${pageContext.request.contextPath},偷懒的童鞋们直接放到taglib.jsp里加:

《c:set var="___ctx" value="${pageContext.request.contextPath}"/》

《script》
	var ___ctx = "${pageContext.request.contextPath}";
《/script》

这样script标签就在《!DOCTYPE html》之前了,这时页面第一个标签就是不是《!DOCTYPE html》而是html标签了,此时浏览器找不到DOCTYPE定义,则部分(不明确的)样式会采用user agent stylesheet样式渲染。

阅读详细 »

px

“绝对大小”--在同一块屏幕中

指包含多少个像素点,因为屏幕的分辨率(像素密度,即ppi)不一样,所以px算是一个相对的绝对值

em

相对大小--相对body元素

1.对于元素font-size属性而言是相对父元素font-size

2.对于没有font-size属性的元素而言,其他属性也是相对父元素font-size

3.对于有font-size属性的元素而言,其他属性是相对自身的font-size

rem

相对大小--相对html元素

PS:浏览器默认情况下设置body元素及html元素的font-size为16px

阅读详细 »

简介

java实现浏览器等本地桌面的功能,非常好用-java Browser desktop, and other local functions, very handy

分享

微云

via

http://www.codeforge.cn/article/57730

阅读详细 »