摘要: Anybody who has interest in google's offer should read thishttp://steve-yegge.blogspot.com/2008/03/get-that-job-at-google.html 阅读全文
posted @ 2011-10-21 18:57 nosaferyao 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 一致性Hash算法(转)2010-10-08 11:40:26|分类:分布式|字号订阅consistent hashing算法早在1997年就在论文Consistent hashing and random trees中被提出,目前在cache系统中应用越来越广泛;1基本场景比如你有N个cache服务器(后面简称cache),那么如何将一个对象object映射到N个cache上呢,你很可能会采用类似下面的通用方法计算object的hash值,然后均匀的映射到到N个cache;hash(object)%N一切都运行正常,再考虑如下的两种情况;1一个cache服务器m down掉了(在实际应用中必 阅读全文
posted @ 2011-10-19 13:47 nosaferyao 阅读(225) 评论(0) 推荐(0) 编辑
摘要: 看linux下面的stl源码, 发现stl的resize和clear区别不大。当resize的目标size比当前的size要大的时候, 需要insert到末尾处, 否则就erase到目标大小。 代码为: void resize(size_type __new_size, const value_type& __x) { if (__new_size < size()) erase(begin() + __new_size, end()); else insert(end(), __new_size - size(), __x); }而clear就是一个简单的 erase(be.. 阅读全文
posted @ 2011-10-17 19:15 nosaferyao 阅读(1421) 评论(0) 推荐(0) 编辑
摘要: int swap2(int& x, int& y){ x = x + y; y = x - y; x = x - y;}这段代码相信大家都看过, 很多面试的人, 都喜欢拿出来做面试题。 和下面的标准swap比起来, 觉得有点高科技。int swap(int x, int y){ int w = x; x = y; y = w; }但其实经过性能测试, 前面在没有开 O2的情况下, 是明显输于后面的函数的。在开了O2的情况下, 差不多, 没有差异 阅读全文
posted @ 2011-08-12 10:04 nosaferyao 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 使用 ostringstream,很耗性能。原话是这么说的:t's really an implementation issue, butstd::localehas a static function that retrieves and set the 'global' locale. The global locale is defined to be used in several areas of the standard library which implies that there must be a global locale somewhere.In 阅读全文
posted @ 2011-07-29 22:14 nosaferyao 阅读(789) 评论(0) 推荐(0) 编辑
摘要: class A{ public: A(int y): x(y) {} void print() { cout<<"this is a:"<<get()<<endl; } int get() { return x; } private: int32_t x;};class B: public A{ public: B(int y):A(y){} virtual void print() { cout<<"this is b:"<<get()<<endl; } };int main(){ 阅读全文
posted @ 2011-06-10 11:38 nosaferyao 阅读(210) 评论(0) 推荐(0) 编辑
摘要: copy from http://blog.csdn.net/jiean/archive/2009/01/02/3686207.aspx今天在看APUE,这两个问题很难理解,GOOGLE一下,有篇文章总结的不错,看了一下才明白透彻了。由于用户在UNIX下经常会遇到SUID、SGID的概念,而且SUID和SGID涉及到系统安全,所以用户也比较关心这个问题。关于SUID、 SGID的问题也经常有人提问,但回答的人一般答得不够详细,加上曾经回答过两个网友的问题,还查了一些资料,决定整理成本文,以供大家参考。限于本人的水平问题,文章中如果有不当之处,请广大网友指正。第9位表示文件类型,可以为p、d、l 阅读全文
posted @ 2011-04-02 10:52 nosaferyao 阅读(1461) 评论(0) 推荐(0) 编辑
摘要: Mem: 16418660k total, 15651536k used, 767124k free, 83956k buffersSwap: 2096472k total, 612292k used, 1484180k free, 1220564k cached比如这个数据。Mem_total = mem_used + mem_freeswap_total = swap_used + swap_freebuffers 表示 IO缓存的数据cached 表示 系统缓冲的数据 阅读全文
posted @ 2011-03-30 20:46 nosaferyao 阅读(161) 评论(0) 推荐(0) 编辑
摘要: libtool的工作原理2009-03-01 11:43copy from :http://hi.baidu.com/kitandi/blog/item/bd86f6008c046a0e1d958351.htmllibtool 是一个通用库支持脚本,将使用动态库的复杂性隐藏在统一、可移植的接口中;使用libtool的标准方法,可以在不同平台上创建并调用动态库。可以认为 libtool是gcc的一个抽象,其包装了gcc(或者其他的编译器),用户无需知道细节,只要告诉libtool需要编译哪些库即可,libtool 将处理库的依赖等细节。libtool只与后缀名为lo、la为的libtool文件打 阅读全文
posted @ 2011-03-28 22:14 nosaferyao 阅读(511) 评论(0) 推荐(0) 编辑
摘要: 1, 编译时期指定的路径2, LD_LIBRARY_PATH 指定的路径3, 动态库的搜索路径是配置文件/etc/ld.so.conf指定的路径4, 动态库的搜索路径是默认搜索路径/lib5, 默认搜索路径/usr/lib 阅读全文
posted @ 2011-03-28 21:19 nosaferyao 阅读(319) 评论(0) 推荐(0) 编辑