The Three Rules of TDD

Robert C. Martin (“Uncle Bob”) provides a concise set of rules for practicing TDD. Write production code only to pass a failing unit test. Write no more of a unit test than sufficient to fail (compilation failures are failures). Write no more production code than necessary to pass the one failing unit test. Rule #1 […] →Read more

GDI, OpenGL, WebGL and Direct3D

The main APIs we used are: drawIimage renderText GDI The Graphics Device Interface (GDI) is a legacy component of Microsoft Windows responsible for representing graphical objects and transmitting them to output devices such as monitors and printers. Windows apps use Windows API to interact with GDI, for such tasks as drawing lines and curves, rendering […] →Read more

WebRTC Congestion Control classes

Module remote_bitrate_estimator class RemoteEstimatorProxy It is used when send-side BWE is enabled: This proxy is instantiated on the receive side. It buffers a number of receive timestamps and then sends transport feedback messages back too the send side. class AimdRateControl A rate control implementation based on additive increases of bitrate when no over-use is detected […] →Read more

写作力读书笔记一

这本书是由高语罕写于1922 年,一百年之后,读起来仍有收获。 这位安徽老乡之前并未听说,网上搜索一下,竟然是这样一位高人。 第二章 如何从无到有写了一篇好文章 一 写什么:选题的七点建议 要部分的,不要全体的 微服务架构之道,不如 “微服务之道:度量驱动开发” 要具体的,不要抽象的 要是自己的经验或观察 或是自己的想象 或者自己对于所研究的学科的见解 要有吸引力 要简单明了 二 确定观点,摒弃五种偏见 point of view 作者的观察,易为师承所囿 作者的观察,易为主观见解与蔽 作者的观察,易为时代思想所囿 作者的观察,易为地方的见解所束缚 作者的观察,易为感情或客气所转移 誉之则升诸九天,毁之则堕诸必渊 爱之欲其生,恶之欲其死 三 取材:确立文章骨干 四 布局和起草 五 修饰与朗读 第三章 好文章的四要素 事实:宜写确切的事实 思想:宜有正确的思想 语言:宜用明白的语言 读者:我的文章是给谁看的 第四章 文章的戒律 戒虚伪, 戒夸大, 戒堆砌典故, 戒模仿, 戒轻薄 →Read more

回顾最小二乘法

最小二乘法的用途 最小二乘法来常常用来估计线性回归中的斜率,以作线性最小二乘拟合 linear least squares fit res = ys – (inter + slope * xs) res: 残差 ys: 因变量序列 xs: 自变量序列 inter: 截距 slope: 斜率 最好是找到合适的 inter 和 slope 使残差的绝对值最小,常见的做法是使得残差的平方和最小, 因为平方和与残差的正负值无关,并使较大的残差具有更多的权重。 ··· sum(res**2) ··· 最小二乘法说明 具体算法参见 https://en.wikipedia.org/wiki/Numerical_methods_for_linear_least_square 和 https://zh.wikipedia.org/wiki/%E6%9C%80%E5%B0%8F%E4%BA%8C%E4%B9%98%E6%B3%95 线性函数模型 Q = \sum_{i=1}^{n} \ [y_i – f(\vec{x}_i;\hat{\vec{\beta}})]^2 y = \beta_0 + \beta_1x + \varepsilon \, […] →Read more

cmake 简明手册

1. 概述 用 CMakeLists.txt 来描述构建依赖关系和构建目标, 用 cmake <options> <folder> 来生成 Makefile. 这个 <folder> 就是CMakeLists.txt 文件所在的目录. 可以通过命令行传入宏变量定义,例如 cmake -DABSL_BUILD_TESTING=ON -DABSL_USE_GOOGLETEST_HEAD=ON -DCMAKE_CXX_STANDARD=11 .. cmake –build . –target all 这个项目 https://github.com/abseil/abseil-cpp 中的 cmake 用法可作参考 2. 快速上手 cmake_minimum_required(VERSION 3.0.0) project(webrtc_primer VERSION 0.1.0) include(CTest) enable_testing() add_executable(webrtc_primer main.cpp) set(CPACK_PROJECT_NAME ${PROJECT_NAME}) set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) include(CPack) main.cpp #include <iostream> int main(int, char**) { std::cout […] →Read more

WebRTC congestion control v1

Class Responsibility Collaborators Comments TrendlineEstimator Estimate bandwidth usage as trendline TrendlineEstimatorSettings implement interface DelayIncreaseDetectorInterface DelayBasedBwe Estimate bandwidth based on delay AimdRateControl A rate control implementation based on additive increases of bitrate when no over-use is detected and multiplicative decreases when over-uses are detected. When we think the available bandwidth has changes or is unknown, we […] →Read more

用 Ninja and GN 来加速 C++构建

Ninja Ninja 原意是忍者的意思,它是一个专注于速度的小型构建工具。它是一个构建系统。 它将文件的相互依赖关系(通常是源代码和输出可执行文件)作为输入,并快速编排构建它们。 运行Ninja,默认情况下,它会在当前目录中查找名为 build.ninja 的文件并构建所有过时的目标。 您可以指定要构建的目标(文件)作为命令行参数。 还有一个特殊的语法 target^ 用于将目标指定为某个规则的第一个输出,其中包含您在命令行中输入的源(如果存在)。 例如,如果您将目标指定为 foo.c^,那么 foo.o 将被构建(假设您的构建文件中有这些目标)。 一般情况下,我们不需要手写 ninja 文件,通过 gn 或 cmake 来描述项目结构和依赖关系,再通过它们来生成 build.ninja 文件 详见Ninja 手册 – https://ninja-build.org/manual.html, Example byteorder.c #include <stdio.h> int main(int argc, char **argv) { union { short s; char c[sizeof(short)]; }un; un.s = 0x0102; if (sizeof(short) == 2) { if (un.c[0] […] →Read more

回顾贝叶斯公式

盗墓贼的抉择 假设场景为盗墓,墓中情况不明,可能有宝物(概率为1/3),也可能有机关陷阱(概率为 2/3),通过探测仪可以检测到机关陷阱,但是并不完全准确,对机械类的机关还行,对有毒的东西就难以检测出来了,检测的错误率为 1/4 那么盗墓贼通过分金定穴术,找到一个古墓,通过探测得知墓中没有机关,那么墓中其实有机关陷阱的概率有多少?如果概率小于30%,那么盗墓贼就决定准备点防护措施,冒险一试 以随机变量 X 表示墓中有机关的概率,有随机变量 Y 表示探测到机关的概率 已知: P(X=有机关) = 2/3 P(Y=没发现机关 | X=有机关) = 1/4 P(Y=发现机关 | X=没有机关) = 1/4 未知待求: P(Y=没发现机关 | X=有机关) 的概率 分析 2/3 的概率是有机关,1/4 的概率会检测错: (2/3)*(1/4) = 1/6 1/3 的概率是无机关,3/4 的概率会检测对: (1/3)*(3/4) = 1/4 所以没有发现机关的概率为 1/6 + 1/4 = 5/12, 其中X=有机关的概率是 (1/6)/(5/12) = 2/5 = 0.4 , […] →Read more

The Tiger

THE TIGER by: William Blake (威廉姆布萊克1757-1827) Tyger! Tyger! Burning bright ① In the forests of the night! What immortal hand or eye Could frame thy fearful symmetry? ② In what distant deeps or skies Burnt the fire of thine eyes? ③ On what wings dare he aspire? What the hand dare seize the fire? And […] →Read more