Merge pull request #7 from LCTT/master

Update from LCTT
This commit is contained in:
heguangzhi 2020-02-24 21:45:00 +08:00 committed by GitHub
commit 288f46efa9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 2350 additions and 854 deletions

View File

@ -1,22 +1,24 @@
[#]: collector: (lujun9972)
[#]: translator: (lujun9972)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (#:acid 'words: Handle Chromium & Firefox sessions with org-mode)
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-11926-1.html)
[#]: subject: (Handle Chromium & Firefox sessions with org-mode)
[#]: via: (https://acidwords.com/posts/2019-12-04-handle-chromium-and-firefox-sessions-with-org-mode.html)
[#]: author: (Sanel Z https://acidwords.com/)
Handle Chromium & Firefox sessions with org-mode
通过 Org 模式管理 Chromium 和 Firefox 会话
======
I was big fan of [Session Manager][1], small addon for Chrome and Chromium that will save all open tabs, assign the name to session and, when is needed, restore it.
![](https://img.linux.net.cn/data/attachment/album/202002/24/113047w8jtoh2o5j085750.jpg)
Very useful, especially if you are like me, switching between multiple "mind sessions" during the day - research, development or maybe news reading. Or simply, you'd like to remember workflow (and tabs) you had few days ago.
我是[会话管理器][1]的铁粉,它是 Chrome 和 Chromium 的小插件,可以保存所有打开的选项卡,为会话命名,并在需要时恢复会话。
After I decided to ditch all extensions from Chromium except [uBlock Origin][2], it was time to look for alternative. My main goal was it to be browser agnostic and session links had to be stored in text file, so I can enjoy all the goodies of plain text file. What would be better for that than good old [org-mode][3] ;)
它非常有用,特别是如果你像我一样,白天的时候需要在多个“思维活动”之间切换——研究、开发或者阅读新闻。或者你只是单纯地希望记住几天前的工作流(和选项卡)。
Long time ago I found this trick: [Get the currently open tabs in Google Chrome via the command line][4] and with some elisp sugar and coffee, here is the code:
在我决定放弃 chromium 上除了 [uBlock Origin][2] 之外的所有扩展后,就必须寻找一些替代品了。我的主要目标是使之与浏览器无关,同时会话链接必须保存在文本文件中,这样我就可以享受所有纯文本的好处了。还有什么比 [org 模式][3]更好呢 ;)
很久以前我就发现了这个小诀窍:[通过命令行获取当前在谷歌 Chrome 中打开的标签][4] 再加上些 elisp 代码:
```
(require 'cl-lib)
@ -57,9 +59,9 @@ Make sure to put cursor on date heading that contains list of urls."
(forward-line 1)))))
```
So, how does it work?
那么,它的工作原理是什么呢?
Evaluate above code, open new org-mode file and call `M-x save-chromium-session`. It will create something like this:
运行上述代码,打开一个新 org 模式文件并调用 `M-x save-chromium-session`。它会创建类似这样的东西:
```
* [2019-12-04 12:14:02]
@ -68,9 +70,9 @@ Evaluate above code, open new org-mode file and call `M-x save-chromium-session`
- https://news.ycombinator.com
```
or whatever urls are running in Chromium instance. To restore it back, put cursor on desired date and run `M-x restore-chromium-session`. All tabs should be back.
也就是任何在 chromium 实例中运行着的 URL。要还原的话则将光标置于所需日期上然后运行 `M-x restore-chromium-session`。所有标签都应该恢复了。
Here is how I use it, with randomly generated data for the purpose of this text:
以下是我的使用案例,其中的数据是随机生成的:
```
#+TITLE: Browser sessions
@ -88,27 +90,27 @@ Here is how I use it, with randomly generated data for the purpose of this text:
- https://news.ycombinator.com
```
Note that hack for reading Chromium session isn't perfect: `strings` will read whatever looks like string and url from binary database and sometimes that will yield small artifacts in urls. But, you can easily edit those and keep session file lean and clean.
请注意,用于读取 Chromium 会话的方法并不完美:`strings` 将从二进制数据库中读取任何类似 URL 字符串的内容,有时这将产生不完整的 URL。不过你可以很方便地地编辑它们从而保持会话文件简洁。
To actually open tabs, elisp code will use [browse-url][5] and it can be further customized to run Chromium, Firefox or any other browser with `browse-url-browser-function` variable. Make sure to read documentation for this variable.
为了真正打开标签elisp 代码中使用到了 [browse-url][5],它可以通过 `browse-url-browser-function` 变量进一步定制成运行 Chromium、Firefox 或任何其他浏览器。请务必阅读该变量的相关文档。
Don't forget to put session file in git, mercurial or svn and enjoy the fact that you will never loose your session history again :)
别忘了把会话文件放在 git、mercurial 或 svn 中,这样你就再也不会丢失会话历史记录了 :)
### What about Firefox?
### 那么 Firefox 呢?
If you are using Firefox (recent versions) and would like to pull session urls, here is how to do it.
如果你正在使用 Firefox最近的版本并且想要获取会话 URL下面是操作方法。
First, download and compile [lz4json][6], small tool that will decompress Mozilla lz4json format, where Firefox stores session data. Session data (at the time of writing this post) is stored in `$HOME/.mozilla/firefox/<unique-name>/sessionstore-backups/recovery.jsonlz4`.
首先,下载并编译 [lz4json][6],这是一个可以解压缩 Mozilla lz4json 格式的小工具Firefox 以这种格式来存储会话数据。会话数据(在撰写本文时)存储在 `$HOME/.mozilla/firefox/<unique-name>/sessionstore-backup /recovery.jsonlz4` 中。
If Firefox is not running, `recovery.jsonlz4` will not be present, but use `previous.jsonlz4` instead.
如果 Firefox 没有运行,则没有 `recovery.jsonlz4`,这种情况下用 `previous.jsonlz4` 代替。
To extract urls, try this in terminal:
要提取网址,尝试在终端运行:
```
$ lz4jsoncat recovery.jsonlz4 | grep -oP '"(http.+?)"' | sed 's/"//g' | sort | uniq
```
and update `save-chromium-session` with:
然后更新 `save-chromium-session` 为:
```
(defun save-chromium-session ()
@ -122,7 +124,7 @@ and update `save-chromium-session` with:
;; rest of the code is unchanged
```
Updating documentation strings, function name and any further refactoring is left for exercise.
更新本函数的文档字符串、函数名以及进一步的重构都留作练习。
--------------------------------------------------------------------------------
@ -131,7 +133,7 @@ via: https://acidwords.com/posts/2019-12-04-handle-chromium-and-firefox-sessions
作者:[Sanel Z][a]
选题:[lujun9972][b]
译者:[lujun9972](https://github.com/lujun9972)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -1,82 +1,80 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-11920-1.html)
[#]: subject: (Screenshot your Linux system configuration with Bash tools)
[#]: via: (https://opensource.com/article/20/1/screenfetch-neofetch)
[#]: author: (Don Watkins https://opensource.com/users/don-watkins)
使用 Bash 工具截屏 Linux 系统配置
======
使用 ScreenFetch 和 Neofetch 与其他人轻松分享 Linux 环境。
![metrics and data shown on a computer screen][1]
你可能有很多原因想要与他人分享 Linux 配置。你可能正在寻求帮助来对系统上的问题进行故障排除,或者你对所创建的环境感到非常自豪,因此想向其他开源爱好者展示
> 使用 ScreenFetch 和 Neofetch 与其他人轻松分享你的 Linux 环境。
你可以在 Bash 提示符下使用 **cat /proc/cpuinfo****lscpu** 命令获取某些信息。但是如果你想共享更多详细信息例如你的操作系统、内核、运行时间、shell 环境屏幕分辨率等那么可以选择两个很棒的工具screenFetch 和 Neofetch。
![](https://img.linux.net.cn/data/attachment/album/202002/23/124525yiiqs18ll736oro8.jpg)
### ScreenFetch
你可能有很多原因想要与他人分享你的 Linux 配置。你可能正在寻求帮助来对系统上的问题进行故障排除,或者你对所创建的环境感到非常自豪,因此想向其他开源爱好者展示。
[ScreenFetch][2] 是 Bash 命令行程序,它可以产生非常漂亮的系统配置和运行时间的截图。这是方便的与它人共享系统配置的方法。
你可以在 Bash 提示符下使用 `cat /proc/cpuinfo``lscpu` 命令获取某些信息。但是如果你想共享更多详细信息例如你的操作系统、内核、运行时间、shell 环境屏幕分辨率等那么可以选择两个很棒的工具screenFetch 和 Neofetch。
### screenFetch
[screenFetch][2] 是 Bash 命令行程序,它可以产生非常漂亮的系统配置和运行时间的截图。这是方便的与它人共享系统配置的方法。
在许多 Linux 发行版上安装 screenFetch 很简单。
在 Fedora 上,输入:
```
`$ sudo dnf install screenfetch`
$ sudo dnf install screenfetch
```
在 Ubuntu 上,输入:
```
`$ sudo apt install screenfetch`
$ sudo apt install screenfetch
```
对于其他操作系统,包括 FreeBSD、MacOS 等,请查阅 screenFetch 的 wiki [安装页面][3]。安装 screenFetch 后,它可以生成详细而彩色的截图,如下所示:
![screenFetch][4]
ScreenFetch 还提供各种命令行选项来调整你的结果。例如, **screenfetch -v** 返回详细输出,逐行显示每个选项以及上面的显示。
ScreenFetch 还提供各种命令行选项来调整你的结果。例如,`screenfetch -v` 返回详细输出,逐行显示每个选项以及上面的显示。
**screenfetch -n** 在显示系统信息时消除了操作系统图标。
`screenfetch -n` 在显示系统信息时消除了操作系统图标。
![screenfetch -n option][5]
其他选项包括 **screenfetch -N**,它去除所有输出的颜色。**screenfetch -t**,它根据终端的大小截断输出。**screenFetch -E**,它可抑制错误输出。
其他选项包括 `screenfetch -N`,它去除所有输出的颜色。`screenfetch -t`,它根据终端的大小截断输出。`screenFetch -E`,它可抑制错误输出。
请检查手册页来了解其他选项。ScreenFetch 在 GPLv3 许可证下的开源,你可以在它的 [GitHub 仓库][6]中了解有关该项目的更多信息。
请检查手册页来了解其他选项。screenFetch 在 GPLv3 许可证下的开源,你可以在它的 [GitHub 仓库][6]中了解有关该项目的更多信息。
### Neofetch
[Neofetch][7] 是创建系统信息截图的另一个工具。它是用 Bash 3.2 编写的,在 [MIT 许可证][8]下开源。
根据项目网站“Neofetch 支持近 150 种不同的操作系统。从 Linux 到 Windows一直到 Minix、AIX 和 Haiku 等更晦涩的操作系统。”
根据项目网站所述“Neofetch 支持近 150 种不同的操作系统。从 Linux 到 Windows一直到 Minix、AIX 和 Haiku 等更晦涩的操作系统。”
![Neofetch][9]
该项目维护了一个 wiki其中包含用于各种发行版和操作系统的出色的[安装文档] [10]。
该项目维护了一个 wiki其中包含用于各种发行版和操作系统的出色的[安装文档][10]。
如果你使用的是 Fedora、RHEL 或 CentOS那么可以在 Bash 提示符下使用以下命令安装 Neofetch
```
`$ sudo dnf install neofetch`
$ sudo dnf install neofetch
```
在 Ubuntu 17.10 及更高版本上,你可以使用:
```
`$ sudo apt install neofetch`
$ sudo apt install neofetch
```
首次运行时Neofetch 将 **~/.config/neofetch/config.conf** 文件写入主目录(**.config/config.conf**),它让你可以[自定义和控制] [ 11] Neofetch 输出的各个方面。例如,你可以配置 Neofetch 使用图像、ASCII 文件、你选择的壁纸或者完全不使用。config.conf 文件还让与它人分享配置变得容易。
首次运行时Neofetch 将 `~/.config/neofetch/config.conf` 文件写入主目录(`.config/config.conf`),它让你可以[自定义和控制][11] Neofetch 输出的各个方面。例如,你可以配置 Neofetch 使用图像、ASCII 文件、你选择的壁纸或者完全不使用。config.conf 文件还让与它人分享配置变得容易。
如果 Neofetch 不支持你的操作系统或不提供所需选项,请在项目的 [GitHub 仓库] [12]中打开一个问题。
如果 Neofetch 不支持你的操作系统或不提供所需选项,请在项目的 [GitHub 仓库][12]中打开一个问题。
### 总结
@ -89,7 +87,7 @@ via: https://opensource.com/article/20/1/screenfetch-neofetch
作者:[Don Watkins][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -1,13 +1,13 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-11916-1.html)
[#]: subject: (What is WireGuard? Why Linux Users Going Crazy Over it?)
[#]: via: (https://itsfoss.com/wireguard/)
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)
什么是 WireGuard为什么 Linux 用户它疯狂?
什么是 WireGuard为什么 Linux 用户它疯狂?
======
从普通的 Linux 用户到 Linux 创建者 [Linus Torvalds][1],每个人都对 WireGuard 很感兴趣。什么是 WireGuard它为何如此特别
@ -18,7 +18,6 @@
[WireGuard][3] 是一个易于配置、快速且安全的开源 [VPN][4],它利用了最新的加密技术。目的是提供一种更快、更简单、更精简的通用 VPN它可以轻松地在树莓派这类低端设备到高端服务器上部署。
[IPsec][5] 和 OpenVPN 等大多数其他解决方案是几十年前开发的。安全研究人员和内核开发人员 Jason Donenfeld 意识到它们速度慢且难以正确配置和管理。
这让他创建了一个新的开源 VPN 协议和解决方案,它更加快速、安全、易于部署和管理。
@ -31,31 +30,31 @@ WireGuard 最初是为 Linux 开发的,但现在可用于 Windows、macOS、BS
除了可以跨平台之外WireGuard 的最大优点之一就是易于部署。配置和部署 WireGuard 就像配置和使用 SSH 一样容易。
看看 [WireGuard 设置指南][7]。安装 WireGuard、生成公钥和私钥像 SSH 一样),设置防火墙规则并启动服务。现在将它和 [OpenVPN 设置指南][8]进行比较。它有太多要做的了。
看看 [WireGuard 设置指南][7]。安装 WireGuard、生成公钥和私钥像 SSH 一样),设置防火墙规则并启动服务。现在将它和 [OpenVPN 设置指南][8]进行比较——有太多要做的了。
WireGuard 的另一个好处是它有一个仅 4000 行代码的精简代码库。将它与 [OpenVPN][9](另一个流行的开源 VPN的 100,000 行代码相比。显然,调试W ireGuard 更加容易。
WireGuard 的另一个好处是它有一个仅 4000 行代码的精简代码库。将它与 [OpenVPN][9](另一个流行的开源 VPN的 100,000 行代码相比。显然,调试 WireGuard 更加容易。
不要小看它的简单。WireGuard 支持所有最新的加密技术,例如 [Noise协议框架][10]、[Curve25519][11]、[ChaCha20][12]、[Poly1305][13]、[BLAKE2][14]、[SipHash24][15]、[HKDF][16] 和安全受信任结构。
不要因其简单而小看它。WireGuard 支持所有最新的加密技术,例如 [Noise 协议框架][10]、[Curve25519][11]、[ChaCha20][12]、[Poly1305][13]、[BLAKE2][14]、[SipHash24][15]、[HKDF][16] 和安全受信任结构。
由于 WireGuard 运行在[内核空间][17],因此可以高速提供安全的网络。
这些是 WireGuard 越来越受欢迎的一些原因。Linux 创造者 Linus Torvalds 非常喜欢 WireGuard以至于将其合并到 [Linux Kernel 5.6][18] 中:
> 我能否再次声明对它的爱,并希望它能很快合并?也许代码不是完美的,但我已经忽略,与 OpenVPN 和 IPSec 的恐怖相比,这是一件艺术品。
> 我能否再次声明对它的爱,并希望它能很快合并?也许代码不是完美的,但我不在乎,与 OpenVPN 和 IPSec 的恐怖相比,这是一件艺术品。
>
> Linus Torvalds
### 如果 WireGuard 已经可用,那么将其包含在 Linux 内核中有什么大惊小怪的?
这可能会让新的 Linux 用户感到困惑。你知道可以在 Linux 上安装和配置 WireGuard VPN 服务器,但同时会看到 Linux Kernel 5.6 将包含 WireGuard 的消息。让我向您解释。
这可能会让新的 Linux 用户感到困惑。你知道可以在 Linux 上安装和配置 WireGuard VPN 服务器,但同时会看到 Linux Kernel 5.6 将包含 WireGuard 的消息。让我向您解释。
目前,你可以将 WireGuard 作为[内核模块][19]安装在 Linux 中。诸如 VLC、GIMP 等常规应用安装在 Linux 内核之上(在 [用户空间][20]中),而不是内部。
目前,你可以将 WireGuard 作为[内核模块][19]安装在 Linux 中。诸如 VLC、GIMP 等常规应用安装在 Linux 内核之上(在 [用户空间][20]中),而不是内部。
当将 WireGuard 安装为内核模块时,基本上自行修改 Linux 内核并向其添加代码。从 5.6 内核开始,你无需手动添加内核模块。默认情况下它将包含在内核中。
当将 WireGuard 安装为内核模块时,基本上需要你自行修改 Linux 内核并向其添加代码。从 5.6 内核开始,你无需手动添加内核模块。默认情况下它将包含在内核中。
在 5.6 内核中包含 WireGuard 很有可能[扩展 WireGuard 的采用,从而改变当前的 VPN 场景][21]。
**总结**
### 总结
WireGuard 之所以受欢迎是有充分理由的。诸如 [Mullvad VPN][23] 之类的一些流行的[关注隐私的 VPN][22] 已经在使用 WireGuard并且在不久的将来采用率可能还会增长。
@ -68,7 +67,7 @@ via: https://itsfoss.com/wireguard/
作者:[Abhishek Prakash][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
@ -96,4 +95,4 @@ via: https://itsfoss.com/wireguard/
[20]: http://www.linfo.org/user_space.html
[21]: https://www.zdnet.com/article/vpns-will-change-forever-with-the-arrival-of-wireguard-into-linux/
[22]: https://itsfoss.com/best-vpn-linux/
[23]: https://mullvad.net/en/
[23]: https://mullvad.net/en/

View File

@ -0,0 +1,101 @@
[#]: collector: (lujun9972)
[#]: translator: (HankChow)
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-11919-1.html)
[#]: subject: (Top hacks for the YaCy open source search engine)
[#]: via: (https://opensource.com/article/20/2/yacy-search-engine-hacks)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
使用开源搜索引擎 YaCy 的技巧
======
> 无需适应其他人的眼光,而是使用 YaCY 搜索引擎定义你想要的互联网。
![](https://img.linux.net.cn/data/attachment/album/202002/23/115822jqkdyjwzdqwdad0y.jpg)
在我以前介绍 [YaCy 入门][2]的文章中讲述过 [YaCy][3] 这个<ruby>对等<rt>peer-to-peer</rt></ruby>式的搜索引擎是如何安装和使用的。YaCy 最令人兴奋的一点就是它事实上是一个本地客户端,全球范围内的每一个 YaCy 用户都是构成整个这个分布式搜索引擎架构的一个节点,这意味着每个用户都可以掌控自己的互联网搜索体验。
Google 曾经提供过 google.com/linux 这样的主题简便方式以便快速筛选出和 Linux 相关的搜索内容,这个小功能受到了很多人的青睐,但 Google 最终还是在 2011 年的时候把它[下线][4]了。
而 YaCy 则让自定义搜索引擎变得可能。
### 自定义 YaCy
YaCy 安装好之后,只需要访问 `localhost:8090` 就可以使用了。要自定义搜索引擎,只需要点击右上角的“<ruby>管理<rt>Administration</rt></ruby>”按钮(它可能隐藏在小屏幕的菜单图标中)。
你可以在管理面板中配置 YaCy 对系统资源的使用策略,以及如何跟其它的 YaCy 客户端进行交互。
![YaCy profile selector][5]
例如,点击侧栏中的“<ruby>第一步<rt>First steps</rt></ruby>”按钮可以配置备用端口,以及设置 YaCy 对内存和硬盘的使用量;而“<ruby>监控<rt>Monitoring</rt></ruby>”面板则可以监控 YaCy 的运行状况。大多数功能都只需要在面板上点击几下就可以完成了,例如以下几个常用的功能。
### 内网搜索应用
目前市面上也有不少公司推出了[内网搜索应用][6],而 YaCy 可以免费为你提供一个。对于能够通过 HTTP、FTP、Samba 等协议访问的文件YaCy 都可以进行索引因此无论是作为私人的文件搜索还是企业内部的本地共享文件搜索YaCy 都可以实现。它可以让内部网络中的用户使用你个人的 YaCy 实例来查找共享文件,于此同时保持对内部网络以外的用户不可见。
### 网络配置
YaCy 在默认情况下就支持隐私和隔离。点击“<ruby>用例与账号<rt>Use Case & Account</rt></ruby>”页面顶部的“<ruby>网络配置<rt>Network Configuration</rt></ruby>”链接,即可进入网络配置面板设置对等网络。
![YaCy network configuration][7]
### 爬取站点
YaCy 的分布式运作方式决定了它对页面的爬取是由用户驱动的。并没有一个大型公司对整个互联网上的所有可访问页面都进行搜索,对于 YaCy 来说也是这样,一个站点只有在被用户指定爬取的前提下,才会被 YaCy 爬取并进入索引。
YaCy 客户端提供了两种爬取页面的方式:你可以手动爬取,并让 YaCy 根据建议去爬取。
![YaCy advanced crawler][8]
#### 手动爬取
手动爬取是指由用户输入指定的网站 URL 并启动 YaCy 的爬虫任务。只需要点击“<ruby>高级爬虫<rt>Advanced Crawler</rt></ruby>”并输入计划爬取的若干 URL然后选择页面底部的“<ruby>进行远程索引<rt>Do Remote indexing</rt></ruby>”选项,这个选项会让客户端向互联网广播它要索引的 URL可选地接受这些请求的客户端可以帮助你爬取这些 URL。
点击页面底部的“<ruby>开始新爬虫任务<rt>Start New Crawl Job</rt></ruby>”按钮就可以开始进行爬取了,我就是这样对一些常用和有用站点进行爬取和索引的。
爬虫任务启动之后YaCy 会将这些 URL 对应的页面在本地生成和存储索引。在高级模式下,也就是本地计算机允许 8090 端口流量进出时,全网的 YaCy 用户都可以使用到这一份索引。
#### 加入爬虫网络
尽管一些非常敬业的 YaCy 高级用户已经强迫症般地在互联网上爬取了很多页面,但对于全网浩如烟海的页面而言也只是沧海一粟。单个用户所拥有的资源远不及很多大公司的网络爬虫,但大量 YaCy 用户如果联合起来成为一个社区,能产生的力量就大得多了。只要开启了 YaCy 的爬虫请求广播功能,就可以让其它客户端参与进来爬取更多页面。
只需要在“<ruby>高级爬虫<rt>Advanced Crawler</rt></ruby>”面板中点击页面顶部的“<ruby>远程爬取<rt>Remote Crawling</rt></ruby>”,勾选“<ruby>加载<rt>Load</rt></ruby>”旁边的复选框,就可以让你的客户端接受其它人发来的爬虫任务请求了。
![YaCy remote crawling][9]
### YaCy 监控相关
YaCy 除了作为一个非常强大的搜索引擎,还提供了很丰富的主题和用户体验。你可以在“<ruby>监控<rt>Monitor</rt></ruby>”面板中监控 YaCy 客户端的网络运行状况,甚至还可以了解到有多少人从 YaCy 社区中获取到了自己所需要的东西。
![YaCy monitoring screen][10]
### 搜索引擎发挥了作用
你使用 YaCy 的时间越长,就越会思考搜索引擎如何改变自己的视野,因为你对互联网的体验很大一部分来自于你在搜索引擎中一次次简单查询的结果。实际上,当你和不同行业的人交流时,可能会注意到每个人对“互联网”的理解都有所不同。有些人会认为,互联网的搜索引擎中充斥着各种广告和推广,同时也仅仅能从搜索结果中获取到有限的信息。例如,假设有人不断搜索关于关键词 X 的内容,那么大部分商业搜索引擎都会在搜索结果中提高关键词 X 的权重,但与此同时,另一个关键词 Y 的权重则会相对降低,从而让关键词 Y 被淹没在搜索结果当中,即使这样对完成特定任务更好。
就像在现实生活中一样,走出虚拟的世界视野会让你看到一个更广阔的世界。尝试使用 YaCy看看你发现了什么。
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/2/yacy-search-engine-hacks
作者:[Seth Kenlon][a]
选题:[lujun9972][b]
译者:[HankChow](https://github.com/HankChow)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/seth
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_desktop_website_checklist_metrics.png?itok=OKKbl1UR (Browser of things)
[2]: https://linux.cn/article-11905-1.html
[3]: https://yacy.net/
[4]: https://www.linuxquestions.org/questions/linux-news-59/is-there-no-more-linux-google-884306/
[5]: https://opensource.com/sites/default/files/uploads/yacy-profiles.jpg (YaCy profile selector)
[6]: https://en.wikipedia.org/wiki/Vivisimo
[7]: https://opensource.com/sites/default/files/uploads/yacy-network-config.jpg (YaCy network configuration)
[8]: https://opensource.com/sites/default/files/uploads/yacy-advanced-crawler.jpg (YaCy advanced crawler)
[9]: https://opensource.com/sites/default/files/uploads/yacy-remote-crawl-accept.jpg (YaCy remote crawling)
[10]: https://opensource.com/sites/default/files/uploads/yacy-monitor.jpg (YaCy monitoring screen)

View File

@ -1,32 +1,34 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-11917-1.html)
[#]: subject: (Dino is a Modern Looking Open Source XMPP Client)
[#]: via: (https://itsfoss.com/dino-xmpp-client/)
[#]: author: (Ankush Das https://itsfoss.com/author/ankush/)
Dino一个有着现代外观的开源 XMPP 客户端
Dino一个有着现代外观的开源 XMPP 客户端
======
_**简介Dino 是一个相对较新的开源 XMPP 客户端,它尝试提供良好的用户体验,同时鼓励注重隐私的用户使用 XMPP 发送消息。**_
> Dino 是一个相对较新的开源 XMPP 客户端,它试图提供良好的用户体验,鼓励注重隐私的用户使用 XMPP 发送消息。
![](https://img.linux.net.cn/data/attachment/album/202002/22/102844mhzgzb3533xgq6d8.jpg)
### Dino一个开源 XMPP 客户端
![][1]
[XMPP][2] (可扩展通讯和表示协议) 是一个去中心化的网络模型,可促进即时消息传递和协作。去中心化意味着没有中央服务器可以访问你的数据。通信直接点对点。
[XMPP][2]<ruby>可扩展通讯和表示协议<rt>eXtensible Messaging Presence Protocol</rt></ruby> 是一个去中心化的网络模型,可促进即时消息传递和协作。去中心化意味着没有中央服务器可以访问你的数据。通信直接点对点。
我们中的一些人可能会称它为"老派"技术,可能是因为 XMPP 客户端通常有着非常糟糕的用户体验,或者仅仅是因为它需要时间来适应(或设置它)。
我们中的一些人可能会称它为“老派”技术,可能是因为 XMPP 客户端通常用户体验非常糟糕,或者仅仅是因为它需要时间来适应(或设置它)。
这时候 [Dino[3] 作为现代 XMPP 客户端出现了,在不损害你的隐私的情况下提供干净清爽的用户体验。
这时候 [Dino][3] 作为现代 XMPP 客户端出现了,在不损害你的隐私的情况下提供干净清爽的用户体验。
### 用户体验
![][4]
Dino 试图改善 XMPP 客户端的用户体验,但值得注意的是,它的外观和感受将在一定程度上取决于你的 Linux 发行版。你的图标主题或 Gnome 主题会让你的个人体验更好或更糟。
Dino 试图改善 XMPP 客户端的用户体验,但值得注意的是,它的外观和感受将在一定程度上取决于你的 Linux 发行版。你的图标主题或 Gnome 主题会让你的个人体验更好或更糟。
从技术上讲,它的用户界面非常简单,易于使用。所以,我建议你看下 Ubuntu 中的[最佳图标主题][5]和 [GNOME 主题][6]来调整 Dino 的外观。
@ -34,7 +36,7 @@ Dino 有试图改善 XMPP 客户端的用户体验,但值得注意的是,它
![Dino Screenshot][7]
你可以期望将 Dino 用作 Slack、[Signal][8] 或 [Wire][9] 的替代产品,来用于你的业务或个人用途。
你可以将 Dino 用作 Slack、[Signal][8] 或 [Wire][9] 的替代产品,来用于你的业务或个人用途。
它提供了消息应用所需的所有基本特性,让我们看下你可以从中得到的:
@ -47,14 +49,10 @@ Dino 有试图改善 XMPP 客户端的用户体验,但值得注意的是,它
* 支持 [OpenPGP][10] 和 [OMEMO][11] 加密
* 轻量级原生桌面应用
### 在 Linux 上安装 Dino
你可能会发现它列在你的软件中心中也可能未找到。Dino 为基于 Debiandeb和 Fedorarpm的发行版提供了可用的二进制文件。
**对于 Ubuntu**
Dino 在 Ubuntu 的 universe 仓库中,你可以使用以下命令安装它:
```
@ -63,15 +61,15 @@ sudo apt install dino-im
类似地,你可以在 [GitHub 分发包页面][12]上找到其他 Linux 发行版的包。
如果你想要获取最新的,你可以在 [OpenSUSE 的软件页面][13]找到 Dino 的 **.deb** 和 .**rpm** (每日构建版)安装在 Linux 中。
如果你想要获取最新的,你可以在 [OpenSUSE 的软件页面][13]找到 Dino 的 **.deb** 和 .**rpm** (每日构建版)安装在 Linux 中。
在任何一种情况下,前往它的 [Github 页面][14]或点击下面的链接访问官方网站。
[下载 Dino][3]
- [下载 Dino][3]
**总结**
### 总结
它工作良好没有出过任何问题(在我编写这篇文章时快速测试过它)。我将尝试探索更多,并希望能涵盖更多有关 XMPP 的文章来鼓励用户使用 XMPP 的客户端和服务器用于通信。
在我编写这篇文章时快速测试过它,它工作良好,没有出过问题。我将尝试探索更多,并希望能涵盖更多有关 XMPP 的文章来鼓励用户使用 XMPP 的客户端和服务器用于通信。
你觉得 Dino 怎么样?你会推荐另一个可能好于 Dino 的开源 XMPP 客户端吗?在下面的评论中让我知道你的想法。
@ -82,7 +80,7 @@ via: https://itsfoss.com/dino-xmpp-client/
作者:[Ankush Das][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -0,0 +1,97 @@
[#]: collector: (lujun9972)
[#]: translator: (Morisun029)
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-11924-1.html)
[#]: subject: (Why developers like to code at night)
[#]: via: (https://opensource.com/article/20/2/why-developers-code-night)
[#]: author: (Matt Shealy https://opensource.com/users/mshealy)
程序员为什么喜欢在晚上编码
======
> 对许多开源程序员来说,夜间的工作计划是创造力和生产力来源的关键。
![](https://img.linux.net.cn/data/attachment/album/202002/24/104251b2hxch46h45c8zwd.jpg)
如果你问大多数开发人员更喜欢在什么时候工作,大部人会说他们最高效的时间在晚上。这对于那些在工作之余为开源项目做贡献的人来说更是如此(尽管如此,希望在他们的健康范围内[避免透支][2])。
有些人喜欢从晚上开始,一直工作到凌晨,而另一些人则很早就起床(例如,凌晨 4 点),以便在开始日常工作之前完成大部分编程工作。
这种工作习惯可能会使许多开发人员看起来像个怪人,不合时宜。但是,为什么有这么多的程序员喜欢在非正常时间工作,原因有很多:
### 制造者日程
根据 <ruby>[保罗·格雷厄姆][3]<rt>Paul Graham</rt></ruby> 的观点,“生产东西”的人倾向于遵守 制造者日程 —— 他们更愿意以半天或更长时间为单位使用时间。事实上,大多数[开发人员也有相同的偏好][4]。LCTT 译注:保罗·格雷厄姆有[一篇文章][8]述及制造者日程和管理者日程。)
一方面,开发人员从事大型抽象系统工作,需要思维空间来处理整个模型。将他们的日程分割成 15 分钟或 30 分钟的时间段来处理电子邮件、会议、电话以及来自同事的打断,工作效果只会适得其反。
另一方面,通常不可能以小时为单位进行有效编程。因为这么短的时间几乎不够让你把思绪放在手头的任务上并开始工作。
上下文切换也会对编程产生不利影响。在晚上工作,开发人员可以避免尽可能多的干扰。在没有不断的干扰的情况下,他们可以花几个小时专注于手头任务,并尽可能提高工作效率。
### 平和安静的环境
由于晚上或凌晨不太会有来自各种活动的噪音(例如,办公室闲谈、街道上的交通),这使许多程序员感到放松,促使他们更具创造力和生产力,特别是在处理诸如编码之类的精神刺激任务时。
独处与平静,加上他们知道自己将有几个小时不被中断的工作时间,通常会使他们摆脱白天工作计划相关的时间压力,从而产出高质量的工作。
更不用说了,当解决了一个棘手的问题后,没有什么比尽情享受自己最喜欢的午夜小吃更美好的事情了!
### 沟通
与在公司内工作的程序员相比,从事开源项目的开发人员可以拥有不同的沟通节奏。大多数开源项目的沟通都是通过邮件或 GitHub 上的评论等渠道异步完成的。很多时候,其他程序员在不同的国家和时区,因此实时交流通常需要开发人员变成一个夜猫子。
### 昏昏欲睡的大脑
这听起来可能违反直觉,但是随着时间的推移,大脑会变得非常疲倦,因此只能专注于一项任务。晚上工作从根本上消除了多任务处理,而这是保持专注和高效的主要障碍。当大脑处于昏昏欲睡的状态时,你是无法保持专注的!
此外,许多开发人员在入睡时思考要解决的问题通常会取得重大进展。潜意识开始工作,答案通常在他们半睡半醒的凌晨时分就出现了。
这不足为奇,因为[睡眠可增强大脑功能][5],可帮助我们理解新信息并进行更有创造性的思考。当解决方案在凌晨出现时,这些开发人员便会起来开始工作,不错过任何机会。
### 灵活和创造性思考
许多程序员体会到晚上创造力会提升。前额叶皮层,即大脑中与集中能力有关的部分,在一天结束时会感到疲倦。这似乎为某些人提供了更灵活和更具创造性的思考。
匹兹堡大学医学院精神病学助理教授 [Brant Hasler][6] 表示:“由于自上而下的控制和‘认知抑制’的减少,大脑可能会解放出来进行更发散的思考,从而使人们更容易地将不同概念之间的联系建立起来。” 结合轻松环境所带来的积极情绪,开发人员可以更轻松地产生创新想法。
此外,在没有干扰的情况下集中精力几个小时,“沉浸在你做的事情中”。这可以帮助你更好地专注于项目并参与其中,而不必担心周围发生的事情。
### 明亮的电脑屏幕
因为整天看着明亮的屏幕, 许多程序员的睡眠周期被延迟。电脑屏幕发出的蓝光[扰乱我们的昼夜节律][7],延迟了释放诱发睡眠的褪黑激素和提高人的机敏性,并将人体生物钟重置到更晚的时间。从而导致,开发人员往往睡得越来越晚。
### 来自过去的影响
过去,大多数开发人员是出于必要在晚上工作,因为在白天当公司其他人都在使用服务器时,共享服务器的计算能力支撑不了编程工作,所以开发人员需要等到深夜才能执行白天无法进行的任务,例如测试项目、运行大量的“编码-编译-运行-调试”周期以及部署新代码。现在尽管服务器功能变强大了,大多数可以满足需求,但夜间工作的趋势仍是这种文化的一部分。
### 结语
尽管开发人员喜欢在晚上工作的原因很多,但请记住,做为夜猫子并不意味着你应该克扣睡眠时间。睡眠不足会导致压力和焦虑,并最终导致倦怠。
获得足够质量的睡眠是维持良好身体健康和大脑功能的关键。例如,它可以帮助你整合新信息、巩固记忆、创造性思考、清除身体积聚的毒素、调节食欲并防止过早衰老。
无论你是哪种日程,请确保让你的大脑得到充分的休息,这样你就可以在一整天及每天的工作中发挥最大的作用!
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/2/why-developers-code-night
作者:[Matt Shealy][a]
选题:[lujun9972][b]
译者:[Morisun029](https://github.com/Morisun029)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/mshealy
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_code_programming_laptop.jpg?itok=ormv35tV (Person programming on a laptop on a building)
[2]: https://opensource.com/article/19/11/burnout-open-source-communities
[3]: http://www.paulgraham.com/makersschedule.html
[4]: https://www.chamberofcommerce.com/business-advice/software-development-trends-overtaking-the-market
[5]: https://amerisleep.com/blog/sleep-impacts-brain-health/
[6]: https://www.vice.com/en_us/article/mb58a8/late-night-creativity-spike
[7]: https://www.sleepfoundation.org/articles/how-blue-light-affects-kids-sleep
[8]: http://www.paulgraham.com/makersschedule.html

View File

@ -1,8 +1,8 @@
[#]: collector: (lujun9972)
[#]: translator: (qianmingtian)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-11923-1.html)
[#]: subject: (How to install Vim plugins)
[#]: via: (https://opensource.com/article/20/2/how-install-vim-plugins)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
@ -10,74 +10,73 @@
如何安装 Vim 插件
======
无论你是手动安装还是通过包管理器安装,插件都可以帮你为你的工作流中打造一个完美的 Vim 。
![Team checklist and to dos][1]
> 无论你是手动安装还是通过包管理器安装,插件都可以帮助你在工作流中打造一个完美的 Vim 。
虽然 [Vim][2] 是快速且高效的,但在默认情况下,它仅仅只是一个文本编辑器。至少,这就是没有插件的情况 Vim 应当具备的样子,插件构建在 Vim 之上,并添加额外的功能,使 Vim 不仅仅是一个输入文本的窗口。有了合适的插件组合,你可以控制你的生活,形成你自己独特的 Vim 体验。你可以[自定义你的主题][3],你可以添加语法高亮,代码 linting ,版本跟踪器等等。
![](https://img.linux.net.cn/data/attachment/album/202002/23/215719kwhqzwwj1ezoen6o.jpg)
虽然 [Vim][2] 是快速且高效的,但在默认情况下,它仅仅只是一个文本编辑器。至少,这就是没有插件的情况 Vim 应当具备的样子,插件构建在 Vim 之上,并添加额外的功能,使 Vim 不仅仅是一个输入文本的窗口。有了合适的插件组合,你可以控制你的生活,形成你自己独特的 Vim 体验。你可以[自定义你的主题][3],你可以添加语法高亮,代码 linting版本跟踪器等等。
### 怎么安装 Vim 插件
Vim 可以通过插件进行扩展,但很长一段时间以来,并没有官方的安装方式去安装这些插件。从 Vim 8 开始,有一个关于插件如何安装和加载的结构。你可能会在网上或项目自述文件中遇到旧的说明,但只要你运行 Vim 8 或更高版本,你应该根据 Vim 的[官方插件安装方法][4]安装或使用 Vim 包管理器。您可以使用包管理器,无论你运行的是什么版本(包括比 8.x 更老的版本),这使得安装过程比您自己维护更新更容易。
Vim 可以通过插件进行扩展,但很长一段时间以来,并没有官方的安装方式去安装这些插件。从 Vim 8 开始,有一个关于插件如何安装和加载的结构。你可能会在网上或项目自述文件中遇到旧的说明,但只要你运行 Vim 8 或更高版本,你应该根据 Vim 的[官方插件安装方法][4]安装或使用 Vim 包管理器。你可以使用包管理器,无论你运行的是什么版本(包括比 8.x 更老的版本),这使得安装过程比你自己维护更新更容易。
手动和自动安装方法都值得了解,所以请继续阅读以了解这两种方法。
### 手动安装插件( Vim 8 及以上版本)
### 手动安装插件Vim 8 及以上版本)
Vim 包是一个包含一个或多个插件的目录。默认情况下,你的 Vim 设置包含在 **~/.vim** 中,这是 vim 在启动时寻找插件的地方。(下面的示例使用了通用名称 **vendor** 来表示插件是从一个不是你的实体获得的。)
所谓的 “Vim 包是一个包含一个或多个插件的目录。默认情况下,你的 Vim 设置包含在 `~/.vim` 中,这是 Vim 在启动时寻找插件的地方。(下面的示例使用了通用名称 `vendor` 来表示插件是从其它地方获得的。)
当你启动 Vim 时,它首先处理你的 **.vimrc**文件,然后扫描 **~/.vim** 中的所有目录查找包含在 **pack/*/start** 中的插件。
当你启动 Vim 时,它首先处理你的 `.vimrc`文件,然后扫描 `~/.vim` 中的所有目录,查找包含在 `pack/*/start` 中的插件。
默认情况下,你的 **~/.vim** 目录(如果你有一个)没有这样的文件结构,所以设置为:
默认情况下,你的 `~/.vim` 目录(如果你有的话)中没有这样的文件结构,所以设置为:
```
`$ mkdir -p ~/.vim/pack/vendor/start`
$ mkdir -p ~/.vim/pack/vendor/start
```
现在,你可以将 Vim 插件放在 **~/.vim/pack/vendor/start** 中,它们会在你启动 Vim 时自动加载。
例如,尝试安装一下 [NERDTree][5] ,一个基于文本的 Vim 文件管理器。首先,使用 Git 克隆 NERDTree 存储库的快照:
现在,你可以将 Vim 插件放在 `~/.vim/pack/vendor/start` 中,它们会在你启动 Vim 时自动加载。
例如,尝试安装一下 [NERDTree][5],这是一个基于文本的 Vim 文件管理器。首先,使用 Git 克隆 NERDTree 存储库的快照:
```
$ git clone --depth 1 \
  <https://github.com/preservim/nerdtree.git> \
  https://github.com/preservim/nerdtree.git \
  ~/.vim/pack/vendor/start/nerdtree
```
启动 Vim 或者 gvim ,然后键入如下命令:
启动 Vim 或者 gvim然后键入如下命令
```
`:NERDTree`
:NERDTree
```
Vim 窗口左侧将打开一个文件树。
![NERDTree plugin][6]
如果你不想每次启动 Vim 时自动加载插件,你可以在 **~/.vim/pack/vendor** 中创建 **opt** 文件夹:
如果你不想让一个插件每次启动 Vim 时都自动加载,你可以在 `~/.vim/pack/vendor` 中创建 `opt` 文件夹:
```
`$ mkdir ~/.vim/pack/vendor/opt`
$ mkdir ~/.vim/pack/vendor/opt
```
任何安装到 **opt** 的插件都可被 Vim 使用,但是只有当你使用 **packadd** 命令将它们添加到一个会话中时,它们才会被加载到内存中。例如,一个虚构的叫 foo 的插件:
任何安装到 `opt` 的插件都可被 Vim 使用,但是只有当你使用 `packadd` 命令将它们添加到一个会话中时,它们才会被加载到内存中。例如,一个虚构的叫 foo 的插件:
```
`:packadd foo`
:packadd foo
```
Vim 官方建议每个插件项目在 **~/.Vim /pack** 中有自己的目录。例如,如果你要安装 NERDTree 插件和假想的 foo 插件,你需要创建这样的目录结构:
Vim 官方建议每个插件项目在 `~/.Vim/pack` 中创建自己的目录。例如,如果你要安装 NERDTree 插件和假想的 foo 插件,你需要创建这样的目录结构:
```
$ mkdir -p ~/.vim/pack/NERDTree/start/
$ git clone --depth 1 \
  <https://github.com/preservim/nerdtree.git> \
  ~/.vim/pack/NERDTree/start/NERDTree
https://github.com/preservim/nerdtree.git \
~/.vim/pack/NERDTree/start/NERDTree
$ mkdir -p ~/.vim/pack/foo/start/
$ git clone --depth 1 \
  <https://notabug.org/foo/foo.git> \
  ~/.vim/pack/foo/start/foo
https://notabug.org/foo/foo.git \
~/.vim/pack/foo/start/foo
```
这样做是否方便取决于你。
@ -88,14 +87,14 @@ $ git clone --depth 1 \
#### 使用 vim-plug 安装插件
安装 vim-plug ,以便它在启动时自动加载:
安装 vim-plug以便它在启动时自动加载
```
$ curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
  <https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim>
  https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
```
创建一个 **~/.vimrc** 文件(如果你还没有文件),然后输入以下文本:
创建一个 `~/.vimrc` 文件(如果你还没有这个文件),然后输入以下文本:
```
call plug#begin()
@ -103,38 +102,38 @@ Plug 'preservim/NERDTree'
call plug#end()
```
每次要安装插件时,都必须在 **plugbegin()****plugend()** 之间输入插件的名称和位置(上面以 NERDTree 文件管理器为例)。如果你所需的插件未托管在 GitHub 上,你可以提供完整的 URL ,而不仅仅是 GitHub 用户名和项目 ID 。你甚至可以在 **~/.vim** 目录之外“安装”本地插件。
每次要安装插件时,都必须在 `plugbegin()``plugend()` 之间输入插件的名称和位置(上面以 NERDTree 文件管理器为例)。如果你所需的插件未托管在 GitHub 上,你可以提供完整的 URL,而不仅仅是 GitHub 的用户名和项目 ID。你甚至可以在 `~/.vim` 目录之外“安装”本地插件。
最后,启动 Vim 并提示 vim-plug 安装 **~/.vimrc** 中列出的插件:
最后,启动 Vim 并提示 vim-plug 安装 `~/.vimrc` 中列出的插件:
```
`:PlugInstall`
:PlugInstall
```
等待插件下载。
#### 通过 vim-plug 更新插件
与手动安装过程相比,编辑 **~/.vimrc** 并使用命令来进行安装可能看起来并没有多省事,但是 vim-plug 的真正优势在更新。更新所有安装的插件,使用这个 Vim 命令:
与手动安装过程相比,编辑 `~/.vimrc` 并使用命令来进行安装可能看起来并没有多省事,但是 vim-plug 的真正优势在更新。更新所有安装的插件,使用这个 Vim 命令:
```
`:PlugUpdate`
:PlugUpdate
```
如果你不想更新所有的插件,你可以通过添加插件的名字来更新任何插件:
```
`:PlugUpdate NERDTree`
:PlugUpdate NERDTree
```
#### 恢复插件
vim-plug 的另一个优点是它的导出和恢复功能。 Vim 用户都知道,正是插件的缘故,通常每个用户使用 Vim 的工作方式都是独一无二的。一旦你安装和配置了正确的插件组合,你最不想要的就是再也找不到它们。
vim-plug 的另一个优点是它的导出和恢复功能。Vim 用户都知道,正是插件的缘故,通常每个用户使用 Vim 的工作方式都是独一无二的。一旦你安装和配置了正确的插件组合,你最不想要的局面就是再也找不到它们。
Vim-plug 有这个命令来生成一个脚本来恢复所有当前的插件:
```
`:PlugSnapshot ~/vim-plug.list`
:PlugSnapshot ~/vim-plug.list
```
vim-plug 还有许多其他的功能,所以请参考它的[项目页面][7]以获得完整的文档。
@ -151,7 +150,7 @@ via: https://opensource.com/article/20/2/how-install-vim-plugins
作者:[Seth Kenlon][a]
选题:[lujun9972][b]
译者:[qianmingtian][c]
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -0,0 +1,64 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Google Cloud moves to aid mainframe migration)
[#]: via: (https://www.networkworld.com/article/3528451/google-cloud-moves-to-aid-mainframe-migration.html)
[#]: author: (Michael Cooney https://www.networkworld.com/author/Michael-Cooney/)
Google Cloud moves to aid mainframe migration
======
Google bought Cornerstone Technology, whose technology facilitates moving mainframe applications to the cloud.
Thinkstock
Google Cloud this week bought a mainframe cloud-migration service firm Cornerstone Technology with an eye toward helping Big Iron customers move workloads to the private and public cloud. 
Google said the Cornerstone technology found in its [G4 platform][1]  will shape the foundation of its future mainframe-to-Google Cloud offerings and help mainframe customers modernize applications and infrastructure.
[[Get regularly scheduled insights by signing up for Network World newsletters.]][2]
“Through the use of automated processes, Cornerstones tools can break down your Cobol, PL/1, or Assembler programs into services and then make them cloud native, such as within a managed, containerized environment” wrote Howard Weale, Googles director, Transformation Practice, in a [blog][3] about the buy.
“As the industry increasingly builds applications as a set of services, many customers want to break their mainframe monolith programs into either Java monoliths or Java microservices,” Weale stated. 
Google Clouds Cornerstone service will:
* Develop a migration roadmap where Google will assess a customers mainframe environment and create a roadmap to a modern services architecture.
* Convert any language to any other language and any database to any other database to prepare applications for modern environments.
* Automate the migration of workloads to the Google Cloud.
“Easy mainframe migration will go a long way as Google attracts large enterprises to its cloud,” said Matt Eastwood, senior vice president, Enterprise Infrastructure, Cloud, Developers and Alliances, IDC wrote in a statement.
The Cornerstone move is also part of Googles effort stay competitive in the face of mainframe-migration offerings from [Amazon Web Services][4], [IBM/RedHat][5] and [Microsoft][6].
While the idea of moving legacy applications off the mainframe might indeed be beneficial to a business, Gartner last year warned that such decisions should be taken very deliberately.
“The value gained by moving applications from the traditional enterprise platform onto the next bright, shiny thing rarely provides an improvement in the business process or the companys bottom line. A great deal of analysis must be performed and each cost accounted for,” Gartner stated in a report entitled *[_Considering Leaving Legacy IBM Platforms? Beware, as Cost Savings May Disappoint, While Risking Quality_][7]. * “Legacy platforms may seem old, outdated and due for replacement. Yet IBM and other vendors are continually integrating open-source tools to appeal to more developers while updating the hardware. Application leaders should reassess the capabilities and quality of these platforms before leaving them.”
Join the Network World communities on [Facebook][8] and [LinkedIn][9] to comment on topics that are top of mind.
--------------------------------------------------------------------------------
via: https://www.networkworld.com/article/3528451/google-cloud-moves-to-aid-mainframe-migration.html
作者:[Michael Cooney][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.networkworld.com/author/Michael-Cooney/
[b]: https://github.com/lujun9972
[1]: https://www.cornerstone.nl/solutions/modernization
[2]: https://www.networkworld.com/newsletters/signup.html
[3]: https://cloud.google.com/blog/topics/inside-google-cloud/helping-customers-migrate-their-mainframe-workloads-to-google-cloud
[4]: https://aws.amazon.com/blogs/enterprise-strategy/yes-you-should-modernize-your-mainframe-with-the-cloud/
[5]: https://www.networkworld.com/article/3438542/ibm-z15-mainframe-amps-up-cloud-security-features.html
[6]: https://azure.microsoft.com/en-us/migration/mainframe/
[7]: https://www.gartner.com/doc/reprints?id=1-6L80XQJ&ct=190429&st=sb
[8]: https://www.facebook.com/NetworkWorld/
[9]: https://www.linkedin.com/company/network-world

View File

@ -0,0 +1,57 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Japanese firm announces potential 80TB hard drives)
[#]: via: (https://www.networkworld.com/article/3528211/japanese-firm-announces-potential-80tb-hard-drives.html)
[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/)
Japanese firm announces potential 80TB hard drives
======
Using some very fancy physics for stacking electrons, Showa Denko K.K. plans to quadruple the top end of proposed capacity.
[geralt][1] [(CC0)][2]
Hard drive makers are staving off obsolescence to solid-state drives (SSDs) by offering capacities that are simply not feasible in an SSD. Seagate and Western Digital are both pushing to release 20TB hard disks in the next few years. A 20TB SSD might be doable but also cost more than a new car.
But Showa Denko K.K. of Japan has gone one further with the announcement of its next-generation of heat-assisted magnetic recording (HAMR) media for hard drives. The platters use all-new magnetic thin films to maximize their data density, with the goal of eventually enabling 70TB to 80TB hard drives in a 3.5-inch form factor.
[[Get regularly scheduled insights by signing up for Network World newsletters.]][3]
Showa Denko is the worlds largest independent maker of platters for hard drives, selling them to basically anyone left making hard drives not named Seagate and Western Digital. Those two make their own platters and are working on their own next-generation drives for release in the coming years.
While similar in concept, Seagate and Western Digital have chosen different solutions to the same problem. HAMR, championed by Seagate and Showa, works by temporarily heating the disk material during the write process so data can be written to a much smaller space, thus increasing capacity.
Western Digital supports a different technology called microwave-assisted magnetic recording (MAMR). It operates under a similar concept as HAMR but uses microwaves instead of heat to alter the drive platter. Seagate hopes to get to 48TB by 2023, while Western Digital is planning on releasing 18TB and 20TB drives this year.
Heat is never good for a piece of electrical equipment, and Showa Denkos platters for HAMR HDDs are made of a special composite alloy to tolerate temperature and reduce wear, not to mention increase density. A standard hard disk has a density of about 1.1TB per square inch. Showas drive platters have a density of 5-6TB per square inch.
The question is when they will be for sale, and who will use them. Fellow Japanese electronics giant Toshiba is expected to ship drives with Showa platters later this year. Seagate will be the first American company to adopt HAMR, with 20TB drives scheduled to ship in late 2020.
[][4]
Know whats scary? That still may not be enough. IDC predicts that our global datasphere the total of all of the digital data we create, consume, or capture will grow from a total of approximately 40 zettabytes of data in 2019 to 175 zettabytes total by 2025.
So even with the growth in hard-drive density, the growth in the global data pool everything from Oracle databases to Instagram photos may still mean deploying thousands upon thousands of hard drives across data centers.
Join the Network World communities on [Facebook][5] and [LinkedIn][6] to comment on topics that are top of mind.
--------------------------------------------------------------------------------
via: https://www.networkworld.com/article/3528211/japanese-firm-announces-potential-80tb-hard-drives.html
作者:[Andy Patrizio][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.networkworld.com/author/Andy-Patrizio/
[b]: https://github.com/lujun9972
[1]: https://pixabay.com/en/data-data-loss-missing-data-process-2764823/
[2]: https://creativecommons.org/publicdomain/zero/1.0/
[3]: https://www.networkworld.com/newsletters/signup.html
[4]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE21620&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage)
[5]: https://www.facebook.com/NetworkWorld/
[6]: https://www.linkedin.com/company/network-world

View File

@ -0,0 +1,106 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Discussing Past, Present and Future of FreeBSD Project)
[#]: via: (https://itsfoss.com/freebsd-interview-deb-goodkin/)
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)
Discussing Past, Present and Future of FreeBSD Project
======
[FreeBSD][1] is one of the most popular BSD distributions. It is used on desktop, servers and embedded devices for more than two decades.
We talked to Deb Goodkin, executive director, [FreeBSD Foundation][2] and discussed the past, present and future of FreeBSD project.
![][3]
**Its FOSS: FreeBSD has been in the scene for more than 25 years. How do you see the journey of FreeBSD? **
Over the years, weve seen a lot of innovation happening on and with FreeBSD. When the Foundation came into play 20 years ago, we were able to step in and help accelerate changes in the operating system. Over the years, weve increased our marketing support, to provide more advocacy and educational material, and to increase the awareness and use of FreeBSD.
In addition, weve increased our staff of software developers to allow us to quickly step in to fix bugs, review patches, implement workarounds to hardware issues, and implement new features and functionality. We have also increased the number of development projects we are funding to improve various areas of FreeBSD.
The history of stability and reliability, along with all the improvements and growth with FreeBSD, is making it a compelling choice for companies, universities, and individuals.
**Its FOSS: We know that Netflix uses FreeBSD extensively. What other companies or groups rely on FreeBSD? How do they contribute to BSD/FreeBSD (if they do at all)?**
Sonys Playstation 4 uses a modified version of FreeBSD as their operating system, Apple with their MacOS and iOS, NetApp in their ONTAP product, Juniper Networks  in [JunOS][4], Trivago in their backend infrastructure, University of Cambridge in security research including the Capability Hardware Enhanced RISC Instruction (CHERI) project, University of Notre Dame in their Engineering Department, Groupon in their datacenter, LA Times in their data center, as well as, other notable companies like Panasonic, and Nintendo.
I listed a variety of organizations to highlight the different FreeBSD use cases. Companies like [Netflix support FreeBSD][5] by supporting the Project financially, as well as, by upstreaming their code. Some of the companies, like Sony, take advantage of the BSD license and dont give back at all. 
![Deb Goodkin And Friend Promoting FreeBSD At Oscon][6]
**Its FOSS: Linux is ruling the servers and cloud computing. It seems that BSD is lagging in that field?**
I wouldnt characterize it as lagging, per se. Linux distributions do have a much higher market share than FreeBSD, but our strength falls in those two markets. FreeBSD does extremely well in these markets, because it provides a consistent and reliable foundation, and tends to just work. Known for having long term API stability, the user will integrate once and upgrade on their terms as both FreeBSD and their product evolves. 
**Its FOSS: Do you see the emergence of Linux as a threat to BSD? **
Sure, [there are so many Linux distributions][7] already, and most of them are supported by for profit companies. In fact, companies like Intel have many Linux developers on staff, so Linux is easily supported on their hardware.
However, thanks to the continuing education efforts and as our market share continues to grow, more developers will be available to support companies various FreeBSD use cases. 
**Its FOSS: Lets talk about desktop. Recently, the devs of Project Trident announced that they were moving away from FreeBSD as a base. They said that they made this decision because FreeBSD is slow to review updates and support for new hardware. For example, the most recent version of Telegram on FreeBSD is 9 releases behind the version available on Linux. How would you respond to their comments?**
There are quite a few FreeBSD distros for the desktop, with various focuses. The latest, is [FuryBSD][8], which coincidentally was started by iXsystems employees, but is independent of iXsystems, just like Project Trident is. In addition to FuryBSD, you may want to check out [NomadBSD][9] and [MidnightBSD][10].
Regarding supporting new hardware, weve stepped up our efforts to get FreeBSD working on more popular newer laptops. For example, the Foundation recently purchased a couple of the latest generation Lenovo X1 Carbon laptops and sponsored work to make sure that peripherals are supported out-of-the-box.
**Its FOSS: Why should a desktop user consider choosing FreeBSD?**
There are many reasons people should consider using FreeBSD on their desktop! Just to highlight a few, it has rock solid stability; high performance; supports [ZFS][11] to protect your data; a community that is friendly, helpful, and approachable; excellent documentation to easily find answers; over 30,000 open source software packages that are easy to install, allowing you to easily set up your environment without a lot of extras, and that includes many choices of popular GUIs, and it follows the POLA philosophy ([Principle of Least Astonishment][12]) which means, dont break things that work and upgrades are generally painless (even across major releases). 
**Its FOSS: Are there any plans to make it easier to install FreeBSD as a desktop system? The current focus seems to be on servers.**
The Foundation is supporting efforts to make sure FreeBSD works on the latest hardware and peripherals that appear in desktop systems, and will continue to support making FreeBSD easy to deploy, monitor, and configure to provide a great toolbox for building a desktop on top of it. That allows others to take as much or as little of FreeBSD to build a desktop version to produce a specific user experience they desire.
Like I mentioned above, there are other FreeBSD distributions that have taken these FreeBSD components and created their own desktop versions.
**Its FOSS: What are your plans/roadmap for FreeBSD in the coming years?**
The FreeBSD Foundations purpose is to support the FreeBSD Project. While were an entirely separate entity, we work closely with the Core Team and the community to help move the Project forward. The Foundation identifies key areas we should support in the coming years, based on input from users and what we are seeing in the industry. 
In 2019, we embarked on an even broader spectrum advocacy project to recruit new members throughout the world, while raising awareness about the benefits of learning FreeBSD. We are funding development projects including WiFi improvements, supporting OpenJDK, ZFS RAID-Z expansion, security, toolchain, performance improvements, and other features to keep FreeBSD innovative.
The FreeBSD Foundation will continue to host workshops and expand the amount of training opportunities and materials we provide. Finally, the [BSD Certification program][13] recently launched through Linux Professional Institute with greater availability. 
**Its FOSS: How can we bring more people to the BSD hold?**
We need more PR for FreeBSD and get more tech journalists like yourself to write about FreeBSD. We also need more trainings and classes that include FreeBSD in universities, trainings/workshops at technical conferences, more FreeBSD contributors giving talks at those conferences, more technical journalists, as well as, users writing about FreeBSD, and finally we need case studies from companies and organizations successfully using FreeBSD. It all takes having more resources! Were working on all of the above. 
**Its FOSS: Any message you would like to convey to our readers?**
Readers should consider getting involved with the largest and oldest democratically run open source project!
Whether you want to learn systems programming or how an operating system works, the small size of the operating system makes it a great platform to learn from. The size of the Project makes it easier for anyone to make a notable contribution, and there is a strong mentorship culture to support new contributors.
Being a democratically run project, allows your voice to be heard and work in the areas you are interested in. I hope your readers will go to [freebsd.org][1] and try it out themselves.
--------------------------------------------------------------------------------
via: https://itsfoss.com/freebsd-interview-deb-goodkin/
作者:[Abhishek Prakash][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/abhishek/
[b]: https://github.com/lujun9972
[1]: https://www.freebsd.org/
[2]: https://www.freebsdfoundation.org/
[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/02/deb-goodkin-interview.png?ssl=1
[4]: https://www.juniper.net/us/en/products-services/nos/junos/
[5]: https://itsfoss.com/netflix-freebsd-cdn/
[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/02/FreeBSDFoundation_Deb_Goodkin_and_friend_promoting_FreeBSD_at_OSCON.jpg?ssl=1
[7]: https://itsfoss.com/best-linux-distributions/
[8]: https://itsfoss.com/furybsd/
[9]: https://itsfoss.com/nomadbsd/
[10]: https://itsfoss.com/midnightbsd-1-0-release/
[11]: https://itsfoss.com/what-is-zfs/
[12]: https://en.wikipedia.org/wiki/Principle_of_least_astonishment
[13]: https://www.lpi.org/our-certifications/bsd-overview

View File

@ -1,234 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (lujun9972)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Fun and Games in Emacs)
[#]: via: (https://www.masteringemacs.org/article/fun-games-in-emacs)
[#]: author: (Mickey Petersen https://www.masteringemacs.org/about)
Fun and Games in Emacs
======
Its yet another Monday and youre hard at work on those [TPS reports][1] for your boss, Lumbergh. Why not play Emacss Zork-like text adventure game to take your mind off the tedium of work?
But seriously, yes, there are both games and quirky playthings in Emacs. Some you have probably heard of or played before. The only thing they have in common is that most of them were added a long time ago: some are rather odd inclusions (as youll see below) and others were clearly written by bored employees or graduate students. What they all have in common is a whimsy and a casualness that I rarely see in Emacs today. Emacs is Serious Business now in a way that it probably wasnt back in the 1980s when some of these games were written.
### Tower of Hanoi
The [Tower of Hanoi][2] is an ancient mathematical puzzle game and one that is probably familiar to some of us as it is often used in Computer Science as a teaching aid because of its recursive and iterative solutions.
![Tower of Hanoi Screenshot](https://www.masteringemacs.org/static/uploads/hanoi.png)
In Emacs there are three commands you can run to trigger the Tower of Hanoi puzzle: M-x hanoi with a default of 3 discs; M-x hanoi-unix and M-x hanoi-unix-64 uses the unix timestamp, making a move each second in line with the clock, and with the latter pretending it uses a 64-bit clock.
The Tower of Hanoi implementation in Emacs dates from the mid 1980s — an awful long time ago indeed. There are a few Customize options (M-x customize-group RET hanoi RET) such as enabling colorized discs. And when you exit the Hanoi buffer or type a character you are treated to a sarcastic goodbye message (see above.)
### 5x5
![5x5 game grid](https://www.masteringemacs.org/static/uploads/5x5.png)
The 5x5 game is a logic puzzle: you are given a 5x5 grid with a central cross already filled-in; your goal is to fill all the cells by toggling them on and off in the right order to win. Its not as easy as it sounds!
To play, type M-x 5x5, and with an optional digit argument you can change the size of the grid. What makes this game interesting is its rather complex ability to suggest the next move and attempt to solve the game grid. It uses Emacss very own, and very cool, symbolic RPN calculator M-x calc (and in [Fun with Emacs Calc][3] I use it to solve a simple problem.)
So what I like about this game is that it comes with a very complex solver really, you should read the source code with M-x find-library RET 5x5 and a “cracker” that attempts to brute force solutions to the game.
Try creating a bigger game grid, such as M-10 M-x 5x5, and then run one of the crack commands below. The crackers will attempt to iterate their way to the best solution. This runs in real time and is fun to watch:
`M-x 5x5-crack-mutating-best`
Attempt to crack 5x5 by mutating the best solution.
`M-x 5x5-crack-mutating-current`
Attempt to crack 5x5 by mutating the current solution.
`M-x 5x5-crack-randomly`
Attempt to crack 5x5 using random solutions.
`M-x 5x5-crack-xor-mutate`
Attempt to crack 5x5 by xoring the current and best solution.
### Text Animation
You can display a fancy birthday present animation by running M-x animate-birthday-present and giving it your name. It looks rather cool!
![xkcd](https://imgs.xkcd.com/comics/real_programmers.png)
The animate package is also used by M-x butterfly command, a command added to Emacs as an homage to the [XKCD][4] strip above. Of course the Emacs command in the strip is teeechnically not valid but the humor more than makes up for it.
### Blackbox
The objective of this game I am going to quote literally:
> The object of the game is to find four hidden balls by shooting rays into the black box. There are four possibilities: 1) the ray will pass thru the box undisturbed, 2) it will hit a ball and be absorbed, 3) it will be deflected and exit the box, or 4) be deflected immediately, not even being allowed entry into the box.
So, its a bit like the [Battleship][5] most of us played as kids but… for people with advanced degrees in physics?
Its another game that was added back in the 1980s. I suggest you read the extensive documentation on how to play by typing C-h f blackbox.
### Bubbles
![Bubbles game](https://www.masteringemacs.org/static/uploads/bubbles.png)
The M-x bubbles game is rather simple: you must clear out as many “bubbles” as you can in as few moves as possible. When you remove bubbles the other bubbles drop and stick together. Its a fun game that, as an added bonus, comes with graphics if you use Emacss GUI. It also works with your mouse.
You can configure the difficulty of the game by calling M-x bubbles-set-game- where is one of: easy, medium, difficult, hard, or userdefined. Furthermore, you can alter the graphics, grid size and colors using Customize: M-x customize-group bubbles.
For its simplicity and fun factor, this ranks as one of my favorite games in Emacs.
### Fortune & Cookie
I like the fortune command. Snarky, unhelpful and often sarcastic “advice” mixed in with literature and riddles brightens up my day whenever I launch a new shell.
Rather confusingly there are two packages in Emacs that does more-or-less the same thing: fortune and cookie1. The former is geared towards putting fortune cookie messages in email signatures and the latter is just a simple reader for the fortune format.
Anyway, to use Emacss cookie1 package you must first tell it where to find the file by customizing the variable cookie-file with customize-option RET cookie RET.
If youre on Ubuntu you will have to install the fortune package first. The files are found in the /usr/share/games/fortunes/ directory.
You can then call M-x cookie or, should you want to do this, find all matching cookies with M-x cookie-apropos.
### Decipher
This package perfectly captures the utilitarian nature of Emacs: its a package to help you break simple substitution ciphers (like cryptogram puzzles) using a helpful user interface. You just know that more than twenty years ago someone really had a dire need to break a lot of basic ciphers. Its little things like this module that makes me overjoyed to use Emacs: a module of scant importance to all but a few people and, yet, should you need it there it is.
So how do you use it then? Well, lets consider the “rot13” cipher: rotating characters by 13 places in a 26-character alphabet. Its an easy thing to try out in Emacs with M-x ielm, Emacss REPL for [Evaluating Elisp][6]:
```
*** Welcome to IELM *** Type (describe-mode) for help.
ELISP> (rot13 "Hello, World")
"Uryyb, Jbeyq"
ELISP> (rot13 "Uryyb, Jbeyq")
"Hello, World"
ELISP>
```
So how can the decipher module help us here? Well, create a new buffer test-cipher and type in your cipher text (in my case Uryyb, Jbeyq)
![cipher](https://www.masteringemacs.org/static/uploads/cipher.png)
Youre now presented with a rather complex interface. You can now place the point on any of the characters in the ciphertext on the purple line and guess what the character might be: Emacs will update the rest of the plaintext guess with your choices and tell you how the characters in the alphabet have been allocated thus far.
You can then start winnowing down the options using various helper commands to help infer which cipher characters might correspond to which plaintext character:
`D`
Shows a list of digrams (two-character combinations from the cipher) and their frequency
`F`
Shows the frequency of each ciphertext letter
`N`
Shows adjacency of characters. I am not entirely sure how this works.
`M` and `R`
Save and restore a checkpoint, allowing you to branch your work and explore different ways of cracking the cipher.
All in all, for such an esoteric task, this package is rather impressive! If you regularly solve cryptograms maybe this package can help?
### Doctor
![doctor](https://www.masteringemacs.org/static/uploads/doctor.png)
Ah, the Emacs doctor. Based on the original [ELIZA][7] the “Doctor” tries to psychoanalyze what you say and attempts to repeat the question back to you. Rather fun, for a few minutes, and one of the more famous Emacs oddities. You can run it with M-x doctor.
### Dunnet
Emacss very own Zork-like text adventure game. To play it, type M-x dunnet. Its rather good, if short, but its another rather famous Emacs game that too few have actually played through to the end.
If you find yourself with time to kill between your TPS reports then its a great game with a built-in “boss screen” as its text-only.
Oh, and, dont try to eat the CPU card :)
### Gomoku
![gomoku](https://www.masteringemacs.org/static/uploads/gomoku.png)
Another game written in the 1980s. You have to connect 5 squares, tic-tac-toe style. You can play against Emacs with M-x gomoku. The game also supports the mouse, which is rather handy. You can customize the group gomoku to adjust the size of the grid.
### Game of Life
[Conways Game of Life][8] is a famous example of cellular automata. The Emacs version comes with a handful of starting patterns that you can (programmatically with elisp) alter by adjusting the life-patterns variable.
You can trigger a game of life with M-x life. The fact that the whole thing, display code, comments and all, come in at less than 300 characters is also rather impressive.
### Pong, Snake and Tetris
![tetris](https://www.masteringemacs.org/static/uploads/tetris.png)
These classic games are all implemented using the Emacs package gamegrid, a generic framework for building grid-based games like Tetris and Snake. The great thing about the gamegrid package is its compatibility with both graphical and terminal Emacs: if you run Emacs in a GUI you get fancy graphics; if you dont, you get simple ASCII art.
You can run the games by typing M-x pong, M-x snake, or M-x tetris.
The Tetris game in particular is rather faithfully implemented, having both gradual speed increase and the ability to slide blocks into place. And given you have the code to it, you can finally remove that annoying Z-shaped piece no one likes!
### Solitaire
![solitaire image](https://www.masteringemacs.org/static/uploads/solitaire.png)
This is not the card game, unfortunately. But a peg-based game where you have to end up with just one stone on the board, by taking a stone (the o) and “jumping” over an adjacent stone into the hole (the .), removing the stone you jumped over in the process. Rinse and repeat until the board is empty.
There is a handy solver built in called M-x solitaire-solve if you get stuck.
### Zone
Another of my favorites. This times its a screensaver or rather, a series of screensavers.
Type M-x zone and watch what happens to your screen!
You can configure a screensaver idle time by running M-x zone-when-idle (or calling it from elisp) with an idle time in seconds. You can turn it off with M-x zone-leave-me-alone.
This ones guaranteed to make your coworkers freak out if it kicks off while they are looking.
### Multiplication Puzzle
![mpuz](https://www.masteringemacs.org/static/uploads/mpuz.png)
This is another brain-twisting puzzle game. When you run M-x mpuz you are given a multiplication puzzle where you have to replace the letters with numbers and ensure the numbers add (multiply?) up.
You can run M-x mpuz-show-solution to solve the puzzle if you get stuck.
### Miscellaneous
There are more, but theyre not the most useful or interesting:
* You can translate a region into morse code with M-x morse-region and M-x unmorse-region.
* The Dissociated Press is a very simple command that applies something like a random walk markov-chain generator to a body of text in a buffer and generates nonsensical text from the source body. Try it with M-x dissociated-press.
* The Gamegrid package is a generic framework for building grid-based games. So far only Tetris, Pong and Snake use it. Its called gamegrid.
* The gametree package is a complex way of notating and tracking chess games played via email.
* The M-x spook command inserts random words (usually into emails) designed to confuse/overload the “NSA trunk trawler” and keep in mind this module dates from the 1980s and 1990s with various words the spooks are supposedly listening for. Of course, even ten years ago that wouldve seemed awfully paranoid and quaint but not so much any more…
### Conclusion
I love the games and playthings that ship with Emacs. A lot of them date from, well, lets just call a different era: an era where whimsy was allowed or perhaps even encouraged. Some are known classics (like Tetris and Tower of Hanoi) and some of the others are fun variations on classics (like blackbox) — and yet I love that they ship with Emacs after all these years. I wonder if any of these would make it into Emacss codebase today; well, they probably wouldnt — theyd be relegated to the package manager where, in a clean and sterile world, they no doubt belong.
Theres a mandate in Emacs to move things not essential to the Emacs experience to ELPA, the package manager. I mean, as a developer myself, that does make sense, but… surely for every package removed and exiled to ELPA we chip away the essence of what defines Emacs?
--------------------------------------------------------------------------------
via: https://www.masteringemacs.org/article/fun-games-in-emacs
作者:[Mickey Petersen][a]
选题:[lujun9972][b]
译者:[lujun9972](https://github.com/lujun9972)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://www.masteringemacs.org/about
[b]:https://github.com/lujun9972
[1]:https://en.wikipedia.org/wiki/Office_Space
[2]:https://en.wikipedia.org/wiki/Tower_of_Hanoi
[3]:https://www.masteringemacs.org/article/fun-emacs-calc
[4]:http://www.xkcd.com
[5]:https://en.wikipedia.org/wiki/Battleship_(game)
[6]:https://www.masteringemacs.org/article/evaluating-elisp-emacs
[7]:https://en.wikipedia.org/wiki/ELIZA
[8]:https://en.wikipedia.org/wiki/Conway's_Game_of_Life

View File

@ -1,49 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (heguangzhi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How Kubernetes Became the Standard for Compute Resources)
[#]: via: (https://www.linux.com/articles/how-kubernetes-became-the-standard-for-compute-resources/)
[#]: author: (Swapnil Bhartiya https://www.linux.com/author/swapnil/)
How Kubernetes Became the Standard for Compute Resources
======
<https://www.linux.com/wp-content/uploads/2019/08/elevator-1598431_1920.jpg>
2019 has been a game-changing year for the cloud-native ecosystem. There were [consolidations][1], acquisitions of powerhouses like Red Hat Docker and Pivotal, and the emergence of players like Rancher Labs and Mirantis.
“All these consolidation and M&amp;A in this space is an indicator of how fast the market has matured,” said Sheng Liang, co-founder and CEO of Rancher Labs, a company that offers a complete software stack for teams adopting containers.
Traditionally, emerging technologies like Kubernetes and Docker appeal to tinkerers and mega-scalers such as Facebook and Google. There was very little interest outside of that group. However, both of these technologies experienced massive adoption at the enterprise level. Suddenly, there was a massive market with huge opportunities. Almost everyone jumped in. There were players who were bringing innovative solutions and then there were players who were trying to catch up with the rest. It became very crowded very quickly.
It also changed the way innovation was happening. [Early adopters were usually tech-savvy companies.][2] Now, almost everyone is using it, even in areas that were not considered turf for Kubernetes. It changed the market dynamics as companies like Rancher Labs were witnessing unique use cases.
Liang adds, “Ive never been in a market or technology evolution thats happened as quickly and as dynamically as Kubernetes. When we started some five years ago, it was a very crowded space. Over time, most of our peers disappeared for one reason or the other. Either they werent able to adjust to the change or they chose not to adjust to some of the changes.”
In the early days of Kubernetes, the most obvious opportunity was to build Kubernetes distro and Kubernetes operations. Its new technology. Its known to be reasonably complex to install, upgrade, and operate.
It all changed when Google, AWS, and Microsoft entered the market. At that point, there was a stampede of vendors rushing in to provide solutions for the platform. “As soon as cloud providers like Google decided to make Kubernetes as a service and offered it for free as loss-leader to drive infrastructure consumption, we knew that the business of actually operating and supporting Kubernetes, the upside of that would be very limited,” said Liang.
Not everything was bad for non-Google players. Since cloud vendors removed all the complexity that came with Kubernetes by offering it as a service, it meant wider adoption of the technology, even by those who refrained from using it due to the overhead of operating it. It meant that Kubernetes would become ubiquitous and would become an industry standard.
“Rancher Labs was one of the very few companies that saw this as an opportunity and looked one step further than everyone else. We realized that Kubernetes was going to become the new computing standard, just the way TCP/IP became the networking standard,” said Liang.
CNCF plays a critical role in building a vibrant ecosystem around Kubernetes, creating a massive community to build, nurture and commercialize cloud-native open source technologies.
--------------------------------------------------------------------------------
via: https://www.linux.com/articles/how-kubernetes-became-the-standard-for-compute-resources/
作者:[Swapnil Bhartiya][a]
选题:[lujun9972][b]
译者:[heguangzhi](https://github.com/heguangzhi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.linux.com/author/swapnil/
[b]: https://github.com/lujun9972
[1]: https://www.cloudfoundry.org/blog/2019-is-the-year-of-consolidation-why-ibms-deal-with-red-hat-is-a-harbinger-of-things-to-come/
[2]: https://www.packet.com/blog/open-source-season-on-the-kubernetes-highway/

View File

@ -1,135 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How to Install Latest Git Version on Ubuntu)
[#]: via: (https://itsfoss.com/install-git-ubuntu/)
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)
How to Install Latest Git Version on Ubuntu
======
Installing Git on Ubuntu is very easy. It is available in the [main repository of Ubuntu][1] and you can install it [using the apt command][2] like this:
```
sudo apt install git
```
Easy? Isnt it?
There is only a slight little problem (which might not be a problem at all) and that is the version of [Git][3] it installs.
On an LTS system, the software stability is of upmost importance this is why Ubuntu 18.04 and other distributions often provide older but stable version of a software that is well tested with the distribution release.
This is why when you check the Git version, youll see that it installs a version which is older than the [current Git version available on Git projects website][4]:
```
[email protected]:~$ git --version
git version 2.17.1
```
At the time of writing this tutorial, the version available on its website is 2.25. So how do you install the latest Git on Ubuntu then?
### Install latest Git on Ubuntu-based Linux distributions
![][5]
One way would be to [install from source code][6]. That cool, old school method is not everyones cup of tea. Thankfully, there is a [PPA available from Ubuntu Git Maintainers team][7] that you can use to easily install the latest stable Git version.
```
sudo add-apt-repository ppa:git-core/ppa
sudo apt update
sudo apt install git
```
Even if you had installed Git using apt previously, it will get updated to the latest stable version.
```
[email protected]:~$ git --version
git version 2.25.0
```
The beauty of [using PPA][8] is that if there is a new stable version of Git released, youll get it with the system updates. [Just update Ubuntu][9] to get the latest Git stable version.
Trivia
Did you know that Git version control system was created by none other than [Linux creator Linus Torvalds][10]?
### Configure Git [Recommended for developers]
If you have installed Git for development purposes, youll soon start cloning repos, make your changes and commit your change.
If you try to commit your code, you may see a Please tell me who you are error like this:
```
[email protected]:~/compress-pdf$ git commit -m "update readme"
*** Please tell me who you are.
Run
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got '[email protected](none)')
```
This is because you havent configured Git with your personal information which is mandatory.
As the error already hints, you can set up global Git configuration like this:
```
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
```
You can check the Git configuration with this command:
```
git config --list
```
It should show an output like this:
```
[email protected]
user.name=abhishek
```
This configuration is stored in ~/.gitconfig file. You may also change it manually to change the configuration.
* * *
**In the end…**
I hope this quick little tutorial helped you to install Git on Ubuntu. With the PPA, you easily get the latest Git version.
If you have any questions or suggestions, please feel free to ask in the comment section. A quick thank you is also welcomed :)
--------------------------------------------------------------------------------
via: https://itsfoss.com/install-git-ubuntu/
作者:[Abhishek Prakash][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/abhishek/
[b]: https://github.com/lujun9972
[1]: https://itsfoss.com/ubuntu-repositories/
[2]: https://itsfoss.com/apt-command-guide/
[3]: https://git-scm.com/
[4]: https://git-scm.com/downloads
[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/02/install_git_ubuntu.png?ssl=1
[6]: https://itsfoss.com/install-software-from-source-code/
[7]: https://launchpad.net/~git-core/+archive/ubuntu/ppa
[8]: https://itsfoss.com/ppa-guide/
[9]: https://itsfoss.com/update-ubuntu/
[10]: https://itsfoss.com/linus-torvalds-facts/

View File

@ -1,110 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Tools for SSH key management)
[#]: via: (https://opensource.com/article/20/2/ssh-tools)
[#]: author: (Ben Nuttall https://opensource.com/users/bennuttall)
Tools for SSH key management
======
Time-saving shortcuts for a commonly used open source tool.
![collection of hardware on blue backround][1]
I use SSH constantly. Every day I find myself logged in to multiple servers and Pis (both in the same room as me and over the internet). I have many devices I need access to, and different requirements for gaining access, so in addition to using various SSH/SCP command options, I have to maintain a config file with all the connection details.
Over time Ive come up with a few time-saving tips and tools that you might find useful, too.
### SSH keys
SSH keys are a way to authenticate SSH connections without using a password, either to speed up your access or as a security measure, if you turn password access off and ensure only authorized keys are permitted. To create an SSH key, run the command:
```
`$ ssh-keygen`
```
This will create a key-pair (a public and private key) in **~/.ssh/**. Keep the private key (id_rsa) on the PC and never share it. You can share the public key (id_rsa.pub) with others or place it on other servers.
### ssh-copy-id
If Im working on a Pi at home or work, I tend to leave SSH settings at their default, as Im not concerned with security on an internal trusted network, and I usually copy my SSH key to the Pi to avoid having to authenticate with a password every time. To do this, I use the **ssh-copy-id** command to copy it to the Pi. This automatically adds your key to the Pi:
```
`$ ssh-copy-id pi@192.168.1.20`
```
On production servers, I tend to turn off password authentication and only allow authorized SSH keys.
### ssh-import-id
Another similar tool is ssh-import-id. You can use this to give yourself (or others) access to a computer or server by importing their keys from GitHub. For example, I have registered my various SSH keys with my GitHub account, so I can push to GitHub without a password. These public keys are made available, so ssh-import-id can use them to authorize me from any of my computers:
```
`$ ssh-import-id gh:bennuttall`
```
I can also use this to give someone else access to a server without asking them for their keys:
```
`$ ssh-import-id gh:waveform80`
```
### storm
I also use a tool called Storm, which helps you add SSH connections to your SSH config, so you dont have to remember them all. You can install it with pip:
```
`$ sudo pip3 install stormssh`
```
Then you can add an SSH connection to your config with the following command:
```
`$ storm add pi3 pi@192.168.1.20`
```
Then you can just use **ssh pi3** to gain access. Similarly, **scp file.txt pi3:** or **sshfs pi pi3:**
You can also use more SSH options, such as the port number:
```
$ storm add pi3 pi@192.168.1.20:2000
```
You can list, search, and edit saved connections easily using Storms [documentation][2]. All Storm actually does is manage items in your ssh config file at **~/.ssh/config**. Once you see how these are stored, you might choose to edit them manually. An example connection in config looks like this:
```
Host pi3
   user pi
   hostname 192.168.1.20
   port 22
```
### Conclusion
SSH is an important tool for system administration, from Raspberry Pi to the largest cloud infrastructures. Familiarizing yourself with key management will forever be handy. Do you have other SSH tricks to add? I would love to have you share them in the comments.
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/2/ssh-tools
作者:[Ben Nuttall][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/bennuttall
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc_BUS_Apple_520.png?itok=ZJu-hBV1 (collection of hardware on blue backround)
[2]: https://stormssh.readthedocs.io/en/stable/usage.html

View File

@ -1,5 +1,5 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: translator: (heguangzhi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
@ -656,7 +656,7 @@ via: https://opensource.com/article/20/2/python-gnu-octave-data-science
作者:[Cristiano L. Fontana][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
译者:[heguangzhi](https://github.com/heguangzhi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -0,0 +1,427 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Don't like loops? Try Java Streams)
[#]: via: (https://opensource.com/article/20/2/java-streams)
[#]: author: (Chris Hermansen https://opensource.com/users/clhermansen)
Don't like loops? Try Java Streams
======
It's 2020 and time to learn about Java Streams.
![Person drinking a hat drink at the computer][1]
In this article, I will explain how to not write loops anymore.
What? Whaddaya mean, no more loops?
Yep, that's my 2020 resolution—no more loops in Java. Understand that it's not that loops have failed me, nor have they led me astray (well, at least, I can argue that point). Really, it is that I, a Java programmer of modest abilities since 1997 or so, must finally learn about all this new [Streams][2] stuff, saying "what" I want to do and not "how" I want to do it, maybe being able to parallelize some of my computations, and all that other good stuff.
I'm guessing that there are other Java programmers out there who also have been programming in Java for a decent amount of time and are in the same boat. Therefore, I'm offering my experiences as a guide to "how to not write loops in Java anymore."
### Find a problem worth solving
If you're like me, then the first show-stopper you run into is "right, cool stuff, but what am I solving for, and how do I apply this?" I realized that I can spot the perfect opportunity camouflaged as _Something I've Done Before_.
In my case, it's sampling land cover within a specific area and coming up with an estimate and a confidence interval around that estimate for the land cover across the whole area. The specific problem involves deciding whether an area is "forested" or not, given a specific legal definition: if at least 10% of the soil is covered over by tree crowns, then the area is considered to be forested; otherwise, it's something else.
![Image of land cover in an area][3]
It's a pretty esoteric example of a recurring problem; I'll grant you. But there it is. For the ecologists and foresters out there who are accustomed to cool temperate or tropical forests, 10% might sound kind of low, but in the case of dry areas with low-growing shrubs and trees, that's a reasonable number.
So the basic idea is: use images to stratify the area (i.e., areas completely devoid of trees, areas of predominantly small trees spaced quite far apart, areas of predominantly small trees spaced closer together, areas of somewhat larger trees), locate some samples in those strata, send the crew out to measure the samples, analyze the results, and calculate the proportion of soil covered by tree crowns across the area. Simple, right?
![Survey team assessing land cover][4]
### What the field data looks like
In the current project, the samples are rectangular areas 20 meters wide by 25 meters long, so 500 square meters each. On each patch, the field crew measured each tree: its species, its height, the maximum and minimum width of its crown, and the diameter of its trunk at trunk height (nominally 30cm above the ground). This information was collected, entered into a spreadsheet, and exported to a bar separated value (BSV) file for me to analyze. It looks like this:
Stratum# | Sample# | Tree# | Species | Trunk diameter (cm) | Crown diameter 1 (m) | Crown diameter 2 (m) | Height (m)
---|---|---|---|---|---|---|---
1 | 1 | 1 | Ac | 6 | 3.6 | 4.6 | 2.4
1 | 1 | 2 | Ac | 6 | 2.2 | 2.3 | 2.5
1 | 1 | 3 | Ac | 16 | 2.5 | 1.7 | 2.4
1 | 1 | 4 | Ac | 6 | 1.5 | 2.1 | 1.8
1 | 1 | 5 | Ac | 5 | 0.9 | 1.7 | 1.7
1 | 1 | 6 | Ac | 6 | 1.7 | 1.3 | 1.6
1 | 1 | 7 | Ac | 5 | 1.82 | 1.32 | 1.8
1 | 1 | 1 | Ac | 1 | 0.3 | 0.25 | 0.9
1 | 1 | 2 | Ac | 2 | 1.2 | 1.2 | 1.7
The first column is the stratum number (where 1 is "predominantly small trees spaced quite far apart," 2 is "predominantly small trees spaced closer together," and 3 is "somewhat larger trees"; we didn't sample the areas "completely devoid of trees"). The second column is the sample number (there are 73 samples altogether, located in the three strata in proportion to the area of each stratum). The third column is the tree number within the sample. The fourth is the two-letter species code, the fifth the trunk diameter (in this case, 10cm above ground or exposed roots), the sixth the smallest distance across the crown, the seventh the largest distance, and the eighth the height of the tree.
For the purposes of this exercise, I'm only concerned with the total amount of ground covered by the tree crowns—not the species, nor the height, nor the diameter of the trunk.
In addition to the measurement information above, I also have the areas of the three strata, also in a BSV:
stratum | hectares
---|---
1 | 114.89
2 | 207.72
3 | 29.77
### What I want to do (not how I want to do it)
In keeping with one of the main design goals of Java Streams, here is "what" I want to do:
1. Read the stratum area BSV and save the data as a lookup table.
2. Read the measurements from the measurement BSV file.
3. Accumulate each measurement (tree) to calculate the total area of the sample covered by tree crowns.
4. Accumulate the sample tree crown area values and count the number of samples to estimate the mean tree crown area coverage and standard error of the mean for each stratum.
5. Summarize the stratum figures.
6. Weigh the stratum means and standard errors by the stratum areas (looked up from the table created in step 1) and accumulate them to estimate the mean tree crown area coverage and standard error of the mean for the total area.
7. Summarize the weighted figures.
Generally speaking, the way to define "what" with Java Streams is by creating a stream processing pipeline of function calls that pass over the data. So, yes, there is actually a bit of "how" that ends up creeping in… in fact, quite a bit of "how." But, it needs a very different knowledge base than the good, old fashioned loop.
I'll go through each of these steps in detail.
#### Build the stratum area table
The first job is to convert the stratum areas BSV file to a lookup table:
```
[String][5] fileName = "stratum_areas.bsv";
Stream&lt;String&gt; inputLineStream = Files.lines(Paths.get(fileName));  // (1)
final Map&lt;[Integer][6],Double&gt; stratumAreas =   // (2)
    inputLineStream     // (3)
        .skip(1)                   // (4)
        .map(l -&gt; l.split("\\\|"))  // (5)
        .collect(                  // (6)
            Collectors.toMap(      // (7)
                a -&gt; [Integer][6].parseInt(a[0]),  // (8)
                a -&gt; [Double][7].parseDouble(a[1]) // (9)
            )
        );
inputLineStream.close();   // (10)
[System][8].out.println("stratumAreas = " + stratumAreas);  // (11)
```
I'll take this a line or two at a time, where the numbers in comments following the lines above—e.g., _// (3)_— correspond to the numbers below:
1. java.nio.Files.lines() gives a stream of strings corresponding to lines in the file.
2. The goal is to create the lookup table, **stratumAreas**, which is a **Map&lt;Integer,Double&gt;**. Therefore, I can get the **double** value area for stratum 2 as **stratumAreas.get(2)**.
3. This is the beginning of the stream "pipeline."
4. Skip the first line in the pipeline since it's the header line containing the column names.
5. Use **map()** to split the **String** input line into an array of **String** fields, with the first field being the stratum # and the second being the stratum area.
6. Use **collect()** to [materialize the results][9].
7. The materialized result will be produced as a sequence of **Map** entries.
8. The key of each map entry is the first element of the array in the pipeline—the **int** stratum number. By the way, this is a _Java lambda_ expression—[an anonymous function][10] that takes an argument and returns that argument converted to an **int**.
9. The value of each map entry is the second element of the array in the pipeline—the **double** stratum area.
10. Don't forget to close the stream (file).
11. Print out the result, which looks like: [code]`stratumAreas = {1=114.89, 2=207.72, 3=29.77}`
```
### Build the measurements table and accumulate the measurements into the sample totals
Now that I have the stratum areas, I can start processing the main body of data—the measurements. I combine the two tasks of building the measurements table and accumulating the measurements into the sample totals since I don't have any interest in the measurement data per se.
```
fileName = "sample_data_for_testing.bsv";
inputLineStream = Files.lines(Paths.get(fileName));
 final Map&lt;[Integer][6],Map&lt;[Integer][6],Double&gt;&gt; sampleValues =
    inputLineStream
        .skip(1)
        .map(l -&gt; l.split("\\\|"))
        .collect(                  // (1)
            Collectors.groupingBy(a -&gt; [Integer][6].parseInt(a[0]),     // (2)
                Collectors.groupingBy(b -&gt; [Integer][6].parseInt(b[1]), // (3)
                    Collectors.summingDouble(                      // (4)
                        c -&gt; {                                     // (5)
                            double rm = ([Double][7].parseDouble(c[5]) +
                                [Double][7].parseDouble(c[6]))/4d;      // (6)
                            return rm*rm * [Math][11].PI / 500d;         // (7)
                        })
                )
            )
        );
inputLineStream.close();
[System][8].out.println("sampleValues = " + sampleValues);  // (8)
```
Again, a line or two or so at a time:
1. The first seven lines are the same in this task and the previous, except the name of this lookup table is **sampleValues**; and it is a **Map** of **Map**s.
2. The measurement data is grouped into samples (by sample #), which are, in turn, grouped into strata (by stratum #), so I use **Collectors.groupingBy()** at the topmost level [to separate data][12] into strata, with **a[0]** here being the stratum number.
3. I use **Collectors.groupingBy()** once more to separate data into samples, with **b[1]** here being the sample number.
4. I use the handy **Collectors.summingDouble()** [to accumulate the data][13] for each measurement within the sample within the stratum.
5. Again, a Java lambda or anonymous function whose argument **c** is the array of fields, where this lambda has several lines of code that are surrounded by **{** and **}** with a **return** statement just before the **}**.
6. Calculate the mean crown radius of the measurement.
7. Calculate the crown area of the measurement as a proportion of the total sample area and return that value as the result of the lambda.
8. Again, similar to the previous task. The result looks like (with some numbers elided): [code]`sampleValues = {1={1=0.09083231861452731, 66=0.06088002082602869, ... 28=0.0837823490804228}, 2={65=0.14738326403381743, 2=0.16961183847374103, ... 63=0.25083064794883453}, 3={64=0.3306323635177101, 32=0.25911911184680053, ... 30=0.2642668470291564}}`
```
This output shows the **Map** of **Map**s structure clearly—there are three entries in the top level corresponding to the strata 1, 2, and 3, and each stratum has subentries corresponding to the proportional area of the sample covered by tree crowns.
#### Accumulate the sample totals into the stratum means and standard errors
At this point, the task becomes more complex; I need to count the number of samples, sum up the sample values in preparation for calculating the sample mean, and sum up the squares of the sample values in preparation for calculating the standard error of the mean. I may as well incorporate the stratum area into this grouping of data as well, as I'll need it shortly to weigh the stratum results together.
So the first thing to do is create a class, **StratumAccumulator**, to handle the accumulation and provide the calculation of the interesting results. This class implements **java.util.function.DoubleConsumer**, which can be passed to **collect()** to handle accumulation:
```
class StratumAccumulator implements DoubleConsumer {
    private double ha;
    private int n;
    private double sum;
    private double ssq;
    public StratumAccumulator(double ha) { // (1)
        this.ha = ha;
        this.n = 0;
        this.sum = 0d;
        this.ssq = 0d;
    }
    public void accept(double d) { // (2)
        this.sum += d;
        this.ssq += d*d;
        this.n++;
    }
    public void combine(StratumAccumulator other) { // (3)
        this.sum += other.sum;
        this.ssq += other.ssq;
        this.n += other.n;
    }
    public double getHa() {  // (4)
        return this.ha;
    }
    public int getN() {  // (5)
        return this.n;
    }
    public double getMean() {  // (6)
        return this.n &gt; 0 ? this.sum / this.n : 0d;
    }
    public double getStandardError() {  // (7)
        double mean = this.getMean();
        double variance = this.n &gt; 1 ? (this.ssq - mean*mean*n)/(this.n - 1) : 0d;
        return this.n &gt; 0 ? [Math][11].sqrt(variance/this.n) : 0d;
    }
}
```
Line-by-line:
1. The constructor **StratumAccumulator(double ha)** takes an argument, the area of the stratum in hectares, which allows me to merge the stratum area lookup table into instances of this class.
2. The **accept(double d)** method is used to accumulate the stream of double values, and I use it to:
a. Count the number of values.
b. Sum the values in preparation for computing the sample mean.
c. Sum the squares of the values in preparation for computing the standard error of the mean.
3. The **combine()** method is used to merge substreams of **StratumAccumulator**s (in case I want to process in parallel).
4. The getter for the area of the stratum
5. The getter for the number of samples in the stratum
6. The getter for the mean sample value in the stratum
7. The getter for the standard error of the mean in the stratum
Once I have this accumulator, I can use it to accumulate the sample values pertaining to each stratum:
```
final Map&lt;[Integer][6],StratumAccumulator&gt; stratumValues =   // (1)
    sampleValues.entrySet().stream()   // (2)
        .collect(                      // (3)
            Collectors.toMap(          // (4)
                e -&gt; e.getKey(),       // (5)
                e -&gt; e.getValue().entrySet().stream()   // (6)
                    .map([Map.Entry][14]::getValue)           // (7)
                    .collect(          // (8)
                        () -&gt; new StratumAccumulator(stratumAreas.get(e.getKey())),   // (9)
                        StratumAccumulator::accept,     // (10)
                        StratumAccumulator::combine)    // (11)
            )
        );
```
Line-by-line:
1. This time, I'm using the pipeline to build **stratumValues**, which is a **Map&lt;Integer,StratumAccumulator&gt;**, so **stratumValues.get(3)** will return the **StratumAccumulator** instance for stratum 3.
2. Here, I'm using the **entrySet().stream()** method provided by **Map** to get a stream of (key, value) pairs; recall these are **Map**s of sample values by stratum.
3. Again, I'm using **collect()** to gather the pipeline results by stratum…
4. using **Collectors.toMap()** to generate a stream of **Map** entries…
5. whose keys are the key of the incoming stream (that is, the stratum #)…
6. and whose values are the Map of sample values, and I again use **entrySet().stream()** to convert to a stream of Map entries, one for each sample.
7. Using **map()** to get the value of the sample **Map** entry; I'm not interested in the key by this point.
8. Yet again, using **collect()** to accumulate the sample results into the **StratumAccumulator** instances.
9. Telling **collect()** how to create a new **StratumAccumulator**—I need to pass the stratum area into the constructor here, so I can't just use **StratumAccumulator::new**.
10. Telling **collect()** to use the **accept()** method of **StratumAccumulator** to accumulate the stream of sample values.
11. Telling **collect()** to use the **combine()** method of **StratumAccumulator** to merge **StratumAccumulator** instances.
#### Summarize the stratum figures
Whew! After all of that, printing out the stratum figures is pretty straightforward:
```
stratumValues.entrySet().stream()
    .forEach(e -&gt; {
        StratumAccumulator sa = e.getValue();
        int n = sa.getN();
        double se66 = sa.getStandardError();
        double t = new TDistribution(n - 1).inverseCumulativeProbability(0.975d);
        [System][8].out.printf("stratum %d n %d mean %g se66 %g t %g se95 %g ha %g\n",
            e.getKey(), n, sa.getMean(), se66, t, se66 * t, sa.getHa());
    });
```
In the above, once again, I use **entrySet().stream()** to transform the **stratumValues** Map to a stream, and then apply the **forEach()** method to the stream. **ForEach()** is pretty much what it sounds like—a loop! But the business of finding the head of the stream, finding the next element, and checking to see if hits the end is all handled by Java Streams. So, I just get to say what I want to do for each record, which is basically to print it out.
My code looks a bit more complicated because I declare some local variables to hold some intermediate results that I use more than once—**n**, the number of samples, and **se66**, the standard error of the mean. I also calculate the inverse T value to [convert my standard error of the mean to a 95% confidence interval][15].
The result looks like this:
```
stratum 1 n 24 mean 0.0903355 se66 0.0107786 t 2.06866 se95 0.0222973 ha 114.890
stratum 2 n 38 mean 0.154612 se66 0.00880498 t 2.02619 se95 0.0178406 ha 207.720
stratum 3 n 11 mean 0.223634 se66 0.0261662 t 2.22814 se95 0.0583020 ha 29.7700
```
#### Accumulate the stratum means and standard errors into the total
Once again, the task becomes more complex, so I create a class, **TotalAccumulator**, to handle the accumulation and provide the calculation of the interesting results. This class implements **java.util.function.Consumer&lt;T&gt;**, which can be passed to **collect()** to handle accumulation:
```
class TotalAccumulator implements Consumer&lt;StratumAccumulator&gt; {
    private double ha;
    private int n;
    private double sumWtdMeans;
    private double ssqWtdStandardErrors;
    public TotalAccumulator() {
        this.ha = 0d;
        this.n = 0;
        this.sumWtdMeans = 0d;
        this.ssqWtdStandardErrors = 0d;
    }
    public void accept(StratumAccumulator sa) {
        double saha = sa.getHa();
        double sase = sa.getStandardError();
        this.ha += saha;
        this.n += sa.getN();
        this.sumWtdMeans += saha * sa.getMean();
        this.ssqWtdStandardErrors += saha * saha * sase * sase;
    }
    public void combine(TotalAccumulator other) {
        this.ha += other.ha;
        this.n += other.n;
        this.sumWtdMeans += other.sumWtdMeans;
        this.ssqWtdStandardErrors += other.ssqWtdStandardErrors;
    }
    public double getHa() {
        return this.ha;
    }
    public int getN() {
        return this.n;
    }
    public double getMean() {
        return this.ha &gt; 0 ? this.sumWtdMeans / this.ha : 0d;
    }
    public double getStandardError() {
        return this.ha &gt; 0 ? [Math][11].sqrt(this.ssqWtdStandardErrors) / this.ha : 0;
    }
}
```
I'm not going to go into much detail on this, since it's structurally pretty similar to **StratumAccumulator**. Of main interest:
1. The constructor takes no arguments, which simplifies its use.
2. The **accept()** method accumulates instances of **StratumAccumulator**, not **double** values, hence the use of the **Consumer&lt;T&gt;** interface.
3. As for the calculations, they are assembling a weighted average of the **StratumAccumulator** instances, so they make use of the stratum areas, and the formulas might look a bit strange to anyone who's not used to stratified sampling.
As for actually carrying out the work, it's easy-peasy:
```
final TotalAccumulator totalValues =
    stratumValues.entrySet().stream()
        .map([Map.Entry][14]::getValue)
        .collect(TotalAccumulator::new, TotalAccumulator::accept, TotalAccumulator::combine);
```
Same old stuff as before:
1. Use **entrySet().stream()** to convert the **stratumValue Map** entries to a stream.
2. Use **map()** to replace the **Map** entries with their values—the instances of **StratumAccumulator**.
3. Use **collect()** to apply the **TotalAccumulator** to the instances of **StratumAccumulator**.
#### Summarize the total figures
Getting the interesting bits out of the **TotalAccumulator** instance is also pretty straightforward:
```
int nT = totalValues.getN();
double se66T = totalValues.getStandardError();
double tT = new TDistribution(nT - stratumValues.size()).inverseCumulativeProbability(0.975d);
[System][8].out.printf("total n %d mean %g se66 %g t %g se95 %g ha %g\n",
    nT, totalValues.getMean(), se66T, tT, se66T * tT, totalValues.getHa());
```
Similar to the **StratumAccumulator**, I just call the relevant getters to pick out the number of samples **nT** and the standard error **se66T**. I calculate the T value **tT** (using "n 3" here since there are three strata), and then I print the result, which looks like this:
```
`total n 73 mean 0.139487 se66 0.00664653 t 1.99444 se95 0.0132561 ha 352.380`
```
### In conclusion
Wow, that looks like a bit of a marathon. It feels like it, too. As is often the case, there is a great deal of information about how to use Java Streams, all illustrated with toy examples, which kind of help, but not really. I found that getting this to work with a real-world (albeit very simple) example was difficult.
Because I've been working in [Groovy][16] a lot lately, I kept finding myself wanting to accumulate into "maps of maps of maps" rather than creating accumulator classes, but I was never able to pull that off except in the case of totaling up the measurements in the sample. So, I worked with accumulator classes instead of maps of maps, and maps of accumulator classes instead of maps of maps of maps.
I don't feel like any kind of master of Java Streams at this point, but I do feel I have a pretty solid understanding of **collect()**, which is deeply important, along with various methods to reformat data structures into streams and to reformat stream elements themselves. So yeah, more to learn!
Speaking of collect(), in the examples I presented above, we can see moving from a very simple use of this fundamental method - using the Collectors.summingDouble() accumulation method - through defining an accumulator class that extends one of the pre-defined interfaces - in this case DoubleConsumer - to defining a full-blown accumulator of our own, used to accumulate the intermediate stratum class. I was tempted - sort of - to work backward and implement fully custom accumulators for the stratum and sample accumulators, but the point of this exercise was to learn more about Java Streams, not to become an expert in one single part of it all.
What's your experience with Java Streams? Done anything big and complicated yet? Please share it in the comments.
Optimizing your Java code requires an understanding of how the different elements in Java interact...
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/2/java-streams
作者:[Chris Hermansen][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/clhermansen
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coffee_tea_laptop_computer_work_desk.png?itok=D5yMx_Dr (Person drinking a hat drink at the computer)
[2]: https://docs.oracle.com/javase/8/docs/api/java/util/stream/package-summary.html
[3]: https://opensource.com/sites/default/files/uploads/landcover.png (Image of land cover in an area)
[4]: https://opensource.com/sites/default/files/uploads/foresters.jpg (Survey team assessing land cover)
[5]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+string
[6]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+integer
[7]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+double
[8]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+system
[9]: https://www.baeldung.com/java-8-collectors
[10]: https://docs.oracle.com/javase/tutorial/java/javaOO/lambdaexpressions.html
[11]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+math
[12]: https://www.baeldung.com/java-groupingby-collector
[13]: http://www.java2s.com/Tutorials/Java/java.util.stream/Collectors/Collectors.summingDouble_ToDoubleFunction_super_T_mapper_.htm
[14]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+map.entry
[15]: https://en.wikipedia.org/wiki/Standard_error
[16]: http://groovy-lang.org/

View File

@ -0,0 +1,171 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Live video streaming with open source Video.js)
[#]: via: (https://opensource.com/article/20/2/video-streaming-tools)
[#]: author: (Aaron J. Prisk https://opensource.com/users/ricepriskytreat)
Live video streaming with open source Video.js
======
Video.js is a widely used protocol that will serve your live video
stream to a wide range of devices.
![video editing dashboard][1]
Last year, I wrote about [creating a video streaming server with Linux][2]. That project uses the Real-Time Messaging Protocol (RMTP), Nginx web server, Open Broadcast Studio (OBS), and VLC media player.
I used VLC to play our video stream, which may be fine for a small local deployment but isn't very practical on a large scale. First, your viewers have to use VLC, and RTMP streams can provide inconsistent playback. This is where [Video.js][3] comes into play! Video.js is an open source JavaScript framework for creating custom HTML5 video players. Video.js is incredibly powerful, and it's used by a host of very popular websites—largely due to its open nature and how easy it is to get up and running.
### Get started with Video.js
This project is based off of the video streaming project I wrote about last year. Since that project was set to serve RMTP streams, to use Video.js, you'll need to make some adjustments to that Nginx configuration. HTTP Live Streaming ([HLS][4]) is a widely used protocol developed by Apple that will serve your stream better to a multitude of devices. HLS will take your stream, break it into chunks, and serve it via a specialized playlist. This allows for a more fault-tolerant stream that can play on more devices.
First, create a directory that will house the HLS stream and give Nginx permission to write to it:
```
mkdir /mnt/hls
chown www:www /mnt/hls
```
Next, fire up your text editor, open the Nginx.conf file, and add the following under the **application live** section:
```
       application live {
            live on;
            # Turn on HLS
            hls on;
            hls_path /mnt/hls/;
            hls_fragment 3;
            hls_playlist_length 60;
            # disable consuming the stream from nginx as rtmp
            deny play all;
}
```
Take note of the HLS fragment and playlist length settings. You may want to adjust them later, depending on your streaming needs, but this is a good baseline to start with. Next, we need to ensure that Nginx is able to listen for requests from our player and understand how to present it to the user. So, we'll want to add a new section at the bottom of our nginx.conf file.
```
server {
        listen 8080;
        location / {
            # Disable cache
            add_header 'Cache-Control' 'no-cache';
            # CORS setup
            add_header 'Access-Control-Allow-Origin' '*' always;
            add_header 'Access-Control-Expose-Headers' 'Content-Length';
            # allow CORS preflight requests
            if ($request_method = 'OPTIONS') {
                add_header 'Access-Control-Allow-Origin' '*';
                add_header 'Access-Control-Max-Age' 1728000;
                add_header 'Content-Type' 'text/plain charset=UTF-8';
                add_header 'Content-Length' 0;
                return 204;
            }
            types {
                application/dash+xml mpd;
                application/vnd.apple.mpegurl m3u8;
                video/mp2t ts;
            }
            root /mnt/;
        }
    }
```
Visit Video.js's [Getting started][5] page to download the latest release and check out the release notes. Also on that page, Video.js has a great introductory template you can use to create a very basic web player. I'll break down the important bits of that template and insert the pieces you need to get your new HTML player to use your stream.
The **head** links in the Video.js library from a content-delivery network (CDN). You can also opt to download and store Video.js locally on your web server if you want.
```
&lt;head&gt;
  &lt;link href="<https://vjs.zencdn.net/7.5.5/video-js.css>" rel="stylesheet" /&gt;
  &lt;!-- If you'd like to support IE8 (for Video.js versions prior to v7) --&gt;
  &lt;script src="[https://vjs.zencdn.net/ie8/1.1.2/videojs-ie8.min.js"\&gt;\][6]&lt;/script&gt;
&lt;/head&gt;
```
Now to the real meat of the player. The **body** section sets the parameters of how the video player will be displayed. Within the **video** element, you need to define the properties of your player. How big do you want it to be? Do you want it to have a poster (i.e., a thumbnail)? Does it need any special player controls? This example defines a simple 600x600 pixel player with an appropriate (to me) thumbnail featuring Beastie (the BSD Demon) and Tux (the Linux penguin).
```
&lt;body&gt;
  &lt;video
    id="my-video"
    class="video-js"
    controls
    preload="auto"
    width="600"
    height="600"
    poster="BEASTIE-TUX.jpg"
    data-setup="{}"
  &gt;
```
Now that you've set how you want your player to look, you need to tell it what to play. Video.js can handle a large number of different formats, including HLS streams.
```
    &lt;source src="<http://MY-WEB-SERVER:8080/hls/STREAM-KEY.m3u8>" type="application/x-mpegURL" /&gt;
    &lt;p class="vjs-no-js"&gt;
      To view this video please enable JavaScript, and consider upgrading to a
      web browser that
      &lt;a href="<https://videojs.com/html5-video-support/>" target="_blank"
        &gt;supports HTML5 video&lt;/a
      &gt;
    &lt;/p&gt;
  &lt;/video&gt;
```
### Record your streams
Keeping a copy of your streams is super easy. Just add the following at the bottom of your **application live** section in the nginx.conf file:
```
# Enable stream recording
record all;
record_path /mnt/recordings/;
record_unique on;
```
Make sure that **record_path** exists and that Nginx has permissions to write to it:
```
`chown -R www:www /mnt/recordings`
```
### Down the stream
That's it! You should now have a spiffy new HTML5-friendly live video player. There are lots of great resources out there on how to expand all your video-making adventures. If you have any questions or suggestions, feel free to reach out to me on [Twitter][7] or leave a comment below.
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/2/video-streaming-tools
作者:[Aaron J. Prisk][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/ricepriskytreat
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/video_editing_folder_music_wave_play.png?itok=-J9rs-My (video editing dashboard)
[2]: https://opensource.com/article/19/1/basic-live-video-streaming-server
[3]: https://videojs.com/
[4]: https://en.wikipedia.org/wiki/HTTP_Live_Streaming
[5]: https://videojs.com/getting-started
[6]: https://vjs.zencdn.net/ie8/1.1.2/videojs-ie8.min.js"\>\
[7]: https://twitter.com/AKernelPanic

View File

@ -0,0 +1,245 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How to install TT-RSS on a Raspberry Pi)
[#]: via: (https://opensource.com/article/20/2/ttrss-raspberry-pi)
[#]: author: (Patrick H. Mullins https://opensource.com/users/pmullins)
How to install TT-RSS on a Raspberry Pi
======
Read your news feeds while keeping your privacy intact with Tiny Tiny
RSS.
![Raspberries with pi symbol overlay][1]
[Tiny Tiny RSS][2] (TT-RSS) is a free and open source web-based news feed (RSS/Atom) reader and aggregator. It's ideally suited to those who are privacy-focused and still rely on RSS for their daily news. Tiny Tiny RSS is self-hosted software, so you have 100% control of the server, your data, and your overall privacy. It also supports a wide range of plugins, add-ons, and themes, Want a dark mode interface? No problem. Want to filter your incoming news based on keywords? TT-RSS has you covered there, as well.
![Tiny Tiny RSS screenshot][3]
Now that you know what TT-RSS is and why you may want to use it, I'll explain everything you need to know about installing it on a Raspberry Pi or a Debian 10 server.
### Install and configure TT-RSS
To install TT-RSS on a Raspberry Pi, you must also install and configure the latest version of PHP (7.3 as of this writing), PostgreSQL for the database backend, the Nginx web server, Git, and finally, TT-RSS.
#### 1\. Install PHP 7
Installing PHP 7 is, by far, the most involved part of this process. Thankfully, it's not as difficult as it might appear. Start by installing the following support packages:
```
`$ sudo apt install -y ca-certificates apt-transport-https`
```
Now, add the repository PGP key:
```
`$ wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -`
```
Next, add the PHP repository to your apt sources:
```
`$ echo "deb https://packages.sury.org/php/ buster main" | sudo tee /etc/apt/sources.list.d/php.list`
```
Then update your repository index:
```
`$ sudo apt update`
```
Finally, install PHP 7.3 (or the latest version) and some common components:
```
`$ sudo apt install -y php7.3 php7.3-cli php7.3-fpm php7.3-opcache php7.3-curl php7.3-mbstring php7.3-pgsql php7.3-zip php7.3-xml php7.3-gd php7.3-intl`
```
The command above assumes you're using PostgreSQL as your database backend and installs **php7.3-pgsql**. If you'd rather use MySQL or MariaDB, you can easily change this to **php7.3-mysql**.
Next, verify that PHP is installed and running on your Raspberry Pi:
```
`$ php -v`
```
Now it's time to install and configure the webserver.
#### 2\. Install Nginx
Nginx can be installed via apt with:
```
`$ sudo apt install -y nginx`
```
Modify the default Nginx virtual host configuration so that the webserver will recognize PHP files and know what to do with them:
```
`$ sudo nano /etc/nginx/sites-available/default`
```
You can safely delete everything in the original file and replace it with:
```
server {
        listen 80 default_server;
        listen [::]:80 default_server;
        root /var/www/html;
        index index.html index.htm index.php;
        server_name _;
        location / {
                try_files $uri $uri/ =404;
        }
        location ~ \\.php$ {
          include snippets/fastcgi-php.conf;
          fastcgi_pass unix:/run/php/php7.3-fpm.sock;
        }
}
```
Use **Ctrl+O** to save your new configuration file and then **Ctrl+X** to exit Nano. You can test your new configuration with:
```
`$ nginx -t`
```
If there are no errors, restart the Nginx service:
```
`$ systemctl restart nginx`
```
#### 3\. Install PostgreSQL
Next up is installing the database server. Installing PostgreSQL on the Raspberry Pi is super easy:
```
`$ sudo apt install -y postgresql postgresql-client postgis`
```
Check to see if the database server was successfully installed by entering:
```
`$ psql --version`
```
#### 4\. Create the Tiny Tiny RSS database
Before you can do anything else, you need to create a database that the TT-RSS software will use to store data. First, log into the PostgreSQL server:
```
`sudo -u postgres psql`
```
Next, create a new user and assign a password:
```
`CREATE USER username WITH PASSWORD 'your_password' VALID UNTIL 'infinity';`
```
Then create the database that will be used by TT-RSS:
```
`CREATE DATABASE tinyrss;`
```
Finally, grant full permissions to the new user:
```
`GRANT ALL PRIVILEGES ON DATABASE tinyrss to user_name;`
```
That's it for the database. You can exit the **psql** app by typing **\q**.
#### 5\. Install Git
Installing TT-RSS requires Git, so install Git with:
```
`$ sudo apt install git -y`
```
Now, change directory to wherever Nginx serves web pages:
```
`$ cd /var/www/html`
```
Then download the latest source for TT-RSS:
```
`$ git clone https://git.tt-rss.org/fox/tt-rss.git tt-rss`
```
Note that this process creates a new **tt-rss** folder.
#### 6\. Install and configure Tiny Tiny RSS
It's finally time to install and configure your new TT-RSS server. First, verify that you can open **<http://your.site/tt-rss/install/index.php>** in a web browser. If you get a **403 Forbidden** error, your permissions are not set properly on the **/var/www/html** folder. The following will usually fix this issue:
```
`$ chmod 755 /var/www/html/ -v`
```
If everything goes as planned, you'll see the TT-RSS Installer page, and it will ask you for some database information. Just tell it the database username and password that you created earlier; the database name; **localhost** for the hostname; and **5432** for the port.
Click **Test Configuration** to continue. If all went well, you should see a red button labeled **Initialize Database.** Click on it to begin the installation. Once finished, you'll have a configuration file that you can copy and save as **config.php** in the TT-RSS directory.
After finishing with the installer, open your TT-RSS installation at **<http://yoursite/tt-rss/>** and log in with the default credentials (username: **admin**, password: **password**). The system will recommend that you change the admin password as soon as you log in. I highly recommend that you follow that advice and change it as soon as possible.
### Set up TT-RSS
If all went well, you can start using TT-RSS right away. It's recommended that you create a new non-admin user, log in as the new user, and start importing your feeds, subscribing, and configuring it as you see fit.
Finally, and this is super important, don't forget to read the [Updating Feeds][4] section on TT-RSS's wiki. It describes how to create a simple systemd service that will update your feeds. If you skip this step, your RSS feeds will not update automatically.
### Conclusion
Whew! That was a lot of work, but you did it! You now have your very own RSS aggregation server. Want to learn more about TT-RSS? I recommend checking out the official [FAQ][5], the [support][6] forum, and the detailed [installation][7] notes. Feel free to comment below if you have any questions or issues.
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/2/ttrss-raspberry-pi
作者:[Patrick H. Mullins][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/pmullins
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/life-raspberrypi_0.png?itok=Kczz87J2 (Raspberries with pi symbol overlay)
[2]: https://tt-rss.org/
[3]: https://opensource.com/sites/default/files/uploads/tt-rss.jpeg (Tiny Tiny RSS screenshot)
[4]: https://tt-rss.org/wiki/UpdatingFeeds
[5]: https://tt-rss.org/wiki/FAQ
[6]: https://community.tt-rss.org/c/tiny-tiny-rss/support
[7]: https://tt-rss.org/wiki/InstallationNotes

View File

@ -0,0 +1,272 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (17 Cool Arduino Project Ideas for DIY Enthusiasts)
[#]: via: (https://itsfoss.com/cool-arduino-projects/)
[#]: author: (Ankush Das https://itsfoss.com/author/ankush/)
17 Cool Arduino Project Ideas for DIY Enthusiasts
======
[Arduino][1] is an open-source electronics platform that combines both open source software and hardware to let people make interactive projects with ease. You can get Arduino-compatible [single board computers][2] and use them to make something useful.
In addition to the hardware, you will also need to know the [Arduino language][3] to use the [Arduino IDE][4] to successfully create something.
You can code using the web editor or use the Arduino IDE offline. Nevertheless, you can always refer to the [official resources][5] available to learn about Arduino.
Considering that you know the essentials, I will be mentioning some of the best (or interesting) Arduino projects. You can try to make them for yourself or modify them to come up with something of your own.
### Interesting Arduino project ideas for beginners, experts, everyone
![][6]
The following projects need a variety of additional hardware so make sure to check out the official link to the projects (_originally featured on the [official Arduino Project Hub][7]_) to learn more about them.
Also, it is worth noting that they arent particularly in any ranking order so feel free to try what sounds best to you.
#### 1\. LED Controller
Looking for simple Arduino projects? Heres one for you.
One of the easiest projects that let you control LED lights. Yes, you do not have to opt for expensive LED products just to decorate your room (or for any other use-case), you can simply make an LED controller and customize it to use it however you want.
It requires using the [Arduino UNO board][8] and a couple more things (which also includes an Android phone). You can learn more about it in the link to the project below.
[LED Controller][9]
#### 2\. Hot Glue LED Matrix Lamp
![][10]
Another Arduino LED project for you. Since we are talking about using LEDs to decorate, you can also make an LED lamp that looks beautiful.
For this, you might want to make sure that you have a 3D printer. Next, you need an LED strip and **Arduino Nano R3** as the primary materials.
Once youve printed the case and assembled the lamp section, all you need to do is to add the glue sticks and figure out the wiring. It does sound very simple to mention you can learn more about it on the official Arduino project feature site.
[LED Matrix Lamp][11]
#### 3\. Arduino Mega Chess
![][12]
Want to have a personal digital chessboard? Why not?
Youll need a TFT LCD touch screen display and an [Arduino Mega 2560][13] board as the primary materials. If you have a 3D printer, you can create a pretty case for it and make changes accordingly.
Take a look at the original project for inspiration.
[Arduino Mega Chess][14]
#### 4\. Enough Already: Mute My TV
A very interesting project. I wouldnt argue the usefulness of it but if youre annoyed by certain celebrities (or personalities) on TV, you can simply mute their voice whenever theyre about to speak something on TV.
Technically, it was tested with the old tech back then (when you didnt really stream anything). You can watch the video above to get an idea and try to recreate it or simply head to the link to read more about it.
[Mute My TV][15]
#### 5\. Robot Arm with Controller
![][16]
If you want to do something with the help of your robot and still have manual control over it, the robot arm with a controller is one of the most useful Arduino projects. It uses the [Arduino UNO board][8] if youre wondering.
You will have a robot arm -for which you can make a case using the 3D printer to enhance its usage and you can use it for a variety of use-cases. For instance, to clean the carbage using the robot arm or anything similar where you dont want to directly intervene.
[Robotic Arm With Controller][17]
#### 6\. Make Musical Instrument Using Arduino
Ive seen a variety of musical instruments made using Arduino. You can explore the Internet if you want something different than this.
You would need a [Pi supply flick charge][18] and an **Arduino UNO** to make it happen. It is indeed a cool Arduino project where you get to simply tap and your hand waves will be converted to music. Also, it isnt tough to make this so you should have a lot of fun making this.
[Musical Instrument using Arduino][19]
#### 7\. Pet Trainer: The MuttMentor
An Arduino-based device that assists you to help train your pet sounds exciting!
For this, theyre using the [Arduino Nano 33 BLE Sense][20] while utilizing TensorFlow to train a small neural network for all the common actions that your pet does. Accordingly, the buzzer will offer a reinforcing notification when your pet obeys your command.
This can have wide applications when tweaked as per your requirements. Check out the details below.
[The MuttMentor][21]
#### 8\. Basic Earthquake Detector
Normally, you depend on the government officials to announce/inform about the earthquake stats (or the warning for it).
But with Arduino boards, you can simply build a basic earthquake detector and have transparent results for yourself without depending on the authorities. Click on the button below to know about the relevant details to help make it.
[Basic Earthquake Detector][22]
#### 9\. Security Access Using RFID Reader
![][23]
As the project describes “_RFID tagging is an ID system that uses small radio frequency identification_ “.
So, in this project, you will be making an RFID reader using Arduino while pairing it with an [Adafruit NFC card][24] for security access. Check out the full details using the button below and let me know how it works for you.
[Security Access using RFID reader][25]
#### 10\. Smoke Detection using MQ-2 Gas Sensor
![][26]
This could be potentially one of the best Arduino projects out there. You dont need to spend a lot of money to equip smoke detectors for your home, you can manage with a DIY solution to some extent.
Of course, unless you want a complex failsafe set up along with your smoke detector, a basic inexpensive solution should do the trick. In either case, you can also find other applications for the smoke detector.
[Smoke Detector][27]
#### 11\. Arduino Based Amazon Echo using 1Sheeld
![][28]
In case you didnt know [1Sheeld][29] basically replaces the need for an add-on Arduino board. You just need a smartphone and add Arduino shields to it so that you can do a lot of things with it.
Using 5 such shields, the original creator of this project made himself a DIY Amazon Echo. You can find all the relevant details, schematics, and code to make it happen.
[DIY Amazon Echo][30]
#### 12\. Audio Spectrum Visualizer
![][31]
Just want to make something cool? Well, heres an idea for an audio spectrum visualizer.
For this, you will need an Arduino Nano R3 and an LED display as primary materials to get started with. You can tweak the display as required. You can connect it with your headphone output or simply a line-out amplifier.
Easily one of the cheapest Arduino projects that you can try for fun.
[Audio Spectrum Visualizer][32]
#### 13\. Motion Following Motorized Camera
![][33]
Up for a challenge? If you are this will be one of the coolest Arduino Projects in our list.
Basically, this is meant to replace your home security camera which is limited to an angle of video recording. You can turn the same camera into a motorized camera that follows the motion.
So, whenever it detects a movement, it will change its angle to try to follow the object. You can read more about it to find out how to make it.
[Motion Following Motorized Camera][34]
#### 14\. Water Quality Monitoring System
![][35]
If youre concerned about your health in connection to the water you drink, you can try making this.
It requires an Arduino UNO and the water quality sensors as the primary materials. To be honest, a useful Arduino project to go for. You can find everything you need to make this in the link below.
[Water Quality Monitoring System][36]
#### 15\. Punch Activated Arm Flamethrower
I would be very cautious about this but seriously, one of the best (and coolest) Arduino projects Ive ever come across.
Of course, this counts as a fun project to try out to see what bigger projects you can pull off using Arduino and here it is. In the project, he originally used the [SparkFun Arduino Pro Mini 328][37] along with an accelerometer as the primary materials.
[Punch Activated Flamethrower][38]
#### 16\. Polar Drawing Machine
![][39]
This isnt any ordinary plotter machine that you mightve seen people creating using Arduino boards.
With this, you can draw some cool vector graphics images or bitmap. It might sound like bit of overkill but then it could also be fun to do something like this.
This could be a tricky project, so you can refer to the details on the link to go through it thoroughly.
[Polar Drawing Machine][40]
#### 17\. Home Automation
Technically, this is just a broad project idea because you can utilize the Arduino board to automate almost anything you want at your home.
Just like I mentioned, you can go for a security access device, maybe create something that automatically waters the plants or simply make an alarm system.
Countless possibilities of what you can do to automate things at your home. For reference, Ive linked to an interesting home automation project below.
[Home Automation][41]
#### Bonus: Robot Cat (OpenCat)
![][42]
A programmable robotic cat for AI-enhanced services and STEM education. In this project, both Arduino and Raspberry Pi boards have been utilized.
You can also look at the [Raspberry Pi alternatives][2] if you want. This project needs a lot of work, so you would want to invest a good amount of time to make it work.
[OpenCat][43]
**Wrapping Up**
With the help of Arduino boards (coupled with other sensors and materials), you can do a lot of projects with ease. Some of the projects that Ive listed above are suitable for beginners and some are not. Feel free to take your time to analyze what you need and the cost of the project before proceeding.
Did I miss listing an interesting Arduino project that deserves the mention here? Let me know your thoughts in the comments.
--------------------------------------------------------------------------------
via: https://itsfoss.com/cool-arduino-projects/
作者:[Ankush Das][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/ankush/
[b]: https://github.com/lujun9972
[1]: https://www.arduino.cc/
[2]: https://itsfoss.com/raspberry-pi-alternatives/
[3]: https://www.arduino.cc/reference/en/
[4]: https://www.arduino.cc/en/main/software
[5]: https://www.arduino.cc/en/Guide/HomePage
[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/02/arduino-project-ideas.jpg?ssl=1
[7]: https://create.arduino.cc/projecthub
[8]: https://store.arduino.cc/usa/arduino-uno-rev3
[9]: https://create.arduino.cc/projecthub/mayooghgirish/arduino-bluetooth-basic-tutorial-d8b737?ref=platform&ref_id=424_trending___&offset=89
[10]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/02/led-matrix-lamp.jpg?ssl=1
[11]: https://create.arduino.cc/projecthub/john-bradnam/hot-glue-led-matrix-lamp-42322b?ref=platform&ref_id=424_trending___&offset=42
[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/02/arduino-chess-board.jpg?ssl=1
[13]: https://store.arduino.cc/usa/mega-2560-r3
[14]: https://create.arduino.cc/projecthub/Sergey_Urusov/arduino-mega-chess-d54383?ref=platform&ref_id=424_trending___&offset=95
[15]: https://makezine.com/2011/08/16/enough-already-the-arduino-solution-to-overexposed-celebs/
[16]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/02/robotic-arm-controller.jpg?ssl=1
[17]: https://create.arduino.cc/projecthub/H0meMadeGarbage/robot-arm-with-controller-2038df?ref=platform&ref_id=424_trending___&offset=13
[18]: https://uk.pi-supply.com/products/flick-hat-3d-tracking-gesture-hat-raspberry-pi
[19]: https://create.arduino.cc/projecthub/lanmiLab/make-musical-instrument-using-arduino-and-flick-large-e2890b?ref=platform&ref_id=424_trending___&offset=24
[20]: https://store.arduino.cc/usa/nano-33-ble-sense
[21]: https://create.arduino.cc/projecthub/whatsupdog/the-muttmentor-9d9753?ref=platform&ref_id=424_trending___&offset=44
[22]: https://www.instructables.com/id/Basic-Arduino-Earthquake-Detector/
[23]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/02/security-access-arduino.jpg?ssl=1
[24]: https://www.adafruit.com/product/359
[25]: https://create.arduino.cc/projecthub/Aritro/security-access-using-rfid-reader-f7c746?ref=platform&ref_id=424_trending___&offset=85
[26]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/02/smoke-detection-arduino.jpg?ssl=1
[27]: https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a?ref=platform&ref_id=424_trending___&offset=89
[28]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/02/diy-amazon-echo.jpg?ssl=1
[29]: https://1sheeld.com/
[30]: https://create.arduino.cc/projecthub/ahmedismail3115/arduino-based-amazon-echo-using-1sheeld-84fa6f?ref=platform&ref_id=424_trending___&offset=91
[31]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/02/audio-spectrum-visualizer.jpg?ssl=1
[32]: https://create.arduino.cc/projecthub/Shajeeb/32-band-audio-spectrum-visualizer-analyzer-902f51?ref=platform&ref_id=424_trending___&offset=87
[33]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/02/motion-following-camera.jpg?ssl=1
[34]: https://create.arduino.cc/projecthub/lindsi8784/motion-following-motorized-camera-base-61afeb?ref=platform&ref_id=424_trending___&offset=86
[35]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/02/water-quality-monitoring.jpg?ssl=1
[36]: https://create.arduino.cc/projecthub/chanhj/water-quality-monitoring-system-ddcb43?ref=platform&ref_id=424_trending___&offset=93
[37]: https://www.sparkfun.com/products/11113
[38]: https://create.arduino.cc/projecthub/Advanced/punch-activated-arm-flamethrowers-real-firebending-95bb80
[39]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/02/polar-drawing-machine.jpg?ssl=1
[40]: https://create.arduino.cc/projecthub/ArduinoFT/polar-drawing-machine-f7a05c?ref=search&ref_id=drawing&offset=2
[41]: https://create.arduino.cc/projecthub/ahmedel-hinidy2014/home-management-system-control-your-home-from-a-website-076846?ref=search&ref_id=home%20automation&offset=4
[42]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/02/opencat.jpg?ssl=1
[43]: https://create.arduino.cc/projecthub/petoi/opencat-845129?ref=platform&ref_id=424_popular___&offset=8

View File

@ -0,0 +1,243 @@
[#]: collector: (lujun9972)
[#]: translator: (lujun9972)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Fun and Games in Emacs)
[#]: via: (https://www.masteringemacs.org/article/fun-games-in-emacs)
[#]: author: (Mickey Petersen https://www.masteringemacs.org/about)
Emacs 中的游戏与乐趣
======
又是周一,你正在为你的老板 Lumbergh 努力倒腾那些 [无聊之极的文档 ][1]。为什么不玩玩 Emacs 中类似 zork 的文本冒险游戏来让你的大脑从单调的工作中解脱出来呢?
但说真的Emacs 中既有游戏,也有古怪的玩物。有些你可能有所耳闻。这些玩意唯一的共同点就是,它们大多是很久以前就添加到 Emacs 中的:有些东西真的是相当古怪(如您将在下面看到的),而另一些则显然是由无聊的员工或毕业生编写的。
它们中都带着一种奇思妙想和随意性,这在今天的 Emacs 中很少见。
Emacs 现在变得十分严肃,在某种程度上,它已经与 20 世纪 80 年代那些玩意被编写出来的时候大不一样。
### 汉诺塔
[汉诺塔 ][2] 是一款古老的数学解密游戏,有些人可能对它很熟悉,因为它的递归和迭代解决方案经常被用与计算机科学教学辅助。
![Tower of Hanoi Screenshot](https://www.masteringemacs.org/static/uploads/hanoi.png)
Emacs 中有三个命令可以运行汉诺塔:`M-x hanoi` 默认为 3 个碟子; `M-x hanoi-unix``M-x hanoi-unix-64` 使用 unix 时间戳的位数 (32bit 或 64bit) 作为默认盘子的个数,并且每秒钟自动移动一次,两者不同之处在于后者假装使用 64 位时钟(因此有 64 个碟子)。
Emacs 中汉诺塔的实现可以追溯到 20 世纪 80 年代中期——确实是久得可怕。它有一些自定义选项 (`M-x customize-group RET hanoi RET`),如启用彩色光盘等。
当你离开汉诺塔缓冲区或输入一个字符,你会收到一个讽刺的告别信息(见上文)。
### 5x5
![5x5 game grid](https://www.masteringemacs.org/static/uploads/5x5.png)
5x5 的游戏是一个逻辑解密游戏:你有一个 5x5 的网格,中间的十字被填满;你的目标是通过按正确的顺序切换它们的空满状态来填充所有的单元格,从而获得胜利。这并不像听起来那么容易!
输入 `M-x 5x5` 就可以开始玩了,使用可选的数字参数可以改变网格的大小。
这款游戏的有趣之处在于它能向你建议下一步行动并尝试解决该游戏网格。它用到了了 Emacs 自己的一款非常酷的符号 RPN 计算器 `M-x calc` (在 [Fun with Emacs Calc][3] 这篇文章中,我使用它来解决了一个简单的问题。)
所以我喜欢这个游戏的原因是它提供了一个非常复杂的解决器——真的,你应该通过 `M-x find-library RET 5x5` 来阅读其源代码——和一个试图通过强力破解游戏的“破解器”。
创建一个更大的游戏网格,例如输入 `M-10 M-x 5x5`,然后运行下面某个 `crack` 命令。破坏者将尝试通过迭代获得最佳解决方案。它会实时运行该游戏,观看起来非常有趣:
- `M-x 5x5-crack-mutating-best`: 试图通过修改最佳解决方案来破解 5x5。
- `M-x 5x5-crack-mutating-current`: 试图通过修改当前解决方案来破解 5x5。
- `M-x 5x5-crack-random`: 尝试使用随机方案解破解 5x5。
- `M-x 5x5-crack-xor-mutate`: 尝试通过将当前方案和最佳方案进行异或运算来破解 5x5。
### 文本动画
您可以通过运行 `M-x animation-birthday-present` 并给出名字来显示一个奇特的生日礼物动画。它看起来很酷!
![xkcd](https://imgs.xkcd.com/comics/real_programmers.png)
`M-x butterfly` 命令中也使用了 `animate`butterfly 命令被添加到 Emacs 中,以向上面的 [XKCD][4] 漫画致敬。当然,漫画中的 Emacs 命令在技术上是无效的,但它的幽默足以弥补这一点。
### 黑箱
我将逐字引用这款游戏的目标:
> 游戏的目标是通过向黑盒子发射光线来找到四个隐藏的球。有四种可能:
> 1) 射线将通过盒子不受干扰,
> 2) 它将击中一个球并被吸收,
> 3) 它将偏转并退出盒子,或
> 4) 立即偏转,甚至不被允许进入盒子。
所以,这有点像我们小时候玩的 [Battleship][5],但是……是专为物理专业高学历的人准备的?
这是另一款添加于 20 世纪 80 年代的游戏。我建议你输入 `C-h f blackbox` 来阅读玩法说明(文档巨大)。
### 泡泡
![Bubbles game](https://www.masteringemacs.org/static/uploads/bubbles.png)
`M-x bubble` 游戏相当简单:你必须用尽可能少移动清除尽可能多的“泡泡”。当你移除气泡时,其他气泡会掉落并粘在一起。
这是一款有趣的游戏,此外如果你使用 Emacs 的图形用户界面,它还支持图像现实。而且它还支持鼠标。
您可以通过调用 `M-x bubbles-set-game-< 难度>` 来设置难度,其中嗯 `<难度>` 可以是其中之一:`easy``medium==difficult``hard`,或 `userdefined`
此外,您可以使用:`M-x custom-group bubbles` 来更改图形、网格大小和颜色。
由于它即简单又有趣,这是 Emacs 中我最喜欢的游戏之一。
### 幸运饼干
我喜欢 `fortune` 命令。每当我启动一个新 shell 时,就会有刻薄、无益、常常带有讽刺意味的“建议(以及文学摘要,谜语)”就会点亮我的一天。
令人困惑的是Emacs 中有两个包做了类似的事情:`fortune` 和 `cookie`。前者主要用于在电子邮件签名中添加幸运饼干消息,而后者只是一个简单的 fortune 格式阅读器。
不管怎样,使用 Emacs 的 `cookie` 包前,你首先需要通过 `customize-option RET cookie RET` 来自定义变量 `cookie-file` 告诉它从哪找到 fortune 文件。
如果你的操作系统是 Ubuntu那么你先安装 `fortune` 软件包,然后就能在 `/usr/share/games/fortune/` 目录中找到这些文件了。
之后你就可以调用 `M-x cookie` 随机显示 fortune 内容,或者,如果你想的话,也可以调用 `M-x cookie-apropos` 查找所有匹配的 cookie。
### Decipher
这个包完美地抓住了 Emacs 的实用本质:这个包为你破解简单的替换密码(如密码谜题)提供了一个很有用的界面。
你知道,二十多年前,某人确实迫切需要破解很多基础密码。正是像这个模块这样的小玩意让我非常高兴地用起 Emacs 来:这个模块只对少数人有用,但是,如果你突然需要它了,那么它就在那里等着你。
那么如何使用它呢?让我们假设使用 “rot13” 密码:在 26 个字符的字母表中,将字符旋转 13 个位置。
通过 `M-x ielm` (Emacs 用于 [运行 Elisp][6] 的 REPL 环境)可以很容易在 Emacs 中进行尝试:
```
*** Welcome to IELM *** Type (describe-mode) for help.
ELISP> (rot13 "Hello, World")
"Uryyb, Jbeyq"
ELISP> (rot13 "Uryyb, Jbeyq")
"Hello, World"
ELISP>
```
那么decipher 模块又是如何帮助我们的呢?让我们创建一个新的缓冲区 `test-cipher` 并输入您的密码文本(在我的例子中是 `UryybJbeyq`)
![cipher](https://www.masteringemacs.org/static/uploads/cipher.png)
您现在面对的是一个相当复杂的接口。现在把光标放在紫行秘文中的任意字符上猜猜这个字符可能是什么Emacs 将根据你的选择更新其他明文的猜测结果,并告诉你字母表中的字符是如何分配的。
您现在可以下面各种 helper 命令来帮助推断密码字符可能对应的明文字符:
- **`D`:** 显示数字符号(密码中两个字符组合)及其频率的列表
- **`F`:** 表示每个密文字母的频率
- **`N`:** 显示字符的邻接信息。我不确定这是干啥的。
- **`M``R`:** 保存和恢复一个检查点,允许你对工作进行分支以探索破解密码的不同方法。
总而言之,对于这样一个深奥的任务,这个包是相当令人印象深刻的!如果你经常破解密码,也许这个程序包能帮上忙?
### 医生
![doctor](https://www.masteringemacs.org/static/uploads/doctor.png)
Emacs 医生。其基于最初的 [ELIZA][7],“ 医生”试图对你说的话进行心理分析,并试图把问题复述给你。体验它的那几分钟相当有趣,它也是 Emacs 中最著名的古怪玩意之一。你可以使用 `M-x doctor` 来运行它。
### Dunnet
Emacs 自己特有的类 Zork 文本冒险游戏。输入 `M-x dunnet` 就能玩了。
这是一款相当不错的游戏,虽然时间不长,但非常著名,很少有人真正玩到最后。
如果你发现自己能在无聊的文档工作之间空出时间来,那么这是一个超级棒的游戏,内置“老板屏幕”,因为它是纯文本的。
哦,还有,不要吃掉那块 CPU 卡 :)
### 五子棋
![gomoku](https://www.masteringemacs.org/static/uploads/gomoku.png)
另一款写于 20 世纪 80 年代的游戏。你必须连接 5 个方块,井字游戏风格。你可以运行 `M-x gomoku` 来与 Emacs 对抗。游戏还支持鼠标,非常方便。您也可以自定义 `gomoku` 组来调整网格的大小。
### 生命游戏
[Conway 的生命游戏 ][8] 是细胞自动机的一个著名例子。Emacs 版本提供了一些启动模式,你可以(通过 elisp 编程)通过调整 `life-patterns` 变量来更改这些模式。
你可以用 `M-x life` 触发生命游戏。事实上,所有的东西,包括代码,注释和所有的东西,总共不到 300 行,这也让人印象深刻。
### 乒乓,贪吃蛇和俄罗斯方块
![tetris](https://www.masteringemacs.org/static/uploads/tetris.png)
这些经典游戏都是使用 Emacs 包 `gamegrid` 实现的,这是一个用于构建网格游戏(如俄罗斯方块和贪吃蛇)的通用框架。gamegrid 包的伟大之处在于它同时兼容图形化和终端 Emacs: 如果你在 GUI 中运行 Emacs你会得到精美的图形;如果你没有,你得到简单的 ASCII 艺术。
你可以通过输入 `M-x pong``M-x snake``M-x tetris` 来运行这些游戏。
特别是俄罗斯方块游戏实现的非常到位,会逐渐增加速度并且能够滑块。而且既然你已经有了源代码,你完全可以移除那个讨厌的 Z 形块,没人喜欢它!
### Solitaire
![solitaire image](https://www.masteringemacs.org/static/uploads/solitaire.png)
可惜,这不是纸牌游戏,而是一个基于 peg 的游戏,你可以选择一块石头 (`o`) 并“跳过”相邻的石头进入洞中(`。`),并在这个过程中去掉你跳过的那些石头,最终只能在棋盘上留下一块石头,
重复该过程直到板子被请空(只保留一个石头)。
如果你卡住了,有一个内置的解题器名为 `M-x solitire-solve`
### Zone
我的另一个最爱。这是一个屏幕保护程序——或者更确切地说,是一系列的屏幕保护程序。
输入 `M-x zone`,然后看看屏幕上发生了什么!
您可以通过运行 `M-x zone-when-idle` (或从 elisp 调用它)来配置屏幕保护程序的空闲时间,时间以秒为单位。
您也可以通过 `M-x zone-leave-me-alone` 来关闭它。
如果它在你的同事看着的时候被启动,你的同事肯定会抓狂的。
### 乘法解谜
![mpuz](https://www.masteringemacs.org/static/uploads/mpuz.png)
这是另一个脑筋急转弯的益智游戏。当您运行 `M-x mpuz` 时,将看到一个乘法解谜题,你必须将字母替换为对应的数字,并确保数字相加(相乘?)符合结果
如果遇到难题,可以运行 `M-x mpuz-show-solution` 来解决。
### 杂项
还有更多好玩的东西,但它们就不如刚才那些那么好玩好用了:
- 你可以通过 `M-x morse-region``M-x unmorse-region` 将一个区域翻译成莫尔斯电码。
- Dissociated Press 是一个非常简单的命令,它将类似随机游动 markov 链生成器应用到 buffer 中的文本中,并以此生成无意义的文本。试一下 `M-x dissociated-press`
- Gamegrid 包是构建网格游戏的通用框架。到目前为止,只有俄罗斯方块,乒乓和贪吃蛇使用了它。其名为 `gamegrid`
- `gametree` 软件包是一个通过电子邮件记录和跟踪国际象棋游戏的复杂方法。
- `M-x spook` 命令插入随机单词(通常是在电子邮件中),目的是混淆/超载 “NSA trukn trawler”—— 记住,这个模块可以追溯到 20 世纪 80 年代和 90 年代——那时应该有间谍们在监听各种单词。当然,即使是在十年前,这样做也会显得非常偏执和古怪,不过现在看来已经不那么奇怪了……
### 结论
我喜欢 Emacs 附带的游戏和玩具。它们大多来自于,嗯,我们姑且称之为一个不同的时代:一个允许或甚至鼓励奇思妙想的时代。
有些玩意非常经典(如俄罗斯方块和汉诺塔),有些对经典游戏进行了有趣的变种(如黑盒)——但我很高兴这么多年后他们依然在 Emacs 中。
我想知道时至今日,这些玩意是否还会纳入 Emacs 的代码库中;嗯,它们很可能不会——它们将被归入包管理仓库中,而在这个干净而贫瘠的世界中,它们无疑属于包管理仓库。
Emacs 要求将对 Emacs 体验不重要的内容转移到包管理仓库 ELPA 中。我的意思是,作为一个开发者,这是有道理的,但是……对于每一个被移出并流放到 ELPA 的包,我们都在蚕食 Emacs 的精髓。
--------------------------------------------------------------------------------
via: https://www.masteringemacs.org/article/fun-games-in-emacs
作者:[Mickey Petersen][a]
选题:[lujun9972][b]
译者:[lujun9972](https://github.com/lujun9972)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://www.masteringemacs.org/about
[b]:https://github.com/lujun9972
[1]:https://en.wikipedia.org/wiki/Office_Space
[2]:https://en.wikipedia.org/wiki/Tower_of_Hanoi
[3]:https://www.masteringemacs.org/article/fun-emacs-calc
[4]:http://www.xkcd.com
[5]:https://en.wikipedia.org/wiki/Battleship_(game)
[6]:https://www.masteringemacs.org/article/evaluating-elisp-emacs
[7]:https://en.wikipedia.org/wiki/ELIZA
[8]:https://en.wikipedia.org/wiki/Conway's_Game_of_Life

View File

@ -0,0 +1,161 @@
[#]: collector: (lujun9972)
[#]: translator: (lujun9972)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Some Advice for How to Make Emacs Tetris Harder)
[#]: via: (https://nickdrozd.github.io/2019/01/14/tetris.html)
[#]: author: (nickdrozd https://nickdrozd.github.io)
让 Emacs 俄罗斯方块变得更难的一些建议 (Advice)
======
你知道吗,**Emacs** 与 **俄罗斯方块** 的实现捆绑在一起了?只需要输入 `M-x tetris` 就行了。
![img](https://nickdrozd.github.io/assets/2019-01-14-tetris/tetris-normal.png)
在文本编辑器讨论中Emacs 倡导者经常提到这一点。“没错,但是那个编辑器能运行俄罗斯方块吗?”
我很好奇,这会让大家相信 Emacs 更优秀吗?比如,为什么有人会关心他们是否可以在文本编辑器中玩游戏呢?“是的,但是那台吸尘器能播放 mp3 吗?”
有人说,俄罗斯方块总是很有趣的。像 Emacs 中的所有东西一样,它的源代码是开放的,易于检查和修改,因此 **我们可以使它变得更加有趣**。所谓更多的乐趣,我意思是更难。
让游戏变得更困难的一个最简单的方法就是“不要下一个块预览”。你无法再在知道下一个块会填满空间的情况下有意地将 S/Z 块放在一个危险的位置——你必须碰碰运气,希望出现最好的情况。
下面是没有预览的情况(如你所见,没有预览,我做出的某些选择带来了“可怕的后果”):
![img](https://nickdrozd.github.io/assets/2019-01-14-tetris/tetris-no-preview.png)
预览框由一个名为 `tetris-draw-next-shape` 的函数设置:
```
(defun tetris-draw-next-shape ()
(dotimes (x 4)
(dotimes (y 4)
(gamegrid-set-cell (+ tetris-next-x x)
(+ tetris-next-y y)
tetris-blank)))
(dotimes (i 4)
(let ((tetris-shape tetris-next-shape)
(tetris-rot 0))
(gamegrid-set-cell (+ tetris-next-x
(aref (tetris-get-shape-cell i) 0))
(+ tetris-next-y
(aref (tetris-get-shape-cell i) 1))
tetris-shape))))
```
首先,我们引入一个标志,决定是否允许显示下一个预览块:
```
(defvar tetris-preview-next-shape nil
"When non-nil, show the next block the preview box.")
```
现在的问题是,我们如何才能让 `tetris-draw-next-shape` 遵从这个标志?最明显的方法是重新定义它:
```
(defun tetris-draw-next-shape ()
(when tetris-preview-next-shape
;; existing tetris-draw-next-shape logic
))
```
但这不是理想的解决方案。同一个函数有两个定义,这很容易引起混淆,如果上游版本发生变化,我们必须维护修改后的定义。
一个更好的方法是使用 **advice**。Emacs 的 advice 类似于 **Python 装饰器**,但是更加灵活,因为 advice 可以从任何地方添加到函数中。这意味着我们可以修改函数而不影响原始的源文件。
有很多不同的方法使用 Emacs advice([ 查看手册 ][4]),但是这里我们只使用 `advice-add` 函数和 `:around` 标志。advise 函数将原始函数作为参数,原始函数可能执行也可能不执行。我们这里,我们让原始函数只有在预览标志是非空的情况下才能执行:
```
(defun tetris-maybe-draw-next-shape (tetris-draw-next-shape)
(when tetris-preview-next-shape
(funcall tetris-draw-next-shape)))
(advice-add 'tetris-draw-next-shape :around #'tetris-maybe-draw-next-shape)
```
这段代码将修改 `tetris-draw-next-shape` 的行为,而且它可以存储在配置文件中,与实际的俄罗斯方块代码分离。
去掉预览框是一个简单的改变。一个更激烈的变化是,**让块随机停止在空中**:
![img](https://nickdrozd.github.io/assets/2019-01-14-tetris/tetris-air.png)
本图中,红色的 I 和绿色的 T 部分没有掉下来,它们被固定下来了。这会让游戏变得 **及其难玩**,但却很容易实现。
和前面一样,我们首先定义一个标志:
```
(defvar tetris-stop-midair t
"If non-nil, pieces will sometimes stop in the air.")
```
目前,**Emacs 俄罗斯方块的工作方式** 类似这样子:活动部件有 x 和 y 坐标。在每个时钟滴答声中y 坐标递增(块向下移动一行),然后检查是否有与现存的块重叠。
如果检测到重叠,则将该块回退(其 y 坐标递减)并设置该活动块到位。为了让一个块在半空中停下来,我们所要做的就是破解检测函数 `tetris-test-shape`
**这个函数内部做什么并不重要** —— 重要的是它是一个返回布尔值的无参数函数。我们需要它在正常情况下返回布尔值 true( 否则我们将出现奇怪的重叠情况),但在其他时候也需要它返回 true。我相信有很多方法可以做到这一点以下是我的方法的
```
(defun tetris-test-shape-random (tetris-test-shape)
(or (and
tetris-stop-midair
;; Don't stop on the first shape.
(< 1 tetris-n-shapes )
;; Stop every INTERVAL pieces.
(let ((interval 7))
(zerop (mod tetris-n-shapes interval)))
;; Don't stop too early (it makes the game unplayable).
(let ((upper-limit 8))
(< upper-limit tetris-pos-y))
;; Don't stop at the same place every time.
(zerop (mod (random 7) 10)))
(funcall tetris-test-shape)))
(advice-add 'tetris-test-shape :around #'tetris-test-shape-random)
```
这里的硬编码参数使游戏变得更困难,但仍然可玩。当时我在飞机上喝醉了,所以它们可能需要进一步调整。
顺便说一下,根据我的 `tetris-scores` 文件,我的 **最高分**
```
01389 Wed Dec 5 15:32:19 2018
```
该文件中列出的分数默认最多为五位数,因此这个分数看起来不是很好。
**给读者的练习**
1。使用 advice 修改 Emacs 俄罗斯方块,使得每当方块下移动时就闪烁显示讯息 “OH SHIT”。消息的大小与块堆的高度成比例(当没有块时,消息应该很小的或不存在的,当最高块接近天花板时,消息应该很大)。
2。在这里给出的 `tetris-test-shape-random` 版本中,每隔七格就有一个半空中停止。一个玩家有可能能计算出时间间隔,并利用它来获得优势。修改它,使间隔随机在一些合理的范围内(例如,每 5 到 10 格)。
3。另一个对使用 Tetris 使用 advise 的场景,你可以试试 [`autotetris-mode`][1]。
4。想出一个有趣的方法来打乱块的旋转机制然后使用 advice 来实现它。
附注
============================================================
[1][5] Emacs 只有一个巨大的全局命名空间,因此函数和变量名一般以包名做前缀以避免冲突。
[2][6] 很多人会说你不应该使用已有的命名空间前缀而且应该将自己定义的所有东西都放在一个预留的命名空间中,比如像这样 `my/tetris-preview-next-shape`,然而这样很难看而且没什么意义,因此我不会这么干。
--------------------------------------------------------------------------------
via: https://nickdrozd.github.io/2019/01/14/tetris.html
作者:[nickdrozd][a]
选题:[lujun9972][b]
译者:[lujun9972](https://github.com/lujun9972)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://nickdrozd.github.io
[b]: https://github.com/lujun9972
[1]: https://nullprogram.com/blog/2014/10/19/
[2]: https://nickdrozd.github.io/2019/01/14/tetris.html#fn.1
[3]: https://nickdrozd.github.io/2019/01/14/tetris.html#fn.2
[4]: https://www.gnu.org/software/emacs/manual/html_node/elisp/Advising-Functions.html
[5]: https://nickdrozd.github.io/2019/01/14/tetris.html#fnr.1
[6]: https://nickdrozd.github.io/2019/01/14/tetris.html#fnr.2

View File

@ -1,99 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (HankChow)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Top hacks for the YaCy open source search engine)
[#]: via: (https://opensource.com/article/20/2/yacy-search-engine-hacks)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
使用开源搜索引擎 YaCy 的技巧
======
> 不想再受制于各种版本的搜索引擎?使用 YaCy 自定义一款吧。
![Browser of things][1]
在我以前介绍 [YaCy 入门][2]的文章中讲述过 [YaCy][3] 这个<ruby>点对点<rt>peer-to-peer</rt></ruby>式的搜索引擎是如何安装和使用的。YaCy 最大的一个特点就是可以在本地部署,全球范围内的每一个 YaCy 用户都是构成整个分布式搜索引擎架构的其中一个节点,因此每个用户都可以掌控自己的互联网搜索体验。
Google 曾经提供过 `google.com/linux` 这样的简便方式以便快速筛选出和 Linux 相关的搜索内容,这个功能受到了很多人的青睐,但 Google 最终还是在 2011 年的时候把它[下线][4]了。
而 YaCy 则让自定义搜索引擎变得可能。
### 自定义 YaCy
YaCy 安装好之后,只需要访问 `localhost:8090` 就可以使用了。要开始自定义搜索引擎,只需要点击右上角的“<ruby>管理<rt>Administration</rt></ruby>”按钮,如果没有找到,需要点击菜单图标打开菜单。
你可以在管理面板中配置 YaCy 对系统资源的使用策略,以及如何跟其它的 YaCy 客户端进行交互。
![YaCy profile selector][5]
例如,点击侧栏中的“<ruby>初步<rt>First steps</rt></ruby>”按钮可以配置备用端口,以及设置 YaCy 对内存和硬盘的使用量;而“<ruby>监控<rt>Monitoring</rt></ruby>”面板则可以监控 YaCy 的运行状况。大多数功能都只需要在面板上点击几下就可以完成了,例如以下几个常用的功能。
### 搜索应用
目前市面上也有不少公司推出了[内网搜索应用][6],而 YaCy 的优势是免费使用。对于能够通过 HTTP、FTP、Samba 等协议访问的文件YaCy 都可以进行索引因此无论是作为私人的文件搜索还是企业内部的本地共享文件搜索YaCy 都可以实现。它可以让内部网络中的用户使用自定义配置的 YaCy 查找共享文件,于此同时保持对内部网络以外的用户不可见。
### 网络配置
YaCy 在默认情况下就对隐私隔离有比较好的支持。点击“<ruby>用例与账号<rt>Use Case & Account</rt></ruby>”页面顶部的“<ruby>网络配置<rt>Network Configuration</rt></ruby>”链接,即可进入网络配置面板设置点对点网络。
![YaCy network configuration][7]
### 爬取站点
YaCy 点对点的分布式运作方式决定了它对页面的爬取是由用户驱动的。任何一个公司的爬虫都不可能完全访问到整个互联网上的所有页面,对于 YaCy 来说也是这样,一个站点只有在被用户指定爬取的前提下,才会被 YaCy 爬取并进入索引。
YaCy 客户端提供了两种爬取页面的方式:一是自定义爬虫,二是使用 YaCy 推荐的爬虫。
![YaCy advanced crawler][8]
#### 自定义爬虫任务
自定义爬虫是指由用户输入指定的网站 URL 并启动 YaCy 的爬虫任务。只需要点击“<ruby>高级爬虫<rt>Advanced Crawler</rt></ruby>”并输入计划爬取的 URL然后选择页面底部的“<ruby>进行远程索引<rt>Do Remote indexing</rt></ruby>”选项,这个选项会让客户端将上面输入的 URL 向互联网广播,接收到广播的其它远程客户端就会开始爬取这些 URL 所指向的页面。
点击页面底部的“<ruby>开始新爬虫任务<rt>Start New Crawl Job</rt></ruby>”按钮就可以开始进行爬取了,我就是这样对一些常用和有用站点进行爬取和索引的。
爬虫任务启动之后YaCy 会将这些 URL 对应的页面在本地生成和存储索引。在高级模式下,也就是本地计算机允许 8090 端口流量进出时,全网的 YaCy 用户都可以使用到这一份索引。
#### 加入爬虫任务
尽管 YaCy 用户已经在互联网上爬取了很多页面,但对于全网浩如烟海的页面而言也只是沧海一粟。单个用户所拥有的资源远不及很多大公司的网络爬虫,但大量 YaCy 用户如果联合起来成为一个社区,能产生的力量就大得多了。只要开启了 YaCy 的爬虫请求广播功能,就可以让其它客户端参与进来爬取更多页面。
只需要在“<ruby>高级爬虫<rt>Advanced Crawler</rt></ruby>”面板中点击页面顶部的“<ruby>远程爬取<rt>Remote Crawling</rt></ruby>”,勾选“<ruby>加载<rt>Load</rt></ruby>”复选框,就可以让你的客户端接受其它人发来的爬虫任务请求了。
![YaCy remote crawling][9]
### YaCy 监控相关
YaCy 除了作为一个非常强大的搜索引擎,还提供了很丰富的用户体验。你可以在“<ruby>监控<rt>Monitor</rt></ruby>”面板中监控 YaCy 客户端的网络运行状况,甚至还可以了解到有多少人从 YaCy 社区中获取到了自己所需要的东西。
![YaCy monitoring screen][10]
### 搜索引擎发挥了作用
你使用 YaCy 的时间越长,就越会思考搜索引擎如何改变自己的视野,因为你对互联网的体验很大一部分来自于你在搜索引擎中一次次简单查询的结果。实际上,当你和不同行业的人交流时,可能会注意到每个人对“互联网”的理解都有所不同。有些人会认为,互联网的搜索引擎中充斥着各种广告和推广,同时也仅仅能从搜索结果中获取到有限的信息。例如,假设有人不断搜索关于关键词 X 的内容,那么大部分商业搜索引擎都会在搜索结果中提高关键词 X 的权重,但与此同时,另一个关键词 Y 的权重则会相对降低,从而让关键词 Y 被淹没在搜索结果当中。
就像在现实生活中一样,走出舒适圈会让你看到一个更广阔的世界。尝试使用 YaCy看看你会不会有所收获。
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/2/yacy-search-engine-hacks
作者:[Seth Kenlon][a]
选题:[lujun9972][b]
译者:[HankChow](https://github.com/HankChow)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/seth
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_desktop_website_checklist_metrics.png?itok=OKKbl1UR (Browser of things)
[2]: https://opensource.com/article/20/2/open-source-search-engine
[3]: https://yacy.net/
[4]: https://www.linuxquestions.org/questions/linux-news-59/is-there-no-more-linux-google-884306/
[5]: https://opensource.com/sites/default/files/uploads/yacy-profiles.jpg (YaCy profile selector)
[6]: https://en.wikipedia.org/wiki/Vivisimo
[7]: https://opensource.com/sites/default/files/uploads/yacy-network-config.jpg (YaCy network configuration)
[8]: https://opensource.com/sites/default/files/uploads/yacy-advanced-crawler.jpg (YaCy advanced crawler)
[9]: https://opensource.com/sites/default/files/uploads/yacy-remote-crawl-accept.jpg (YaCy remote crawling)
[10]: https://opensource.com/sites/default/files/uploads/yacy-monitor.jpg (YaCy monitoring screen)

View File

@ -1,101 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (Morisun029)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Why developers like to code at night)
[#]: via: (https://opensource.com/article/20/2/why-developers-code-night)
[#]: author: (Matt Shealy https://opensource.com/users/mshealy)
开发人员为什么喜欢在晚上编码
======
对许多开源程序员来说,夜间工作计划是创造力和生产力来源的关键。
![Person programming on a laptop on a building][1]
如果你问大多数开发人员更喜欢在什么时候工作,大部人会说他们最高效的时间在晚上。这对于那些在工作之余为开源项目做贡献的人来说更是如此(尽管如此,希望在他们的健康范围内[避免透支][2])。
有些人喜欢从晚上开始一直工作到凌晨而另一些人则很早就起床例如凌晨4点以便在开始日常工作之前完成大部分编程工作。
这种工作习惯可能会使许多开发人员看起来像个怪胎和不称职。 但是,为什么有这么多的程序员喜欢在非正常时间工作,这其中有很多原因:
### maker 日程
根据[Paul Graham][3]的观点, "生产东西" 的人倾向于遵守 maker's schedule—他们更愿意以半天或更长时间为单位使用时间。事实上大多数 [开发人员也有相同的偏好][4].
一方面,开发人员从事大型抽象系统工作,需要思维空间来处理整个模型。 将他们的日程分割成15分钟或30分钟的时间段来处理电子邮件会议电话以及来自同事的打断工作效果只会适得其反。
另一方面,通常不可能以一个小时为单位进行有效编程。 因为这么短的时间几乎不够来处理当前的任务并开始工作。
上下文切换也会对编程产生不利影响。 在晚上工作,开发人员可以避免尽可能多的干扰。 在没有持续中断的情况下,他们可以花几个小时专注于手头任务,并尽可能提高工作效率。
### 平和安静的环境
由于晚上或凌晨不太会有来自各种活动的噪音(例如,办公室闲谈,街道上的交通),这使许多程序员感到放松,促使他们更具创造力和生产力,特别是在处理诸如编码之类的精神刺激任务时。
独处与平和,加上知道自己将有几个小时不被中断的工作时间,通常会使他们摆脱白天工作计划相关的时间压力,从而产出高质量的工作。
更不用说了,当解决了一个棘手的问题后,没有什么比尽情享受自己最喜欢的午夜小吃更美好的事情了!
### 沟通
与在公司内里工作的程序员相比,从事开源项目的开发人员可以拥有不同的沟通节奏。 大多数开源项目的沟通都是通过邮件或 GitHub 上的评论等渠道异步完成。 很多时候,其他程序员在不同的国家和时区,因此实时交流通常需要开发人员变成一个夜猫子。
### 昏昏欲睡的大脑
这听起来可能违反直觉,但是随着时间的推移,大脑会变得非常疲倦,因此只能专注于一项任务。 晚上工作从根本上消除了多任务处理,多任务处理是保持专注和高效的主要障碍。 当大脑处于昏昏欲睡的状态时,你是无法保持专注的!
许多开发人员在入睡时思考要解决的问题通常会取得重大进展。 潜意识开始工作,答案通常在他们半睡半醒的早些时候就出现了。
这不足为奇,因为[睡眠可增强大脑功能][5],可帮助我们理解新信息并进行更有创造性的思考。当解决方案在凌晨出现时,这些开发人员便会起来并开始工作,不错过任何机会。
### 灵活和创造性思考
许多程序员体会到晚上创造力会提升。 前额叶皮层,即与集中能力有关的大脑部分,在一天结束时会感到疲倦。 这似乎为某些人提供了更灵活和更具创造性的思考。
匹兹堡大学医学院精神病学助理教授[Brant Hasler][6] 表示:“由于自上而下的控制和'认知抑制'功能较少,大脑可能会解放出来进行更多样化的思考,从而使人们更容易地将不同概念之间的联系建立起来。” 结合轻松环境所带来的积极情绪,开发人员可以更轻松地产生创新想法。
此外,在没有干扰的情况下集中精力几个小时,“沉浸在你做的事情中”。 这可以帮助你更好地专注于项目并参与其中,而不必担心周围发生的事情。
### 明亮的电脑屏幕
因为整天看着明亮的屏幕, 许多程序员的睡眠周期被延迟。电脑屏幕发出的蓝光[扰乱我们的昼夜节律][7]通过延迟释放诱发睡眠的褪黑激素和提高人的机敏性将人体生物钟重置到更晚的时间。从而导致,开发人员往往睡得越来越晚。
### 过去的影响
过去,大多数开发人员是出于必要在晚上工作,因为在白天当公司其他人都在使用服务器时,共享服务器的计算能力支撑不了编程工作,所以开发人员需要等到深夜才能执行白天无法进行的任务,例如测试项目,运行大量的代码编译运行调试周期以及部署新代码。现在尽管服务器功能变强大了,大多数可以满足需求,但夜间工作的趋势仍是这种文化的一部分。
### 结语
尽管开发人员喜欢在晚上工作出于多种原因,但请记住,成为夜猫子并不意味着你应该克扣睡眠时间。 睡眠不足会导致压力和焦虑,并最终导致倦怠。
获得足够质量的睡眠是维持良好身体健康和大脑功能的关键。 例如,它可以帮助你整合新信息,巩固记忆,创造性思考,清除身体积聚的毒素,调节食欲并防止过早衰老。
无论你是哪种日程,请确保让你的大脑得到充分的休息,这样你就可以在一整天及每天的工作中发挥最大的作用!
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/2/why-developers-code-night
作者:[Matt Shealy][a]
选题:[lujun9972][b]
译者:[Morisun029](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/mshealy
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_code_programming_laptop.jpg?itok=ormv35tV (Person programming on a laptop on a building)
[2]: https://opensource.com/article/19/11/burnout-open-source-communities
[3]: http://www.paulgraham.com/makersschedule.html
[4]: https://www.chamberofcommerce.com/business-advice/software-development-trends-overtaking-the-market
[5]: https://amerisleep.com/blog/sleep-impacts-brain-health/
[6]: https://www.vice.com/en_us/article/mb58a8/late-night-creativity-spike
[7]: https://www.sleepfoundation.org/articles/how-blue-light-affects-kids-sleep

View File

@ -0,0 +1,50 @@
[#]: collector: (lujun9972)
[#]: translator: (heguangzhi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How Kubernetes Became the Standard for Compute Resources)
[#]: via: (https://www.linux.com/articles/how-kubernetes-became-the-standard-for-compute-resources/)
[#]: author: (Swapnil Bhartiya https://www.linux.com/author/swapnil/)
Kubernetes 如何成为计算资源的标准
======
<https://www.linux.com/wp-content/uploads/2019/08/elevator-1598431_1920.jpg>
对于原生云生态系统来说2019年是改变游戏规则的一年。有大的[并购][1),如 Red Hat Docker 和 Pivotal并出现其他的玩家 如Rancher Labs 和 Mirantis 。
“所有这些并购",Rancher Labs (一家为采用容器的团队提供完整软件栈的公司) 的联合创始人兼首席执行官盛亮表示:“这一领域的成功表明市场成熟的速度很快。”。
传统上,像 Kubernetes 和 Docker 这样的新兴技术吸引着开发者和像脸书和谷歌这样的超级用户。这群人之外没什么其他的兴趣。然而,这两种技术都在企业层面得到了广泛采用。突然间,有了一个巨大的市场,有了巨大的机会。几乎每个人都跳了进去。有人带来了创新的解决方案,也有人试图赶上其他人。它很快变得非常拥挤和热闹起来。
它也改变了创新的方式。[早期采用者通常是精通技术的公司。][2]现在,几乎每个人都在使用它,即使是在不被认为是 Kubernetes 地盘的地方。它改变了市场动态,像 Rancher Labs 这样的公司见证了独特的用例。
梁补充道,“我从来没有经历过像 Kubernete 这样快速、动态的市场或这样的技术进化。当我们五年前开始的时候,这是一个非常拥挤的空间。随着时间的推移,我们大多数的同龄人因为这样或那样的原因消失了。他们要么无法适应变化,要么选择不适应某些变化。”
在 Kubernetes 的早期,最明显的机会是建立 Kubernetes 发行版本和 Kubernetes 业务。这是新技术。众所周知,它的安装、升级和操作相当的复杂。
当谷歌、AWS 和微软进入市场时,一切都变了。当时,有一群供应商蜂拥而至,为平台提供解决方案。梁表示:“一旦像谷歌这样的云提供商决定将Kubernetes 作为一项服务,并亏本出售的商品免费提供,以推动基础设施消费;我们就知道,运营和支持 Kubernetes 业务的优势将非常有限了。”。
对非谷歌玩家来说,并非一切都不好。由于云供应商通过将它作为服务来提供,消除了 Kubernetes 带来的所有复杂性,这意味着更广泛地采用该技术,即使是那些由于运营成本而不愿使用该技术的人也是如此。这意味着 Kubernetes 将变得无处不在,并将成为一个行业标准。
“Rancher Labs 是极少数将此视为机遇并比其他公司看得更远的公司之一。我们意识到 Kubernetes 将成为新的计算标准就像TCP/IP成为网络标准一样”梁说。
CNCF围绕 Kubernetes 构建一个充满活力的生态系统方面发挥着至关重要的作用,创建了一个庞大的社区来构建、培育和商业化原生云开源技术。
--------------------------------------------------------------------------------
via: https://www.linux.com/articles/how-kubernetes-became-the-standard-for-compute-resources/
作者:[Swapnil Bhartiya][a]
选题:[lujun9972][b]
译者:[heguangzhi](https://github.com/heguangzhi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.linux.com/author/swapnil/
[b]: https://github.com/lujun9972
[1]: https://www.cloudfoundry.org/blog/2019-is-the-year-of-consolidation-why-ibms-deal-with-red-hat-is-a-harbinger-of-things-to-come/
[2]: https://www.packet.com/blog/open-source-season-on-the-kubernetes-highway/

View File

@ -0,0 +1,130 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How to Install Latest Git Version on Ubuntu)
[#]: via: (https://itsfoss.com/install-git-ubuntu/)
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)
如何在 Ubuntu 上安装最新版本的 Git
======
在 Ubuntu 上安装 Git 非常容易。它存在于 [Ubuntu 的主仓库][1]中,你可以像这样[使用 apt 命令][2]安装它:
```
sudo apt install git
```
很简单?是不是?
只有一点点小问题(这可能根本不是问题),就是它安装的 [Git][3] 版本。
在 LTS 系统上,软件稳定性至关重要,这就是为什么 Ubuntu 18.04 和其他发行版经常提供较旧但稳定的软件版本的原因,它们都经过发行版的良好测试。
这就是为什么当你检查 Git 版本时,会看到安装的版本会比 [Git 网站上当前最新 Git 版本][4]旧:
```
[email protected]:~$ git --version
git version 2.17.1
```
在编写本教程时,网站上提供的版本为 2.25。那么,如何在 Ubuntu 上安装最新的 Git
### 在基于 Ubuntu 的 Linux 发行版上安装最新的 Git
![][5]
一种方法是[从源代码安装][6]。这种很酷又老派的方法不适合所有人。值得庆幸的是Ubuntu Git 维护团队提供了 [PPA][7],莫可以使用它轻松地安装最新的稳定 Git 版本。
```
sudo add-apt-repository ppa:git-core/ppa
sudo apt update
sudo apt install git
```
即使你以前使用 apt 安装了 Git它也将更新为最新的稳定版本。
```
[email protected]:~$ git --version
git version 2.25.0
```
[使用PPA][8] 的好处在于,如果发布了新的 Git 稳定版本,那么就可以通过系统更新获得它。[仅更新 Ubuntu][9]来获取最新的 Git 稳定版本。
### 配置Git (推荐给开发者)
如果你出于开发目的安装了 Git你会很快开始克隆仓库进行更改并提交更改。
如果你尝试提交代码,那么你可能会看到 “Please tell me who you are” 这样的错误:
```
[email protected]:~/compress-pdf$ git commit -m "update readme"
*** Please tell me who you are.
Run
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got '[email protected](none)')
```
这是因为你还没配置必要的个人信息。
正如错误已经暗示的那样,你可以像这样设置全局 Git 配置:
```
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
```
你可以使用以下命令检查 Git 配置:
```
git config --list
```
它应该显示如下输出:
```
[email protected]
user.name=abhishek
```
配置保存在 \~/.gitconfig 中。你可以手动修改配置。
* * *
**结尾**
我希望这个小教程可以帮助你在 Ubuntu 上安装 Git。使用 PPA你可以轻松获得最新的 Git 版本。
如果你有任何疑问或建议,请随时在评论部分提问。也欢迎直接写“谢谢” :)
--------------------------------------------------------------------------------
via: https://itsfoss.com/install-git-ubuntu/
作者:[Abhishek Prakash][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/abhishek/
[b]: https://github.com/lujun9972
[1]: https://itsfoss.com/ubuntu-repositories/
[2]: https://itsfoss.com/apt-command-guide/
[3]: https://git-scm.com/
[4]: https://git-scm.com/downloads
[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/02/install_git_ubuntu.png?ssl=1
[6]: https://itsfoss.com/install-software-from-source-code/
[7]: https://launchpad.net/~git-core/+archive/ubuntu/ppa
[8]: https://itsfoss.com/ppa-guide/
[9]: https://itsfoss.com/update-ubuntu/

View File

@ -0,0 +1,104 @@
[#]: collector: (lujun9972)
[#]: translator: (wxy)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Tools for SSH key management)
[#]: via: (https://opensource.com/article/20/2/ssh-tools)
[#]: author: (Ben Nuttall https://opensource.com/users/bennuttall)
SSH 密钥管理工具
======
> 常用开源工具的省时快捷方式。
![collection of hardware on blue backround][1]
我经常使用 SSH。我发现自己每天都要登录多个服务器和树莓派与我位于同一房间并接入互联网。我有许多设备需要访问并且获得访问权限的要求也不同因此除了使用各种 `ssh` / `scp` 命令选项之外,我还必须维护一个包含所有连接详细信息的配置文件。
随着时间的推移,我发现了一些省时的技巧和工具,你可能也会发现它们有用。
### SSH 密钥
SSH 密钥是一种在不使用密码的情况下认证 SSH 连接的方法,可以用来加快访问速度或作为一种安全措施(如果你关闭了密码访问权限并确保仅允许授权的密钥)。要创建 SSH 密钥,请运行以下命令:
```
$ ssh-keygen
```
这将在 `~/.ssh/` 中创建一个密钥对(公钥和私钥)。将私钥(`id_rsa`)保留在 PC 上,切勿共享。你可以与其他人共享公钥(`id_rsa.pub`)或将其放置在其他服务器上。
### ssh-copy-id
如果我在家中或公司工作时使用树莓派,则倾向于将 SSH 设置保留为默认设置,因为我不担心内部信任网络上的安全性,并且通常将 SSH 密钥(公钥)复制到树莓派上,以避免每次都使用密码进行身份验证。为此,我使用 `ssh-copy-id` 命令将其复制到树莓派。这会自动将你的密钥(公钥)添加到树莓派:
```
$ ssh-copy-id pi@192.168.1.20
```
在生产服务器上,我倾向于关闭密码身份验证,仅允许授权的 SSH 密钥登录。
### ssh-import-id
另一个类似的工具是 `ssh-import-id`。你可以使用此方法通过从 GitHub 导入密钥来授予你自己(或其他人)对计算机或服务器的访问权限。例如,我已经在我的 GitHub 帐户中注册了各个 SSH 密钥,因此无需密码即可推送到 GitHub。这些公钥是有效的因此 `ssh-import-id` 可以使用它们在我的任何计算机上授权我:
```
$ ssh-import-id gh:bennuttall
```
我还可以使用它来授予其他人访问服务器的权限,而无需询问他们的密钥:
```
$ ssh-import-id gh:waveform80
```
### storm
我还使用了名为 Storm 的工具,该工具可帮助你将 SSH 连接添加到 SSH 配置中,因此你不必记住这些连接细节信息。你可以使用 `pip` 安装它:
```
$ sudo pip3 install stormssh
```
然后,你可以使用以下命令将 SSH 连接添加到配置中:
```
$ storm add pi3 pi@192.168.1.20
```
然后,你可以只使用 `ssh pi3` 来获得访问权限。类似的还有 `scp file.txt pi3:``sshfs pi pi3:`
你还可以使用更多的 SSH 选项,例如端口号:
```
$ storm add pi3 pi@192.168.1.20:2000
```
你可以参考 Storm 的[文档][2]轻松列出、搜索和编辑已保存的连接。Storm 实际所做的只是管理 SSH 配置文件 `~/.ssh/config` 中的项目。一旦了解了它们是如何存储的,你就可以选择手动编辑它们。配置中的示例连接如下所示:
```
Host pi3
   user pi
   hostname 192.168.1.20
   port 22
```
### 结论
从树莓派到大型的云基础设施SSH 是系统管理的重要工具。熟悉密钥管理会很方便。你还有其他 SSH 技巧要添加吗?我希望你在评论中分享他们。
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/2/ssh-tools
作者:[Ben Nuttall][a]
选题:[lujun9972][b]
译者:[wxy](https://github.com/wxy)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/bennuttall
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc_BUS_Apple_520.png?itok=ZJu-hBV1 (collection of hardware on blue backround)
[2]: https://stormssh.readthedocs.io/en/stable/usage.html