Skip to content

Instantly share code, notes, and snippets.

View marvin-min's full-sized avatar
🌼
I may be slow to respond.

Marvin.Min marvin-min

🌼
I may be slow to respond.
View GitHub Profile
@PavloBezpalov
PavloBezpalov / 1. ELK.install
Last active January 5, 2024 16:14
ELK Stack with Rails (Elasticsearch, Logstash, Kibana) on Ubuntu VPS
INSTALL JAVA
$ sudo apt-get update && sudo apt-get install default-jre
INSTALL ELASTIC SEARCH https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-repositories.html
$ wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
$ echo "deb https://packages.elastic.co/elasticsearch/2.x/debian stable main" | sudo tee -a /etc/apt/sources.list.d/elasticsearch-2.x.list
$ sudo apt-get update && sudo apt-get install elasticsearch
$ sudo update-rc.d elasticsearch defaults 95 10
$ sudo service elasticsearch restart
$ sudo service elasticsearch status
@chzyer
chzyer / go-concurrent-programming.md
Last active June 30, 2020 02:27
golang并发编程 - 例子解析

最近在看《Programming in Go》, 其中关于并发编程写得很不错, 受益非浅, 其中有一些例子是需要多思考才能想明白的, 所以我打算记录下来, 强化一下思路

《Programming in Go》在 Chapter 7. Concurrent Programming 里面一共用3个例子来讲述并发编程的3个模式, 第一个是 filter , 筛选出后缀名和文件大小文件列表, 还算简单就不说, 然后第二个是升级版, 正则版 filter , 不同的是他是根据正则搜索出文件的文本并且列出来. 这个例子我起初看是有点蒙的, 这样写是没错, 但是为什么要这样写, 他的设计思路是什么, 和其他方法相比他有什么优势, 这些都不清楚, 于是决定好好分析一下. 实际上这个例子实现的功能并不复杂, 所以我的文章实际上是在讨论怎么产生出和作者相似的思路.

如果不考虑用 goroutine 的话, 思路其实很简单:

1. 列出文件列表, 编译正则.
2. 遍历文件, 打开并遍历每行, 如果正则能匹配, 记录下来.
3. 列出来.