Skip to content

Instantly share code, notes, and snippets.

@tonyc726
tonyc726 / regex-weburl.js
Created November 11, 2013 08:43 — forked from dperini/regex-weburl.js
正则验证URL是否合法
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Updated: 2010/12/05
// License: MIT
//
// Copyright (c) 2010-2013 Diego Perini (http://www.iport.it)
//
// Permission is hereby granted, free of charge, to any person
@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 / 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 / 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;
@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 / git_config.md
Last active January 8, 2019 17:35
Git 小记 -- 记录一些平时常用的git技巧

1.同一台电脑可以有2个git账号(不同网站的)

文件路径:~/.ssh/config

首先不同网站,当然可以使用同一个邮箱,比如我的github,gitlab,bitbucket的账号都是monkeysuzie[at]gmail.com 这时候不用担心密钥的问题,因为这些网站push pull 认证的唯一性的是邮箱 比如我的windows 上 2个账号一个gitlab 一个github (用的都是id_rsa)

host github
  hostname github.com

Port 22

@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 / 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) {
# remove node_modules in floder
find . -name 'node_modules' -type d -prune -exec rm -rf '{}' +
# rename
rename -d "Typescript" ./