- 博客(30)
- 收藏
- 关注
原创 python scrapy window linux 坑
想写个爬虫,看大家用的最多的是 python 库 scrapy,结果环境啊各种问题搞得真是麻烦。。。linux 下注意:scrapy 安装需要 Python 2.7 以上,但是 centos6 提供的是 Python2.6,而且因为系统各种工具包括 yum 都基于Python2.6,所以不能简单的升级。网上教程表示可以源码安装并修改软链到 2.7,然后将系统其它工具如 yum 等的解析
2015-12-07 01:04:11
742
原创 protobuf java 反射
需求:线上需要一份数据,这份数据是存储在hbase中的(比如对于某一个实体,其各个字段是存储在hbase的各个列的)。而希望最终导出的文件的每一行是一个 protobuf 的message,以方便解析和维护。具体做法:定义一个 protobuf message,其各个 field 的名字与 hbase 各列的 key 的名字对应,将 hbase 中各列对应的 value 取出来,填充
2015-11-13 19:00:33
5469
原创 Eclipse cdt c++11 blade 设置
下载 Eclipse cdt:http://ftp.daumkakao.com/eclipse/technology/epp/downloads/release/mars/R/eclipse-cpp-mars-R-linux-gtk-x86_64.tar.gz默认不支持 c++11,打开c++11:http://stackoverflow.com/questions/174
2015-09-17 15:11:10
1665
原创 couchbase ttl 设置问题
哈哈,今天打算把这个博客写成流水账。。今天加班过来公司想解决一个 bug,然后优化一下代码。但是过来之后就开始学 Scala 相关的东西,一直到了五点才开始想这个 bug。没想到一分钟就灵关一闪意识到了为什么。。。调查了一下代码果然是这样。。。可怜自己前两天凌晨 debug 一个多小时。。。可见有了 bug 无需惊慌,不着急的话可以缓缓。原因是我把在配置文件中设置的 ttl:1
2015-09-12 19:56:33
850
原创 c++ thread 笔记1
今天看 c++ Concurrency In Action, 读到:Once you’ve started your thread, you need to explicitly decide whether to wait for it tofinish (by joining with it—see section 2.1.2) or leave it to run on its own
2015-07-18 19:10:14
803
原创 boost tokenizer 坑
今天发现 boost tokenizer容易用错的地方,记录一下。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 8 9 using namespace std; 10 using names
2015-05-26 15:57:37
523
原创 多线程 栈空间变量 可见性
今天看couchbase 回调代码的时候发现 callback 函数有一个参数是 cookie,相当于一个调用异步函数时的上下文。http://docs.couchbase.com/developer/c-2.4/c-intro.html我们代码里面是类似这样用的。// 回调函数static void get_callback(lcb_t instance,
2015-05-08 22:23:18
1324
原创 APUE 笔记 文件访问权限
文件模式字中有两个特殊标识:“设置用户ID” 和 “设置组ID”.“设置用户ID”的作用是“当执行此文件时,将进程的有效用户ID设置为文件所有者的用户ID”如 passwd 程序,[root@licchen-test-dev001-bjdxt tests]# which passwd/usr/bin/passwd[root@licchen-test-dev001-bjdxt te
2015-04-27 22:21:58
411
原创 map 下标操作 value 需要有默认构造函数
今天在写程序时有一个编译错误,no matching function for call to 'AAAA()'
2014-09-18 22:13:24
3696
1
原创 Python笔记
1. 正则表达式 match 和 search 区别:match从开始处匹配,search扫描整个字符串。>>> regex=re.compile(r'hello')>>> match=regex.match("world hello")>>> print matchNone但是match换成search可以匹配。。2. 原始字符串的用法:>
2014-09-11 14:54:56
472
原创 protobuf笔记
今天发现google::protobuf::TextFormat::Parse 即使顺序错误确实可以解析。。而且发现ParseFromString有两个。一个与google::protobuf::TextFormat::ParseFromString,与google::protobuf::TextFormat::Parse类似,只是将文件换成了字符串;另外一个是Message(其实
2014-09-10 21:10:04
5972
原创 c++ null pointer 导致segment fault
#include 2 #include 3 #include 4 #include 5 6 using namespace std; 7 class A { 8 public: 9 A() : pa(NULL), inta(-1) {} 10 A* getPa() { return pa; } 11 void fun() { cout << "fun" << endl; } 12 int getI
2014-07-18 10:29:33
693
原创 工作中遇到的一些问题 小 tip
将某文件夹递归scp到使用key认证的远程server:1. 在client端生成 key pair, 将公钥(以.pub结尾)的内容添加到远程server的 /$HOME/.ssh/authorized_keys 的末尾。2. scp -i private_key_file -r folder_digui username@server:/directory删除某文件
2014-04-09 21:01:49
800
原创 win8.1 华硕S300CA 触摸板 卡
今天触摸板的滚动效果和右键效果很卡,指针移动和触摸板底部左键和右键的按下功能正常。我想起来刚升级了win8.1,所以可能是因为这个。解决办法:在控制面板 -> 程序和功能 -> ASUS Smart Gesture -> 修复 -> 重启电脑。就ok了。
2014-03-01 22:00:45
1311
原创 JAVA垃圾回收 之 引用计数 之 循环引用
。。。java鸟蛋表示搞不明白。。。关于引用计数版本的垃圾回收机制,大家的说法都是:"无法检测出循环引用。如父对象有一个对子对象的引用,子对象反过来引用父对象。这样,他们的引用计数永远不可能为0."但是为什么不能检测出来呢?比如Class A{B b;}Class B{A a;}如果有以下代码:{A a = new A
2013-04-01 18:04:56
6374
原创 字符串全排列 C语言实现
参考 http://www.cnblogs.com/python27/archive/2011/12/08/2281352.html#include #include void swap(char *left, char *right){ char tmp = *left; *left = *right; *right = tmp;}void permutatio
2012-10-06 16:50:35
2246
原创 按单词翻转字符串 C语言实现
先翻转整个字符串,再翻转每个单词。#include void swap(char *left, char *right){ char tmp = *left; *left = *right; *right = tmp;}void reverse(char *str, int begin, int end){ while(begin < end){ swap(&st
2012-10-06 15:25:12
1092
原创 去除字符串中多余的空格 C语言实现
比如“hello world hey baby”变成“hello world hey baby”思想是设置两个指针,前面的(front)一直往前走直到字符串结尾,后面的(last)复制front当前指向的字符,当遇到多个空格时并不复制,而是等到front指向非空格字符时在往前走。#include #include #incl
2012-09-26 22:06:57
5885
原创 数据结构 算法面试100题 之 二叉树转换成双向链表
本质上是对二叉树进行中序遍历。二叉树节点和链表节点使用同一个struct,只改变指针指向。#include "stdio.h"#include "stddef.h"#include "stdlib.h"#include "assert.h"struct s_node{int value;struct s_node *lNode;struct s_no
2012-09-11 16:16:52
643
原创 数据结构 算法面试100题 之 逐层遍历二叉树元素
其实就相当于图的宽度优先遍历。#include "stdio.h"#include "stddef.h"#include "stdlib.h"#include "assert.h"struct s_treeNode{int value;struct s_treeNode *lc;struct s_treeNode *rc;};typedef
2012-09-07 19:35:09
472
原创 MOS管 基础
1. MOS管可以看成开关。当栅源电压VGS大于阈值电压VT时,源漏之间会形成导电沟道。如果源漏之间有电压差(VDS不等于0),则会有电流流过。VDS较小时,为线性工作区,电流随电压VDS的增大几乎成线性方式增大,当VDS> VGS - VT时,电流不在增大,而保持常数(与VGS成平方关系),为饱和区。2. NMOS的阈值电压为正,PMOS的阈值电压为负值。
2012-08-30 17:08:54
1502
原创 快排 c语言实现
#include int split(int a[], int first, int last){int pvt = a[first];int left = first; // can't written as left = first + 1, which will ca
2012-08-28 20:38:37
858
原创 C++ 实现 根据字符串 调用同名函数
需求: 希望根据用户的输入调用同名的函数。因为不想写各种 if else,所以就建立一个key为string,value为函数指针的map,根据string的值调用相应的函数。以下代码在gcc 3.4.6下测试通过。下面是代码的第一次实现:#include#include#includevoid buildMap();class
2012-08-24 18:35:03
6531
原创 二分查找 c语言实现
额,都不知道类别应该选择成神马才合适。#includeint binary(int *arr, int size, int searchValue);int main(){// int arr[] = { 2 5 8 9 12 56 87 99 };e, nothing to say...int arr[] = { 2, 5, 8, 9, 12, 5
2012-08-15 16:32:40
742
原创 归并排序 c语言实现
好吧,跟 http://blog.youkuaiyun.com/morewindows/article/details/6678165 差不多是一样的。。#define ARR_SIZE 30#include #include #include void mergeSort(int *arr, int first, int last, int *temp);
2012-07-19 18:16:13
466
原创 hash表 c语言实现
简单的hash表实现采用chaining法。#define DIVIDOR 23#define ELE_NUM 100#includetypedef struct t_node{ int value; struct t_node *next;} Node;void build_table(Node **table, i
2012-07-19 18:10:12
665
转载 ubuntu11.04 sis显卡 分辨率问题
感谢http://ubuntuforums.org/showthread.php?t=958967&page=38http://hi.baidu.com/tianhenlanfeng/blog/item/8dd8e819fb8742038718bfda.html
2012-02-13 23:19:22
374
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人