Skip to content

Instantly share code, notes, and snippets.

# remove node_modules in floder
find . -name 'node_modules' -type d -prune -exec rm -rf '{}' +
# rename
rename -d "Typescript" ./
@tonyc726
tonyc726 / nginx
Created February 25, 2017 10:52 — forked from vdel26/nginx
Openresty init.d script
#!/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 March 7, 2024 20:48
淘宝镜像加速npm的资源安装升级速度
# 注册模块镜像
registry=https://registry.npmmirror.com
# node-gyp 编译依赖的 node 源码镜像
disturl=https://npmmirror.com/mirrors/node/
# chromedriver
chromedriver_cdnurl=https://cdn.npmmirror.com/binaries/chromedriver/
# operadriver
@tonyc726
tonyc726 / cors-nginx.conf
Created July 1, 2016 01:17 — forked from alexjs/cors-nginx.conf
Slightly tighter CORS config for nginx
#
# 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 February 16, 2016 02:36
客户端身份证验证
// 验证身份证号码
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) {
@tonyc726
tonyc726 / toThousands_1.js
Last active January 14, 2016 03:18
JS千分位格式化,摘录 http://heeroluo.net/article/detail/115
// 方法一
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 July 11, 2019 12:31
Luhn校验银行卡号
/**
* [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 December 24, 2015 11:45
JS数字金额大写转换
var digitUppercase = function(n) {
var fraction = ['角', '分'];
var digit = [
'零', '壹', '贰', '叁', '肆',
'伍', '陆', '柒', '捌', '玖'
];
var unit = [
['元', '万', '亿'],
['', '拾', '佰', '仟']
];
@tonyc726
tonyc726 / color.js
Created November 6, 2015 06:40
JS随机生成颜色值
function color(){
return '#' + Math.floor(0x1000000 + Math.random() * 0x1000000).toString(16).slice(1);
}
@tonyc726
tonyc726 / EventUtil.js
Last active October 19, 2016 03:29
JavaScript高级程序设计之EventUtil
// 简单的通用事件方法
// http://www.imooc.com/wenda/detail/4603
var EventUtil = {
getEvent: function (e) {
return e || window.event;
},
getTarget: function (e) {
return e.target || e.srcElement;