Home

gtest在mac上链接的问题

gtest鉴于google自己的风格,不提供make install,直接make完之后配置路径链接就行,在linux上这样是ok的: g++ -I$GTEST_DIR/include -I$GTEST_DIR -c $GTEST_DIR/src/gtest-all.cc g++ -I$GTEST_DIR/include -I$GTEST_DIR -c $GTEST_DIR/src/gtest_main.cc ar -rv libgtest.a gtest-all.o ar -rv libgtest_main.a gtest_main.o c++ -g -Wall -Wextra -pthread -isystem $GTEST_DIR/include -c -o R...

Read more

区分下shell和makefile中的特殊字符

主要是在Makefile中看到了这种字符($@),不理解含义,查阅了一下,跟shell中意义不一样: $@ -is the name of the target currently being processed. $< -is the name of the first dependency. 顺便提下shell下的 $# Stores the number of command-line arguments that were passed to the shell program. $? Stores the exit value of the last command that was executed. $0 Sto...

Read more

gcc命令行参数总结

总结一下混乱的GCC命令行参数,帮助写Makefile: 编译阶段 预编译E->生成汇编S(ccl)->生成机器码c(as)->链接生成目标程序(ld) 输出类型: -E 只执行到预编译 -S 只执行到汇编阶段。生成汇编代码。 -c 只执行到编译。输出目标文件。 空。生成链接目标代码。 -o 指定输出文件名。 输入类型: 每个阶段可以接受之前阶段的中间结果(可跨越)。比如: gcc -E hello.c -o hello.i gcc -S hel...

Read more

Python Configuration Inheritance

While refactoring a project, I met with a situation that one configuration extends another configuration, like this: ConfigA = {"a":xx, "b":xx} ConfigB extends ConfigA + {"a":yy, c:"yy"} Code before refactor treats configA and configB separately. So after a few code iterations you will find configA has something same with configB. So I change...

Read more

About random shuffle in cplusplus

Actually I just want to memorize the usage of STL function random_shuffle. It takes two or threes arguments, the begin iterator, end iterator and a generator. What makes it interesting is the optional third parameter. Random_shuffle will pass the index to generator and takes the output as index to place current element while shuffling. Here is a...

Read more

我的治牙经历

2015.1.12,生日,去做了第一轮刮治的第一次治疗。痛不欲生啊。 11月的时候查出来牙周有问题,其实很早就觉得不好了,洗牙之前没去看。洗牙的时候拍了牙片,槽骨吸收的很厉害了。中间又拖了两个月,一个是忙,一个是没挂上号,终于上周去北大口腔挂了号。医生说很严重,侵袭性牙周炎,牙周袋太深,可能还是得手术。 今天第一次刮治。感慨牙这个东西,不意识到的时候不会觉得他的重要,上周探完牙周袋深度就疼了一个周,这次更是痛不欲生的感觉,打了麻药还是这样。而且奇怪的是手刮并不怎么疼,疼的还是超声洗牙石的部分。唯一的安慰是大夫态度都不错。牙科的大夫mm居多,虽然带着口罩都看不清楚长相… 以前还是不重视啊。家庭上也整体不重视。中国还是有很多落后的地方,理念上这么多年都没有更新过来。联想到公务员热和中...

Read more

在命令行使用Shadowsocks翻墙

拜GFW所赐,连tm boot2docker都连接不上了。好在有shadowsocks的服务,可以转成http proxy给命令行使用。 首先安装privoxy。Linux下直接apt-get install privoxy,然后编辑配置文件(etc/privoxy/config): forward-socks5 / 127.0.0.1:1080 . listen-address localhost:8118 #local network do not use proxy forward 192.168.*.*/ . forward 10.*.*.*/ . forward 1...

Read more

Java 中相等的比较

遇到如下一个问题,java中使用复杂类型做Hashkey的时候,构造另一个值相同的对象作为key无法获取map的value。原因其实是java的==判断的依据是两个引用是否指向了同一个对象。实际调用了hashCode函数。内置对象的逻辑相等比较需要使用equals,比如String。而对于非内置对象,equals也同样调用了hashCode来判断相等。 所以对于需要逻辑相等判断的对象,需要override两个函数,比如如下一个getkey的类定义了如何从Map中根据path和type得到一个唯一的对象: class ZkEventKey { EventType type = null; String path = null; ZkEventKey(EventType...

Read more