`
文章列表
    #!/usr/bin/env python import unittest; class CValue: '''test for run equal''' def __init__(self, nVal): self.m_nVal = nVal; def Equal(self, nVal): if self.m_nVal == nVal: return True; return False; def Multiple(self, nVal): ...
  #!/usr/bin/env python import unittest; class CForTest: '''test for run equal''' def __init__(self, nVal): self.m_nVal = nVal; def equal(self, nVal): if self.m_nVal == nVal: return True; return False; class TestA(unittest.TestCase): ...
  #!/usr/bin/env python import sys; import hashlib; def GetFileMd5(strFile): file = None; bRet = False; strMd5 = ""; try: file = open(strFile, "rb"); md5 = hashlib.md5(); strRead = ""; while ...
Rsync 实现原理 前言 关于rsync的原始文档 Rsync technical report 以及Andrew Tridgell的论文 Phd thesis (pdf) 都是关于rsync算法原理的极好的文档。但是,这些文档注重的是rsync算法本身,而对算 法的实现方法则描述较少。 本文试图对Linux/Unix下的rsync工具的实现进行分析,并将描述下列问题: rsync 算法纵览(非数学性的); rsync 工具中,算法是如何实现的; rsync 工具中用到的协议; rsync 工具中,各个进程的作用(The identifiable ...
  for i in "$LIST": #!/bin/bash LIST="a b c d" echo "first type" for i in $LIST do echo $i; done echo -e "\n\n"; echo "second type" for i in "$LIST" do echo $i done     结果: first type a b c ...
#!/usr/bin/env python from ConfigParser import ConfigParser; def GetIniString(strFile, strSection, strKey): strNullRet = "" if (not os.path.exists(strFile)) or (not strSection) or (not strKey): return strNullRet cfg = ConfigParser() try: cfg. ...
PHP 安装memcached扩展 PHP 中操作memcache有两个扩展,一个叫memcache,一个叫memcached都可以在php的reference中找到,现在 网上比较推荐使用基于libmemcahced 库的memcached扩展。支持memcache提供的CAS操作,稳定性和效率也更好。 安装方法如下: wget http://launchpad.net/libmemcached/1.0/0.42/+download/libmemcached-0.42.tar.gz wget http://pecl.php.net/get/memcached-1.0.2. ...
使用telnet连接memcached,发送统计命令:stats。 shell>telnet 192.168.228.3 9999 Trying 192.168.228.3... Connected to 192.168.228.3. Escape character is '^]'. statsSTAT pid 6995STAT uptime 87233STAT time 1222314531STAT version 1.2.6
memcachedb跟memcache一样,网络socket数据处理依赖于libevent,所以,在安装之前需要下载三个安装包,即libevent、Berkeley Db以及memcachedb。 Libevent 下载页面:http://monkey.org/~provos/libevent/ ,下载最新稳定版本就行。 Berkeley Db下载页面:http://www.oracle.com/technology/software/products/berkeley-db/index.html 需要安装4.6版本 memcachedb下载页面:http://code.google. ...
Web应用中为什么会需要消息队列?主要原因是由于在高并发环境下,由于来不及同步处理,请求往往会发生堵塞,比如说,大量的insert,update之类的请求同时到达mysql,直接导致无数的行锁表锁,甚至最后请求会堆积过多,从而触发too many connections错误。通过使用消息队列,我们可以异步处理请求,从而缓解系统的压力。在Web2.0的时代,高并发的情况越来越常见,从而使消息队列有成为居家必备的趋势,相应的也涌现出了很多实现方案,像Twitter以前就使用RabbitMQ实现消息队列服务,现在又转而使用Kestrel来实现消息队列服务,此外还有很多其他的选择,比如说:ActiveM ...
#include <iostream> using namespace std; class A { public: A() { } virtual ~A() { }; public: virtual void fun() { cout << "A::fun()" << endl; } virtual void fun2() { cout << "A::fun2()" << endl; } void ...

C++文件行查找

#include <iostream> #include <string> #include <fstream> using namespace std; void usage(const char* szExe) { cout << "usage:" << szExe << " <file path> <file string> <print type>" << endl; cout << &qu ...
#!/usr/bin/env python import sys; import simplejson as json; def GetJsonVal(strJsonFile, lsKey): try: if len(lsKey) <= 0: return [-1, '']; mapJson = json.load(file(strJsonFile)); mapVal = mapJson; for strKey in lsKey: ...
import time; import os; import sys; #print a day def PrintTime(stTime): print("%s-%s-%s %s:%s:%s" %(stTime.tm_year, stTime.tm_mon, stTime.tm_mday, stTime.tm_hour, stTime.tm_min, stTime.tm_sec)); def ToInt(strVal): try: nVal = int(strVal); except: re ...
c++偏特化   // temp1.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> #include <string.h> #include <math.h> using namespace std; template <class T> const T& Max(const T& t1, const T& ...
Global site tag (gtag.js) - Google Analytics