Skip to content

Instantly share code, notes, and snippets.

View taojy123's full-sized avatar

taojy123 taojy123

View GitHub Profile
@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 / 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 / wx_get_file_path.py
Last active July 16, 2016 05:59
wxpython 文件和目录选择对话框
path = wx.FileSelector("Open")
path = wx.DirSelector()
@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 / rwxls.py
Last active March 1, 2017 01:22
Python 读写xls 以及 winapi 读取和替换 word 内容
import sys
import os
import urllib2
import traceback
import re
import xlrd
import xlutils.copy
import win32com
from win32com.client import Dispatch, constants
@taojy123
taojy123 / read_write_xlsx.py
Created February 9, 2015 03:06
Python 读写 xlsx 文件操作
from openpyxl import Workbook
from openpyxl.reader.excel import load_workbook
wb_new = Workbook()
wb = load_workbook('1.xlsx')
col1 = "C"
col2 = "A"
sheet1 = wb.get_sheet_by_name(wb.sheetnames[0])
sheet2 = wb.get_sheet_by_name(wb.sheetnames[1])
@taojy123
taojy123 / onlinetime.py
Created February 8, 2015 02:44
通过互联网获取当前时间
import urllib2
import re
import time
def get_online_seconds():
p = urllib2.urlopen("http://www.baidu.com/").read()
r = re.findall(r'serverTime : "(.*?)"', p)
if r:
t = r[0]
else:
@taojy123
taojy123 / mail21cn.py
Created February 2, 2015 07:33
快捷申请21cn邮箱
#coding=utf8
import cookielib
import urllib2, urllib
import time
import re
import traceback
import time
import random
from PIL import Image
@taojy123
taojy123 / darwin.py
Last active August 29, 2015 14:14
darwin.affiliatewindow.com 网站邀请码 暴力破解
import cookielib
import urllib2, urllib
import time
import re
import traceback
import time
def findre(reg, s):
r = re.findall(reg, s)
@taojy123
taojy123 / m1.bas
Created January 20, 2015 01:32
excel 宏 自动分割日期
Attribute VB_Name = "模块1"
Sub 自动分割日期()
'先把15天的数据清空
For i = 1 To 15
'选择每一张表
Sheets(CStr(i)).Select
'全选 清空
Cells.Select
Selection.Delete