Skip to content

Instantly share code, notes, and snippets.

View shsunmoonlee's full-sized avatar

Seunghun Sunmoon Lee shsunmoonlee

View GitHub Profile
shsunmoonlee / LRU Cache.js
Created February 4, 2020 13:39
Classic LRU Cache in JavaScript. Goal: Real World Implementation
function ListNode(key, value) {
this.value = value
this.key = key = this.prev = null
* @param {number} capacity
var LRUCache = function(capacity) {
JuHwon / Dockerfile
Last active April 27, 2020 02:51
react-boilerplate dockerfile example
FROM containership/alpine-node-yarn
COPY internals/scripts myappname/internals/scripts
COPY package.json myappname/package.json
COPY yarn.lock myappname/yarn.lock
COPY build myappname/build
COPY server myappname/server
WORKDIR myappname/
ereli / countries.sql
Last active June 6, 2024 14:22 — forked from adhipg/countries.sql
Sql dump of all the Countries, Country Codes, Phone codes. PostgreSQL compatible
CREATE SEQUENCE country_seq;
id int NOT NULL DEFAULT NEXTVAL ('country_seq'),
iso char(2) NOT NULL,
name varchar(80) NOT NULL,
nicename varchar(80) NOT NULL,
iso3 char(3) DEFAULT NULL,
numcode smallint DEFAULT NULL,
phonecode int NOT NULL,
marshallswain / authentication.js
Last active September 24, 2021 08:59
Example tools for using querystring redirects with Feathers OAuth login.
'use strict';
const authentication = require('feathers-authentication');
const jwt = require('feathers-authentication-jwt');
const local = require('feathers-authentication-local');
const oauth2 = require('feathers-authentication-oauth2');
const GithubStrategy = require('passport-github');
// Bring in the oauth-handler
const makeHandler = require('./oauth-handler');
ar5had / mongoose-connection-options.js
Created January 20, 2017 07:17
mLab recommended mongoose connection options. More supported connections for the underlying Node Native driver can be found here:
// mongoose 4.3.x
var mongoose = require('mongoose');
* Mongoose by default sets the auto_reconnect option to true.
* We recommend setting socket options at both the server and replica set level.
* We recommend a 30 second connection timeout because it allows for
* plenty of time in most operating environments.
var options = { server: { socketOptions: { keepAlive: 300000, connectTimeoutMS: 30000 } },
tpae / minHeap.js
Last active April 8, 2024 14:14
JavaScript implementation of Min Heap Data Structure
// Implement a min heap:
// -> insert, extract_min
// property:
// - elements are in ascending order
// - complete binary tree (node is smaller than it’s children)
// - root is the most minimum
// - insert takes O(logn) time
// - insert to the bottom right
haocong / karatsuba.js
Last active December 22, 2018 19:53
Karatsuba Multiplication in JavaScript
* Karatsuba Multiplication
* @param {Number} x - first number
* @param {Number} y - second number
* @return {Number} Multiply of x and y
function karatsubaMulti(x, y) {
let n = Math.min(('' + x).length, ('' + y).length);
patik /
Last active May 30, 2024 07:59
How to squash commits in git

Squashing Git Commits

The easy and flexible way

This method avoids merge conflicts if you have periodically pulled master into your branch. It also gives you the opportunity to squash into more than 1 commit, or to re-arrange your code into completely different commits (e.g. if you ended up working on three different features but the commits were not consecutive).

Note: You cannot use this method if you intend to open a pull request to merge your feature branch. This method requires committing directly to master.

Switch to the master branch and make sure you are up to date:

fabien0102 / gist:88dcaa184d801fd5e67a
Created March 15, 2015 09:33
Import multiple json files into mongoDB
ls -1 *.json | while read jsonfile; do mongoimport -d support -c logs -file $jsonfile --jsonArray -type json; done
bcherny / gist:de24955c15430efd99f1
Last active April 30, 2021 12:09
How to squash commits with git

Let's say you have a Pull Request from myBranch to master with 3 commits, and you want them to appear as a single commit in master.

If you're merging on the command line, this is trivial:

git checkout master
git merge --squash myBranch
git commit