12 2012 档案
C++11标准支持UTF-8编码
摘要:在新的C++标准C++11[1]中,增强了对Unicode的支持。 char被定义为能够存储UTF-8的8位编码。还增加了用于支持UTF-16和UTF-32的数据类型char16_t和char32_t。 Unicode是为了表示世界上所有语言而诞生的。任何文字在Unicode都对应一个值,称为代... 阅读全文
posted @ 2012-12-30 18:32 #hanhui 阅读(1346) 评论(0) 推荐(0)
TCP Fast Open
摘要:TFO[1]是Linux 内核3.6版本引入的新特性,相关标准由Google提出,仍旧是RFC的草案[2],非正式标准。作者是Yuchung Cheng,Google工程师,他从加州大学圣迭戈分校获得博士学位,从国立台湾大学[3](NTU,新加坡也有一个NTU[4],美国好像也有一个)获得学士学... 阅读全文
posted @ 2012-12-30 15:59 #hanhui 阅读(149) 评论(0) 推荐(0)
Analysis of the NoSQL landscape
摘要:对NoSQL的分类统计 [1] http://blog.knuthaugen.no/2010/03/the-nosql-landscape.html 阅读全文
posted @ 2012-12-30 14:05 #hanhui 阅读(89) 评论(0) 推荐(0)
A Brief History of NoSQL (转)
摘要:NoSQL的简短介绍 http://blog.knuthaugen.no/2010/03/a-brief-history-of-nosql.html 阅读全文
posted @ 2012-12-29 23:51 #hanhui 阅读(107) 评论(0) 推荐(0)
整洁代码之道 [3] - 函数,注释,和格式
摘要:函数 函数要尽可能短,缩进有一到两级,包含20行代码就是最好了。 if/else/while只占一行 一个函数只完成一件事情,这件事情要看当前函数处于什么抽象级别。要让代码拥有自顶向下的阅读顺序。 可以用多态替代switch。 函数要具有描述性的名称。长函数名称比长注释好。函数参数要少。参数多... 阅读全文
posted @ 2012-12-29 22:27 #hanhui 阅读(201) 评论(0) 推荐(0)
《敏捷软件开发 原则、模式与时间》读后感 - 敏捷设计原则
摘要:SRP: 单一职责 如果有多于一个的原因修改类的实现,则视为违反单一职责规范.问题是我们怎样未卜先知会有一些什么需求变化呢 如果将类分离为两个,那么如果需要对它们进行同步操作时,把实现放哪里呢 我想,设计模式的一个弊端就是让程序员不自觉的忽略(或弱化)了逻辑实体(类实例)之间的同步控制, 或... 阅读全文
posted @ 2012-12-29 11:08 #hanhui 阅读(185) 评论(0) 推荐(0)
Mac OSX Darwin - Notes
摘要:抓图:command + shift + 3 右键:ctr + 单击 防火墙设置(允许连接tcp端口3888):ipfw add 7000 allow tcp from any to any dst-port 3888 查看端口是否在监听:lsof -i :3888 阅读全文
posted @ 2012-12-29 11:03 #hanhui 阅读(98) 评论(0) 推荐(0)
design pattern notes [8] - interpreter, and command
摘要:Interpreter is used to parse a language, just as compiler does. Sometimes invoker of operation does not know who will process the request or how th... 阅读全文
posted @ 2012-12-29 00:41 #hanhui 阅读(78) 评论(0) 推荐(0)
POLL, SELECT & EPOLL 原理比较分析
摘要:原文出处:http://www.cnblogs.com/sharra/archive/2010/12/30/1921287.html 因为需要了解底层设备访问的原理,所以惯用高层应用语言的我,需要了解一下Linux的设备访问机制,尤其是处理一组非阻塞IO的原理方法,标准的术语好像是叫多路复用。以... 阅读全文
posted @ 2012-12-27 12:53 #hanhui 阅读(143) 评论(0) 推荐(0)
OpenSSL线程安全
摘要:OpenSSL can safely be used in multi-threaded applications provided that at least two callback functions are set, locking_function and threadid_func... 阅读全文
posted @ 2012-12-27 12:52 #hanhui 阅读(444) 评论(0) 推荐(0)
Getting Started with POSIX Threads
摘要:注: 1)记得调用pthread_join让线程退出后能释放资源(如栈空间) 2)记得调用pthread_testcancel查看线程是否已经被终止,并释放资源 3)记得调用pthread_setcancelstate防止线程被意外终止运行 原文: Getting Started wit... 阅读全文
posted @ 2012-12-27 12:50 #hanhui 阅读(93) 评论(0) 推荐(0)
linux下history命令的使用方法
摘要:摘录 !number用来执行history列表中的某一个命令,number表示列表中的数字 !!表示执行上一条命令 !ls执行最近一个以ls开始的命令 [1] http://www.9usb.net/200906/linux-history-mingling.html 阅读全文
posted @ 2012-12-25 09:47 #hanhui 阅读(146) 评论(0) 推荐(0)
完成90%的项目 [3]- 团队文化
摘要:运转流畅的项目意味着运转流畅的流程,一个团队的做事风格是由这个团队的带头人决定的。之所以这么说,是因为团队带头人每天审查团队成员的工作,判定工作是否完成,完成的质量如何,甚至最终决定团队成员的绩效,决定他/她是否能得到更好的薪酬。因此,各个团队成员是唯你带头人马首是瞻,按照你的风格开展... 阅读全文
posted @ 2012-12-24 22:32 #hanhui 阅读(97) 评论(0) 推荐(0)
design pattern notes [7] - state,strategy,memento,mediator,and iterator
摘要:State allows the object alter its behavior when its internal state changes. This pattern avoids large, multipart conditional statements. It also in... 阅读全文
posted @ 2012-12-24 20:50 #hanhui 阅读(148) 评论(0) 推荐(0)
Virtual networking in Linux
摘要:介绍Linux虚拟网络, Open vSwitch http://www.ibm.com/developerworks/linux/library/l-virtual-networking/index.html 阅读全文
posted @ 2012-12-24 13:16 #hanhui 阅读(99) 评论(0) 推荐(0)
design pattern notes [6] - Observer
摘要:Observer is also known as dependents or publish-subscribe. When the object changes its state, its dependents will be notified and updated automatic... 阅读全文
posted @ 2012-12-23 19:11 #hanhui 阅读(82) 评论(0) 推荐(0)
代码整洁之道 [2]- 命名
摘要:使用有意义的名字,名字明确了用途,不用更多注释。有时错误的注释会更坏事,即使现在正确,但随着时间的推移,注释和代码多半已经不能对应了。 别让名字掺杂有现有数据类型名字,有时会让人误解。也不要使用很难区分差别的名字。 使用有意义的名字,别使用0和O,l和1,谁看谁晕。要从名字区分出意... 阅读全文
posted @ 2012-12-23 09:51 #hanhui 阅读(109) 评论(0) 推荐(0)
代码整洁之道 [1]
摘要:是糟糕的代码毁掉了公司吗?不是代码,而是无穷无尽的需求和无法逃避的交付时间毁掉了代码和公司。停止增加新代码,代码质量才能得到提升。我们当然需要高质量代码,但那需要时间,如果只看到交付时间,最终肯定是糟糕的代码。 这里最了解问题的是程序员,他/她应该说明实情,只重眼前利益(需求+交付时间),... 阅读全文
posted @ 2012-12-23 00:01 #hanhui 阅读(75) 评论(0) 推荐(0)
MAC OSX Darwin - 设置PATH环境变量
摘要:Mac OS 设置$PATH环境变量 启动Terminal, echo 'export PATH=somepath:$PATH' >> ~/.bash_profile 打开一个新的Terminal,echo $PATH ,查看新的$PATH内容 原文:http://www.... 阅读全文
posted @ 2012-12-22 22:36 #hanhui 阅读(129) 评论(0) 推荐(0)
完成90%的项目 [2]
摘要:完成一个项目或者一个特性相关的开发工作,对于软件工程师来说就如履行一份合同或者一份契约和承诺。涉及的甲乙双方应该都对合同所涉及的工作、完成日期以及报酬达成一致意见。如果甲方(通常是客户或者是领导)将合同强加给乙方(通常是软件开发团队或者软件工程师),那么在开发工作开始之前就埋下了项目失败... 阅读全文
posted @ 2012-12-21 15:43 #hanhui 阅读(113) 评论(0) 推荐(0)
完成90%的项目
摘要:“在这个迭代周期就快封版之前,team leader Alice询问特性A是否可以按时提交版本发布,软件工程师Bob回答说已经完成90%,应该可以发布特性。”这样的场景恐怕很多软件开发人员(包括项目经理和软件工程师)都经历过。 已经完成90%的特性似乎距离发布就差百米赛跑的最... 阅读全文
posted @ 2012-12-21 00:04 #hanhui 阅读(123) 评论(0) 推荐(0)
design pattern notes [5] - template method
摘要:Template method lets abstract base class (this is the class to implement the algorithm) to implement invariant algorithm. The subclasses can redefi... 阅读全文
posted @ 2012-12-20 23:23 #hanhui 阅读(121) 评论(0) 推荐(0)
Rethinking Design Patterns - from Jeff Atwood
摘要:本文出处[1] ... It's certainly worthwhile for every programmer to read Design Patterns at least once, if only to learn the shared vocabulary of common... 阅读全文
posted @ 2012-12-19 12:10 #hanhui 阅读(131) 评论(0) 推荐(0)
Macbook Pro(Darwin)获取root权限
摘要:Mac OS 10.8买回来后,只有一个非root的管理员用户,问销售人员他们也不知道root密码。 回来网上搜了一下,终于搞定。 具体方法如下: 1)sudo su切换到root,输入的用户密码是当前用户的密码; 2)切换到root后,执行passwd root,设置root用户密码即可。 ... 阅读全文
posted @ 2012-12-16 21:07 #hanhui 阅读(163) 评论(0) 推荐(0)
敏捷不是为所有人准备的
摘要:刚刚看到一篇文章, "敏捷不是为所有人准备的",作者Johnanna, 下面简单翻译一段, ... You don’t have to change the culture on Day One. But you do have to change eventually. And s... 阅读全文
posted @ 2012-12-16 12:53 #hanhui 阅读(96) 评论(0) 推荐(0)
How main() is executed On Linux?
摘要:http://tldp.org/LDP/LGNET/84/hawk.html 阅读全文
posted @ 2012-12-15 22:18 #hanhui 阅读(106) 评论(0) 推荐(0)
智能指针:从std::auto_ptr到std::unique_ptr
摘要:std::auto_ptr封装动态申请对象内存返回的指针,并且其行为也和普通指针一样。最重要的一点,程序员不必记得去释放之前申请的内存,当std::auto_ptr销毁时,其封装的指针所指向的内存也会自动销毁。当需要处理异常时,这尤其重要,RAII技术保证异常发生后,在栈上保存的对象依次销毁释放... 阅读全文
posted @ 2012-12-15 21:38 #hanhui 阅读(155) 评论(0) 推荐(0)
Linux X86架构虚拟内存分布
摘要:在Linux系统上,c/c++ 编程语言使用的指针占用的存储空间大小为4或者8个字节(分别对应32位和64位cpu架构),因此指针所能引用的虚拟内存范围是分别是4G或者4G*4G.而事实上Linux操作系统将虚拟地址空间分成了两部分,其中的低地址部分作为用户空间,高地址部分作为内核空间. 具体来... 阅读全文
posted @ 2012-12-15 16:35 #hanhui 阅读(296) 评论(0) 推荐(0)
C++异常安全
摘要:http://www.boost.org/community/exception_safety.html 阅读全文
posted @ 2012-12-15 01:33 #hanhui 阅读(100) 评论(0) 推荐(0)
读书的牢骚
摘要:前两天买了一本关于项目管理的书, 软件管理那些事, 一直没时间看,今天下班拿上决定看看.十一章十一个作者, 很多图表和数据;我从十号线地铁西土城到国贸翻了一遍,然后决定还是看视频吧! 辜负作者了...... 临时结论:还是看经典吧 阅读全文
posted @ 2012-12-15 01:12 #hanhui 阅读(98) 评论(0) 推荐(0)
c/c++项目如何管理头文件
摘要:最近的项目一直在讨论如何管理头文件,原项目使用Visual Studio开发,源文件中对头文件的引用比较乱,有很多类似于"../../include/header.h"的头文件引用。现在要移植到类UNIX平台,头文件的引用管理问题也逐渐显露出来。 IDE的使用一方面简化了我们的开发工作,另一方面... 阅读全文
posted @ 2012-12-14 21:01 #hanhui 阅读(683) 评论(0) 推荐(0)
和我一起写lua - lua模块管理
摘要:lua有一个专门的模块管理工具, luarocks 在mac os x上试了一下,lua安装5.2,luarocks安装2.0.12(前几个2.0版本的luarocks有bug), 然后用luarocks install luafilesystem 成功 阅读全文
posted @ 2012-12-13 16:27 #hanhui 阅读(163) 评论(0) 推荐(0)
linux下如何把时间转成秒数,或把秒数转换成标准时间格式
摘要:$ date Tue Feb 3 11:29:00 CST 2009 --把时间转成秒数 $ date +%s 1233631748 --把秒数转换成标准时间格式(方法1) $ date -d '1970-1-1 0:0:0 GMT + 1233631748 seconds' Tue Feb 3... 阅读全文
posted @ 2012-12-13 10:27 #hanhui 阅读(703) 评论(0) 推荐(0)
C++ Exceptions: Pros and Cons
摘要:关于C++异常的争论 http://www.codeproject.com/Articles/38449/C-Exceptions-Pros-and-Cons 阅读全文
posted @ 2012-12-13 10:00 #hanhui 阅读(161) 评论(0) 推荐(0)
Apple: HTTP Live Streaming
摘要:介绍HTTP Live Streaming的标准课程 http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/StreamingMediaGuide/Introduction/Int... 阅读全文
posted @ 2012-12-13 09:59 #hanhui 阅读(152) 评论(0) 推荐(0)
design pattern notes [4] - chain of responsibility, visitor
摘要:chain of responsibility When one object does not know which specific object will handle its request, the chain of responsibility can be used to for... 阅读全文
posted @ 2012-12-13 09:57 #hanhui 阅读(136) 评论(0) 推荐(0)
design pattern notes [3] - factory
摘要:Factory method is virtual method to create local-specific object in the class hierarchy. The base class may or not implement it. If a parameter is ... 阅读全文
posted @ 2012-12-13 09:54 #hanhui 阅读(80) 评论(0) 推荐(0)
design pattern notes [2] - decorator, facade, Singleton, Flyweight, and Adapter
摘要:The decorator has same interfaces to component to which it enhances functions or appearance. It is also called wrapper. With this pattern, client do... 阅读全文
posted @ 2012-12-13 09:53 #hanhui 阅读(87) 评论(0) 推荐(0)
design pattern notes [1] - Bridge and composite
摘要:Bridge pathern is used to decouple abstraction and implementation so that both can involve independently. This makes it easy to modify, extend and r... 阅读全文
posted @ 2012-12-13 09:49 #hanhui 阅读(98) 评论(0) 推荐(0)
最近看的三本书
摘要:《数学之美》 看过多一半,然后放在家里让夫人看其中作者介绍其导师那一章 《软件管理沉思录》 电子版 《Design Patterns: Elements of Reusable Object-Oriented Software》,看了其中约15种模式 阅读全文
posted @ 2012-12-13 09:43 #hanhui 阅读(110) 评论(0) 推荐(0)
线程数以及虚拟内存大小的关系
摘要:之前有个小项目,具体需求是: 完成一个客户端,按照某一速度向服务器发送Radius请求,并处理服务器返回的响应. 实现方案: 采用多线程方式实现,每个线程负责发送请求,并等待服务器返回的响应. 测试发现,发送速度达到某个值时就无法增加了,日志显示内存不够,无法创建更多线程. 进而发现可以创建不... 阅读全文
posted @ 2012-12-13 09:30 #hanhui 阅读(293) 评论(0) 推荐(0)