The Art Of Computer Programming: 1.1Table of Contents1. Algorithm1 Algorithm1.1 算法的特性算法除了是一套有限的规则 (Being a finite set of rules) 之外,还有如下的五个特性:有限性 (Finiteness) :需要在有限的步骤内收敛结束。可定义性 (Definieness) :算法中的每一步... Read More
posted @ 2014-08-28 15:13 英超 Views(231) Comments(0) Diggs(0) Edit
Below is a snapshot of the Web page as it appeared on 8/12/2014. This is the version of the page that was used for ranking your search results. The pa... Read More
posted @ 2014-08-13 11:45 英超 Views(165) Comments(0) Diggs(0) Edit
How to detect whether socket is still connected…From wget source code…booltest_socket_open (int sock){ fd_set check_set; struct timeval to; int ret = 0; /* Check if we still have a valid (non-EOF)... Read More
posted @ 2014-07-19 22:07 英超 Views(348) Comments(0) Diggs(0) Edit
Table of Contents1. 准备工作:2. Saucy Salamander3. 刷入 最新 版Touch最近手里的 Nexus 4 手机一直闲置,它的配置要比我六年前买的笔记本还好,于是就动起了向里面刷个 Ubuntu Touch 的想法。1 准备工作:安装 Adb tools, go... Read More
posted @ 2014-07-14 08:19 英超 Views(1422) Comments(0) Diggs(0) Edit
LanguageTagTable of Contents1. The Language TagThis is a memo of RFC 5646, ie BCP-47.1 The Language TagLanguage tags are used to help identify languages, whether spoken,written, signed, or otherwise s... Read More
posted @ 2014-06-18 13:29 英超 Views(603) Comments(0) Diggs(0) Edit
private static native void printString(String text); ... void examplePrintString() { String str = "A" + "\u00ea" + "\u00f1" + "\u00fc" + "C"; System.out.println("String = " + str); p... Read More
posted @ 2014-01-20 18:10 英超 Views(256) Comments(0) Diggs(0) Edit
Table of Contents1. Introduction2. Use tmget in gentoo3. About MTU1 IntroductionMulityGet to speed up downloading from server.It provides a library named libmget and a sample app named tmget.You can download it from: here .2 Use tmget in gentooYou can set tmget to be used to fetch resources from int Read More
posted @ 2013-12-26 21:57 英超 Views(217) Comments(0) Diggs(0) Edit
Last week, I tried to use Valgrind to identify potential memory related bugs, since segmentation faults occured randomly in a Python C library. However... Read More
posted @ 2013-12-20 13:24 英超 Views(1532) Comments(0) Diggs(0) Edit
vector 测试 写个简单的东西来测试一下数据很多时候几种创建 vector 的方法,结果有点意思: #include #include #include using namespace std; typedef unsigned int uint32; struct Obj { Obj(int a1, int b1, int c1) ... Read More
posted @ 2013-12-13 20:24 英超 Views(425) Comments(0) Diggs(0) Edit
abc (转载请注明出处,使用许可:署名-非商业性使用-相同方式共享 3.0 中国大陆许可协议 。) Read More
posted @ 2013-12-10 13:39 英超 Views(165) Comments(0) Diggs(0) Edit
Effective STL 43: Prefer algorithm calls to hand-written loops Suppose you have a Widget class that supports redrawing: class Widget { public: Widget(); virtual ~Widget()... Read More
posted @ 2013-11-25 21:07 英超 Views(241) Comments(0) Diggs(0) Edit
test.c #include #include #include #include #include #include #include void dump_line(const unsigned char* buf, int w, int l) { #define YYYGET(X) ( X >= 32 && X 1 ? ... Read More
posted @ 2013-11-22 22:37 英超 Views(287) Comments(0) Diggs(0) Edit
Hex Dump In Many Programming Languages See also: ArraySumInManyProgrammingLanguages, CounterInManyProgrammingLanguages, DotProductInManyProgrammingLanguages, WardNumberInManyProgrammingLanguages, ... Read More
posted @ 2013-11-22 22:35 英超 Views(707) Comments(0) Diggs(0) Edit
Effective STL 学习笔记 39 ~ 41 Table of Contents Make Predicate pure Function Make Functor classes adaptable ptr_fun, mem_fun and mem_fun_ref 1 Make Predicate pure Function 纯函数... Read More
posted @ 2013-11-21 12:45 英超 Views(353) Comments(0) Diggs(0) Edit
Http PipeLining Table of Contents Pipeline and Persistent Connection — From rfc2616 Http Pipeline and libCurl 1 Pipeline and Persistent Connection — From rfc2616 1.1 Pipeli... Read More
posted @ 2013-11-20 12:16 英超 Views(714) Comments(0) Diggs(0) Edit
Effective STL 学习笔记 Item 38 : Design functor classes for pass-by-value 严格来讲, C 和 C++ 都不支持将函数作为参数,真正作为参数的,实际上是 pass-by-value 的函数指针, 作为函数指针的模拟, Functor 作为参数时候也是按值传递的,有些 STL 的实现中,将 Funct... Read More
posted @ 2013-11-19 20:50 英超 Views(5810) Comments(0) Diggs(0) Edit
Effective STL 学习笔记 Item 34: 了解哪些算法希望输入有序数据 有些个算法对有序的和无序的数据都能应用,但多数情况下,他们在输入数据有序时才最有用。 下列算法要求输入数据必须有序: binary_search, upper_bound, lower_bound, equal_range 这些算法均使用了二分查找 (binar... Read More
posted @ 2013-11-15 22:10 英超 Views(311) Comments(0) Diggs(0) Edit
Effective STL 学习笔记 32 ~ 33 Table of Contents 记得 Remove 后要 Erase remove, container, pointer 1 记得 Remove 后要 Erase Item 9 中已经提到过,如果真的想要用 remove 从容器中删除元素,必须要在 remove 之后使用 erase... Read More
posted @ 2013-11-15 21:24 英超 Views(200) Comments(0) Diggs(0) Edit
Effective STL 学习笔记 31:排序算法 Table of Contents partial_sort nth_element stability partition 总结 1 partial_sort partial sort 可以进行部分排序,例如,仅 按顺序排出 某个容器中的前 20 名: bool quality... Read More
posted @ 2013-11-15 21:16 英超 Views(338) Comments(0) Diggs(0) Edit
编程六月定律 ... Read More
posted @ 2013-11-12 09:31 英超 Views(218) Comments(0) Diggs(0) Edit
Emacs 启动优化二三事 Table of Contents 启动(加载)时间检测 autoload and eval-after-load backtrace function and advice 这两天一直在折腾 Emacs 的配置文件以优化启动时间,这里做个简单的总结。 1 启动(加载)时间检测 检测配置文件的加载时间非常简单,... Read More
posted @ 2013-11-11 22:45 英超 Views(3497) Comments(0) Diggs(0) Edit
... Read More
posted @ 2013-11-08 10:23 英超 Views(611) Comments(0) Diggs(0) Edit
Effective STL 学习笔记 Item 30: 保证目标区间足够大 Table of Contents 1. 容器区间与算法 2. back_inserter 3. front_inserter 4. inserter 5. inserter & reserve 1 容器区间与算法 STL 容器吸引人的地方之一在于它能够自动管理内存,... Read More
posted @ 2013-11-07 10:20 英超 Views(284) Comments(0) Diggs(0) Edit
Effective STL 学习笔记 Item 26: Prefer Iterator to reverse_iterator and const_rever_itertor Table of Contents 1. Iterator 的类型 2. 迭代器之间的转换 3. Iterator is Special 4. 总结: 1 Iterator... Read More
posted @ 2013-11-05 22:08 英超 Views(373) Comments(0) Diggs(0) Edit
Effective API Design Table of Contents 1. Foreword 2. Process of API Design 3. General Principles 4. Classes Deisgn 5. Method Design 6. Exceptions Design 7. Refactoring API Design ... Read More
posted @ 2013-11-05 18:53 英超 Views(327) Comments(0) Diggs(0) Edit
Effective STL 学习笔记: Item 22 ~ 24 Table of Contents 1. 避免 \(set \& multiset\) 在原位改变 Key 2. Consider replacing associative containers with sorted vectors 3. Choose carefully betwe... Read More
posted @ 2013-11-05 10:57 英超 Views(257) Comments(0) Diggs(0) Edit
Effective STL 学习笔记 Item 21:Comparison Function 相关 Table of Contents 1. Always have comparison functions return false for equal values 2. Strict Weak Ordering 1 Always have c... Read More
posted @ 2013-11-04 18:21 英超 Views(401) Comments(0) Diggs(0) Edit
Effective STL 学习笔记:19 ~ 20 Table of Contents 1. Item 19: 相等 (Equality) 与等价 (Equivalence) 2. Item 20: Specify Comparison Type for Associative containers of pointers 1 Item 19... Read More
posted @ 2013-11-04 13:55 英超 Views(408) Comments(0) Diggs(0) Edit
vector 看起来像是一个存放布尔变量的容器,但是其实本身其实并不是一个容器,它里面存放的对象也不是布尔变量,这一点在 GCC 源码中 vector 的注释中写的很清楚:/** * @brief A specialization of vector for booleans which offers fixed time * access to individual elements in any order. * * Note that vector does not actually meet the requirements for being * a container. ... Read More
posted @ 2013-11-04 11:14 英超 Views(305) Comments(0) Diggs(0) Edit
重装完 KDE 后发现在 dolphin 中无法挂载 U 盘了,提示 unable to authenticate。但是用 udisksctl 却可以挂载:yyc@TDesk run > udisksctl mount -b /dev/sdc1==== AUTHENTICATING FOR org.freedesktop.udisks2.filesystem-mount-other-seat ===挂载 Generic Mass-Storage (/dev/sdc1) 需要身份验证Authenticating as: rootpassword:==== AUTHENTICATION CO Read More
posted @ 2013-11-01 22:16 英超 Views(665) Comments(0) Diggs(0) Edit
假设有若干对象存于一个 vector 中:class Widget;vector vw;后来由于某些原因,从该容器中删除了若干对象(参考erase-remove idiom )。对于 vector 和 string 来讲, erase() 和 clear() 并不会改变容器的capacity,也就不会改变他们的内存占用。swap() 本意是用来交换两个容器的内容( Iterators, pointers, and references),但我们可以用他来快速将容器的 capacity 调整为 合适 的大小:vector(vw).swap(vw);巧妙之处在于, vector 的拷贝构造函数仅仅 Read More
posted @ 2013-11-01 18:27 英超 Views(1039) Comments(0) Diggs(0) Edit
有时需要支持 C 的接口,但这并不复杂。对于 vector 来讲, \(v[0]\) 的地址 \(\&v[0]\) 即可作为数组指针传递给 C API: 1: // Legacy C API. 2: extern void doSomething(const int* pInts, size_t numInts); 3: 4: vector v; 5: // ... 6: // Operations on v. 7: // ... 8: 9: if (!v.empty())10: {11: doSomething(&v[0], v.size());12: }也许有人会说:可以用 Read More
posted @ 2013-11-01 15:51 英超 Views(592) Comments(0) Diggs(0) Edit
2013/11/01 | Comments大约一年前,我接触了 Java 中的 Btrace 能够不停机查看线上 JVM 运行情况的特性让我艳羡不已。 另外还有强悍的 jStack 和 jConsole 来进行运行期侦测,JVM 的工业级强度果然不是盖的。当时公司技术方面也遇到了一些瓶颈,一部分原因是 CPython 本身的 IO 模型问题, 另一方面也和早期代码写的极不工整脱不了关系。万般无奈之下,我们用 Jython 推翻重做了主要业务,效果立竿见影,但同时也把真实问题给规避掉了。在这之后我们在 JVM 的领导下,走上了康庄大道。但我心中始终还有一个梗, 就是想对性能遇到瓶颈的 Pytho Read More
posted @ 2013-11-01 10:31 英超 Views(3404) Comments(0) Diggs(0) Edit
vector 和 string 容器在动态插入一个新的对象时,如果容器内空间不够,该容器会:重新分配空间 通常的做法是分配当前 Capacity 大小两倍的空间。将旧空间中的所有元素拷贝进新的空间中。销毁原有空间中存储的对象。销毁原有的空间。可见一个简单的操作背后实际可能会有许多动作。例如如果想创建一个容器让其存放 1 ~ 1000 这 1000 个 int 值,如果用下面的方法:vector v;for (int i = 1; i v;v.reserve(1000);for (int i = 1; i 当前 capacity: 重新分配空间,改变 Capacity,但不影响 siz... Read More
posted @ 2013-10-31 12:33 英超 Views(361) Comments(0) Diggs(0) Edit
Effective STL 学习笔记: 多用 vector & string如果可能的话, 尽量避免自己去写动态分配的数组,转而使用 vector 和 string 。原书作者唯一想到的一个不用 string 的可能的理由,就是 string 所使用的引用计数 (reference counting) 在多线程下可能会因为并发控制反而导致性能下降。我们可以通过查看文档或者 STL 源面的方法来看 String 是否引入了引用计数,如果 string 在多线程下真的因为引用计数而导致了性能下降,我们可以通过下面的方法来避免:看是否可以通过某些方法来禁用引用计数,例如条件编译 该方法可移植 Read More
posted @ 2013-10-30 22:09 英超 Views(546) Comments(0) Diggs(0) Edit
Table of Contents1. STL, Thread and SGI2. STL and Lock2.1. RAII2.2. Use Lock in STL1 STL, Thread and SGIC++98 以及之前的 C++ 标准中,并未对线程做出过规定,但对于 STL 来讲,SGI 做出了自己的规定,很多其他的 STL 实现也遵循这些规定:The SGI implementation of STL is thread-safe only in the sense that simultaneous accesses to distinct containers are safe Read More
posted @ 2013-10-30 17:32 英超 Views(711) Comments(0) Diggs(0) Edit
Effective STL 笔记 – Item 6 ~ 7: Container and Object Pointer中间两次笔记被删掉了,简单补一下:Item 3 中提到如果将对象直接放入容器中,可能会引发问题:大量的拷贝行为要求对象的拷贝构造代价要小试图将派生类放入存放基类的容器中会引发 Slicing 问题。对此的简单方法就是在容器中保存对象 指针 ,但如果直接保存指针的话,我们需要自己维护和管理内存,容易混乱。最好的方法是保存 智能指针(smart pointer shared_ptr)) 。需要注意的是,这里提倡的是 shared_ptr,不是 autoptr,C++ 标准要求不能声 Read More
posted @ 2013-10-30 14:48 英超 Views(284) Comments(0) Diggs(0) Edit
How to omit h1 title heading in HTML export Introduce how to omit h1 title in the exported html. Sometimes it would be better to omit h1 title in exported HTML, and there is an ema... Read More
posted @ 2013-10-30 14:22 英超 Views(317) Comments(0) Diggs(0) Edit
Introduction to MWB Minor Mode Table of Contents 1. Introduction 2. Usage 1 Introduction MWB stands for "MetaWeblog", it is an submode for org mode and can be used to publish ... Read More
posted @ 2013-10-30 14:21 英超 Views(287) Comments(0) Diggs(0) Edit
假设有一个容器中存放着 int ,Container c, 现在想从其中删除数值 1963,可以有如下方法:1: c.erase(remove(c.begin(), c.end(), 1963), c.end()); // c is continguous memory container2: c.remove(1963); // c is list3: c.erase(1963) // c is standard associative container对于 continguous memory container 来说, std::remove() 可以保证返回的 iterator .. Read More
posted @ 2013-10-29 15:22 英超 Views(615) Comments(0) Diggs(0) Edit