干货码技算法篇

8 篇文章 0 订阅
2 篇文章 0 订阅
Array.prototype.unique=function(){
	var r = [];var obj = {};
	for (var i=0,l=this.length; i<l; i++) {
		var item=this[i];
        if (!obj[item]) {
			r.push(item);
            obj[item] = 1;
		}
	}
    return r;
};
Array.prototype.chunk =function(process, context){
    setTimeout(function() {
        process.call(context, this.shift());
        if (this.length > 0) {
            setTimeout(arguments.callee, 100);
        }
    }, 100);
}
Array.prototype.forEach = function forEach( callback, thisArg ) {
        var T, k;
        if ( this == null ) {
            throw new TypeError( "this is null or not defined" );
        }
        var O = Object(this);
        var len = O.length >>> 0;
        if ( typeof callback !== "function" ) {
            throw new TypeError( callback + " is not a function" );
        }
        if ( arguments.length > 1 ) {
            T = thisArg;
        }
        k = 0;
        while( k < len ) {
            var kValue;
            if ( k in O ) {
                kValue = O[ k ];
                callback.call( T, kValue, k, O );
            }
            k++;
        }
    };
 if (!document.querySelector) {
    document.querySelector = function (selectors) {
        var elements = document.querySelectorAll(selectors);
        return (elements.length) ? elements[0] : null;
	};
	
}
'function(){ if(a>b){ return a }else{ return b } }'.match(/(?<=^function\(\)\{).*(?=\}$)/)[0]
let c:string="abcdefg"
console.time(`3`);let d:string="";
for(let i=c.length-1;i>-1;i--){d=d+c.charAt(i);}
console.timeEnd(`3`);console.log(d);
console.time(`5`);'!@#……%.*&.—_.gif'.replace(/([^_]|_)+\./,'\.');console.timeEnd(`5`);
console.time(`6`);'!@#……%.*&.—_.gif'.replace(/().*(?=)\./,'\.');console.timeEnd(`6`);
String.prototype.suffix=function(v){return v.replace(/().*(?=)\./,'\.');}
String.prototype.trim=function(){return this.replace(/(^\s+)|(\s+$)/g,'')};
'tcdNumber 8'.match(/(?<=\s).*(?=$)/)[0]
'tcdNumber 8'.match(/(\d)+/)[0]
[{name: "accp", value: 11},{name: "admin", value: 10}].find(v=> v.name=='admin')
const tasks = [];
for (var i = 0; i < 5; i++) {
    ((j) => {
        tasks.push(new Promise((resolve) => {
            setTimeout(() => {
                console.log(new Date, j);
                resolve();  // 这里一定要 resolve,否则代码不会按预期 work
            }, 1000 * j);   // 定时器的超时时间逐步增加
        }));
    })(i);
}
Promise.all(tasks).then(() => {
    setTimeout(() => {
        console.log(new Date, i);
    }, 1000);   // 注意这里只需要把超时设置为 1 秒
});
//---------------------------------------//
const tasks = []; // 这里存放异步操作的 Promise
const output = (i) => new Promise((resolve) => {
    setTimeout(() => {
        console.log(new Date, i);
        resolve();
    }, 1000 * i);
});

// 生成全部的异步操作
for (var i = 0; i < 5; i++) {
    tasks.push(output(i));
}

