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
| from blinker import signal | |
| def subscriber(sender): | |
| print("Got a signal send by %r" % sender) | |
| # already have signal, define own receive method | |
| send_data = signal('send-data') |
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
| def my_callback(sender, **kwargs): | |
| ''' | |
| 这是个receiver函数 | |
| ''' | |
| print(sender) | |
| print(kwargs) | |
| print("Request finished!") | |
| class Observed(object): |
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 os | |
| import oss2 | |
| oss_accesskeyid = os.environ.get('OSS_AccessKeyId', None) | |
| oss_accesskeysecret = os.environ.get('OSS_AccessKeySecret', None) | |
| oss_endpoint = os.environ.get('OSS_ENDPOINT', None) | |
| oss_bucketname = os.environ.get('OSS_BUCKETNAME', None) | |
| # 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录 https://ram.console.aliyun.com 创建RAM账号。 |
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
| version: '2' | |
| services: | |
| dnsmasq: | |
| image: andyshinn/dnsmasq:latest | |
| restart: always | |
| ports: | |
| - "53535:53/tcp" | |
| - "53535:53/udp" | |
| cap_add: | |
| - NET_ADMIN |
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
| l1 = [1, 2, 3] | |
| l2 = list.sort(l1) | |
| l3 = l1.sort() | |
| l4 = sorted(l1) | |
| def myprint(l): | |
| print("{}, id:{}".format(l, id(l))) | |
| return 0 |
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
| from cerberus import Validator | |
| schema = {'a': {'type': 'string'}} | |
| data = {'a': '1', 'b': None} | |
| if __name__ == '__main__': | |
| v = Validator() | |
| if not v.validate(data, schema): | |
| print(v.errors) |
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
| FROM python:3.6 | |
| WORKDIR /Project/demo | |
| COPY requirements.txt ./ | |
| RUN pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple | |
| COPY . . | |
| CMD ["python", "app.py"] |
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
| version: '2' | |
| services: | |
| # MONGODB | |
| mongo: | |
| image: mongo:4.2 | |
| # hostname: mongo.myrepl | |
| networks: | |
| - mset | |
| command: |
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
| obj-m += hello.o | |
| PWD := $(shell pwd) | |
| KVER := $(shell uname -r) | |
| KDIR :=/lib/modules/$(KVER)/build/ | |
| all: | |
| $(MAKE) -C $(KDIR) M=$(PWD) | |
| clean: | |
| rm -rf *.o *.mod.c *.mod.o *.ko *.symvers *.order *.a |
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
| from collections import ChainMap | |
| d1 = {'a': 'a', 'b': 'b'} | |
| d2 = {'c': 'c', 'd': 'd'} | |
| m = ChainMap(d1, d2) | |
| if __name__ == '__main__': | |
| print(m) | |
| n = m.new_child({"e": "e"}) |