Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Poised_flw luofei2011

🏠
Working from home
View GitHub Profile
@luofei2011
luofei2011 / check date
Last active Aug 29, 2015
is the correct date string
View check date
/**
* @description 判断是否为合法的日期字符串
* @param {String} str 目标字符串
* @return {Boolean} 是否是合法的
*/
function check(str) {
var obj = {
1: 31,
2: 28,
3: 31,
@luofei2011
luofei2011 / shell-command
Created Jun 2, 2015
常用的linux命令
View shell-command
# 得到ip地址(awk使用)
ifconfig | grep "Mask" | awk '$2 {print $2}' | awk -F ':' '{print $2}'
# 找到匹配的文件并删除
find . -name *.jpg -exec rm -rf {} \
# 内容替换
tr "\\n" " "
# 拷贝文件(忽略掉某些文件)
View convert nums to zh_cn
```
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 / gist:8108791
Created Dec 24, 2013
搞定mouseover和mouseout兼容性的代码
View gist:8108791
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);
}
View countrycode.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"},