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
try: | |
import MySQLdb as Database | |
Database = pool.manage(Database) | |
except ImportError, e: | |
from django.core.exceptions import ImproperlyConfigured | |
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e) |
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
proxies = {} | |
class _DbWrapper(): | |
def __init__(self,module): | |
self.connection=None #这个就是维护的长连接对象 | |
self.db=module #这个是被包装的原生MySQLdb的module | |
def __getattr__(self, key): | |
return getattr(self.db, key) #代理所有不关心的函数 | |
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
(function($) { | |
// ajax提交一个form表单的内容的插件 | |
$.fn.extend( | |
{ | |
Submit:function(callback){ | |
$(this).each(function(i){ | |
var form = $(this); | |
var params = {}; | |
var url = form.attr("action"); | |
console.log(url); |
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 requests | |
import datetime | |
from bs4 import BeautifulSoup | |
import random | |
def get_page(url): | |
r=requests.get(url,headers={"content-type":"text","User-Agent":"Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11"}) | |
return BeautifulSoup(r.text) | |
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
$.fn.extend({ | |
gist:function(){ | |
var r = /(https\:\/\/gist\.github\.com\/\w+\/\d+)/g; | |
this.each(function(index){ | |
var content = $(this).html(); | |
content = content.replace(r,"<script src=\"$1.js\"></script>"); | |
$(this).html(content); | |
}); | |
return true; | |
}, |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title></title> | |
<script src="/jquery.js"></script> | |
<script src="/jsbn.js"></script> | |
<script src="/rsa.js"></script> | |
<script src="/sha1.js"></script> | |
<script type="text/javascript"> | |
function encrypt() { |
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
class WordsArr(object): | |
def __init__(self,col_count): | |
self.total = 26**col_count | |
def __getitem__(self,idx): | |
if idx>self.total-1: | |
raise IndexError("index out of range") | |
nums = [] | |
lst = idx%26 | |
while idx/26: |
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
#-*- coding:utf-8 -*- | |
from flask import Flask, g, request | |
app = Flask(__name__) | |
app.debug = True | |
@app.route('/') | |
def hello(): | |
return "Hello, world! - Flask\n" |
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
#coding=utf8 | |
import pybcs | |
import logging | |
pybcs.init_logging(logging.INFO) | |
AK = '' #请改为你的AK | |
SK = '' #请改为你的SK | |
BUCKET='myimage1' |
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
DATALIST="""<?xml version="1.0" encoding="utf-8"?> | |
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> | |
<soap12:Body> | |
<GetDataListByDate xmlns="http://tempuri.org/"> | |
<token>%(token)s</token> | |
<fromDate>%(fdate)s</fromDate> | |
<toDate>%(tdate)s</toDate> | |
</GetDataListByDate> | |
</soap12:Body> | |
</soap12:Envelope>""" |