03 2014 档案

摘要:在使用c++多线程使用libcurl抓取网页时,遇到程序随机core掉的情况,gdb 一下出错信息有这么一条:longjmp causes uninitialized stack frame。在网上查了一下原来是curl有“CURLOPT_NOSIGNAL” ,将这个值设为1就忽略抛出的信号了~具体解释:CURLOPT_NOSIGNALPass a long. If it is 1, libcurl will not use any functions that install signal handlers or any functions that cause signals to be 阅读全文
posted @ 2014-03-20 20:17 anexplore 阅读(439) 评论(0) 推荐(0)
摘要:在多元线性回归中会用到梯度下降来计算参数值。这里我用python实现一个梯度下降版本。这里多元线性方程为 y = A0+A1*x1+...+An* xn数据输入格式,y表示y \t x1 \t x2 \t .... xn代码如下:import osimport systheta = []training_data = []h_value = []alpha = 0.0000009 def load(path): f = open(path,'r') for x in f: x = x.strip('\r\n') field = x.split('\t&# 阅读全文
posted @ 2014-03-11 22:06 anexplore 阅读(641) 评论(0) 推荐(0)
摘要:下面一段代码是创建socket server的代码片段:需要引用的库包括:#include #include #include int ss = -1; ss = socket(AF_INET,SOCK_STREAM,0); //获得句柄 if(ss < 0){ fprintf(stderr,"socket create error\n"); return false; } server_fd = ss; sockaddr_in server_addr; server_addr.sin_family = AF_INET; //协议类型 server_addr.sin_ 阅读全文
posted @ 2014-03-03 16:58 anexplore 阅读(2190) 评论(0) 推荐(0)