This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from 'axios'; | |
const tr = p => (throw new Error(`Oops, you are missing a required field: "${p}"`)); | |
const api = async function* ({path = tr('url'), params = {page: 1, pageSize: 10}}) { | |
let page = -1; | |
do { | |
try { | |
const {page: nextPage, pageSize, total, items} = await axios.get(path, {params}); | |
page = nextPage; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<button :class="computedClass"> | |
<slot></slot> | |
</button> | |
</template> | |
<script> | |
export default { | |
name: 'ip-button', | |
props: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const moment = require('moment-timezone'); | |
const {mongo} = require('../mongodb'); | |
const DEFAULT_VALUES = { | |
NOW: new Date() | |
}; | |
const MongoQueryParser = class { | |
constructor({params, values}) { | |
Object.assign(this, { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
date=`date "+%Y-%m-%dT%H_%M_%S"` | |
HOME=/YOUR/LOCALHOME | |
SERVER=ID@HOST | |
DIR=backup | |
rsync -azP \ | |
--bwlimit=500 \ | |
--delete \ | |
--delete-excluded \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const splice = (arr = [], start = 0, deleteCount = 0, ...items) => { | |
if (start < 0 || arr.length - 1 < start) { | |
return [[], [...arr, ...items]]; | |
} | |
const arr1 = []; | |
const arr2 = [...arr]; | |
const result = []; | |
for (let i = 0; i < arr.length; i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const prime4 = end =>{ | |
if(end < 2) return []; | |
const num = [2]; | |
for(let i = 3; i <= end; i += 2) num.push(i); | |
for(let i = 1, j = num.length, curr; i < j; i++){ | |
if(curr = num[i]){ | |
const min = curr * curr; | |
if(end < min) break; | |
for(let k = (min - 1) / 2; k < j; k += curr) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const prime3 = end =>{ | |
if(end < 2) return []; | |
const num = [2]; | |
for(let i = 3; i <= end; i += 2) num.push(i); | |
for(let k = 1; k < num.length; k++){ | |
let curr = num[k], min = curr * curr, i = num.length; | |
if(num[i - 1] < min) break; | |
while(i--){ | |
if(num[i] < min) break; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const prime2 = end => { | |
if(end < 2) return []; | |
const prime = [2], num = []; | |
let curr = 2, i = 3, j; | |
while(i <= end){ | |
num.push(i); | |
i += 2; | |
} | |
while(num.length){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const prime1 = end => { | |
const prime = [], num = []; | |
let curr = 2, i = curr; | |
while(i <= end) num.push(i++); | |
while(num.length){ | |
prime.push(curr = num.shift()); | |
i = num.length; | |
while(i--) if(num[i] % curr == 0) num.splice(i, 1); | |
if(curr * curr > num[num.length - 1]) break; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(_ => { | |
for (let i = 2; i < 10; i++) { | |
for (let j = 1; j < 10; j++) { | |
console.log(`${i} * ${j} = ${i * j}`); | |
} | |
console.log(''); | |
} | |
})(); |
NewerOlder