Strong types for strong interfaces
How to add a type wrapper for built-in types.
Besides using phantom template parameter to avoid alias, one can also use private inheritance:
1 | class NamedType |
Passing strong types by reference – First attempt
This post is the sequal of the above post.
The main problem the post tryies to solve is: how to make copy of NamedType
values cheap.
However, I am conservative on using reference-wrapper as the solution, because doing this has to expose the lifetime of the wrapped object to public; after all, reference-wrapper is only a point per se.
ydiff 是基于 CLI 的一个 diff tool,支持 side-by-side 模式
前段时间在 surface 上 pip 安装后发现不能使用,直接提示找不到 SIGPIPE
;看来这玩意儿压根没考虑过支持 Windows。
前段时间部门技术老板要求每个组统计每个研发同学在某个版本的千行 bug 率,所以第一步就要能够统计某个人在某个指定分支的提交信息。
这个很容易做,利用
1 | git log d313a36e199^..HEAD --shortstat --author="Kingsley Chen" |
CppCon 2015: Fedor Pikus “The Unexceptional Exceptions”
Handling exceptions is just as to handle errors using error code, exception is just a tool.
The key point is to maintain the program state in a well defiend state.
Turn error handling into resource management and use RAII to automate it; use explicit try…catch only when absolute necessary.
Bonus tip: avoid uses of pthread_cancel
.
Pros and cons of functional programming
Pure function: avoid shared state; immutable structures; function composition.
Declarative: instead of answers the question ‘how to do’ in imperative style, it answers the question ‘what to do’; imperative relies on instructions while declarative relies more on expressions.
Cons of FP: not suitable for graph algorithms; major shift on mind patterns.
Understanding Shell Script’s idiom: 2>&1
General usage:
1 | cat foo.txt > result.log 2>&1 |
a > b
is a shortcut for a 1> b
and 1 here is fd value for stdout&fd
to reference a fd value2>&1
would redirect stderr to stdout, and 1>&2
would do the opposite.前段时间分别在 Linux 和 Windows 下实现了一个简单的 TCP 网络框架之后,感觉一些必要的坑都踩的差不多了,可以开始动手写一个真正的跨平台的 TCP 网络框架了。
于是就有了这个新坑:ezio。
ezio 这个名字是某天跑步的时候突然想到的,有几重含义:
ezio 的目标是:提供同时支持 Linux 和 Windows 的轻量型非阻塞且具备扩展性(non-blocking and scalable)的 TCP 网络框架;针对 Linux 做性能侧优化,针对 Windows 做一致性开发体验的优化。
这个目标初看起来有点怪异,但是确实非常实际的做法。
因为 Linux 和 Windows 在网络编程上存在根本的范式差异性,所以为了提供一致的对外接口,必须要有所侧重和牺牲。Linux 目前占据了绝大多数互联网产品服务器系统的份额,而 Windows 则提供了可以说是当前最好的开发环境。
ezio 这个设计目标可以使得绝大多数业务逻辑在 Windows 上开发,然后在 Linux 上进行最后的部署。
Macro ENSURE()
from KBase can ‘capture’ variables by outputing their content to the internal stringtream, provided the type of captured variables has overloaded operator<<()
.