REV="$(git describe --tags 2> /dev/null || git rev-parse HEAD)"
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
"""See also https://www.codeforests.com/2020/11/05/python-suppress-stdout-and-stderr/""" | |
import os | |
import sys | |
from contextlib import contextmanager | |
@contextmanager | |
def suppress_output(suppress_stdout=True, suppress_stderr=True): | |
orig_streams = (sys.stdout, sys.stderr) | |
null_stream = open(os.devnull, "w") |
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 | |
webhook_url = "<your-slack-webhook-url>" | |
def slack_log(message, webhook_url=webhook_url): | |
requests.post( | |
webhook_url, | |
json={"text": message} | |
) |
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 jsonpath_ng import jsonpath, parse | |
def mod_func(orig, data, field): | |
data[field] *= 2 | |
data = { | |
"foo": [ | |
{"baz": 1}, | |
{"baz": 2}, | |
], |
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
# /etc/netplan/01-netcfg.yaml | |
network: | |
version: 2 | |
renderer: networkd | |
ethernets: | |
eth0: | |
dhcp4: no | |
addresses: | |
- 172.23.10.197/24 | |
- 172.23.10.198/24 |
class ExampleViewSet(PartialUpdateModelMixin, viewsets.ReadOnlyModelViewSet):
...
@action(detail=False, methods=["GET"], url_path="_meta")
def api_meta(self, request):
meta = {
"fields": {
"types": {
"choices": Example.ExampleType.choices
Your Django project maybe required to hosted under a shared domain, but use a separate subpath.
To make django generate right URLs and avoid cookie conflicts, do settings below:
FORCE_SCRIPT_NAME = '/A-site/'
CSRF_COOKIE_PATH = LANGUAGE_COOKIE_PATH = SESSION_COOKIE_PATH = FORCE_SCRIPT_NAME
LOGIN_URL = '{0}api-auth/login/'.format(FORCE_SCRIPT_NAME)
LOGOUT_URL = '{0}api-auth/logout/'.format(FORCE_SCRIPT_NAME)
@keywords: django-rest-framework, django, restful
- gunicorn~=20.0.4
- Django~=3.1.1
- django-deprecate-fields~=0.1.0
- psycopg2-binary~=2.8.5
- django-cors-headers~=3.5.0
- django-storages[boto3]~=1.9.1
- djangorestframework~=3.12.2
- djangorestframework-queryfields~=1.0.0
Updated file /usr/share/fcitx/data/punc.mb.zh_CN
. 。
, ,
? ?
" “ ”
: :
; ;
' ‘ ’