Skip to content

Instantly share code, notes, and snippets.

View dapangmao's full-sized avatar
🏠
Working from home

Dapangmao dapangmao

🏠
Working from home
View GitHub Profile
function someAsyncThing(x) {
return new Promise(function(resolve, reject) {
// this will throw, x does not exist
if (x > 10) {
resolve(x);
} else {
reject(x);
}
});
};
@dapangmao
dapangmao / bb1.txt
Last active January 1, 2020 01:34
Bloomberg 全体展览
【===========算法============】
【*****leetcode/lintcode*****】
same tree, Binary tree inorder iterator, inorder & postorder traverse BST, binary tree level order traversal(print指定level的binary tree), tree upside down, add next to every tree node, Convert Sorted Array to BST, binary tree的maxSumPath, reverse linkedlist, linkedlist输出倒数K个node的值, linked list取中值, linked list做减法/加法(反序), valid BST, linkedlist找merge point, copy linkedlist with random pointer, flatten BST to linkedlist(把BST替换为2Dlinkedlist,本质不变), depth, interseciton of linked list(一个一步一个多步是否可以(复杂度高)) LRUCache, upside down, recover binary tree from inorder and preorder,
word search I, min stack, stock transaction I(buy date is needed) & II, two sum, subset, unique paths II, merge two/k sorted array/linked list, Find kth largest number(quickselect, array partition), sort colors, remove duplicate from a sorted array, search in sorted rotated array(binary search), search for a range and delete it in array, next permutation, find peak element(一个先降后升的数组,怎么在这个数组中找到
from selenium import webdriver
import time
driver = webdriver.Chrome()
driver.get('http://www.jandown.com/link.php?ref=5YoRMuQ8')
driver.find_element_by_xpath('/html/body/form/table[2]/tbody/tr/td[2]/input').click()
time.sleep(5)
driver.quit()

A link

import pandas as pd
df = pd.read_csv('mypath.csv')
df.columns = [c.lower() for c in df.columns]

from sqlalchemy import create_engine
engine = create_engine('postgresql://username:password@localhost:5432/dbname')
"""
Django settings for forum project.
Generated by 'django-admin startproject' using Django 1.8.2.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
@dapangmao
dapangmao / tips.md
Last active August 29, 2015 14:27
django
from time import time
from concurrent.futures import ProcessPoolExecutor
def gcd(pair):
a, b = pair
low = min(a, b)
for i in range(low, 0, -1):
if a % i == 0 and b % i == 0:
return i
@dapangmao
dapangmao / pattern.md
Last active August 29, 2015 14:21
Design pattern

From here

  1. Decorateor
from functools import wraps

def makebold(fn):
    @wraps(fn)
    def wrapped():
        return "<b>" + fn() + "</b>"
@dapangmao
dapangmao / graph.md
Last active August 29, 2015 14:20
Graph
  • Undirected graph
"""
Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water.

Example 1:

11110
11010
11000
class Solution:
def combinationSum(self, candidates, target):
self.res = []
self.dfs(sorted(candidates), [], target)
return self.result
def dfs(self, candidates, current, target):
if target == 0:
self.res.append(current)
return