Skip to content

Instantly share code, notes, and snippets.

tony tonyc726

Block or report user

Report or block tonyc726

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tonyc726
tonyc726 / nginx
Created Feb 25, 2017 — forked from vdel26/nginx
Openresty init.d script
View nginx
#!/bin/sh
#
# chkconfig: 2345 55 25
# Description: Nginx init.d script, put in /etc/init.d, chmod +x /etc/init.d/nginx
# For Debian, run: update-rc.d -f nginx defaults
# For CentOS, run: chkconfig --add nginx
#
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
@tonyc726
tonyc726 / .npmrc
Last active Dec 17, 2018
河蟹加速npm/yarn的资源安装升级速度
View .npmrc
# 注册模块镜像
registry=https://registry.npm.taobao.org
# node-gyp 编译依赖的 node 源码镜像
disturl=https://npm.taobao.org/dist
# chromedriver 二进制包镜像
chromedriver_cdnurl=https://cdn.npm.taobao.org/dist/chromedriver
# operadriver 二进制包镜像
@tonyc726
tonyc726 / cors-nginx.conf
Created Jul 1, 2016 — forked from alexjs/cors-nginx.conf
Slightly tighter CORS config for nginx
View cors-nginx.conf
#
# Slightly tighter CORS config for nginx
#
# A modification of https://gist.github.com/1064640/ to include a white-list of URLs
#
# Despite the W3C guidance suggesting that a list of origins can be passed as part of
# Access-Control-Allow-Origin headers, several browsers (well, at least Firefox)
# don't seem to play nicely with this.
#
@tonyc726
tonyc726 / verify_id_card.js
Created Feb 16, 2016
客户端身份证验证
View verify_id_card.js
// 验证身份证号码
function verify_id_card(value) {
// 转换字母为大写,增加大小写X的容错能力
var id_card = value.toUpperCase();
//检查号码是否符合规范,包括长度,类型
var isCardNo = function(obj) {
//身份证号码为15位或者18位,15位时全为数字,18位前17位为数字,最后一位是校验位,可能为数字或字符X
var reg = /(^\d{15}$)|(^\d{17}(\d|X)$)/;
if (reg.test(obj) === false) {
View toThousands_1.js
// 方法一
function toThousands(num) {
var result = [ ], counter = 0;
num = (num || 0).toString().split('');
for (var i = num.length - 1; i >= 0; i--) {
counter++;
result.unshift(num[i]);
if (!(counter % 3) && i != 0) { result.unshift(','); }
}
return result.join('');
@tonyc726
tonyc726 / Luhn-self.js
Last active Feb 16, 2016
Luhn校验银行卡号
View Luhn-self.js
/**
* [validate_card_luhn Luhn算法检验卡号]
*
* @param {String} card_number [需要检验的卡号]
* @return {Boolean}
*
* @via https://zh.wikipedia.org/wiki/Luhn%E7%AE%97%E6%B3%95
* @author tonyc726
*/
function validate_card_luhn(card_number){
@tonyc726
tonyc726 / exchange.js
Created Dec 24, 2015
JS数字金额大写转换
View exchange.js
var digitUppercase = function(n) {
var fraction = ['', ''];
var digit = [
'', '', '', '', '',
'', '', '', '', ''
];
var unit = [
['', '', '亿'],
['', '', '', '']
];
@tonyc726
tonyc726 / color.js
Created Nov 6, 2015
JS随机生成颜色值
View color.js
function color(){
return '#' + Math.floor(0x1000000 + Math.random() * 0x1000000).toString(16).slice(1);
}
@tonyc726
tonyc726 / EventUtil.js
Last active Oct 19, 2016
JavaScript高级程序设计之EventUtil
View EventUtil.js
// 简单的通用事件方法
// http://www.imooc.com/wenda/detail/4603
var EventUtil = {
getEvent: function (e) {
return e || window.event;
},
getTarget: function (e) {
return e.target || e.srcElement;
@tonyc726
tonyc726 / type.coffee
Created May 27, 2014
通过 Object.prototype.toString.call() 进行类型判断
View type.coffee
# http://zhang.zipeng.info/library/coffeescript/07_the_bad_parts.html
# 使用typeof
# 这里是jQuery的$.type的实现的例子
type = do ->
classToType = {}
for name in "Boolean Number String Function Array Date RegExp Undefined Null".split(" ")
classToType["[object " + name + "]"] = name.toLowerCase()
(obj) ->
You can’t perform that action at this time.