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 email | |
| import imaplib | |
| import os | |
| from email.header import decode_header | |
| detach_dir = '.' | |
| if 'attachments' not in os.listdir(detach_dir): | |
| os.mkdir('attachments') | |
| import os |
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
| package main | |
| import ( | |
| "fmt" | |
| "reflect" | |
| ) | |
| type User struct{ | |
| Name string `json:"name" bson:"b_name"` | |
| Age int `json:"age" bson:"b_age"` |
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
| func NestedMapToFlatMap(a_map map[string]interface{}) map[string]interface{} { | |
| new_map := map[string]interface{}{} | |
| for key, val := range a_map{ | |
| t:=reflect.TypeOf(val) | |
| if t.Kind() == reflect.Map{ | |
| mapval, _ := val.(map[string]interface{}) | |
| for i,j :=range mapval{ | |
| new_map[i] = j | |
| } | |
| } else { |
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
| package main | |
| import ( | |
| "errors" | |
| "os" | |
| "os/signal" | |
| "time" | |
| "log" | |
| ) | |
| var ErrTimeOut = errors.New("执行者执行超时") | |
| var ErrInterrupt = errors.New("执行者被中断") |
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 os, sys | |
| os.execv(sys.executable, ['python'] + sys.argv) | |
| # sys.executable: the python path you are using which will auto know if you are using virtualenv | |
| # e.g: /home/pd/.virtualenvs/competehunt_main/bin/python' [so if it not what you want, write it manually] | |
| # of course, sys.argv is the current file name if you donnot add extra params [yes, add it if need to] | |
| # so ['python'] + sys.argv ==> ["python", "current.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
| import os | |
| import signal | |
| import time | |
| import sys | |
| pid = os.getpid() | |
| received = False | |
| def signal_usr1(signum, frame): |
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
| package main | |
| import ( | |
| "net/http" | |
| httptransport "github.com/go-kit/kit/transport/http" | |
| "os" | |
| "github.com/go-kit/kit/log" | |
| "github.com/go-redis/redis" | |
| "flag" |
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 os | |
| import signal | |
| import time | |
| import requests | |
| from functools import partial | |
| from redis import Redis | |
| redis_conn = Redis(host='xxx', port=xxxx, password='xxxx') | |
| def ini_life(): |
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 flask import Flask, request, jsonify | |
| from users import User | |
| from ext import db | |
| app = Flask(__name__) | |
| app.config.from_object('config') | |
| db.init_app(app) | |
| # with app.app_context(): |
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 zhon import hanzi # pip install zhon | |
| import string | |
| from itertools import chain | |
| a_string = a_string.translate( | |
| str.maketrans({key: None for key in chain(hanzi.punctuation, string.punctuation)}) | |
| ) |
NewerOlder