Skip to content

Instantly share code, notes, and snippets.

@zii
zii / masaik.py
Last active December 5, 2017 00:06
# coding: utf-8
import os
import random
from PIL import Image
import time
def blend(tile, crop):
"""
两个图混合
:param tile: 前景图
@zii
zii / nginx.conf
Last active October 15, 2017 10:01
uwsgi+nginx
worker_processes 4;
events {
worker_connections 1024;
}
http {
#include mime.types;
types {
text/html html htm shtml;
# 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(
@zii
zii / macos
Last active July 28, 2020 21:58
# 修改系统最大连接数
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
@zii
zii / git alias
Created September 18, 2017 07:23
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'
}
@zii
zii / regex.py
Last active September 15, 2017 06:44
# 将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属性的
@zii
zii / pagination.py
Last active September 8, 2017 08:21
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'}
@zii
zii / neo4j note
Last active February 24, 2018 01:16
创建节点
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
@zii
zii / fenci.py
Last active September 13, 2017 08:45
python interesting code
# 从一篇文章中提取人名, 效果不错
# 原理: jieba分词+百家姓+数据查找
# 百家姓
FAMILY_NAMES = set()
def load_family_names():
"""
载入百家姓
"""
global FAMILY_NAMES
#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