2013年8月24日

安装gevent

摘要: 安装的时候报了个错:error: Setup script exited with error: command 'gcc' failed with exit status 1其实就是没有安装libevent-devapt-get install libevent-dev 好了 阅读全文

posted @ 2013-08-24 02:00 h3idan 阅读(154) 评论(0) 推荐(0) 编辑

2013年8月16日

python 查看文件的修改时间

摘要: 1 import os2 time.strftime('%Y-%m-%d %H:%M', time.localtime(os.stat('test/d.tbz').st_mtime)) 阅读全文

posted @ 2013-08-16 17:44 h3idan 阅读(483) 评论(0) 推荐(0) 编辑

2013年7月8日

python 一些简单的算法

摘要: 1 def qsort(alist):2 if not a:3 return []4 else:5 return qsort([i for i in alist[1:] if i = alist[0]])快速排序。 1 def search2(alist, num): 2 low = 0 3 high = len(alist) - 1 4 while low m:10 high = mid - 111 else:12 return mid二分查找1 def ... 阅读全文

posted @ 2013-07-08 20:58 h3idan 阅读(262) 评论(0) 推荐(0) 编辑

2013年6月27日

python + ajax 实现拖动功能

摘要: 这些日子写了一个机房中添加机柜的功能,需要实现机柜自由拖动,然后保存数据库。html代码 1 2 3 4 5 机房视图 6 7 8 9 10 11 24 25 30 31 32 33 34 35 37 {{ room.name }}布局管理 38 39 --> 40 41 42 43 44 45 模板 46 {% for cabinet in cabinets %} 47 48 {{ cabinet.id }... 阅读全文

posted @ 2013-06-27 11:11 h3idan 阅读(538) 评论(0) 推荐(0) 编辑

2013年5月22日

django后台实现微信公众平台网址接入

摘要: django1.3.1 + python2.6.6前期准备不多说,自己的服务器,自己去申请微信公众平台帐号在高级功能 --> 开发模式填写django配置中你需要的接入的url和token。这块主要是实现接入微信api的时候需要认证的功能 1 from django.http import HttpResponse 2 import hashlib 3 4 def checkSignature(request): 5 ''' 6 验证微信api提供的signature和token等信息 7 ''' 8 9 token = '自己随意 阅读全文

posted @ 2013-05-22 16:56 h3idan 阅读(1912) 评论(0) 推荐(0) 编辑

2013年5月17日

rhel5.4下编译安装python2..6.6 + mod_python

摘要: ./configure CFLAGS=-fPIC && make && make install编译安装必须添加 CFLAGS=-fPIC,否则在安装mod_python的时候会报错。错误:/usr/local/lib/python2.6/config/libpython2.6.a: could not read symbols: Bad value编译安装完后编译安装,mod_python,指定python版本./configure --with-python=/usr/local/bin/python2.6网上推荐用:./configure --enable 阅读全文

posted @ 2013-05-17 13:39 h3idan 阅读(230) 评论(0) 推荐(0) 编辑

2013年4月25日

ajax接收django发送的json数据

摘要: 首先django要有写发送json数据的方法 1 import simplejson 2 3 def sendjson(request): 4 ''' 发送json数据 ''' 5 result = {'username': 'username', 'password': 'password'} 6 result = simplejson.dumps(result) 7 8 return HttpResponse(result) 9 10 def index(request):11 阅读全文

posted @ 2013-04-25 22:41 h3idan 阅读(522) 评论(0) 推荐(0) 编辑

2013年4月22日

ajax 中after(), insertAfter(), before(), insertBefore()等用法

摘要: 之前一直写后台,对ajax不是特别熟悉。只是知道有这么个牛逼的东西。最近看了下,实现了几个简单的功能。记录下来。下载jquery。在html文件中导入。ajax可以减少服务器的流量。减轻前端的压力。反正优点多多。 1 <script type="text/javascript"> 2 function getfiles(dirnames){ // dirnames是django传过来的参数。 3 $.ajax({ 4 url:"/localoperate/projects/projectfiles/", // 需要请求的u... 阅读全文

posted @ 2013-04-22 22:45 h3idan 阅读(343) 评论(0) 推荐(0) 编辑

2013年3月27日

自己用的vim配置文件 .vimrc

摘要: python和c可以自动缩进 1 " filename:.vimrc 2 " author:h3idan 3 4 set nocompatible "非兼容模式 5 syntax on "开启语法高亮 6 set background=dark "背景色 7 8 " 配色方案 9 "color peaksea 10 color desert 11 12 set filetype=python 13 14 set modeline 15 set ruler "在左下角显示当前文件所在行 16 set showcmd 阅读全文

posted @ 2013-03-27 15:38 h3idan 阅读(272) 评论(0) 推荐(0) 编辑

python dict根据value排序

摘要: 用一个sorted这个内置函数,可以字典排列成一个list的元组。1 #!/etc/bin/env python2 #conding: utf-83 4 d = {'a': 1, 'b': 12, 'c': 3, 'd': 0}5 6 sorted(d.items(), key=lambda x: x[1]) # d.items() 将dict中key-value转化成元组形式, x[1]就是元组中的第二个元素 阅读全文

posted @ 2013-03-27 15:22 h3idan 阅读(197) 评论(0) 推荐(0) 编辑

导航