Skip to content

Instantly share code, notes, and snippets.

View taojy123's full-sized avatar

taojy123 taojy123

View GitHub Profile
@taojy123
taojy123 / nginx_site.conf
Last active July 12, 2017 08:08
django+nginx+uwsgi
server {
listen 8000;
server_name 127.0.0.1;
location /static/ {
alias /root/SWE/static/;
autoindex on;
}
@taojy123
taojy123 / wx_get_file_path.py
Last active July 16, 2016 05:59
wxpython 文件和目录选择对话框
path = wx.FileSelector("Open")
path = wx.DirSelector()
@taojy123
taojy123 / django_ajax_csrf.js
Created August 18, 2016 04:59
django ajax csrf
"use strict";
var AjaxForm = (function() {
var hasSetup = false;
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
@taojy123
taojy123 / BackwardsReader.py
Created August 29, 2016 08:02
BackwardsReader
# Copyright (c) Peter Astrand <[email protected]>
class BackwardsReader:
"""Read a file line by line, backwards"""
BLKSIZE = 4096
def readline(self):
while 1:
newline_pos = string.rfind(self.buf, "\n")
pos = self.file.tell()
@taojy123
taojy123 / globalvar.py
Last active September 1, 2016 07:11
Python 跨文件跨进程使用全局变量
abc = None
cba = None
def set_abc(value):
global abc
abc = value
@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 / tplink.py
Created April 5, 2017 01:04
TP-Link 路由器自动重选桥接信道并重启
@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 / 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 / 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):