# Remotes: upstream, origin, team
# Branchs: dev, feature
# Set Remote
git remote add upstream "upstream url"
git remote add team "team url"
# Check remote details
git remote -v
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 RPN(): | |
_input_priority = { | |
'*': 5, | |
'/': 5, | |
'+': 3, | |
'-': 3, | |
'(': 7, | |
} | |
_instack_priority = { | |
'*': 6, |
L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns
Compress 1K bytes with Zippy ............. 3,000 ns = 3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns = 20 µs
SSD random read ........................ 150,000 ns = 150 µs
Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs
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
import random | |
import time | |
import unittest | |
__all__=['Cache'] | |
_current_time_ms = lambda: int(round(time.time() * 1000)) | |
""" |
#System Design Interview Cheatsheet
Picking the right architecture = Picking the right battles + Managing trade-offs
##Basic Steps
- Clarify and agree on the scope of the system
- User cases (description of sequences of events that, taken together, lead to a system doing something useful)
- Who is going to use it?
- How are they going to use it?
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
var createFilter = function(i) { | |
return { | |
before: function(req) { | |
return new Promise(function(resolve, reject) { | |
setTimeout(function() { | |
console.log('[before hook] ' + i); | |
resolve(req); | |
}, 500); | |
}); | |
}, |
I hereby claim:
- I am haocs on github.
- I am haocs (https://keybase.io/haocs) on keybase.
- I have a public key whose fingerprint is 4D6B F6A5 B482 44A8 2752 D189 978F 38F6 82A1 2F91
To claim this, I am signing this object:
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
// Allow CORS for client side JS tests | |
app.use(function(req, res, next) { | |
res.header("Access-Control-Allow-Origin", '*'); | |
res.header("Access-Control-Allow-Methods", 'HEAD,GET,PUT,POST,DELETE,PATCH,OPTIONS'); | |
// Allow all custom headers in reqeusts | |
res.header("Access-Control-Allow-Headers", req.headers['access-control-request-headers']); | |
// Specify headers | |
//res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization, Content-Length, X-Requested-With, x-ms-client-request-id'); | |
// intercept OPTIONS method |
def isDAG(G):
# status: 1 discover 2 visited
def has_cycle(G, status, node):
if status[node] == 2:
return False
status[node] = 1
neighbors = G[node]
for neighbor in neighbors:
if status[neighbor] == 1:
def binary_left(seq, target):
l, r = 0, len(seq) - 1
while l < r:
mid = (l + r) // 2 # always choose the left half
# if seq[mid] == target:
# r = mid
if seq[mid] >= target:
r = mid
else:
OlderNewer