Skip to content

Instantly share code, notes, and snippets.

@licaomeng
licaomeng / TaskManager.ts
Created October 22, 2022 09:40 — forked from Wicpar/TaskManager.ts
A Typescript task manager that allows promises to be run sequencially. Can be paused and resumed. An onStart event is added to the enqueued promise.
function skipOne(): Promise<void> {
return new Promise(((resolve, reject) => {
setTimeout(resolve, 0)
}))
}
export class TaskManagerPromise<T> extends Promise<T> {

System Design interview - Frontend

Sections to cover in the design:

  1. 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?

Callback

function loadScript(src) {
  // creates a <script> tag and append it to the page
  // this causes the script with given src to start loading and run when complete
  let script = document.createElement('script');
  script.src = src;
  document.head.append(script);
}
@licaomeng
licaomeng / ABC.md
Created October 2, 2022 04:55 — forked from jdnichollsc/ABC.md
The Job Interview Guide

The Job Interview Guide 💼

And English is a Work in Progress ⌛

@licaomeng
licaomeng / indeed2.py
Created August 30, 2022 14:26 — forked from com3345/interview2.py
indeed interview2
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:
@licaomeng
licaomeng / indeed1.py
Created August 30, 2022 14:26 — forked from com3345/untitled.py
indeed interview
'''
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
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,
@licaomeng
licaomeng / eslint-changed.sh
Created May 27, 2019 03:06 — forked from kentcdodds/eslint-changed.sh
Shell script to lint only changed files to be used as a githook (specific to my project)
#!/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
@licaomeng
licaomeng / ngrok-installation.md
Created March 5, 2019 16:02 — forked from wosephjeber/ngrok-installation.md
Installing ngrok on Mac

#Installing ngrok on OSX

  1. Download ngrok
  2. Unzip it to your Applications directory
  3. Create a symlink (instructions below)

Creating a symlink to ngrok

Run the following two commands in Terminal to create the symlink.

# cd into your local bin directory