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
package main | |
import ( | |
"encoding/binary" | |
"errors" | |
"io" | |
"net" | |
"reflect" | |
"strings" | |
"syscall" |
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
/* | |
Navicat Premium Data Transfer | |
Source Server : localhost | |
Source Server Type : MySQL | |
Source Server Version : 50542 | |
Source Host : localhost | |
Source Database : rule | |
Target Server Type : MySQL |
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
import copy | |
from rest_framework import serializers | |
from django.db import models | |
from rest_framework.fields import IntegerField | |
class BigIntegerField(IntegerField): | |
def to_representation(self, value): | |
return str(value) | |
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
class WhiteListViewSet(ModelViewSet): | |
queryset = WhiteList.objects.all() | |
serializer_class = WhiteListSerializer | |
permission_classes = [IsAdminUser] | |
pagination_class = None | |
def get_permissions(self): | |
""" | |
根据不同的action获取不同的权限校验中间件 | |
""" |
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
class PrimaryKeyRelatedField(serializers.PrimaryKeyRelatedField): | |
"""主要是为了避免当外键为0这种情况的发生,比如树状表""" | |
def to_internal_value(self, data): | |
if self.pk_field is not None: | |
data = self.pk_field.to_internal_value(data) | |
try: | |
return self.get_queryset().get(pk=data) | |
except ObjectDoesNotExist: | |
return self.get_queryset().model(pk=0) | |
except (TypeError, ValueError): |
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
# websocket middleware | |
from channels.middleware import BaseMiddleware | |
from channels.auth import UserLazyObject | |
from django.conf import settings | |
from importlib import import_module | |
from channels.auth import get_user | |
from urllib.parse import parse_qs | |
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
var jschardet = require("jschardet") | |
var iconv = require('iconv-lite') | |
var data = Buffer.from('ODAwICB1c2VybGlzdC50eHQKMTAwNjY2L3J3LXJ3LXJ3LSAgNjIwICAgICAgICAgZmlsICAgMjAyMC0wNi0xMiAxMzo1MDoxNiArMDgwMCAgd2FpdC5odG1sCjEwMDY2Ni9ydy1ydy1ydy0gIDUyNDI5NTEyICAgIGZpbCAgIDIwMjAtMDYtMTYgMDk6NTc6MjkgKzA4MDAgIHdlYl9zdGRlcnIubG9nLjkKMTAwNjY2L3J3LXJ3LXJ3LSAgODcxNzUzMDQgICAgZmlsICAgMjAyMC0xMC0yMCAxNzowNzoyMSArMDgwMCAgd2VibG9naWNfZXhwbG9pdC0xLjAtU05BUFNIT1QtYWxsLmphcgoxMDA3Nzcvcnd4cnd4cnd4ICAxNDEzMTIgICAgICBmaWwgICAyMDIwLTA0LTMwIDEwOjUxOjA2ICswODAwICB4eW50ZXN0KDEpLmV4ZQoxMDA3Nzcvcnd4cnd4cnd4ICAxNDEzMTIgICAgICBmaWwgICAyMDIwLTA0LTMwIDEwOjQxOjIzICswODAwICB4eW50ZXN0LmV4ZQoxMDA2NjYvcnctcnctcnctICA5NTUwICAgICAgICBmaWwgICAyMDIwLTA0LTI5IDE3OjU0OjQ5ICswODAwICB6aGFuZ3pob3UuZ292LmNuLmRucwoxMDA2NjYvcnctcnctcnctICAxMDQzODEgICAgICBmaWwgICAyMDIwLTA2LTAzIDA5OjI5OjMxICswODAwICDjgJDlronlhajlt6XnqIvluIggXyDmna3lt54yMDAtMjUwX+WkqeOAkemZiOWiqOeEtiDkuIDlubTku6XlhoUuZG9jeAoxMDA2NjYvcnctcnctcnctICAxMTI2OTQ2ICAgICBmaWwgICAyMDIwLTExLTA2IDA5OjU1OjU4 |
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
nim c -d:danger --opt:size --passc=-flto --passl:-s main.nim |
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
""" | |
requirement: | |
pip install python_logging_loki | |
""" | |
from multiprocessing import Queue | |
LOGGING = { | |
'version': 1, | |
'disable_existing_loggers': False, | |
'formatters': { |