Skip to content

Instantly share code, notes, and snippets.

View ljwrer's full-sized avatar
馃幆
Focusing

Rmaiy ljwrer

馃幆
Focusing
View GitHub Profile
class LRUCache {
capacity: number
map = new Map<number, DoubleListNode>()
young: DoubleListNode = new DoubleListNode()
old: DoubleListNode = new DoubleListNode()
// yound -> node1 -> node2 -> old
constructor(capacity: number) {
this.capacity = capacity
this.young.next = this.old
this.old.prev = this.young
@ljwrer
ljwrer / heap
Last active August 9, 2021 02:34
abstract class Heap<T> {
protected readonly list: (T | null)[] = [null]
constructor (items: T[]) {
this.list.push(...items)
const size = items.length
const op = size >> 1
for (let i = op; i > 0; i--) {
this.heapify(i)
}
export default {
methods: {
addEvent (bus, event, handler) {
if (!this.$_event_busMap) {
this.$_event_busMap = new Map()
}
bus.$on(event, handler)
if (!this.$_event_busMap.has(bus)) {
this.$_event_busMap.set(bus, new Map())
}
import _ from 'lodash'
const arrayFy = value => Array.isArray(value) ? value : [value]
export default class Validator {
constructor () {
this.rulesMap = new Map()
this.validIdMap = new Map()
}
register (name, validateFunc) {
if (_.isRegExp(validateFunc)) {
const check = async function () {
let result={valid:true};
for(const rule of rules){
try{
result = await validator.verify({value, ...rule})
if (result.valid === false) {
return Promise.reject(result)
}
}catch (e){
return Promise.reject(e)
// setTimeout(function(){console.log(4)},0);
// process.nextTick(function () {
// console.log(6)
// })
// setImmediate(function () {
// console.log(7)
// })
// new Promise(function(resolve){
// console.log(1)
// for( var i=0 ; i<10000 ; i++ ){
@ljwrer
ljwrer / down.py
Created September 12, 2017 08:03
download git group (python 3)
from urllib.request import urlopen
import json
import subprocess, shlex
allProjects = urlopen("http://git.analysys.cn/api/v3/groups/fss-modules/projects/?private_token=UjGdeqGEgjhe4S524AME")
allProjectsDict = json.loads(allProjects.read().decode())
for thisProject in allProjectsDict:
try:
thisProjectURL = thisProject['ssh_url_to_repo']
command = shlex.split('git clone %s' % thisProjectURL)
import _ from 'lodash'
import table from './packages/table'
import tableColumn from './packages/table-column'
const createHead = function (columns) {
const h = this.$createElement // eslint-disable-line
return columns.map((col, index) => {
let children, scopedSlots
if (_.size(col.children)) {
children = createHead.call(this, col.children)
}
const renderToolTip = function (des) {
return `<span>${des.title}<span>姘旀场</span></span>`
}
const head = [
{
title:'瀵规瘮',
data:'compare',
fixed:true
},
{
const renderToolTip = function (des) {
return `<span>${des.title}<span>姘旀场</span></span>`
}
const head = [
{
title:'瀵规瘮',
fixed:true
},
{
title:'搴忓彿',