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')
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
function someAsyncThing(x) { | |
return new Promise(function(resolve, reject) { | |
// this will throw, x does not exist | |
if (x > 10) { | |
resolve(x); | |
} else { | |
reject(x); | |
} | |
}); | |
}; |
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
【===========算法============】 | |
【*****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(一个先降后升的数组,怎么在这个数组中找到 |
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
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() |
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
""" | |
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/ |
- Python问答网站ChinaPy“开发”手记
- Install django
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
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 |
From here
- Decorateor
from functools import wraps
def makebold(fn):
@wraps(fn)
def wrapped():
return "<b>" + fn() + "</b>"
- 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
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 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 |