Skip to content

Instantly share code, notes, and snippets.

@shivam1283
shivam1283 / 1PromisesAndCallback.md
Last active December 21, 2022 08:31
JS concepts

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);
}
@petrsavchenko
petrsavchenko / System Design Interview - Frontend.md
Last active October 2, 2022 06:48
System Design Interview - Frontend

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?
@jdnichollsc
jdnichollsc / ABC.md
Last active December 7, 2024 17:45
The Job Interview Guide

The Job Interview Guide 💼

And English is a Work in Progress ⌛

const path = require('path');
const fs = require('fs');
const {injectBabelPlugin} = require('react-app-rewired');
const rewireBabelLoader = require('react-app-rewire-babel-loader');
const appDirectory = fs.realpathSync(process.cwd());
const resolveApp = relativePath => path.resolve(appDirectory, relativePath);
module.exports = function override(config, env) {
let isDev = env === 'development';
@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 = {
@com3345
com3345 / untitled.py
Created January 10, 2018 12:08
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 / 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;
}
@jayphelps
jayphelps / package.json
Last active March 24, 2025 01:15
TypeScript output es2015, esm (ES Modules), CJS, UMD, UMD + Min + Gzip. Assumes you install typescript (tsc), rollup, uglifyjs either globally or included as devDependencies
{
"scripts": {
"build": "npm run build:es2015 && npm run build:esm && npm run build:cjs && npm run build:umd && npm run build:umd:min",
"build:es2015": "tsc --module es2015 --target es2015 --outDir dist/es2015",
"build:esm": "tsc --module es2015 --target es5 --outDir dist/esm",
"build:cjs": "tsc --module commonjs --target es5 --outDir dist/cjs",
"build:umd": "rollup dist/esm/index.js --format umd --name YourLibrary --sourceMap --output dist/umd/yourlibrary.js",
"build:umd:min": "cd dist/umd && uglifyjs --compress --mangle --source-map --screw-ie8 --comments --o yourlibrary.min.js -- yourlibrary.js && gzip yourlibrary.min.js -c > yourlibrary.min.js.gz",
}
}
@mentos1386
mentos1386 / Webstorm-Airbnb-Javascript-codeStyle.xml
Created March 12, 2017 11:03
Airbnb inspired Webstorm Javascript CodeStyle
<code_scheme name="Airbnb">
<option name="RIGHT_MARGIN" value="100" />
<option name="HTML_ATTRIBUTE_WRAP" value="4" />
<option name="HTML_ELEMENTS_TO_INSERT_NEW_LINE_BEFORE" value="" />
<option name="HTML_ENFORCE_QUOTES" value="true" />
<DBN-PSQL>
<case-options enabled="false">
<option name="KEYWORD_CASE" value="lower" />
<option name="FUNCTION_CASE" value="lower" />
<option name="PARAMETER_CASE" value="lower" />
@JonasGroeger
JonasGroeger / sync-projects
Last active March 3, 2025 12:06
Gitlab: Clone / Pull all projects in a group
#!/usr/bin/env bash
# Documentation
# https://docs.gitlab.com/ce/api/projects.html#list-projects
NAMESPACE="YOUR_NAMESPACE"
BASE_PATH="https://gitlab.example.com/"
PROJECT_SEARCH_PARAM=""
PROJECT_SELECTION="select(.namespace.name == \"$NAMESPACE\")"
PROJECT_PROJECTION="{ "path": .path, "git": .ssh_url_to_repo }"