Skip to content

Instantly share code, notes, and snippets.

View quieterbwhite's full-sized avatar
🔴

bwhite quieterbwhite

🔴
View GitHub Profile
@quieterbwhite
quieterbwhite / pinyin.py
Last active July 1, 2022 22:03
汉语拼音转换工具 pypinyin 库的使用
# -*- coding=utf-8 -*-
# Created Time: Wed 07 Jan 2015 03:51:26 PM CST
# File Name: pinpin.py
# Author: bwhite.liiiii@gmail.com
'''
测试 汉语拼音转换工具 pypinyin 库的使用.
将汉语转为拼音。可以用于汉字注音、排序、检索。
根据词组智能匹配最正确的拼音。
@quieterbwhite
quieterbwhite / huahua.conf
Created January 6, 2015 13:04
Nginx + gunicorn + django + supervisor + mongodb 环境, supervisor 配置文件.
[program:huahua]
command = /home/apps/hua_env/start
user = web
stdout_logfile = /home/apps/hua_env/logs/super.log
redirect_stderr = true
environment=LANG=en_US.UTF-8,LC_ALL=en_US.UTF-8
@quieterbwhite
quieterbwhite / settings_local.py
Created January 6, 2015 12:58
Nginx + gunicorn + django + supervisor + mongodb 环境, Django 配置文件.
# -*- coding=utf-8 -*-
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
('bwhite','bwhite.liiiii@gmail.com'),
)
DATABASES = {
@quieterbwhite
quieterbwhite / huahua.conf
Last active August 29, 2015 14:12
Nginx + gunicorn + django + supervisor + mongodb 环境, Nginx 配置文件.
upstream hua_server {
# fail_timeout=0 means we always retry an upstream even if it failed
# to return a good HTTP response(in case the Unicorn master nukes a
# single worker for time out).
# server 127.0.0.1:8085;
ip_hash;
server unix:/home/apps/hua_env/run/gunicorn.sock fail_timeout=0;
}
server {
@quieterbwhite
quieterbwhite / gunicorn_config.py
Created January 6, 2015 12:51
Nginx + gunicorn + django + supervisor + mongodb 环境, gunicorn配置文件
#!/bin/bash
NAME="huahua"
DJANGODIR=/home/apps/hua_env/huahua
SOCKFILE=/home/apps/hua_env/run/gunicorn.sock
USER=web
GROUP=webgrp
NUM_WORKERS=1
DJANGO_SETTINGS_MODULE=hua.settings.local
@quieterbwhite
quieterbwhite / dateutil.py
Last active August 29, 2015 14:12
计算时间差 S, M, H, d, m, Y. 格式化时间
# -*- coding=utf-8 -*-
# Created Time: Fri 21 Nov 2014 10:18:31 AM CST
# File Name: dateutil.py
# Author: bwhite.liiiii@gmail.com
'''
计算两个时间之间的差, 可以是s, min, hour, day, month, year.
所以这个上方库非常方便
关于rrule
@quieterbwhite
quieterbwhite / weixin_menu_python
Last active August 29, 2015 14:12
weixin_menu_python_code
# -*- coding=utf-8 -*-
# Created Time: Tue 11 Nov 2014 04:33:25 PM CST
# File Name: weixin_menu_python.py
# Author: bwhite.liiiii@gmail.com
'''
python 设置微信菜单代码
'''
import urllib2, json
@quieterbwhite
quieterbwhite / producer_consumer.py
Created January 5, 2015 10:18
python threading producer consumer
# -*- coding=utf-8 -*-
# Created Time: Fri 02 Jan 2015 03:28:17 PM CST
# File Name: producer_consumer.py
# Author: bwhite.liiiii@gmail.com
'''
生产者 消费者 python
随机数, 文件锁, json, 中文, 异常, 队列, 线程
'''
@quieterbwhite
quieterbwhite / diff_datetime.py
Last active August 29, 2015 14:12
time-difference day-month-year
# -*- coding=utf-8 -*-
# Created Time: Mon 05 Jan 2015 04:11:10 PM CST
# File Name: diff_datetime.py
# Author: bwhite.liiiii@gmail.com
'''
根据一个日期生成相隔多少天,月,年的另一个日期
'''
import datetime