阿小信大人的头像
Talk is cheap. Show me the code. Linus Torvalds

CentOS升级Python2.6到2.72015-04-24 14:47

#### Python2.6升级Python2.7:

编译环境准备

yum groupinstall "Development tools"
yum install python-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel

下载安装2.7

tar -jxvf Python-2.7.11.tgz
cd Python-2.7.11
./configure --prefix=/usr/

......
#Linux/Mac#   评论[0]阅读全文[1599]

判断一个文件是否有bom头2015-04-22 16:53

# !usr/bin/env python
#-*- coding:utf-8 -*-
import codecs

def has_bom(fn):
with open(fn, 'rb') as f:
sample = f.read(4)
return sample[:3] == b'\xef\xbb\xbf' or \
sample.startswith(codecs.BOM_UTF16_LE) or \
samp

......
#Python#   评论[0]阅读全文[989]

Mac屏幕录像转成gif2015-04-04 13:18

**屏幕录像**

打开Quicktime Player -> 文件 -> 新建屏幕录像 -> 点击/拖动鼠标进行录像区域选择(点击是进行全屏录制) -> 完成后选择文件 -> 存储为一个.mov的视频文件

**转换为gif**

安装ffmpeg和gifsicle

brew install ffmpeg
brew install gifsicle
# brew install imagemagick

转换:

ffmpeg -i in.mov -s 600x400 -pix_fmt rgb24 -r 10 -f gif - |

......
#Linux/Mac#   评论[0]阅读全文[1117]

[转]SQLAlchemy2015-04-02 10:27

架构图

原文:

SQLAlchemy是Python界的ORM(Object Relational Mapper)框架,它两个主要的组件: **SQLAlchemy ORM** 和 **SQLAlchemy Core** 。

![架构图](http://docs.sqlalchemy.org/en/rel_0_8/_images/sqla_arch_small.png)

####安装

pip install SQLAlchemy
#检查安装是否成功:
>>> import sqlalchemy
>>> sqlalchemy.__versio

......
#数据库#   评论[0]阅读全文[2089]

jinja动态include模板文件2015-04-02 10:24

include模板文件语法为:

{% include "template/path/to/templatefile" %}

include后面的参数是写死的,如果用变量代替的话应该直接用变量名,如

{% include current_task['rule_file'] %}

而不是类似

{% include "{{ current_task['rule_file'] }}" %}

的错误语法。

set语法也是直接写变量:

{% set path = 'template/' + path_to + '/x.html

......
#WEB/前端#   评论[0]阅读全文[937]

Two ways to install uwsgi2015-04-02 10:22

You have two ways to install uwsgi on ubuntu: apt-get or pip

**apt-get**

if you use apt-get, you need to install the python plugin:

sudo apt-get install uwsgi-plugin-python
sudo apt-get install uwsgi

And, in your uwsgi ini file for your site, you need to add this:

plugins

......
#Linux/Mac#   评论[0]阅读全文[972]