`
东边日出西边雨
  • 浏览: 258151 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论
文章列表

隐私政策

本应用尊重并保护所有使用服务用户的个人隐私权。为了给您提供更准确、更有个性化的服务,本应用会按照本隐私权政策的规定使用和披露您的个人信息。但本应用将以高度的勤勉、审慎义务对待这些信息。除本隐私权政策另 ...

技术支持

 
如果有问题可以发邮件到 songpengfei1210@outlook.com 谢谢!
  在windows下安装c语言写的python模块时,例如:                  pip install lz4    有时会报错 “Unable to find vcvarsall.bat", 这是由于安装c写的模块时,有个编译的过程,默认会查找vs2008的编译器,如果找不到就会报错,如果系统上安装有vs2008就不会报错。这时如果电脑上安装有vs2010 或者 vs2012,可以在命令行执行以下命令解决:   vs2010                SET VS90COMNTOOLS=%VS100COMNTOOLS% vs2012   ...
  c++ STL 中的vector, list, map这些数据结构,经常需要在遍历时删除其中的元素,但是又不能直接删除,会出错。   在你调用erase方法删除元素时,erase方法会返回下一个元素的迭代器,利用这一点,可以写这样的代码:     for(vector<int>::iterator it=d.begin();it!=d.end(); ) { if(*it==3) { it=d.erase(it); } else { ...
    相应的代码: #include <iostream> #include <vector> #include <string> using namespace std; // base class class Beverage { public: virtual string getDescription() = 0; virtual float cost() = 0; }; // base class of condiment, also a base decorator class class Condim ...
  #include <iostream> #include <vector> using namespace std; class Organisms { public: Organisms() { cout<<"Organisms constructor"<<endl; } ~Organisms() { cout<<"Organisms distructor"<<endl; } }; class Animal: p ...

epoll高效的原因

 
epoll高效的原因:   使用内核中断实现,中断后调用处理函数处理,是异步的。   http://blog.chinaunix.net/uid-17299695-id-3059110.html
c语言, 有两个int型的数字,怎么样不用临时变量交换两个数字的值?   用如下方法即可:   int a = 10; int b = 20; a = a^b; b = a^b; a = a^b; printf("%d %d\n", a, b);   result:    20 10   这是为什么呢?   首先得理解“异或操作”, 异或是一种位操作,相同的位异或结果是0, 不同的位异或结果为1. 在第一个 a = a^b后,a的值其实保存了a, b两个变量之间的比较结果,也可以理解为a, b两变量的差异。 这时根据b和保存 ...
  read -p "Input your birthday(mm-dd):" birth birth=`date +%Y`-$birth date_birth=`date --date $birth +%s` #得到生日的秒值 date_now=`date +%s` #得到当前时间的秒值 internal=$(($date_birth-$date_now)) #计算今日到生日日期的间隔时间 if [ "$internal" -lt "0" ]; then #判断今天的生日是否 ...
  端口写成0就可以,python会查找一个可用的tcp口绑定。   def get_open_port(): import socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind(("",0)) s.listen(1) port = s.getsockname()[1] s.close() return port    
可以用这个函数:   import commands, os, re def process_info(): pid = os.getpid() res = commands.getstatusoutput('ps aux|grep '+str(pid))[1].split('\n')[0] p = re.compile(r'\s+') l = p.split(res) info = {'user':l[0], 'pid':l[1], 'cpu':l[2], 'mem':l ...
如果只是简单地执行shell命令,可以这样:     import os os.system('ls')   得到shell的输出(不管标准输出或是错误输出)     import commands result= commands.getstatusoutput(shellcommand) output= result[1]   但是无法输入信息到shell,subprocess还是要更好用一些,可以和shell交互,因为重定向了stdin, stdout, stderr     import subprocess p = subprocess ...
  用这个函数可以实现功能: import socket import fcntl import struct def get_ip_address(ifname): s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) return socket.inet_ntoa(fcntl.ioctl( s.fileno(), 0x8915, struct.pack('256s', ifname[:15]) )[20:24] )   ...
c版本(UNIX高级编程中的例子):   // sendmsg.h #ifndef SENDMSG_H #define SENDMSG_H #include <sys/types.h> int send_fd(int fd, int fd_to_send); int recv_fd(int fd, ssize_t (*userfunc)(int, const void*, size_t)); #endif     // semdmsg.c #include "sendmsg.h" #include <sys/so ...
转载自:http://www.php100.com/html/itnews/PHPxinwen/2012/0103/9606.html 不断有人跟我说Nginx比Apache好、比Apache快之类。Nginx更主要是作为反向代理,而非Web服务器使用。我翻译过一本关于反向代理的技术书籍,同时精通Apache API开发,对Ngin ...
Global site tag (gtag.js) - Google Analytics