Skip to content

Instantly share code, notes, and snippets.

View zhiweio's full-sized avatar
😊

Wang Zhiwei zhiweio

😊
View GitHub Profile
import logging
import os
import re
import socket
import stat
from datetime import datetime
import paramiko
import pytz
import redo
@zhiweio
zhiweio / draw_map_of_gusu.py
Last active March 14, 2023 05:06
绘图姑苏 Pretty Map of GUSU, SUZHOU
# For local execution (does not require installing the library):
%reload_ext autoreload
%autoreload 2
import sys; sys.path.append('../')
# Prettymaps
from prettymaps import *
# Vsketch
import vsketch
# OSMNX
@zhiweio
zhiweio / supervisor_client.py
Created July 21, 2020 04:17 — forked from jalp/supervisor_client.py
Supervisor api client in Python
import xmlrpclib
class ProcessStatus(object):
RUNNING = 'RUNNING'
STOPPED = 'STOPPED'
FATAL = 'FATAL'
RESTARTING = 'RESTARTING'
SHUTDOWN = 'SHUTDOWN'
@zhiweio
zhiweio / recursive_compare.py
Last active January 15, 2020 07:41
递归比较 Python 数据类型
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function, absolute_import
from datetime import datetime, date
import collections
@zhiweio
zhiweio / header1.py
Last active June 17, 2019 08:11 — forked from arukavina/header1.py
Lazy C&P header
#!usr/bin/env python
# -*- coding: utf-8 -*-
"""
{Description}
{License_info}
"""
# Futures
from __future__ import print_function
@zhiweio
zhiweio / header1b.py
Created June 14, 2019 07:12 — forked from arukavina/header1b.py
Python Header Imports
# Futures
from __future__ import unicode_literals
from __future__ import print_function
# Generic/Built-in
import datetime
import argparse
# Other Libs
import youtube_dl
@zhiweio
zhiweio / excel2pg.py
Created January 14, 2019 07:55
copy excel data to postgres, simple implementation
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from xlrd import xldate_as_datetime
import psycopg2
import xlrd
import sys
DB_CONFIG_TEMPLATE = {
@zhiweio
zhiweio / qingmang.py
Created January 11, 2019 14:53
青芒 笔试题解
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
question1:
大整数加法
'''
def add(num1, num2):
@zhiweio
zhiweio / longest_substring.py
Created January 11, 2019 14:00
最长非重复子字串
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def lsubstring(s):
start = max_len = 0
seen = {}
for i, c in enumerate(s):
if start <= seen.get(c, -1):
start = seen[c] + 1