> 一份2021年03月03日的信息流提炼 ### 每天学点Golang #### 为什么需要使用Interfaces 原文:[Go Pointers: Why I Use Interfaces (in Go)](https://medium.com/@kent.rancourt/go-pointers-why-i-use-interfaces-in-go-338ae0bdc9e4) 在任何语言中使用接口(方法或行为的集合)实际上是在功能和功能调用者之间建立了一层薄抽象。 通过创建接口,调用代码不需要了解它所调用的函数的底层实现细节。这一点极为重要,因为它促进了组件之间的干净分离。 ```go package widgets import uuid "github.com/satori/go.uuid" // Widget 对外暴露 type Widget interface { // ID returns a widget's unique identifier ID() string } // widget 对外隐藏,确保是利用NewWidget()进行实例化 // Go的文档生成工具godoc不会为未导出的函数、类型等生成文档。如果没有写接口,文档会覆盖不到ID()的使用。 type widget struct { id string } // NewWidget() returns a new Widget 类构造函数 func NewWidget() Widget { return widget{ id: uuid.NewV4().String(), } } func (w widget) ID() string { return w.id } ``` ### 每天学点bash #### 优雅的Bash条件 原文:[Elegant Bash Conditionals](https://news.ycombinator.com/item?id=26314489) 文章引起了HN的很多讨论...逻辑简洁or代码简洁? ##### [ vs [[ `[`是一个可执行文件, 用`man [` 可以查看会发现,其实是`test`的别名。 `[[`是一个 "条件构造",所以`[a > b]`和`[[a > b]]`有很大的不同。 ```bash $ type -a [ [ is a shell builtin [ is /usr/bin/[ $ type -a [[ [[ is a shell keyword ``` ##### If-else是类C语言习惯,cmd || other 则是像Perl或Ruby `cmd && { ...; }` instead of `if cmd; then ...; fi` and `cmd || { ...; }` instead of `if ! cmd; then ...; fi` #### Bash相关 - Bash脚本模版:[xwmx/bash-boilerplate](https://github.com/xwmx/bash-boilerplate/blob/master/bash-simple-plus) - Bash单元测试框架: [pgrange/bash_unit](https://github.com/pgrange/bash_unit) ### 每天学点AI #### 基础学习模型 原文:[A Summary of the Basic Machine Learning Models](https://towardsdatascience.com/a-summary-of-the-basic-machine-learning-models-e0a65627ecbe) - **线性回归**:回归算法。将特征向量(我们数据的变量或特征)作为输入,并给出一个数值化的连续输出。是一种参数化的机器学习模型。 - **逻辑回归**: 分类算法。一个输入的特征向量给出一个类标签。 - 应用:根据某个病人的医疗记录来预测他是否有病的算法。 - **决策树**: 非常通用的机器学习模型,可用于回归和分类。构建元素是分支和节点,在每一个节点上,数据的一个特征都会被评估。 - **随机森林**(集成学习): 非参数模型,可用于回归和分类。随机森林在方程中引入了随机性和数字,解决了很多单个决策树的问题,比如过度拟合和预测能力差。 - **提升算法**(集成学习): 随机森林中,所有的树可以并行建立,在提升算法中,每棵树都是按顺序建立的,从前一棵树中获取信息。树4取决于树3是什么样子的 树3取决于树2,以此类推。这个系列的模型如LightGBM、AdaBoost或XGBoost,以及之前讨论过的随机森林可能是机器学习/数据科学行业面对普通表格数据时使用最多的方法。 - **支持向量机**(Support vector Machines / SVMs): 应用广泛的机器学习模型家族,可以解决很多ML问题,比如线性或非线性分类、回归,甚至是离群值检测。 #### 算法选择 ##### 如何进行ML算法的选择 原文:[Which machine learning algorithm should I use?](https://blogs.sas.com/content/subconsciousmusings/2020/12/09/machine-learning-algorithm-use/) - 无监督学习: 降维, 聚类 - 监督学习: 分类, 回归 ![img](https://blogs.sas.com/content/subconsciousmusings/files/2017/04/machine-learning-cheet-sheet-2.png) ##### 机器学习算法小抄(scikit-learn) 原文:[Machine Learning Cheat Sheet (for scikit-learn)](https://peekaboo-vision.blogspot.com/2013/01/machine-learning-cheat-sheet-for-scikit.html) ![img](https://1.bp.blogspot.com/-ME24ePzpzIM/UQLWTwurfXI/AAAAAAAAANw/W3EETIroA80/s1600/drop_shadows_background.png) ### 其他值得阅读 - 世界MOOC清单一览 [Massive List of MOOC Providers Around The World](https://www.classcentral.com/report/mooc-providers-list/) - 2021版,600+谷歌免费学业证书&徽章 [[2021] 600+ Google Free Certificates and Badges](https://www.classcentral.com/report/google-free-certificates/?) - Creative Certification Exam - 305小时以上的免费Linkedin课程(免费证书有)[350+ Hours of Free LinkedIn Learning Courses with Free Certification](https://www.classcentral.com/report/linkedin-learning-free-learning-paths/) - 韩语形容词总结 [Korean Adjectives pdf](https://s3.amazonaws.com/cdn.innovativelanguage.com/sns/em/2021/Landing+Pages/FGOM/march/+adjectives_korean.pdf) - 切换至Arch Linux | 工具集 [Switching to Arch Linux](https://dev.to/mauro_codes/switching-to-arch-linux-1hm) - [i3 Window Manager](https://i3wm.org/) - [Feh](https://github.com/derf/feh) | image viewer - [Polybar](https://github.com/polybar/polybar) | custom status bar for i3 window manager - [Flameshot](https://github.com/flameshot-org/flameshot) | snipping - [Vysor](https://github.com/koush/vysor.io) | mobile develop (phone screen cast) - [Spotify-TUI](https://github.com/Rigellute/spotify-tui) | Spotify - Figma-Linux, Docker, VSCode, Typora ### 今日收获 - mysql因为没有`ROW_NUMBERS`方法,只能设置`@row_num:=`类似的变量来进行模拟. [mysqltutorial](https://www.mysqltutorial.org/mysql-row_number/) - [caddyserver/caddy](caddyserver/caddy) 自动更新HTTPS的web server。 - 记得之前在Awwwards的年度网站上有看到这个3D风格的网站,没想到有开源。 [demo](https://bruno-simon.com/) github: [brunosimon/folio-2019](https://github.com/brunosimon/folio-2019) - 对于CTO来说,有**远见**与会**沟通**至关重要。**tell the story about why it matters**。[Quora](https://www.quora.com/Is-it-required-to-be-a-developer-coder-to-become-a-CTO-Why-cant-an-architect-become-a-CTO) ### 附录:snippets - Bash ```bash # Download the binary wget --quiet --output-document /usr/local/bin/mybinary "$download_url" || { error 'Failed downloading the CLI' exit 1 } # check file test -f "FILE" && source "$_" || echo "$_ does not exist" >&2 ```