This file contains hidden or 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
| import pika | |
| class RabbitMQ(object): | |
| def __init__(self, host, port=5672): | |
| self.host = host | |
| self.port = port | |
| self.conn = "" | |
| self.channel = "" |
This file contains hidden or 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
| apt-get update && apt-get dist-upgrade | |
| reboot | |
| do-release-upgrade | |
| # 修改 /etc/apt/sources.list 为 Ubuntu 16.04 的源 | |
| do-release-upgrade |
This file contains hidden or 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
| # alpine3.7 添加阿里云源 | |
| RUN echo 'http://mirrors.aliyun.com/alpine/v3.7/main/' > /etc/apk/repositories \ | |
| && echo 'http://mirrors.aliyun.com/alpine/v3.7/community/' >> /etc/apk/repositories |
This file contains hidden or 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
| """ | |
| python sqlite3 使用 | |
| """ | |
| class AliceDB(object): | |
| def __enter__(self): | |
| self._connect() | |
| return self | |
| def __exit__(self, type, value, trace): |
This file contains hidden or 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 logging | |
| # mylogger 可以在日志中显示 %(name)s,这样就可以看出是哪个logger 打出的日志。没啥用。 | |
| # 默认为 root logger | |
| logger = logging.getLogger("mylogger") | |
| logger.setLevel(logging.DEBUG) |
This file contains hidden or 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
| openssl genrsa -des3 -out ca.key 2048 | |
| openssl req -new -x509 -days 7305 -key ca.key -out ca.crt | |
| openssl genrsa -des3 -out blog.creke.net.pem 2048 | |
| openssl req -new -nodes -sha256 -newkey rsa:2048 -keyout blog.creke.net.key -out blog.creke.net.csr | |
| openssl ca -policy policy_anything -days 1460 -cert ca.crt -keyfile ca.key -in blog.creke.net.csr -out blog.creke.net.crt | |
| # 如果出现找不到文件夹的错误,执行以下步骤 | |
| mkdir -p CA/newcerts | |
| touch CA/index.txt | |
| touch CA/serial |
This file contains hidden or 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
| # Python3 最重要的新特性大概要算是对文本和二进制数据作了更为清晰的区分。 | |
| # 文本总是Unicode,由str类型表示,二进制数据则由bytes类型表示。 | |
| # Python3 不会以任意隐式的方式混用str和bytes,正是这使得两者的区分特别清晰。 | |
| # 你不能拼接字符串和字节包,也无法在字节包里搜索字符串(反之亦然) | |
| b = b"example" # bytes object | |
| s = "example" # str object | |
| bytes(s, encoding = "utf8") # str to bytes | |
| str(b, encoding = "utf-8") # bytes to str |
This file contains hidden or 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
| import requests | |
| files = {'file': open('/Users/gao/nixiongwo.png', 'rb')} | |
| data = {"name":"123", "info":"hahaha"} | |
| r = requests.post("http://www.baidu.com/postfile", files=files, data=data) | |
| # 更多参数格式参考:https://blog.csdn.net/five3/article/details/74913742 |
This file contains hidden or 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
| deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse | |
| deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse | |
| deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse | |
| deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse | |
| deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse | |
| deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse | |
| deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse | |
| deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse | |
| deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse | |
| deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse |
This file contains hidden or 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 hashlib | |
| from datetime import datetime | |
| UTC_DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%fZ" | |
| def file_md5(f): | |
| hash_md5 = hashlib.md5() | |
| for chunk in iter(lambda: f.read(4096), b""): |
NewerOlder