Skip to content

Instantly share code, notes, and snippets.

" ==============================================================================
" Author: Alan Dong
" Version: 0.3.5
" Last Modified Date: 8/17/2018
" Description: My Vim Configuration file for Server
" ==============================================================================
" set shell for bash as default
set shell=/bin/bash
" ==============================================================================
" Author: Alan Dong
" Version: 0.3.4
" README: TODO
" Last Modified Date: 12/07/2018
" Description: My Vim Configuration file
" ==============================================================================
" set shell for bash as default
set shell=/bin/bash
@adong
adong / javascript_closure.js
Last active April 5, 2024 16:55
javascript closure trap
// What is the result of the following?
for (var i=0; i<10; ++i) {
setTimeout(function() {
console.log(i);
}, 1000);
}
// using IIFE (immediately invoked function)
// with delay
@adong
adong / memoize_function.js
Created October 23, 2018 18:03
Memoize function
function memoize(func) {
var memo = {};
var slice = Array.prototype.slice;
return function() {
var args = slice.call(arguments); // what if func(1,2,3) needs to be treated as the same as func(2,3,1)
if (args in memo) {
@adong
adong / Load_JS_Snippets.js
Created October 9, 2018 21:17
Load external javascript lib from dev tool
(function() {
var u = 'http://example.com/bookmarklet.js';
u = 'https://cdn.jsdelivr.net/npm/[email protected]/build/circular-json.node.min.js';
var s = document.createElement('script');
s.type = 'text/javascript';
s.charset = 'utf-8';
s.src = u;
document.body.appendChild(s);
})()
@adong
adong / zshrc_file
Last active December 8, 2018 04:54
zshrc
# Path to your oh-my-zsh installation.
export ZSH=~/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="robbyrussell"
# Uncomment the following line to use case-sensitive completion.