Skip to content

Instantly share code, notes, and snippets.

View eightHundreds's full-sized avatar
💤

eightHundreds

💤
  • China
View GitHub Profile
@eightHundreds
eightHundreds / consoleWithColorReg.js
Created March 21, 2020 15:18
带颜色的console日志正则
const reg=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g
git tag -d $(git tag --points-at HEAD) # 删除当前commit上的tag
git tag -d $(git tag -l) # 删除全部
git push origin --delete $(git tag -l) # 删除远端
# 参考 https://stackoverflow.com/questions/44702757/how-to-remove-all-git-origin-and-local-tags
@eightHundreds
eightHundreds / passVModel.vue
Created February 6, 2020 08:24
v-model 传递
<template lang="pug">
div
ABC(:value="value" @input="onUpdateVisible") // 将v-model 改为 :value和input事件处理 (value和input是默认情况,ABC内组件能通过model配置项修改)
</template>
<script>
export default {
components: {
ABC,
},
@eightHundreds
eightHundreds / 集合操作.js
Last active May 15, 2020 07:00
lodash操作
_.union([1,2,3],[2,3,4]) // [1,2,3,4] 并集
_.intersection([1,2,3],[2,3,4]) // [2,3] 交集
_.xor([1,2,3],[2,3,4]) // [1,4]
_.difference([1,2,3],[2,3,4]) // [1] 差集
function getCoords(elem) { // crossbrowser version
var box = elem.getBoundingClientRect();
var body = document.body;
var docEl = document.documentElement;
var scrollTop = window.pageYOffset || docEl.scrollTop || body.scrollTop; // 获得整个页面已经滚动的距离
var scrollLeft = window.pageXOffset || docEl.scrollLeft || body.scrollLeft;
var clientTop = docEl.clientTop || body.clientTop || 0;
command1 && command2 # 串行执行
command1 & command2 #并行
wait #等待所有进程执行完成
@eightHundreds
eightHundreds / scss.scss
Created July 3, 2019 09:01
在codepen写demo时候能用
@each $height in 10,20,30,40,50,100,200{
height#{$height}{
height:$height;
}
}
@each $borderColor in red,blue,yellow,orange,black{
border-#{$borderColor}{
border:1px solid $borderColor;
}
function getVariableName(unknownVariableInAHash){
return Object.keys(unknownVariableInAHash)[0]
}
const foo = 42
const bar = 'baz'
console.log(getVariableName({foo})) //returns string "foo"
console.log(getVariableName({bar})) //returns string "bar"
{
"title": "Mouse buttons 3,4,5 -> cut, paste, copy",
"rules": [
{
"description": "Maps button 5 to copy, 4 to paste, and 3 to cut to clipboard",
"manipulators": [
{
"type": "basic",
"from": {
"pointing_button": "button4"
function timeout(funct, args, time) {
var deferred = new jQuery.Deferred(),
promise = funct.apply(null, args);
if (promise) {
$.when(promise)
.done(deferred.resolve)
.fail(deferred.reject)
.progress(deferred.notify);
}