思者无域,行者无疆
sogo6 · 共 68 篇文章
Specify a Vary :Accept-Encoding Header解决办法
在用Google的PageSpeed或Yahoo!的Y!Slow查看网页速度时,会看到“…specify a vary: accept-encoding header”的建议,那么怎么来解决这个问题呢? 在博客程序的根目录下找到.htaccess文件,然后文本编辑器编辑它。在文件最后添加下面的代码: <IfModule mod_headers.c> <FilesMatch “\.(js|css|xml|gz)$”> Header append Vary Accept-Encoding </FilesMatch> </IfModule> 刷新一下看看,OK?
2012-09-15 15:40 · web · 评论(0)
python 记录操作系统日志
def writeSysLog(message): if 'win32' in sys.platform: os.popen('eventcreate /T information /ID 1000 /D "%s"'%message) else: os.popen('logger -p local0.info "%s"'%message)
2012-09-04 21:06 · python · 评论(0)
python 实现xml的解析
from xml.dom import minidom import os def parse_svcfile(svc_file): xmldoc = minidom.parse(svc_file) params = xmldoc.getElementsByTagName('param') procName = '' depends = '' for param in params: #print param.toxml() #print param.attributes['name'].value if 'svcagent' == param.attributes['name'].valu…
2012-09-03 14:58 · python · 评论(0)
忘记mac root用户密码之后的修复方法
For Mac OS X 10.5 and later you can use the Directory Utility instead of NetInfo. For just Mac OS X 10.5 you will find it in the Application/Utilities folder. For Mac OS X 10.6 and later you start the Directory Utility from the System Preferences as follows: Start System Preferences and select "Acc…
2012-07-24 21:58 · mac · 评论(0)
记操作系统日志的方法
linux/unix 级别:err/warning/info 扩展标识:固定填local0,和级别组合,比如“local0.err” 例如: logger -p local0.warning "bbbbbb" windows 级别:error/warning/information 事件ID:固定填1000 eventcreate /T warning /ID 1000 /D "aaaaaa" C++的使用: ACE_OS::system(“eventcreate /T error /ID 1000 /D \"install xxx version failed\"”); python的使用…
2012-04-14 16:40 · linux windows · 评论(0)
linux下使用objcopy与-g进行编译的方法
ifeq ($(debug), 0) DEBUG_FLAG = -O2 -g OBJ_DIR = release BUILD_CONFIG = RELEASE DBG_CONFIG = -DRWDEBUG=0 -D_RWCONFIG=m else DEBUG_FLAG = -g OBJ_DIR = debug BUILD_CONFIG = DEBUG DBG_CONFIG = -D_DEBUG -DRWDEBUG=1 -D_RWCONFIG=md endif $(MOD_BIN):$(MOD_OBJ) @mkdir -p $(dir $(MOD_BIN)) $(DBG_PATH) @if […
2012-02-01 16:23 · linux · 评论(0)
linux 系统操作
取一个进程的内存,cpu等信息 ps -p 进程ID -o pid,pcpu,vsz,thcount,sz|grep -v CPU 获取CPU的个数: cat /proc/cpuinfo |grep processor|wc -l 获取某一个进程的句柄 int getPrFdNum(const string& sPid, int& fdNum) { fdNum = 0; if (sPid.empty()) { ErrorOut("getPrFdNum: failed ,pid is null!"); return -1; } string sPath = string("/proc/") +…
2012-01-11 16:08 · linux · 评论(0)
linux 获取内存的方法
#include <sys/resource> int getrusage(int who, struct rusage *r_usage); 利用getrusage可以得到进程的相关资源信息。如:用户开销时间,系统开销时间,接收的信号量等等; 下面是rusage的结构: struct rusage { struct timeval ru_utime; /* user time used */ struct timeval ru_stime; /* system time used */ long ru_maxrss; #define ru_first ru_ixrss long ru_ix…
2011-12-21 22:35 · C++ · 评论(0)
sql处理之5
int CSQLMake::MakeOnFilter(std::string &strOn, CParaSet &oInPara) { int iRet = 0; std::string::size_type stPos = strOn.find(" on "); if (stPos != std::string::npos) { std::string strOnCond = strOn.substr(stPos+4); MakeOnFilter(strOnCond, oInPara); strOn = strOn.substr(0, stPos); if (!strOnCond.empt…
2011-12-20 18:54 · C++ · 评论(0)
给sql填充数据
int CSQLMake::MakeSqlFit(std::string &strSql, CParaSet &oInPara) { int iRet = 0; std::string::size_type iPos = strSql.find("where"); if (iPos == std::string::npos) { return iRet; } std::string strSelect = strSql.substr(0, iPos); // 此处来处理on的情况 std::string strOn; std::string::size_type stOn = strSele…
2011-12-20 18:51 · C++ · 评论(0)
将sql语句用paraset中的值给填充一下!
int CSQLMake::DoSqlFit(std::string &strSql, CParaSet &oInPara) { int iRet = 0; // 拆分sql std::vector<std::string> vctSql; SplitSql(strSql, vctSql); // 循环处理sql std::vector<std::string> vctSqlFit; std::vector<std::string>::iterator itr; for (itr=vctSql.begin(); itr!=vctSql.end(); itr++) { //std::cout …
2011-12-20 18:39 · C++ · 评论(0)
将多个sql语句给合并成一个sql
int CSQLMake::MergeSql(std::string &strSql, std::vector<std::string> &vctSql) { int iRet = 0; boost::regex regEx("@@([\\d]+)"); boost::match_flag_type flags = boost::match_default; std::vector<std::string>::iterator itr; std::string strTemp; std::string::const_iterator start, end; int iCount = 0; f…
2011-12-20 18:32 · C++ · 评论(0)
使用正则表达式来分割sql语句!
int CSQLMake::SplitSql(std::string &strSql, std::vector<std::string> &vctSql) { int iRet = 0; boost::regex regEx("\\(select[\\w\\s='<>!#,.@]*\\)"); std::string::const_iterator start, end; boost::match_results<std::string::const_iterator> what; boost::match_flag_type flags = boost::match_default; in…
2011-12-20 18:30 · C++ · 评论(0)
Webpy + Nginx with FastCGI搭建Web.py
这一节讲解的是如何使用Nginx和FastCGI搭建Web.py应用 环境依赖的软件包 Nginx 0.8.* or 0.7.* (需要包含fastcgi和rewrite模块)。 Webpy 0.32 Spawn-fcgi 1.6.2 Flup 注意:Flup是最常见的忘记装的软件,需要安装 更老的版本应该也可以工作,但是没有测试过,最新的是可以工作的 一些资源 Nginx wiki Spawn-fcgi Flup Notes 你可以重命名index.py为任何你想要的文件名。 /path/to/www 为代码路径。 /path/to/www/index.py为python代码的完整路径。 …