This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Simple sample for explaining the resolve and reject of Promise | |
async function test(flag) { | |
// | |
return new Promise((resolve, reject)=>{ | |
if(flag) { | |
resolve(0) | |
} else { | |
reject(-1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/tmux | |
# vim: syntax=tmux | |
# set 2nd bind key (like screen) | |
set -g prefix2 C-a | |
# | |
bind C-b last-window | |
# reload config |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# quick back file or dir via ln into Dropbox for syncing | |
BACKUPDIR=~/Dropbox/Mackup | |
PWD=`pwd` | |
function backup() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MinStack: | |
def __init__(self): | |
self.L=[] | |
self.count = 0 | |
def pop(self): | |
self.count -= 1 | |
return self.L.pop()[0] | |
def push(self,x): | |
minval = self.L[-1][1] if self.count > 0 else x | |
d = (x,x) if x < minval else (x, minval) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/user/bin/python | |
import json | |
class DocumentBase(object): | |
def traversal_for_init_dict(self, items): | |
for k in items: | |
if type(items[k]) == dict: | |
setattr(self, k, DocumentDict(**items[k])) | |
elif type(items[k]) == list: |