Thriftrw

Triftrw is a general purpose, serialization-only, thrift encoding libraries written by Uber. Since there’re some thrift code generation ralated issues in my working project right now, I decide to give myself a chance to dive into this attractive library. Of course, the Go implementation. AST There are three basic interfaces in thriftrw’s ast package Node is a single element in the Thrift AST. Walker provides acccess to information about the state of the AST walker.

Operator pattern

Operators Are Software SREs. The key tenet of SRE is automating systems administration by writing software to run your software. An Operator is like an automated SRE for its applications.

Chef Sever 12

On production enviroment, chef server is recommended when you need to manage more than one machine at a time. three types: Hosted Enterprise Chef On Premises (Private) Enterprise Chef Open Source Chef There is a good tutorial about setting up chef server 12. However, there are some differences when applying to the latest chef-server release version. For our example, Enviroment: workstation: macOS Sierra 10.12.2 chef server and nodes: Vagrant based CentOS 6.

Why Modulo $1e9+7$

一直很好奇很多编程问题,比如求大数阶乘,大数的排列组合等,要求将输出结果对$ 1e9+7 $(=1000000007)取模。为什么是这样一个数呢?今天一查,网上还是有不少讨论的。总结一下有下面几个原因。

  • 首先因为$ 1e9+7 $是一个质数
  • 其次是$ 1e9+7 $对于int32来说足够大
  • 还有就是$ 1e9+7 $的平方对于int64来说也恰好不会溢出

Rejection Sampling

如何产生符合一定分布的随机变量?对于简单的随机变量,我们往往可以直接获得其概率分布函数$ F(x)=P(X\leqslant x) $。但是对于更多复杂的随机变量来说,获得其概率分布的解析表达式是不可能的。对于这种情况,要产生这样的随机变量就需要另辟蹊径。Rejection sampling就是其中最具代表性的一种。下文主要参考了Karl Sigman的notes