Skip to content

Instantly share code, notes, and snippets.

View windard's full-sized avatar

Wenqiang Yang windard

View GitHub Profile
@windard
windard / args.sh
Created March 30, 2020 08:21
args.sh
#!/bin/bash
#
msg1='$'
echo "Shell本身的PID(ProcessID)"
printf "The ${msg1}$ is %s\n" "$$"
echo "Shell最后运行的后台Process的PID"
printf "The ${msg1}! is %s\n" "$!"
echo "最后运行的命令的结束代码(返回值)"
@windard
windard / retry_with_times.py
Created December 27, 2019 03:44
retry_with_times
# coding=utf-8
def catch_retry(times):
def inner(func):
def wrapper(*args, **kwargs):
for _ in range(times):
try:
return func(*args, **kwargs)
except Exception as e:
@windard
windard / geo_coding.py
Last active October 23, 2019 12:57
Geohash
# -*- coding: utf-8 -*-
import string
import geohash
base32_string = (string.digits + string.lowercase) \
.replace('a', '').replace('i', '').replace('o', '').replace('l', '')
@windard
windard / ip_coding.py
Last active October 23, 2019 08:29
ip address
# -*- coding: utf-8 -*-
import struct
import ipaddress
def ip2hex(ip, encoding='utf-8'):
if type(ip) in [bytes, str]:
ip = ip.decode(encoding)
elif type(ip) not in [unicode]: