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
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
int exec_command(char* command, char* out); | |
int main( int argc, char *argv[] ) { | |
char *tmp_buf = malloc(1025); | |
char result[4097] = { 0 }; | |
strcpy(tmp_buf, argv[1]); |
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
import json | |
from rest_framework.fields import Field | |
from django.utils.translation import gettext_lazy as _ | |
class MyJSONField(Field): | |
default_error_messages = { | |
'invalid': _('Value must be valid JSON.') | |
} |
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
import os | |
import uuid | |
import shutil | |
import zipfile | |
import lxml.etree | |
def inplace_change(filename, old_string, new_string): | |
"""打开文件替换字符串""" | |
s = '' | |
with open(filename) as f: |
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 |