fedora21防火墙图形界面

2015年5月21日 17:49

fedora21默认未安装firewall的图形界面,需要自己安装
sudo yum install firewall-config
启动
sudo firewall-config

 

评论(2) 阅读(3124)

在fedora21中运行VMware Tools进入死循环

2015年5月21日 15:28

在vmware中安装fedora21,然后安装VMware Tools,执行命令之后,一路回车,结果在下面不断循环
The path "/bin/gcc" appears to be a valid path to the gcc binary.
Would you like to change it? [no] 
Searching for a valid kernel header path...
The path "" is not a valid path to the 3.19.7-200.fc21.x86_64 kernel headers.
Would you like to change it? [yes] 
 
猜测是缺少了dev包,执行下面命令后,就好了
sudo yum install kernel-devel
 

评论(0) 阅读(1609)

python2.6.6控制台输出小数问题

2015年5月12日 17:32

示例
[root@wyq-vserver-vm-master ~]# python
Python 2.6.6 (r266:84292, Jun  3 2012, 00:16:45) 
[GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> a=3.4
>>> a
3.3999999999999999   #输出不正常
>>> b=2
>>> b
2
>>> a*b
6.7999999999999998   #输出不正常
>>> print a*b
6.8                  #输出正常并且数值正确
>>> 
 
从上面内容,可以看出,a与b的数值本身正常,只是控制台在进行格式化输出时不正常
 

评论(0) 阅读(1927)

如何配置django静态文件路径

2015年5月12日 09:54

django默认无法直接访问静态文件(js、css、images),并且设置方法会与DEBUG相关

DEBUG=True时

要在settings中的配置STATICFILES_DIRS参数. 如下
# static目录url路径
STATIC_URL = '/static/'

#static目录磁盘路径
STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'mysite/static'),
)

DEBUG=Flase时

在DEBUG=Flase时,不仅需要进行上面设置,而且要多加两处配置.
  • settings文件
STATIC_ROOT = '/homew/wyq/mysite/mysite/static'
  • urls.py文件
from django.conf import settings

if settings.DEBUG is False:
    urlpatterns += patterns('',
        url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {
            'document_root': settings.STATIC_ROOT,
        }),
    )
 

 

评论(21) 阅读(2690)

ssh公钥匙登录失败原因

2015年5月09日 16:50

一、配置参数未开启

打开远程主机/etc/ssh/sshd_config,去掉下面几行前面的"#"注释
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
然后重启ssh服务
service sshd restart

二、目录权限不正确

查看/var/log/secure文件,发现提示
May  9 15:25:17 localhost sshd[54931]: Authentication refused: bad ownership or modes for directory /root
 
查看此时ssh用户的目录权限
drwxrwxrwx   9 root root  4096 5月   9 15:38 root
 
使用"chmod og-w /root"修改为
drw-xr-r. 1 root root 942 5月   7 16:57 anaconda-ks.cfg
这里权限只是一个示例,大部分机器上的root目录权限不是这样的.

三、密钥未添加到ssh-agent

ssh调试信息中出现
➜  ~  ssh -v root@192.168.8.11
...
Agent admitted failure to sign using the key
...
 
解决办法
➜  ~  ssh-add
Identity added: /home/wyq/.ssh/id_rsa (/home/wyq/.ssh/id_rsa)
ssh-agent用于管理公钥身份验证所使用的私钥,ssh-add用于将密钥加入到ssh-agent中
 
 

评论(0) 阅读(3162)

shell中怎么注释多行

2015年5月08日 16:27

shell本身没有多行注释,有什么办法达到多行注释效果?
  • 语法
:<<标记

...代码

标记
冒号":"表示什么也不做,即空命令
重定向"<<"是Here Document
表示把文档内容重定向到空命令
  • 示例
:<<EOF
echo "hello world"
...
EOF
再如
:<<BLOCK
echo "hello world"
....
BLOCK
 

Tags: shell
评论(0) 阅读(2291)

sqlite客户端sqliteman

2015年5月06日 11:29

sqliteman是sqlite数据库的图形化管理工具

  • 安装
sudo yum install sqliteman
  • 启动
sqliteman

 

评论(1) 阅读(2452)

jekyll云分类

2015年4月06日 16:48

分类太多,导致分类列表太长,页面很难看,该怎么办? 一个办法是改变展示形式. jquery正好有插件,可以让列表直接成为云标签.
  • 插件地址
https://github.com/addywaddy/jquery.tagcloud.js
插件本身用法非常简单,重点介绍在jekyll博客中的示例.
  • 新建模板(_includes/category_cloud.html)
<script type="text/javascript" src="{{ site.baseurl }}/static/js/jquery.tagcloud.js"></script>

<div id='category_cloud'>
    <h3>分类</h3>
    <div class="categories">
        {% for cat in site.categories\%}
        <a href="/categories.html#{{cat | first}}" rel="{{ cat|last|size  }}">{{cat | first}}</a>
        {% endfor \%}
    </div>
</div>
<script>
$.fn.tagcloud.defaults = {
  size: {start: 14, end: 18, unit: 'pt'},
  color: {start: '#555', end: '#428bca'}
};

$(function () {
  $('.categories a').tagcloud();
});
</script>
  • 包含模板  
