Skip to content

Instantly share code, notes, and snippets.

Seunghun Sunmoon Lee SeunghunSunmoonLee

Block or report user

Report or block SeunghunSunmoonLee

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View nodemon.json
{
"events": {
"restart": "kill-port 3010",
"crash": "kill-port 3010"
},
"delay": "1500"
}
@SeunghunSunmoonLee
SeunghunSunmoonLee / async-http.js
Last active May 30, 2019
How to asynchronously use nested http.get request using native node.js method.
View async-http.js
/*
* Complete the function below.
* Instead of returning the answer, log the answer to the console.
* https://jsonmock.hackerrank.com/api/countries/search?name=
*/
function getCountries(s, p) {
let answer = 0;
const https = require("https");
let base_url = `https://jsonmock.hackerrank.com/api/countries/search`;
View 102. Binary Tree Level Order Traversal.js
/**
* Definition for a binary tree node.
* function TreeNode(val) {
* this.val = val;
* this.left = this.right = null;
* }
*/
/**
* @param {TreeNode} root
* @return {number[][]}
@SeunghunSunmoonLee
SeunghunSunmoonLee / permutations.js
Created Apr 17, 2019
leetcode - permutations.js
View permutations.js
/**
* @param {number[]} nums
* @return {number[][]}
*/
function swap(nums, i, j) {
let temp = nums[i]
nums[i] = nums[j]
nums[j] = temp
}
const indent = (length) => {
View gist:edf8fa1d5fc9ee21d4818e80c125ebaa
code --install-extension christian-kohler.npm-intellisense
code --install-extension christian-kohler.path-intellisense
code --install-extension CoenraadS.bracket-pair-colorizer-2
code --install-extension dbaeumer.vscode-eslint
code --install-extension dracula-theme.theme-dracula
code --install-extension dsznajder.es7-react-js-snippets
code --install-extension eamodio.gitlens
code --install-extension esbenp.prettier-vscode
code --install-extension felipecaputo.git-project-manager
code --install-extension formulahendry.auto-close-tag
View flattenArray.js
const flatten = list => list.reduce(
(a, b) => a.concat(Array.isArray(b) ? flatten(b) : b), []
);
@SeunghunSunmoonLee
SeunghunSunmoonLee / mongoimport
Created Jan 7, 2019
import multiple json files from the folder in linux, mac for mongodb using mongoimport
View mongoimport
cd jsonfilesfolder
ls -1 *.json | while read jsonfile; do mongoimport -d shop --file $jsonfile --type json; done
@SeunghunSunmoonLee
SeunghunSunmoonLee / countInversion.js
Created Jan 3, 2019
count inversion using mergesort
View countInversion.js
// Result count: 2407905288
/**
* Counting Inversion Using MergeSort
*/
// let arr = [1,3,5,2,6,4,7,9,8,10]
function merge(a, b) {
let i = 0
let j = 0
let temp = []
@SeunghunSunmoonLee
SeunghunSunmoonLee / mergesort.js
Created Dec 31, 2018
classic merge sort in javascript
View mergesort.js
/*
Classic Merge Sort
*/
let arr = [1,3,5,2,6,4,7,9,8,10]
function merge(a, b) {
let i = 0
let j = 0
let temp = []
while(i < a.length && j < b.length) {
if(a[i] > b[j]) {
View functionDoesntCopyMap.js
function functionDoesntCopyMap() {
let map = {1: 2, 2: 3}
let val = 3
function functionCopiesValue(map, val) {
map[1] --
val --
console.log("inner map, val", map, val)
}
console.log("======functionDoesntCopyMap")
functionCopiesValue(map, val)
You can’t perform that action at this time.