Left-Aligned | Center Aligned | Right Aligned |
---|---|---|
col 3 is | some wordy text | $1600 |
col 2 is | centered | $12 |
zebra stripes | are neat | $1 |
This file contains 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 Context(object): | |
def __init__(self, name): | |
self.file = open(name) | |
def __enter__(self): | |
return self.file | |
def __exit__(self, ctx_type, ctx_value, ctx_traceback): | |
self.file.close() |
This file contains 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
set nohud | |
map h J | |
map l K | |
map c x | |
map C X | |
set cncpcompletion | |
let barposition = "bottom" | |
set typelinkhints | |
set noautofocus |
This file contains 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 threading import _Timer | |
class RepeatedTimer(_Timer): | |
""" | |
See: https://hg.python.org/cpython/file/2.7/Lib/threading.py#l1079 | |
""" | |
def run(self): | |
while not self.finished.is_set(): | |
self.finished.wait(self.interval) | |
self.function(*self.args, **self.kwargs) |
This file contains 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
# make brew link python workable https://github.com/Homebrew/homebrew-core/issues/20985 | |
sudo mkdir -p /usr/local/Frameworks | |
sudo chown -R $(whoami) /usr/local/* | |
brew link python3 |
This file contains 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 collections import defaultdict | |
from heapq import * | |
def dijkstra(edges, f, t): | |
g = defaultdict(list) | |
for l,r,c in edges: | |
g[l].append((c,r)) | |
# dist records the min value of each node in heap. | |
q, seen, dist = [(0,f,())], set(), {f: 0} |
This file contains 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
def reversePairs_using_bst_tree(nums): | |
class Node: | |
def __init__(self, v, left=None, right=None): | |
self.val = v | |
# cnt初始值为1,因为节点本身记录cnt,创建的时候就包含了一次 | |
# cnt记录大于等于v的节点个数 | |
self.cnt = 1 | |
self.left = left | |
self.right = right |
This file contains 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 LinkedNode: | |
def __init__(self, value, next): | |
self.value = value | |
self.next = next | |
class LRUCache: | |
def __init__(self, capacity): | |
self.head = LinkedNode(None, None) | |
self.tail = None |
This file contains 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
def bisect_left(data, v): | |
left, right = 0, len(data) | |
while left < right: | |
mid = (left+right)//2 | |
if v <= data[mid]: | |
right = mid | |
else: | |
left = mid+1 | |
return right |
This file contains 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
def next_permutation(nums): | |
""" | |
:type nums: List[int] | |
:rtype: void Do not return anything, modify nums in-place instead. | |
""" | |
if not nums: return nums | |
l = len(nums) | |
i, j = l - 2, l - 1 | |
while i >= 0 and nums[i] >= nums[i + 1]: | |
i -= 1 |
OlderNewer