Skip to content

Instantly share code, notes, and snippets.

View luofei2011's full-sized avatar
🏠
Working from home

Poised_flw luofei2011

🏠
Working from home
View GitHub Profile
@luofei2011
luofei2011 / countrycode.json
Last active July 9, 2019 15:42
国际区号JSON
[{"cn":"中国","en":"China","phone_code":"+86"},
{"cn":"美国","en":"United States","phone_code":"+1"},
{"cn":"中国香港","en":"Hong Kong (SAR)","phone_code":"+852"},
{"cn":"中国澳门","en":"Macao","phone_code":"+853"},
{"cn":"中国台湾","en":"Taiwan","phone_code":"+886"},
{"cn":"英国","en":"United Kingdom","phone_code":"+44"},
{"cn":"阿富汗","en":"Afghanistan","phone_code":"+93"},
{"cn":"阿尔巴尼亚","en":"Albania","phone_code":"+355"},
{"cn":"阿尔及利亚","en":"Algeria","phone_code":"+213"},
{"cn":"美属萨摩亚","en":"American Samoa","phone_code":"+684"},
```
function getCode(num) {
num = (num + '').split('');
var map = {0: '', 1: '一', 2: '二', 3: '三', 4: '四', 5: '五', 6: '六', 7: '七', 8: '八', 9: '九', 10: '十'};
var _map = {0: '', 1: '十', 2: '百', 3: '千', 4: '万'};
var now;
var index = 0;
var re = [];
while((now = num.pop())) {
if (+now) {
@luofei2011
luofei2011 / shell-command
Created June 2, 2015 06:34
常用的linux命令
# 得到ip地址(awk使用)
ifconfig | grep "Mask" | awk '$2 {print $2}' | awk -F ':' '{print $2}'
# 找到匹配的文件并删除
find . -name *.jpg -exec rm -rf {} \
# 内容替换
tr "\\n" " "
# 拷贝文件(忽略掉某些文件)
@luofei2011
luofei2011 / check date
Last active August 29, 2015 14:22
is the correct date string
/**
* @description 判断是否为合法的日期字符串
* @param {String} str 目标字符串
* @return {Boolean} 是否是合法的
*/
function check(str) {
var obj = {
1: 31,
2: 28,
3: 31,
@luofei2011
luofei2011 / gist:8108791
Created December 24, 2013 04:28
搞定mouseover和mouseout兼容性的代码
function isMouseLeaveOrEnter(e, handler) {
if (e.type != 'mouseout' && e.type != 'mouseover') return false;
var reltg = e.relatedTarget ? e.relatedTarget : e.type == 'mouseout' ? e.toElement : e.fromElement;
while (reltg && reltg != handler)
reltg = reltg.parentNode;
return (reltg != handler);
}