Skip to content

Instantly share code, notes, and snippets.

@licaomeng
licaomeng / JavaScript-Map.js
Created September 14, 2017 15:24
Map Utility for JavaScript
/**
* Created by lica on 6/12/2016.
*/
function Map() {
this.container = new Object();
}
Map.prototype.put = function (key, value) {
this.container[key] = value;
}
@licaomeng
licaomeng / JavaScript-Promise-Lite.js
Created May 16, 2018 13:53
JavaScript-Promise-Lite
function MyPromise(fn) {
this.resolve;
this.reject;
_this = this;
setTimeout(function () {
fn(_this.resolveFunc.bind(_this), _this.rejectFunc.bind(_this));
}, 0)
}
MyPromise.prototype = {
@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
@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
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 / infix-to-postfix.js
Last active August 28, 2020 15:55
infix-to-postfix
// 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.
@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
@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 / 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 ⌛

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);
}