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 | |
""" | |
git clone https://github.com/shuxiang/hakka-lang-bobai | |
git clone https://github.com/hxgdzyuyi/tang_poetry | |
mysql> source tang_poetry.sql | |
pip3 install flask | |
pip3 install xpinyin | |
pip3 install Flask-SQLALchemy | |
python3 poem_rhythm.py |
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 | |
"""pip install gevent pyquery requests weasyprint""" | |
import gevent | |
from gevent import monkey | |
monkey.patch_all() | |
from pyquery import PyQuery as pq | |
import requests | |
import re, sys | |
from weasyprint import HTML |
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) |
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 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
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
# 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 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
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
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) | |
NewerOlder