Skip to content

Instantly share code, notes, and snippets.

View taojy123's full-sized avatar

taojy123 taojy123

View GitHub Profile
@taojy123
taojy123 / django_send_mail.py
Last active April 23, 2019 07:10
Python 发送邮件
# ----------------- django ---------------------------
from django.core.mail import send_mail
send_mail('Subject here', 'Here is the message.', '[email protected]', ['[email protected]'])
# ----------------- settings.py ----------------------
SERVER_EMAIL = '[email protected]'
EMAIL_HOST = 'smtp.163.com'
EMAIL_PORT = 465 # 25
EMAIL_USE_SSL = True # False
@taojy123
taojy123 / clear.bat
Created August 14, 2017 00:44
删除U盘隐形病毒
attrib -s -h /s /d
pause
del "Microsoft Word.WsF"
del "Microsoft Excel.WsF"
del "*.WsF"
pause
del "*.lnk"
pause
@taojy123
taojy123 / str_sub.lua
Created June 11, 2017 12:08
截取中英混合的UTF8字符串
--截取中英混合的UTF8字符串,endIndex可缺省
function SubStringUTF8(str, startIndex, endIndex)
if startIndex < 0 then
startIndex = SubStringGetTotalIndex(str) + startIndex + 1;
end
if endIndex ~= nil and endIndex < 0 then
endIndex = SubStringGetTotalIndex(str) + endIndex + 1;
end
@taojy123
taojy123 / nginx.conf
Last active June 9, 2017 08:50 — forked from nl5887/nginx.conf
[SNI] OpenResty + MySQL
worker_processes 1;
error_log logs/error.log debug;
daemon off;
events {
worker_connections 1024;
}
@taojy123
taojy123 / django_import_xls.py
Created May 18, 2017 06:25
django upload and read xls file by xlrd
def import_data(request):
data = request.FILES.get('data')
book = xlrd.open_workbook(data.name, file_contents=data.read())
sheet = book.sheets()[0]
names = sheet.col_values(1, 1)
stocks = sheet.col_values(5, 1)
dates = sheet.col_values(22, 1)
for name, stock, date in zip(names, stocks, dates):
@taojy123
taojy123 / a.py
Created May 7, 2017 13:19
Pandas 代码小示例
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
df = pd.read_csv('pandasTest.csv')
print(df)
print('================================================================')
@taojy123
taojy123 / get_rsa_sign.py
Last active April 20, 2017 09:16
请求参数 RSA 签名
def get_rsa_sign(data, private_key=PRIVATE_KEY):
# pip install pyopenssl
from OpenSSL.crypto import load_privatekey, FILETYPE_PEM, sign
import base64
keys = sorted(data)
kstr = ''
for key in keys:
@taojy123
taojy123 / tplink.py
Created April 5, 2017 01:04
TP-Link 路由器自动重选桥接信道并重启
@taojy123
taojy123 / clipboard.py
Last active July 19, 2018 02:18
Python 操作win剪切板
import win32clipboard
import win32con
def getText():
win32clipboard.OpenClipboard()
d = win32clipboard.GetClipboardData(win32con.CF_TEXT)
win32clipboard.CloseClipboard()
return d
def setText(aString):
@taojy123
taojy123 / globalvar.py
Last active September 1, 2016 07:11
Python 跨文件跨进程使用全局变量
abc = None
cba = None
def set_abc(value):
global abc
abc = value