在需要使用的地方包含category_cloud.html即可
<div class="well">
{% include category_cloud.html %}
</div>
 

Tags: jquery
评论(0) 阅读(3628)

基于python的最简单jQuery File Upload示例

2015年3月27日 13:42

找到个很不错的文件上传插件jQuery File Upload. 资料太少. 只能自己搭个环境,照着例子摸索. 奈何最简单的例子是基于php的, 不熟. 弄了个基于python的例子.
  • github
https://github.com/blueimp/jQuery-File-Upload
  • 目录
使用flask做了个简单web服务器,接收上传请求. 目录结构如下
https://github.c➜  flask-demo  tree
.
├── app.py
├── static
│   ├── 123.txt
│   └── file-upload
│       ├── angularjs.html
│       ├── basic.html
│       ├── basic-plus.html
│       ├── blueimp-file-upload.jquery.json
│       ├── bower.json
│       ├── CONTRIBUTING.md
│       ├── cors
│       │   ├── postmessage.html
│       │   └── result.html
│       ├── css
│       │   ├── demo.css
│       │   ├── demo-ie8.css
│       │   ├── jquery.fileupload.css
│       │   ├── jquery.fileupload-noscript.css
│       │   ├── jquery.fileupload-ui.css
│       │   ├── jquery.fileupload-ui-noscript.css
│       │   └── style.css
│       ├── Gruntfile.js
│       ├── img
│       │   ├── loading.gif
│       │   └── progressbar.gif
│       ├── index.html
│       ├── jquery-ui.html
│       ├── js
│       │   ├── app.js
│       │   ├── cors
│       │   │   ├── jquery.postmessage-transport.js
│       │   │   └── jquery.xdr-transport.js
│       │   ├── jquery.fileupload-angular.js
│       │   ├── jquery.fileupload-audio.js
│       │   ├── jquery.fileupload-image.js
│       │   ├── jquery.fileupload-jquery-ui.js
│       │   ├── jquery.fileupload.js
│       │   ├── jquery.fileupload-process.js
│       │   ├── jquery.fileupload-ui.js
│       │   ├── jquery.fileupload-validate.js
│       │   ├── jquery.fileupload-video.js
│       │   ├── jquery.iframe-transport.js
│       │   ├── jquery.min.js
│       │   ├── main.js
│       │   └── vendor
│       │       └── jquery.ui.widget.js
│       ├── package.json
│       ├── README.md
│       ├── server
│       │   ├── gae-go
│       │   │   ├── app
│       │   │   │   └── main.go
│       │   │   ├── app.yaml
│       │   │   └── static
│       │   │       ├── favicon.ico
│       │   │       └── robots.txt
│       │   ├── gae-python
│       │   │   ├── app.yaml
│       │   │   ├── main.py
│       │   │   └── static
│       │   │       ├── favicon.ico
│       │   │       └── robots.txt
│       │   ├── node
│       │   │   ├── package.json
│       │   │   ├── public
│       │   │   │   └── files
│       │   │   │       └── thumbnail
│       │   │   ├── server.js
│       │   │   └── tmp
│       │   └── php
│       │       ├── files
│       │       ├── index.php
│       │       └── UploadHandler.php
│       ├── test
│       │   ├── index.html
│       │   └── test.js
│       └── test.html
└── templates
    └── index.html

23 directories, 57 filesom/blueimp/jQuery-File-Upload
  • app.py
#encoding=utf-8
from flask import Flask
from flask import request
from flask import abort, redirect, url_for
from flask import render_template
import json

app = Flask(__name__)


@app.route('/')
def index():
    return render_template('index.html')


@app.route('/upload', methods=['GET', 'POST'])
def upload_file():
    if request.method == 'POST':
        f = request.files['files[]']
        filename = f.filename
        minetype = f.content_type
        f.save('static/' + filename)
    return json.dumps({"files": [{"name": filename, "minetype": minetype}]})


if __name__ == '__main__':
    app.run(host="0.0.0.0", port=7000, debug=True)
  • demo.html
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>jQuery File Upload 示例</title>
</head>
<body>
<input id="fileupload" type="file" name="files[]" data-url="/upload" multiple>
<script src="/static/file-upload/js/jquery.min.js"></script>
<script src="/static/file-upload/js/vendor/jquery.ui.widget.js"></script>
<script src="/static/file-upload/js/jquery.iframe-transport.js"></script>
<script src="/static/file-upload/js/jquery.fileupload.js"></script>
<script>
$(function () {
    $('#fileupload').fileupload({
        dataType: 'json',
        done: function (e, data) {
            $.each(data.result.files, function (index, file) {
                $('<p/>').text(file.name).appendTo(document.body);
            });
        }
    });
});
</script>
</body> 
</html>
试了之后,确实很不错.
 

Tags: python flask jquery
评论(109) 阅读(13546)

pillow模块生成缩略图

2015年3月26日 15:32

python使用pillow模块生成缩略图

  • 安装
pip install Pillow
  • 示例
from PIL import Image

im = Image.open("logo.png")
im.thumbnail((32, 32))
im.save("thumbnail.png", "png")
pillow文档地址

 

 

评论(1) 阅读(4685)