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 | |
import os | |
import random | |
from PIL import Image | |
import time | |
def blend(tile, crop): | |
""" | |
两个图混合 | |
:param tile: 前景图 |
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
worker_processes 4; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
#include mime.types; | |
types { | |
text/html html htm shtml; |
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 | |
import jinja2 | |
from jinja2 import Template, Environment | |
import time | |
text = u'Hello {{ name }} {{ name }}!' | |
text = text * 100 | |
env = jinja2.Environment( | |
loader = jinja2.FileSystemLoader( |
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
# 修改系统最大连接数 | |
sudo vim /etc/sysctl.conf | |
kern.maxfiles=1000000 | |
kern.maxfilesperproc=1000000 | |
kern.ipc.somaxconn=1000 | |
sudo vim /etc/launchd.conf | |
limit maxfiles 1000000 1000000 | |
limit maxfilesperproc 1000000 1000000 | |
limit maxproc 100000 200000 |
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
alias cd1='cd /d/dev/www/web/www.linkeddb.com/' | |
alias gs='git status' | |
alias gd="git diff" | |
alias pull='git pull origin `git rev-parse --abbrev-ref HEAD`' | |
alias push='git push origin `git rev-parse --abbrev-ref HEAD`' | |
gc(){ | |
git commit -am '$1' | |
} |
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
# 将abc中的b替换成x | |
re.sub(r'(.*?)b(.*?)', r'\1x\2', 'abc', 1) | |
# 提取<a>x</a>中的x | |
re.sub(r'<a>(.*?)</a>', r'\1', '<a>x</a>') | |
# 剔除所有a标签 | |
re.sub(r'<a.*?>(.*?)</a>', '', '<a>x</a>b') | |
# 匹配标签中不含class属性的 |
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
def pagination_div(page, psize, total): | |
""" | |
生成后台分页标签 | |
:param page: 当前页号 | |
:param psize: 每页条数 | |
:param total: 总条数 | |
:return: <div>...</div> | |
""" | |
base_args = {k: v.encode('utf-8') for k, v in request.args.items() if k!='p'} |
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
创建节点 | |
create (a:Hum{name:"cat"}) | |
更新节点属性 | |
match (r:Role) where id(r)=1054808 set r.intro="呵呵", r.weight=2 | |
创建关系 | |
match (a:Hum),(b:Hum) where id(a)=435 and id(b)=436 create(a)-[r:KNOWS{time:1}]->(b) return r | |
merge会防止重复创建关系 | |
match (a:Hum),(b:Hum) where id(a)=435 and id(b)=436 merge (a)-[r:KNOWS{time:1}]->(b) return r |
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
# 从一篇文章中提取人名, 效果不错 | |
# 原理: jieba分词+百家姓+数据查找 | |
# 百家姓 | |
FAMILY_NAMES = set() | |
def load_family_names(): | |
""" | |
载入百家姓 | |
""" | |
global FAMILY_NAMES |
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 | |
# download and install VC++ for python 2.7 | |
# https://www.microsoft.com/en-us/download/details.aspx?id=44266 | |
from distutils import msvc9compiler | |
msvc9compiler.find_vcvarsall = lambda v: 'C:/Users/cat/AppData/Local/Programs/Common/Microsoft/Visual C++ for Python/9.0/vcvarsall.bat' | |
import pyximport; pyximport.install() | |
import hello |