function format1(inputString) {
// String slicing approach
return inputString.slice(0, 4) + 'Y' +
inputString.slice(4, 6) + 'M' +
inputString.slice(6, 8) + 'D ' +
inputString.slice(8, 10) + ':' +
inputString.slice(10, 12) + ':' +
inputString.slice(12, 14);
This file contains 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
function skipOne(): Promise<void> { | |
return new Promise(((resolve, reject) => { | |
setTimeout(resolve, 0) | |
})) | |
} | |
export class TaskManagerPromise<T> extends Promise<T> { |
- General reqs
Who is the customer?
How and why they gonna use it?
Are they all from one country or from all over the world?
What are they using now to solve the problem?
How many customers we are expecting with simultanious interactions?
This file contains 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
def summmaryranges(nums): | |
ranges = [] | |
for num in nums: | |
if not ranges or num - ranges[-1][-1] > 1: | |
ranges.append([]) | |
ranges[-1][1:] = [num] | |
return ['->'.join(map(str, r)) for r in ranges] | |
def reverse(l, r, cl): | |
while l < r: |
This file contains 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
''' | |
moving avg,就是一个stream输入, | |
给一个int getNow()API获取当前timestamp, | |
完成两个函数void record(int value)和double getAvg(), | |
有输入时会自动call record,然后call getAvg()时返回5分钟内的平均值。 | |
getMedium -> quick select | |
''' | |
from collections import deque |
This file contains 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
// Algorithm from http://csis.pace.edu/~wolf/CS122/infix-postfix.htm | |
function infixToPostfix(exp) { | |
const infix = exp.match(/(\*\*)|[\+\-\*\/\%\(\)]|([0-9]+([\.][0-9]+)?)/g); | |
const presedences = ['-', '+', '**', '*', '/', '%']; | |
let opsStack = []; | |
let postfix = []; | |
for (let token of infix) { | |
// 1. Print operands as they arrive. |
This file contains 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
yum install -y m2crypto python-setuptools | |
yum install -y python-pip | |
pip install shadowsocks | |
vim /etc/shadowsocks.json | |
{ | |
"server":"0.0.0.0", | |
"server_port":8388, | |
"local_port":1080, | |
"password":"passwd", | |
"timeout":600, |
This file contains 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
#!/usr/bin/env bash | |
set -e | |
# allow being run from somewhere other than the git rootdir | |
gitroot=$(git rev-parse --show-cdup) | |
# default gitroot to . if we're already at the rootdir | |
gitroot=${gitroot:-.}; | |
nm_bin=$gitroot/node_modules/.bin |
NewerOlder