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
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 / tips.md
Last active August 29, 2015 14:27
django
"""
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/

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')
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()
@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(一个先降后升的数组,怎么在这个数组中找到
function someAsyncThing(x) {
return new Promise(function(resolve, reject) {
// this will throw, x does not exist
if (x > 10) {
resolve(x);
} else {
reject(x);
}
});
};
<!doctype html>
<html ng-app="app">
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular-animate.js"></script>
<!-- <script src="http://ui-grid.info/docs/grunt-scripts/csv.js"></script>
<script src="http://ui-grid.info/docs/grunt-scripts/pdfmake.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular-touch.js"></script>
<script src="http://ui-grid.info/docs/grunt-scripts/vfs_fonts.js"></script> -->
(function() {
angular.module("loc8rApp", ["ngRoute", "ngSanitize", "ui.bootstrap"]);
function e(e, t) {
e.when("/", {
templateUrl: "/home/home.view.html",
controller: "homeCtrl",
controllerAs: "vm"
}).when("/about", {
templateUrl: "/common/views/genericText.view.html",
@dapangmao
dapangmao / file1.md
Created February 1, 2016 20:50
minimal scrapy

Minimal Scrapy

import os
import subprocess

from __future__ import print_function