// 异步操作完成之后,输出最后的 i
Promise.all(tasks).then(() => {
    setTimeout(() => {
        console.log(new Date, i);
    }, 1000);
});
var hexChars=new Array();
function onInit(){
	hexChars[0]='0';hexChars[1]='1';hexChars[2]='2';hexChars[3]='3';
	hexChars[4]='4';hexChars[5]='5';hexChars[6]='6';hexChars[7]='7';
	hexChars[8]='8';hexChars[9]='9';hexChars[10]='A';hexChars[11]='B';
	hexChars[12]='C';hexChars[13]='D';hexChars[14]='E';hexChars[15]='F';
	for(var d0=15,d1;d0>-1;d0--){
		for(d1=15;d1>-1;d1--){
			hexChars[d0*16+d1]=hexChars[d0]+hexChars[d1];
		}
	};
}onInit();
function randColor() {
return "#"+hexChars[Math.floor(Math.random()*256)]+hexChars[Math.floor(Math.random()*16)]
}
hexChars.findIndex(item=> item=== '1A');
if (!Array.prototype.forEach)
{
    Array.prototype.forEach = function(fun /*, thisp*/)
    {
        var len = this.length;
        if (typeof fun != "function")
            throw new TypeError();

        var thisp = arguments[1];
        for (var i = 0; i < len; i++)
        {
            if (i in this)
                fun.call(thisp, this[i], i, this);
        }
    };
}
Array.prototype.remove = function(from) {
var rest = this.slice(from+1||this.length);
rest.forEach(function(item,index){
Object.defineProperty(item,'id',{value:item.id-1})
});this.length=from<0?this.length+from:from;
return this.push.apply(this, rest);
};
Array.prototype.search=function(str) {
    var newList = [];
    var startChar = str.charAt(0);
    var strLen = str.length;
    for (var i = 0; i < this.length; i++) {
        var obj = this[i];
        var isMatch = false;
        for (var p in obj) {
            if ( typeof (obj[p]) == "function") {
                obj[p]();
            } else {
                var curItem = "";
                if(obj[p]!=null){
                    curItem = obj[p];
                }
                for (var j = 0; j < curItem.length; j++) {
                    if (curItem.charAt(j) == startChar)
                    {
                        if (curItem.substring(j).substring(0, strLen) == str)
                        {
                            isMatch = true;
                            break;
                        }
                    }
                }
            }
        }
        if (isMatch) {
            newList.push(obj);
        }
    }
    return newList;
}

ffmpeg -i “concat:input1.avi|input2.avi|input3.avi” -c copy output.avi

ffmpeg -i 3.mp4 -vn -y -acodec copy 3.aac
ffmpeg -i baow.qsv -vcodec copy -an w.mp4
ffmpeg -ss 00:00:23 -t 00:00:08 -i baow.flv -vcodec copy -acodec copy 1.flv
ffmpeg -ss 00:03:23.000 -t 00:00:03.200 -i Lihuaxu.flv -vcodec copy -acodec copy 10.flv
ffmpeg -i “concat:1.ts|2.ts|3.ts|4.ts|5.ts|6.ts|7.ts|8.ts|9.ts|10.ts” -c copy out.flv
for /l %i in (1,1,10) do (ffmpeg -i %i.flv -c copy -bsf:v h264_mp4toannexb -f mpegts %i.ts)

ffmpeg -i “concat:1.ts|2.ts|3.ts|4.ts|5.ts|6.ts|7.ts|8.ts|9.ts|10.ts” -c copy -bsf:a aac_adtstoasc -movflags +faststart out.avi
单点登录?微服务通过主API proxy,验证在主API。
工具SAML 2.0 SSO
netstat -a -n -o
taskkill /pid 8648 -f

let pending = []; //声明一个数组用于存储每个ajax请求的取消函数和ajax标识
let cancelToken = axios.CancelToken;
let removePending = (config) => {
for (let p in pending) {
if (pending[p].u === config.url + ‘&’ + config.method) { //当当前请求在数组中存在时执行函数体
pending[p].f(); //执行取消操作
pending.splice(p, 1); //把这条记录从数组中移除
}
}
};

//添加请求拦截器
axios.interceptors.request.use(config => {
removePending(config); //在一个ajax发送前执行一下取消操作
config.cancelToken = new cancelToken(© => {
// 这里的ajax标识我是用请求地址&请求方式拼接的字符串,当然你可以选择其他的一些方式
pending.push({u: config.url + ‘&’ + config.method, f: c});
});
return config;
}, error => {
return Promise.reject(error);
});

//添加响应拦截器
axios.interceptors.response.use(response => {
removePending(response.config); //在一个ajax响应后再执行一下取消操作,把已经完成的请求从pending中移除
return response;
}, error => {
return {
data: {
success: false,
cancel: true,
errorMsg: ‘请求已关闭’
}
};
// 返回一个空对象,主要是防止控制台报错
});

ALTER TABLE admin CONVERT TO CHARACTER SET utf8//修改mysql的admin表所有字段字符集为utf8

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值