启动新会话:
tmux [new -s 会话名 -n 窗口名]
恢复会话:
tmux at [-t 会话名]
InfiniteDict = lambda: defaultdict(InfiniteDict) # noqa |
# 修改默认 shell | |
set-option -g default-shell /bin/zsh | |
# 启用终端 256 色 | |
set -g default-terminal "screen-256color" | |
# 状态栏编码 | |
set -g status-utf8 on | |
# 状态栏前景色背景色 | |
set -g status-fg white | |
set -g status-bg cyan | |
# 状态栏高亮 |
def longest_substring(str1, str2): | |
""" | |
>>> longest_substring("apple pie available", "apple pies") | |
'apple pie' | |
>>> longest_substring("apples", "appleses") | |
'apples' | |
>>> longest_substring("bapples", "cappleses") | |
'apples' | |
""" | |
result = "" |
class LRUCache: | |
""" LRUCache implemented with HashMap and LinkList | |
>>> cache = LRUCache(3) | |
>>> cache.set(1,1) | |
>>> cache.set(2,2) | |
>>> cache.set(3,3) | |
>>> cache | |
capacity: 3 [(1, 1), (2, 2), (3, 3)] | |
>>> cache.get(1) | |
1 |
import platform | |
import time | |
import sys | |
import binascii | |
import marshal | |
import dis | |
import struct | |
def view_pyc_file(path): |
# ip source https://db-ip.com/db/#downloads | |
import csv | |
import netaddr | |
result = [] | |
with open('dbip-country-2017-05.csv', 'r') as rf, \ | |
open('ip-cidr-CN', 'w') as wf: | |
reader = csv.reader(rf, delimiter=',') | |
for row in reader: |
def binary_search(l, t): | |
low, high = -1, len(l) | |
while low+1 != high: | |
mid = (low + high) / 2 | |
if l[mid] < t: | |
low = mid | |
else: | |
high = mid | |
pos = high | |
if pos >= len(l) or l[pos] != t: |
def flatten(seq): | |
l = [] | |
for elt in seq: | |
t = type(elt) | |
if t is tuple or t is list: | |
for elt2 in flatten(elt): | |
l.append(elt2) | |
else: | |
l.append(elt) | |
return l |