This file contains 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 uvent | |
uvent.install() | |
import gevent | |
from gevent import monkey | |
monkey.patch_all()# must patch first, then from gevent import sth else | |
from gevent.threadpool import ThreadPool | |
import time | |
import rethinkdb as r |
This file contains 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
/************************ need js lib *********************************** | |
// https://raw.githubusercontent.com/SheetJS/js-xlsx/master/dist/xlsx.core.min.js | |
// https://raw.githubusercontent.com/SheetJS/js-xls/master/dist/xls.core.min.js | |
// https://raw.githubusercontent.com/gkindel/CSV-JS/master/csv.js | |
************************************************************************/ | |
//upload file | |
function handleKVFile(e) { | |
var files = e.target.files; | |
var i,f; |
This file contains 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 MySQLdb | |
class Row(dict): | |
"""A dict that allows for object-like property access syntax.""" | |
def __getattr__(self, name): | |
try: | |
return self[name] | |
except KeyError: | |
raise AttributeError(name) | |
This file contains 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 os.path | |
import time | |
from ConfigParser import SafeConfigParser | |
from django.conf import settings | |
__all__ = ['get_config'] | |
_CONFIG_MAP = {} | |
def get_config(path): |
This file contains 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.ext.sqlalchemy import SQLAlchemy | |
def get_model(self, name): | |
return self.Model._decl_class_registry.get(name, None) | |
SQLAlchemy.get_model = get_model | |
def get_model_by_tablename(self, tablename): | |
for c in self.Model._decl_class_registry.values(): | |
if hasattr(c, '__tablename__') and c.__tablename__ == tablename: | |
return c |
This file contains 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
# apt-get install libtesseract3 libtesseract-dev; pip install pytesseract; | |
# download google tesseract eng data then copy it to /usr/local/share/tessdata: https://github.com/tesseract-ocr/tesseract/wiki/Data-Files | |
import Image | |
import requests | |
import pytesseract | |
from StringIO import StringIO | |
jpg = Image.open(StringIO(requests.get('http://test.jpg').content)) | |
code = pytesseract.image_to_string(jpg).replace(' ', '') |
This file contains 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 reportlab.pdfgen import canvas | |
from io import BytesIO | |
from reportlab.pdfbase import pdfmetrics | |
from reportlab.pdfbase.ttfonts import TTFont | |
# 采用微软雅黑字体 | |
def some_view(): | |
pdfmetrics.registerFont(TTFont('msyh', os.path.join(veteransApp.config['PROJECT_DIR'], '../msyh.ttf'))) | |
# Create the PDF object, using the response object as its "file." | |
buffer = BytesIO() |
This file contains 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 | |
from fabric.api import * | |
env.user = 'root' | |
env.password = 'jindengtaia10' | |
env.hosts = ['121.199.4.240'] | |
@task | |
def nginx_start(): |
This file contains 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
# /etc/nginx/sites-enabled/google | |
server { | |
listen 443 default ssl; | |
listen [::]:443; | |
#listen 80; | |
server_name yourhostname; | |
##1,设置反向代理的域名 | |
ssl on; | |
ssl_certificate /home/sx/googleca.crt; | |
ssl_certificate_key /home/sx/nopassgoogle.key; |
This file contains 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 | |
from datetime import datetime, timedelta, date | |
import time | |
from time import struct_time | |
from time import localtime | |
""" | |
%y 两位数的年份表示(00-99) | |
%Y 四位数的年份表示(000-9999) | |
%m 月份(01-12) |
OlderNewer