mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-03-03 01:10:13 +08:00
commit
794b9a5264
136
published/20200702 6 best practices for managing Git repos.md
Normal file
136
published/20200702 6 best practices for managing Git repos.md
Normal file
@ -0,0 +1,136 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (stevenzdg988)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13200-1.html)
|
||||
[#]: subject: (6 best practices for managing Git repos)
|
||||
[#]: via: (https://opensource.com/article/20/7/git-repos-best-practices)
|
||||
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
|
||||
|
||||
6 个最佳的 Git 仓库管理实践
|
||||
======
|
||||
|
||||
> 抵制在 Git 中添加一些会增加管理难度的东西的冲动;这里有替代方法。
|
||||
|
||||

|
||||
|
||||
有权访问源代码使对安全性的分析以及应用程序的安全成为可能。但是,如果没有人真正看过代码,问题就不会被发现,即使人们主动地看代码,通常也要看很多东西。幸运的是,GitHub 拥有一个活跃的安全团队,最近,他们 [发现了已提交到多个 Git 仓库中的特洛伊木马病毒][2],甚至仓库的所有者也偷偷溜走了。尽管我们无法控制其他人如何管理自己的仓库,但我们可以从他们的错误中吸取教训。为此,本文回顾了将文件添加到自己的仓库中的一些最佳实践。
|
||||
|
||||
### 了解你的仓库
|
||||
|
||||
![Git 仓库终端][3]
|
||||
|
||||
这对于安全的 Git 仓库来可以说是头号规则。作为项目维护者,无论是你自己创建的还是采用别人的,你的工作是了解自己仓库中的内容。你可能无法记住代码库中每一个文件,但是你需要了解你所管理的内容的基本组成部分。如果在几十个合并后出现一个游离的文件,你会很容易地发现它,因为你不知道它的用途,你需要检查它来刷新你的记忆。发生这种情况时,请查看该文件,并确保准确了解为什么它是必要的。
|
||||
|
||||
### 禁止二进制大文件
|
||||
|
||||
![终端中 Git 的二进制检查命令][4]
|
||||
|
||||
Git 是为文本而生的,无论是用纯文本编写的 C 或 Python 还是 Java 文本,亦或是 JSON、YAML、XML、Markdown、HTML 或类似的文本。Git 对于二进制文件不是很理想。
|
||||
|
||||
两者之间的区别是:
|
||||
|
||||
```
|
||||
$ cat hello.txt
|
||||
This is plain text.
|
||||
It's readable by humans and machines alike.
|
||||
Git knows how to version this.
|
||||
|
||||
$ git diff hello.txt
|
||||
diff --git a/hello.txt b/hello.txt
|
||||
index f227cc3..0d85b44 100644
|
||||
--- a/hello.txt
|
||||
+++ b/hello.txt
|
||||
@@ -1,2 +1,3 @@
|
||||
This is plain text.
|
||||
+It's readable by humans and machines alike.
|
||||
Git knows how to version this.
|
||||
```
|
||||
|
||||
和
|
||||
|
||||
```
|
||||
$ git diff pixel.png
|
||||
diff --git a/pixel.png b/pixel.png
|
||||
index 563235a..7aab7bc 100644
|
||||
Binary files a/pixel.png and b/pixel.png differ
|
||||
|
||||
$ cat pixel.png
|
||||
<EFBFBD>PNG
|
||||
▒
|
||||
IHDR7n<EFBFBD>$gAMA<4D><41>
|
||||
<20>abKGD݊<44>tIME<4D>
|
||||
|
||||
-2R<32><52>
|
||||
IDA<EFBFBD>c`<60>!<21>3%tEXtdate:create2020-06-11T11:45:04+12:00<30><30>r.%tEXtdate:modify2020-06-11T11:45:04+12:00<30><30>ʒIEND<4E>B`<60>
|
||||
```
|
||||
|
||||
二进制文件中的数据不能像纯文本一样被解析,因此,如果二进制文件发生任何更改,则必须重写整个内容。一个版本与另一个版本之间唯一的区别就是全部不同,这会快速增加仓库大小。
|
||||
|
||||
更糟糕的是,Git 仓库维护者无法合理地审计二进制数据。这违反了头号规则:应该对仓库的内容了如指掌。
|
||||
|
||||
除了常用的 [POSIX][5] 工具之外,你还可以使用 `git diff` 检测二进制文件。当你尝试使用 `--numstat` 选项来比较二进制文件时,Git 返回空结果:
|
||||
|
||||
```
|
||||
$ git diff --numstat /dev/null pixel.png | tee
|
||||
- - /dev/null => pixel.png
|
||||
$ git diff --numstat /dev/null file.txt | tee
|
||||
5788 0 /dev/null => list.txt
|
||||
```
|
||||
|
||||
如果你正在考虑将二进制大文件(BLOB)提交到仓库,请停下来先思考一下。如果它是二进制文件,那它是由什么生成的。是否有充分的理由不在构建时生成它们,而是将它们提交到仓库?如果你认为提交二进制数据是有意义的,请确保在 `README` 文件或类似文件中指明二进制文件的位置、为什么是二进制文件的原因以及更新它们的协议是什么。必须谨慎对其更新,因为你每提交一个二进制大文件的变化,它的存储空间实际上都会加倍。
|
||||
|
||||
### 让第三方库留在第三方
|
||||
|
||||
第三方库也不例外。尽管它是开源的众多优点之一,你可以不受限制地重用和重新分发不是你编写的代码,但是有很多充分的理由不把第三方库存储在你自己的仓库中。首先,除非你自己检查了所有代码(以及将来的合并),否则你不能为第三方完全担保。其次,当你将第三方库复制到你的 Git 仓库中时,会将焦点从真正的上游源代码中分离出来。从技术上讲,对库有信心的人只对该库的主副本有把握,而不是对随机仓库的副本有把握。如果你需要锁定特定版本的库,请给开发者提供一个合理的项目所需的发布 URL,或者使用 [Git 子模块][6]。
|
||||
|
||||
### 抵制盲目的 git add
|
||||
|
||||
![Git 手动添加命令终端中][7]
|
||||
|
||||
如果你的项目已编译,请抵制住使用 `git add .` 的冲动(其中 `.` 是当前目录或特定文件夹的路径),因为这是一种添加任何新东西的简单方法。如果你不是手动编译项目,而是使用 IDE 为你管理项目,这一点尤其重要。用 IDE 管理项目时,跟踪添加到仓库中的内容会非常困难,因此仅添加你实际编写的内容非常重要,而不是添加项目文件夹中出现的任何新对象。
|
||||
|
||||
如果你使用了 `git add .`,请在推送之前检查暂存区里的内容。如果在运行 `make clean` 或等效命令后,执行 `git status` 时在项目文件夹中看到一个陌生的对象,请找出它的来源,以及为什么仍然在项目的目录中。这是一种罕见的构建工件,不会在编译期间重新生成,因此在提交前请三思。
|
||||
|
||||
### 使用 Git ignore
|
||||
|
||||
![终端中的 `Git ignore` 命令][8]
|
||||
|
||||
许多为程序员打造的便利也非常杂乱。任何项目的典型项目目录,无论是编程的,还是艺术的或其他的,到处都是隐藏的文件、元数据和遗留的工件。你可以尝试忽略这些对象,但是 `git status` 中的提示越多,你错过某件事的可能性就越大。
|
||||
|
||||
你可以通过维护一个良好的 `gitignore` 文件来为你过滤掉这种噪音。因为这是使用 Git 的用户的共同要求,所以有一些入门级的 `gitignore` 文件。[Github.com/github/gitignore][9] 提供了几个专门创建的 `gitignore` 文件,你可以下载这些文件并将其放置到自己的项目中,[Gitlab.com][10] 在几年前就将`gitignore` 模板集成到了仓库创建工作流程中。使用这些模板来帮助你为项目创建适合的 `gitignore` 策略并遵守它。
|
||||
|
||||
### 查看合并请求
|
||||
|
||||
![Git 合并请求][11]
|
||||
|
||||
当你通过电子邮件收到一个合并/拉取请求或补丁文件时,不要只是为了确保它能正常工作而进行测试。你的工作是阅读进入代码库的新代码,并了解其是如何产生结果的。如果你不同意这个实现,或者更糟的是,你不理解这个实现,请向提交该实现的人发送消息,并要求其进行说明。质疑那些希望成为版本库永久成员的代码并不是一种社交失误,但如果你不知道你把什么合并到用户使用的代码中,那就是违反了你和用户之间的社交契约。
|
||||
|
||||
### Git 责任
|
||||
|
||||
社区致力于开源软件良好的安全性。不要鼓励你的仓库中不良的 Git 实践,也不要忽视你克隆的仓库中的安全威胁。Git 功能强大,但它仍然只是一个计算机程序,因此要以人为本,确保每个人的安全。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/7/git-repos-best-practices
|
||||
|
||||
作者:[Seth Kenlon][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[stevenzdg988](https://github.com/stevenzdg988)
|
||||
校对:[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/wfh_work_home_laptop_work.png?itok=VFwToeMy (Working from home at a laptop)
|
||||
[2]: https://securitylab.github.com/research/octopus-scanner-malware-open-source-supply-chain/
|
||||
[3]: https://opensource.com/sites/default/files/uploads/git_repo.png (Git repository )
|
||||
[4]: https://opensource.com/sites/default/files/uploads/git-binary-check.jpg (Git binary check)
|
||||
[5]: https://opensource.com/article/19/7/what-posix-richard-stallman-explains
|
||||
[6]: https://git-scm.com/book/en/v2/Git-Tools-Submodules
|
||||
[7]: https://opensource.com/sites/default/files/uploads/git-cola-manual-add.jpg (Git manual add)
|
||||
[8]: https://opensource.com/sites/default/files/uploads/git-ignore.jpg (Git ignore)
|
||||
[9]: https://github.com/github/gitignore
|
||||
[10]: https://about.gitlab.com/releases/2016/05/22/gitlab-8-8-released
|
||||
[11]: https://opensource.com/sites/default/files/uploads/git_merge_request.png (Git merge request)
|
@ -1,62 +1,61 @@
|
||||
[#]: subject: (An Introduction to WebAssembly)
|
||||
[#]: via: (https://www.linux.com/news/an-introduction-to-webassembly/)
|
||||
[#]: author: (Dan Brown https://training.linuxfoundation.org/announcements/an-introduction-to-webassembly/)
|
||||
[#]: author: (Marco Fioretti https://training.linuxfoundation.org/announcements/an-introduction-to-webassembly/)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13197-1.html)
|
||||
|
||||
WebAssembly 介绍
|
||||
======
|
||||
|
||||
_Marco Fioretti 编写_
|
||||

|
||||
|
||||
## **到底什么是 WebAssembly?**
|
||||
### 到底什么是 WebAssembly?
|
||||
|
||||
[WebAssembly,也叫 Wasm][1],是一种 Web 优化的代码格式和 API(应用编程接口),它可以大大提高网站的性能和能力。WebAssembly 的 1.0 版本,于 2017 年发布,并于 2019 年成为 W3C 官方标准。
|
||||
[WebAssembly][1],也叫 Wasm,是一种为 Web 优化的代码格式和 API(应用编程接口),它可以大大提高网站的性能和能力。WebAssembly 的 1.0 版本于 2017 年发布,并于 2019 年成为 W3C 官方标准。
|
||||
|
||||
该标准得到了所有主流浏览器供应商的积极支持,原因显而易见:官方列出的[“浏览器内部”用例][2]中提到了,其中包括视频编辑、3D 游戏、虚拟和增强现实、p2p 服务和科学模拟。除了让浏览器的功能比J avaScript 强大得多,该标准甚至可以延长网站的寿命:例如,正是 WebAssembly 为[互联网档案馆的 Flash 动画和游戏][3]提供了持续的支持。
|
||||
该标准得到了所有主流浏览器供应商的积极支持,原因显而易见:官方列出的 [“浏览器内部”用例][2] 中提到了,其中包括视频编辑、3D 游戏、虚拟和增强现实、p2p 服务和科学模拟。除了让浏览器的功能比JavaScript 强大得多,该标准甚至可以延长网站的寿命:例如,正是 WebAssembly 为 [互联网档案馆的 Flash 动画和游戏][3] 提供了持续的支持。
|
||||
|
||||
不过,WebAssembly 并不只用于浏览器,目前它还被用于移动和基于边缘环境的 Cloudflare Workers 等产品中。
|
||||
|
||||
## **WebAssembly 如何工作**
|
||||
### WebAssembly 如何工作?
|
||||
|
||||
.wasm 格式的文件包含低级二进制指令(字节码),可由使用通用栈的虚拟机以“接近 CPU 原生速度”执行。这些代码被打包成模块,也就是可以被浏览器直接执行的对象。每个模块可以被一个网页多次实例化。模块内部定义的函数被列在一个专用数组中,或称为 Table,相应的数据被包含在另一个结构中,称为 arraybuffer。开发者可以通过 Javascript WebAssembly.memory() 的调用,为 .wasm 代码显式分配内存。
|
||||
.wasm 格式的文件包含低级二进制指令(字节码),可由使用通用栈的虚拟机以“接近 CPU 原生速度”执行。这些代码被打包成模块(可以被浏览器直接执行的对象),每个模块可以被一个网页多次实例化。模块内部定义的函数被列在一个专用数组中,或称为<ruby>表<rt>Table</rt></ruby>,相应的数据被包含在另一个结构中,称为 <ruby>缓存数组<rt>arraybuffer</rt></ruby>。开发者可以通过 Javascript `WebAssembly.memory()` 的调用,为 .wasm 代码显式分配内存。
|
||||
|
||||
.wasm 格式的纯文本版本可以大大简化学习和调试,同样也可以使用。然而,WebAssembly 并不是真的要供人直接使用。从技术上讲,.wasm 只是一个与浏览器兼容的**编译目标**:一种软件编译器可以自动翻译用高级编程语言编写的代码的格式。
|
||||
.wasm 格式也有纯文本版本,它可以大大简化学习和调试。然而,WebAssembly 并不是真的要供人直接使用。从技术上讲,.wasm 只是一个与浏览器兼容的**编译目标**:一种用高级编程语言编写的软件编译器可以自动翻译的代码格式。
|
||||
|
||||
这种选择正是使开发人员能够使用数十亿人熟悉的语言(C/C++、Python、Go、Rust 等)直接为用户界面进行编程的方式,但以前浏览器无法对其进行有效利用。更妙的是,程序员将得到这些,至少在理论上无需直接查看 WebAssembly 代码,也无需担心(因为目标是一个**虚拟**机)物理 CPU 将实际运行他们的代码。
|
||||
这种选择正是使开发人员能够使用数十亿人熟悉的语言(C/C++、Python、Go、Rust 等)直接为用户界面进行编程的方式,但以前浏览器无法对其进行有效利用。更妙的是,至少在理论上程序员可以利用它们,无需直接查看 WebAssembly 代码,也无需担心物理 CPU 实际运行他们的代码(因为目标是一个**虚拟**机)。
|
||||
|
||||
## **但是我们已经有了 JavaScript,我们真的需要 WebAssembly 吗?**
|
||||
### 但是我们已经有了 JavaScript,我们真的需要 WebAssembly 吗?
|
||||
|
||||
是的,有几个原因。首先,作为二进制指令,.wasm 文件比同等功能的 JavaScript 文件小得多,下载速度也快得多。最重要的是,Javascript 文件必须在浏览器将其转换为其内部虚拟机可用的字节码之前进行完全解析和验证。
|
||||
|
||||
而 .wasm 文件则可以一次性验证和编译,从而使“流式编译”成为可能:浏览器在开始**下载它们**的那一刻就可以开始编译和执行它们,就像串流电影一样。
|
||||
|
||||
这就是说,并不是所有可以想到的 WebAssembly 应用肯定会比由专业程序员手动优化的等效 JavaScript 应用更快或更小。例如,如果一些 .wasm 需要包含 JavaScript 不需要的库,这种情况可能会发生。
|
||||
这就是说,并不是所有可以想到的 WebAssembly 应用都肯定会比由专业程序员手动优化的等效 JavaScript 应用更快或更小。例如,如果一些 .wasm 需要包含 JavaScript 不需要的库,这种情况可能会发生。
|
||||
|
||||
## **WebAssembly 是否会让 JavaScript 过时?**
|
||||
### WebAssembly 是否会让 JavaScript 过时?
|
||||
|
||||
一句话:不会。当然暂时不会,至少在浏览器内不会。WebAssembly 模块仍然需要 JavaScript,因为在设计上它们不能访问文档对象模型 (DOM),也就是[主要用于修改网页的 API][4]。此外,.wasm 代码不能进行系统调用或读取浏览器的内存。WebAssembly 只能在沙箱中运行,一般来说,它能与外界的交互甚至比 JavaScript 更少,而且只能通过 JavaScript 接口进行。
|
||||
一句话:不会。暂时不会,至少在浏览器内不会。WebAssembly 模块仍然需要 JavaScript,因为在设计上它们不能访问文档对象模型 (DOM)—— [主要用于修改网页的 API][4]。此外,.wasm 代码不能进行系统调用或读取浏览器的内存。WebAssembly 只能在沙箱中运行,一般来说,它能与外界的交互甚至比 JavaScript 更少,而且只能通过 JavaScript 接口进行。
|
||||
|
||||
因此,至少在不久的将来 .wasm 模块将只是通过 JavaScript 提供那些如果用 JavaScript 语言编写会消耗更多带宽、内存或 CPU 时间的部分。
|
||||
|
||||
## **网络浏览器如何运行 WebAssembly**
|
||||
### Web 浏览器如何运行 WebAssembly?
|
||||
|
||||
一般来说,浏览器至少需要两块来处理动态应用:运行应用代码的虚拟机 (VM),以及可以同时修改浏览器行为和网页显示的 API。
|
||||
一般来说,浏览器至少需要两块来处理动态应用:运行应用代码的虚拟机(VM),以及可以同时修改浏览器行为和网页显示的 API。
|
||||
|
||||
现代浏览器内部的虚拟机通过以下方式同时支持 JavaScript 和 WebAssembly:
|
||||
|
||||
1. 浏览器下载一个用 HTML 标记语言编写的网页,然后进行渲染
|
||||
2. 如果该 HTML 调用 JavaScript 代码,浏览器的虚拟机就会执行该代码。但是...
|
||||
3. 如果 JavaScript 代码中包含了 WebAssembly 模块的实例,那么就按照上面的描述获取该实例,然后根据需要通过 JavaScript 的 WebAssembly API 来使用该实例
|
||||
4. 当 WebAssembly 代码产生的东西将修改 DOM 即“宿主”网页的结构,JavaScript 代码就会接收到,并继续进行实际的修改。
|
||||
4. 当 WebAssembly 代码产生的东西将修改 DOM(即“宿主”网页)的结构,JavaScript 代码就会接收到,并继续进行实际的修改。
|
||||
|
||||
### 我如何才能创建可用的 WebAssembly 代码?
|
||||
|
||||
## **我如何才能创建可用的 WebAssembly 代码?**
|
||||
|
||||
越来越多的编程语言社区支持直接编译到 Wasm,我们建议从 webassembly.org 的[入门指南][5]开始,这取决于你使用什么语言。请注意,并不是所有的编程语言都有相同水平的 Wasm 支持,因此你的工作量可能会有所不同。
|
||||
越来越多的编程语言社区支持直接编译到 Wasm,我们建议从 webassembly.org 的 [入门指南][5] 开始,这取决于你使用什么语言。请注意,并不是所有的编程语言都有相同水平的 Wasm 支持,因此你的工作量可能会有所不同。
|
||||
|
||||
我们计划在未来几个月内发布一系列文章,提供更多关于 WebAssembly 的信息。要自己开始使用它,你可以报名参加 Linux 基金会的免费 [WebAssembly 介绍][6]在线培训课程。
|
||||
|
||||
@ -69,7 +68,7 @@ via: https://www.linux.com/news/an-introduction-to-webassembly/
|
||||
作者:[Dan Brown][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/) 荣誉推出
|
||||
|
@ -4,15 +4,15 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (wxy)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13203-1.html)
|
||||
|
||||
学习使用 GDB 调试代码
|
||||
======
|
||||
|
||||
> 使用 GNU 调试器来解决你的代码问题。
|
||||
|
||||
![在电脑屏幕上放大镜,发现代码中的错误][1]
|
||||

|
||||
|
||||
GNU 调试器常以它的命令 `gdb` 称呼它,它是一个交互式的控制台,可以帮助你浏览源代码、分析执行的内容,其本质上是对错误的应用程序中出现的问题进行逆向工程。
|
||||
|
@ -3,22 +3,22 @@
|
||||
[#]: author: (Kader Miyanyedi https://fedoramagazine.org/author/moonkat/)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13202-1.html)
|
||||
|
||||
如何在 Fedora 上使用 Poetry 来管理你的 Python 项目?
|
||||
======
|
||||
|
||||
![Python & Poetry on Fedora][1]
|
||||
|
||||
Python 开发人员经常创建一个新的虚拟环境来分离项目依赖,然后用 _pip、pipenv_ 等工具来管理它们。Poetry 是一个简化 Python 中依赖管理和打包的工具。这篇文章将向你展示如何在 Fedora 上使用 Poetry 来管理你的 Python 项目。
|
||||
Python 开发人员经常创建一个新的虚拟环境来分离项目依赖,然后用 `pip`、`pipenv` 等工具来管理它们。Poetry 是一个简化 Python 中依赖管理和打包的工具。这篇文章将向你展示如何在 Fedora 上使用 Poetry 来管理你的 Python 项目。
|
||||
|
||||
与其他工具不同,Poetry 只使用一个配置文件来进行依赖管理、打包和发布。这消除了对不同文件的需求,如 _Pipfile、MANIFEST.in、setup.py_ 等。这也比使用多个工具更快。
|
||||
与其他工具不同,Poetry 只使用一个配置文件来进行依赖管理、打包和发布。这消除了对不同文件的需求,如 `Pipfile`、`MANIFEST.in`、`setup.py` 等。这也比使用多个工具更快。
|
||||
|
||||
下面详细介绍一下开始使用 Poetry 时使用的命令。
|
||||
|
||||
### **在 Fedora 上安装 Poetry**
|
||||
### 在 Fedora 上安装 Poetry
|
||||
|
||||
如果你已经使用 Fedora 32 或以上版本,你可以使用这个命令直接从命令行安装 Poetry:
|
||||
|
||||
@ -26,22 +26,20 @@ Python 开发人员经常创建一个新的虚拟环境来分离项目依赖,
|
||||
$ sudo dnf install poetry
|
||||
```
|
||||
|
||||
```
|
||||
编者注:在 Fedora Silverblue 或 CoreOs上,Python 3.9.2 是核心提交的一部分,你可以用下面的命令安装 Poetry:
|
||||
|
||||
```
|
||||
|
||||
rpm-ostree install poetry
|
||||
|
||||
```
|
||||
|
||||
### 初始化一个项目
|
||||
|
||||
使用 _new_ 命令创建一个新项目。
|
||||
使用 `new` 命令创建一个新项目:
|
||||
|
||||
```
|
||||
$ poetry new poetry-project
|
||||
```
|
||||
|
||||
The structure of a project created with Poetry looks like this:
|
||||
用 Poetry 创建的项目结构是这样的:
|
||||
|
||||
```
|
||||
@ -54,7 +52,7 @@ The structure of a project created with Poetry looks like this:
|
||||
└── test_poetry_project.py
|
||||
```
|
||||
|
||||
Poetry 使用 _pyproject.toml_ 来管理项目的依赖。最初,这个文件看起来类似于这样:
|
||||
Poetry 使用 `pyproject.toml` 来管理项目的依赖。最初,这个文件看起来类似于这样:
|
||||
|
||||
```
|
||||
[tool.poetry]
|
||||
@ -81,10 +79,7 @@ build-backend = "poetry.masonry.api"
|
||||
* 第三部分包含开发依赖。
|
||||
* 第四部分描述的是符合 [PEP 517][2] 的构建系统。
|
||||
|
||||
|
||||
|
||||
|
||||
如果你已经有一个项目,或者创建了自己的项目文件夹,并且你想使用 Poetry,请在你的项目中运行 _init_ 命令。
|
||||
如果你已经有一个项目,或者创建了自己的项目文件夹,并且你想使用 Poetry,请在你的项目中运行 `init` 命令。
|
||||
|
||||
```
|
||||
$ poetry init
|
||||
@ -100,7 +95,7 @@ $ poetry init
|
||||
$ poetry shell
|
||||
```
|
||||
|
||||
Poetry 默认在 _/home/username/.cache/pypoetry_ 项目中创建虚拟环境。你可以通过编辑 poetry 配置来更改默认路径。使用下面的命令查看配置列表:
|
||||
Poetry 默认在 `/home/username/.cache/pypoetry` 项目中创建虚拟环境。你可以通过编辑 Poetry 配置来更改默认路径。使用下面的命令查看配置列表:
|
||||
|
||||
```
|
||||
$ poetry config --list
|
||||
@ -111,7 +106,7 @@ virtualenvs.in-project = true
|
||||
virtualenvs.path = "{cache-dir}/virtualenvs"
|
||||
```
|
||||
|
||||
修改 _virtualenvs.in-project_ 配置变量,在项目目录下创建一个虚拟环境。Poetry 命令是:
|
||||
修改 `virtualenvs.in-project` 配置变量,在项目目录下创建一个虚拟环境。Poetry 命令是:
|
||||
|
||||
```
|
||||
$ poetry config virtualenv.in-project true
|
||||
@ -119,27 +114,27 @@ $ poetry config virtualenv.in-project true
|
||||
|
||||
### 添加依赖
|
||||
|
||||
使用 _poetry add_ 命令为项目安装一个依赖。
|
||||
使用 `poetry add` 命令为项目安装一个依赖:
|
||||
|
||||
```
|
||||
$ poetry add django
|
||||
```
|
||||
|
||||
你可以使用带有 _-dev_ 选项的 _add_ 命令来识别任何只用于开发环境的依赖。
|
||||
你可以使用带有 `--dev` 选项的 `add` 命令来识别任何只用于开发环境的依赖:
|
||||
|
||||
```
|
||||
$ poetry add black --dev
|
||||
```
|
||||
|
||||
**add** 命令会创建一个 _poetry.lock_ 文件,用来跟踪软件包的版本。如果 _poetry.lock_ 文件不存在,那么会安装 _pyproject.toml_ 中所有依赖项的最新版本。如果 _poetry.lock_ 存在,Poetry 会使用文件中列出的确切版本,以确保每个使用这个项目的人的软件包版本是一致的。
|
||||
`add` 命令会创建一个 `poetry.lock` 文件,用来跟踪软件包的版本。如果 `poetry.lock` 文件不存在,那么会安装 `pyproject.toml` 中所有依赖项的最新版本。如果 `poetry.lock` 存在,Poetry 会使用文件中列出的确切版本,以确保每个使用这个项目的人的软件包版本是一致的。
|
||||
|
||||
使用 poetry _install_ 命令来安装当前项目中的所有依赖。
|
||||
使用 `poetry install` 命令来安装当前项目中的所有依赖:
|
||||
|
||||
```
|
||||
$ poetry install
|
||||
```
|
||||
|
||||
通过使用 _no-dev_ 选项防止安装开发依赖。
|
||||
通过使用 `--no-dev` 选项防止安装开发依赖:
|
||||
|
||||
```
|
||||
$ poetry install --no-dev
|
||||
@ -147,7 +142,7 @@ $ poetry install --no-dev
|
||||
|
||||
### 列出软件包
|
||||
|
||||
_show_ 命令会列出所有可用的软件包。_tree_ 选项将以树状列出软件包。
|
||||
`show` 命令会列出所有可用的软件包。`--tree` 选项将以树状列出软件包:
|
||||
|
||||
```
|
||||
$ poetry show --tree
|
||||
@ -158,7 +153,7 @@ django 3.1.7 A high-level Python Web framework that encourages rapid development
|
||||
└── sqlparse >=0.2.2
|
||||
```
|
||||
|
||||
包含软件包名称,以列出特定软件包的详细信息。
|
||||
包含软件包名称,以列出特定软件包的详细信息:
|
||||
|
||||
```
|
||||
$ poetry show requests
|
||||
@ -174,7 +169,7 @@ dependencies
|
||||
- urllib3 >=1.21.1,<1.27
|
||||
```
|
||||
|
||||
最后,如果你想知道软件包的最新版本,你可以通过 _latest_ 选项。
|
||||
最后,如果你想知道软件包的最新版本,你可以通过 `--latest` 选项:
|
||||
|
||||
```
|
||||
$ poetry show --latest
|
||||
@ -194,7 +189,7 @@ via: https://fedoramagazine.org/how-to-use-poetry-to-manage-your-python-projects
|
||||
作者:[Kader Miyanyedi][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/) 荣誉推出
|
||||
|
107
published/20210310 How to Update openSUSE Linux System.md
Normal file
107
published/20210310 How to Update openSUSE Linux System.md
Normal file
@ -0,0 +1,107 @@
|
||||
[#]: subject: (How to Update openSUSE Linux System)
|
||||
[#]: via: (https://itsfoss.com/update-opensuse/)
|
||||
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13199-1.html)
|
||||
|
||||
如何更新 openSUSE Linux 系统
|
||||
======
|
||||
|
||||

|
||||
|
||||
就我记忆所及,我一直是 Ubuntu 的用户。我曾经转向过其他发行版,但最终还是一次次回到 Ubuntu。但最近,我开始使用 openSUSE 来尝试一些非 Debian 的东西。
|
||||
|
||||
随着我对 [openSUSE][1] 的不断探索,我不断发现 SUSE 中略有不同的东西,并打算在教程中介绍它们。
|
||||
|
||||
第一篇我写的是更新 openSUSE 系统。有两种方法可以做到:
|
||||
|
||||
* 使用终端(适用于 openSUSE 桌面和服务器)
|
||||
* 使用图形工具(适用于 openSUSE 桌面)
|
||||
|
||||
### 通过命令行更新 openSUSE
|
||||
|
||||
更新 openSUSE 的最简单方法是使用 `zypper` 命令。它提供了补丁和更新管理的全部功能。它可以解决文件冲突和依赖性问题。更新也包括 Linux 内核。
|
||||
|
||||
如果你正在使用 openSUSE Leap,请使用这个命令:
|
||||
|
||||
```
|
||||
sudo zypper update
|
||||
```
|
||||
|
||||
你也可以用 `up` 代替 `update`,但我觉得 `update` 更容易记住。
|
||||
|
||||
如果你正在使用 openSUSE Tumbleweed,请使用 `dist-upgrade` 或者 `dup`(简称)。Tumbleweed 是[滚动发行版][2],因此建议使用 `dist-upgrade` 选项。
|
||||
|
||||
```
|
||||
sudo zypper dist-upgrade
|
||||
```
|
||||
|
||||
它将显示要升级、删除或安装的软件包列表。
|
||||
|
||||
![][3]
|
||||
|
||||
如果你的系统需要重启,你会得到通知。
|
||||
|
||||
如果你只是想刷新仓库(像 `sudo apt update` 一样),你可以使用这个命令:
|
||||
|
||||
```
|
||||
sudo zypper refresh
|
||||
```
|
||||
|
||||
如果你想列出可用的更新,也可以这样做:
|
||||
|
||||
```
|
||||
sudo zypper list-updates
|
||||
```
|
||||
|
||||
### 以图形方式更新 openSUSE
|
||||
|
||||
如果你使用 openSUSE 作为桌面,你可以选择使用 GUI 工具来安装更新。这个工具可能会根据 [你使用的桌面环境][4] 而改变。
|
||||
|
||||
例如,KDE 有自己的软件中心,叫做 “Discover”。你可以用它来搜索和安装新的应用。你也可以用它来安装系统更新。
|
||||
|
||||
![][5]
|
||||
|
||||
事实上,KDE 会在通知区通知你可用的系统更新。你必须打开 Discover,因为点击通知不会自动进入 Discover。
|
||||
|
||||
![][6]
|
||||
|
||||
如果你觉得这很烦人,你可以使用这些命令禁用它:
|
||||
|
||||
```
|
||||
sudo zypper remove plasma5-pk-updates
|
||||
sudo zypper addlock plasma5-pk-updates
|
||||
```
|
||||
|
||||
不过我不推荐。最好是获取可用的更新通知。
|
||||
|
||||
还有一个 YAST 软件管理 [GUI 工具][7],你可以用它来对软件包管理进行更精细的控制。
|
||||
|
||||
![][8]
|
||||
|
||||
就是这些了。这是一篇简短的文章。在下一篇 SUSE 教程中,我将通过实例向大家展示一些常用的 `zypper` 命令。敬请期待。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/update-opensuse/
|
||||
|
||||
作者:[Abhishek Prakash][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/abhishek/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://www.opensuse.org/
|
||||
[2]: https://itsfoss.com/rolling-release/
|
||||
[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/03/update-opensuse-with-zypper.png?resize=800%2C406&ssl=1
|
||||
[4]: https://itsfoss.com/find-desktop-environment/
|
||||
[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/03/opensuse-update-gui.png?resize=800%2C500&ssl=1
|
||||
[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/03/update-notification-opensuse.png?resize=800%2C259&ssl=1
|
||||
[7]: https://itsfoss.com/gui-cli-tui/
|
||||
[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/03/yast-software-management-suse.png?resize=800%2C448&ssl=1
|
@ -1,5 +1,5 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: translator: (cooljelly)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
@ -0,0 +1,134 @@
|
||||
[#]: subject: (Extending Looped Music for Fun, Relaxation and Productivity)
|
||||
[#]: via: (https://theartofmachinery.com/2021/03/12/loopx.html)
|
||||
[#]: author: (Simon Arneaud https://theartofmachinery.com)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
Extending Looped Music for Fun, Relaxation and Productivity
|
||||
======
|
||||
|
||||
Some work (like programming) takes a lot of concentration, and I use noise-cancelling headphones to help me work productively in silence. But for other work (like doing business paperwork), I prefer to have quiet music in the background to help me stay focussed. Quiet background music is good for meditation or dozing, too. If you can’t fall asleep or completely clear your mind, zoning out to some music is the next best thing.
|
||||
|
||||
The best music for that is simple and repetitive — something nice enough to listen too, but not distracting, and okay to tune out of when needed. Computer game music is like that, by design, so there’s plenty of good background music out there. The harder problem is finding samples that play for more than a few minutes.
|
||||
|
||||
So I made [`loopx`][1], a tool that takes a sample of music that loops a few times, and repeats the loop to make a long piece of music.
|
||||
|
||||
When you’re listening to the same music loop for a long time, even slight distortion becomes distracting. Making quality extended music audio out of real-world samples (and doing it fast enough) takes a bit of maths and computer science. About ten years ago I was doing digital signal processing (DSP) programming for industrial metering equipment, so this side project got me digging up some old theory again.
|
||||
|
||||
### The high-level plan
|
||||
|
||||
It would be easy if we could just play the original music sample on repeat. But, in practice, most files we’ll have won’t be perfectly trimmed to the right loop length. Some tracks will also have some kind of intro before the loop, but even if they don’t, they’ll usually have some fade in and out.
|
||||
|
||||
`loopx` needs to analyse the music file to find the music loop data, and then construct a longer version by copying and splicing together pieces of the original.
|
||||
|
||||
By the way, the examples in this post use [Beneath the Rabbit Holes][2] by Jason Lavallee from the soundtrack of the [FOSS platform game SuperTux][3]. I looped it a couple of times and added silence and fade in/out to the ends.
|
||||
|
||||
### Measuring the music loop length (or “period”)
|
||||
|
||||
If you don’t care about performance, estimating the period at which the music repeats itself is pretty straightforward. All you have to do is take two copies of the music side by side, and slide one copy along until you find an offset that makes the two copies match up again.
|
||||
|
||||
![][4]
|
||||
|
||||
Now, if we could guarantee the music data would repeat exactly, there are many super-fast algorithms that could be used to help here (e.g., Rabin-Karp or suffix trees). However, even if we’re looking at computer-generated music, we can’t guarantee the loop will be exact for a variety of reasons like phase distortion (which will come up again later), dithering and sampling rate effects.
|
||||
|
||||
![Converting this greyscale image of a ball in a room to a black/white image demonstrates dithering. Simple thresholding turns the image into regions of solid black and regions of solid white, with all detail lost except near the threshold. Adding random noise before converting fuzzes the threshold, allowing more detail to come through. This example is extreme, but the same idea is behind dithering digital audio when approximating smooth analogue signals.][5]
|
||||
|
||||
By the way, Chris Montgomery (who developed Ogg Vorbis) made [an excellent presentation about the real-world issues (and non-issues) with digital audio][6]. There’s a light-hearted video that’s about 20 minutes and definitely worth watching if you have any interest in this stuff. Before that, he also did [an intro to the technical side of digital media][7] if you want to start from the beginning.
|
||||
|
||||
If exact matching isn’t an option, we need to find a best fit instead, using one of the many vector similarity algorithms. The problem is that any good similarity algorithm will look at all the vector data and be (O(N)) time at best. If we naïvely calculate that at every slide offset, finding the best fit will be (O(N^{2})) time. With over 40k samples for every second of music (multiplied by the number of channels), these vectors are way too big for that approach to be fast enough.
|
||||
|
||||
Thankfully, we can do it in (O(N\log N)) time using the Fourier transform if we choose to use autocorrelation to find the best fit. Autocorrelation means taking the dot product at every offset, and with some normalisation that’s a bit like using cosine similarity.
|
||||
|
||||
![Log energy plot of the autocorrelation of the Beneath the Rabbit Holes sample \(normalised by overlap length\). This represents the closeness of match when the music is compared to a time-shifted version of itself. Naturally, there's a peak at 0 minutes offset, but the next biggest peak is at 2m58.907s, which happens to be exactly the length of the original music loop. The smaller peaks reflect small-scale patterns, such as the music rhythm.][8]
|
||||
|
||||
### The Fourier transform?
|
||||
|
||||
The Fourier transform is pretty famous in some parts of STEM, but not others. It’s used a lot in `loopx`, so here are some quick notes for those in the second group.
|
||||
|
||||
There are a couple of ways to think about and use the Fourier transform. The first is the down-to-earth way: it’s an algorithm that takes a signal and analyses the different frequencies in it. If you take Beethoven’s Symphony No. 9 in D minor, Op 125, Ode to Joy, and put it through a Fourier transform, you’ll get a signal with peaks that correspond to notes in the scale of D minor. The Fourier transform is reversible, so it allows manipulating signals in terms of frequency, too.
|
||||
|
||||
The second way to think of Fourier transforms is stratospherically abstract: the Fourier transform is a mapping between two vector spaces, often called the time domain and the frequency domain. It’s not just individual vectors that have mirror versions in the other domain. Operations on vectors and differential equations over vectors and so on can all be transformed, too. Often the version in one domain is simpler than the version in the other, making the Fourier transform a useful theoretical tool. In this case, it turns out that autocorrelation is very simple in the frequency domain.
|
||||
|
||||
The Fourier transform is used both ways in `loopx`. Because Fourier transforms represent most of the number crunching, `loopx` uses [FFTW][9], a “do one thing really, really well” library for fast Fourier transform implementations.
|
||||
|
||||
### Dealing with phase distortion
|
||||
|
||||
I had some false starts implementing `loopx` because of a practical difference between industrial signal processing and sound engineering: psychoacoustics. Our ears are basically an array of sensors tuned to different frequencies. That’s it. Suppose you play two tones into your ears, with different phases (i.e., they’re shifted in time relatively to each other). You literally can’t hear the difference because there’s no wiring between the ears and the brain carrying that information.
|
||||
|
||||
![][10]
|
||||
|
||||
Sure, if you play several frequencies at once, phase differences can interact in ways that are audible, but phase matters less overall. A sound engineer who has to make a choice between phase distortion and some other kind of distortion will tend to favour phase distortion because it’s less noticeable. Phase distortion is usually simple and consistent, but phase distortion from popular lossy compression standards like MP3 and Ogg Vorbis seems to be more complicated.
|
||||
|
||||
Basically, when you zoom right into the audio data, any algorithmic approach that’s sensitive to the precise timing of features is hopeless. Because audio files are designed for phase-insensitve ears, I had to make my algorithms phase-insensitive too to get any kind of robustness. That’s probably not news to anyone with real audio engineering experience, but it was a bit of an, “Oh,” moment for someone like me coming from metering equipment DSP.
|
||||
|
||||
I ended up using spectrograms a lot. They’re 2D heatmaps in which one axis represents time, and the other axis represents frequency. The example below shows how they make high-level music features much more recognisable, without having to deal with low-level issues like phase. (If you’re curious, you can see [a 7833x192 spectrogram of both channels of the whole track][11].)
|
||||
|
||||
![Spectrogram of the first 15s of Beneath the Rabbit Holes. Time advances to the right. Each vertical strip shows the signal strength by frequency at a given time window, which low notes at the bottom and high ones at the top. The bright strip at the bottom is the bass. The vertical streaks are percussion. The melody starts at about 10s, and appears as dots for notes.][12]
|
||||
|
||||
The Fourier transform does most of the work of getting frequency information out of music, but a bit more is needed to get a useful spectrogram. The Fourier transform works over the whole input, so instead of one transformation, we need to do transformations of overlapping windows running along the input. Each windowed transformation turns into a single frame of the spectrogram after a bit of postprocessing. The Fourier transform uses a linear frequency scale, which isn’t natural for music (every 8th white key on a piano has double the pitch), so frequencies get binned according to a Mel scale (designed to approximate human pitch perception). After that, the total energy for each frequency gets log-transformed (again, to match human perception). [This article describes the steps in detail][13] (ignore the final DCT step).
|
||||
|
||||
### Finding the loop zone
|
||||
|
||||
Remember that the music sample will likely have some intro and outro? Before doing more processing, `loopx` needs to find the section of the music sample that actually loops (what’s called the “loop zone” in the code). It’s easy in principle: scan along the music sample and check if it matches up with the music one period ahead. The loop zone is assumed to be the longest stretch of music that matches (plus the one period at the end). Processing the spectrogram of the music, instead of the raw signal itself, turned out to be more robust.
|
||||
|
||||
![The difference between each spectrogram frame and the one that's a music period after in the Beneath the Rabbit Holes sample. The difference is high at the beginning and end because of the silence and fade in/out. The difference is low in the middle because of the music loop.][14]
|
||||
|
||||
A human can eyeball a plot like the one above and see where the intro and outro are. However, the error thresholds for “match” and “mismatch” vary depending on the sample quality and how accurate the original period estimate are, so finding a reliable computer algorithm is more complicated. There are statistical techniques for solving this problem (like Otsu’s method), but `loopx` just exploits the assumption that a loop zone exists, and figures out thresholds based on low-error sections of the plot. A variant of Schmitt triggering is used to get a good separation between the loop zone and the rest.
|
||||
|
||||
### Refining the period estimate
|
||||
|
||||
Autocorrelation is pretty good for estimating the period length, but a long intro or outro can pull the estimate either way. Knowing the loop zone lets us refine the estimate: any recognisable feature (like a chord change or drum beat) inside the loop zone will repeat one period before or after. If we find a pair of distinctive features, we can measure the difference to get an accurate estimate of the period.
|
||||
|
||||
`loopx` finds the strongest features in the music using a novelty curve — which is just the difference between one spectrogram frame and the next. Any change (a beat, a note, a change of key) will cause a spike in this curve, and the biggest spikes are taken as points of interest. Instead of trying to find the exact position of music features (which would be fragile), `loopx` just takes the region around a point of interest and its period-shifted pair, and uses cross-correlation to find the shift that makes them best match (just like the autocorrelation, but between two signals). For robustness, shifts are calculated for a bunch of points and the median is used to correct the period. The median is better than the average because each single-point correction estimate is either highly accurate alone or way off because something went wrong.
|
||||
|
||||
### Extending the music
|
||||
|
||||
The loop zone has the useful property that jumping back or forward a multiple of the music period keeps the music playing uninterrupted, as long as playback stays within the loop zone. This is the essence of how `loopx` extends music. To make a long output, `loopx` copies music data from the beginning until it hits the end of the loop zone. Then it jumps back as many periods as it can (staying inside the loop zone) and keeps repeating copies like that until it has output enough data. Then it just keeps copying to the end.
|
||||
|
||||
That sounds simple, but if you’ve ever tried it you’ll know there’s one more problem. Most music is made of smooth waves. If you just cut music up in arbitrary places and concatenate the pieces together, you get big jumps in the wave signal that turn into jarring popping sounds when played back as an analogue signal. When I’ve done this by hand, I’ve tried to minimise this distortion by making the curve as continuous as possible. For example, I might find a place in the first fragment of audio where the signal crosses the zero line going down, and I’ll try to match it up with a place in the second fragment that’s also crossing zero going down. That avoids a loud pop, but it’s not perfect.
|
||||
|
||||
An alternative that’s actually easier to implement in code is a minimum-error match. Suppose you’re splicing signal A to signal B, and you want to evaluate how good the splice is. You can take some signal near the splice point and compare it to what the signal would have been if signal A had kept playing. Simply substracting and summing the squares gives a reasonable measure of quality. I also tried filtering the errors before squaring and summing because distortion below 20Hz and above 20kHz isn’t as bad as distortion inside normal human hearing range. This approach improved the splices a lot, but it wasn’t reliable at making them seamless. I don’t have super hearing ability, but the splices got jarring when listening to a long track with headphones in a quiet room.
|
||||
|
||||
Once again, the spectral approach was more robust. Calculating the spectrum around the splice and comparing it to the spectrum around the original signal is a useful way to measure splice quality. The pop sound of a broken audio signal appears as an obvious burst of noise across most of the spectrum. Even better, because the spectrum is designed to reflect human hearing, it also catches any other annoying effects, like a blip caused by a bad splice right on the edge of a drum beat. Anything that’s obvious to a human will be obvious in the spectrogram.
|
||||
|
||||
![Examples of how splicing affects the local music spectrum. The signal plots on the left show the splice point and a few hundred audio samples either side. The spectra on the right are calculated from a few thousand samples either side of the splice point. The centre row shows the original, unspliced signal and its spectrum. The spectrum of the bad splice is flooded with noise and is obviously different from the original spectrum. The spectrum of the improved splice looks much more like the original. The audio signal already looks reasonably smooth in the time domain, but loopx is able to find even better splices by looking at the spectra.][15]
|
||||
|
||||
There are multiple splice points that need to be made seamless. The simple approach to optimising them is a greedy one: just process each splice point in order and take the best splice found locally. However, `loopx` also tries to maintain the music loop length as best as possible, which means each splice point will depend on the splicing decisions made earlier. That means later splices can be forced to be worse because of overeager decisions made earlier.
|
||||
|
||||
Now, I admit this might be getting into anal retentive territory, but I wasn’t totally happy with about %5 of the tracks I tested, and I wanted a tool that could reliably make music better than my hearing (assuming quality input data). So I switched to optimising the splices using Dijkstra’s algorithm. Normally Dijkstra is thought of as an algorithm for figuring out the shortest path from start to finish using available path segments. In this case, I’m finding the least distortion series of copies to get from an empty output audio file to one that’s the target length, using spliced segments of the input file. Abstractly, it’s the same problem. I also calculate cost a little differently. In normal path finding, the path cost is the sum of the segment costs. However, total distortion isn’t the best measure for `loopx`. I don’t care if Dijkstra’s algorithm can make an almost-perfect splice perfect if it means making an annoying splice worse. So, `loopx` finds the copy plan with the least worst-case distortion level. That’s no problem because Dijkstra’s algorithm works just as well finding min-max as it does finding min-sum (abstractly, it just needs paths to be evaluated in a way that’s a total ordering and never improves when another segment is added).
|
||||
|
||||
### Enjoying the music
|
||||
|
||||
It’s rare for any of my hobby programming projects to actually be useful at all to my everyday life away from computers, but I’ve already found multiple uses for background music generated by `loopx`. As usual, [the full source is available on GitLab][1].
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://theartofmachinery.com/2021/03/12/loopx.html
|
||||
|
||||
作者:[Simon Arneaud][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://theartofmachinery.com
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://gitlab.com/sarneaud/loopx
|
||||
[2]: https://github.com/SuperTux/supertux/blob/56efa801a59e7e32064b759145e296a2d3c11e44/data/music/forest/beneath_the_rabbit_hole.ogg
|
||||
[3]: https://github.com/SuperTux/supertux
|
||||
[4]: https://theartofmachinery.com/images/loopx/shifted.jpg
|
||||
[5]: https://theartofmachinery.com/images/loopx/dither_demo.png
|
||||
[6]: https://wiki.xiph.org/Videos/Digital_Show_and_Tell
|
||||
[7]: https://wiki.xiph.org/Videos/A_Digital_Media_Primer_For_Geeks
|
||||
[8]: https://theartofmachinery.com/images/loopx/autocorrelation.jpg
|
||||
[9]: http://www.fftw.org/
|
||||
[10]: https://theartofmachinery.com/images/loopx/phase_shift.svg
|
||||
[11]: https://theartofmachinery.com/images/loopx/spectrogram.png
|
||||
[12]: https://theartofmachinery.com/images/loopx/spectrogram_intro.png
|
||||
[13]: https://www.practicalcryptography.com/miscellaneous/machine-learning/guide-mel-frequency-cepstral-coefficients-mfccs/
|
||||
[14]: https://theartofmachinery.com/images/loopx/loop_zone_errors.png
|
||||
[15]: https://theartofmachinery.com/images/loopx/splice.png
|
@ -1,5 +1,5 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: translator: (stevenzdg988)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
@ -227,7 +227,7 @@ via: https://opensource.com/article/20/1/open-source-tools-nodejs
|
||||
|
||||
作者:[Hiren Dhadhuk][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
译者:[stevenzdg988](https://github.com/stevenzdg988)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
@ -1,84 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Turn your Raspberry Pi into a HiFi music system)
|
||||
[#]: via: (https://opensource.com/article/21/1/raspberry-pi-hifi)
|
||||
[#]: author: (Peter Czanik https://opensource.com/users/czanik)
|
||||
|
||||
Turn your Raspberry Pi into a HiFi music system
|
||||
======
|
||||
Play music for your friends, family, co-workers, or anyone else with an
|
||||
inexpensive audiophile setup.
|
||||
![HiFi vintage stereo][1]
|
||||
|
||||
For the past 10 years, I've worked remotely most of the time, but when I go into the office, I sit in a room full of fellow introverts who are easily disturbed by ambient noise and talking. We discovered that listening to music can suppress office noise, make voices less distracting, and provide a pleasant working environment with enjoyable music.
|
||||
|
||||
Initially, one of our colleagues brought in some old powered computer speakers, connected them to his desktop, and asked us what we wanted to listen to. It did its job, but the sound quality wasn't great, and it only worked when he was in the office. Next, we bought a pair of Altec Lansing speakers. The sound quality improved, but flexibility did not.
|
||||
|
||||
Not much later, we got a generic Arm single-board computer (SBC). This meant anyone could control the playlist and the speakers over the network using a web interface. But a random Arm developer board meant we could not use popular music appliance software. Updating the operating system was a pain due to a non-standard kernel, and the web interface broke frequently.
|
||||
|
||||
When the team grew and moved into a larger room, we started dreaming about better speakers and an easier way to handle the software and hardware combo.
|
||||
|
||||
To solve our issue in a way that is relatively inexpensive, flexible, and has good sound quality, we developed an office HiFi with a Raspberry Pi, speakers, and open source software.
|
||||
|
||||
### HiFi hardware
|
||||
|
||||
Having a dedicated PC for background music is overkill. It's expensive, noisy (unless it's silent, but then it's even more expensive), and not environmentally friendly. Even the cheapest Arm boards are up to the job, but they're often problematic from the software point of view. The Raspberry Pi is still on the cheap end and, while not standards-compliant, is well-supported on the hardware and the software side.
|
||||
|
||||
The next question was: what speakers to use. Good-quality, powered speakers are expensive. Passive speakers cost less but need an amplifier, and that would add another box to the setup. They would also have to use the Pi's audio output; while it works, it's not exactly the best, especially when you're already spending money on quality speakers and an amplifier.
|
||||
|
||||
Luckily, among the thousands of Raspberry Pi hardware extensions are amplifiers with built-in digital-analog converters (DAC). We selected [HiFiBerry's Amp][2]. It was discontinued soon after we bought it (replaced by an Amp+ model with a better sample rate), but it's good enough for our purposes. With air conditioning on, I don't think you can hear the difference between a DAC capable of 48kHz or 192kHz anyway.
|
||||
|
||||
For speakers, we chose the [Audioengine P4][3], which we bought when a shop had a clearance sale with extra-low prices. It easily fills our office room with sound without distortion (and fills much more than our room with some distortion, but neighboring engineers tend to dislike that).
|
||||
|
||||
### HiFi software
|
||||
|
||||
Maintaining Ubuntu on our old generic Arm SBC with a fixed, ancient, out-of-packaging system kernel was problematic. The Raspberry Pi OS includes a well-maintained kernel package, making it a stable and easily updated base system, but it still required us to regularly update a Python script to access Spotify and YouTube. That was a little too high-maintenance for our purposes.
|
||||
|
||||
Luckily, using the Raspberry Pi as a base means there are many ready-to-use software appliances available.
|
||||
|
||||
We settled on [Volumio][4], an open source project that turns a Pi into a music-playing appliance. Installation is a simple _next-next-finish_ process. Instead of painstakingly installing and maintaining an operating system and regularly debugging broken Python code, installation and upgrades are completely pain-free. Configuring the HiFiBerry amplifier doesn't require editing any configuration files; you can just select it from a list. Of course, getting used to a new user interface takes some time, but the stability and ease of maintenance made this change worthwhile.
|
||||
|
||||
![Volumio interface][5]
|
||||
|
||||
Screenshot courtesy of [Volumeio][4] (© Michelangelo Guarise)
|
||||
|
||||
### Playing music and experimenting
|
||||
|
||||
While we're all working from home during the pandemic, the office HiFi is installed in my home office, which means I have free reign over what it runs. A constantly changing user interface would be a pain for a team, but for someone with an R&D background, playing with a device on my own, change is fun.
|
||||
|
||||
I'm not a programmer, but I have a strong Linux and Unix sysadmin background. That means that while I find fixing broken Python code tiresome, Volumio is just perfect enough to be boring for me (a great "problem" to have). Luckily, there are many other possibilities to play music on a Raspberry Pi.
|
||||
|
||||
As a terminal maniac (I even start LibreOffice from a terminal window), I mostly use Music on Console ([MOC][6]) to play music from my network-attached storage (NAS). I have hundreds of CDs, all turned into [FLAC][7] files. And I've also bought many digital albums from sources like [BandCamp][8] or [Society of Sound][9].
|
||||
|
||||
Another option is the [Music Player Daemon (MPD)][10]. With it running on the Raspberry Pi, I can interact with my music remotely over the network using any of the many clients available for Linux and Android.
|
||||
|
||||
### Can't stop the music
|
||||
|
||||
As you can see, the possibilities for creating an inexpensive HiFi system are almost endless on both the software and the hardware side. Our solution is just one of many, and I hope it inspires you to build something that fits your environment.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/1/raspberry-pi-hifi
|
||||
|
||||
作者:[Peter Czanik][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/czanik
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/hi-fi-stereo-vintage.png?itok=KYY3YQwE (HiFi vintage stereo)
|
||||
[2]: https://www.hifiberry.com/products/amp/
|
||||
[3]: https://audioengineusa.com/shop/passivespeakers/p4-passive-speakers/
|
||||
[4]: https://volumio.org/
|
||||
[5]: https://opensource.com/sites/default/files/uploads/volumeio.png (Volumio interface)
|
||||
[6]: https://en.wikipedia.org/wiki/Music_on_Console
|
||||
[7]: https://xiph.org/flac/
|
||||
[8]: https://bandcamp.com/
|
||||
[9]: https://realworldrecords.com/news/society-of-sound-statement/
|
||||
[10]: https://www.musicpd.org/
|
@ -1,105 +0,0 @@
|
||||
[#]: subject: (Use gImageReader to Extract Text From Images and PDFs on Linux)
|
||||
[#]: via: (https://itsfoss.com/gimagereader-ocr/)
|
||||
[#]: author: (Ankush Das https://itsfoss.com/author/ankush/)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
Use gImageReader to Extract Text From Images and PDFs on Linux
|
||||
======
|
||||
|
||||
_Brief: gImageReader is a GUI tool to utilize tesseract OCR engine for extracting texts from images and PDF files in Linux._
|
||||
|
||||
[gImageReader][1] is a front-end for [Tesseract Open Source OCR Engine][2]. _Tesseract_ was originally developed at HP and then was open-sourced in 2006.
|
||||
|
||||
Basically, the OCR (Optical Character Recognition) engine lets you scan texts from a picture or a file (PDF). It can detect several languages by default and also supports scanning through Unicode characters.
|
||||
|
||||
However, the Tesseract by itself is a command-line tool without any GUI. So, here, gImageReader comes to the rescue to let any user utilize it to extract text from images and files.
|
||||
|
||||
Let me highlight a few things about it while mentioning my experience with it for the time I tested it out.
|
||||
|
||||
### gImageReader: A Cross-Platform Front-End to Tesseract OCR
|
||||
|
||||
![][3]
|
||||
|
||||
To simplify things, gImageReader comes in handy to extract text from a PDF file or an image that contains any kind of text.
|
||||
|
||||
Whether you need it for spellcheck or translation, it should be useful for a specific group of users.
|
||||
|
||||
To sum up the features in a list, here’s what you can do with it:
|
||||
|
||||
* Add PDF documents and images from disk, scanning devices, clipboard and screenshots
|
||||
* Ability to rotate images
|
||||
* Common image controls to adjust brightness, contrast, and resolution
|
||||
* Scan images directly through the app
|
||||
* Ability to process multiple images or files in one go
|
||||
* Manual or automatic recognition area definition
|
||||
* Recognize to plain text or to [hOCR][4] documents
|
||||
* Editor to display the recognized text
|
||||
* Can spellcheck the text extracted
|
||||
* Convert/Export to PDF documents from hOCR document
|
||||
* Export extracted text as a .txt file
|
||||
* Cross-platform (Windows)
|
||||
|
||||
|
||||
|
||||
### Installing gImageReader on Linux
|
||||
|
||||
**Note**: _You need to explicitly install Tesseract language packs to detect from images/files from your software manager._
|
||||
|
||||
![][5]
|
||||
|
||||
You can find gImageReader in the default repositories for some Linux distributions like Fedora and Debian.
|
||||
|
||||
For Ubuntu, you need to add a PPA and then install it. To do that, here’s what you need to type in the terminal:
|
||||
|
||||
```
|
||||
sudo add-apt-repository ppa:sandromani/gimagereader
|
||||
sudo apt update
|
||||
sudo apt install gimagereader
|
||||
```
|
||||
|
||||
You can also find it for openSUSE from its build service and [AUR][6] will be the place for Arch Linux users.
|
||||
|
||||
All the links to the repositories and the packages can be found in their [GitHub page][1].
|
||||
|
||||
[gImageReader][1]
|
||||
|
||||
### Experience with gImageReader
|
||||
|
||||
gImageReader is a quite useful tool for extracting texts from images when you need them. It works great when you try from a PDF file.
|
||||
|
||||
For extracting images from a picture shot on a smartphone, the detection was close but a bit inaccurate. Maybe when you scan something, recognition of characters from the file could be better.
|
||||
|
||||
So, you’ll have to try it for yourself to see how well it works for your use-case. I tried it on Linux Mint 20.1 (based on Ubuntu 20.04).
|
||||
|
||||
I just had an issue to manage languages from the settings and I didn’t get a quick solution for that. If you encounter the issue, you might want to troubleshoot it and explore more about it how to fix it.
|
||||
|
||||
![][7]
|
||||
|
||||
Other than that, it worked just fine.
|
||||
|
||||
Do give it a try and let me know how it worked for you! If you know of something similar (and better), do let me know about it in the comments below.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/gimagereader-ocr/
|
||||
|
||||
作者:[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://github.com/manisandro/gImageReader
|
||||
[2]: https://tesseract-ocr.github.io/
|
||||
[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/03/gImageReader.png?resize=800%2C456&ssl=1
|
||||
[4]: https://en.wikipedia.org/wiki/HOCR
|
||||
[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/03/tesseract-language-pack.jpg?resize=800%2C620&ssl=1
|
||||
[6]: https://itsfoss.com/aur-arch-linux/
|
||||
[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/03/gImageReader-1.jpg?resize=800%2C460&ssl=1
|
@ -1,107 +0,0 @@
|
||||
[#]: subject: (How to Update openSUSE Linux System)
|
||||
[#]: via: (https://itsfoss.com/update-opensuse/)
|
||||
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
How to Update openSUSE Linux System
|
||||
======
|
||||
|
||||
I have been an Ubuntu user for as long as I remember. I distrohopped a little but keep on coming back to Ubuntu. But recently, I have started using openSUSE to try something non-Debian.
|
||||
|
||||
As I keep exploring [openSUSE][1], I keep on stumbling upon things that are slightly different in SUSE-worse and I plan to cover them in tutorials on It’s FOSS.
|
||||
|
||||
As a first, I am writing about updating openSUSE system. There are two ways you can do that:
|
||||
|
||||
* Using terminal (valid for openSUSE desktops and servers)
|
||||
* Using a graphical tool (valid for openSUSE desktops)
|
||||
|
||||
|
||||
|
||||
### Update openSUSE via command line
|
||||
|
||||
The simplest way to update openSUSE is by using the zypper command. It provides full functionality of patches and updates management. It takes care of the file conflicts and dependency problems. The updates also include Linux kernel.
|
||||
|
||||
If you are using openSUSE Leap, use this command:
|
||||
|
||||
```
|
||||
sudo zypper update
|
||||
```
|
||||
|
||||
You may also use `up` instead of `update` but I find it easier to remember.
|
||||
|
||||
If you are using openSUSE Tumbleweed, use the `dist-upgrade` or `dup` (in short). Tumbleweed is [rolling release distribution][2] and hence it is advised to use dist-upgrade option.
|
||||
|
||||
```
|
||||
sudo zypper dist-upgrade
|
||||
```
|
||||
|
||||
It will show you the list of the packages to be upgraded, removed or installed.
|
||||
|
||||
![][3]
|
||||
|
||||
You’ll be notified if your system requires reboots.
|
||||
|
||||
If you just want to refresh the repositories (like sudo apt update), you may use this command:
|
||||
|
||||
```
|
||||
sudo zypper refresh
|
||||
```
|
||||
|
||||
If you want to list the available updates, you can also do that:
|
||||
|
||||
```
|
||||
sudo zypper list-updates
|
||||
```
|
||||
|
||||
### Graphical way to update openSUSE
|
||||
|
||||
If you are using openSUSE as a desktop, you’ll have the additional option of using the GUI tools for installing the updates. This tool may change depending on [which desktop environment you are using][4].
|
||||
|
||||
For example, KDE has its own Software center called Discover. You can use it to search and install new applications. You can also use it to install system updates.
|
||||
|
||||
![][5]
|
||||
|
||||
In fact, KDE notifies you of available system updates in the notification area. You’ll have to open Discover explicitly because clicking on the notification doesn’t automatically take you to Discover.
|
||||
|
||||
![][6]
|
||||
|
||||
If you find that annoying, you may disable it using these commands:
|
||||
|
||||
```
|
||||
sudo zypper remove plasma5-pk-updates
|
||||
sudo zypper addlock plasma5-pk-updates
|
||||
```
|
||||
|
||||
I wouldn’t recommend it though. It’s better to get notified of available updates.
|
||||
|
||||
There is also the YAST Software Management [GUI tool][7] which you can use for more granular control on package managements.
|
||||
|
||||
![][8]
|
||||
|
||||
That’s it. It was a short one. In the next SUSE tutorial, I’ll show you some common zypper commands with examples. Stay tuned.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/update-opensuse/
|
||||
|
||||
作者:[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.opensuse.org/
|
||||
[2]: https://itsfoss.com/rolling-release/
|
||||
[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/03/update-opensuse-with-zypper.png?resize=800%2C406&ssl=1
|
||||
[4]: https://itsfoss.com/find-desktop-environment/
|
||||
[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/03/opensuse-update-gui.png?resize=800%2C500&ssl=1
|
||||
[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/03/update-notification-opensuse.png?resize=800%2C259&ssl=1
|
||||
[7]: https://itsfoss.com/gui-cli-tui/
|
||||
[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/03/yast-software-management-suse.png?resize=800%2C448&ssl=1
|
@ -2,7 +2,7 @@
|
||||
[#]: via: (https://opensource.com/article/21/3/files-freedos)
|
||||
[#]: author: (Kevin O'Brien https://opensource.com/users/ahuka)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
@ -1,187 +0,0 @@
|
||||
[#]: subject: (Linux Mint Cinnamon vs MATE vs Xfce: Which One Should You Use?)
|
||||
[#]: via: (https://itsfoss.com/linux-mint-cinnamon-mate-xfce/)
|
||||
[#]: author: (Dimitrios https://itsfoss.com/author/dimitrios/)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
Linux Mint Cinnamon vs MATE vs Xfce: Which One Should You Use?
|
||||
======
|
||||
|
||||
Linux Mint is undoubtedly [one of the best Linux distributions for beginners][1]. This is especially true for Windows users that walking their first steps to Linux world.
|
||||
|
||||
Since 2006, the year that Linux Mint made its first release, a selection of [tools][2] has been developed to enhance user experience. Furthermore, Linux Mint is based on Ubuntu, so you have a large community of users to seek help.
|
||||
|
||||
I am not going to discuss how good Linux Mint is. If you have already made your mind to [install Linux Mint][3], you probably get a little confused on the [download section][4] on its website.
|
||||
|
||||
It gives you three options to choose from: Cinnamon, MATE and Xfce. Confused? I’ll help you with that in this article.
|
||||
|
||||
![][5]
|
||||
|
||||
If you are absolutely new to Linux and have no idea about what the above things are, I recommend you to understand a bit on [what is a desktop environment in Linux][6]. And if you could spare some more minutes, read this excellent explanation on [what is Linux and why there are so many of Linux operating systems that look similar to each other][7].
|
||||
|
||||
With that information, you are ready to understand the difference between the various Linux Mint editions. If you are unsure which to choose, with this article I will help you to make a conscious choice.
|
||||
|
||||
### Which Linux Mint version should you choose?
|
||||
|
||||
![][8]
|
||||
|
||||
Briefly, the available choices are the following:
|
||||
|
||||
* **Cinnamon desktop:** A modern touch on traditional desktop
|
||||
* **MATE desktop:** A traditional looking desktop resembling the GNOME 2 era.
|
||||
* **Xfce desktop:** A popular lightweight desktop environment.
|
||||
|
||||
|
||||
|
||||
Let’s have a look at the Mint variants one by one.
|
||||
|
||||
#### Linux Mint Cinnamon edition
|
||||
|
||||
Cinnamon desktop is developed by Linux Mint team and clearly it is the flagship edition of Linux Mint.
|
||||
|
||||
Almost a decade back when the GNOME desktop opted for the unconventional UI with GNOME 3, Cinnamon development was started to keep the traditional looks of the desktop by forking some components of GNOME 2.
|
||||
|
||||
Many Linux users like Cinnamon for its similarity with Windows 7 like interface.
|
||||
|
||||
![Linux Mint Cinnamon desktop][9]
|
||||
|
||||
##### Performance and responsiveness
|
||||
|
||||
The cinnamon desktop performance has improved from the past releases but without an SSD you can feel a bit sluggish. The last time I used cinnamon desktop was in version 4.4.8, the RAM consumption right after boot was around 750mb. There is a huge improvement in the current version 4.8.6, reduced by 100mb after boot.
|
||||
|
||||
To get the best user experience, a dual-core CPU with 4 GB of RAM as a minimum should be considered.
|
||||
|
||||
![Linux Mint 20 Cinnamon idle system stats][10]
|
||||
|
||||
##### Pros
|
||||
|
||||
* Seamless switch from Windows
|
||||
* Pleasing aesthetics
|
||||
* Highly [customizable][11]
|
||||
|
||||
|
||||
|
||||
##### Cons
|
||||
|
||||
* May still not be ideal if you have a system with 2 GB RAM
|
||||
|
||||
|
||||
|
||||
**Bonus Tip**: If you prefer Debian instead of Ubuntu you have the option of [Linux Mint Debian Edition][12]. The main difference between LMDE and Debian with Cinnamon desktop is that LMDE ships the latest desktop environment to its repositories.
|
||||
|
||||
#### Linux Mint Mate edition
|
||||
|
||||
[MATE desktop environment][13] shares a similar story as it aims to maintain and support the GNOME 2 code base and applications. The Look and feel is very similar to GNOME 2.
|
||||
|
||||
In my opinion, the best implementation of MATE desktop is by far [Ubuntu MATE][14]. In Linux Mint you get a customized version of MATE desktop, which is in line with Cinnamon aesthetics and not to the traditional GNOME 2 set out.
|
||||
|
||||
![Screenshot of Linux Mint MATE desktop][15]
|
||||
|
||||
##### Performance and responsiveness
|
||||
|
||||
MATE desktop has a reputation of its lightweight nature and there is no doubt about that. Compared to Cinnamon desktop, the CPU usage always remains a bit lower, and this can be translated to a better battery life on a laptop.
|
||||
|
||||
Although it doesn’t feel as snappy as Xfce (in my opinion), but not to an extent to compromise user experience. RAM consumption starts under 500mb which is impressive for a feature rich desktop environment.
|
||||
|
||||
![Linux Mint 20 MATE idle system stats][16]
|
||||
|
||||
##### Pros
|
||||
|
||||
* Lightweight desktop without compromising on [features][17]
|
||||
* Enough [customization][18] potential
|
||||
|
||||
|
||||
|
||||
##### Cons
|
||||
|
||||
* Traditional looks may give you a dated feel
|
||||
|
||||
|
||||
|
||||
#### Linux Mint Xfce edition
|
||||
|
||||
XFCE project started in 1996 inspired by the [Common Desktop Environment][19] of UNIX. XFCE” stands for “[XForms][20] Common Environment”, but since it no longer uses the XForms toolkit, the name is spelled as “Xfce”.
|
||||
|
||||
It aims to be fast, lightweight and easy to use. Xfce is the flagship desktop of many popular Linux distributions like [Manjaro][21] and [MX Linux][22].
|
||||
|
||||
Linux Mint offers a polished Xfce desktop but can’t match the beauty of Cinnamon desktop even in a Dark theme.
|
||||
|
||||
![Linux Mint 20 Xfce desktop][23]
|
||||
|
||||
##### Performance and responsiveness
|
||||
|
||||
Xfce is the leanest desktop environment Linux Mint has to offer. By clicking the start menu, the settings control panel or exploring the bottom panel you will notice that this is a simple yet a flexible desktop environment.
|
||||
|
||||
Despite I find minimalism a positive attribute, Xfce is not an eye candy, leaving a more traditional taste. For some users a classic desktop environment is the one to go for.
|
||||
|
||||
At the first boot the ram usage is similar to MATE desktop but not quite as good. If your computer isn’t equipped with an SSD, Xfce desktop environment can resurrect your system.
|
||||
|
||||
![Linux Mint 20 Xfce idle system stats][24]
|
||||
|
||||
##### Pros
|
||||
|
||||
* Simple to use
|
||||
* Very lightweight – suitable for older hardware
|
||||
* Rock-solid stable
|
||||
|
||||
|
||||
|
||||
##### Cons
|
||||
|
||||
* Outdated look
|
||||
* May not have as much customization to offer in comparison to Cinnamon
|
||||
|
||||
|
||||
|
||||
#### Conclusion
|
||||
|
||||
Since all these three desktop environments are based on GTK toolkit, the choice is purely a matter of taste. All of them are easy on system resources and perform well for a modest system with 4 GB RAM. Xfce and MATE can go a bit lower by supporting systems with as low as 2 GB RAM.
|
||||
|
||||
Linux Mint is not the only distribution that provides multiple choices. Distros like Manjaro, Fedora and [Ubuntu have various flavors][25] to choose from as well.
|
||||
|
||||
If you still cannot make your mind, I’ll say go with the default Cinnamon edition first and try to [use Linux Mint in a virtual box][26]. See if you like the look and feel. If not, you can test other variants in the same fashion. If you decide on the version, you can go on and [install it on your main system][3].
|
||||
|
||||
I hope I was able to help you with this article. If you still have questions or suggestions on this topic, please leave a comment below.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/linux-mint-cinnamon-mate-xfce/
|
||||
|
||||
作者:[Dimitrios][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/dimitrios/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://itsfoss.com/best-linux-beginners/
|
||||
[2]: https://linuxmint-developer-guide.readthedocs.io/en/latest/mint-tools.html#
|
||||
[3]: https://itsfoss.com/install-linux-mint/
|
||||
[4]: https://linuxmint.com/download.php
|
||||
[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/03/linux-mint-version-options.png?resize=789%2C277&ssl=1
|
||||
[6]: https://itsfoss.com/what-is-desktop-environment/
|
||||
[7]: https://itsfoss.com/what-is-linux/
|
||||
[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/03/Linux-Mint-variants.jpg?resize=800%2C450&ssl=1
|
||||
[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/03/linux-mint-20.1-cinnamon.jpg?resize=800%2C500&ssl=1
|
||||
[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/03/Linux-Mint-20-Cinnamon-ram-usage.png?resize=800%2C600&ssl=1
|
||||
[11]: https://itsfoss.com/customize-cinnamon-desktop/
|
||||
[12]: https://itsfoss.com/lmde-4-release/
|
||||
[13]: https://mate-desktop.org/
|
||||
[14]: https://itsfoss.com/ubuntu-mate-20-04-review/
|
||||
[15]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/07/linux-mint-mate.jpg?resize=800%2C500&ssl=1
|
||||
[16]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/03/Linux-Mint-20-MATE-ram-usage.png?resize=800%2C600&ssl=1
|
||||
[17]: https://mate-desktop.org/blog/2020-02-10-mate-1-24-released/
|
||||
[18]: https://itsfoss.com/ubuntu-mate-customization/
|
||||
[19]: https://en.wikipedia.org/wiki/Common_Desktop_Environment
|
||||
[20]: https://en.wikipedia.org/wiki/XForms_(toolkit)
|
||||
[21]: https://itsfoss.com/manjaro-linux-review/
|
||||
[22]: https://itsfoss.com/mx-linux-19/
|
||||
[23]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/07/linux-mint-xfce.jpg?resize=800%2C500&ssl=1
|
||||
[24]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/03/Linux-Mint-20-Xfce-ram-usage.png?resize=800%2C600&ssl=1
|
||||
[25]: https://itsfoss.com/which-ubuntu-install/
|
||||
[26]: https://itsfoss.com/install-linux-mint-in-virtualbox/
|
@ -2,7 +2,7 @@
|
||||
[#]: via: (https://opensource.com/article/21/3/raspberry-pi-parental-control)
|
||||
[#]: author: (Daniel Oh https://opensource.com/users/daniel-oh)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
@ -0,0 +1,303 @@
|
||||
[#]: subject: (Build a router with mobile connectivity using Raspberry Pi)
|
||||
[#]: via: (https://opensource.com/article/21/3/router-raspberry-pi)
|
||||
[#]: author: (Lukas Janėnas https://opensource.com/users/lukasjan)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
Build a router with mobile connectivity using Raspberry Pi
|
||||
======
|
||||
Use OpenWRT to get more control over your network's router.
|
||||
![Mesh networking connected dots][1]
|
||||
|
||||
The Raspberry Pi is a small, single-board computer that, despite being the size of a credit card, is capable of doing a lot of things. In reality, this little computer can be almost anything you want to be. You just need to open up your imagination.
|
||||
|
||||
Raspberry Pi enthusiasts have made many different projects, from simple programs to complex automation projects and solutions like weather stations or even smart-home devices. This article will show how to turn your Raspberry Pi into a router with LTE mobile connectivity using the OpenWRT project.
|
||||
|
||||
### About OpenWRT and LTE
|
||||
|
||||
[OpenWRT][2] is an open source project that uses Linux to target embedded devices. It's been around for more than 15 years and has a large and active community.
|
||||
|
||||
There are many ways to use OpenWRT, but its main purpose is in routers. It provides a fully writable filesystem with package management, and because it is open source, you can see and modify the code and contribute to the ecosystem. If you would like to have more control over your router, this is the system you want to use.
|
||||
|
||||
Long-term evolution (LTE) is a standard for wireless broadband communication based on the GSM/EDGE and UMTS/HSPA technologies. The LTE modem I'm using is a USB device that can add 3G or 4G (LTE) cellular connectivity to a Raspberry Pi computer.
|
||||
|
||||
![Teltonika TRM240 modem][3]
|
||||
|
||||
(Lukas Janenas, [CC BY-SA 4.0][4])
|
||||
|
||||
### Prerequisites
|
||||
|
||||
For this project, you will need:
|
||||
|
||||
* A Raspberry Pi with a power cable
|
||||
* A computer, preferably running Linux
|
||||
* A microSD card with at least 16GB
|
||||
* An Ethernet cable
|
||||
* An LTE modem (I am using a Teltonika [TRM240][5])
|
||||
* A SIM card for mobile connectivity
|
||||
|
||||
|
||||
|
||||
### Install OpenWRT
|
||||
|
||||
To get started, download the latest [Raspberry Pi-compatible release of OpenWRT][6]. On the OpenWRT site, you see four images: two with **ext4** and two with **squashfs** filesystems. I use the **ext4** filesystem. You can download either the **factory** or **sysupgrade** image; both work great.
|
||||
|
||||
![OpenWRT image files][7]
|
||||
|
||||
(Lukas Janenas, [CC BY-SA 4.0][4])
|
||||
|
||||
Once you download the image, you need to extract it and install it on the SD card by [following these instructions][8]. It can take some time to install the firmware, so be patient. Once it's finished, there will be two partitions on your microSD card. One is used for the bootloader and the other one for the OpenWRT system.
|
||||
|
||||
### Boot up the system
|
||||
|
||||
To boot up your new system, insert the microSD card into the Raspberry Pi, connect the Pi to your router (or a switch) with an Ethernet cable, and power it on.
|
||||
|
||||
If you're experienced with the Raspberry Pi, you may be used to accessing it through a terminal over SSH, or just by connecting it to a monitor and keyboard. OpenWRT works a little differently. You interact with this software through a web browser, so you must be able to access your Pi over your network.
|
||||
|
||||
By default, the Raspberry Pi uses this IP address: 192.168.1.1. The computer you use to configure the Pi must be on the same subnet as the Pi. If your network doesn't use 192.168.1.x addresses, or if you're unsure, open **Settings** in GNOME, navigate to network settings, select **Manual**, and enter the following IP address and Netmask:
|
||||
|
||||
* **IP address:** 192.168.1.15
|
||||
* **Netmask:** 255.255.255.0
|
||||
|
||||
|
||||
|
||||
![IP addresses][9]
|
||||
|
||||
(Lukas Janenas, [CC BY-SA 4.0][4])
|
||||
|
||||
Open a web browser on your computer and navigate to 192.168.1.1. This opens an authentication page so you can log in to your Pi.
|
||||
|
||||
![OpenWRT login page][10]
|
||||
|
||||
(Lukas Janenas, [CC BY-SA 4.0][4])
|
||||
|
||||
No password is required yet, so just click the **Login** button to continue.
|
||||
|
||||
### Configure network connection
|
||||
|
||||
The Raspberry Pi has only one Ethernet port, while normal routers have a couple of them: one for WAN (wired area network) and the other for LAN (local area network). You have two options:
|
||||
|
||||
1. Use your Ethernet port for network connectivity
|
||||
2. Use WiFi for network connectivity
|
||||
|
||||
|
||||
|
||||
**To use Ethernet:**
|
||||
|
||||
Should you decide to use Ethernet, navigate to **Network → Interfaces**. On the configuration page, press the blue **Edit** button that is associated with the **LAN** interface.
|
||||
|
||||
![LAN interface][11]
|
||||
|
||||
(Lukas Janenas, [CC BY-SA 4.0][4])
|
||||
|
||||
A pop-up window should appear. In that window, you need to enter the IP address to match the subnet of the router to which you will connect the Raspberry Pi. Change the Netmask, if needed, and enter the IP address of the router the Raspberry Pi will connect to.
|
||||
|
||||
![Enter IP in the LAN interface][12]
|
||||
|
||||
(Lukas Janenas, [CC BY-SA 4.0][4])
|
||||
|
||||
Save this configuration and connect your Pi to the router over Ethernet. You can now reach the Raspberry Pi with this new IP address.
|
||||
|
||||
Be sure to set a password for your OpenWRT router before you put it into production use!
|
||||
|
||||
**To use WiFi**
|
||||
|
||||
If you would like to connect the Raspberry Pi to the internet through WiFi, navigate to **Network → Wireless**. In the **Wireless** menu, press the blue **Scan** button to locate your home network.
|
||||
|
||||
![Scan the network][13]
|
||||
|
||||
(Lukas Janenas, [CC BY-SA 4.0][4])
|
||||
|
||||
In the pop-up window, find your WiFi network and connect to it. Don't forget to **Save and Apply** the configuration.
|
||||
|
||||
In the **Network → Interfaces** section, you should see a new interface.
|
||||
|
||||
![New interface][14]
|
||||
|
||||
(Lukas Janenas, [CC BY-SA 4.0][4])
|
||||
|
||||
Be sure to set a password for your OpenWRT router before you put it into production use!
|
||||
|
||||
### Install the necessary packages
|
||||
|
||||
By default, the router doesn't have a lot of packages. OpenWRT offers a package manager with a selection of packages you need to install. Navigate to **System → Software** and update your package manager by pressing the button labeled "**Update lists…**".
|
||||
|
||||
![Updating packages][15]
|
||||
|
||||
(Lukas Janenas, [CC BY-SA 4.0][4])
|
||||
|
||||
You will see a lot of packages; you need to install these:
|
||||
|
||||
* usb-modeswitch
|
||||
* kmod-mii
|
||||
* kmod-usb-net
|
||||
* kmod-usb-wdm
|
||||
* kmod-usb-serial
|
||||
* kmod-usb-serial-option
|
||||
* kmod-usb-serial-wwan (if it's not installed)
|
||||
|
||||
|
||||
|
||||
Additionally, [download this modemmanager package][16] and install it by pressing the button labeled **Upload Package…** in the pop-up window. Reboot the Raspberry Pi for the packages to take effect.
|
||||
|
||||
### Set up the mobile interface
|
||||
|
||||
After all those packages are installed, you can set up the mobile interface. Before connecting the modem to the Raspberry Pi read, the [modem instructions][17] to set it up. Then connect your mobile modem to the Raspberry Pi and wait a little until the modem boots up.
|
||||
|
||||
Navigate to **Network → Interface**. At the bottom of the page, press the **Add new interface…** button. In the pop-up window, give your interface a name (e.g., **mobile**) and select **ModemManager** from the drop-down list.
|
||||
|
||||
![Add a new mobile interface][18]
|
||||
|
||||
(Lukas Janenas, [CC BY-SA 4.0][4])
|
||||
|
||||
Press the button labeled **Create Interface**. You should see a new pop-up window. This is the main window for configuring the interface. In this window, select your modem and enter any other information like an Access Point Name (APN) or a PIN.
|
||||
|
||||
![Configuring the interface][19]
|
||||
|
||||
(Lukas Janenas, [CC BY-SA 4.0][4])
|
||||
|
||||
**Note:** If no modem devices appear in the list, try rebooting your Raspberry Pi or installing the kmod-usb-net-qmi-wwan package.
|
||||
|
||||
When you are done configuring your interface, press **Save** and then **Save and Apply**. Give some time for the system to take effect. If everything went well, you should see something like this.
|
||||
|
||||
![Configured interface][20]
|
||||
|
||||
(Lukas Janenas, [CC BY-SA 4.0][4])
|
||||
|
||||
If you want to check your internet connection over this interface, you can use ssh to connect to your Raspberry Pi shell. In the terminal, enter:
|
||||
|
||||
|
||||
```
|
||||
`ssh root@192.168.1.1`
|
||||
```
|
||||
|
||||
The default IP address is 192.168.1.1; if you changed it, then use that IP address to connect. When connected, execute this command in the terminal:
|
||||
|
||||
|
||||
```
|
||||
`ping -I ppp0 google.com`
|
||||
```
|
||||
|
||||
If everything is working, then you should receive pings back from Google's servers.
|
||||
|
||||
![Terminal interface][21]
|
||||
|
||||
(Lukas Janenas, [CC BY-SA 4.0][4])
|
||||
|
||||
**ppp0** is the default interface name for the mobile interface you created. You can check your interfaces using **ifconfig**. It shows active interfaces only.
|
||||
|
||||
### Set up the firewall
|
||||
|
||||
To get the mobile interface working, you need to configure a firewall for the **mobile** interface and the **lan** interface to direct traffic to the correct interface.
|
||||
|
||||
Navigate to **Network → Firewall**. At the bottom of the page, you should see a section called **Zones**.
|
||||
|
||||
![Firewall zones][22]
|
||||
|
||||
(Lukas Janenas, [CC BY-SA 4.0][4])
|
||||
|
||||
The simplest way to configure the firewall is to adjust the **wan** zone. Press the **Edit** button and in the **Covered networks** option, select your **mobile** interface, and **Save and Apply** your configuration. If you don't want to use WiFi to connect to the internet, you can remove **wwan** from the **Covered networks** or disable the WiFi connection.
|
||||
|
||||
![Firewall zone settings][23]
|
||||
|
||||
(Lukas Janenas, [CC BY-SA 4.0][4])
|
||||
|
||||
If you want to set up individual zones for each interface, just create a new zone and assign the necessary interfaces. For example, you may want to have a mobile zone that covers the mobile interface and is used to forward LAN interface traffic through it. Press the **Add** button, then **Name** your zone, check the **Masquerading** check box, select **Covered Networks**, and choose which zones can forward their traffic.
|
||||
|
||||
![Firewall zone settings][24]
|
||||
|
||||
(Lukas Janenas, [CC BY-SA 4.0][4])
|
||||
|
||||
Then **Save and Apply** the changes. Now you have a new zone.
|
||||
|
||||
### Set up an Access Point
|
||||
|
||||
The last step is to configure a network with an Access Point for your devices to connect to the internet. To set up an Access Point, navigate to **Network → Wireless**. You will see a WiFi device interface, a disabled Access Point named **OpenWRT**, and a connection that is used to connect to the internet over WiFi (if you didn't disable or delete it earlier). On the **Disable** interface, press the **Edit** button, then **Enable** the interface.
|
||||
|
||||
![Enabling wireless network][25]
|
||||
|
||||
(Lukas Janenas, [CC BY-SA 4.0][4])
|
||||
|
||||
If you want, you can change the interface name by editing the **ESSID** option. You can also select which network it will be associated with. By default, it with be associated with the **lan** interface.
|
||||
|
||||
![Configuring the interface][26]
|
||||
|
||||
(Lukas Janenas, [CC BY-SA 4.0][4])
|
||||
|
||||
To add a password for this interface, select the **Wireless Security** tab. In the tab, select the encryption **WPA2-PSK** and enter the password for the interface in the **Key** option field.
|
||||
|
||||
![Setting a password][27]
|
||||
|
||||
(Lukas Janenas, [CC BY-SA 4.0][4])
|
||||
|
||||
Then **Save and Apply** the configuration. If the configuration was set correctly, when scanning available Access Points with your device, you should see a new Access Point with the name you assigned.
|
||||
|
||||
### Additional packages
|
||||
|
||||
If you want, you can download additional packages for your router through the web interface. Just go to **System → Software** and install the package you want from the list or download it from the internet and upload it. If you don't see any packages in the list, press the **Update lists…** button.
|
||||
|
||||
You can also add other repositories that have packages that are good to use with OpenWRT. Packages and their web interfaces are installed separately. The packages that start with the prefix **luci-** are web interface packages.
|
||||
|
||||
![Packages with luci- prefix][28]
|
||||
|
||||
(Lukas Janenas, [CC BY-SA 4.0][4])
|
||||
|
||||
### Give it a try
|
||||
|
||||
This is what my Raspberry Pi router setup looks like.
|
||||
|
||||
![Raspberry Pi router][29]
|
||||
|
||||
(Lukas Janenas, [CC BY-SA 4.0][4])
|
||||
|
||||
It not difficult to build a router from a Raspberry Pi. The downside is that a Raspberry Pi has only one Ethernet port. You can add more ports with a USB-to-Ethernet adapter. Don't forget to configure the port on the interface's website.
|
||||
|
||||
OpenWRT supports a large number of mobile modems, and you can configure the mobile interface for any of them with the modemmanager, which is a universal tool to manage modems.
|
||||
|
||||
Have you used your Raspberry Pi as a router? Let us know how it went in the comments.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/3/router-raspberry-pi
|
||||
|
||||
作者:[Lukas Janėnas][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/lukasjan
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/mesh_networking_dots_connected.png?itok=ovINTRR3 (Mesh networking connected dots)
|
||||
[2]: https://openwrt.org/
|
||||
[3]: https://opensource.com/sites/default/files/uploads/lte_modem.png (Teltonika TRM240 modem)
|
||||
[4]: https://creativecommons.org/licenses/by-sa/4.0/
|
||||
[5]: https://teltonika-networks.com/product/trm240/
|
||||
[6]: https://downloads.openwrt.org/releases/19.07.7/targets/brcm2708/bcm2710/
|
||||
[7]: https://opensource.com/sites/default/files/uploads/imagefiles.png (OpenWRT image files)
|
||||
[8]: https://opensource.com/article/17/3/how-write-sd-cards-raspberry-pi
|
||||
[9]: https://opensource.com/sites/default/files/uploads/ipaddresses.png (IP addresses)
|
||||
[10]: https://opensource.com/sites/default/files/uploads/openwrt-login.png (OpenWRT login page)
|
||||
[11]: https://opensource.com/sites/default/files/uploads/lan-interface.png (LAN interface)
|
||||
[12]: https://opensource.com/sites/default/files/uploads/lan-interface-ip.png (Enter IP in the LAN interface)
|
||||
[13]: https://opensource.com/sites/default/files/uploads/scannetwork.png (Scan the network)
|
||||
[14]: https://opensource.com/sites/default/files/uploads/newinterface.png (New interface)
|
||||
[15]: https://opensource.com/sites/default/files/uploads/updatesoftwarelist.png (Updating packages)
|
||||
[16]: https://downloads.openwrt.org/releases/packages-21.02/aarch64_cortex-a53/luci/luci-proto-modemmanager_git-21.007.43644-ab7e45c_all.ipk
|
||||
[17]: https://wiki.teltonika-networks.com/view/TRM240_SIM_Card
|
||||
[18]: https://opensource.com/sites/default/files/uploads/addnewinterface.png (Add a new mobile interface)
|
||||
[19]: https://opensource.com/sites/default/files/uploads/configureinterface.png (Configuring the interface)
|
||||
[20]: https://opensource.com/sites/default/files/uploads/configuredinterface.png (Configured interface)
|
||||
[21]: https://opensource.com/sites/default/files/uploads/terminal.png (Terminal interface)
|
||||
[22]: https://opensource.com/sites/default/files/uploads/firewallzones.png (Firewall zones)
|
||||
[23]: https://opensource.com/sites/default/files/uploads/firewallzonesettings.png (Firewall zone settings)
|
||||
[24]: https://opensource.com/sites/default/files/uploads/firewallzonepriv.png (Firewall zone settings)
|
||||
[25]: https://opensource.com/sites/default/files/uploads/enablewirelessnetwork.png (Enabling wireless network)
|
||||
[26]: https://opensource.com/sites/default/files/uploads/interfaceconfig.png (Configuring the interface)
|
||||
[27]: https://opensource.com/sites/default/files/uploads/interfacepassword.png (Setting a password)
|
||||
[28]: https://opensource.com/sites/default/files/uploads/luci-packages.png (Packages with luci- prefix)
|
||||
[29]: https://opensource.com/sites/default/files/uploads/raspberrypirouter.jpg (Raspberry Pi router)
|
@ -0,0 +1,288 @@
|
||||
[#]: subject: (Visualize multi-threaded Python programs with an open source tool)
|
||||
[#]: via: (https://opensource.com/article/21/3/python-viztracer)
|
||||
[#]: author: (Tian Gao https://opensource.com/users/gaogaotiantian)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
Visualize multi-threaded Python programs with an open source tool
|
||||
======
|
||||
VizTracer traces concurrent Python programs to help with logging,
|
||||
debugging, and profiling.
|
||||
![Colorful sound wave graph][1]
|
||||
|
||||
Concurrency is an essential part of modern programming, as we have multiple cores and many tasks that need to cooperate. However, it's harder to understand concurrent programs when they are not running sequentially. It's not as easy for engineers to identify bugs and performance issues in these programs as it is in a single-thread, single-task program.
|
||||
|
||||
With Python, you have multiple options for concurrency. The most common ones are probably multi-threaded with the threading module, multiprocess with the subprocess and multiprocessing modules, and the more recent async syntax with the asyncio module. Before [VizTracer][2], there was a lack of tools to analyze programs using these techniques.
|
||||
|
||||
VizTracer is a tool for tracing and visualizing Python programs, which is helpful for logging, debugging, and profiling. Even though it works well for single-thread, single-task programs, its utility in concurrent programs is what makes it unique.
|
||||
|
||||
### Try a simple task
|
||||
|
||||
Start with a simple practice task: Figure out whether the integers in an array are prime numbers and return a Boolean array. Here is a simple solution:
|
||||
|
||||
|
||||
```
|
||||
def is_prime(n):
|
||||
for i in range(2, n):
|
||||
if n % i == 0:
|
||||
return False
|
||||
return True
|
||||
|
||||
def get_prime_arr(arr):
|
||||
return [is_prime(elem) for elem in arr]
|
||||
```
|
||||
|
||||
Try to run it normally, in a single thread, with VizTracer:
|
||||
|
||||
|
||||
```
|
||||
if __name__ == "__main__":
|
||||
num_arr = [random.randint(100, 10000) for _ in range(6000)]
|
||||
get_prime_arr(num_arr)
|
||||
|
||||
[/code] [code]`viztracer my_program.py`
|
||||
```
|
||||
|
||||
![Running code in a single thread][3]
|
||||
|
||||
(Tian Gao, [CC BY-SA 4.0][4])
|
||||
|
||||
The call-stack report indicates it took about 140ms, with most of the time spent in `get_prime_arr`.
|
||||
|
||||
![call-stack report][5]
|
||||
|
||||
(Tian Gao, [CC BY-SA 4.0][4])
|
||||
|
||||
It's just doing the `is_prime` function over and over again on the elements in the array.
|
||||
|
||||
This is what you would expect, and it's not that interesting (if you know VizTracer).
|
||||
|
||||
### Try a multi-thread program
|
||||
|
||||
Try doing it with a multi-thread program:
|
||||
|
||||
|
||||
```
|
||||
if __name__ == "__main__":
|
||||
num_arr = [random.randint(100, 10000) for i in range(2000)]
|
||||
thread1 = Thread(target=get_prime_arr, args=(num_arr,))
|
||||
thread2 = Thread(target=get_prime_arr, args=(num_arr,))
|
||||
thread3 = Thread(target=get_prime_arr, args=(num_arr,))
|
||||
|
||||
thread1.start()
|
||||
thread2.start()
|
||||
thread3.start()
|
||||
|
||||
thread1.join()
|
||||
thread2.join()
|
||||
thread3.join()
|
||||
```
|
||||
|
||||
To match the single-thread program's workload, this uses a 2,000-element array for three threads, simulating a situation where three threads are sharing the task.
|
||||
|
||||
![Multi-thread program][6]
|
||||
|
||||
(Tian Gao, [CC BY-SA 4.0][4])
|
||||
|
||||
As you would expect if you are familiar with Python's Global Interpreter Lock (GIL), it won't get any faster. It took a little bit more than 140ms due to the overhead. However, you can observe the concurrency of multiple threads:
|
||||
|
||||
![Concurrency of multiple threads][7]
|
||||
|
||||
(Tian Gao, [CC BY-SA 4.0][4])
|
||||
|
||||
When one thread was working (executing multiple `is_prime` functions), the other one was frozen (one `is_prime` function); later, they switched. This is due to GIL, and it is the reason Python does not have true multi-threading. It can achieve concurrency but not parallelism.
|
||||
|
||||
### Try it with multiprocessing
|
||||
|
||||
To achieve parallelism, the way to go is the multiprocessing library. Here is another version with multiprocessing:
|
||||
|
||||
|
||||
```
|
||||
if __name__ == "__main__":
|
||||
num_arr = [random.randint(100, 10000) for _ in range(2000)]
|
||||
|
||||
p1 = Process(target=get_prime_arr, args=(num_arr,))
|
||||
p2 = Process(target=get_prime_arr, args=(num_arr,))
|
||||
p3 = Process(target=get_prime_arr, args=(num_arr,))
|
||||
|
||||
p1.start()
|
||||
p2.start()
|
||||
p3.start()
|
||||
|
||||
p1.join()
|
||||
p2.join()
|
||||
p3.join()
|
||||
```
|
||||
|
||||
To run it with VizTracer, you need an extra argument:
|
||||
|
||||
|
||||
```
|
||||
`viztracer --log_multiprocess my_program.py`
|
||||
```
|
||||
|
||||
![Running with extra argument][8]
|
||||
|
||||
(Tian Gao, [CC BY-SA 4.0][4])
|
||||
|
||||
The whole program finished in a little more than 50ms, with the actual task finishing before the 50ms mark. The program's speed roughly tripled.
|
||||
|
||||
To compare it with the multi-thread version, here is the multiprocess version:
|
||||
|
||||
![Multi-process version][9]
|
||||
|
||||
(Tian Gao, [CC BY-SA 4.0][4])
|
||||
|
||||
Without GIL, multiple processes can achieve parallelism, which means multiple `is_prime` functions can execute in parallel.
|
||||
|
||||
However, Python's multi-thread is not useless. For example, for computation-intensive and I/O-intensive programs, you can fake an I/O-bound task with sleep:
|
||||
|
||||
|
||||
```
|
||||
def io_task():
|
||||
time.sleep(0.01)
|
||||
```
|
||||
|
||||
Try it in a single-thread, single-task program:
|
||||
|
||||
|
||||
```
|
||||
if __name__ == "__main__":
|
||||
for _ in range(3):
|
||||
io_task()
|
||||
```
|
||||
|
||||
![I/O-bound single-thread, single-task program][10]
|
||||
|
||||
(Tian Gao, [CC BY-SA 4.0][4])
|
||||
|
||||
The full program took about 30ms; nothing special.
|
||||
|
||||
Now use multi-thread:
|
||||
|
||||
|
||||
```
|
||||
if __name__ == "__main__":
|
||||
thread1 = Thread(target=io_task)
|
||||
thread2 = Thread(target=io_task)
|
||||
thread3 = Thread(target=io_task)
|
||||
|
||||
thread1.start()
|
||||
thread2.start()
|
||||
thread3.start()
|
||||
|
||||
thread1.join()
|
||||
thread2.join()
|
||||
thread3.join()
|
||||
```
|
||||
|
||||
![I/O-bound multi-thread program][11]
|
||||
|
||||
(Tian Gao, [CC BY-SA 4.0][4])
|
||||
|
||||
The program took 10ms, and it's clear how the three threads worked concurrently and improved the overall performance.
|
||||
|
||||
### Try it with asyncio
|
||||
|
||||
Python is trying to introduce another interesting feature called async programming. You can make an async version of this task:
|
||||
|
||||
|
||||
```
|
||||
import asyncio
|
||||
|
||||
async def io_task():
|
||||
await asyncio.sleep(0.01)
|
||||
|
||||
async def main():
|
||||
t1 = asyncio.create_task(io_task())
|
||||
t2 = asyncio.create_task(io_task())
|
||||
t3 = asyncio.create_task(io_task())
|
||||
|
||||
await t1
|
||||
await t2
|
||||
await t3
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
```
|
||||
|
||||
As asyncio is literally a single-thread scheduler with tasks, you can use VizTracer directly on it:
|
||||
|
||||
![VizTracer with asyncio][12]
|
||||
|
||||
(Tian Gao, [CC BY-SA 4.0][4])
|
||||
|
||||
It still took 10ms, but most of the functions displayed are the underlying structure, which is probably not what users are interested in. To solve this, you can use `--log_async` to separate the real task:
|
||||
|
||||
|
||||
```
|
||||
`viztracer --log_async my_program.py`
|
||||
```
|
||||
|
||||
![Using --log_async to separate tasks][13]
|
||||
|
||||
(Tian Gao, [CC BY-SA 4.0][4])
|
||||
|
||||
Now the user tasks are much clearer. For most of the time, no tasks are running (because the only thing it does is sleep). Here's the interesting part:
|
||||
|
||||
![Graph of task creation and execution][14]
|
||||
|
||||
(Tian Gao, [CC BY-SA 4.0][4])
|
||||
|
||||
This shows when the tasks were created and executed. Task-1 was the `main()` co-routine and created other tasks. Tasks 2, 3, and 4 executed `io_task` and `sleep` then waited for the wake-up. As the graph shows, there is no overlap between tasks because it's a single-thread program, and VizTracer visualized it this way to make it more understandable.
|
||||
|
||||
To make it more interesting, add a `time.sleep` call in the task to block the async loop:
|
||||
|
||||
|
||||
```
|
||||
async def io_task():
|
||||
time.sleep(0.01)
|
||||
await asyncio.sleep(0.01)
|
||||
```
|
||||
|
||||
![time.sleep call][15]
|
||||
|
||||
(Tian Gao, [CC BY-SA 4.0][4])
|
||||
|
||||
The program took much longer (40ms), and the tasks filled the blanks in the async scheduler.
|
||||
|
||||
This feature is very helpful for diagnosing behavior and performance issues in async programs.
|
||||
|
||||
### See what's happening with VizTracer
|
||||
|
||||
With VizTracer, you can see what's going on with your program on a timeline, rather than imaging it from complicated logs. This helps you understand your concurrent programs better.
|
||||
|
||||
VizTracer is open source, released under the Apache 2.0 license, and supports all common operating systems (Linux, macOS, and Windows). You can learn more about its features and access its source code in [VizTracer's GitHub repository][16].
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/3/python-viztracer
|
||||
|
||||
作者:[Tian Gao][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/gaogaotiantian
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/colorful_sound_wave.png?itok=jlUJG0bM (Colorful sound wave graph)
|
||||
[2]: https://readthedocs.org/projects/viztracer/
|
||||
[3]: https://opensource.com/sites/default/files/uploads/viztracer_singlethreadtask.png (Running code in a single thread)
|
||||
[4]: https://creativecommons.org/licenses/by-sa/4.0/
|
||||
[5]: https://opensource.com/sites/default/files/uploads/viztracer_callstackreport.png (call-stack report)
|
||||
[6]: https://opensource.com/sites/default/files/uploads/viztracer_multithread.png (Multi-thread program)
|
||||
[7]: https://opensource.com/sites/default/files/uploads/viztracer_concurrency.png (Concurrency of multiple threads)
|
||||
[8]: https://opensource.com/sites/default/files/uploads/viztracer_multithreadrun.png (Running with extra argument)
|
||||
[9]: https://opensource.com/sites/default/files/uploads/viztracer_comparewithmultiprocess.png (Multi-process version)
|
||||
[10]: https://opensource.com/sites/default/files/uploads/io-bound_singlethread.png (I/O-bound single-thread, single-task program)
|
||||
[11]: https://opensource.com/sites/default/files/uploads/io-bound_multithread.png (I/O-bound multi-thread program)
|
||||
[12]: https://opensource.com/sites/default/files/uploads/viztracer_asyncio.png (VizTracer with asyncio)
|
||||
[13]: https://opensource.com/sites/default/files/uploads/log_async.png (Using --log_async to separate tasks)
|
||||
[14]: https://opensource.com/sites/default/files/uploads/taskcreation.png (Graph of task creation and execution)
|
||||
[15]: https://opensource.com/sites/default/files/uploads/time.sleep_call.png (time.sleep call)
|
||||
[16]: https://github.com/gaogaotiantian/viztracer
|
173
sources/tech/20210313 Build an open source theremin.md
Normal file
173
sources/tech/20210313 Build an open source theremin.md
Normal file
@ -0,0 +1,173 @@
|
||||
[#]: subject: (Build an open source theremin)
|
||||
[#]: via: (https://opensource.com/article/21/3/open-source-theremin)
|
||||
[#]: author: (Gordon Haff https://opensource.com/users/ghaff)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
Build an open source theremin
|
||||
======
|
||||
Create your own electronic musical instrument with Open.Theremin V3.
|
||||
![radio communication signals][1]
|
||||
|
||||
Even if you haven't heard of a [theremin][2], you're probably familiar with the [eerie electronic sound][3] it makes from watching TV shows and movies like the 1951 science fiction classic _The Day the Earth Stood Still_. Theremins have also appeared in popular music, although often in the form of a theremin variant. For example, the "theremin" in the Beach Boys' "Good Vibrations" was actually an [electro-theremin][4], an instrument played with a slider invented by trombonist Paul Tanner and amateur inventor Bob Whitsell and designed to be easier to play.
|
||||
|
||||
Soviet physicist Leon Theremin invented the theremin in 1920. It was one of the first electronic instruments, and Theremin introduced it to the world through his concerts in Europe and the US in the late 1920s. He patented his invention in 1928 and sold the rights to RCA. However, in the wake of the 1929 stock market crash, RCA's expensive product flopped. Theremin returned to the Soviet Union under somewhat mysterious circumstances in the late 1930s. The instrument remained relatively unknown until Robert Moog, of synthesizer fame, became interested in them as a high school student in the 1950s and started writing articles and selling kits. RA Moog, the company he founded, remains the best-known maker of commercial theremins today.
|
||||
|
||||
### What does this have to do with open source?
|
||||
|
||||
In 2008, Swiss engineer Urs Gaudenz was at a festival put on by the Swiss Mechatronic Art Society, which describes itself as a collective of engineers, hackers, scientists, and artists who collaborate on creative uses of technology. The festival included a theremin exhibit, which introduced Gaudenz to the instrument.
|
||||
|
||||
At a subsequent event focused on bringing together music and technology, one of the organizers told Gaudenz that there were a lot of people who wanted to build theremins from kits. Some kits existed, but they often didn't work or play well. Gaudenz set off to build an open theremin that could be played in the same manner and use the same operating principles as a traditional theremin but with a modern electronic board and microcontroller.
|
||||
|
||||
The [Open.Theremin][5] project (currently in version 3) is completely open source, including the microcontroller code and the [hardware files][6], which include the schematics and printed circuit board (PCB) layout. The hardware and the instructions are under GPL v3, while the [control code][7] is under LGPL v3. Therefore, the project can be assembled completely from scratch. In practice, most people will probably work from the kit available from Gaudi.ch, so that's what I'll describe in this article. There's also a completely assembled version available.
|
||||
|
||||
### How does a theremin work?
|
||||
|
||||
Before getting into the details of the Open.Theremin V3 and its assembly and use, I'll talk at a high level about how traditional theremins work.
|
||||
|
||||
Theremins are highly unusual in that they're played without touching the instrument directly or indirectly. They're controlled by varying your distance and hand shape from [two antennas][8], a horizontal volume loop antenna, typically on the left, and a vertical pitch antenna, typically on the right. Some theremins have a pitch antenna only—Robert Plant of Led Zeppelin played such a variant—and some, including the Open.Theremin, have additional knob controls. But hand movements associated with the volume and pitch antennas are the primary means of controlling the instrument.
|
||||
|
||||
I've been referring to the "antennas" because that's how everyone else refers to them. But they're not antennas in the usual sense of picking up radio waves. Each antenna acts as a plate in a capacitor. This brings us to the basic theremin operating principle: the heterodyne oscillator that mixes signals from a fixed and a variable oscillator.
|
||||
|
||||
Such a circuit can be implemented in various ways. The Open.Theremin uses a combination of an oscillating crystal for the fixed frequency and an LC (inductance-capacitance) oscillator tuned to a similar but different frequency for the variable oscillator. There's one circuit for volume and a second one (operating at a slightly different frequency to avoid interference) for pitch, as this functional block diagram shows.
|
||||
|
||||
![Theremin block diagram][9]
|
||||
|
||||
(Gaudi Labs, [GPL v3][10])
|
||||
|
||||
You play the theremin by moving or changing the shape of your hand relative to each antenna. This changes the capacitance of the LC circuit. These changes are, in turn, processed and turned into sound.
|
||||
|
||||
### Assembling the materials
|
||||
|
||||
But enough theory. For this tutorial, I'll assume you're using an Open.Theremin V3 kit. In that case, here's what you need:
|
||||
|
||||
* [Open.Theremin V3 kit][11]
|
||||
* Arduino Uno with mounting plate
|
||||
* Soldering iron and related materials (you'll want fairly fine solder; I used 0.02")
|
||||
* USB printer-type cable
|
||||
* Wire for grounding
|
||||
* Replacement antenna mounting hardware: Socket head M3-10 bolt, washer, wing nut (x2, optional)
|
||||
* Speaker or headphones (3.5mm jack)
|
||||
* Tripod with standard ¼" screw
|
||||
|
||||
|
||||
|
||||
The Open.Theremin is a shield for an Arduino, which is to say it's a modular circuit board that piggybacks on the Arduino microcontroller to extend its capabilities. In this case, the Arduino handles most of the important tasks for the theremin board, such as linearizing and filtering the audio and generating the instrument's sound using stored waveforms. The waveforms can be changed in the Arduino software. The Arduino's capabilities are an important part of enabling a wholly digital theremin with good sound quality without analog parts.
|
||||
|
||||
The Arduino is also open source. It grew out of a 2003 project at the Interaction Design Institute Ivrea in Ivrea, Italy.
|
||||
|
||||
### Building the hardware
|
||||
|
||||
There are [good instructions][12] for building the theremin hardware on the Gaudi.ch site, so I won't take you through every step. I'll focus on the project at a high level and share some knowledge that you may find helpful.
|
||||
|
||||
The PCB that comes with the kit already has the integrated circuits and discrete electronics surface-mounted on the board's backside, so you don't need to worry about those (other than not damaging them). What you do need to solder to the board are the pins to attach the shield to the Arduino, four potentiometers (pots), and a couple of surface-mount LEDs and a surface-mount button on the front side.
|
||||
|
||||
Before going further, I should note that this is probably an intermediate-level project. There's not a lot of soldering, but some of it is fairly detailed and in close proximity to other electronics. The surface-mount LEDs and button on the front side aren't hard to solder but do take a little technique (described in the instructions on the Gaudi.ch site). Just deliberately work your way through the soldering in the suggested order. You'll want good lighting and maybe a magnifier. Carefully check that no pins are shorting other pins.
|
||||
|
||||
Here is what the front of the hardware looks like:
|
||||
|
||||
![Open.Theremin front][13]
|
||||
|
||||
(Gordon Haff, [CC-BY-SA 4.0][14])
|
||||
|
||||
This shows the backside; the pins are the interface to the Arduino.
|
||||
|
||||
![Open.Theremin back][15]
|
||||
|
||||
(Gordon Haff, [CC-BY-SA 4.0][14])
|
||||
|
||||
I'll return to the hardware after setting up the Arduino and its software.
|
||||
|
||||
### Loading the software
|
||||
|
||||
The Arduino part of this project is straightforward if you've done anything with an Arduino and, really, even if you haven't.
|
||||
|
||||
* Install the [Arduino Desktop IDE][16]
|
||||
* Download the [Open.Theremin control software][7] and load it into the IDE
|
||||
* Attach the Arduino to your computer with a USB cable
|
||||
* Upload the software to the Arduino
|
||||
|
||||
|
||||
|
||||
It's possible to modify the Arduino's software, such as changing the stored waveforms, but I will not get into that in this article.
|
||||
|
||||
Power off the Arduino and carefully attach the shield. Make sure you line them up properly. (If you're uncertain, look at the Open.Theremin's [schematics][17], which show you which Arduino sockets aren't in use.)
|
||||
|
||||
Reconnect the USB. The red LED on the shield should come on. If it doesn't, something is wrong.
|
||||
|
||||
Use the Arduino Desktop IDE one more time to check out the calibration process, which, hopefully, will offer more confirmation that things are going according to plan. Here are the [detailed instructions][18].
|
||||
|
||||
What you're doing here is monitoring the calibration process. This isn't a real calibration because you haven't attached the antennas, and you'll have to recalibrate whenever you move the theremin. But this should give you an indication of whether the theremin is basically working.
|
||||
|
||||
Once you press the function button for about a second, the yellow LED should start to blink slowly, and the output from the Arduino's serial monitor should look something like the image below, which shows typical Open.Theremin calibration output. The main things that indicate a problem are frequency-tuning ranges that are either just zeros or that have a range that doesn't bound the set frequency.
|
||||
|
||||
![Open.Theremin calibration output][19]
|
||||
|
||||
(Gordon Haff, [CC-BY-SA 4.0][14])
|
||||
|
||||
### Completing the hardware
|
||||
|
||||
To finish the hardware, it's easiest if you separate the Arduino from the shield. You'll probably want to screw some sort of mounting plate to the back of the Arduino for the self-adhesive tripod mount you'll attach. Attaching the tripod mount works much better on a plate than on the Arduino board itself. Furthermore, I found that the mount's adhesive didn't work very well, and I had to use stronger glue.
|
||||
|
||||
Next, attach the antennas. The loop antenna goes on the left. The pitch antenna goes on the right (the shorter leg connects to the shield). Attach the supplied banana plugs to the antennas. (You need to use enough force to mate the two parts that you'll want to do it before attaching the banana plugs to the board.)
|
||||
|
||||
I found the kit's hardware extremely frustrating to tighten sufficiently to keep the antennas from rotating. In fact, due to the volume antenna swinging around, it ended up grounding itself on some of the conductive printing on the PCB, which led to a bit of debugging. In any case, the hardware listed in the parts list at the top of this article made it much easier for me to attach the antennas.
|
||||
|
||||
Attach the tripod mount to a tripod or stand of some sort, connect the USB to a power source, plug the Open.Theremin into a speaker or headset, and you're ready to go.
|
||||
|
||||
Well, almost. You need to ground it. Plugging the theremin into a stereo may ground it, as may the USB connection powering it. If the person playing the instrument (i.e., the player) has a strong coupling to ground, that can be sufficient. But if these circumstances don't apply, you need to ground the theremin by running a wire from the ground pad on the board to something like a water pipe. You can also connect the ground pad to the player with an antistatic wrist strap or equivalent wire. This gives the player strong capacitive coupling directly with the theremin, [which works][20] as an alternative to grounding the theremin.
|
||||
|
||||
At this point, recalibrate the theremin. You probably don't need to fiddle with the knobs at the start. Volume does what you'd expect. Pitch changes the "zero beat" point, i.e., where the theremin transitions from high pitched near the pitch antenna to silence near your body. Register is similar to what's called sensitivity on other theremins. Timbre selects among the different waveforms programmed into the Arduino.
|
||||
|
||||
There are many theremin videos online. It is _not_ an easy instrument to play well, but it is certainly fun to play with.
|
||||
|
||||
### The value of open
|
||||
|
||||
The open nature of the Open.Theremin project has enabled collaboration that would have been more difficult otherwise.
|
||||
|
||||
For example, Gaudenz received a great deal of feedback from people who play the theremin well, including [Swiss theremin player Coralie Ehinger][21]. Gaudenz says he really doesn't play the theremin but the help he got from players enabled him to make changes to make Open.Theremin a playable musical instrument.
|
||||
|
||||
Others contributed directly to the instrument design, especially the Arduino software code. Gaudenz credits [Thierry Frenkel][22] with improved volume control code. [Vincent Dhamelincourt][23] came up with the MIDI implementation. Gaudenz used circuit designs that others had created and shared, like designs [for the oscillators][24] that are a central part of the Open.Theremin board.
|
||||
|
||||
Open.Theremin is a great example of how open source is not just good for the somewhat abstract reasons people often mention. It can also lead to specific examples of improved collaboration and more effective design.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/3/open-source-theremin
|
||||
|
||||
作者:[Gordon Haff][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/ghaff
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/sound-radio-noise-communication.png?itok=KMNn9QrZ (radio communication signals)
|
||||
[2]: https://en.wikipedia.org/wiki/Theremin
|
||||
[3]: https://www.youtube.com/watch?v=2tnJEqXSs24
|
||||
[4]: https://en.wikipedia.org/wiki/Electro-Theremin
|
||||
[5]: http://www.gaudi.ch/OpenTheremin/
|
||||
[6]: https://github.com/GaudiLabs/OpenTheremin_Shield
|
||||
[7]: https://github.com/GaudiLabs/OpenTheremin_V3
|
||||
[8]: https://en.wikipedia.org/wiki/Theremin#/media/File:Etherwave_Theremin_Kit.jpg
|
||||
[9]: https://opensource.com/sites/default/files/uploads/opentheremin_blockdiagram.png (Theremin block diagram)
|
||||
[10]: https://www.gnu.org/licenses/gpl-3.0.en.html
|
||||
[11]: https://gaudishop.ch/index.php/product-category/opentheremin/
|
||||
[12]: https://www.gaudi.ch/OpenTheremin/images/stories/OpenTheremin/Instructions_OpenThereminV3.pdf
|
||||
[13]: https://opensource.com/sites/default/files/uploads/opentheremin_front.jpg (Open.Theremin front)
|
||||
[14]: https://creativecommons.org/licenses/by-sa/4.0/
|
||||
[15]: https://opensource.com/sites/default/files/uploads/opentheremin_back.jpg (Open.Theremin back)
|
||||
[16]: https://www.arduino.cc/en/software
|
||||
[17]: https://www.gaudi.ch/OpenTheremin/index.php/opentheremin-v3/schematics
|
||||
[18]: http://www.gaudi.ch/OpenTheremin/index.php/40-general/197-calibration-diagnostics
|
||||
[19]: https://opensource.com/sites/default/files/uploads/opentheremin_calibration.png (Open.Theremin calibration output)
|
||||
[20]: http://www.thereminworld.com/Forums/T/30525/grounding-and-alternatives-yes-a-repeat-performance--
|
||||
[21]: https://youtu.be/8bxz01kN7Sw
|
||||
[22]: https://theremin.tf/en/category/projects/open_theremin-projects/
|
||||
[23]: https://www.gaudi.ch/OpenTheremin/index.php/opentheremin-v3/midi-implementation
|
||||
[24]: http://www.gaudi.ch/OpenTheremin/index.php/home/sound-and-oscillators
|
94
sources/tech/20210313 My review of the Raspberry Pi 400.md
Normal file
94
sources/tech/20210313 My review of the Raspberry Pi 400.md
Normal file
@ -0,0 +1,94 @@
|
||||
[#]: subject: (My review of the Raspberry Pi 400)
|
||||
[#]: via: (https://opensource.com/article/21/3/raspberry-pi-400-review)
|
||||
[#]: author: (Don Watkins https://opensource.com/users/don-watkins)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
My review of the Raspberry Pi 400
|
||||
======
|
||||
Raspberry Pi 400's support for videoconferencing is a benefit for
|
||||
homeschoolers seeking inexpensive computers.
|
||||
![Raspberries with pi symbol overlay][1]
|
||||
|
||||
The [Raspberry Pi 400][2] promises to be a boon to the homeschool market. In addition to providing an easy-to-assemble workstation that comes loaded with free software, the Pi 400 also serves as a surprisingly effective videoconferencing platform. I ordered a Pi 400 from CanaKit late last year and was eager to explore this capability.
|
||||
|
||||
### Easy setup
|
||||
|
||||
After unboxing my Pi 400, which came in this lovely package, the setup was quick and easy.
|
||||
|
||||
![Raspberry Pi 400 box][3]
|
||||
|
||||
(Don Watkins, [CC BY-SA 4.0][4])
|
||||
|
||||
The Pi 400 reminds me of the old Commodore 64. The keyboard and CPU are in one form factor.
|
||||
|
||||
![Raspberry Pi 400 keyboard][5]
|
||||
|
||||
(Don Watkins, [CC BY-SA 4.0][4])
|
||||
|
||||
The matching keyboard and mouse make this little unit both aesthetically and ergonomically appealing.
|
||||
|
||||
Unlike earlier versions of the Raspberry Pi, there are not many parts to assemble. I connected the mouse, power supply, and micro HDMI cable to the back of the unit.
|
||||
|
||||
The ports on the back of the keyboard are where things get interesting.
|
||||
|
||||
![Raspberry Pi 400 ports][6]
|
||||
|
||||
(Don Watkins, [CC BY-SA 4.0][4])
|
||||
|
||||
From left to right, the ports are:
|
||||
|
||||
* 40-pin GPIO
|
||||
* MicroSD: a microSD card is the main hard drive, and it comes with a microSD card in the slot, ready for startup
|
||||
* Two micro HDMI ports
|
||||
* USB-C port for power
|
||||
* Two USB 3.0 ports and one USB 2.0 port for the mouse
|
||||
* Gigabit Ethernet port
|
||||
|
||||
|
||||
|
||||
The CPU is a Broadcom 1.8GHz 64-bit quad-core ARMv8 CPU, overclocked to make it even faster than the Raspberry Pi 4's processor.
|
||||
|
||||
My unit came with 4GB RAM and a stock 16GB microSD card with Raspberry Pi OS installed and ready to boot up for the first time.
|
||||
|
||||
### Evaluating the software and user experience
|
||||
|
||||
The Raspberry Pi Foundation continually improves its software. Raspberry Pi OS has various wizards to make setup easier, including ones for keyboard layout, WiFi settings, and so on.
|
||||
|
||||
The software included on the microSD card was the August 2020 Raspberry Pi OS release. After initial startup and setup, I connected a Logitech C270 webcam (which I regularly use with my other Linux computers) to one of the USB 3.0 ports.
|
||||
|
||||
The operating system recognized the Logitech webcam, but I could not get the microphone to work with [Jitsi][7]. I solved this problem by updating to the latest [Raspberry Pi OS][8] release with Linux Kernel version 5.4. This OS version includes many important features that I love, like an updated Chromium browser and Pulse Audio, which solved my webcam audio woes. I can use open source videoconferencing sites, like Jitsi, and common proprietary ones, like Google Hangouts, for video calls, but Zoom was entirely unsuccessful.
|
||||
|
||||
### Learning computing with the Pi
|
||||
|
||||
The icing on the cake is the Official Raspberry Pi Beginners Guide, a 245-page book introducing you to your new computer. Packed with informative tutorials, this book hearkens back to the days when technology _provided documentation_! For the curious mind, this book is a vitally important key to the Pi, which is best when it serves as a gateway to open source computing.
|
||||
|
||||
And after you become enchanted with Linux and all that it offers by using the Pi, you'll have months of exploration ahead, thanks to Opensource.com's [many Raspberry Pi articles][9].
|
||||
|
||||
I paid US$ 135 for my Raspberry Pi 400 because I added an optional inline power switch and an extra 32GB microSD card. Without those additional components, the unit is US$ 100. It's a steal either way and sure to provide years of fun, fast, and educational computing.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/3/raspberry-pi-400-review
|
||||
|
||||
作者:[Don Watkins][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/don-watkins
|
||||
[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://opensource.com/article/20/11/raspberry-pi-400
|
||||
[3]: https://opensource.com/sites/default/files/uploads/pi400box.jpg (Raspberry Pi 400 box)
|
||||
[4]: https://creativecommons.org/licenses/by-sa/4.0/
|
||||
[5]: https://opensource.com/sites/default/files/uploads/pi400-keyboard.jpg (Raspberry Pi 400 keyboard)
|
||||
[6]: https://opensource.com/sites/default/files/uploads/pi400-ports.jpg (Raspberry Pi 400 ports)
|
||||
[7]: https://opensource.com/article/20/5/open-source-video-conferencing
|
||||
[8]: https://www.raspberrypi.org/software/
|
||||
[9]: https://opensource.com/tags/raspberry-pi
|
@ -0,0 +1,100 @@
|
||||
[#]: subject: (12 Raspberry Pi projects to try this year)
|
||||
[#]: via: (https://opensource.com/articles/21/3/raspberry-pi-projects)
|
||||
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
12 Raspberry Pi projects to try this year
|
||||
======
|
||||
There are plenty of reasons to use your Raspberry Pi at home, work, and
|
||||
everywhere in between. Celebrate Pi Day by choosing one of these
|
||||
projects.
|
||||
![Raspberry Pi 4 board][1]
|
||||
|
||||
Remember when the Raspberry Pi was just a really tiny hobbyist Linux computer? Well, to the surprise of no one, the Pi's power and scope has escalated quickly. Have you got a new Raspberry Pi or an old one lying around needing something to do? If so, we have plenty of new project ideas, ranging from home automation to cross-platform coding, and even some new hardware to check out.
|
||||
|
||||
### Raspberry Pi at home
|
||||
|
||||
Although I started using the Raspberry Pi mostly for electronics projects, any spare Pi not attached to a breadboard quickly became a home server. As I decommission old units, I always look for a new reason to keep it working on something useful.
|
||||
|
||||
* While it's fun to make LEDs blink with a Pi, after you've finished a few basic electronics projects, it might be time to give your Pi some serious responsibilities. Predictably, it turns out that a homemade smart thermostat is substantially smarter than those you buy off the shelf. Try out ThermOS and this tutorial to [build your own multizone thermostat with a Raspberry Pi][2].
|
||||
|
||||
* Whether you have a child trying to focus on remote schoolwork or an adult trying to stay on task during work hours, being able to "turn off" parts of the Internet can be an invaluable feature for your home network. [The Pi-hole project][3] grants you this ability by turning your Pi into your local DNS server, which allows you to block or re-route specific sites. There's a sizable community around Pi-hole, so there are existing lists of commonly blocked sites, and several front-ends to help you interact with Pi-hole right from your Android phone.
|
||||
|
||||
* Some families have a complex schedule. Kids have school and afterschool activities, adults have important events to attend, anniversaries and birthdays to remember, appointments to keep, and so on. You can keep track of everything using your mobile phone, but this is the future! Shouldn't wall calendars be interactive by now?
|
||||
|
||||
For me, nothing is more futuristic than paper that changes its ink. Of course, we have e-ink now, and the Pi can use an e-ink display as its screen. [Build a family calendar][4] with a Pi and an e-ink display for one of the lowest-powered yet most futuristic (or magical, if you prefer) calendaring systems possible.
|
||||
|
||||
* There's something about the Raspberry Pi's minimal design and lack of a case that inspires you to want to build something with it. After you've built yourself a thermostat and a calendar, why not [replace your home router with a Raspberry Pi][5]? With the OpenWRT distribution, you can repurpose your Pi as a router, and with the right hardware you can even add mobile connectivity.
|
||||
|
||||
|
||||
|
||||
|
||||
### Monitoring your world with the Pi
|
||||
|
||||
For modern technology to be truly interactive, it has to have an awareness of its environment. For instance, a display that brightens or dims based on ambient light isn't possible without useful light sensor data. Similarly, the actual _environment_ is really important to us humans, and so it helps to have technology that can monitor it for us.
|
||||
|
||||
* Gathering data from sensors is one of the foundations you need to understand before embarking on a home automation or Internet of Things project. The Pi can do serious computing tasks, but it's got to get its data from something. Sensors provide a Pi with data about the environment. [Learn more about the fine art of gathering data over sensors][6] so you'll be ready to monitor the physical world with your Pi.
|
||||
|
||||
* Once you're gathering data, you need a way to process it. The open source monitoring tool Prometheus is famous for its ability to represent complex data inputs, and so it's an ideal candidate to be your IoT (Internet of Things) aggregator. Get started now, and in no time you'll be monitoring and measuring and general data crunching with [Prometheus on a Pi][7].
|
||||
|
||||
* While a Pi is inexpensive and small enough to be given a single task, it's still a surprisingly powerful computer. Whether you've got one Pi monitoring a dozen other Pi units on your IoT, or whether you just have a Pi tracking the temperature of your greenhouse, sometimes it's nice to be able to check in on the Pi itself to find out what its workload is like, or where specific tasks might be able to be optimized.
|
||||
|
||||
Grafana is a great platform for monitoring servers, including a Raspberry Pi. [Prometheus and Grafana][8] work together to monitor all aspects of your hardware, providing a friendly dashboard so you can check in on performance and reliability at a glance.
|
||||
|
||||
* You can download mobile apps to help you scan your home for WiFi signal strength, or you can [build your own on a Raspberry Pi using Go][9]. The latter sounds a lot more fun than the former, and because you're writing it yourself, there's a lot more customization you can do on a Pi-based solution.
|
||||
|
||||
|
||||
|
||||
|
||||
### The Pi at work
|
||||
|
||||
I've run file shares and development servers on Pi units at work, and I've seen them at former workplaces doing all kinds of odd jobs (I remember one that got hooked up to an espresso machine to count how many cups of coffee my department consumed each day, not for accounting purposes but for bragging rights). Ask your IT department before bringing your Pi to work, of course, but look around and see what odd job a credit-card-sized computer might be able to do for you.
|
||||
|
||||
* Of course you could host a website on a Raspberry Pi from the very beginning of the Pi. But as the Pi has developed, it's gotten more RAM and better processing power, and so [a dynamic website with SQLite or Postgres and Python][10] is an entirely reasonable prospect.
|
||||
|
||||
* Printers are infamously frustrating. Wouldn't it be nice to program [your very own print UI][11] using the amazing cross-platform framework TotalCross and a Pi? The less you have to struggle through screens of poorly designed and excessive options, the better. If you design it yourself, you can provide exactly the options your department needs, leaving the rest out of sight and out of mind.
|
||||
|
||||
* Containers are the latest trend in computing, but before containers there were FreeBSD jails. Jails are a great solution for running high-risk applications safely, but they can be complex to set up and maintain. However, if you install FreeBSD on your Pi and run [Bastille for jail management][12] and mix in the liberal use of jail templates, you'll find yourself using jails with the same ease you use containers on Linux.
|
||||
|
||||
* The "problem" with having so many tech devices around your desk is that your attention tends to get split between screens. If you'd rather be able to relax and just stare at a single screen, then you might look into the Scrcpy project, a screen copying application that [lets you access the screen of your mobile device on your Linux desktop or Pi][13]. I've tested scrcpy on a Pi 3 and a Pi 4, and the performance has surprised me each time. I use scrcpy often, but especially when I'm setting up an exciting new Edge computing node on your Pi cluster, or building my smart thermostat, or my mobile router, or whatever else.
|
||||
|
||||
|
||||
|
||||
|
||||
### Get a Pi
|
||||
|
||||
To be fair, not everyone has a Pi. If you haven't gotten hold of a Pi yet, you might [take a look at the Pi 400][14], an ultra-portable Pi-in-a-keyboard computer. Evocative of the Commodore 64, this unique form factor is designed to make it easy for you to plug your keyboard (and the Pi inside of it) into the closest monitor and get started computing. It's fast, easy, convenient, and almost _painfully_ retro. If you don't own a Pi yet, this may well be the one to get.
|
||||
|
||||
What Pi projects are you working on for Pi day? Tell us in the comments.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/articles/21/3/raspberry-pi-projects
|
||||
|
||||
作者:[Seth Kenlon][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/seth
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/raspberry-pi-4_lead.jpg?itok=2bkk43om (Raspberry Pi 4 board)
|
||||
[2]: https://opensource.com/article/21/3/thermostat-raspberry-pi
|
||||
[3]: https://opensource.com/article/21/3/raspberry-pi-parental-control
|
||||
[4]: https://opensource.com/article/21/3/family-calendar-raspberry-pi
|
||||
[5]: https://opensource.com/article/21/3/router-raspberry-pi
|
||||
[6]: https://opensource.com/article/21/3/sensor-data-raspberry-pi
|
||||
[7]: https://opensource.com/article/21/3/iot-measure-raspberry-pi
|
||||
[8]: https://opensource.com/article/21/3/raspberry-pi-grafana-cloud
|
||||
[9]: https://opensource.com/article/21/3/troubleshoot-wifi-go-raspberry-pi
|
||||
[10]: https://opensource.com/article/21/3/web-hosting-raspberry-pi
|
||||
[11]: https://opensource.com/article/21/3/raspberry-pi-totalcross
|
||||
[12]: https://opensource.com/article/21/3/bastille-raspberry-pi
|
||||
[13]: https://opensource.com/article/21/3/android-raspberry-pi
|
||||
[14]: https://opensource.com/article/21/3/raspberry-pi-400-review
|
@ -1,135 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (stevenzdg988)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (6 best practices for managing Git repos)
|
||||
[#]: via: (https://opensource.com/article/20/7/git-repos-best-practices)
|
||||
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
|
||||
|
||||
6 个最佳的 Git 仓库管理实践
|
||||
======
|
||||
阻止向 Git 中添加内容的主张会使其变得更难管理;
|
||||
这里有替代方法。
|
||||
![在家中使用笔记本电脑工作][1]
|
||||
|
||||
有权访问源代码使对安全性的分析以及应用程序的安全成为可能。但是,如果没有人真正看过代码,问题就不会被发现,即使人们积极地看代码,通常也要看很多东西。幸运的是,GitHub 拥有一个活跃的安全团队,最近,他们 [发现了已提交到多个 Git 存储库中的特洛伊木马病毒][2],甚至仓库的所有者也偷偷溜走了。尽管我们无法控制其他人如何管理自己的存储库,但我们可以从他们的错误中吸取教训。为此,本文回顾了将文件添加到自己的存储库中的一些最佳实践。
|
||||
|
||||
### 了解您的仓库
|
||||
|
||||
![Git 存储库终端][3]
|
||||
|
||||
对于安全的 Git 存储库来说大概是 Rule Zero (头号规则)。作为项目维护者,无论您是从自己的开始还是采用别人的,您的工作是了解自己存储库中的内容。您可能没有代码库中关于每个文件的存储列表,但是您需要了解所管理内容的基本组成。如果几十个合并后出现一个偏离的文件,您将可以很容易地识别它,因为您不知道它的用途,并且需要刷新内存检查它。发生这种情况时,请查看文件,并确保准确了解为什么它是必要的。
|
||||
|
||||
### 禁止二进制大文件
|
||||
|
||||
![终端中 Git 的二进制检查命令][4]
|
||||
|
||||
Git 用于文本,无论是用纯文本编写的 C 或 Python 还是 Java 文本,亦或是 JSON,YAML,XML,Markdown,HTML 或类似的文本。Git 对于二进制文件不是很理想。
|
||||
|
||||
两者之间的区别是:
|
||||
|
||||
```
|
||||
$ cat hello.txt
|
||||
This is plain text.
|
||||
It's readable by humans and machines alike.
|
||||
Git knows how to version this.
|
||||
|
||||
$ git diff hello.txt
|
||||
diff --git a/hello.txt b/hello.txt
|
||||
index f227cc3..0d85b44 100644
|
||||
\--- a/hello.txt
|
||||
+++ b/hello.txt
|
||||
@@ -1,2 +1,3 @@
|
||||
This is plain text.
|
||||
+It's readable by humans and machines alike.
|
||||
Git knows how to version this.
|
||||
```
|
||||
|
||||
和
|
||||
|
||||
```
|
||||
$ git diff pixel.png
|
||||
diff --git a/pixel.png b/pixel.png
|
||||
index 563235a..7aab7bc 100644
|
||||
Binary files a/pixel.png and b/pixel.png differ
|
||||
|
||||
$ cat pixel.png
|
||||
<EFBFBD>PNG
|
||||
▒
|
||||
IHDR7n<EFBFBD>$gAMA<4D><41>
|
||||
<20>abKGD݊<44>tIME<4D>
|
||||
|
||||
-2R<32><52>
|
||||
IDA<EFBFBD>c`<60>!<21>3%tEXtdate:create2020-06-11T11:45:04+12:00<30><30>r.%tEXtdate:modify2020-06-11T11:45:04+12:00<30><30>ʒIEND<4E>B`<60>
|
||||
```
|
||||
|
||||
二进制文件中的数据无法以解析纯文本相同的方式进行解析,因此,如果二进制文件发生任何更改,则必须重写整个内容。一个版本与另一个版本之间的仅有地区别是快速增加的内容。
|
||||
|
||||
更糟糕的是,Git 存储库维护者无法合理地审计二进制数据。这违反了 Rule Zero (头号规则):应该对存储库的内容了如指掌。
|
||||
|
||||
除了常用的 [POSIX(可移植性操作系统接口)][5] 工具之外,您还可以使用 `git diff` 检测二进制文件。当您尝试使用 `--numstat` 选项来比较二进制文件时,Git 返回空结果:
|
||||
|
||||
```
|
||||
$ git diff --numstat /dev/null pixel.png | tee
|
||||
\- - /dev/null => pixel.png
|
||||
$ git diff --numstat /dev/null file.txt | tee
|
||||
5788 0 /dev/null => list.txt
|
||||
```
|
||||
|
||||
如果您正在考虑将二进制大文件提交到存储库,请停下来先思考一下。如果是二进制文件,则它是由什么生成的。 有充分的理由在构建时生成它们来代替将它们提交存储库?你决定提交二进制数据可行,请确保在 README 文件或类似文件中标识二进制文件的位置,为什么是二进制的原因以及更新它们的协议。必须谨慎执行更新,因为对于提交给二进制大文件的每次更改,该二进制大文件的存储空间实际上都会加倍。
|
||||
|
||||
### 保留第三方库
|
||||
|
||||
第三方库也不例外。尽管它是开放源代码的众多优点之一,您可以不受限制地重用和重新分发未编写的代码,但是有很多充分的理由不去覆盖存储在您自己的存储库中第三方库。首先,除非您自己检查了所有代码(以及将来的合并),否则您无法准确确定第三方库。其次,当您将第三方库复制到您的 Git 存储库中时,会将焦点从真正的上游源分离出来。从技术上仅对主库的副本有把握,而不对随机存储库的副本有把握。如果您需要锁定特定版本的库,请为开发人员提供项目所需版本的合理 URL,或者使用[Git 子模块][6]。
|
||||
|
||||
### 抵制盲目的 `git add`
|
||||
|
||||
![Git 手动添加命令终端中][7]
|
||||
|
||||
如果您的项目已编译,请不要使用 `git add .`(其中 `.` 是当前目录或特定文件夹的路径)作为添加任意和每一个新内容的简单方法。如果您不是手动编译项目,而是使用 IDE 为您管理项目,则这一点尤其重要。用 IDE 管理项目时,跟踪添加到存储库中的内容非常困难,因此仅添加您实际编写的内容非常重要,而不是在项目文件夹中弹出的任何新对象。
|
||||
|
||||
如果您使用 `git add .` 做,请在推送之前检查这一状态里的情况。如果在执行 `git status` 时在项目文件夹中看到一个陌生的对象,请在运行 `make clean` 或等效命令找出它的来源以及为什么仍然在项目的目录中。这是非常好的不会在编译期间重新生成的创建方法,因此在提交前请三思。
|
||||
|
||||
### 使用 Git ignore
|
||||
|
||||
![终端中的 `Git ignore` 命令][8]
|
||||
|
||||
为程序员提供的许多方便的创建众说纷纭。任何项目,程序,富有艺术性的或其他的典型项目目录中都充斥着隐藏的文件,元数据和残留的内容。您可以尝试忽略这些对象,但是 `git status` 中的提示越多,您错过某件事的可能性就越大。
|
||||
|
||||
您可以通过维护一个良好的 `gitignore` 文件来为您过滤掉这种噪音。因为这是使用 Git 的用户的共同要求,所以有一些入门 `gitignore` 文件可用。[Github.com/github/gitignore][9] 提供了几个专门创建 `gitignore` 的文件,您可以下载这些文件并将其放置到自己的项目中,几年前 [Gitlab.com][10] 将`gitignore` 模板集成到了存储库创建工作流程中。使用这些帮助您为项目创建适合的 `gitignore` 策略并遵守它。
|
||||
|
||||
### 查看合并请求
|
||||
|
||||
![Git 合并请求][11]
|
||||
|
||||
当您通过电子邮件收到合并或拉取请求或补丁文件时,请勿仅对其进行测试以确保其正常工作。您的工作是阅读新代码进入代码库的并了解其如何产生结果。如果您不同意实施,或者更糟的是,您不理解该实施,请向提交该实施的人发送消息,并要求其进行说明。询问所依赖代码要成为存储库中永久性装置具有优先权,但是这是在你同你的用户的不知道将合并什么到他们将要使用的代码中开启的约定。
|
||||
|
||||
### Git 责任
|
||||
|
||||
社区致力于开源软件良好的安全性。不要鼓励在您的存储库中使用不良的 Git 实践,也不要忽视克隆的存储库中的安全威胁。Git 功能强大,但它仍然只是一个计算机程序,因此要以人为本,确保每个人的安全。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/7/git-repos-best-practices
|
||||
|
||||
作者:[Seth Kenlon][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[stevenzdg988](https://github.com/stevenzdg988)
|
||||
校对:[校对者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/wfh_work_home_laptop_work.png?itok=VFwToeMy (Working from home at a laptop)
|
||||
[2]: https://securitylab.github.com/research/octopus-scanner-malware-open-source-supply-chain/
|
||||
[3]: https://opensource.com/sites/default/files/uploads/git_repo.png (Git repository )
|
||||
[4]: https://opensource.com/sites/default/files/uploads/git-binary-check.jpg (Git binary check)
|
||||
[5]: https://opensource.com/article/19/7/what-posix-richard-stallman-explains
|
||||
[6]: https://git-scm.com/book/en/v2/Git-Tools-Submodules
|
||||
[7]: https://opensource.com/sites/default/files/uploads/git-cola-manual-add.jpg (Git manual add)
|
||||
[8]: https://opensource.com/sites/default/files/uploads/git-ignore.jpg (Git ignore)
|
||||
[9]: https://github.com/github/gitignore
|
||||
[10]: https://about.gitlab.com/releases/2016/05/22/gitlab-8-8-released
|
||||
[11]: https://opensource.com/sites/default/files/uploads/git_merge_request.png (Git merge request)
|
@ -0,0 +1,83 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (wxy)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Turn your Raspberry Pi into a HiFi music system)
|
||||
[#]: via: (https://opensource.com/article/21/1/raspberry-pi-hifi)
|
||||
[#]: author: (Peter Czanik https://opensource.com/users/czanik)
|
||||
|
||||
把你的树莓派变成一个 HiFi 音乐系统。
|
||||
======
|
||||
|
||||
> 为你的朋友、家人、同事或其他任何拥有廉价发烧设备的人播放音乐。
|
||||
|
||||
![HiFi 复古立体声][1]
|
||||
|
||||
在过去的 10 年里,我大部分时间都是远程工作,但当我走进办公室时,我坐在一个充满内向的同伴的房间里,他们很容易被环境噪音和谈话所干扰。我们发现,听音乐可以抑制办公室的噪音,让声音不那么扰人,用愉快的音乐提供一个愉快的工作环境。
|
||||
|
||||
起初,我们的一位同事带来了一些老式的有源电脑音箱,把它们连接到他的桌面上,然后问我们想听什么。它可以工作,但音质不是很好,而且只有当他在办公室的时候才可以使用。接下来,我们又买了一对 Altec Lansing 音箱。音质有所改善,但没有什么灵活性。
|
||||
|
||||
不久之后,我们得到了一台通用 ARM 单板计算机(SBC),这意味着任何人都可以通过 Web 界面控制播放列表和扬声器。但一块普通的 ARM 开发板意味着我们不能使用流行的音乐设备软件。由于非标准的内核,更新操作系统是一件很痛苦的事情,而且 Web 界面也经常出现故障。
|
||||
|
||||
当团队壮大并搬进更大的房间后,我们开始梦想着有更好的扬声器和更容易处理软件和硬件组合的方法。
|
||||
|
||||
为了用一种相对便宜、灵活、音质好的方式解决我们的问题,我们用树莓派、音箱和开源软件开发了一个办公室 HiFi。
|
||||
|
||||
### HiFi 硬件
|
||||
|
||||
用一个专门的 PC 来播放背景音乐就有点过分了。它昂贵、嘈杂(除非是静音的,但那就更贵了),而且不环保。即使是最便宜的 ARM 板也能胜任这个工作,但从软件的角度来看,它们往往存在问题。树莓派还是比较便宜的,虽然不符合标准,但在硬件和软件方面都有很好的支持。
|
||||
|
||||
接下来的问题是:用什么音箱。质量好的、有源的扬声器很贵。无源音箱的成本较低,但需要一个放大器,这将为这套设备增加另一个盒子。它们还必须使用树莓派的音频输出;虽然可以工作,但并不是最好的,特别是当你已经在高质量的扬声器和放大器上投入资金的时候。
|
||||
|
||||
幸运的是,在数以千计的树莓派硬件扩展中,有内置数字模拟转换器(DAC)的放大器。我们选择了 [HiFiBerry 的 Amp][2]。它在我们买来后不久就停产了(被采样率更好的 Amp+ 型号取代),但对于我们的目的来说,它已经足够好了。在开着空调的情况下,我想无论如何你也听不出能达到 48kHz 或 192kHz 的 DAC 有什么不同。
|
||||
|
||||
音箱方面,我们选择了 [Audioengine P4][3],是在某店家清仓大甩卖的时候买的,价格超低。它很容易让我们的办公室房间充满了声音而不失真(并且还不止充满了我们的房间,有一些失真,而邻居的工程师往往不喜欢)。
|
||||
|
||||
### HiFi 软件
|
||||
|
||||
在我们旧的通用 ARM SBC 上我们需要维护一个 Ubuntu,使用一个固定的、古老的、在软件包仓库外的系统内核,这是有问题的。树莓派操作系统包括一个维护良好的内核包,使其成为一个稳定且易于更新的基础系统,但它仍然需要我们定期更新 Python 脚本来访问 Spotify 和 YouTube。对于我们的目的来说,这有点过于高维护。
|
||||
|
||||
幸运的是,使用树莓派作为基础意味着有许多现成的软件设备可用。
|
||||
|
||||
我们选择了 [Volumio][4],这是一个将树莓派变成音乐播放设备的开源项目。安装是一个简单的*一步步完成*的过程。安装和升级是完全无痛的,而不用辛辛苦苦地安装和维护一个操作系统,并定期调试破损的 Python 代码。配置 HiFiBerry 放大器不需要编辑任何配置文件,你只需要从列表中选择即可。当然,习惯新的用户界面需要一定的时间,但稳定性和维护的便捷性让这个改变是值得的。
|
||||
|
||||
![Volumio interface][5]
|
||||
|
||||
### 播放音乐并体验
|
||||
|
||||
虽然大流行期间我们都在家里办公,但办公室的 HiFi 安装在我家的办公室里,这意味着我可以自由支配它的运行。一个不断变化的用户界面对于一个团队来说会很痛苦,但对于一个有研发背景的人来说,自己玩一个设备,变化是很有趣的。
|
||||
|
||||
我不是一个程序员,但我有很强的 Linux 和 Unix 系统管理背景。这意味着,虽然我觉得修复坏掉的 Python 代码很烦人,但 Volumio 对我来说却足够完美,足够无聊(这是一个很好的“问题”)。幸运的是,在树莓派上播放音乐还有很多其他的可能性。
|
||||
|
||||
作为一个终端狂人(我甚至从终端窗口启动 LibreOffice),我主要使用 Music on Console([MOC][6])来播放我的网络存储(NAS)中的音乐。我有几百张 CD,都变成了 [FLAC][7] 文件。而且我还从 [BandCamp][8] 或 [Society of Sound][9] 等渠道购买了许多数字专辑。
|
||||
|
||||
另一个选择是 [音乐播放器守护进程(MPD)][10]。把它运行在树莓派上,我可以通过网络使用 Linux 和 Android 的众多客户端之一与我的音乐进行远程交互。
|
||||
|
||||
### 音乐不停歇
|
||||
|
||||
正如你所看到的,创建一个廉价的 HiFi 系统的可能性在软件和硬件方面几乎是无限的。我们的解决方案只是众多解决方案中的一个,我希望它能启发你建立适合你环境的东西。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/1/raspberry-pi-hifi
|
||||
|
||||
作者:[Peter Czanik][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/czanik
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/hi-fi-stereo-vintage.png?itok=KYY3YQwE (HiFi vintage stereo)
|
||||
[2]: https://www.hifiberry.com/products/amp/
|
||||
[3]: https://audioengineusa.com/shop/passivespeakers/p4-passive-speakers/
|
||||
[4]: https://volumio.org/
|
||||
[5]: https://opensource.com/sites/default/files/uploads/volumeio.png (Volumio interface)
|
||||
[6]: https://en.wikipedia.org/wiki/Music_on_Console
|
||||
[7]: https://xiph.org/flac/
|
||||
[8]: https://bandcamp.com/
|
||||
[9]: https://realworldrecords.com/news/society-of-sound-statement/
|
||||
[10]: https://www.musicpd.org/
|
@ -0,0 +1,105 @@
|
||||
[#]: subject: (Use gImageReader to Extract Text From Images and PDFs on Linux)
|
||||
[#]: via: (https://itsfoss.com/gimagereader-ocr/)
|
||||
[#]: author: (Ankush Das https://itsfoss.com/author/ankush/)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
在 Linux 上使用 gImageReader 从图像和 PDF 中提取文本
|
||||
======
|
||||
|
||||
_简介:gImageReader 是一个 GUI 工具,用于在 Linux 中利用 Tesseract OCR 引擎从图像和 PDF 文件中提取文本。_
|
||||
|
||||
[gImageReader][1] 是 [Tesseract 开源 OCR 引擎][2]的一个前端。_Tesseract_ 最初是由 HP 公司开发的,然后在 2006 年开源。
|
||||
|
||||
基本上,OCR(光学字符识别)引擎可以让你从图片或文件(PDF)中扫描文本。默认情况下,它可以检测几种语言,还支持通过 Unicode 字符扫描。
|
||||
|
||||
然而,Tesseract 本身是一个没有任何 GUI 的命令行工具。因此,gImageReader 就来解决这点,它可以让任何用户使用它从图像和文件中提取文本。
|
||||
|
||||
让我重点介绍一些有关它的内容,同时说下我在测试期间的使用经验。
|
||||
|
||||
### gImageReader:一个跨平台的 Tesseract OCR 前端
|
||||
|
||||
![][3]
|
||||
|
||||
为了简化事情,gImageReader 在从 PDF 文件或包含任何类型文本的图像中提取文本时非常方便。
|
||||
|
||||
无论你是需要它来进行拼写检查还是翻译,它都应该对特定的用户群体有用。
|
||||
|
||||
在列表总结下功能,这里是你可以用它做的事情:
|
||||
|
||||
* 从磁盘、扫描设备、剪贴板和截图中添加 PDF 文档和图像
|
||||
* 能够旋转图像
|
||||
* 常用的图像控制,用于调整亮度、对比度和分辨率。
|
||||
* 直接通过应用扫描图像
|
||||
* 能够一次性处理多个图像或文件
|
||||
* 手动或自动识别区域定义
|
||||
* 识别纯文本或 [hOCR][4] 文档
|
||||
* 编辑器显示识别的文本
|
||||
* 可对对提取的文本进行拼写检查
|
||||
* 从 hOCR 文件转换/导出为 PDF 文件
|
||||
* 将提取的文本导出为 .txt 文件
|
||||
* 跨平台(Windows)
|
||||
|
||||
|
||||
|
||||
### 在 Linux 上安装 gImageReader
|
||||
|
||||
**注意**:_你需要安装 Tesseract 语言包,才能从软件管理器中的图像/文件中进行检测。_
|
||||
|
||||
![][5]
|
||||
|
||||
你可以在一些 Linux 发行版如 Fedora 和 Debian 的默认仓库中找到 gImageReader。
|
||||
|
||||
对于 Ubuntu,你需要添加一个 PPA,然后安装它。要做到这点,下面是你需要在终端中输入的内容:
|
||||
|
||||
```
|
||||
sudo add-apt-repository ppa:sandromani/gimagereader
|
||||
sudo apt update
|
||||
sudo apt install gimagereader
|
||||
```
|
||||
|
||||
你也可以从 openSUSE 的构建服务中找到它,Arch Linux 用户可在 [AUR][6] 中找到。
|
||||
|
||||
所有的仓库和包的链接都可以在他们的 [GitHub 页面][1]中找到。
|
||||
|
||||
[gImageReader][1]
|
||||
|
||||
### gImageReader 使用经验
|
||||
|
||||
当你需要从图像中提取文本时,gImageReader 是一个相当有用的工具。当你尝试从 PDF 文件中提取文本时,它的效果非常好。
|
||||
|
||||
对于从智能手机拍摄的图片中提取,检测很接近,但有点不准确。也许当你进行扫描时,从文件中识别字符可能会更好。
|
||||
|
||||
所以,你需要亲自尝试一下,看看它是否对你而言工作良好。我在 Linux Mint 20.1(基于 Ubuntu 20.04)上试过。
|
||||
|
||||
我只遇到了一个从设置中管理语言的问题,我没有得到一个快速的解决方案。如果你遇到此问题,那么可能需要对其进行故障排除,并进一步了解如何解决该问题。
|
||||
|
||||
![][7]
|
||||
|
||||
除此之外,它工作良好。
|
||||
|
||||
试试吧,让我知道它是如何为你服务的!如果你知道类似的东西(和更好的),请在下面的评论中告诉我。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/gimagereader-ocr/
|
||||
|
||||
作者:[Ankush Das][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/ankush/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://github.com/manisandro/gImageReader
|
||||
[2]: https://tesseract-ocr.github.io/
|
||||
[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/03/gImageReader.png?resize=800%2C456&ssl=1
|
||||
[4]: https://en.wikipedia.org/wiki/HOCR
|
||||
[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/03/tesseract-language-pack.jpg?resize=800%2C620&ssl=1
|
||||
[6]: https://itsfoss.com/aur-arch-linux/
|
||||
[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/03/gImageReader-1.jpg?resize=800%2C460&ssl=1
|
@ -0,0 +1,173 @@
|
||||
[#]: subject: (Linux Mint Cinnamon vs MATE vs Xfce: Which One Should You Use?)
|
||||
[#]: via: (https://itsfoss.com/linux-mint-cinnamon-mate-xfce/)
|
||||
[#]: author: (Dimitrios https://itsfoss.com/author/dimitrios/)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (wxy)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
Cinnamon vs MATE vs Xfce:你应该选择那一个 Linux Mint 口味?
|
||||
======
|
||||
|
||||
Linux Mint 无疑是 [最适合初学者的 Linux 发行版之一][1]。尤其是对于刚刚迈向 Linux 世界的 Windows 用户来说,更是如此。
|
||||
|
||||
2006 年以来(也就是 Linux Mint 首次发布的那一年),他们开发了一系列的提高用户的体验的 [工具][2]。此外,Linux Mint 是基于 Ubuntu 的,所以你有一个可以寻求帮助的庞大的用户社区。
|
||||
|
||||
我不打算讨论 Linux Mint 有多好。如果你已经下定决心 [安装Linux Mint][3],你可能会对它网站上的 [下载部分][4] 感到有些困惑。
|
||||
|
||||
它给了你三个选择:Cinnamon、MATE 和 Xfce。不知道该如何选择吗?我将在本文中帮你解决这个问题。
|
||||
|
||||
![][5]
|
||||
|
||||
如果你是个 Linux 的绝对新手,对上面的东西一无所知,我建议你了解一下 [什么是 Linux 桌面环境][6]。如果你能再多花点时间,请阅读这篇关于 [什么是 Linux,以及为什么有这么多看起来相似的 Linux 操作系统][7] 的优秀解释。
|
||||
|
||||
有了这些信息,你就可以了解各种 Linux Mint 版本之间的区别了。如果你不知道该选择哪一个,通过这篇文章,我将帮助你做出一个有意识的选择。
|
||||
|
||||
### 你应该选择哪个 Linux Mint 版本?
|
||||
|
||||
![][8]
|
||||
|
||||
简单来说,可供选择的有以下几种:
|
||||
|
||||
* **Cinnamon 桌面**:具有现代感的传统桌面。
|
||||
* **MATE 桌面**:类似 GNOME 2 时代的传统外观桌面。
|
||||
* **Xfce 桌面**:一个流行的轻量级桌面环境。
|
||||
|
||||
我们来逐一看看 Mint 的各个变种。
|
||||
|
||||
#### Linux Mint Cinnamon 版
|
||||
|
||||
Cinnamon 桌面是由 Linux Mint 团队开发的,显然它是 Linux Mint 的主力版本。
|
||||
|
||||
早在近十年前,当 GNOME 桌面选择了非常规的 GNOME 3 用户界面时,人们就开始了 Cinnamon 的开发,通过复刻 GNOME 2 的一些组件来保持桌面的传统外观。
|
||||
|
||||
很多 Linux 用户喜欢 Cinnamon,就是因为它有像 Windows 7 一样的界面。
|
||||
|
||||
![Linux Mint Cinnamon desktop][9]
|
||||
|
||||
##### 性能和相应能力
|
||||
|
||||
Cinnamon 桌面的性能比过去的版本有所提高,但如果没有固态硬盘,你会觉得有点迟钝。上一次我使用 Cinnamon 桌面是在 4.4.8 版,开机后的内存消耗在 750MB 左右。现在的 4.8.6 版有了很大的改进,开机后减少了 100MB 内存消耗。
|
||||
|
||||
为了获得最佳的用户体验,应该考虑双核 CPU,最低 4GB 内存。
|
||||
|
||||
![Linux Mint 20 Cinnamon idle system stats][10]
|
||||
|
||||
##### 优势
|
||||
|
||||
* 从 Windows 无缝切换
|
||||
* 赏心悦目
|
||||
* 高度 [可定制][11]
|
||||
|
||||
##### 劣势
|
||||
|
||||
* 如果你的系统只有 2GB 内存,可能还是不够理想
|
||||
|
||||
**附加建议**:如果你喜欢 Debian 而不是 Ubuntu,你可以选择 [Linux Mint Debian 版][12](LMDE)。LMDE 和带有 Cinnamon 桌面的 Debian 主要区别在于 LMDE 向其仓库提供最新的桌面环境。
|
||||
|
||||
#### Linux Mint Mate 版
|
||||
|
||||
[MATE 桌面环境][13] 也有类似的故事,它的目的是维护和支持 GNOME 2 的代码库和应用程序。它的外观和感觉与 GNOME 2 非常相似。
|
||||
|
||||
在我看来,到目前为止,MATE 桌面的最佳实现是 [Ubuntu MATE][14]。在 Linux Mint 中,你会得到一个定制版的 MATE 桌面,它符合 Cinnamon 美学,而不是传统的 GNOME 2 设定。
|
||||
|
||||
![Screenshot of Linux Mint MATE desktop][15]
|
||||
|
||||
##### 性能和响应能力
|
||||
|
||||
MATE 桌面以轻薄著称,这一点毋庸置疑。与 Cinnamon 桌面相比,其 CPU 的使用率始终保持在较低的水平,换言之,在笔记本电脑上会有更好的电池续航时间。
|
||||
|
||||
虽然感觉没有 Xfce 那么敏捷(在我看来),但不至于影响用户体验。内存消耗在 500MB 以下起步,这对于功能丰富的桌面环境来说是令人印象深刻的。
|
||||
|
||||
![Linux Mint 20 MATE idle system stats][16]
|
||||
|
||||
##### 优势
|
||||
|
||||
* 不影响 [功能][17] 的轻量级桌面
|
||||
* 足够的 [定制化][18] 可能性
|
||||
|
||||
##### 劣势
|
||||
|
||||
* 传统的外观可能会给你一种过时的感觉
|
||||
|
||||
#### Linux Mint Xfce 版
|
||||
|
||||
Xfce 项目始于 1996 年,受到了 UNIX 的 [通用桌面环境(CDE)][19] 的启发。Xfce 是 “[XForms][20] Common Environment” 的缩写,但由于它不再使用 XForms 工具箱,所以名字拼写为 “Xfce”。
|
||||
|
||||
它的目标是快速、轻量级和易于使用。Xfce 是许多流行的 Linux 发行版的主要桌面,如 [Manjaro][21] 和 [MX Linux][22]。
|
||||
|
||||
Linux Mint 提供了一个精致的 Xfce 桌面,但即使是黑暗主题也无法与 Cinnamon 桌面的美感相比。
|
||||
|
||||
![Linux Mint 20 Xfce desktop][23]
|
||||
|
||||
##### 性能和响应能力
|
||||
|
||||
Xfce 是 Linux Mint 提供的最精简的桌面环境。通过点击开始菜单、设置控制面板或探索底部面板,你会发现这是一个简单而又灵活的桌面环境。
|
||||
|
||||
尽管我觉得极简主义是一个积极的属性,但 Xfce 并不是一个养眼的产品,反而留下的是比较传统的味道。但对于一些用户来说,经典的桌面环境才是他们的首选。
|
||||
|
||||
在第一次开机时,内存的使用情况与 MATE 桌面类似,但并不尽如人意。如果你的电脑没有配备 SSD,Xfce 桌面环境可以让你的系统复活。
|
||||
|
||||
![Linux Mint 20 Xfce idle system stats][24]
|
||||
|
||||
##### 优势
|
||||
|
||||
* 使用简单
|
||||
* 非常轻巧,适合老式硬件
|
||||
* 坚如磐石的稳定
|
||||
|
||||
##### 劣势
|
||||
|
||||
* 过时的外观
|
||||
* 与 Cinnamon 相比,可能没有那么多的定制化服务
|
||||
|
||||
### 总结
|
||||
|
||||
由于这三款桌面环境都是基于 GTK 工具包的,所以选择哪个纯属个人喜好。它们都很节约系统资源,对于 4GB 内存的适度系统来说,表现良好。Xfce 和 MATE 可以更低一些,支持低至 2GB 内存的系统。
|
||||
|
||||
Linux Mint 并不是唯一提供多种选择的发行版。Manjaro、Fedora和 [Ubuntu 等发行版也有各种口味][25] 可供选择。
|
||||
|
||||
如果你还是无法下定决心,我建议先选择默认的 Cinnamon 版,并尝试 [在虚拟机中使用 Linux Mint][26]。看看你是否喜欢这个外观和感觉。如果不喜欢,你可以用同样的方式测试其他变体。如果你决定了这个版本,你可以继续 [在你的主系统上安装它][3]。
|
||||
|
||||
希望我的这篇文章能够帮助到你。如果你对这个话题还有疑问或建议,请在下方留言。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/linux-mint-cinnamon-mate-xfce/
|
||||
|
||||
作者:[Dimitrios][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[wxy](https://github.com/wxy)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/dimitrios/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://itsfoss.com/best-linux-beginners/
|
||||
[2]: https://linuxmint-developer-guide.readthedocs.io/en/latest/mint-tools.html#
|
||||
[3]: https://itsfoss.com/install-linux-mint/
|
||||
[4]: https://linuxmint.com/download.php
|
||||
[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/03/linux-mint-version-options.png?resize=789%2C277&ssl=1
|
||||
[6]: https://itsfoss.com/what-is-desktop-environment/
|
||||
[7]: https://itsfoss.com/what-is-linux/
|
||||
[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/03/Linux-Mint-variants.jpg?resize=800%2C450&ssl=1
|
||||
[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/03/linux-mint-20.1-cinnamon.jpg?resize=800%2C500&ssl=1
|
||||
[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/03/Linux-Mint-20-Cinnamon-ram-usage.png?resize=800%2C600&ssl=1
|
||||
[11]: https://itsfoss.com/customize-cinnamon-desktop/
|
||||
[12]: https://itsfoss.com/lmde-4-release/
|
||||
[13]: https://mate-desktop.org/
|
||||
[14]: https://itsfoss.com/ubuntu-mate-20-04-review/
|
||||
[15]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/07/linux-mint-mate.jpg?resize=800%2C500&ssl=1
|
||||
[16]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/03/Linux-Mint-20-MATE-ram-usage.png?resize=800%2C600&ssl=1
|
||||
[17]: https://mate-desktop.org/blog/2020-02-10-mate-1-24-released/
|
||||
[18]: https://itsfoss.com/ubuntu-mate-customization/
|
||||
[19]: https://en.wikipedia.org/wiki/Common_Desktop_Environment
|
||||
[20]: https://en.wikipedia.org/wiki/XForms_(toolkit)
|
||||
[21]: https://itsfoss.com/manjaro-linux-review/
|
||||
[22]: https://itsfoss.com/mx-linux-19/
|
||||
[23]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/07/linux-mint-xfce.jpg?resize=800%2C500&ssl=1
|
||||
[24]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/03/Linux-Mint-20-Xfce-ram-usage.png?resize=800%2C600&ssl=1
|
||||
[25]: https://itsfoss.com/which-ubuntu-install/
|
||||
[26]: https://itsfoss.com/install-linux-mint-in-virtualbox/
|
Loading…
Reference in New Issue
Block a user