最近在整理文件时发现了以前记下的一些设置,但是单独记在一个文件里不好找,也占用空间,现在记在博客里
vesa error
fcitx输入法
1sudo pacman -S fcitx-im fcitx-configtool fcitx-sunpinyin
使用
增加内容到~/.xinitrc
1export LANG=zh_CN.UTF-8
2export XMODIFIERS=@im=fcitx
3...
最近在整理文件时发现了以前记下的一些设置,但是单独记在一个文件里不好找,也占用空间,现在记在博客里
1sudo pacman -S fcitx-im fcitx-configtool fcitx-sunpinyin
增加内容到~/.xinitrc
1export LANG=zh_CN.UTF-8
2export XMODIFIERS=@im=fcitx
3...
1>>> import datetime
1>>> import datetime
2>>> str = "2016-04-03"
3>>> date_time = datetime.datetime.strptime(str,'...
1def index():
2 if form.validate_on_submit() and request.method == "POST":
3 # do something
4 else:
5 # 这里使用**redirect**重定向而不是render_template
问题是这样的: 1只母羊,在第2年和第4年生下小母羊,在第5年死去,问N年后有多少母羊?
想了很久,终于有了一个思路,不过目前效率不高
给出代码:
1a = [1]
2def sheep(N):
3 N = int(N)
4 if N == 1:
5 return a
6 for n,k in enumerate...
map()函数接收两个参数,一个是函数,一个是Iterable, map将传入的函数依次作用到序列的每个元素, 并把结果作为新的Iterator返回。
1>>> def f(x):
2... return x * x
3...
4>>> r = map(f, [1, 2, 3, 4, 5, 6, 7, 8, 9...
都可看做是where但用法不一样
1question = Questions.query.filter_by(id=1).first()
1question = Questions.query.filter(Questions.id==1).first()
其实就是= 与==还有是否带类名的区别
如果要select * from questions where id < 5
这时只能使用...
也就是降序排序
questions = Questions.query.order_by(Questions.time.desc()).all()
如果几乎所有的questions都是按照时间降序排序,总不能每一条语句都加上order_by(Questions.time.desc())
所以设置默认排序是有效的
1class Questions(db.Model):
2 __tablename__ = 'questions'
3 id = db...
fabric也使用好久了,这次静下心来好好整理一遍,当然这只是很简单的用法
参考文档
凡事先从安装说起,fabric不支持python3,所以只能安装python2版本的fabric
由于我使用了virtualenv,所以先退出虚拟环境
1$ deactivate
安装全局fabric
1$ sudo pip2 install fabric
使用之前先想想以前是怎么部署的,是不是这样:
先ssh到服务器,进行数据备份,然后退出(或者重新开一个终端),然后上传文件到服务器,
再ssh到服务器,安装所需要的模块,然后退出,ssh到root账户,重启,再退出···
是不是想想都烦
没关系...
·参考
ranger(100)表示0到99这一百个数
可以被next()函数调用并不断返回下一个值的对象称为迭代器:Iterator。
把list、dict、str等Iterable变成Iterator可以使用iter()函数
1>>> a = 'abc'
2>>> a.replace('a', 'A')
3'...
书签不够用了
例子1:https://gist.github.com/bkdinoop/6698956
1def safe_clean(text):
2 from flask import Markup
3 from bleach import clean
4 tags = ['b','i','font','br']
5 attrs =...
:confuse: signature from "Thorsten Töpper [email protected]" is unknown trust
解决:
1$ sudo pacman-key --refresh-keys
arch错误:无法准备事务处理 (无法满足依赖关系) :: package-query: 要求 pacman<4.3
解决:
1$ sudo pacman...
虽然算不上是实时预览
实时预览功能等有时间在把它加上
还是把实时预览加上,不过实时预览可能会对网站有所影响,读者看着加上
1<script type="text/javascript">
2function previewTopicContent(){
3 $.getJSON("{{ url_for('blog.preview') }}", {
4 content: $("#content").val...
1<script type=text/javascript>
2$(document).ready(function(){
3 $('button#ajax').click(function() {
4 $.ajax ({
5 type : "POST",
6 url : "{{ url_for('index...
必须得记下来,否则等那天看到又要浪费时间了,主要记录访问时间这里
1 '''记录访问的时间'''
2 now_time = int(time()) #首先得到当前时间戳
3 '''查询上次访问的时间和最近访问的时间'''
4 query_last_time = redis_data.zscore(visited_users...
supervisor安装请参考flask应用部署——安装环境
1# cd /etc
2# mkdir -p supervisord/conf.d
3# echo_supervisord_conf > /etc/supervisord/supervisord.conf
1# vim supervisord.conf # G直接跳到最后一行
取消下面注释并修改
1[include]
2files = /etc...
虽然以前安装过但是没有记录,这次重新安装,趁机记录下来,省得满世界地找
环境: centos7
参考资料
使用yum list nginx会发现nginx是1.6的版本,但现在nginx已经到了1.9,虽然不必那么新,
但是过旧的版本说不定会出现安全问题
1# vim /etc/yum.repos.d/nginx.repo
输入
1[nginx]
2name=nginx repo
3baseurl=http://nginx.org...
参考资料
准备
1from PIL import Image, ImageDraw, ImageFont, ImageFilter
2
3_letter_cases = "abcdefghjkmnpqrstuvwxy" # 去除可能干扰的i,l,o,z
4_upper_cases = _letter_cases.upper() # 大写字母
5_numbers = ''.join...