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
# -*- 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]: |
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
# -*- coding: utf-8 -*- | |
import string | |
import geohash | |
base32_string = (string.digits + string.lowercase) \ | |
.replace('a', '').replace('i', '').replace('o', '').replace('l', '') | |
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
#!/bin/bash | |
# | |
msg1='$' | |
echo "Shell本身的PID(ProcessID)" | |
printf "The ${msg1}$ is %s\n" "$$" | |
echo "Shell最后运行的后台Process的PID" | |
printf "The ${msg1}! is %s\n" "$!" | |
echo "最后运行的命令的结束代码(返回值)" |
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
# 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: |