Skip to content

Instantly share code, notes, and snippets.

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

毛毛星 XingMXTeam

🏠
Working from home
View GitHub Profile
@XingMXTeam
XingMXTeam / change2Array.js
Created August 16, 2017 06:02
arguments to array
Array.slice.call(arguments);
[].slice.call(arguments);
@XingMXTeam
XingMXTeam / check.js
Created August 16, 2017 06:00
feature check
//特性检测
if (window.XMLHttpRequest) {
new XMLHttpRequest();
}
//特性推断:A存在则判断B也存在
if (document.getElementsByTagName) {
element = document.getElementById(id);
}
@XingMXTeam
XingMXTeam / triangle.scss
Last active August 16, 2017 05:24
triangle
&:before {
//set position
top: rem(-14px);
left: rem(20px);
//set size
border-width: rem(8px);
//set color
border-bottom-color: #FF0000;
@XingMXTeam
XingMXTeam / error.js
Created August 2, 2017 00:48
A way handle not catched error by Node
process.on('unhandledRejection', function (err, p) {
console.error(err.stack)
});
@XingMXTeam
XingMXTeam / center.scss
Created April 14, 2017 07:46
垂直居中
@mixin verticalCenterAll() {
content: '';
display: inline-block;
vertical-align: middle;
}
.centerAll::before {
@include verticalCenterAll();
}
@mixin maskEffect($opacity) {
@include size(100%);
@include position(absolute, 0 0);
content: '';
background: rgba(0, 0, 0, $opacity);
display: inline-block;
}
.maskover::after {
@mixin textOverflow($lineNum) {
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: $lineNum;
-webkit-box-orient: vertical;
}
.line_1px:after{
height: 1px;
content: '';
background: #E6EAF2;
width: 100%;
display: block;
}
@XingMXTeam
XingMXTeam / config.js
Last active April 14, 2017 07:47
可维护代码:写一个函数,根据结婚的次数给出婚假的天数。如果未婚,婚假天数当然是 0 天,如果是初婚,婚假天数为 15 天,如果是再婚或第 N 次结婚(N >= 2),则婚假天数为 3 天。
exports.holiday_data = {
// year: holidays
0: 0,
1: 15,
'other': 3
};