可能不是最优的选择,但是值得一试,如果事实证明可行,我也不想再去调研更多的方案了。毕竟人都是懒惰的。下面介绍,如何利用 Hugo 和 Github Actions 来搭建一个博客。
1. Hugo
Hugo 是一个 Go 语言实现的静态页面生成器,同类产品很多,还有 Jekyll、Hexo 等。选此款有几个原因,一个是在 Github 上的 Star 数量比较多,社区活跃,年头也很长了,比较成熟稳定。另外,学习 Go 语言也一直以来是我的一个计划。当然,这类生成器模式的博客,原理都大同小异,选哪个其实也都无所谓。其实单就个人喜好来说,我见过的几款 Hexo 的皮肤,更符合我的口味一点,而 Hugo 的皮肤往往都不如 Hexo 好看,原因可能是,Hexo 是前端程序员这个群体的制作的产品。
此类生成器,大多是采用某种结构化或者半结构化语言,比如 Markdown,撰写博客的内容,然后用生成器,将其转化为 HTML 静态页面,根据 theme 主题,组织成一个博客网站,然后发布到托管服务器上,供整个互联网查看。
场景是这样的,我开发了一款 App,是公司的办公网站 OA 的配套 App,通过 App 可以访问公司的办公环境。一般来说,我们的办公系统,是不需要客户端证书的,因为没有涉及到核心业务。不过我们给大家提供了一个很好的特性,就是使用 OA 系统统一登录去访问其他公司的内部网站,也就是常说的 SSO。而 OA 客户端 App 作为配套 App,自然带有将客户端身份转换为网页登录态的机制。所以,用 OA App 就可以免登录访问公司的业务网站。
在电脑上,这种 OAuth 授权是非常流畅的,因为 OA 的登录功能,只是代替了用户名密码这个输入环节,遇到需要使用客户端验证的业务网站,浏览器自然会提供相应的证书。
Backtracking is a general algorithm for finding all (or some) solutions to some computationalproblems, notably constraint satisfaction problems, that incrementally builds candidates to the solutions, and abandons a candidate (“backtracks”) as soon as it determines that the candidate cannot possibly be completed to a valid solution.
Depth-first search (DFS) is an algorithm for traversing or searching tree or graph data structures. The algorithm starts at the root node (selecting some arbitrary node as the root node in the case of a graph) and explores as far as possible along each branch before backtracking.
For me, the difference between backtracking and DFS is that backtracking handles an implicit tree and DFS deals with an explicit one. This seems trivial, but it means a lot. When the search space of a problem is visited by backtracking, the implicit tree gets traversed and pruned in the middle of it. Yet for DFS, the tree/graph it deals with is explicitly constructed and unacceptable cases have already been thrown, i.e. pruned, away before any search is done.
So, backtracking is DFS for implicit tree, while DFS is backtracking without pruning.
比如,使用回溯法常见的一类问题就是排列组合问题。例如经典的,使用 n 对括号,能排列出多少种合法的括号串(括号必须配对)。这是经典的需要回溯法解决的问题,你能把这个问题想象成图么?不管如何,如果你能把这个问题写成一个递归函数来解决,至少在递归深入到下一层和回来的过程,都绘制成节点和边的话,这个可视化出来的东西,就是一棵树(树是图的特例)。