Skip to content

Instantly share code, notes, and snippets.

View willwangcc's full-sized avatar
⚙️
workflow

Will willwangcc

⚙️
workflow
View GitHub Profile
@willwangcc
willwangcc / 0_reuse_code.js
Last active August 29, 2015 14:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@willwangcc
willwangcc / python_resources.md
Last active August 29, 2015 14:10 — forked from jookyboi/python_resources.md
Python-related modules and guides.

Packages

  • lxml - Pythonic binding for the C libraries libxml2 and libxslt.
  • boto - Python interface to Amazon Web Services
  • Django - Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.
  • Fabric - Library and command-line tool for streamlining the use of SSH for application deployment or systems administration task.
  • PyMongo - Tools for working with MongoDB, and is the recommended way to work with MongoDB from Python.
  • Celery - Task queue to distribute work across threads or machines.
  • pytz - pytz brings the Olson tz database into Python. This library allows accurate and cross platform timezone calculations using Python 2.4 or higher.

Guides

@willwangcc
willwangcc / Export-your-kindle-highlights
Created December 10, 2014 01:54
Export/Download Your Kindle Highlights into text at MAC.
#author:hellosec via http://www.zhihu.com/question/23031778
#instructions:only text(time & position omitted)
import os
note_path='/Volumes/Kindle/documents/My Clippings.txt'
f=open(note_path,'r+')
digest_path='/Users/yangxin/Desktop/digest/'
os.mkdir(digest_path)
while True:
onenote=[]
@willwangcc
willwangcc / Kruskal`sMST.py
Created December 15, 2014 03:35
Kruskal`sMST: to find a minimum spanning tree for a connected weighted graph # tests: kruskal(graph) # graph = {'vertices': ['A', 'B', 'C', 'D', 'E', 'F'], 'edges': set([(4, 'A', 'B'),(8, 'A', 'C'),(15, 'A', 'D'),(16, 'B', 'C'),(23, 'B', 'D'),(42, 'C', 'D'),]) # expected is: set([(15, 'A', 'D'), (4, 'A', 'B'), (8, 'A', 'C')])
#! /usr/bin/env python
#coding:utf-8
# author : wzx, 2123409
# date: Dec 14, 2014
# kruskal : graph{vertices,edge} -> set([weight,vertices])
# to find a minimum spanning tree for a connected weighted graph
# algorithm
# example: kruskal(graph)
# graph:(4, 'A', 'B'),(8, 'A', 'C'),(15, 'A', 'D'),(16, 'B', 'C'),(23, 'B', 'D'),(42, 'C', 'D')
# Given n processes, each process has a unique PID (process id) and its PPID (parent process id).
# Each process only has one parent process, but may have one or more children processes.
# This is just like a tree structure. Only one process has PPID that is 0,
# which means this process has no parent process. All the PIDs will be distinct positive integers.
# We use two list of integers to represent a list of processes,
# where the first list contains PID for each process and the second list contains the corresponding PPID.
# Now given the two lists, and a PID representing a process you want to kill,
class Solution(object):
def findSubsequences(self, nums):
"""
:type nums: List[int]
:rtype: List[List[int]]
"""
dp = set()
for n in nums:
for y in list(dp):
if n >= y[-1]:
# Time: O(n)
# Space: O(1)
# 31 Next Permutation
# Edge case
'''
https://www.nayuki.io/res/next-lexicographical-permutation-algorithm/next-permutation-algorithm.png
'''
class Solution(object):
def nextPermutation(self, nums):
# Time: O(n!)
# Space: O(n!)
# 46. Permutations
class Solution(object):
def permute(self, nums):
"""
:type nums: List[int]
# Time: O(n)
# Space: O(1)
# 3. Longest substring without repeating characters
class Solution(object):
def lengthOfLongestSubstring(self, s):
"""
:type s: str
:rtype: int
# Time: O(n)
# Space: O(1)
# 11. Container With Most Water
class Solution(object):
def maxArea(self, height):
"""
:type height: List[int]
:rtype: int