04 2013 档案

摘要:1、连接数据库import os,sysPROJECT_ROOT = os.path.dirname(os.path.realpath(__file__))sys.path.insert(0, os.path.join(PROJECT_ROOT, 'lib'))CONFIG_PATH = os.path.join(PROJECT_ROOT,'config.cfg')from sqlalchemy import create_enginefrom sqlalchemy.ext.declarative import declarative_baseimport Co 阅读全文
posted @ 2013-04-26 20:16 glose 阅读(4316) 评论(0) 推荐(0) 编辑
摘要:登录数据库 [root@localhost tornado]# psql -U luoyun -d luoyun\c dbname切换数据库,相当于mysql的use dbname\l列举数据库,相当于mysql的show databases\dt列举表,相当于show tables\d tblname查看表结构,相当于desc tblname,show columns from tbnamecreatedb 创建一个新的PostgreSQL的数据库(和SQL语句:CREATE DATABASE 相同)createuser 创建一个新的PostgreSQL的用户(和SQL语句:CREATE U 阅读全文
posted @ 2013-04-26 16:02 glose 阅读(348) 评论(0) 推荐(0) 编辑
摘要:yum installpython-psycopg2yum install libvirt-devel 阅读全文
posted @ 2013-04-26 15:26 glose 阅读(137) 评论(0) 推荐(0) 编辑
摘要:fromsqlalchemy.ext.declarativeimportdeclarative_basefromsqlalchemyimportColumn,Integer,StringfromsqlalchemyimportSequencefromsqlalchemy.ormimportsessionmakerBase=declarative_base()fromsqlalchemyimportcreate_engineengine=create_engine('sqlite:///:memory:',echo=True)classUser(Base):__tablename 阅读全文
posted @ 2013-04-26 10:12 glose 阅读(443) 评论(0) 推荐(0) 编辑
摘要:PS:Nginx使用有两三年了,现在经常碰到有新用户问一些很基本的问题,我也没时间一一回答,今天下午花了点时间,结合自己的使用经验,把Nginx的主要配置参数说明分享一下,也参考了一些网络的内容,这篇是目前最完整的Nginx配置参数中文说明了。更详细的模块参数请参考:http://wiki.nginx.org/Main#定义Nginx运行的用户和用户组user www www;#nginx进程数,建议设置为等于CPU总核心数。worker_processes8;#全局错误日志定义类型,[ debug | info | notice | warn | error | crit ]error_lo 阅读全文
posted @ 2013-04-25 09:36 glose 阅读(2017) 评论(0) 推荐(0) 编辑
摘要:第一部分、从一道题,漫谈数据结构、以及压缩、位图算法(转载)海量数据处理往往会很有趣,有趣在什么地方呢?空间,aliveable的内存不够,需要反复交换内存时间,速度太慢不行,毕竟那是海量数据处理,数据是一次调用还是反复调用,因为针对时间和空间,通常来说,多次调用的话,势必会增加预处理以减少每次调用的时候的时间代价。题目如下7、腾讯面试题:给40亿个不重复的unsignedint的整数,没排过序的,然后再给一个数,如何快速判断这个数是否在那40亿个数当中?分析:1个unsigned int占用4字节,40亿大约是4G个数不到,那么一共大约要用16G的内存空间,如果内存不够大,反复和硬盘交换数据 阅读全文
posted @ 2013-04-22 10:21 glose 阅读(1483) 评论(0) 推荐(0) 编辑
摘要:给定一个超过10万元素,每个元素均不大于1000的数组,怎样对其进行排序?这个题目就要多亏了晓东。明显的是这些元素中会有很多重复的元素。计数排序无疑是最佳的方式。参考链接:http://www.cppblog.com/shongbee2/archive/2009/04/24/80991.html#include<stdio.h>#include<stdlib.h>//计数排序intCountSort(int*pData,intnLen){int*pCout=NULL;//保存记数数据的指针pCout=(int*)malloc(sizeof(int)*nLen);//申请 阅读全文
posted @ 2013-04-21 20:10 glose 阅读(211) 评论(0) 推荐(0) 编辑
摘要:http://blog.csdn.net/piaojun_pj/article/details/6103709 阅读全文
posted @ 2013-04-19 10:05 glose 阅读(192) 评论(0) 推荐(0) 编辑
摘要:http://www.cppblog.com/baby-fly/archive/2009/10/24/99356.htmlhttp://www.cnblogs.com/Myhsg/archive/2009/08/29/1556460.html 阅读全文
posted @ 2013-04-19 08:39 glose 阅读(132) 评论(0) 推荐(0) 编辑
摘要:1、去http://nodejs.org/download/下载一个安装包 上传到系统的某个路径下2、tar xvfnode-v0.10.4.tar.gz3、cdnode-v0.10.44、检查所需配置# ./configure出现错误提示:Exception: Call to '(echo | $(echo ${CXX_host:-$(which g++)}) -m32 -E -> /dev/null 2>&1) && echo "-m32" || true' returned exit status 0. whilel 阅读全文
posted @ 2013-04-17 14:10 glose 阅读(213) 评论(0) 推荐(0) 编辑
摘要:安装1、yum install postgresql postgresql-server2、初始化数据库以及启动服务service postgresql initdbservice postgresql start3、postgresql的端口号5432 有防火墙的时候需要开放配置yum安装postgresql后的安装路径为:/var/lib/pgsql下,主要配置文件在其data文件夹下,进入data文件夹1、修改postgresql.conf文件如果想让PostgreSQL监听整个网络的话,将listen_addresses前的#去掉,并将listen_addresses = 'l 阅读全文
posted @ 2013-04-17 10:19 glose 阅读(336) 评论(0) 推荐(0) 编辑
摘要:su -c 'rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm' 阅读全文
posted @ 2013-04-16 23:35 glose 阅读(154) 评论(0) 推荐(0) 编辑
摘要:http://www.cnblogs.com/dolphin0520/archive/2011/08/24/2151846.htmlhttp://www.cppblog.com/oosky/archive/2006/07/06/9486.htmlhttp://kenby.iteye.com/blog/1025599 阅读全文
posted @ 2013-04-10 10:24 glose 阅读(143) 评论(0) 推荐(0) 编辑
摘要:修改系统的两个文件即可。vi /etc/pam.d/loginsession required /lib64/security/pam_limits.sosession required pam_limits.sovi /etc/security/limits.conf* soft nofile 102400* hard nofile 409600参考:http://www.centos.bz/2012/05/linux-increase-the-maximum-number-of-open-files/也可以在/etc... 阅读全文
posted @ 2013-04-08 20:24 glose 阅读(446) 评论(0) 推荐(0) 编辑
摘要:http://www.cnblogs.com/xia520pi/archive/2012/05/16/2503949.html 阅读全文
posted @ 2013-04-08 18:17 glose 阅读(137) 评论(0) 推荐(0) 编辑
摘要:http://linux.bokee.com/catalog_11708.html 阅读全文
posted @ 2013-04-05 20:30 glose 阅读(107) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/pythontry: import jsonexcept ImportError: import simplejson as jsonimport sysif __name__=='__main__': compath=b"/LuoYun/conf/luoyun.conf" f=open(compath,"r") jsonstr="" for l in f.readlines(): if l[:5]=='JSON=': jsonstr=l[5:] jsonstr.strip() b 阅读全文
posted @ 2013-04-03 15:31 glose 阅读(216) 评论(0) 推荐(0) 编辑
摘要:import socketimport reimport sysimport getoptimport stringdef check_server(address,port): s=socket.socket() print "Attempting to connect to %s on port %s" % (address, port) try: s.connect((address,port)) print "Connected to %s on port %s" % (address, port) return True excep... 阅读全文
posted @ 2013-04-03 15:30 glose 阅读(342) 评论(0) 推荐(0) 编辑
摘要:import subprocessmachines=["10.0.4.1","10.0.4.2","10.0.4.3","10.0.4.4","10.0.4.5","10.0.4.6","10.0.4.7","10.0.4.8","10.0.4.9","10.0.4.10"]cmd = "hostname"for machine in machines: subprocess. 阅读全文
posted @ 2013-04-03 15:29 glose 阅读(384) 评论(0) 推荐(0) 编辑
摘要:VI打开和编辑多个文件的命令可分两种情况:1、在同一窗口中打开多个文件:vifile1 file2 file3:n 切换到下一个文件 (n=next):N 切换到上一个文件2、在不同窗口中打开多个文件:如果已经打开一个了一个文件,则在vi的命令输入状态下输入:sp另外一个文件的路径及文件名,如此就可以在一个窗口打开多个文件了。或者用vi -ofile1 file2 file3....用分割屏幕窗口方式同时打开多个文件。可以使用 ctrl + 两次按w或者ctrl + w然后按上下键在上下窗口间切换。2.窗口分割实现编辑多文件 *先使用vi打开一个文件,例如vi actinia_proenrul 阅读全文
posted @ 2013-04-03 10:55 glose 阅读(256) 评论(0) 推荐(0) 编辑
摘要:import getoptimport sysdef usage(): print(''' this is help message -h --help show help info -i --input the input file or directory -g --grep grep words -t --time modify time -v --verbose show verbose information ''') passdef main(): try: opts,args=getopt.getopt(sys.argv[1:],& 阅读全文
posted @ 2013-04-03 10:54 glose 阅读(691) 评论(0) 推荐(0) 编辑

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示