Merge pull request #1 from LCTT/master

Rebase
This commit is contained in:
BoosterY 2021-06-27 12:13:39 +08:00 committed by GitHub
commit 68779ea191
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
38 changed files with 3308 additions and 1216 deletions

View File

@ -0,0 +1,75 @@
[#]: collector: (lujun9972)
[#]: translator: (littlebirdnest)
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-13525-1.html)
[#]: subject: (FCC auctions should be a long-term boost for 5G availability)
[#]: via: (https://www.networkworld.com/article/3584072/fcc-auctions-should-be-a-long-term-boost-for-5g-availability.html)
[#]: author: (Jon Gold https://www.networkworld.com/author/Jon-Gold/)
FCC 的频谱拍卖是对 5G 普及的长期助推
======
> FCC 制定新政策是为了让更多的频谱能够被用于通信以此来创造新的服务。
![FCC][1]
随着 5G 的发展为了完全实现它的服务显然需要更多的频谱来FCC 显然对此当成重中之重。
FCC 近日完成了有关<ruby>公民宽带无线电服务<rt>Citizens Broadband Radio Service</rt></ruby>CBRS的 5G 频谱的[拍卖][8],这些频谱是位于 3.5GHz 频段中的 70MHz 新带宽。它拍卖了 45.8 个亿是近几年为无线传输释放更多频道的拍卖会之一。FCC 在 2011、2014 和 2015 年在中低频段(大致在 1.7GHz 至 2.2GHz)和 700MHz 上拍卖了 65MHz。
当前频谱可操作的范围是低于 6GHz 频段或是中频段的频谱,与 [CBRS][9] 拍卖中出售的频谱处于同一区域。据专家称,即将举行的 C 频段拍卖将会是重要一环,将会有高达 280 MHz 频谱被拍卖。
IDC 的研究主管 Jasom leigh 说“C 频段的拍卖将带来大笔资金。……美国的中频段频谱是稀缺的,这就是为什么你会看到这种巨大的紧迫性。”
虽然几大主要移动运营商仍有望抢到这次拍卖中的大部分可用的许可证,但频谱的一些最具创新性的用途将由企业实施,所以将会与运营商竞争一系列可用的频段。
[物联网][11]、资产追踪以及其他私人网络应用的专用网络早已可以通过私人 LTE 实现,但由于 5G 技术先进的频谱共享、低延迟和多连接的特性,它的成熟大大拓宽了它们的范围。广义上讲,能替代更多当前需要连线的应用,如工业自动化、设备管理等等。
### 重新分配频谱就意味着谈判
对于想要改变美国的频谱优先事项上的问题并不是小事FCC 前主席 Tom Wheeler 对此绝对深有体会,过去 10 年里,美国政府一直在推动重新分配频段,而持有频段者的大多是政府机构或者是卫星网络运营商。
Wheeler 说,这些利益相关者必须被分配到不同频段,通常以纳税人出资补偿,而让各个相关方参与分享和进行分享经常是一个复杂的过程。
他指出“FCC 现在面临的挑战之一是,频谱的分配是根据假定使用模拟信号做出的,而这些假定由于数字技术而被改写”。就像电视从模拟电视转变成数字电视。当模拟电视占用了 6MHz 频段,并需要两侧的保护带以避免干扰时,数字信号却能够在一个频段里容纳四到五个信号。
事实证明,这些假定是很难面对的。反对者公开反对 FCC 在中频段的动作,认为这样做没有足够的预防措施来避免对他们原有的设备和服务的干扰,而改变频率也意味着必须购买新的设备。
“我们和美国国防部还有卫星公司讨论过事实上其中一个较大的原因是监管的挑战没人想放弃现有体系下基于模拟信号假定下的安全地位。”Wheeler 说到,“我认为你也必须考虑周全,但我发现那些所谓宣声信号冲突的人,其实是将眼下当作避难所,根本没有竞争和威胁方面的意识。”
### 未来:更多的服务
Leigh 表示,无论开放频谱的确切方式如何,但广泛的观点认为将中频频段开放给运营商和企业,对美国商业会有潜在的优势。而当美国坚持以拍卖形式分配无线频谱时,其他国家,像德国,就已经专门预留了供企业使用的中频段频谱。
对于试图推出自己的私有 5G 网络的公司而言,可能会推高频谱拍卖价格。但是,只要最终有足够可用的频谱,就有服务足够可用,无论它们是内部提供的,还是由移动运营商或供应商销售的。
他说:“企业在 5G 方面做的事情,将推动真正的未来。”
------
via: https://www.networkworld.com/article/3584072/fcc-auctions-should-be-a-long-term-boost-for-5g-availability.html
作者:[Jon Gold][a]
选题:[lujun9972][b]
译者:[littlebirdnest](https://github.com/littlebirdnest)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.networkworld.com/author/Jon-Gold/
[b]: https://github.com/lujun9972
[1]: https://images.techhive.com/images/article/2017/01/fcc-100704762-large.jpg
[2]: https://www.networkworld.com/article/3203489/what-is-5g-fast-wireless-technology-for-enterprises-and-phones.html
[3]: https://www.networkworld.com/article/3568253/how-5g-frequency-affects-range-and-speed.html
[4]: https://www.networkworld.com/article/3568614/private-5g-can-solve-some-enterprise-problems-that-wi-fi-can-t.html
[5]: https://www.networkworld.com/article/3488799/private-5g-keeps-whirlpool-driverless-vehicles-rolling.html
[6]: https://www.networkworld.com/article/3570724/5g-can-make-for-cost-effective-private-backhaul.html
[7]: https://www.networkworld.com/article/3529291/cbrs-wireless-can-bring-private-5g-to-enterprises.html
[8]: https://www.networkworld.com/article/3572564/cbrs-wireless-yields-45b-for-licenses-to-support-5g.html
[9]: https://www.networkworld.com/article/3180615/faq-what-in-the-wireless-world-is-cbrs.html
[10]: https://www.networkworld.com/newsletters/signup.html
[11]: https://www.networkworld.com/article/3207535/what-is-iot-the-internet-of-things-explained.html
[12]: https://www.facebook.com/NetworkWorld/
[13]: https://www.linkedin.com/company/network-world

View File

@ -3,55 +3,48 @@
[#]: author: (Ray Paik https://opensource.com/users/rpaik)
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-13517-1.html)
试试这个新的数据分析开源工具
Cube.js试试这个新的数据分析开源工具
======
Cube.js 是一个开源的分析平台,作为数据源和应用之间的一层。
![metrics and data shown on a computer screen][1]
数据分析是一个时髦的领域,有许多解决方案可供选择。其中之一是 [Cube.js][2],一个开源的分析平台。你可以把 Cube.js 看作是你的数据源和应用之间的一个层。
> Cube.js 是一个开源的分析平台,可以作为数据源和应用之间的中间层。
![](https://img.linux.net.cn/data/attachment/album/202106/24/114907z53fpzv6szv936vj.jpg)
数据分析是一个时髦的领域,有许多解决方案可供选择。其中之一是 [Cube.js][2],这是一个开源的分析平台。你可以把 Cube.js 看作是你的数据源和应用之间的一个中间层。
如下图所示Cube.js 支持无服务器数据仓库和大多数现代关系型数据库管理系统 RDBMS。你可以使用任何用于数据可视化的 JavaScript 前端库,而 Cube.js 将负责其他工作,包括访问控制、性能、并发性等。
![Cube.js architecture][3]
©2021, [Cube Dev, Inc.][2]
### 主要优点
当我向我们的社区成员询问 Cube.js 的主要优点时,他们经常提到:
* **它的抽象层**:配置 Cube.js 后人们说他们不再需要担心性能优化、资源管理、SQL 专业知识等问题。许多人把 Cube.js 称为 “黑盒”,因为它的抽象层帮助他们专注于理解数据,而不是实施细节。
* **易于定制**:由于 Cube.js 是可视化的,它很容易与前端框架集成,建立看起来像用户自己平台的解决方案。大多数商业平台(如 Looker、Tableau 等)需要更多的定制工作来与他们的基础设施整合。许多用户说,定制的便利性与抽象层相结合,使他们能够减少数据分析平台的开发时间。
* **社区支持**:在开始使用 Cube.js 时,人们通常会从社区成员那里得到帮助(特别是在我们的 [Slack][4]),许多人提到社区支持是一个关键的入门资源。
**它的抽象层:**配置 Cube.js 后人们说他们不再需要担心性能优化、资源管理、SQL 专业知识等问题。许多人把 Cube.js 称为 “黑盒”,因为它的抽象层帮助他们专注于理解数据,而不是实施细节。
**易于定制:**由于 Cube.js 是可视化的,它很容易与前端框架集成,建立看起来像用户自己平台的解决方案。大多数商业平台(如 Looker、Tableau 等)需要更多的定制工作来与他们的基础设施整合。许多用户说,定制的便利性与抽象层相结合,使他们能够减少数据分析平台的开发时间。
**社区支持:**在开始使用 Cube.js 时,人们通常会从社区成员那里得到帮助(特别是在我们的 [Slack][4]),许多人提到社区支持是一个关键的入门资源。
访问[用户故事页面][5],阅读更多关于人们使用 Cube.js 的经验以及他们如何使用它。
访问 [用户故事页面][5],阅读更多关于人们使用 Cube.js 的经验以及他们如何使用它。
### 开始使用
如果你想了解 Cube.js
* 进入我们的[文档页面][6],点击**开始**,并按照指示在你的笔记本电脑或工作站上启动和运行 Cube.js。
* 进入我们的 [文档页面][6],点击**开始**,并按照指示在你的笔记本电脑或工作站上启动和运行 Cube.js。
* 当你进入 [Developer Playground][7],你将能够生成数据模式,执行查询,并建立仪表盘,以看到 Cube.js 的运行。
在你启动和运行 Cube.js 之后,这里有一些有用的资源:
* [文档][6]:我们把大量的精力放在我们的文档上,因为它是开源社区的重要资源。我们还在我们的文档页面和 YouTube 频道的[入门播放列表][8]中添加了视频剪辑。
* [文档][6]:我们把大量的精力放在我们的文档上,因为它是开源社区的重要资源。我们还在我们的文档页面和 YouTube 频道的 [入门播放列表][8] 中添加了视频剪辑。
* [Discourse][9]Cube.js 论坛是最近增加的,社区成员可以在这里分享他们的使用案例、技巧和窍门等,这样我们就可以建立一个社区知识库。
* [GitHub][10]: 你可以在这里找到 Cube.js 的代码,社区成员可以通过[问题页面][11]提交错误或功能请求。我们还在 GitHub 上发布了我们的[季度路线图][12],以便每个人都能看到我们正在进行的工作。
* [每月社区电话会议][13]:我们在每个月的第二个星期三举行电话会议,讨论社区更新,展示功能演示,并邀请社区成员分享他们的使用案例。你可以在[社区电话会议页面][13]上找到电话会议的日程,你也可以在我们 YouTube 频道的[社区电话会议播放列表][14]上找到过去的电话会议录音。
* [GitHub][10]: 你可以在这里找到 Cube.js 的代码,社区成员可以通过 [问题页面][11] 提交错误或功能请求。我们还在 GitHub 上发布了我们的 [季度路线图][12],以便每个人都能看到我们正在进行的工作。
* [每月社区电话会议][13]:我们在每个月的第二个星期三举行电话会议,讨论社区更新,展示功能演示,并邀请社区成员分享他们的使用案例。你可以在 [社区电话会议页面][13] 上找到电话会议的日程,你也可以在我们 YouTube 频道的 [社区电话会议播放列表][14] 上找到过去的电话会议录音。
就像任何好的开源项目一样Cube.js 有许多软件贡献者。如果你想查看社区的拉取请求 PR请搜索带有 `pr:community` 标签的 PR。如果你想寻找你可以回答的问题请搜索带有 `good first issue` 或者 `help wanted` 标签的问题。
就像任何好的开源项目一样Cube.js 有许多软件贡献者。如果你想查看社区的拉取请求PR请搜索带有 `pr:community` 标签的 PR。如果你想寻找你可以回答的问题请搜索带有 `good first issue` 或者 `help wanted` 标签的问题。
我希望你试试 Cube.js。如果你有任何问题请随时在下面留言或在 [Cube.js Slack][4] 上找我!
@ -62,7 +55,7 @@ via: https://opensource.com/article/21/6/cubejs
作者:[Ray Paik][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -3,60 +3,60 @@
[#]: author: (Miguel Perez Colino https://opensource.com/users/mperezco)
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-13520-1.html)
这个新工具将虚拟机迁移到 Kubernetes 上
Forklift 将虚拟机迁移到 Kubernetes 上
======
用 Forklift 将你的虚拟化工作负载过渡到 Kubernetes。
![Containers on a ship on the ocean][1]
2017 年,[KubeVirt][2] 团队[发起][3]了一个在 [Kubernetes][4] 中与容器一起管理虚拟机 VM 的项目。这个开源项目的意图是让虚拟机成为这个环境中的一等公民
> 用 Forklift 将你的虚拟化工作负载过渡到 Kubernetes。
自从在 [2018 年开源峰会][5]上推出以来KubeVirt 一直在不断成熟和发展。它在 GitHub 上已经达到了 200 多颗星,甚至在 2021 年 2 月推出了自己的活动:[KubeVirt 峰会][6]。
![](https://img.linux.net.cn/data/attachment/album/202106/25/113010mxhtznxjhxf1glz7.jpg)
2017 年,[KubeVirt][2] 团队 [发起][3] 了一个在 [Kubernetes][4] 中管理容器及相关的虚拟机VM的项目。这个开源项目的意图是让虚拟机成为这个环境中的一等公民。
自从在 [2018 年开源峰会][5] 上推出以来KubeVirt 一直在不断成熟和发展。它在 GitHub 上已经达到了 200 多颗星,甚至在 2021 年 2 月推出了自己的活动:[KubeVirt 峰会][6]。
![KubeVirt architecture][7]
KubeVirt架构© 2020,[Red Hat OpenShift][8]
*KubeVirt 架构(© 2020,[Red Hat OpenShift][8]*
KubeVirt 是 [OpenShift 虚拟化][9]的基础,它帮助开发者将虚拟机带入容器化工作流程。
KubeVirt 是 [OpenShift 虚拟化][9] 的基础,它帮助开发者将虚拟机带入容器化工作流程。
### 在 Kubernetes 中使用虚拟机
KubeVirt 使你能够在虚拟机上原生使用 Kubernetes。这意味着它们可以连接到使用标准 Kubernetes 方法访问的 pod 网络,包括服务、路由、管道等。应用于虚拟机 pod 的网络策略与应用于应用的 pod 方式相同,它提供一个一致的模型来管理虚拟机到 pod (反之亦然)的通信。
KubeVirt 使你能够在虚拟机上原生使用 Kubernetes。这意味着它们可以连接到使用标准 Kubernetes 方法(如服务、路由、管道等)访问的<ruby>吊舱<rt>Pod</rt></ruby>网络。应用于虚拟机吊舱的网络策略与应用于应用吊舱的方式相同,它提供一个一致的模型来管理虚拟机到吊舱(或反之)的通信。
这方面的一个真实例子是一家航空公司利用旧的模拟器软件的方式。它注入了人工智能和机器学习 AI/ML 的模型,然后在基于虚拟机的模拟器上自动部署和测试它们。这使得它能够使用 Kubernetes 和 [Kubeflow][10] 完全自动化地获得测试结果和新的遥测训练数据。
![VM-creation workflow][11]
Konveyor, [CC BY-SA 4.0][12]
*Konveyor, [CC BY-SA 4.0][12]*
[Konveyor.io][13] 是一个开源项目,帮助现有工作负载(开发、测试和生产)过渡到 Kubernetes。其工具包括 [Crane][14]将容器从一个 Kubernetes 平台转移到另一个平台、[Move2Kube][15],将工作负载从 Cloud Foundry 带到 Kubernetes以及 [Tackle][16],分析 Java 应用,使其对 Kubernetes 等容器化平台中的运行时更加标准和便携,从而使其现代化
[Konveyor.io][13] 是一个开源项目,帮助现有工作负载(开发、测试和生产)过渡到 Kubernetes。其工具包括将容器从一个 Kubernetes 平台转移到另一个平台的 [Crane][14];将工作负载从 Cloud Foundry 带到 Kubernetes的 [Move2Kube][15];以及分析 Java 应用,使其对 Kubernetes 等容器化平台中的运行时更加标准和可移植,从而使其现代化的 [Tackle][16]
这些工具在转化模式中很有用,但许多项目希望在早期阶段利用 Kubernetes以变得更加敏捷和富有成效。在基础设施方面这些好处可能包括蓝/绿负载均衡、路由管理、声明式部署,或(取决于你的部署方式)由于不可变的基础设施而更容易升级。在开发方面,它们可能包括将持续集成/持续开发 CI/CD 管道与平台整合,使应用更快地投入生产,自我提供资源,或整合健康检查和监控。
KubeVirt 可以通过在 Kubernetes 环境中作为虚拟机运行工作负载来帮助你。它能让你的工作负载迅速使用 Kubernetes享受它的好处并随着时间的推移稳步实现工作负载的现代化。但是仍然有一个问题,就是把你的虚拟机从传统的虚拟化平台带到现代的 Kubernetes 平台。这就是 Konveyor 的 [Forklift][17] 项目的意义所在。
KubeVirt 可以通过在 Kubernetes 环境中以虚拟机来运行工作负载帮助你。它能让你的工作负载迅速使用 Kubernetes享受它的好处并随着时间的推移稳步实现工作负载的现代化。但是仍然有一个问题就是把你的虚拟机从传统的虚拟化平台带到现代的 Kubernetes 平台。这就是 Konveyor 的 [Forklift][17] 项目的意义所在。
### 关于 Forklift
Forklift 使用 KubeVirt 将不同来源的虚拟化工作负载迁移到 Kubernetes。它被设计成使任务变得简单,以便你可以从一两台机器到数百台机器迁移任何东西。
Forklift 使用 KubeVirt 将不同来源的虚拟化工作负载迁移到 Kubernetes。它的设计目标是使任务变得简单,以便你可以从一两台机器到数百台机器迁移任何东西。
迁移是一个简单的、三阶段的过程:
1. 连接到一个现有的虚拟化平台(称为“源提供者”)和一个 Kubernetes 环境(“目标提供者”)。
2. 将网络和存储资源从源提供者映射到目标提供者,在两者中寻找相同的资源。
2. 将网络和存储资源从源提供者映射到目标提供者,在两者中寻找等价的资源。
3. 选择要迁移的虚拟机,分配网络和存储映射,制定迁移计划。然后运行它。
### 如何开始
要开始使用 Forklift首先你需要一个兼容的源提供商。你还需要一个带有 KubeVirt 0.40 或更新版本的 Kubernetes 环境和裸机节点(尽管为了测试,你可以使用嵌套虚拟化)。用读-写-执行 RWX 功能配置你的存储类,并使用 [Multus][18] 配置你的网络,以匹配你的虚拟机在源提供者中使用的网络。(如果你不能这样做,也不用担心。你也可以选择重新分配 IP 地址。)
最后,使用提供的操作在你的 Kubernetes 上[安装 Forklift][19],并进入用户界面,开始运行你的第一次测试迁移。
最后,使用提供的操作在你的 Kubernetes 上[安装 Forklift][19],并进入用户界面,开始运行你的第一次测试迁移。
Forklift 是 Red Hat 的[虚拟化迁移工具套件][20]的上游版本。因此,如果你想在生产环境中使用它,你可以考虑使用该工具的支持版本。
Forklift 是 Red Hat 的 [虚拟化迁移工具套件][20] 的上游版本。因此,如果你想在生产环境中使用它,你可以考虑使用该工具的支持版本。
迁移愉快!
@ -67,7 +67,7 @@ via: https://opensource.com/article/21/6/migrate-vms-kubernetes-forklift
作者:[Miguel Perez Colino][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -0,0 +1,220 @@
[#]: subject: (Systemd Timers for Scheduling Tasks)
[#]: via: (https://fedoramagazine.org/systemd-timers-for-scheduling-tasks/)
[#]: author: (Richard England https://fedoramagazine.org/author/rlengland/)
[#]: collector: (lujun9972)
[#]: translator: (dcoliversun)
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-13522-1.html)
用于调度任务的 systemd 定时器
======
![](https://img.linux.net.cn/data/attachment/album/202106/25/175650j4wrdw0z884iod80.jpg )
systemd 提供定时器有一段时间了,定时器替代了 cron 功能,这一特性值得看看。本文将向你介绍在系统启动后如何使用 systemd 中的定时器来运行任务,并在此后重复运行。这不是对 systemd 的全面讨论,只是对此特性的一个介绍。
### 快速回顾cron、anacron 与 systemd
cron 可以以几分钟到几个月或更长时间的粒度调度运行一个任务。设置起来相对简单,它只需要一个配置文件。虽然配置过程有些深奥,但一般用户也可以使用。
然而,如果你的系统在需要执行的时间没有运行,那么 cron 会失败。
anacron 克服了“系统没有运行”的问题。它确保任务将在你的系统再次启动时执行。虽然它旨在给管理员使用,但有些系统允许普通用户访问 anacron。
但是anacron 的执行频率不能低于每天一次。
cron 和 anacron 都存在执行上下文一致性的问题。必须注意任务运行时有效的环境与测试时使用的环境完全相同。必须提供相同的 shell、环境变量和路径。这意味着测试和调试有时会很困难。
systemd 定时器提供了 cron 和 anacron 二者的优点,允许调度到分钟粒度。确保在系统再次运行时执行任务,即使在预期的执行时间内系统处于关闭状态。它对所有用户都可用。你可以在它将要运行的环境中测试和调试执行。
但是,它的配置更加复杂,至少需要两个配置文件。
如果你的 cron 和 anacron 配置可以很好地为你服务,那么可能没有理由改变。但是 systemd 至少值得研究,因为它可以简化任何当前的 cron/anacron 工作方式。
### 配置
systemd 定时器执行功能至少需要两个文件。这两个是“<ruby>定时器单元<rt>timer unit</rt></ruby>”和“<ruby>服务单元<rt>service unit</rt></ruby>”。(其执行的)“动作”不仅仅是简单的命令,你还需要一个“作业”文件或脚本来执行必要的功能。
定时器单元文件定义调度表,而服务单元文件定义执行的任务。有关的更多详细信息请参考 `man systemd.timer` 中提供的 .timer 单元。服务单元的详细信息可在 `man systemd.service` 中找到。
单元文件存放在几个位置(在手册页中有列出)。然而,对于普通用户来说,最容易找到的位置可能是 `~/.config/systemd/user`。请注意,这里的 `user` 是字符串 `user`
### 示例
此示例是一个创建用户调度作业而不是(以 root 用户身份运行的)系统调度作业的简单示例。它将消息、日期和时间打印到文件中。
1、首先创建一个执行任务的 shell 脚本。在你的本地 `bin` 目录中创建它,例如在 `~/bin/schedule-test.sh` 中。
创建文件:
```
touch ~/bin/schedule-test.sh
```
然后将以下内容添加到你刚刚创建的文件中:
```
#!/bin/sh
echo "This is only a test: $(date)" >> "$HOME/schedule-test-output.txt"
```
记住赋予你的 shell 脚本执行权限。
2、创建 .service 单元调用上面的脚本。在以下位置创建目录与文件:`~/.config/systemd/user/schedule-test.service`
```
[Unit]
Description=A job to test the systemd scheduler
[Service]
Type=simple
ExecStart=/home/<user>/bin/schedule-test.sh
[Install]
WantedBy=default.target
```
请注意 `<user>` 应该是你的家目录地址,但是单元文件路径名中的 `user` 实际上是字符串 `user`
`ExecStart` 应该提供一个没有变量的绝对地址。例外情况是,对于用户单元文件,你可以用 `%h` 替换 `$HOME`。换句话说,你可以使用:
```
ExecStart=%h/bin/schedule-test.sh
```
这仅用于用户单元文件,而不适用于系统服务,因为在系统环境中运行时 `%h` 总是返回 `/root`。其他特殊符号可在 `man systemd.unit``SPECIFIERS` 中找到。因为它超出了本文的范围,所以这就是我们目前需要了解的关于特殊符号的全部内容。
3、创建一个 .timer 单元文件,该文件实际上调度你创建的 .service 单元文件。在 .service 单元文件相同位置创建它:`~/.config/systemd/user/schedule-test.timer`。请注意,文件名仅在扩展名上有所不同,例如一个是 `.service`,一个是 `.timer`
```
[Unit]
Description=Schedule a message every 1 minute
RefuseManualStart=no # Allow manual starts
RefuseManualStop=no # Allow manual stops
[Timer]
#Execute job if it missed a run due to machine being off
Persistent=true
#Run 120 seconds after boot for the first time
OnBootSec=120
#Run every 1 minute thereafter
OnUnitActiveSec=60
#File describing job to execute
Unit=schedule-test.service
[Install]
WantedBy=timers.target
```
请注意,这个 .timer 单元文件使用了 `OnUnitActiveSec` 来指定调度表。`OnCalendar` 选项更加灵活。例如:
```
# run on the minute of every minute every hour of every day
OnCalendar=*-*-* *:*:00
# run on the hour of every hour of every day
OnCalendar=*-*-* *:00:00
# run every day
OnCalendar=*-*-* 00:00:00
# run 11:12:13 of the first or fifth day of any month of the year
# 2012, but only if that day is a Thursday or Friday
OnCalendar=Thu,Fri 2012-*-1,5 11:12:13
```
有关 `OnCalendar` 的更多信息参见 [这里][2]。
4、所有的部件都已就位但你应该进行测试以确保一切正常。首先启用该用户服务:
```
$ systemctl --user enable schedule-test.service
```
这将导致类似如下的输出:
```
Created symlink /home/<user>/.config/systemd/user/default.target.wants/schedule-test.service → /home/<user>/.config/systemd/user/schedule-test.service.
```
现在执行测试工作:
```
$ systemctl --user start schedule-test.service
```
检查你的输出文件(`$HOME/schedule-test-output.txt`),确保你的脚本运行正常。应该只有一个条目,因为我们还没有启动定时器。必要时进行调试。如果你需要更改 .service 单元文件,而不是更改它调用的 shell 脚本,请不要忘记再次启用该服务。
5、一旦作业正常运行通过为服务启用、启动用户定时器来实时调度作业
```
$ systemctl --user enable schedule-test.timer
$ systemctl --user start schedule-test.timer
```
请注意,你已经在上面的步骤 4 中启动、启用了服务,因此只需要为它启用、启动定时器。
`enable` 命令会产生如下输出:
```
Created symlink /home/<user>/.config/systemd/user/timers.target.wants/schedule-test.timer → /home/<user>/.config/systemd/user/schedule-test.timer.
```
`start` 命令将只是返回命令行界面提示符。
### 其他操作
你可以检查和监控服务。如果你从系统服务收到错误,下面的第一个命令特别有用:
```
$ systemctl --user status schedule-test
$ systemctl --user list-unit-files
```
手动停止服务:
```
$ systemctl --user stop schedule-test.service
```
永久停止并禁用定时器和服务,重新加载守护程序配置并重置任何失败通知:
```
$ systemctl --user stop schedule-test.timer
$ systemctl --user disable schedule-test.timer
$ systemctl --user stop schedule-test.service
$ systemctl --user disable schedule-test.service
$ systemctl --user daemon-reload
$ systemctl --user reset-failed
```
### 总结
本文以 systemd 定时器为出发点,但是 systemd 的内容远不止于此。这篇文章应该为你提供一个基础。你可以从 [Fedora Magazine systemd 系列][3] 开始探索更多。
### 参考
更多阅读:
* `man systemd.timer`
* `man systemd.service`
* [Use systemd timers instead of cronjobs][4]
* [Understanding and administering systemd][5]
* <https://opensource.com/> 内有 systemd 速查表
--------------------------------------------------------------------------------
via: https://fedoramagazine.org/systemd-timers-for-scheduling-tasks/
作者:[Richard England][a]
选题:[lujun9972][b]
译者:[dcoliversun](https://github.com/dcoliversun)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://fedoramagazine.org/author/rlengland/
[b]: https://github.com/lujun9972
[1]: https://fedoramagazine.org/wp-content/uploads/2021/06/schedule_withsystemdtimer-816x345.jpg
[2]: https://www.freedesktop.org/software/systemd/man/systemd.time.html#Calendar%20Events
[3]: https://fedoramagazine.org/what-is-an-init-system/
[4]: https://opensource.com/article/20/7/systemd-timers
[5]: https://docs.fedoraproject.org/en-US/quick-docs/understanding-and-administering-systemd/

View File

@ -0,0 +1,128 @@
[#]: subject: "Heres Why Switching to Linux Makes Sense in 2021"
[#]: via: "https://news.itsfoss.com/switch-to-linux-in-2021/"
[#]: author: "Ankush Das https://news.itsfoss.com/author/ankush/"
[#]: collector: "lujun9972"
[#]: translator: "zepoch"
[#]: reviewer: "wxy"
[#]: publisher: "wxy"
[#]: url: "https://linux.cn/article-13519-1.html"
为什么在 2021 年我仍然推荐你使用 Linux
======
![](https://i1.wp.com/news.itsfoss.com/wp-content/uploads/2021/05/linux-2021.png?w=1200&ssl=1)
在某些领域Linux 确实要比 Windows 和 macOS 更加优秀。人们正在意识到这一点,而且 Linux 也在桌面操作系统市场上变得愈发流行。
当然,目前大多数桌面操作系统用户仍然对 Windows 或者 macOS 推崇备至,但是也有着越来越多的用户开始尝试新的 Linux 发行版,看看他们是否可以从原来的系统切换到 Linux 系统。
他们可能已经听过 [用 Linux 作为桌面操作系统](https://news.itsfoss.com/linux-foundation-linux-desktop/) 的一些优秀案例,又或者是仅仅想要去尝试一些与原先不同的事物,谁知道呢?
在这里,我将为你解释为什么在 2021 年我仍然推荐你使用 Linux。
### Linux 真棒,但是究竟是什么让其在 2021 年值得推荐呢?
如果已经知道了 [使用 Linux 的优点](https://itsfoss.com/reasons-switch-linux-windows-xp/),你可能就知道接下来我会说些什么。
#### 1、你不需要购买许可证
![][3]
你必须付费才能获得 Windows 10 许可证。
虽然有更便宜的选择,如获得 OEM 密钥。但是,如果你不愿意通过一些地下网站,而是从官方网站获得许可证,那么仅授权使用 1 台 PC 的**家庭版**就至少需要花费 **140 美元**
当然macOS 是一个完全不同的模式(你需要购买先进的硬件才能使用 macOS——所以我们才会一直使用微软的 Windows。
关键是,在失业的浪潮中,配置一台新电脑是一个挑战。此外,你还需要花钱购买操作系统的许可证,但是你却可以在多台计算机上免费使用 Linux。
是的,你不需要为 Linux 获取许可证密钥。你可以轻松下载 [Linux 发行版][4],并根据需要将其安装在尽可能多的设备上。
不要担心,如果你不了解 Linux 发行版,你可以看看我们的 [最好的 Linux 发行版](https://itsfoss.com/best-linux-distributions/) 列表。
#### 2、重新唤醒你的 PC 并节省资金
[全球芯片短缺](https://www.cnbc.com/2021/05/12/the-global-chip-shortage-could-last-until-2023-.html) 已经严重影响了电脑组件的价格,特别是**显卡**。并不是简单的价格上升,而是你不得不支付 **2 到 5 倍**的零售价来购得显卡。
当然,如果你没有电脑,现在配置一个新的电脑可能是难以置信的挑战,但如果你有一个旧电脑的话,选择在上面运行 Windows 10 将会是十分卡顿的。
如果你不想要 Windows 系统,那 macOS 呢?入门级 Mac 系统将会花费至少 **1100** 美金,甚至更多,这取决于你住在哪里。对许多人来说,这会是一笔昂贵的开销。
你肯定需要升级你的系统 —— 但是如果我说 Linux 可以让你的旧电脑重新派上用场,能为你省钱呢?
你将能够在你认为无法运行最新版本的微软 Windows 的电脑上运行 Linux。是的就是这样的。
Linux 是一个资源高效型的操作系统,可在各种较旧的系统配置上运行。
所有你需要做的只是参考我们的列表 [轻量级 Linux 发行版][7],并选择一个你喜欢的。
#### 3、通过再次利用系统来减少电子浪费
![][8]
考虑到电子废物正在全球不断产生,尤其是由加密矿工产生的,我们可以尽量减少浪费。除非你真正需要新的硬件,否则最好将现有硬件设备重新用于新任务。
而且,多亏了 Linux你可以将旧电脑或单片机转变成媒体服务器或个人 [Nextcloud][9] 服务器。
你可以在现有硬件上使用 Linux 做更多工作。
因此,这将显著降低对新硬件的需求,并让你高效地重复使用现有的设备。
#### 4、远离病毒和恶意软件
![][10]
在远程工作无处不在的时代,病毒和恶意软件显著增加。因此,即使你想平静地工作,你最终也可能受到恶意软件的影响。
Windows 和 macOS 比以往任何时候都更容易受到恶意软件的影响。但是,对于 Linux这是不太可能的。
Linux 发行版会定期修补,以确保最佳安全性。
此外,正因为用户群体小,攻击者就不会花太多时间制作欺骗 Linux 用户的病毒或软件。因此,在使用 Linux 时遇到某种形式的恶意软件的机会较小。
#### 5、没有强制更新
![][11]
在一个人们压力倍增的时代,强制更新然后发现计算机无法启动可能是一大烦恼。
至少Windows 用户的情况就是这样。
但是,使用 Linux你可以继续使用你的系统而无需在后台强制下载任何更新。
你的操作系统只有你能决定。
当你想要更新你的 Linux 发行版本时,你可以选择更新,也可以不更新,它可以一直保持不更新的状态并且不会打扰你,除非你有很长一段时间没有更新。
### 总结
这些只是我能想到的几个原因之一Linux 作为操作系统的选择在 2021 年比以往任何时候都更值得被推荐。
当然,这也取决于你的要求,这些好处可能不会体现在在你的用例中。但是,如果你确实不了解 Linux至少现在你可以评估你的需求重新作出选择。
除了上述几点之外,你还能想到什么?请在下面的评论中告诉我。
--------------------------------------------------------------------------------
via: https://news.itsfoss.com/switch-to-linux-in-2021/
作者:[Ankush Das][a]
选题:[lujun9972][b]
译者:[zepoch](https://github.com/zepoch)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://news.itsfoss.com/author/ankush/
[b]: https://github.com/lujun9972
[1]: https://news.itsfoss.com/linux-foundation-linux-desktop/
[2]: https://itsfoss.com/reasons-switch-linux-windows-xp/
[3]: https://i0.wp.com/news.itsfoss.com/wp-content/uploads/2021/06/license-agreement.jpg?w=1000&ssl=1
[4]: https://itsfoss.com/what-is-linux-distribution/
[5]: https://itsfoss.com/best-linux-distributions/
[6]: https://www.cnbc.com/2021/05/12/the-global-chip-shortage-could-last-until-2023-.html
[7]: https://itsfoss.com/lightweight-linux-beginners/
[8]: https://i2.wp.com/news.itsfoss.com/wp-content/uploads/2021/05/e-waste-illustration.jpg?w=800&ssl=1
[9]: https://itsfoss.com/nextcloud/
[10]: https://i2.wp.com/news.itsfoss.com/wp-content/uploads/2021/05/system-malware.jpg?w=800&ssl=1
[11]: https://i0.wp.com/news.itsfoss.com/wp-content/uploads/2021/05/linux-system-update.jpg?w=800&ssl=1

View File

@ -0,0 +1,137 @@
[#]: subject: (Replace find with fd on Linux)
[#]: via: (https://opensource.com/article/21/6/fd-linux)
[#]: author: (Sudeshna Sur https://opensource.com/users/sudeshna-sur)
[#]: collector: (lujun9972)
[#]: translator: (wxy)
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-13516-1.html)
在 Linux 上用 fd 代替 find
======
> fd 命令是一个流行的、用户友好的 find 命令的替代品。
![](https://img.linux.net.cn/data/attachment/album/202106/24/110546npqmttwobtqpo4qk.jpg)
许多 Linux 程序员在其工作中每天都在使用 `find` 命令。但是 `find` 给出的文件系统条目是有限的,如果你要进行大量的 `find` 操作,它甚至不是很快速。因此,我更喜欢使用 Rust 编写的 `fd` 命令,因为它提供了合理的默认值,适用于大多数使用情况。
正如它的 [README][2] 所说,“`fd` 是一个在文件系统中寻找条目的程序。它是一个简单、快速和用户友好的 `find` 的替代品。”它的特点是目录的并行遍历可以一次搜索多个目录。它支持正则表达式regex和基于通配符的模式。
### 安装 fd
在 Linux 上,你可以从你的软件库中安装 `fd`(可用的软件包列表可以在 [Repology 上的 fd 页面][3] 找到)。 例如,在 Fedora 上:
```
$ sudo dnf install fd-find
```
在 macOS 上,可以使用 [MacPorts][4] 或 [Homebrew][5]。
另外,你也可以使用 Rust 的 Cargo 软件包管理器:
```
$ cargo install fd-find
```
### 使用 fd
要做一个简单的搜索,运行 `fd` 并在后面跟上要搜索的名字,例如:
```
$ fd sh
registry/src/github.com-1ecc6299db9ec823/cc-1.0.67/src/bin/gcc-shim.rs
registry/src/github.com-1ecc6299db9ec823/exa-0.10.1/completions/completions.bash
registry/src/github.com-1ecc6299db9ec823/exa-0.10.1/completions/completions.fish
registry/src/github.com-1ecc6299db9ec823/exa-0.10.1/completions/completions.zsh
registry/src/github.com-1ecc6299db9ec823/exa-0.10.1/xtests/run.sh
registry/src/github.com-1ecc6299db9ec823/git2-0.13.18/src/stash.rs
registry/src/github.com-1ecc6299db9ec823/libc-0.2.94/src/unix/solarish
registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.12.19+1.1.0/libgit2/cmake/SelectHashes.cmake
registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.12.19+1.1.0/libgit2/include/git2/stash.h
registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.12.19+1.1.0/libgit2/include/git2/sys/hashsig.h
registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.12.19+1.1.0/libgit2/script/backport.sh
registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.12.19+1.1.0/libgit2/script/leaks.sh
registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.12.19+1.1.0/libgit2/script/valgrind.sh
registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.12.19+1.1.0/libgit2/src/config_snapshot.c
[...]
```
如果你想搜索一个特定的目录,可以将目录路径作为 `fd` 的第二个参数,例如:
```
$ fd passwd /etc
/etc/pam.d/passwd
/etc/passwd
/etc/passwd-
/etc/security/opasswd
```
要搜索一个特定的文件扩展名,使用 `-e` 作为选项。例如:
```
$ fd . '/home/ssur/exa' -e md
/home/ssur/exa/README.md
/home/ssur/exa/devtools/README.md
/home/ssur/exa/man/exa.1.md
/home/ssur/exa/man/exa_colors.5.md
/home/ssur/exa/xtests/README.md
$
```
你也可以通过提供 `-x``-X` 来执行一个命令。
* `-x`/`--exec`:选项为每个搜索结果(并行)运行一个外部命令。
* `-X`/`--exec-batch`:选项将所有搜索结果作为参数启动一次外部命令。
例如,要递归地找到所有的 ZIP 档案并解压:
```
$ fd -e zip -x unzip
```
或者,要列出某个特定目录下在过去 _n_ 天内改变的所有文件,使用`--changed-within` 选项:
```
$ fd . '/home/ssur/Work/' --changed-within 10d
/home/ssur/Work/wildfly/connector/src/main/java/org/jboss/as/connector/subsystems/data_sources/JdbcDriverAdd.java
/home/ssur/Work/wildfly/connector/src/main/java/org/jboss/as/connector/subsystems/data_sources/JdbcExample.java
[...]
```
而要搜索所有在特定天数之前被修改的文件,请使用 `--changed-before` _n_ 选项:
```
$ fd . '/home/ssur/Work/' --changed-before 365d
```
这里,`.` 作为一个(正则)通配符,指示 `fd` 返回所有文件。
要了解更多关于 `fd` 的功能,请查阅 GitHub 上的 [文档][2]。
### 总结
我特别喜欢 `fd` 的一点是,搜索模式默认是不区分大小写的,这使得它更容易找到东西,即使你对你要找的东西没有精确的认识。更好的是,如果模式包含一个大写的字符,它就会*自动*切换到大小写敏感。
另一个好处是,它使用颜色编码来突出不同的文件类型。
如果你已经在使用这个神奇的 Rust 工具,请在评论中告诉我们你的想法。
--------------------------------------------------------------------------------
via: https://opensource.com/article/21/6/fd-linux
作者:[Sudeshna Sur][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://opensource.com/users/sudeshna-sur
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/find-file-linux-code_magnifying_glass_zero.png?itok=E2HoPDg0 (Magnifying glass on code)
[2]: https://github.com/sharkdp/fd
[3]: https://repology.org/project/fd-find/versions
[4]: https://opensource.com/article/20/11/macports
[5]: https://opensource.com/article/20/6/homebrew-mac

View File

@ -0,0 +1,114 @@
[#]: subject: (Windows 11 Makes Your Hardware Obsolete, Use Linux Instead!)
[#]: via: (https://news.itsfoss.com/windows-11-linux/)
[#]: author: (Ankush Das https://news.itsfoss.com/author/ankush/)
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
Windows 11 Makes Your Hardware Obsolete, Use Linux Instead!
======
Windows 11 is finally here. Were not entirely thrilled by it but it introduces problems for many computer users.
And Im not even talking the privacy aspect or its design choice. But it seems that Windows 11 is demanding newer hardware to work, which makes your old computer obsolete in a way and forces you to upgrade your hardware for no good reason.
What else is a problem with the arrival of Windows 11? Whats so bad about it?
### Only Eligible Devices Can Get the Windows 11 Upgrade
To start with, Windows 11 has interestingly added a minimum system requirement which looks good on paper:
* 1 GHz dual-core 64-bit processor
* 4 GB RAM
* 64 GB storage
* UEFI, Secure Boot support
* Trusted Platform Module version 2.0
* DirectX 12 compatible graphics
* 720p resolution display
![][1]
You can check if your system is eligible by downloading the **PC Health Check** app from [Microsofts official site][2].
Most of the computers from the last decade should meet these criteria but theres a catch.
The hardware should have a TPM chip, which may not be the case for some PC builds or laptops. Fortunately, it is not all bad, you may just need to enable it from your BIOS settings including the Secure Boot support, to make your PC eligible. Theres a guide on [PCGamer][3] to help you with that.
Technically, processors older than **Intel 8th gen and Ryzen 3000 series** are not officially supported as per Microsofts official documentations ([AMD][4] | [Intel][5]).
However, there are a sound number of systems that may not have the support for it. So, what do you do?
Easy, [**switch to Linux in 2021**][6] before Windows 10 no longer receives updates. This year, it makes more sense than ever for you to try Linux for your personal computer!
### Windows 11 Installation Requires Internet Connectivity
![][7]
While we do not have enough clarity about this but as per its system requirement specifications, it will require users to have an active Internet connection for Windows 11 installation.
But, with Linux, you do not need that.
Thats just one of the [benefits of using Linux over Windows][8] you get complete control of your operating system.
### No 32-Bit Support
![][7]
Windows 10 did support 32-bit systems, but Windows 11 ends that.
This is where Linux shines.
Even though the 32-bit support is dwindling everywhere, we still have a bunch of [**Linux distributions that support 32-bit systems**][9]. Your 32-bit system may still live for a decade with Linux.
### Windows 10 Support Ends in 2025
Well, this was unexpected considering Microsoft initially planned to never have an upgrade after Windows 10 but support it for the foreseeable future.
Now, Windows 10 will be killed in 2025…
So, what do you do then? Upgrade your hardware just because it does not support Windows 11?
Unless theres a necessity, Linux is your friend forever.
You can try several [**lightweight Linux distributions**][10] that will revive any of your computers that Microsoft considers obsolete!
### Wrapping Up
While Windows 11 plans to force users to upgrade their hardware in the next few years, Linux lets you keep your hardware for a long time along with several added benefits.
So, if you are not happy with Windows 11 release, you may want to start using Linux instead. Fret not, you can refer to our guides on our main web portal [Its FOSS][11] to learn everything you need to get started using Linux!
#### Big Tech Websites Get Millions in Revenue, It's FOSS Got You!
If you like what we do here at It's FOSS, please consider making a donation to support our independent publication. Your support will help us keep publishing content focusing on desktop Linux and open source software.
I'm not interested
--------------------------------------------------------------------------------
via: https://news.itsfoss.com/windows-11-linux/
作者:[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://news.itsfoss.com/author/ankush/
[b]: https://github.com/lujun9972
[1]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjIyNSIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4=
[2]: https://www.microsoft.com/en-us/windows/windows-11
[3]: https://www.pcgamer.com/Windows-11-PC-Health-Check/
[4]: https://docs.microsoft.com/en-us/windows-hardware/design/minimum/supported/windows-11-supported-amd-processors
[5]: https://docs.microsoft.com/en-us/windows-hardware/design/minimum/supported/windows-11-supported-intel-processors
[6]: https://news.itsfoss.com/switch-to-linux-in-2021/
[7]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjQzOSIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4=
[8]: https://itsfoss.com/linux-better-than-windows/
[9]: https://itsfoss.com/32-bit-linux-distributions/
[10]: https://itsfoss.com/lightweight-linux-beginners/
[11]: https://itsfoss.com

View File

@ -2,7 +2,7 @@
[#]: via: (https://opensource.com/article/21/6/home-automation-ebook)
[#]: author: (Alan Smithee https://opensource.com/users/alansmithee)
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: translator: (zepoch)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )

View File

@ -0,0 +1,65 @@
[#]: subject: (How the Apache Software Foundation selects open source projects)
[#]: via: (https://opensource.com/article/21/6/apache-software-foundation)
[#]: author: (Justin Mclean https://opensource.com/users/justin-mclean)
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
How the Apache Software Foundation selects open source projects
======
The Apache Software Foundation (ASF) is built around a unique set of
processes and values to ensure openness.
![Wide open sky and trees][1]
As a longtime volunteer and mentor (and current board member) at the [Apache Software Foundation][2] (ASF) and vice president of the Apache Incubator, I'm proud to offer my insights into the unique processes and values with which the ASF operates.
Centered upon the permissive and pragmatic open source [Apache License][3], the ASF conducts itself differently from many other foundations simply because it is a charitable organization constructed for the public good. For example, the ASF board is elected by members. No one can buy a seat on the board, and the ASF's affiliations are with individuals, not companies. Generally, the corporate affiliation of any individual involved with ASF goes unstated, and it doesn't matter. As an outcome, the ASF has fostered a vendor-neutral environment where companies can comfortably collaborate on building valuable projects.
Let's take a look at how the ASF selects its projects, the state of open source licensing today, and what you can expect from the ASF heading into the future.
### The Apache Incubator process and 'The Apache Way'
Potential Apache projects begin in the [Apache Incubator][4], where they receive assistance and mentoring toward their hopeful graduation as top-level Apache projects. Anyone is welcome to put together a project proposal for the Incubator (they simply need to find someone inside the ASF who's willing to help champion it). When vetting a potential project, the ASF prefers to see a diversity of people and entities involved—and certainly not just a singular corporate body. We've found this greater diversity results in projects that are more widely used and longer lasting.
The central purpose of the Incubator is to help projects learn and operate in alignment with what we call [The Apache Way][5]. It is a set of values that inform best practices for community-led development. The most important aspects of The Apache Way include strict vendor-neutral independence and prioritization of a strong community, even over the strength of a project's code. Open and transparent communication is crucial as well: The ASF requires that all project communication is publicly accessible and permanently archived to enable asynchronous collaboration. In addition, the open source Apache License is attached to all accepted projects, ensuring that all source code is publicly available as well.
At the Incubator, we initially look at whether a project is a good fit in terms of how it aligns with these Apache values. It isn't necessary to have 100% alignment, but the project needs to be willing to adapt. There will also be a discussion around ensuring that the project is fully compatible with Apache from a licensing perspective—in some scenarios, dependencies will be removed or replaced as needed. The Apache Way prepares projects to build communities that are self-sustaining. That said, it can be difficult for some projects to build a community, and some don't make it through the incubator.
Another key element of The Apache Way—one essential to thriving communities—is making decisions based on consensus. In our experience, open discussions and avoiding a single individual project leader are mission-critical to that process. We have had a couple of incubating projects that included a strong personality trying to retain control, and well, those projects didn't succeed for that reason.
### Open source and the Apache License
Open source projects come in many varieties. At the same time, using an open source license doesn't automatically make a project open source. It's a project's community that unlocks open source benefits and whose contributions precipitate greater openness and transparency.
Recently, some companies have made high-profile moves away from the Apache License to less-permissive licensing. If your company changes from an open source to a non-open source license, I have to question why you had that open source license in the first place. It probably meant that the business model didn't fit open source. I believe that by changing away from open source licenses, companies are doing a huge disservice to their communities and their users.
As I said, the ASF is a non-profit, charitable organization that creates software for the public good. That's the purpose of the permissive Apache License. Making money off that software is fine, but that's not what the Apache License is about. As a rule, ASF disallows any field-of-use restrictions. _Anyone_ can use Apache projects for any reason. The idea behind true open source is that some people who use a project will give back to it, but contributions absolutely cannot be required. The companies that seem so hung up on that point need to understand that isn't how open source works, and that isn't how it should work.
### The future of open source and the ASF
Open source has certainly seen outsized adoption in the last five to 10 years and particular acceleration among enterprises. I think it's safe to say that there's hardly any software on the planet that doesn't include or rely upon open source projects in some way. That adoption is only going to grow.
Unlike some foundations, the ASF is fairly hands-off in terms of project recruitment. Expect the ASF to continue as it has, stating the values of The Apache Way and working with those projects that see value in the ASF's approach. With ASF projects leading at the forefront of major industry shifts—initially with web servers and more recently with big data through projects like Apache Hadoop and Spark, Cassandra, and Kafka—the hands-off stance has shown to be successful and sustainable.
When it comes to what's next, the ASF has several large and buzzed-about artificial intelligence and machine learning projects. In addition, several Internet of Things (IoT) projects have also been passing through the Apache Incubator, some of which will likely become quite influential. Looking forward, expect the ASF to continue as it has, introducing some hugely successful open source projects used by major industry players, with other smaller projects providing vital—if more niche—appeal.
--------------------------------------------------------------------------------
via: https://opensource.com/article/21/6/apache-software-foundation
作者:[Justin Mclean][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/justin-mclean
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/nature_open_sky_tree.png?itok=2J79Futp (Wide open sky and trees)
[2]: https://www.apache.org/
[3]: https://www.apache.org/licenses/LICENSE-2.0
[4]: https://incubator.apache.org/
[5]: https://apache.org/theapacheway/

View File

@ -1,91 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How key Python projects are maintained)
[#]: via: (https://opensource.com/article/20/2/python-maintained)
[#]: author: (Moshe Zadka https://opensource.com/users/moshez)
How key Python projects are maintained
======
A peek behind the scenes of the community that keeps open source Python
projects running smoothly.
![and old computer and a new computer, representing migration to new software or hardware][1]
Jannis Leidel is part of the [Jazzband][2] community. Jazzband is a collaborative community that shares the responsibility of maintaining [Python][3]-based projects.
Jazzband was born out of the stress of maintaining an open source project alone for a longer time. Jannis is a roadie, which means he does administrative tasks and makes sure the people in the band can play when they want.
Jazzband is not his first open source volunteer work—he is a former [Django][4] core developer, [Django Software Foundation][5] board member, has written many Django apps and Python projects, has been a [pip][6] and [virtualenv][7] core developer and release manager, co-founded the [Python Packaging Authority][8], and been a [PyPI][9] admin. On the community front, he co-founded the German Django Association, served as [DjangoCon Europe][10] 2010 co-chairperson, has spoken at several conferences, and for the last year has served as a director and co-communication chair of the [Python Software Foundation][11].
### Moshe Zadka: How did you get started with programming?
Jannis Leidel: I got started with programming as part of the regular German computer science lessons in high school, where I dabbled with Turbo Pascal and Prolog. I quickly got drawn into the world of web development and wrote small websites with PHP3, [Perl5][12], and [MySQL][13]. Later at university, I picked up programming again while working on media arts projects and found [Ruby][14], Perl, and Python to be particularly helpful. I eventually stuck with Python for its versatility and ease of use. I'm very happy to have been able to use Python and open web technologies (HTML/JS/CSS) in my career since then.
### Zadka: How did you get started with open source?
Leidel: As part of an art project at university, I needed a way to talk to various web services and interact with some electronics and found my prior PHP skills not up to the task. So I took a class about programming with Python and got interested in learning more about how frameworks work—compared to libraries—as they further enshrine best practices that I wanted to know about. In particular, the nascent Django Web Framework really appealed to me since it favored a pragmatic approach and provided lots of guidance for how to develop web applications. In 2007 I participated as a student in the Google Summer of Code for Django and later contributed more to Django and its ecosystem of reusable components—after a while as a Django core developer as well. While finishing my degree, I was able to use those skills to work as a freelancer and also spend time on many different parts of the Django community. Moving laterally to the broader Python community was only natural at that point.
### Zadka: What do you for your day job?
Leidel: I'm a Staff Software Engineer at Mozilla, working on data tools for the Firefox data pipeline. In practice, that means I'm working in the broader Firefox Engineering team on various internal and public-facing web-based projects that help Mozilla employees and community members to make sense of the telemetry data that the Firefox web browser sends. Part of my current focus is maintaining our data analysis and visualization platform, which is based on the open source project [Redash][15], and also contributing back to it. Other projects that I contribute to are our next-gen telemetry system [Glean][16] and a tool that allows you to do data science in the browser (including the Scientific Python stack) called [Iodide][17].
### Zadka: How did you get involved with Jazzband?
Leidel: Back in 2015, I was frustrated with maintaining projects alone that a lot of people depended on and saw many of my community peers struggle with similar issues. I didn't know a good way to reach more people in the community who may also have an interest in long-term maintenance. On some occasions, I felt that the new "social coding" paradigm was rarely social and often rather isolating and sometimes even traumatic for old and new contributors. I believe the inequality in our community that I find intolerable nowadays was even more rampant at the time, which made providing a safe environment for contributors difficult—something which we now know is essential for stable project maintenance. I wondered if we were missing a more collaborative and inclusive approach to software development.
The Jazzband project was launched in an attempt to lower the barriers to entry for maintenance and simplify some of the more boring aspects of it (e.g., best practices around [CI][18]).
### Zadka: What is your favorite thing about Jazzband?
Leidel: My favorite thing about Jazzband is the fact that we've secured the maintenance of many projects that a lot of people depend on while also making sure that new contributors of any level of experience can join.
### Zadka: What is the job of a "roadie" in Jazzband?
Leidel: A "roadie" is a go-to person when it comes to all things behind the scenes for Jazzband. That means, for example, dealing with onboarding new projects, maintaining the Jazzband website that handles user management and project releases, acting as a first responder to security or Code of Conduct incidents, and much more. The term "roadies" is borrowed from the music and event industry for support personnel that takes care of almost everything that needs to be done while traveling on tour, except for the actual artistic performance. In Jazzband, they are there to make sure the members can work on the projects. That also means that some tasks are partially or fully automated, where it makes sense, and that best practices are applied to the majority of the Jazzband projects like packaging setup, documentation hosting or continuous integration.
### Zadka: What is the most challenging aspect of your job as a roadie for Jazzband?
Leidel: At the moment, the most challenging aspect of my job as a roadie is to implement improvements for Jazzband that community members have proposed without risking the workflow that they have come to rely on. In other words, scaling the project on a conceptual level has become more difficult the bigger Jazzband gets. There is a certain irony in the fact that I'm the only roadie at the moment and handle some of the tasks alone while Jazzband tries to prevent that from happening for its projects. This is a big concern for the future of Jazzband.
### Zadka: What would you say to someone who is wondering whether they should join Jazzband?
Leidel: If you're interested in joining a group of people who believe that working collaboratively is better than working alone, or if you have struggled with maintenance burden on your own and don't know how to proceed, consider joining Jazzband. It simplifies onboarding new contributors, provides a framework for disputes, and automates releases to [PyPI][19]. There are many best practices that work well for reducing the risk of projects becoming unmaintained.
### Zadka: Is there anything else you want to tell our readers?
Leidel: I encourage everyone working on open source projects to consider the people on the other side of the screen. Be empathetic and remember that your own experience may not be the experience of your peers. Understand that you are members of a global and diverse community, which requires us always to take leaps of respect for the differences between us.
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/2/python-maintained
作者:[Moshe Zadka][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/moshez
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/migration_innovation_computer_software.png?itok=VCFLtd0q (and old computer and a new computer, representing migration to new software or hardware)
[2]: https://jazzband.co/
[3]: https://opensource.com/resources/python
[4]: https://opensource.com/article/18/8/django-framework
[5]: https://www.djangoproject.com/foundation/
[6]: https://opensource.com/article/19/11/python-pip-cheat-sheet
[7]: https://virtualenv.pypa.io/en/latest/
[8]: https://www.pypa.io/en/latest/
[9]: https://pypi.org/
[10]: https://djangocon.eu/
[11]: https://www.python.org/psf/
[12]: http://opensource.com/article/18/1/why-i-love-perl-5
[13]: https://opensource.com/life/16/10/all-things-open-interview-dave-stokes
[14]: http://opensource.com/business/16/4/save-development-time-and-effort-ruby
[15]: https://redash.io/
[16]: https://firefox-source-docs.mozilla.org/toolkit/components/telemetry/start/report-gecko-telemetry-in-glean.html
[17]: https://alpha.iodide.io/
[18]: https://opensource.com/article/19/12/cicd-resources
[19]: https://opensource.com/downloads/7-essential-pypi-libraries

View File

@ -1,5 +1,5 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: translator: (stevenzdg988)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
@ -86,7 +86,7 @@ via: https://opensource.com/article/20/2/linux-open-source-music
作者:[Alan Formy-Duval][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/) 荣誉推出

View File

@ -1,60 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (baddate)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Learn Bash with this book of puzzles)
[#]: via: (https://opensource.com/article/20/4/bash-it-out-book)
[#]: author: (Carlos Aguayo https://opensource.com/users/hwmaster1)
Learn Bash with this book of puzzles
======
'Bash it out' covers basic, medium, and advanced Bash scripting using 16
puzzles.
![Puzzle pieces coming together to form a computer screen][1]
Computers are both my hobby and my profession. I have about 10 of them scattered around my apartment, all running Linux (including my Macs). Since I enjoy upgrading my computers and my computer skills, when I came across [_Bash it out_][2] by Sylvain Leroux, I jumped on the chance to buy it. I use the command line a lot on Debian Linux, and it seemed like a great opportunity to expand my Bash knowledge. I smiled when the author explained in the preface that he uses Debian Linux, which is one of my two favorite distributions.
Bash lets you automate tasks, so it's a labor-saving, interesting, and useful tool. Before reading the book, I already had a fair amount of experience with Bash on Unix and Linux. I'm not an expert, in part because the scripting language is so extensive and powerful. I first became intrigued with Bash when I saw it on the welcome screen of [EndeavourOS][3], an Arch-based Linux distribution.
The following screenshots show some options from EndeavourOS. Beleieve it or not, these panels just point to Bash scripts, each of which accomplish some relatively complex tasks. And because it's all open source, I can modify any of these scripts if I want.
![EndeavourOS after install][4]
![EndeavourOS install apps][5]
### Always something to learn
My impressions of this book are very favorable. It's not long, but it is well-thought-out. The author has very extensive knowledge of Bash and an uncanny ability to explain how to use it. The book covers basic, medium, and advanced Bash scripting using 16 puzzles, which he calls "challenges." This taught me to see Bash scripting as a programming puzzle to solve, which makes it more interesting to play with.
An exciting aspect of Bash is that it's deeply integrated with the Linux system. While part of its power lies in its syntax, it's also powerful because it has access to so much. You can script repetitive tasks, or tasks that are easy but you're just tired of performing manually. Nothing is too great or too small, and _Bash it out_ helps you understand both what you can do, and how to achieve it.
This review would not be complete if I didn't mention David Both's free resource [_A sysadmin's guide to Bash scripting_][6] on Opensource.com. This 17-page PDF guide is different from _Bash it out_, but together they make a winning combination for anyone who wants to learn about it.
I am not a computer programmer, but _Bash it out_ has increased my desire to get into more advanced levels of Bash scripting—I might inadvertently end up as a computer programmer without planning to.
One reason I love Linux is because of how powerful and versatile the operating system is. However much I know about Linux, there is always something new to learn that makes me appreciate Linux even more.
In a competitive and ever-changing job market, it behooves all of us to continuously update our skills. This book helped me learn Bash in a very hands-on way. It almost felt as if the author was in the same room with me, patiently guiding me in my learning.
The author, Leroux, has an uncanny ability to engage readers. This is a rare gift that I think is even more valuable than his technical expertise. In fact, I am writing this book review to thank the author for anticipating my own learning needs; although we have never met, I have benefited in real ways from his gifts.
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/4/bash-it-out-book
作者:[Carlos Aguayo][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/hwmaster1
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/puzzle_computer_solve_fix_tool.png?itok=U0pH1uwj (Puzzle pieces coming together to form a computer screen)
[2]: https://www.amazon.com/Bash-Out-Strengthen-challenges-difficulties/dp/1521773262/
[3]: https://endeavouros.com/
[4]: https://opensource.com/sites/default/files/uploads/endeavouros-welcome.png (EndeavourOS after install)
[5]: https://opensource.com/sites/default/files/uploads/endeavouros-install-apps.png (EndeavourOS install apps)
[6]: https://opensource.com/downloads/bash-scripting-ebook

View File

@ -1,215 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Use Python to solve a charity's business problem)
[#]: via: (https://opensource.com/article/20/9/solve-problem-python)
[#]: author: (Chris Hermansen https://opensource.com/users/clhermansen)
Use Python to solve a charity's business problem
======
Comparing how different programming languages solve the same problem is
fun and instructive. Next up, Python.
![Python programming language logo with question marks][1]
In my [first article][2] in this series, I described a problem of dividing bulk supplies into hampers of similar value to distribute to struggling neighbors in your community. I also wrote about how I enjoy solving small problems like this with small programs in various languages and comparing how they do it.
In the first article, I solved this problem with the [Groovy][3] programming language. Groovy is like [Python][4] in many ways, but syntactically it's more like C and Java. Therefore, it should be interesting and instructive to create the same solution in Python.
### The Python solution
In Java, I declare utility classes to hold tuples of data (the new record feature is going to be great for that). In Groovy, I use the language support for maps, and I follow the same approach in Python.
Use a list of dictionaries to hold the bulk items picked up from the wholesaler:
```
packs = [
        {'item':'Rice','brand':'Best Family','units':10,'price':5650,'quantity':1},
        {'item':'Spaghetti','brand':'Best Family','units':1,'price':327,'quantity':10},
        {'item':'Sardines','brand':'Fresh Caught','units':3,'price':2727,'quantity':3},
        {'item':'Chickpeas','brand':'Southern Style','units':2,'price':2600,'quantity':5},
        {'item':'Lentils','brand':'Southern Style','units':2,'price':2378,'quantity':5},
        {'item':'Vegetable oil','brand':'Crafco','units':12,'price':10020,'quantity':1},
        {'item':'UHT milk','brand':'Atlantic','units':6,'price':4560,'quantity':2},
        {'item':'Flour','brand':'Neighbor Mills','units':10,'price':5200,'quantity':1},
        {'item':'Tomato sauce','brand':'Best Family','units':1,'price':190,'quantity':10},
        {'item':'Sugar','brand':'Good Price','units':1,'price':565,'quantity':10},
        {'item':'Tea','brand':'Superior','units':5,'price':2720,'quantity':2},
        {'item':'Coffee','brand':'Colombia Select','units':2,'price':4180,'quantity':5},
        {'item':'Tofu','brand':'Gourmet Choice','units':1,'price':1580,'quantity':10},
        {'item':'Bleach','brand':'Blanchite','units':5,'price':3550,'quantity':2},
        {'item':'Soap','brand':'Sunny Day','units':6,'price':1794,'quantity':2}]
```
There is one bulk pack of 10 bags of rice and 10 bulk packs with one bag each of spaghetti. In the above, the variable `packs` is set to a Python list of dictionaries. This turns out to be very similar to the Groovy approach. A few points worth noting about the difference between Groovy and Python:
1. In Python, there is no keyword used to define the variable `packs`; Python expects the first use to set a value.
2. Python dictionary keys (e.g., `item`, `brand`, `units`, `price`, `quantity`) require quotes to indicate they are strings; Groovy assumes these are strings, but accepts quotes as well.
3. In Python, the notation `{ … }` indicates a dictionary declaration; Groovy uses the same square brackets as a list, but the structure in both cases must have key-value pairs.
And, yes, those prices aren't in US dollars.
Next, unpack the bulk packages. Unpacking the single bulk package of rice, for example, will yield 10 units of rice; that is, the total number of units yielded is `units * quantity`. The Groovy script uses a handy function called `collectMany` that can be used to flatten out lists of lists. As far as I know, Python doesn't have anything similar, so use two list comprehensions to produce the same result:
```
units = [[{'item':pack['item'],'brand':pack['brand'],
        'price':(pack['price'] / pack['units'])}] *
        (pack['units'] * pack['quantity']) for pack in packs]
units = [x for sublist in units for x in sublist]
```
The first list comprehension (assignment to units) builds the list of lists of dictionaries. The second "flattens" that into just a list of dictionaries. Note that both Python and Groovy provide an `*` operator that takes a list on the left and a number `N` on the right and replicates the list `N` times.
The final step is to repack the units into the hampers for distribution. As in the Groovy version, you need to get a bit more specific about the ideal hamper value, and you might as well not be overly restrictive when you get down to just a few units left:
```
valueIdeal = 5000
valueMax = valueIdeal * 1.1
```
OK! Repack the hampers:
```
import random
hamperNumber = 0           # [1]
while len(units) &gt; 0:      # [2]
    hamperNumber += 1
    hamper = []
    value = 0
    canAdd = True              # [2.1]
    while canAdd:              # [2.2]
        u = random.randint(0,len(units)-1)  # [2.2.1]
        canAdd = False                      # [2.2.2]
        o = 0                               # [2.2.3]
        while o &lt; len(units):               # [2.2.4]
            uo = (u + o) % len(units)
            unit = units[uo]
            unitPrice = unit['price']          # [2.2.4.1]
            if len(units) &lt; 3 or not (unit in hamper) and (value + unitPrice) &lt; valueMax:
                                               # [2.2.4.2]
                hamper.append(unit)
                value += unitPrice
                units.pop(u)                   # [2.2.4.3]
                canAdd = len(units) &gt; 0
                break                          # [2.2.4.4]
            o += 1                             # [2.2.4.5]
                                            # [2.2.5]
    print('')
    print('Hamper',hamperNumber,'value',value)
    for item in hamper:
        print('%-25s%-25s%7.2f' % (item['item'],item['brand'],item['price'])) # [2.3]
    print('Remaining units',len(units))                                       # [2.4]
```
Some clarification, with numbers in brackets in the comments above (e.g., _[1]_) corresponding to the clarifications below:
* 1\. Import Python's random number generator facilities and initialize the hamper number.
* 2\. This `while` loop will redistribute units into hampers as long as there are more available:
* 2.1 Increment the hamper number, get a new empty hamper (a list of units), and set its value to 0; start off assuming you can add more items to the hamper.
* 2.2 This `while` loop will add as many units to the hamper as possible (the Groovy code used a `for` loop, but Python's `for` loops expect to iterate over something, while Groovy has the more traditional C form of `for` loop):
* 2.2.1 Get a random number between zero and the number of remaining units minus 1.
* 2.2.2 Assume you can't find more units to add.
* 2.2.3 Create a variable to be used for the offset from the starting point where you're looking for items to put in the hamper.
* 2.2.4 Starting at the randomly chosen index, this `while` loop will try to find a unit that can be added to the hamper (once again, note that the Python `for` loop probably isn't suitable here since the length of the list will change during processing).
* 2.2.4.1. Figure out which unit to look at (random starting point + offset) and get its price.
* 2.2.4.2 You can add this unit to the hamper if there are only a few left or if the value of the hamper isn't too high once the unit is added.
* 2.2.4.3 Add the unit to the hamper, increment the hamper value by the unit price, remove the unit from the available units list.
* 2.2.4.4 As long as there are units left, you can add more, so break out of this loop to keep looking.
* 2.2.4.5 Increment the offset.
* 2.2.5 On exit from this `while` loop, if you inspected every remaining unit and could not find one to add to the hamper, the hamper is complete; otherwise, you found one and can continue looking for more.
* 2.3 Print out the contents of the hamper.
* 2.4 Print out the remaining units info.
When you run this code, the output looks quite similar to the output from the Groovy program:
```
Hamper 1 value 5304.0
UHT milk                 Atlantic                  760.00
Tomato sauce             Best Family               190.00
Rice                     Best Family               565.00
Coffee                   Colombia Select          2090.00
Sugar                    Good Price                565.00
Vegetable oil            Crafco                    835.00
Soap                     Sunny Day                 299.00
Remaining units 148
Hamper 2 value 5428.0
Tea                      Superior                  544.00
Lentils                  Southern Style           1189.00
Flour                    Neighbor Mills            520.00
Tofu                     Gourmet Choice           1580.00
Vegetable oil            Crafco                    835.00
UHT milk                 Atlantic                  760.00
Remaining units 142
Hamper 3 value 5424.0
Soap                     Sunny Day                 299.00
Chickpeas                Southern Style           1300.00
Sardines                 Fresh Caught              909.00
Rice                     Best Family               565.00
Vegetable oil            Crafco                    835.00
Spaghetti                Best Family               327.00
Lentils                  Southern Style           1189.00
Remaining units 135
Hamper 21 value 5145.0
Tomato sauce             Best Family               190.00
Tea                      Superior                  544.00
Chickpeas                Southern Style           1300.00
Spaghetti                Best Family               327.00
UHT milk                 Atlantic                  760.00
Vegetable oil            Crafco                    835.00
Lentils                  Southern Style           1189.00
Remaining units 4
Hamper 22 value 2874.0
Sardines                 Fresh Caught              909.00
Vegetable oil            Crafco                    835.00
Rice                     Best Family               565.00
Rice                     Best Family               565.00
Remaining units 0
```
The last hamper is abbreviated in contents and value.
### Closing thoughts
At a glance, there isn't a whole lot of difference between the Python and Groovy versions of this program. Both have a similar set of constructs that make handling lists and dictionaries very straightforward. Neither requires a lot of "boilerplate code" or other "ceremonial" actions.
Also, as in the Groovy example, there is some fiddly business about being able to add units to the hamper. Basically, you pick a random position in the list of units and, starting at that position, iterate through the list until you either find a unit whose price allows it to be included or until you exhaust the list. Also, when there are only a few items left, you just toss them into the last hamper.
Another issue worth mentioning: This isn't a particularly efficient approach. Removing elements from lists, being careless about repeated expressions, and a few other things make this less suitable for a huge redistribution problem. Still, it runs in a blink on my old machine.
If you are shuddering at my use of `while` loops and mutating the data in this code, you probably wish I made it more functional. I couldn't think of a way to use map and reduce features in Python in conjunction with a random selection of units for repackaging. Can you?
In the next article, I'll re-do this in Java just to see how much less effort Groovy and Python are, and future articles will cover Julia and Go.
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/9/solve-problem-python
作者:[Chris Hermansen][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/clhermansen
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/python_programming_question.png?itok=cOeJW-8r (Python programming language logo with question marks)
[2]: https://opensource.com/article/20/8/solving-problem-groovy
[3]: https://groovy-lang.org/
[4]: https://www.python.org/

View File

@ -1,83 +0,0 @@
[#]: subject: (What is a CI/CD pipeline?)
[#]: via: (https://opensource.com/article/21/6/what-cicd-pipeline)
[#]: author: (Will Kelly https://opensource.com/users/willkelly)
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
What is a CI/CD pipeline?
======
How you define a continuous integration/continuous deployment pipeline
depends on your organization's requirements.
![Plumbing tubes in many directions][1]
A continuous integration/continuous deployment (CI/CD) pipeline is an anchor for every DevOps initiative. The CI/CD pipeline breaks down traditional silos and enables development and operations teams to collaborate throughout the entire software development lifecycle.
Better yet, moving to DevOps and a CI/CD pipeline can help your organization [deliver software][2] more securely at a higher velocity.
### Breaking down the CI/CD pipeline
There are many definitions of CI/CD pipelines out there, so I always advise organizations to define their own version of a CI/CD pipeline and other DevOps concepts rather than using someone else's. Open source CI/CD tools give you the freedom and options to construct a CI/CD pipeline that meets your organization's requirements.
The stages that form a CI/CD pipeline are distinct subsets of tasks grouped into _pipeline stages_. Typical pipeline stages include:
* **Build:** Developers compile the application code. 
* **Test**: The quality assurance (QA) team tests the application code using automated testing tools and strategies. 
* **Release:** The development team delivers the application code to the code repository.
* **Deploy**: The DevOps team stages application code to production. 
* **Security and compliance**: The QA team validates a build based on the project's requirements. This is the stage where organizations deploy container-scanning tools that check the quality of images against Common Vulnerabilities and Exposures (CVEs). 
These are standard stages for a CI/CD pipeline, yet some organizations adapt the CI/CD pipeline model to fit their requirements. For example, an organization building applications for the healthcare market, with its stringent compliance standards, may distribute the test, validation, and compliance gates throughout their toolchain.
Other examples might be an organization that depends on a complex software supply chain with open source software (OSS). Commercial components may institute a gate where development team members generate a [software bill of materials][3] (SBOM) for OSS packages or the outside commercial software vendor must deliver an SBOM as part of their contract deliverable.
### Barriers to CI/CD pipelines
Implementing a CI/CD pipeline changes a team's processes and culture. While many developers are receptive to automation of some tasks and testing, people can be a barrier to CI/CD adoption.
Moving from a waterfall process to CI/CD can shake up the fundamental and implied power structure in some organizations. Since a CI/CD pipeline increases software delivery velocity, the "gatekeepers" of your old manual process may feel threatened by this change.
### Integration opportunities
The open source roots of the tools comprising a CI/CD toolchain create opportunities for some exciting integrations as you achieve greater DevOps maturity levels in your culture, processes, and tooling.
Analyst firm Forrester predicted in 2020 that just-in-time learning will join the CI/CD pipeline. It makes sense if you think about it. It makes even more sense in the current era of remote work and even for remote onboarding of new employees. For instance, an organization could integrate a documentation wiki into its pipeline with documentation of internal processes.
A more ambitious organization can integrate a learning management system (LMS) such as [Moodle][4] into its CI/CD pipeline. It could use the LMS to publish short videos about new DevOps toolchain features that developers need to learn as they onboard or when tools are updated across the pipeline.
Some organizations are integrating group chat and other collaboration tools directly into their CI/CD pipelines. The chat platform serves alerts and enables collaboration and communication among teams. Integrating Mattermost, Rocket.Chat, or another [enterprise chat][5] platform into your CI/CD pipeline requires upfront planning and analysis to ensure that pipeline users won't drown in alerts.
Another integration opportunity to explore is building analytics and advanced reporting into your CI/CD pipeline. This helps you harness the data that courses through your pipeline.
### Final thoughts
The CI/CD pipeline is foundational to DevOps. And open source makes it adaptable and flexible to new requirements resulting from operational changes you implement during your DevOps journey.
I hope to see an open source response to the unified DevOps platform trend, in which organizations seek an end-to-end CI/CD solution. The makings of such a solution are out there. After all, GitLab and GitHub trace their platforms back to open source roots.
Lastly, don't forget the education and outreach underlying every successful CI/CD toolchain. Documenting your toolchains and accompanying processes will improve developer onboarding and ongoing DevOps team training.
How do you and your organization define your CI/CD toolchain? Please share your feedback in the comments.
--------------------------------------------------------------------------------
via: https://opensource.com/article/21/6/what-cicd-pipeline
作者:[Will Kelly][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/willkelly
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/plumbing_pipes_tutorial_how_behind_scenes.png?itok=F2Z8OJV1 (Plumbing tubes in many directions)
[2]: https://techbeacon.com/devops/5-reasons-why-cicd-vital-your-organizations-value-stream
[3]: https://www.ntia.gov/SBOM
[4]: https://moodle.org/
[5]: https://opensource.com/alternatives/slack

View File

@ -1,142 +0,0 @@
[#]: subject: (How to Set Up Razer Devices on Linux for Lighting Effects and Other Configurations)
[#]: via: (https://itsfoss.com/set-up-razer-devices-linux/)
[#]: author: (Ankush Das https://itsfoss.com/author/ankush/)
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
How to Set Up Razer Devices on Linux for Lighting Effects and Other Configurations
======
You have a shiny new Razer hardware, but you cannot find the Razer Synapse software for Linux. And you end up with no proper RGB sync and do not get to customize it. What do you do?
Well, for certain functionalities, like adding macros to your mouse, you will still need access to Razer Synapse (on Windows or macOS).
But, to tweak a few other options like macros for the keyboard, changing the DPI of your mouse, or lighting effects, you can easily set up your Razer peripherals on Linux.
![My Razer Basilisk V2 with lighting effect][1]
Here are sme pictures of both the mouse and the mouse pad. Its the same setup but with different lighting schemes. Click on the images to see bigger images.
![][2]
![][3]
![][4]
Razer Basilisk is a good gaming mouse. If you want you can order it from Amazon or get it from your local store.
SaleBestseller No. 1
![Razer Basilisk v2 Wired Gaming Mouse: 20K DPI Optical Sensor, Fastest Gaming Mouse Switch, Chroma RGB Lighting, 11 Programmable Buttons, Classic Black][5]
![Razer Basilisk v2 Wired Gaming Mouse: 20K DPI Optical Sensor, Fastest Gaming Mouse Switch, Chroma RGB Lighting, 11 Programmable Buttons, Classic Black][5]
[Razer Basilisk v2 Wired Gaming Mouse: 20K DPI Optical Sensor, Fastest Gaming Mouse Switch, Chroma RGB Lighting, 11 Programmable Buttons, Classic Black][6]
$49.99 [][7]
If you already own a Razer device, let me show the steps to configure it just like what I did here.
### Step 1. Install OpenRazer
**OpenRazer** is an open-source driver to make Razer hardware work on Linux. It supports several functionalities to customize and control your devices, including RGB mousemats.
While this is not an official driver for Linux, it works quite well for a wide range of devices.
**It offers support for a variety of Linux distributions that include Solus, openSUSE, Fedora, Debian, Arch Linux, Ubuntu, and a few others.**
Here, I will be focusing on the steps to install it on any Ubuntu-based distro, you may want to refer to the [official instructions][8] for other distros.
You need to install OpenRazer [using a PPA][9] on Ubuntu, heres how to do that:
```
sudo apt install software-properties-gtk
sudo add-apt-repository ppa:openrazer/stable
sudo apt update
sudo apt install openrazer-meta
```
It also offers a [daemon][10] as well, you can choose to make it work, you will be adding your user to the **plugdev** group — which gives privileged access to the device:
```
sudo gpasswd -a $USER plugdev
```
I did not need to configure/add a daemon using the above command, but I can still use the devices just fine. The daemon mostly ensures that the driver stays active.
[Download OpenRazer][11]
### Stpe 2. Install a GUI to Manage and Tweak Options
Now that the driver has been installed, all you need is a graphical user interface (GUI) to help you customize your Razer hardware.
You can find a few options available out there, but I will recommend installing [Polychromatic][12], which offers an attractive UI and works well as well.
![][13]
Polychromatic app is the closest I could recommend to Razer Synapse, and it works good.
For Ubuntu-based distros, all you need to do is install it using PPA:
```
sudo add-apt-repository ppa:polychromatic/stable
sudo apt update
sudo apt install polychromatic
```
You can find it listed in [AUR][14] for Arch Linux users. For more installation instructions, you can refer to the [official download page][15].
[Download Polychromatic][16]
While you will get distinct set of options for various devices. Here, I tried changing the DPI, customizing the color cycle, and the polling rate of my Razer Basilisk v2 mouse and it worked completely fine.
![Customization options for a mouse][17]
It also offers you the ability to easily restart or stop the [daemon][10], change the applet icon, and perform advanced configuration options if you know what you want to do.
Alternatively, you can try [RazerGenie][18], [Snake][19], or [OpenRGB][20] (meant for changing the colors) to tweak the mouse color or any other settings.
### Wrapping Up
Now that you can easily customize your Razer hardware, hope you have fun!
While you may find some other options to configure your Razer devices, I did not find any other options that work very well.
If you have come across something that works and that deserves a mention here for all the Razer users, let me know in the comments below.
--------------------------------------------------------------------------------
via: https://itsfoss.com/set-up-razer-devices-linux/
作者:[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://i2.wp.com/itsfoss.com/wp-content/uploads/2021/06/Razer-Basilisk-V2.jpg?resize=800%2C600&ssl=1
[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/razer-mouse-pad-lighting-effect-3-com.jpg?resize=800%2C600&ssl=1
[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/razer-mouse-pad-lighting-effect-2-com.jpg?resize=800%2C600&ssl=1
[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/razer-mouse-pad-lighting-effect-1-com.jpg?resize=800%2C600&ssl=1
[5]: https://i1.wp.com/m.media-amazon.com/images/I/31WrG8CTRHL._SL160_.jpg?ssl=1
[6]: https://www.amazon.com/dp/B082G5BDNC?tag=chmod7mediate-20&linkCode=osi&th=1&psc=1&keywords=Razer%20Basilisk%20V2 (Razer Basilisk v2 Wired Gaming Mouse: 20K DPI Optical Sensor, Fastest Gaming Mouse Switch, Chroma RGB Lighting, 11 Programmable Buttons, Classic Black)
[7]: https://www.amazon.com/gp/prime/?tag=chmod7mediate-20 (Amazon Prime)
[8]: https://openrazer.github.io/#download
[9]: https://itsfoss.com/ppa-guide/
[10]: https://itsfoss.com/linux-daemons/
[11]: https://openrazer.github.io/
[12]: https://polychromatic.app
[13]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/06/polychromatic-app-1.png?resize=800%2C500&ssl=1
[14]: https://itsfoss.com/aur-arch-linux/
[15]: https://polychromatic.app/download/
[16]: https://polychromatic.app/
[17]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/razer-basilisk-polychromatic.png?resize=800%2C505&ssl=1
[18]: https://github.com/z3ntu/RazerGenie
[19]: https://github.com/bithatch/snake
[20]: https://itsfoss.com/openrgb/

View File

@ -1,110 +0,0 @@
[#]: subject: (KTorrent: An Incredibly Useful BitTorrent Application by KDE)
[#]: via: (https://itsfoss.com/ktorrent/)
[#]: author: (Ankush Das https://itsfoss.com/author/ankush/)
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
KTorrent: An Incredibly Useful BitTorrent Application by KDE
======
There are a variety of BitTorrent applications available for Linux. But finding a good application that offers many features should save you some time.
KTorrent by KDE is one such BitTorrent app built for Linux.
While there are [several torrent clients for Linux][1], I recently found KTorrent interesting for my use-case.
### KTorrent: Open Source BitTorrent Client for Linux
![][2]
KTorrent is a full-fledged torrent client primarily tailored for KDE desktop. It should work simply fine no matter what desktop environment you use.
Of course, with KDE desktop, you may get a seamless user experience.
Let us look at the all the features offered.
### Features of KTorrent
![][3]
For regular torrent users, having an extensive set of features makes things easy. And KTorrent is no exception. Here, Ill highlight the key highlights of KTorrent:
* Adding torrent downloads in a queue
* Ability to control the speed limits per download (or overall)
* Video and audio file preview option
* Supports importing of downloaded files (partial/full)
* Ability to prioritize torrent downloads when downloading multiple files
* Selection of specific files to download for multi-file torrents
* IP filter with the option of kicking/banning peers
* UDP tracker support
* µTorrent peer support
* Support for protocol encryption
* Ability to create trackerless torrent
* Scripting support
* System tray integration
* Connection through a proxy
* Added plugin support
* Supports IPv6
KTorrent sounds something useful as a torrent client that you can use daily with control to manage all your torrent downloads at one place.
![][4]
In addition to the features mentioned above, it offers great control over the behavior of the client as well. For instance, tweaking the color that indicates downloads/pause/trackers.
You also get the ability to set the notification if you want to disable the sound of completing a torrent download or getting notified of the activity.
![][5]
While features like protocol encryption support may not be able to replace some of the [best VPN][6] services, it is an important addition for desktop clients.
### Installing KTorrent in Linux
KTorrent should be available through your package managers like [Synaptic][7] or the default repositories. You can also find it listed in your software center for easy installation.
In addition to this, it also offers a [Flatpak][8] official package on [Flathub][9] for any Linux distribution. If you need help with that, we have a [Flatpak guide][10] for reference.
You can also try the [snap package][11] available if you prefer that.
To explore more about it and the source code, head to its [official KDE app page][12].
[KTorrent][12]
### Closing Thoughts
KTorrent is a phenomenal torrent client for Linux. I tried it on my Linux Mint system on top of Cinnamon desktop, and it worked great.
I like how simple, yet configurable it is. Even though I dont use a torrent client every day, I did not see anything weird with KTorrent in my brief testing.
What do you think about KTorrent as a torrent client for Linux? What do you prefer to use it instead?
--------------------------------------------------------------------------------
via: https://itsfoss.com/ktorrent/
作者:[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://itsfoss.com/best-torrent-ubuntu/
[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/ktorrent-download.png?resize=850%2C582&ssl=1
[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/06/ktorrent-configure.png?resize=850%2C656&ssl=1
[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/ktorrent-speed-limit.png?resize=850%2C585&ssl=1
[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/ktorrent-plugins.png?resize=850%2C643&ssl=1
[6]: https://itsfoss.com/best-vpn-linux/
[7]: https://itsfoss.com/synaptic-package-manager/
[8]: https://itsfoss.com/what-is-flatpak/
[9]: https://flathub.org/apps/details/org.kde.ktorrent
[10]: https://itsfoss.com/flatpak-guide/
[11]: https://snapcraft.io/ktorrent
[12]: https://apps.kde.org/ktorrent/

View File

@ -2,7 +2,7 @@
[#]: via: (https://opensource.com/article/21/6/dust-linux)
[#]: author: (Sudeshna Sur https://opensource.com/users/sudeshna-sur)
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )

View File

@ -0,0 +1,231 @@
[#]: subject: (Parsing config files with Lua)
[#]: via: (https://opensource.com/article/21/6/parsing-config-files-lua)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
Parsing config files with Lua
======
Configure persistent application settings with the Lua programming
language.
![Woman sitting in front of her computer][1]
Not all applications need configuration files; many applications benefit from starting fresh each time they are launched. Simple utilities, for instance, rarely require preferences or settings that persist across uses. However, when you write a complex application, it's nice for users to be able to configure how they interact with it and how it interacts with their system. That's what configuration files are for, and this article discusses some of the ways you can implement persistent settings with the Lua programming language.
### Choose a format
The important thing about configuration files is that they are consistent and predictable. You do not want to dump information into a file under the auspices of saving user preferences and then spend days writing code to reverse-engineer the random bits of information that have ended up in the file.
There are several popular [formats for configuration files][2]. Lua has libraries for most of the common configuration formats; in this article, I'll use the INI format.
### Installing the library
The central hub for Lua libraries is [Luarocks.org][3]. You can search for libraries on the website, or you can install and use the `luarocks` terminal command.
On Linux, you can install it from your distribution's software repository. For example:
```
`$ sudo dnf install luarocks`
```
On macOS, use [MacPorts][4] or [Homebrew][5]. On Windows, use [Chocolatey][6].
Once `luarocks` is installed, you can use the `search` subcommand to search for an appropriate library. If you don't know the name of a library, you can search for a keyword, like `ini` or `xml` or `json`, depending on what's relevant to what you're trying to do. In this case, you can just search for `inifile`, which is the library I use to parse text files in the INI format:
```
$ luarocks search inifile
Search results:
inifile
 1.0-2 (rockspec) - <https://luarocks.org>
 1.0-2 (src) - <https://luarocks.org>
 1.0-1 (rockspec) - <https://luarocks.org>
 [...]
```
A common trap programmers fall into is installing a library on their system and forgetting to bundle it with their application. This can create problems for users who don't have the library installed. To avoid this, use the `--tree` option to install the library to a local folder within your project directory. If you don't have a project directory, create one first, and then install:
```
$ mkdir demo
$ cd demo
$ luarocks install --tree=local inifile
```
The `--tree` option tells `luarocks` to create a new directory, called `local` in this case, and install your library into it. With this simple trick, you can install all the dependency code your project uses directly into the project directory.
### Code setup
First, create some INI data in a file called `myconfig.ini`:
```
[example]
name=Tux
species=penguin
enabled=false
[demo]
name=Beastie
species=demon
enabled=false
```
Save the file as `myconfig.ini` into your home directory, _not_ into your project directory. You usually want configuration files to exist outside your application so that even when a user uninstalls your application, the data they generate while using the application remains on their system. Users might remove unnecessary config files manually, but many don't. As a result, if they reinstall an application, it will retain all of their preferences.
Config file locations are technically unimportant, but each operating system (OS) has a specification or a tradition of where they ought to be placed. On Linux, this is defined by the [Freedesktop specification][7]. It dictates that configuration files are to be saved in a hidden folder named `~/.config`. For clarity during this exercise, just save the file in your home directory so that it's easy to find and use.
Create a second file named `main.lua` and open it in your favorite text editor.
First, you must tell Lua where you've placed the additional library you want it to use. The `package.path` variable determines where Lua looks for libraries. You can view Lua's default package path in a terminal:
```
$ Lua
&gt; print(package.path)
./?.lua;/usr/share/lua/5.3/?.lua;/usr/share/lua/5.3/?/init.lua;/usr/lib64/lua/5.3/?.lua;/usr/lib64/lua/5.3/?/init.lua
```
In your Lua code, append your local library location to `package.path`:
```
`package.path = package.path .. ';local/share/lua/5.3/?.lua`
```
### Parsing INI files with Lua
With the package location established, the next thing to do is to require the `inifile` library and then handle some OS logistics. Even though this is a simple example application, the code needs to get the user's home directory location from the OS and establish how to communicate filesystem paths back to the OS when necessary:
```
package.path = package.path .. ';local/share/lua/5.3/?.lua
inifile = require('inifile')
\-- find home directory
home = os.getenv('HOME')
\-- detect path separator
\-- returns '/' for Linux and Mac
\-- and '\' for Windows
d = package.config:sub(1,1)
```
Now you can use `inifile` to parse data from the config file into a Lua table. Once the data has been placed into a table, you can query the table as you would any other Lua table:
```
\-- parse the INI file and
\-- put values into a table called conf
conf = inifile.parse(home .. d .. 'myconfig.ini')
\-- print the data for review
print(conf['example']['name'])
print(conf['example']['species'])
print(conf['example']['enabled'])
```
Run the code in a terminal to see the results:
```
$ lua ./main.lua
Tux
penguin
false
```
That looks correct. Try doing the same for the `demo` block.
### Saving data in the INI format
Not all parser libraries read and write data (often called _encoding_ and _decoding_), but the `inifile` library does. That means you can use it to make changes to a configuration file.
To change a value in a configuration file, you set the variable representing the value in the parsed table, and then you write the table back to the configuration file:
```
\-- set enabled to true
conf['example']['enabled'] = true
conf['demo']['enabled'] = true
\-- save the change
inifile.save(home .. d .. 'myconfig.ini', conf)
```
Take a look at the configuration file now:
```
$ cat ~/myconfig.ini
[example]
name=Tux
species=penguin
enabled=true
[demo]
name=Beastie
species=demon
enabled=true
```
### Config files
The ability to save data about how a user wants to use an application is an important part of programming. Fortunately, it's a common task for programmers, so much of the work has probably already been done. Find a good library for encoding and decoding into an open format, and you can provide a persistent and consistent user experience.
Here's the entire demo code for reference:
```
package.path = package.path .. ';local/share/lua/5.3/?.lua'
inifile = require('inifile')
\-- find home directory
home = os.[getenv][8]('HOME')
\-- detect path separator
\-- returns '/' for Linux and Mac
\-- and '\' for Windows
d = package.config:sub(1,1)
\-- parse the INI file and
\-- put values into a table called conf
conf = inifile.parse(home .. d .. 'myconfig.ini')
\-- print the data for review
print(conf['example']['name'])
print(conf['example']['species'])
print(conf['example']['enabled'])
\-- enable Tux
conf['example']['enabled'] = true
\-- save the change
inifile.save(home .. d .. 'myconfig.ini', conf)
```
--------------------------------------------------------------------------------
via: https://opensource.com/article/21/6/parsing-config-files-lua
作者:[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/OSDC_women_computing_2.png?itok=JPlR5aCA (Woman sitting in front of her computer)
[2]: https://opensource.com/article/21/6/config-files-and-their-formats
[3]: https://opensource.com/article/19/11/getting-started-luarocks
[4]: https://opensource.com/article/20/11/macports
[5]: https://opensource.com/article/20/6/homebrew-mac
[6]: https://opensource.com/article/20/3/chocolatey
[7]: https://www.freedesktop.org/wiki/Specifications
[8]: http://www.opengroup.org/onlinepubs/009695399/functions/getenv.html

View File

@ -0,0 +1,83 @@
[#]: subject: (Program on FreeDOS with Bywater BASIC)
[#]: via: (https://opensource.com/article/21/6/freedos-bywater-basic)
[#]: author: (Jim Hall https://opensource.com/users/jim-hall)
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
Program on FreeDOS with Bywater BASIC
======
Install Bywater BASIC on your FreeDOS system and start experimenting
with BASIC programming.
![woman on laptop sitting at the window][1]
In the early days of personal computing—from the late 1970s and through the 1980s—many people got their start with BASIC programming. BASIC was a universal programming language that came built into most personal computers, from Apple to IBM PCs.
When we started the FreeDOS Project in June 1994, it seemed natural that we should include an open source BASIC environment. I was excited to discover one already existed in Bywater BASIC.
The [Bywater BASIC website][2] reminds us that “Bywater BASIC implements a large superset of the ANSI Standard for Minimal BASIC (X3.60-1978) and a significant subset of the ANSI Standard for Full BASIC (X3.113-1987).” It's also distributed under the GNU General Public License version 2, which means it's open source software. We only want to include open source programs in FreeDOS, so Bywater BASIC was a great addition to FreeDOS in our early days.
We've included Bywater BASIC since at least FreeDOS Alpha 5, in 1997. You can find Bywater BASIC in FreeDOS 1.3 RC4 in the "Development" package group on the Bonus CD. Load this:
![Bywater BASIC][3]
Installing Bywater BASIC on FreeDOS 1.3 RC4
(Jim Hall, [CC-BY SA 4.0][4])
FreeDOS installs the Bywater BASIC package in the `\DEVEL\BWBASIC` directory. Change to this directory with `CD \DEVEL\BWBASIC` and type `BWBASIC` to run the Bywater BASIC interpreter.
![Bywater BASIC][5]
The Bywater BASIC intepreter
(Jim Hall, [CC-BY SA 4.0][4])
### Writing a sample program
Let me demonstrate Bywater BASIC by writing a test program. We'll keep this simple—print five random numbers. This requires only a few constructs—a loop to iterate over five values and a random number generator. BASIC uses the `RND(1)` statement to generate a random value between 0 and 1. We can use `PRINT` to display the random number.
One feature I like in Bywater BASIC is the integrated "help" system. There's nothing more frustrating than forgetting the syntax for a BASIC statement. For example, I always forget how to create BASIC loops. Do I use `FOR I IN 1 TO 10` or `FOR I = 1 TO 10`? Just type `help FOR` at the Bywater BASIC prompt and the interpreter displays the usage and a brief description.
![Bywater BASIC][6]
Use the "help" system as a quick-reference guide
(Jim Hall, [CC-BY SA 4.0][4])
Another neat feature in Bywater BASIC is how it reformats your BASIC instructions, so they are easier to read. After typing my brief program, I can type `list` to see the full source listing. Bywater BASIC automatically adds the `CALL` keyword to my `RANDOMIZE` statement on line 10 and indents the `PRINT` statement inside my loop. These small changes help me to see loops and other features in my program, which can aid in debugging.
![Bywater BASIC][7]
Bywater BASIC automatically reformats your code
(Jim Hall, [CC-BY SA 4.0][4])
If everything looks okay, then type `RUN` to execute the program. Because I used the `RANDOMIZE` statement at the start of my BASIC program, Bywater _seeds_ the random number generator with a random starting point. This ensures that my numbers are actually random values and don't repeat when I re-run my program.
![Bywater BASIC][8]
Generating lists of random numbers
(Jim Hall, [CC-BY SA 4.0][4])
Install Bywater BASIC on your FreeDOS system and start experimenting with BASIC programming. BASIC can be a great first programming language, especially if you are interested in getting back to the "roots" of personal computing. You can find more information about Bywater BASIC in the manual, installed in the `\DEVEL\BWBASIC` directory as `BWBASIC.DOC`. You can also explore the online "help" system by typing `HELP` at the Bywater BASIC prompt.
--------------------------------------------------------------------------------
via: https://opensource.com/article/21/6/freedos-bywater-basic
作者:[Jim Hall][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/jim-hall
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/lenovo-thinkpad-laptop-window-focus.png?itok=g0xPm2kD (young woman working on a laptop)
[2]: https://sourceforge.net/projects/bwbasic/
[3]: https://opensource.com/sites/default/files/uploads/bwbasic1.png (Installing Bywater BASIC on FreeDOS 1.3 RC4)
[4]: https://creativecommons.org/licenses/by-sa/4.0/
[5]: https://opensource.com/sites/default/files/uploads/bwbasic3.png (The Bywater BASIC intepreter)
[6]: https://opensource.com/sites/default/files/uploads/randnum1.png (Use the "help" system as a quick-reference guide)
[7]: https://opensource.com/sites/default/files/uploads/randnum2.png (Bywater BASIC automatically reformats your code)
[8]: https://opensource.com/sites/default/files/uploads/randnum3.png (Generating lists of random numbers)

View File

@ -0,0 +1,115 @@
[#]: subject: (Python 3.10 beta in Fedora Linux)
[#]: via: (https://fedoramagazine.org/python-3-10-beta-in-fedora-linux/)
[#]: author: (Miro Hrončok https://fedoramagazine.org/author/churchyard/)
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
Python 3.10 beta in Fedora Linux
======
![][1]
The Python developers have already released three beta versions of Python 3.10.0. You can try the latest one in Fedora Linux today! Test your Python code with 3.10 early to be ready for the final 3.10.0 release in October.
### Install Python 3.10 on Fedora Linux
If you run Fedora Linux, you can install Python 3.10 from the official software repository with _dnf_:
```
$ sudo dnf install python3.10
```
You might need to enable the _updates-testing_ repository to get the very latest pre-release:
```
$ sudo dnf install --enablerepo=updates-testing python3.10
```
As more betas and release candidates [will be released][2], the Fedora package will receive updates. No need to compile your own development version of Python, just install it and have it up to date. The Python developers will add no new features starting with the first beta; you can already enjoy all the new things.
### Test your projects with Python 3.10
Run the _python3.10_ command to use Python 3.10 or create virtual environments with the [builtin _venv_ module, tox][3] or with [pipenv][4] and [poetry][5]. Heres an example using _tox_:
```
$ git clone https://github.com/benjaminp/six.git
Cloning into 'six'...
$ cd six/
$ tox -e py310
py310 run-test: commands[0] | python -m pytest -rfsxX
================== test session starts ===================
platform linux -- Python 3.10.0b3, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
collected 200 items
test_six.py ...................................... [ 19%]
.................................................. [ 44%]
.................................................. [ 69%]
.................................................. [ 94%]
............ [100%]
================== 200 passed in 0.43s ===================
________________________ summary _________________________
py310: commands succeeded
congratulations :)
```
If you find a problem with Python 3.10 on Fedora Linux, please do [file bug reports at Fedoras bugzilla][6] or in the [Pythons issue tracker][7]. If you arent sure if it is a problem in Python, you can [contact the Fedoras Python maintainers][8] directly via email or IRC.
### Whats new in Python 3.10
See the [full list of news in Python 3.10][9]. You can, for example, try out [structural pattern matching][10]:
```
$ python3.10
Python 3.10.0b3 (default, Jun 17 2021, 00:00:00)
[GCC 10.3.1 20210422 (Red Hat 10.3.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> point = (3, 10)
>>> match point:
... case (0, 0):
... print("Origin")
... case (0, y):
... print(f"Y={y}")
... case (x, 0):
... print(f"X={x}")
... case (x, y):
... print(f"X={x}, Y={y}")
... case _:
... raise ValueError("Not a point")
...
X=3, Y=10
>>> x
3
>>> y
10
```
And stay tuned for [Python 3.10 as _python3_ in Fedora Linux 35][11]!
--------------------------------------------------------------------------------
via: https://fedoramagazine.org/python-3-10-beta-in-fedora-linux/
作者:[Miro Hrončok][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://fedoramagazine.org/author/churchyard/
[b]: https://github.com/lujun9972
[1]: https://fedoramagazine.org/wp-content/uploads/2021/06/python310-beta-816x345.jpg
[2]: https://www.python.org/dev/peps/pep-0619/
[3]: https://developer.fedoraproject.org/tech/languages/python/multiple-pythons.html
[4]: https://fedoramagazine.org/install-pipenv-fedora/
[5]: https://python-poetry.org/
[6]: https://bugzilla.redhat.com/buglist.cgi?component=python3.10&product=Fedora
[7]: https://bugs.python.org/
[8]: https://fedoraproject.org/wiki/SIGs/Python#Communicate
[9]: https://docs.python.org/3.10/whatsnew/3.10.html
[10]: https://www.python.org/dev/peps/pep-0634/
[11]: https://fedoraproject.org/wiki/Changes/Python3.10

View File

@ -0,0 +1,129 @@
[#]: subject: (Copy files between Linux and FreeDOS)
[#]: via: (https://opensource.com/article/21/6/copy-files-linux-freedos)
[#]: author: (Jim Hall https://opensource.com/users/jim-hall)
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
Copy files between Linux and FreeDOS
======
Here's how I transfer files between my FreeDOS virtual machine and my
Linux desktop system.
![Files in a folder][1]
I run Linux as my primary operating system, and I boot FreeDOS in a virtual machine. Most of the time, I use QEMU as my PC emulator, but sometimes I'll run other experiments with GNOME Boxes (which uses QEMU as a back-end virtual machine) or with VirtualBox.
I like to play classic DOS games, and sometimes I'll bring up a favorite DOS application. I teach a Management Information Systems (MIS) class where I talk about the history of computing, and I'll sometimes record a demonstration using FreeDOS and a legacy DOS application, such as As-Easy-As (my favorite DOS spreadsheet—once released as "shareware" but now available [for free from TRIUS, Inc][2]).
But using FreeDOS this way means I need to transfer files between my FreeDOS virtual machine and my Linux desktop system. Let me show you how I do that.
### Accessing the image with guestmount
I used to access my virtual disk image by calculating the offset to the first DOS partition, then calling the Linux `mount` command with the right mix of options to match that offset. This was always error-prone and not very flexible. Fortunately, there's an easier way to do it. The `guestmount` program from the [libguestfs-tools][3] package lets you access or _mount_ the virtual disk image from Linux. You can install `libguestfs-tools` using this command on Fedora:
```
`$ yum install libguestfs-tools libguestfs`
```
Using `guestmount` is not as easy as double-clicking the file from the GNOME file manager, but the command line isn't too difficult to use. The basic usage of `guestmount` is:
```
`$ guestmount -a image -m device mountpoint`
```
In this usage, _image_ is the virtual disk image to use. On my system, I created my QEMU virtual disk image with the `qemu-img` command. The g`uestmount` program can read this disk image format, as well as the QCOW2 image format used by GNOME Boxes, or the VDI image format used in VirtualBox.
The _device_ option indicates the partition on the virtual disk. Imagine using this virtual disk as a real hard drive. You would access the first partition as `/dev/sda1`, the second partition as `/dev/sda2`, and so on. That's the syntax for `guestmount`. By default, FreeDOS 1.3 RC4 creates one partition on an empty drive, so access that partition as `/dev/sda1`.
And _mountpoint_ is the location to "mount" the DOS filesystem on your local Linux system. I'll usually create a temporary directory to work with. You only need the mount point while you're accessing the virtual disk.
Putting that all together, I use this set of commands to access my FreeDOS virtual disk image from Linux:
```
$ mkdir /tmp/freedos
$ guestmount -a freedos.img -m /dev/sda1 /tmp/freedos
```
After that, I can access my FreeDOS files via the `/tmp/freedos` directory, using normal tools on Linux. I might use `ls /tmp/freedos` at the command line, or open the `/tmp/freedos` mount point using the desktop file manager.
```
$ ls -l /tmp/freedos
total 216
drwxr-xr-x.  5 root root  8192 May 10 15:53 APPS
-rwxr-xr-x.  1 root root 85048 Apr 30 07:54 COMMAND.COM
-rwxr-xr-x.  1 root root   103 May 13 15:48 CONFIG.SYS
drwxr-xr-x.  5 root root  8192 May 15 16:52 DEVEL
drwxr-xr-x.  2 root root  8192 May 15 13:36 EDLIN
-rwxr-xr-x.  1 root root  1821 May 10 15:57 FDAUTO.BAT
-rwxr-xr-x.  1 root root   740 May 13 15:47 FDCONFIG.SYS
drwxr-xr-x. 10 root root  8192 May 10 15:49 FDOS
-rwxr-xr-x.  1 root root 46685 Apr 30 07:54 KERNEL.SYS
drwxr-xr-x.  2 root root  8192 May 10 15:57 SRC
-rwxr-xr-x.  1 root root  3190 May 16 08:34 SRC.ZIP
drwxr-xr-x.  3 root root  8192 May 11 18:33 TEMP
```
![GNOME file manager][4]
Using GNOME file manager to access the virtual disk
(Jim Hall, [CC-BY SA 4.0][5])
For example, to copy several C source files from my Linux `projects` directory into `C:\SRC` on the virtual disk image, so I can use the files under FreeDOS later, I can use the Linux `cp` command:
```
`$ cp /home/jhall/projects/*.c /tmp/freedos/SRC`
```
The files and directories on the virtual drive are technically _case insensitive_, so you can refer to them using uppercase or lowercase letters. However, I find it more natural to type DOS files and directories using all uppercase.
```
$ ls /tmp/freedos
APPS         CONFIG.SYS  EDLIN       FDCONFIG.SYS  KERNEL.SYS  SRC.ZIP
COMMAND.COM  DEVEL       FDAUTO.BAT  FDOS          SRC         TEMP
$ ls /tmp/freedos/EDLIN
EDLIN.EXE  MAKEFILE.OW
$ ls /tmp/freedos/edlin
EDLIN.EXE  MAKEFILE.OW
```
### Unmounting with guestmount
You should always _unmount_ the virtual disk image before you use it again in your virtual machine. If you leave the image mounted while you run QEMU or VirtualBox, you risk messing up your files.
The companion command to `guestmount` is `guestunmount`, to unmount the disk image. Just give the mount point that you wish to unmount:
```
`$ guestunmount /tmp/freedos`
```
Note that this command is spelled slightly differently from the Linux `umount` system command.
--------------------------------------------------------------------------------
via: https://opensource.com/article/21/6/copy-files-linux-freedos
作者:[Jim Hall][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/jim-hall
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/files_documents_paper_folder.png?itok=eIJWac15 (Files in a folder)
[2]: http://www.triusinc.com/forums/viewtopic.php?t=10
[3]: https://libguestfs.org/
[4]: https://opensource.com/sites/default/files/uploads/gnome-file-manager.png (Using GNOME file manager to access the virtual disk)
[5]: https://creativecommons.org/licenses/by-sa/4.0/

View File

@ -0,0 +1,192 @@
[#]: subject: (Linux package management with apt)
[#]: via: (https://opensource.com/article/21/6/apt-linux)
[#]: author: (Chris Hermansen https://opensource.com/users/clhermansen)
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
Linux package management with apt
======
Learn how to install packages on Debian-based Linux distros with the apt
command, then download our cheat sheet to keep the right command at your
fingertips.
![bash logo on green background][1]
On Linux, [package managers][2] help you handle updates, uninstalls, troubleshooting, and more for the software on your computer. Seth Kenlon [wrote about `dnf`][3], the command-line package management tool for installing software in RHEL, CentOS, Fedora, Mageia, OpenMandriva, and other Linux distros.
Debian and Debian-based distros such as MX Linux, Deepin, Ubuntu—and distros based on Ubuntu, such as Linux Mint and Pop!_OS—have `apt`, a "similar but different" tool. In this article, I'll follow Seth's examples—but with `apt`—to show you how to use it.
Before I start, I want to mention four `apt`-related tools for installing software:
* [Synaptic][4] is a GTK+ based graphical user interface (GUI) front end for `apt`.
* [Aptitude][5] is an Ncurses-based full-screen command-line front end for `apt`.
* There are `apt-get`, `apt-cache`, and other predecessors of `apt`.
* [Dpkg][6] is the "behind the scenes" package manager `apt` uses to do the heavy lifting.
There are other packaging systems, such as [Flatpak][7] and [Snap][8], that you might run into on Debian and Debian-based systems, but I'm not going to discuss them here. There are also application "stores," such as [GNOME Software][9], that overlap with `apt` and other packaging technologies; again, I'm not going to discuss them here. Finally, there are other Linux distros such as [Arch][10] and [Gentoo][11] that use neither `dnf` nor `apt`, and I'm not going to discuss those here either!
With all the things I'm not going to discuss here, you may be wondering what tiny subset of software `apt` handles. Well, on my Ubuntu 20.04, `apt` gives me access to 69,371 packages, from the `0ad` real-time strategy game of ancient warfare to the `zzuf` transparent application fuzzer. Not bad at all.
### Finding software with apt
The first step in using a package manager such as `apt` is finding a software package of interest. Seth's `dnf` article used the [Cockpit][12] server management application as an example, so I will, too:
```
$ apt search cockpit
Sorting... Done
Full Text Search... Done
389-ds/hirsute,hirsute 1.4.4.11-1 all
  389 Directory Server suite - metapackage
cockpit/hirsute,hirsute 238-1 all
  Web Console for Linux servers
...
$
```
The second package above is the one you're after (it's the line beginning with `cockpit/hirsute`). If you decide you want to install it, enter:
```
`$ sudo apt install cockpit`
```
`apt` will take care of installing Cockpit and all the bits and pieces, or _dependencies_, needed to make it work. Sometimes that's all that's needed; sometimes it's not. It's possible that having a bit more information could be useful in deciding whether you really want to install this application.
### Package metadata
To find out more about a package, use the `apt show` command:
```
$ apt show cockpit
Package: cockpit
Version: 238-1
Priority: optional
Section: universe/admin
Origin: Ubuntu
Maintainer: Ubuntu Developers &lt;[ubuntu-devel-discuss@lists.ubuntu.com][13]&gt;
Original-Maintainer: Utopia Maintenance Team &lt;[pkg-utopia-maintainers@lists.alioth.debian.org][14]&gt;
Bugs: <https://bugs.launchpad.net/ubuntu/+filebug>
Installed-Size: 88.1 kB
Depends: cockpit-bridge (&gt;= 238-1), cockpit-ws (&gt;= 238-1), cockpit-system (&gt;= 238-1)
Recommends: cockpit-storaged (&gt;= 238-1), cockpit-networkmanager (&gt;= 238-1), cockpit-packagekit (&gt;= 238-1)
Suggests: cockpit-doc (&gt;= 238-1), cockpit-pcp (&gt;= 238-1), cockpit-machines (&gt;= 238-1), xdg-utils
Homepage: <https://cockpit-project.org/>
Download-Size: 21.3 kB
APT-Sources: <http://ca.archive.ubuntu.com/ubuntu> hirsute/universe amd64 Packages
Description: Web Console for Linux servers
 The Cockpit Web Console enables users to administer GNU/Linux servers using a
 web browser.
 .
 It offers network configuration, log inspection, diagnostic reports, SELinux
 troubleshooting, interactive command-line sessions, and more.
$
```
In particular, notice the `Description` field, which tells you more about the application. The `Depends` field says what else must be installed, and `Recommends` shows what other—if any—cooperating components are suggested alongside it. The `Homepage` field offers a URL in case you need more info.
### What package provides a file?
Sometimes you don't know the package name, but you know a file that must be in a package. Seth offers as an example the `qmake-qt5` utility. Using `apt search` doesn't find it:
```
$ apt search qmake-qt5
Sorting... Done
Full Text Search... Done
$
```
However, a related command, `apt-file` will explore inside packages:
```
$ apt-file search qmake-qt5
qt5-qmake-bin: /usr/share/man/man1/qmake-qt5.1.gz
$
```
This turns up a man page for `qmake-qt5` that is part of a package called `qt5-qmake-bin`. Note that this package name reverses the `qmake` and `qt5` parts.
### What files are included in a package?
That handy `apt-file` command also tells which files are included in a given package. For example:
```
$ apt-file list cockpit
cockpit: /usr/share/doc/cockpit/TODO.Debian
cockpit: /usr/share/doc/cockpit/changelog.Debian.gz
cockpit: /usr/share/doc/cockpit/copyright
cockpit: /usr/share/man/man1/cockpit.1.gz
cockpit: /usr/share/metainfo/cockpit.appdata.xml
cockpit: /usr/share/pixmaps/cockpit.png
$
```
Note that this is distinct from the info provided by the `apt show` command, which lists the package's dependencies (other packages that must be installed).
### Removing an application
You can also remove packages with `apt`. For example, to remove the `apt-file` application:
```
`$ sudo apt purge apt-file`
```
Note that a superuser must run `apt` to install or remove applications.
Removing a package doesn't automatically remove all the dependencies that `apt` installs along the way. However, it's easy to carry out that little bit of tidying:
```
`$ sudo apt autoremove`
```
### Getting to know apt
As Seth wrote, "the more you know about how your package manager works, the easier it is for you to install and query applications when necessary."
Even if you're not a regular `apt` user, knowing it can be useful when you need to work at the command line while installing or removing packages (for example, on a remote server or when following a how-to published by some helpful soul). You may also need to know a bit about Dkpg (mentioned above); for example, some software creators provide a bare `.pkg` file.
I find the Synaptic package manager to be a really useful tool on my desktop, but I also use `apt` on a handful of servers that I maintain for various purposes.
**[Download our `apt` cheat sheet][15]** to get used to the command and try some new tricks with it. Once you do, you might find it hard to use anything else.
--------------------------------------------------------------------------------
via: https://opensource.com/article/21/6/apt-linux
作者:[Chris Hermansen][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/clhermansen
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bash_command_line.png?itok=k4z94W2U (bash logo on green background)
[2]: https://opensource.com/article/21/2/linux-package-management
[3]: https://opensource.com/article/21/5/dnf
[4]: https://www.nongnu.org/synaptic/
[5]: https://wiki.debian.org/Aptitude
[6]: https://wiki.debian.org/Teams/Dpkg
[7]: https://flatpak.org/
[8]: https://snapcraft.io/
[9]: https://wiki.gnome.org/Apps/Software
[10]: https://archlinux.org/
[11]: https://www.gentoo.org/
[12]: https://opensource.com/article/20/11/cockpit-server-management
[13]: mailto:ubuntu-devel-discuss@lists.ubuntu.com
[14]: mailto:pkg-utopia-maintainers@lists.alioth.debian.org
[15]: https://opensource.com/downloads/apt-cheat-sheet

View File

@ -0,0 +1,201 @@
[#]: subject: (View statistics about your code with Tokei)
[#]: via: (https://opensource.com/article/21/6/tokei)
[#]: author: (Sudeshna Sur https://opensource.com/users/sudeshna-sur)
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
View statistics about your code with Tokei
======
Learn details about projects' programming languages and more.
![A screen of code.][1]
Recently, GitHub added a small indicator that shows details about projects, including what programming languages a project uses. Before this, it was hard for new contributors to know this type of information about the projects they were interested in.
This addition is helpful, but what if you want to know the same information about projects in your local repository? That's where [Tokei][2] comes in handy. It's a tool that tells you code statistics about a project, which is especially useful when you want to build a project with people who are proficient in different languages.
### Exploring Tokei
According to its [README][3], "Tokei is a program that displays statistics about your code. Tokei will show the number of files, total lines within those files and code, comments, and blanks grouped by language." The introduction to its v.12.1.0 release [elaborates][4], "Tokei is a fast and accurate code analysis CLI tool and library, allowing you to easily and quickly see how many blank lines, comments, and lines of code are in your codebase." It can identify over 150 programming languages.
```
$ ./tokei ~/exa/src ~/Work/wildfly/jaxrs
==================
Language   Files Lines Code Comments Blank
Java        46    6135  4324  945     632
XML         23    5211  4839  473     224
\---------------------------------
Rust
Markdown
\-----------------------------------
Total
```
### Install Tokei
To install Tokei in Fedora:
```
`$ sudo dnf install tokei`
```
To install it with Rust's Cargo package manager:
```
`$ cargo install tokei`
```
### Use Tokei
To list code statistics for the current directory:
```
$ tokei
===============================================================================
 Language            Files        Lines         Code     Comments       Blanks
===============================================================================
 Ada                    10         2840         1681          560          599
 Assembly                4         2508         1509          458          541
 GNU Style Assembly      4         2751         1528          748          475
 Autoconf               16         2294         1153          756          385
 Automake                1           45           34            0           11
 BASH                    4         1895         1602          133          160
 Batch                   2            4            4            0            0
 C                     330       206433       150241        23402        32790
 C Header              342        60941        24682        29143         7116
 CMake                  48         4572         3459          548          565
 C#                      9         1615          879          506          230
 C++                     5          907          599          136          172
 Dockerfile              2           16           10            0            6
 Fish                    1           87           77            5            5
 HTML                    1          545          544            1            0
 JSON                    5         8995         8995            0            0
 Makefile               10          504          293           72          139
 Module-Definition      12         1183         1046           65           72
 MSBuild                 1          141          140            0            1
 Pascal                  4         1443         1016          216          211
 Perl                    2          189          137           16           36
 Python                  4         1257          949          112          196
 Ruby                    1           23           18            1            4
 Shell                  15         1860         1411          222          227
 Plain Text             35        29425            0        26369         3056
 TOML                   64         3180         2302          453          425
 Visual Studio Pro|     30        14597        14597            0            0
 Visual Studio Sol|      6          655          650            0            5
 XML                     1          116           95           17            4
 YAML                    2           81           56           12           13
 Zsh                     1           59           48            8            3
\-------------------------------------------------------------------------------
 Markdown               55         4677            0         3214         1463
 |- C                    1            2            2            0            0
 |- Rust                19          336          268           20           48
 |- TOML                23           61           60            0            1
 (Total)                           5076          330         3234         1512
\-------------------------------------------------------------------------------
 Rust                  496       210966       188958         5348        16660
 |- Markdown           249        17676         1551        12502         3623
 (Total)                         228642       190509        17850        20283
===============================================================================
 Total                1523       566804       408713        92521        65570
===============================================================================
$
```
The following command prints out the supported languages and extensions:
```
$ tokei -l
ABNF
ABAP
ActionScript
Ada
Agda
Alex
Alloy
Arduino C++
AsciiDoc
ASN.1
ASP
ASP.NET
Assembly
GNU Style Assembly
```
If you run `tokei` on two files and specify their location as an argument, it prints the stats for individual files in a last-in-first-out format:
![Running Tokei on two files][5]
(Sudeshna Sur, [CC BY-SA 4.0][6])
By default, `tokei` outputs only data about the languages used, but using the `--files` flag provides individual file statistics:
```
$ tokei ~/exa/src --files
===========================================================================================
 Language                              Files      Lines      Code             Comments     Blanks
===========================================================================================
 Rust                                   54          9339        7070             400       1869
 |- Markdown                            33          1306           0            1165        141
 (Total)                                           10645        7070        1565       2010
\-------------------------------------------------------------------------------------------
 /home/ssur/exa/src/theme/default_theme.rs           130         107           0         23
 /home/ssur/exa/src/output/render/times.rs            30          24           0          6
 /home/ssur/exa/src/output/render/users.rs            98          76           0         22
 /home/ssur/exa/src/output/render/size.rs            182         141           3         38
 /home/ssur/exa/src/output/render/octal.rs           116          88           0         28
 /home/ssur/exa/src/output/render/mod.rs              33          20           3         10
 /home/ssur/exa/src/output/render/inode.rs            28          20           0          8
 /home/ssur/exa/src/output/render/links.rs            87          65           0         22
 /home/ssur/exa/src/output/render/groups.rs          123          93           0         30
 |ome/ssur/exa/src/output/render/filetype.rs          31          26           0          5
 /home/ssur/exa/src/output/render/blocks.rs           57          40           0         17
 /home/ssur/exa/src/output/render/git.rs             108          87           0         21
 |/ssur/exa/src/output/render/permissions.rs         204         160           3         41
 /home/ssur/exa/src/output/grid.rs                    67          51           3         13
 /home/ssur/exa/src/output/escape.rs                  26          18           4          4
 /home/ssur/exa/src/theme/lsc.rs                     235         158          39         38
 /home/ssur/exa/src/options/theme.rs                 159         124           6         29
 /home/ssur/exa/src/options/file_name.rs              46          39           0          7
 /home/ssur/exa/src/options/flags.rs                  84          63           6         15
 /home/ssur/exa/src/fs/mod.rs                         10           8           0          2
 /home/ssur/exa/src/fs/feature/mod.rs                 33          25           0          8
\-- /home/ssur/exa/src/output/time.rs ---------------------------------------------------------------
 |- Rust                                             215          170          5         40
 |- Markdown                                          28            0         25          3
```
### Conclusion
I found it very easy to use `tokei` to learn more about my code statistics. Another good thing about `tokei` is that it can be used as a library, which makes it easy to integrate into other projects. Visit Tokei's [Crate.io page][7] and [Docs.rs][8] to learn more about its usage. If you would like to get involved, you can also contribute to Tokei through its [GitHub repository][2].
Do you find Tokei useful? Let us know in the comments section below.
--------------------------------------------------------------------------------
via: https://opensource.com/article/21/6/tokei
作者:[Sudeshna Sur][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/sudeshna-sur
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_development_programming_screen.png?itok=BgcSm5Pl (A screen of code.)
[2]: https://github.com/XAMPPRocky/tokei
[3]: https://github.com/XAMPPRocky/tokei/blob/master/README.md
[4]: https://github.com/XAMPPRocky/tokei/releases/tag/v12.1.0
[5]: https://opensource.com/sites/default/files/uploads/tokei-two-files_0.png (Running Tokei on two files)
[6]: https://creativecommons.org/licenses/by-sa/4.0/
[7]: https://crates.io/crates/tokei
[8]: https://docs.rs/tokei/12.1.2/tokei/

View File

@ -0,0 +1,161 @@
[#]: subject: (9 Features in Brave Search That Make it a Great Google Search Alternative)
[#]: via: (https://itsfoss.com/brave-search-features/)
[#]: author: (Ankush Das https://itsfoss.com/author/ankush/)
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
9 Features in Brave Search That Make it a Great Google Search Alternative
======
Brave Search is an ambitious initiative by Brave Software based on the open-source project [Tailcat][1], which tries to take on the big tech by introducing the ability to search anonymously. Brave Search itself is [not open source at the moment][2].
Of course, there are various other [private search engines][3] available out there trying to offer a privacy-focused experience. Even though not every service proves to be better than Google (regarding features), Brave Search seems to be a compelling choice when considering Brave Browser as a successful open-source replacement to Google Chrome.
Here, let me highlight a few features in Brave Search that makes it an interesting alternative to Google Search.
### Top 9 Brave Search Features
Brave Search does a few things better than Google and those are worth highlighting as unique feature offerings that sets it apart.
Brave Search is in beta at the time of writing this article. If you notice something different with your experience, there are chances that they may have made an improvement/change. Let me know in the comments below if thats the case.
#### 1\. Anonymous Search
![][4]
Google tracks your search queries, keeps a log of your history (unless you manually delete it or disable recording your activity). Not just the basics, but your IP address and the website you visit from the search result is also recorded in the process.
In contrast, Brave Search does not track the IP, or the search queries made using their search portal.
You stay completely anonymous, along with your search history being private only to yourself.
This could eliminate the need of using a [secure VPN service][5] to keep your Internet search activity private.
#### 2\. Ad-Free Version (Coming Soon)
![][6]
All the private search engines include advertisements to make money (which is fair). The advertisements used by Google Search include trackers when you click on it, which is not the case with privacy-focused search engines.
But Brave Search tries to go a little further by offering a choice to the users.
It is a feature that has been planned for addition, but it is worth mentioning. If you want to get rid of the ads, you can opt for the paid version of the search engine where you can explore the web ad-free.
I think thats a win-win for both Brave and you as a user. They do not lose on making revenue and you get to experience a truly ad-free search engine.
#### 3\. Community Curated Search Rankings (Coming Soon)
Users can help spot the quality of a web resource better than an algorithm often.
So, Brave Search aims to work on a community-curated search ranking system, which will be open to all when it is available.
This should improve the collaborative approach of exploring the web, which should be an impressive feature of Brave Search.
#### 4\. Independent Index with No Search Algorithm
![][7]
With most of the other search engines, theres an algorithm in place to make sure that only the high-quality web pages rank above the rest. Brave Search does not have any special algorithm controlling the search rankings.
And yes, that is a feature in a world where everything depends on algorithms.
Sometimes that algorithm ends up being biased by ranking plagiarism content first, low-quality web pages, along with a few other issues.
Without any special search algorithm, Brave search uses its own Index to fetch results as per your queries.
#### 5\. Private Local and Global Search Results
![][8]
No matter what region you choose for the search results, you get an additional option to filter your results based on your locality (IP address).
Brave explains that the IP address is stored locally on your device and is used to serve you the local feed of results which sounds useful.
![][9]
#### 6\. Transparency in Search Results
![][10]
The web is a vast network. Therefore, to keep the search result quality resourceful, Brave Search fetches some search results anonymously from Google and Bing (which is often less than 10% in my tests).
For the rest of the results, Brave Search relies on its independent index. Brave Search also displays the percent of its independent search index used for your search.
The more users start using Brave Search, the more independent the search results will become. So thats a good thing.
Considering not all search engines reveal a lot about their search results, Transparency, as a principle, can be a feature to compare with when choosing a search engine.
![][11]
#### [Brave: Open Source Web Browser That Blocks Ads and Tracking By Default][12]
An open source web browser that blocks ads and tracking. A good choice if you are looking for a privacy focused web browser. Heres how to install Brave on Linux.
#### 7\. A Refreshing User Interface
While every other Google search alternative tries to offer a familiar experience, Brave Search is actually refreshing to look at (in my opinion).
![][13]
The user interface looks well-thought and offers a modern, clean experience. Dont you think?
I like how DuckDuckGo simplifies things, but Brave certainly makes it up for a better user experience that looks unique and clean.
#### 8\. No Anti-Competitive Nature
Unlike some other search engines (especially, Google) do not suggest anything else explicitly, except their own products and services in their search results.
Thats fair but potentially also anti-competitive, being the most popular search engine. They do have their reasons which we dont have to talk about here, but giving a shout-out to your competitors is something new businesses/services are adopting.
![][14]
And Brave Search does an excellent jobat that. While you scroll through the search results, you will find a choice to use other search engines for your search query.
#### 9\. Dark Mode &amp; Tweaks
Yes, the dark mode is an important feature (sigh).
![][15]
And from the settings available in Brave Search, you can **turn on the dark mode**, **set links to open in a new tab,** and **control the language** (soon).
![][16]
### Wrapping Up
Brave Search is an interesting private search engine that aims to tackle the Big Tech by offering something new. It should be seamless user experience when [using Brave Browser][12] along with it, but you can use it on any browser without any limitations.
I like what I see here, what do you think? Let me know your thoughts in the comments below.
--------------------------------------------------------------------------------
via: https://itsfoss.com/brave-search-features/
作者:[Ankush Das][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/ankush/
[b]: https://github.com/lujun9972
[1]: https://www.tailcat.com
[2]: https://www.reddit.com/r/brave_browser/comments/o5qknc/announcement_brave_search_beta_now_available_in/h2p3q22?utm_source=share&utm_medium=web2x&context=3
[3]: https://itsfoss.com/privacy-search-engines/
[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/06/brave-search-anonymous.png?resize=800%2C530&ssl=1
[5]: https://itsfoss.com/best-vpn-linux/
[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/paid-no-ads-brave.png?resize=800%2C450&ssl=1
[7]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/brave-search-sample.png?resize=800%2C586&ssl=1
[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/brave-local-global-search.png?resize=800%2C228&ssl=1
[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/brave-anonymous-local-results.png?resize=800%2C589&ssl=1
[10]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/brave-search-transparency.png?resize=800%2C654&ssl=1
[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/09/brave-browser-1-e1573731875389.jpeg?resize=150%2C150&ssl=1
[12]: https://itsfoss.com/brave-web-browser/
[13]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/brave-search-ui.png?resize=800%2C590&ssl=1
[14]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/06/brave-search-competitors.png?resize=800%2C502&ssl=1
[15]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/brave-search-dark-mode.png?resize=800%2C573&ssl=1
[16]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/brave-search-settings.png?resize=483%2C389&ssl=1

View File

@ -0,0 +1,137 @@
[#]: subject: (How to program in C on FreeDOS)
[#]: via: (https://opensource.com/article/21/6/program-c-freedos)
[#]: author: (Jim Hall https://opensource.com/users/jim-hall)
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
How to program in C on FreeDOS
======
Programming in C on FreeDOS is very similar to C programming on Linux.
![Woman sitting in front of her computer][1]
When I first started using DOS, I enjoyed writing games and other interesting programs using BASIC, which DOS included. Much later, I learned the C programming language.
I immediately loved working in C! It was a straightforward programming language that gave me a ton of flexibility for writing useful programs. In fact, much of the FreeDOS core utilities are written in C and Assembly.
So it's probably not surprising that FreeDOS 1.3 RC4 includes a C compiler—along with other programming languages. The FreeDOS 1.3 RC4 LiveCD includes two C compilers—Bruce's C compiler (a simple C compiler) and the OpenWatcom C compiler. On the Bonus CD, you can also find DJGPP (a 32-bit C compiler based on GNU GCC) and the IA-16 port of GCC (requires a '386 or better CPU to compile, but the generated programs can run on low-end systems).
Programming in C on FreeDOS is basically the same as C programming on Linux, with two exceptions:
1. **You need to remain aware of how much memory you use.** Linux allows programs to use lots of memory, but FreeDOS is more limited. Thus, DOS programs used one of four [memory models][2] (large, medium, compact, and small) depending on how much memory they needed.
2. **You can directly access the console.** On Linux, you can create _text-mode_ mode programs that draw to the terminal screen using a library like _ncurses_. But DOS allows programs to access the console and video hardware. This provides a great deal of flexibility in writing more interesting programs.
I like to write my C programs in the IA-16 port of GCC, or OpenWatcom, depending on what program I am working on. The OpenWatcom C compiler is easier to install since it's only a single package. That's why we provide OpenWatcom on the FreeDOS LiveCD, so you can install it automatically if you choose to do a "Full installation including applications and games" when you install FreeDOS 1.3 RC4. If you opted to install a "Plain DOS system," then you'll need to install the OpenWatcom C compiler afterward, using the FDIMPLES package manager.
![installing OpenWatcom][3]
Installing OpenWatcom on FreeDOS 1.3 RC4
(Jim Hall, [CC-BY SA 4.0][4])
### DOS C programming
You can find documentation and library guides on the [OpenWatcom project website][5] to learn all about the unique DOS C programming libraries provided by the OpenWatcom C compiler. To briefly describe a few of the most useful functions:
From `conio.h`:
* `int getch(void)—`Get a single keystroke from the keyboard
* `int getche(void)—`Get a single keystroke from the keyboard, and echo it
From `graph.h`:
* `_settextcolor(short color)—`Sets the color when printing text
* `_setbkcolor(short color)—`Sets the background color when printing text
* `_settextposition(short y, short x)—`Move the cursor to row `y` and column `x`
* `_outtext(char _FAR *string)—`Print a string directly to the screen, starting at the current cursor location
DOS only supports [sixteen text colors][6] and eight background colors. You can use the values 0 (Black) to 15 (Bright White) to specify the text colors, and 0 (Black) to 7 (White) for the background colors:
* **0**—Black
* **1**—Blue
* **2**—Green
* **3**—Cyan
* **4**—Red
* **5**—Magenta
* **6**—Brown
* **7**—White
* **8**—Bright Black
* **9**—Bright Blue
* **10**—Bright Green
* **11**—Bright Cyan
* **12**—Bright Red
* **13**—Bright Magenta
* **14**—Yellow
* **15**—Bright White
### A fancy "Hello world" program
The first program many new developers learn to write is a program that just prints "Hello world" to the user. We can use the DOS "conio" and "graphics" libraries to make this a more interesting program and print "Hello world" in a rainbow of colors.
In this case, we'll iterate through each of the text colors, from 0 (Black) to 15 (Bright White). As we print each line, we'll indent the next line by one space. When we're done, we'll wait for the user to press any key, then we'll reset the screen and exit.
You can use any text editor to write your C source code. I like using a few different editors, including [FreeDOS Edit][7]** **and [Freemacs][8], but more recently I've been using the [FED editor][9] because it provides _syntax highlighting_, making it easier to see keywords, strings, and variables in my program source code.
![writing a simple C program][10]
Writing a simple test program in C
(Jim Hall, [CC-BY SA 4.0][4])
Before you can compile using OpenWatcom, you'll need to set up the DOS [environment variables][11]** **so OpenWatcom can find its support files. The OpenWatcom C compiler package includes a setup [batch file][12] that does this for you, as `\DEVEL\OW\OWSETENV.BAT`. Run this batch file to automatically set up your environment for OpenWatcom.
Once your environment is ready, you can use the OpenWatcom compiler to compile this "Hello world" program. I've saved my C source file as `TEST.C`, so I can type `WCL TEST.C` to compile and link the program into a DOS executable, called `TEST.EXE`. In the output messages from OpenWatcom, you can see that `WCL` actually calls the OpenWatcom C Compiler (`WCC`) to compile, and the OpenWatcom Linker (`WLINK`) to perform the object linking stage:
![compiling with OpenWatcom][13]
Compiling the test program with OpenWatcom
(Jim Hall, [CC-BY SA 4.0][4])
OpenWatcom prints some extraneous output that may make it difficult to spot errors or warnings. To tell the compiler to suppress most of these extra messages, use the `/Q` ("Quiet") option when compiling:
![compiling with OpenWatcom][14]
If you don't see any error messages when compiling the C source file, you can now run your DOS program. This "Hello world" example is `TEST.EXE`. Enter `TEST` on the DOS command line to run the new program, and you should see this very pretty output:
![running the test program][15]
C is a very efficient programming language that works well for writing programs on limited-resource systems like DOS. There's lots more that you can do by programming in C on DOS. If you're new to the C language, you can learn C yourself by following along in our [Writing FreeDOS Programs in C][16] self-paced ebook on the FreeDOS website, and the accompanying "how-to" video series on the [FreeDOS YouTube channel][17].
--------------------------------------------------------------------------------
via: https://opensource.com/article/21/6/program-c-freedos
作者:[Jim Hall][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/jim-hall
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_women_computing_2.png?itok=JPlR5aCA (Woman sitting in front of her computer)
[2]: https://devblogs.microsoft.com/oldnewthing/20200728-00/?p=104012
[3]: https://opensource.com/sites/default/files/uploads/install-ow.png (Installing OpenWatcom on FreeDOS 1.3 RC4)
[4]: https://creativecommons.org/licenses/by-sa/4.0/
[5]: http://openwatcom.org/
[6]: https://opensource.com/article/21/6/freedos-sixteen-colors
[7]: https://opensource.com/article/21/6/freedos-text-editor
[8]: https://opensource.com/article/21/6/freemacs
[9]: https://opensource.com/article/21/1/fed-editor
[10]: https://opensource.com/sites/default/files/uploads/fed-test.png (Writing a simple test program in C)
[11]: https://opensource.com/article/21/6/freedos-environment-variables
[12]: https://opensource.com/article/21/6/automate-tasks-bat-files-freedos
[13]: https://opensource.com/sites/default/files/uploads/wcl-test.png (Compiling the test program with OpenWatcom)
[14]: https://opensource.com/sites/default/files/uploads/wcl-q-test.png (Use the /Q ("Quiet") option to make OpenWatcom print less output)
[15]: https://opensource.com/sites/default/files/uploads/test.png (You can create beautiful programs in C)
[16]: https://www.freedos.org/books/cprogramming/
[17]: https://www.youtube.com/freedosproject

View File

@ -0,0 +1,87 @@
[#]: subject: (Mount cue/bin image files with CDemu)
[#]: via: (https://fedoramagazine.org/mount-cue-bin-image-files-with-cdemu/)
[#]: author: (Luca Rastelli https://fedoramagazine.org/author/luca247/)
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
Mount cue/bin image files with CDemu
======
![][1]
Photo by [Cameron Bunney][2] on [Unsplash][3]
The other day I needed to burn a disc. Yeah, I know, some of you might be wondering, “A disc? Whats that?” Others might ask, “Are you really using that archaic media?”
Well, yes I am. I feel there is still something charming about physical things that digital media cannot replace.
I needed to burn a very old game that was comprised of a [cue file][4], some audio tracks in [cda format][5], and a [bin file][6] which stored all the binary content that was indexed by the cue file.
First I tried to use [Brasero][7]. Yeah I know, its old but it does the job generally and it fits with the rest of the system, so its my choice generally. Unfortunately, this time it was not up to the task. It stated that it had some problems reading the cue file. Then I tried [Xfburn][8] and [K3b][9]. But neither of those worked either. They both detected the bin file but not the cda files.
Next, I searched on the web and I found lots of posts explaining how to burn image files using command line applications. Or how to create [iso images][10] and then write those out to discs. These methods seemed excessively complex for what I wanted to do. Why all that difficulty for a task that should be easy as clicking on a button? Fedora Linux should be about freedom, not about difficulties! Although it can be used by experts, an easy way of doing things is always appreciated.
I had almost surrendered. Then, in a forum post buried under all the suggestions mentioned previously, I found the answer I was looking for [CDemu][11].
Those familiar with [Daemon Tools][12] may find CDemu to be similar. I find CDemu to be even easier and far less bloated. With CDemu, you can mount cue images with the classic double-click. Sounds easy? Well thats because it actually is.
CDemu is not present in Fedora Linuxs default repositories. So if you want to try it out, you will have to use the [rok/cdemu][13] Copr repository that is compatible with your version of Fedora Linux.
**Note**: _Copr is not officially supported by Fedora infrastructure. Use packages at your own risk._
Open a terminal and enable the Copr repo by entering the following command.
```
$ sudo dnf copr enable rok/cdemu
```
Then install the daemon and the clients by entering the following commands.
```
$ sudo dnf install cdemu-daemon
$ sudo dnf install cdemu-client
$ sudo dnf install gcdemu
```
Next, enter the following commands to ensure the right kernel module is available and loaded.
```
$ sudo akmods
$ sudo systemctl restart systemd-modules-load.service
```
Now CDemu is installed. To associate it with your CD images, you just need to right-click on a file type that you want to mount with CDemu, select _properties_, and the select _Open with CDemu_. Now, double-clicking on those image types should mount them in Nautilus like a physical drive.
If you need to burn the image (like I did), open Brasero and select _copy disc_.
CDemu can also be run from the command line. But this guide was all about getting easy, right?
--------------------------------------------------------------------------------
via: https://fedoramagazine.org/mount-cue-bin-image-files-with-cdemu/
作者:[Luca Rastelli][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://fedoramagazine.org/author/luca247/
[b]: https://github.com/lujun9972
[1]: https://fedoramagazine.org/wp-content/uploads/2021/06/cdemu-816x345.jpg
[2]: https://unsplash.com/@bdbillustrations?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText
[3]: https://unsplash.com/s/photos/dvd?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText
[4]: https://en.wikipedia.org/wiki/Cue_sheet_(computing)
[5]: https://en.wikipedia.org/wiki/.cda_file
[6]: https://en.wikipedia.org/wiki/Binary_file
[7]: https://en.wikipedia.org/wiki/Brasero_(software)
[8]: https://en.wikipedia.org/wiki/Xfce#Xfburn
[9]: https://en.wikipedia.org/wiki/K3b
[10]: https://en.wikipedia.org/wiki/Optical_disc_image
[11]: https://en.wikipedia.org/wiki/CDemu
[12]: https://en.wikipedia.org/wiki/Daemon_Tools
[13]: https://copr.fedorainfracloud.org/coprs/rok/cdemu/

View File

@ -0,0 +1,205 @@
[#]: subject: (Use Python to parse configuration files)
[#]: via: (https://opensource.com/article/21/6/parse-configuration-files-python)
[#]: author: (Moshe Zadka https://opensource.com/users/moshez)
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
Use Python to parse configuration files
======
The first step is choosing a configuration format: INI, JSON, YAML, or
TOML.
![Python programming language logo with question marks][1]
Sometimes, a program needs enough parameters that putting them all as command-line arguments or environment variables is not pleasant nor feasible. In those cases, you will want to use a configuration file.
There are several popular formats for configuration files. Among them are the venerable (although occasionally under-defined) `INI` format, the popular but sometimes hard to write by hand `JSON` format, the extensive yet occasionally surprising in details `YAML` format, and the newest addition, `TOML`, which many people have not heard of yet.
Your first task is to choose a format and then to document that choice. With this easy part out of the way, it is time to parse the configuration.
It is sometimes a good idea to have a class that corresponds to the "abstract" data in the configuration. Because this code will do nothing with the configuration, this is the simplest way to show parsing logic.
Imagine the configuration for a file processor: it includes an input directory, an output directory, and which files to pick up.
The abstract definition for the configuration class might look something like:
```
`from __future__ import annotations`[/code] [code]
import attr
@attr.frozen
class Configuration:
    @attr.frozen
    class Files:
        input_dir: str
        output_dir: str
    files: Files
    @attr.frozen
    class Parameters:
        patterns: List[str]
    parameters: Parameters
```
To make the format-specific code simpler, you will also write a function to parse this class out of dictionaries. Note that this assumes the configuration will use dashes, not underscores. This kind of discrepancy is not uncommon.
```
def configuration_from_dict(details):
    files = Configuration.Files(
        input_dir=details["files"]["input-dir"],
        output_dir=details["files"]["output-dir"],
    )
    parameters = Configuration.Paraneters(
        patterns=details["parameters"]["patterns"]
    )
    return Configuration(
        files=files,
        parameters=parameters,
    )
```
### JSON
JSON (JavaScript Object Notation) is a JavaScript-like format.
Here is an example configuration in JSON format:
```
json_config = """
{
    "files": {
        "input-dir": "inputs",
        "output-dir": "outputs"
    },
    "parameters": {
        "patterns": [
            "*.txt",
            "*.md"
        ]
    }
}
"""
```
The parsing logic parses the JSON into Python's built-in data structures (dictionaries, lists, strings) using the `json` module and then creates the class from the dictionary:
```
import json
def configuration_from_json(data):
    parsed = json.loads(data)
    return configuration_from_dict(parsed)
```
### INI
The INI format, originally popular on Windows, became a de facto configuration standard.
Here is the same configuration as an INI:
```
ini_config="""
[files]
input-dir = inputs
output-dir = outputs
[parameters]
patterns = ['*.txt', '*.md']
"""
```
Python can parse it using the built-in `configparser` module. The parser behaves as a `dict`-like object, so it can be passed directly to `configuration_from_dict`:
```
import configparser
def configuration_from_ini(data):
    parser = configparser.ConfigParser()
    parser.read_string(data)
    return configuration_from_dict(parser)
```
### YAML
YAML (Yet Another Markup Language) is an extension of JSON that is designed to be easier to write by hand. It accomplishes this, in part, by having a long specification.
Here is the same configuration in YAML:
```
yaml_config = """
files:
  input-dir: inputs
  output-dir: outputs
parameters:
  patterns:
  - '*.txt'
  - '*.md'
"""
```
For Python to parse this, you will need to install a third-party module. The most popular is `PyYAML` (`pip install pyyaml`). The YAML parser also returns built-in Python data types that can be passed to `configuration_from_dict`. However, the YAML parser expects a stream, so you need to convert the string into a stream.
```
import io
import yaml
def configuration_from_yaml(data):
    fp = io.StringIO(data)
    parsed = yaml.safe_load(fp)
    return configuration_from_dict(parsed)
```
### TOML
TOML (Tom's Own Markup Language) is designed to be a lightweight alternative to YAML. The specification is shorter, and it is already popular in some places (for example, Rust's package manager, Cargo, uses it for package configuration).
Here is the same configuration as a TOML:
```
toml_config = """
[files]
input-dir = "inputs"
output-dir = "outputs"
[parameters]
patterns = [ "*.txt", "*.md",]
"""
```
In order to parse TOML, you need to install a third-party package. The most popular one is called, simply, `toml`. Like YAML and JSON, it returns basic Python data types.
```
import toml
def configuration_from_toml(data):
    parsed = toml.loads(data)
    return configuration_from_dict(parsed)
```
### Summary
Choosing a configuration format is a subtle tradeoff. However, once you make the decision, Python can parse most of the popular formats using a handful of lines of code.
--------------------------------------------------------------------------------
via: https://opensource.com/article/21/6/parse-configuration-files-python
作者:[Moshe Zadka][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/moshez
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/python_programming_question.png?itok=cOeJW-8r (Python programming language logo with question marks)

View File

@ -0,0 +1,161 @@
[#]: subject: (How I helped my mom switch from Windows to Linux)
[#]: via: (https://opensource.com/article/21/6/mom-switch-linux)
[#]: author: (Tomasz https://opensource.com/users/tomaszwaraksa)
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
How I helped my mom switch from Windows to Linux
======
With Linux, novice users will gain a smooth, polished desktop experience
with a multitude of familiar applications.
![Red Lego Heart][1]
The Large Hadron Collider is [powered by Linux][2]. Laptops on the International Space Station [run on Linux][3]. So do [Instagram][4] and [Nest thermostats][5]. Recently, we watched Ingenuity fly over Mars, an amazing robo-copter driven by… [Linux][6]! It's yet more proof of how flexible and versatile this operating system can be.
But now, the really big news. It's official. Linux can handle Mom and Dad just as well!
### The story
About a year ago, I decided to migrate my mom to Linux. A year has passed, so it's time for retrospection and conclusions.
Like most of us, I'm officially _Mom's Computer Admin_. Mom is a lovely lady in her late 60s—a real sweetheart. Mom's computer skills are basic. Mom's computer needs are basic, too. Read the internets, send email, type text, browse and edit photos, play videos and music, call family and friends on Skype or Signal.
Until last year, she was using a Windows laptop, old but not too bad. Then one day, through deceit, threats, and obnoxious popups, Microsoft finally made her click that dreaded "UPGRADE TO WINDOWS 10" button.
My life as Mom's Computer Admin quickly turned into hell with her desperate calls for help. Why does everything look so different? Where is my app menu? What, this pile of tiles is now my app menu? Why is the computer so slow? Why does it restart daily for updates, just when I need to use it?! Why is something (she meant the hard drive) making noise all the time? What is it actually doing all the time?
And how would I know that without any ability to look into the source code?
I considered rolling back the upgrade. But with Windows 7 reaching end-of-life soon, I feared the worst: Without security updates, Mom's computer would soon become a member of countless bot networks, mining cryptocurrencies, mailing spam, and launching vicious DDOS attacks on the vital infrastructure of entire countries. And I'd be the one to clean this mess—every weekend.
### Linux to the rescue
With nothing to lose, I decided to migrate her to Linux. I made "the move" five years ago and have never been happier. It surely wouldn't do harm to try it with her.
Mom was happy when I declared to fix her problems once and for all. What she didn't know is that she would become the crucial part of a year-long scientific experiment named: "Can Mom survive Linux?"
![Cowsay "Can Mom Survive Linux?"][7]
(Tomasz Waraksa, [CC BY-SA 4.0][8])
And so, one day in February 2020, I arrived from faraway Dublin with a seven-year-old Lenovo Yoga 13, which had similar specs but a much nicer screen and half the weight. After some deliberations and testing various Linux distributions on VirtualBox, I decided on the [Zorin OS][9] distribution, proudly made in Ireland. My choice was driven by the following factors:
* It's based on Ubuntu Linux, with which I'm most familiar.
* It closely resembles Windows 7, being carefully designed with Windows refugees in mind.
* It feels lightweight, simple, and sufficiently conservative for Mom. No shiny macOS Big Sur glitz anywhere around!
![Zorin OS desktop][10]
(Tomasz Waraksa, [CC BY-SA 4.0][8])
### System installation
I installed the operating system my usual way, with the `/home` folder on a dedicated partition to keep Mom's Stuff safe in the unlikely case of system reinstallation. It's my old trick that makes late-night distro-hopping much easier.
During installation, I chose Polish as the user interface (UI) language. Just like me, Mom is Polish to the bone. No worries, Linux seems to support every possible language, including [Klingon][11].
Then, I installed the following applications to cover Mom's needs:
* Skype
* [Signal for Desktop][12]
* Google Chrome browser
* [Geary][13] email client
* [gThumb][14] for photo viewing and editing
* [VLC][15] for playing video and music
* Softmaker Office for text editing and spreadsheets
Notice how there's no antivirus on the list. Yay!
An hour later, her Zorin OS box was ready and loaded with applications.
![Zorin OS home folder][16]
(Tomasz Waraksa, [CC BY-SA 4.0][8])
### System configuration
I made myself Mom's Computer Admin by doing the following:
* Created an admin account for myself
* Turned Mom's account into non-admin
* Installed the `ssh` daemon for remote unattended access
* Added the machine to my Hamachi VPN: This way, I can securely connect via `ssh` without opening port 22 on the router. Hamachi is a VPN service by LogMeIn. An old-school VPN, I mean. Intended not for running Netflix from another country but for connecting computers into a secure network over the internet.
* Enabled Uncomplicated Firewall ( `ufw`) and allowed ssh traffic
* Installed AnyDesk for logging in to the desktop
With this, I have secure ssh access to Mom's laptop. I can perform periodic maintenance via shell without Mom even noticing anything. That's because Linux normally _does not_ require a reboot after completed updates; what a miracle, how's that even possible?
![Updating software remotely][17]
(Tomasz Waraksa, [CC BY-SA 4.0][8])
### Can Mom survive Linux?
Without the slightest doubt!
When I showed Mom her new PC, she did ask why this new Windows looked different _again_. I had to reveal that this is not Windows at all, but Linux, and explain why we all love Linux. But she picked it up quickly. The classic Zorin OS desktop is very much like her old Windows 7. I watched her find her way through the system and launch her familiar applications with ease.
She immediately noticed how much faster the computer starts and how much better it performs.
She's been asking me when I will do the usual computer cleanup so that it doesn't become slow again. I've explained that, with her average use, it won't be needed. Linux simply doesn't rot on its own as Windows does. So far, this has been true. Her PC runs as smooth and fast as on day one.
Every now and then, I ask how she feels about her new computer. She invariably answers that she's happy with it. Everything works smoothly. The computer doesn't get busy for no reason. No more interrupting her with Very Important Updates. And the menu is where it should always be. She's comfortable with her usual applications in this entirely new environment.
Over the year, I've logged in remotely a few times to run routine package upgrades. I've logged in with AnyDesk twice. Once, when Mom asked whether photos from an inserted SD card could be imported automatically into the `~/Pictures` folder, and preferably into folders named by dates. Yes, `gThumb` can easily be made to do that with a bit of Bash. Another time, I logged in to add frequently used websites as desktop icons.
And this has been all of my effort as Mom's Linux Admin so far! At this pace, I could be Mom's Computer Admin to 50 other moms!
### Summary
I hope that my story will inspire you to think about migrating to Linux. In the past, we considered Linux to be too difficult for casual users. But today I believe that the opposite is true. The less proficient computer users are, the more reasons they have to migrate to Linux!
With Linux, novice users will gain a smooth, polished desktop experience with a multitude of familiar applications. They will be much safer than on any other popular computing platform. And helping them with remote access has never been easier and more secure!
_Disclaimer: This article is not promoting any of the described products, services, or vendors. I don't have any commercial interest nor associations with them. I'm not trying to suggest that these products or services are best for you, nor promising that your experience will be the same._
* * *
_This article originally appeared on [Let's Debug It][18] and is reused with permission._
Sandstorm's Jade Wang shares some of her favorite open source web apps that are self-hosted...
--------------------------------------------------------------------------------
via: https://opensource.com/article/21/6/mom-switch-linux
作者:[Tomasz][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/tomaszwaraksa
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/heart_lego_ccby20.jpg?itok=VRpHf4iU (Red Lego Heart)
[2]: https://www.redhat.com/en/about/press-releases/red-hat-provides-cern-platform-mission-critical-applications
[3]: https://www.extremetech.com/extreme/155392-international-space-station-switches-from-windows-to-linux-for-improved-reliability
[4]: https://instagram-engineering.com/what-powers-instagram-hundreds-of-instances-dozens-of-technologies-adf2e22da2ad
[5]: https://www.theverge.com/2011/11/14/2559567/tony-fadell-nest-learning-thermostat
[6]: https://www.zdnet.com/article/to-infinity-and-beyond-linux-and-open-source-goes-to-mars/
[7]: https://opensource.com/sites/default/files/uploads/intro.png (Cowsay "Can Mom Survive Linux?")
[8]: https://creativecommons.org/licenses/by-sa/4.0/
[9]: https://zorinos.com/
[10]: https://opensource.com/sites/default/files/uploads/zorin-os-desktop.png (Zorin OS desktop)
[11]: https://blogs.gnome.org/muelli/2010/04/klingon-language-support/
[12]: https://github.com/signalapp
[13]: https://wiki.gnome.org/Apps/Geary
[14]: https://wiki.gnome.org/Apps/Gthumb
[15]: https://www.videolan.org/vlc/
[16]: https://opensource.com/sites/default/files/uploads/zorin-os-home-folder.png (Zorin OS home folder)
[17]: https://opensource.com/sites/default/files/uploads/upgrading-software.png (Updating software remotely)
[18]: https://letsdebug.it/post/16-linux-for-mars-copters-moms-and-pops/

View File

@ -0,0 +1,137 @@
[#]: subject: (How to Convert File Formats With Pandoc in Linux [Quick Guide])
[#]: via: (https://itsfoss.com/pandoc-convert-file/)
[#]: author: (Bill Dyer https://itsfoss.com/author/bill/)
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
How to Convert File Formats With Pandoc in Linux [Quick Guide]
======
In an earlier article, I covered the [procedure to batch convert a handful of Markdown files to HTML][1] using pandoc. In that article, multiple HTML files were created, but pandoc can do much more. It has been called “the Swiss army knife” of document conversion and with good reason. There isnt a lot that it cant do.
[Pandoc][2] can covert .docx, .odt, .html, .epub, LaTeX, DocBook, etc. to these and other formats, such as JATS, TEI Simple, AsciiDoc, and more.
Yes, this means that pandoc can convert .docx files to .pdf and .html, but you may be thinking: “Word can export files to .pdf and .html too. Why would I need pandoc?”
You would have a good point there, but since pandoc can convert so many formats, it could well become your go-to tool for all of your conversion tasks. For example, many of us know that [Markdown editors][3] can export its Markdown files to .html. With pandoc, Markdown files can be converted to numerous other formats as well.
I rarely have Markdown export to HTML; I normally let pandoc do it.
### Converting File Formats with Pandoc
![][4]
Here, I will convert Markdown files into a few different formats. I do almost all of my writing using Markdown syntax, but I often have to convert to another format: .docx files are usually required for school work, .html for web pages that I create and for .epub work, .pdf for flyers and handouts, and even an occasional TEI Simple file for a university digital humanities project. Pandoc can handle all of these, and more, easily.
First, you need to [install pandoc][5]. Also, to create .pdf files, LaTeX will be needed as well. The package I prefer is [TeX Live][6].
**Note**: If you would like to try out pandoc before installing it, there is an online try-out page at: <http://pandoc.org/try/>
#### Installing pandoc and texlive
Users of Ubuntu and other Debian distros can type the following commands in the terminal:
```
sudo apt-get update
sudo apt-get install pandoc texlive
```
Notice on the second line, you are installing pandoc and texlive in one shot. [apt-get command][7] will have no problem with this, but go get some coffee; this may take a few minutes.
#### Getting to Conversion
Once pandoc and texlive are installed, you can burn through some work!
The sample document for this project will be an article that was first published in the _North American Review_ in December of 1894, and is titled: “How To Repel Train Robbers”. The Markdown file that I will be using was created some time ago as part of a restoration project.
The file: `how_to_repel_train_robbers.md` is located in my Documents directory, in a sub-directory named samples. Here is what it looks like in Ghostwriter.
![Markdown file in Ghostwriter][8]
I want to create .docx, .pdf, and .html versions of this file.
#### The First Conversion
Ill start with making a .pdf copy first, since I went through the trouble of installing a LaTeX package.
While in the ~/Documents/samples/ directory, I type the following to create a .pdf file:
```
pandoc -o htrtr.pdf how_to_repel_train_robbers.md
```
The above command will create a file called htrtr.pdf from the how_to_repel_train_robbers.md file. The reason I used htrtr as a name was that it is shorter than how_to_repel_train_robbers htrtr is the first letter of each word in the long title.
Here is a snapshot of the .pdf file once it is made:
![Converted PDF file viewed in Ocular][9]
#### The Second Conversion
Next, I want to create a .docx file. The command is almost identical to the one I used to create the .pdf and it is:
```
pandoc -o htrtr.docx how_to_repel_train_robbers.md
```
In no time, a .docx file is created. Here is what it looks like in Libre Writer:
![Converted DOCX file viewed in Libre Writer][10]
#### The Third Conversion
I may want to post this on the web, so a web page would be nice. I will create a .html file with this command:
```
pandoc -o htrtr.html how_to_repel_train_robbers.md
```
Again, the command to create it is very much like the last two conversions. Here is what the .html file looks like in a browser:
![Converted HTML file viewed in Firefox][11]
#### Noticed Anything Yet?
Lets look at the past commands again. They were:
```
pandoc -o htrtr.pdf how_to_repel_train_robbers.md
pandoc -o htrtr.docx how_to_repel_train_robbers.md
pandoc -o htrtr.html how_to_repel_train_robbers.md
```
The only thing different about these three commands is the extension next to htrtr. This gives you a hint that pandoc relies on the extension of the output filename you provide.
### Conclusion
Pandoc can do far more than the three little conversions done here. If you write with a preferred format, but need to convert the file to another format, chances are great that pandoc will be able to do it for you.
What would you do with this? Would you automate this? What if you had a web site that had articles for your readers to download? You could modify these little commands to work as a script and your readers could decide which format they would like. You could offer .docx, .pdf, .odt, .epub, or more. Your readers choose, the proper conversion script runs, and your readers download their file. It can be done.
--------------------------------------------------------------------------------
via: https://itsfoss.com/pandoc-convert-file/
作者:[Bill Dyer][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/bill/
[b]: https://github.com/lujun9972
[1]: https://itsfoss.com/convert-markdown-files/
[2]: https://pandoc.org/
[3]: https://itsfoss.com/best-markdown-editors-linux/
[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/pandoc-quick-guide.png?resize=800%2C450&ssl=1
[5]: https://pandoc.org/installing.html
[6]: https://www.tug.org/texlive/
[7]: https://itsfoss.com/apt-get-linux-guide/
[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/convert_with_pandoc_ghostwriter.png?resize=800%2C516&ssl=1
[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/convert_with_pandoc_ocular.png?resize=800%2C509&ssl=1
[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/convert_with_pandoc_libre_writer.png?resize=800%2C545&ssl=1
[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/convert_with_pandoc_firefox.png?resize=800%2C511&ssl=1

View File

@ -1,106 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (littlebirdnest)
[#]: reviewer:
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (FCC auctions should be a long-term boost for 5G availability)
[#]: via: (https://www.networkworld.com/article/3584072/fcc-auctions-should-be-a-long-term-boost-for-5g-availability.html)
[#]: author: (Jon Gold https://www.networkworld.com/author/Jon-Gold/)
美国联邦通讯委员的拍卖是长期的有助于5G普及
======
美国联邦通讯委员新的决策——让更多的频段能够被用于通信
在5G的竞争当中为了让5G的能力完全发挥出来增加频谱是非常有必要的 美国联邦通讯委员也知晓这一点
什么是5G 给企业和手机更快的传输速度
5G频率是如何影响5G范围和5G的速度的
5G能够解决哪些WiFi无法解决的问题
5G能够让Whirlpool无人驾驶汽车继续运转
5G能够让网络回传更有效率
公民的宽带无线服务将5G带给企业
美国联邦通讯委员近日完成了对公民的宽带无线服务5G频谱的拍卖---3.5GHz中的70MHz
砸进去了45.8个亿的目的,和以往的拍卖不同的地方在于,能腾出更多的频段用于无线传输
FCC 在 2011 2014和2015年拍卖了 65MHz 的低中频大致在1.7GHz至2.2GHz例如现在的700MHz。但是现在可操作的范围的频段是低于6GHz频段或中间频段刚好是CMRS拍卖的部分,即将到来的C频段拍卖将会是重要一环根据专家猜测将会有巨大的280MHz频段进行拍卖
C频段的拍卖将会很有价值” IDC的研究主管Jasom leigh说到
中频段在美国是极稀有的,这也就是为什么人们会如此积极
然而主要的移动数据提供商仍然希望抢到这次拍卖中的最大份额,
企业会对新的频段实施一系列的创新,同样将会与运营商竞争一系列可用的频率
特别是物联网资产追踪以及其他的个人应用早已通过LTE网络实现而5G网络将会有扩大他们的范围这多亏了 5G的频谱共享低延迟多连接的特性。广义讲能替代更多当前需要线的设备如工业上的自动化设备的管理等等
重新分配频段就意味着谈判
对于想要改变美国的频段优先事项上的问题绝非小事FCC此前的主席Tom Wheeler对此绝对深有体会过去10年里政府一直在推动重新分配频段而享有频段者的大多是政府机构或者是卫星网络运营商商
这些频段享有者被分配到不同频段,常以纳税人的税进行补偿,然后让更多的人进行享用,然而这一过程通常是困难的
并指出“ FCC现在要面临的其中一个挑战就是分配频段从原本的模拟信号变成数字信号” 类似于模拟电视变成数字电视
当模拟电视要求上到6MHz频段以及要求更宽的宽带去避免冲突数字信号却能够在一个频率里有5个信号
这一系列变革是具有挑战性的反对者义不容辞公开反对FCC进入中频宽带并说明这样做会干涉他们原有的设备和服务也意味着更换频率就等于买新的设备
公司讨论过,事实上其中一个较大的原因是监管层的问题,没人想放弃现有体系下基于模拟信号的工作岗位” Wheeler说到“我觉得你应该考虑周全但我发现那些所谓宣称信号冲突的人其实并不关心来自竞争的威胁或者其他事物的威胁。
未来:更多的服务
将中频段开放给企业和运营商对美国商业将会有更多潜在的优势无论是具体是哪一个频段开放根据Leigh的说法美国应该根据拍卖的形式来分配无线频段,像德国就早已设立专门的中频段来给企业使用
对于一家试图推出自己的私有 5G 网络的公司,就可能推高拍卖的价格,但最终,一定要让这项服务存在,无论是内部供应服务还是移动运营商贩卖服务,只要他们有足够的频段使用
“企业能够围绕5G做更加有科技含量的事物”他说到
via: https://www.networkworld.com/article/3584072/fcc-auctions-should-be-a-long-term-boost-for-5g-availability.html
作者:[Jon Gold][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/littlebirdnest)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.networkworld.com/author/Jon-Gold/
[b]: https://github.com/lujun9972
[1]: https://www.flickr.com/photos/fccdotgov/4808818548/
[2]: https://www.networkworld.com/article/3203489/what-is-5g-fast-wireless-technology-for-enterprises-and-phones.html
[3]: https://www.networkworld.com/article/3568253/how-5g-frequency-affects-range-and-speed.html
[4]: https://www.networkworld.com/article/3568614/private-5g-can-solve-some-enterprise-problems-that-wi-fi-can-t.html
[5]: https://www.networkworld.com/article/3488799/private-5g-keeps-whirlpool-driverless-vehicles-rolling.html
[6]: https://www.networkworld.com/article/3570724/5g-can-make-for-cost-effective-private-backhaul.html
[7]: https://www.networkworld.com/article/3529291/cbrs-wireless-can-bring-private-5g-to-enterprises.html
[8]: https://www.networkworld.com/article/3572564/cbrs-wireless-yields-45b-for-licenses-to-support-5g.html
[9]: https://www.networkworld.com/article/3180615/faq-what-in-the-wireless-world-is-cbrs.html
[10]: https://www.networkworld.com/newsletters/signup.html
[11]: https://www.networkworld.com/article/3207535/what-is-iot-the-internet-of-things-explained.html
[12]: https://www.facebook.com/NetworkWorld/
[13]: https://www.linkedin.com/company/network-world

View File

@ -1,131 +0,0 @@
[#]: subject: "Heres Why Switching to Linux Makes Sense in 2021"
[#]: via: "https://news.itsfoss.com/switch-to-linux-in-2021/"
[#]: author: "Ankush Das https://news.itsfoss.com/author/ankush/"
[#]: collector: "lujun9972"
[#]: translator: "zepoch"
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
为什么在2021年我仍然推荐你使用Linux
======
在某些领域Linux确实要比Windows和macOS要更加优秀。人们也开始意识到这一点而且Linux也在桌面操作系统应用市场中也在变得愈发流行。
当然,目前大多数桌面操作系统用户仍然使用的是 Windows 或者 macOS 但是也有着越来越多的用户开始尝试新的 Linux 发行版本,看看他们是否可以从原来的系统切换到 Linux 系统。
他们可能已经听过[用 Linux 作为桌面操作系统](https://news.itsfoss.com/linux-foundation-linux-desktop/)的一些优秀案例,又或者是仅仅想要去尝试一些与原先不同的事物,谁知道呢?
在这里我将为你解释为什么在2021年我仍然推荐你使用Linux。
### Linux 是伟大的,但是究竟是什么让其在 2021 年更被推荐呢?
如果已经知道了[使用 Linux 的优点](https://itsfoss.com/reasons-switch-linux-windows-xp/),你可能就知道接下来我会说些什么。
#### 1\. 你不需要购买一个许可证
![][3]
你必须支付购买才能获得 Windows 10 许可证。
虽然有更便宜的选择如获得OEM密钥。但是如果您不愿意通过一些特别的网站而是从官方网站获得许可证那么仅授权使用 1 台 PC 的**家庭版**就至少需要花费 **140 美元**.
当然macOS是一个完全不同的模式你需要购买高级硬件才能使用macOS——所以我们才会一直使用微软的 Windows。
关键是——在失业的浪潮中,组件一台新电脑是一个挑战。此外,您还需要花钱购买操作系统的许可证,但是你却可以在多台计算机上免费使用 Linux。
是的,您不需要为 Linux 获取许可证密钥。您可以轻松下载 [Linux 发行版][4],并根据需要将其安装在尽可能多的设备上。
不要担心, 如果你不知道 Linux 发行, 你可以看看我们的[最好的 Linux 发行版](https://itsfoss.com/best-linux-distributions/)的列表。
#### 2\. 恢复现有的PC并节省资金
[全球芯片短缺](https://www.cnbc.com/2021/05/12/the-global-chip-shortage-could-last-until-2023-.html)已经严重影响了电脑组件的价格,特别是**显卡**。并不是简单的价格上升,而是你不得不支付 **2 到 5 倍**的零售价来购得显卡。
当然,如果你没有电脑,现在组建一个新的电脑可能是难以置信的挑战,但如果你有一个旧电脑的话,选择在上面运行 Windows 10 将会是十分卡顿的。
如果你不想要一个 Windows 的系统,那 macOS 呢?入门级 Mac 系统将会花费至少 **1100** 美金,这取决于你住在哪里。对许多人来说,这会是一笔昂贵的开销。
你肯定需要升级你的系统——但是如果我说 Linux 可以让你的旧电脑重新派上用场,也能为你省钱呢?
您将能够在您认为无法运行最新版本的 Microsoft Windows 的电脑上运行 Linux。是的这是正确的。
Linux 是一个资源高效型的操作系统,可在各种较旧的系统配置上运行。
所有你需要做的只是参考我们的列表 [轻量级 Linux 分布][7] 并选择一个你喜欢的。
#### 3\. 通过恢复系统减少电子浪费
![][8]
考虑到电子废物正在全球不断产生,尤其是矿工,我们可以尽量减少浪费。除非您真正需要新的硬件,否则最好将现有硬件设备重新用于新任务。
而且,多亏了 Linux您可以将旧电脑或单片机转到媒体服务器或个人[Nextcloud][9] 服务器。
您可以在现有硬件上使用 Linux 做更多工作。
因此,这将显著降低对新硬件的需求,并让您高效地重复使用现有的设备。
#### 4\. 远离病毒和恶意软件
![][10]
在远程工作无处不在的时代,病毒和恶意软件显著增加。因此,即使您想和平地工作,您最终也可能受到恶意软件的影响。
Windows 和 macOS 都比以往任何时候都更容易受到恶意软件的影响。但是对于Linux这是极不可能的。
Linux 发行版被定期修补,以确保最佳安全性。
此外,因为用户群很小,攻击者就不会花太多时间制作欺骗 Linux 用户的病毒或软件。因此,在使用 Linux 时遇到某种形式的恶意软件的机会较小。
#### 5\. 没有强制更新
![][8]
在一个人们压力倍增的时代,强制更新和发现计算机无法启动可能是一大烦恼。
至少Windows 用户的情况就是这样。
但是,使用 Linux您可以继续使用您的系统而无需在后台强制下载任何更新。
你的操作系统只有你能决定。
当你想要更新你的 Linux 发行版本时,你可以选择更新,也可以不更新,它可以一直保持不更新的状态并且不会打扰你,除非你有很长一段时间没有更新。
### 总结
这些只是我能想到的几个原因之一, Linux 作为操作系统的选择在 2021 年比以往任何时候都更值得被推荐。
当然,这也取决于您的要求,这些好处可能不会体现在在您的用例中。但是,如果你确实不了解 Linux至少现在你可以评估你的需求重新作出选择。
除了上述要点之外,您还能想到什么?请在下面的评论中告诉我。
### 大型科技网站获得数百万收入It's FOSS 为您服务!
如果您喜欢我们在 It's FOSS 所做的工作,请考虑捐款以支持我们的独立出版物。 您的支持将帮助我们继续发布专注于桌面 Linux 和开源软件的内容。
感谢各位。
--------------------------------------------------------------------------------
via: https://news.itsfoss.com/switch-to-linux-in-2021/
作者:[Ankush Das][a]
选题:[lujun9972][b]
译者:[zepoch](https://github.com/zepoch)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://news.itsfoss.com/author/ankush/
[b]: https://github.com/lujun9972
[1]: https://news.itsfoss.com/linux-foundation-linux-desktop/
[2]: https://itsfoss.com/reasons-switch-linux-windows-xp/
[3]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjUyMCIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4=
[4]: https://itsfoss.com/what-is-linux-distribution/
[5]: https://itsfoss.com/best-linux-distributions/
[6]: https://www.cnbc.com/2021/05/12/the-global-chip-shortage-could-last-until-2023-.html
[7]: https://itsfoss.com/lightweight-linux-beginners/
[8]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjQ5OSIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4=
[9]: https://itsfoss.com/nextcloud/
[10]: data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjUxNCIgd2lkdGg9Ijc4MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiLz4=

View File

@ -0,0 +1,91 @@
[#]: collector: (lujun9972)
[#]: translator: (stevenzdg988)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How key Python projects are maintained)
[#]: via: (https://opensource.com/article/20/2/python-maintained)
[#]: author: (Moshe Zadka https://opensource.com/users/moshez)
How key Python projects are maintained
如何维护关键的 Python 项目
======
开源 Python 项目保持平稳运行的社区幕后。
![旧款电脑和新款电脑,代表迁移到新的软件或硬件][1]
Jannis Leidel 是 [Jazzband][2] 社区的一部分。Jazzband 是一个基于 [Python][3] 项目维护责任的共享协作社区。
Jazzband 的诞生源于长期独自维护一个开源项目的压力。Jannis 是巡回乐队管理员,这意味着他负责管理任务并确保乐队中的人可以在他们想要的时候演奏。
Jazzband 并不是他的第一个开源志愿者工作——他是前 [Django][4] 核心开发人员,[Django 软件基金会][5] 董事会成员,编写了许多 Django 应用程序和 Python 项目,一直是 [pip][6] 和 [virtualenv][7] 核心开发人员和发布经理,共同创立了 [Python 软件包授权][8],并担任 [PyPI][9] 管理员。在社区方面,他共同创立了德国 Django 协会,担任 [DjangoCon Europe][10] 2010 联合主席,在多个会议上发言,并在去年担任了[Python 软件基金会][11]主管和联席主席
### Moshe Zadka: 你是如何开始编程的?
Jannis Leidel我在高中时作为常规德语计算机科学课程的一部分开始学习编程在那里我涉猎了 Turbo Pascal 和 Prolog。我很快就进入了 Web 开发的世界,并使用 PHP3、[Perl5][12] 和 [MySQL][13] 编写了小型网站。后来在大学里,我在从事媒体艺术项目时再次学习编程,发现 [Ruby][14]、Perl 和 Python 特别有用。我最终坚持使用 Python因为它的多功能性和易用性。从那时起我很高兴能够在我的职业生涯中使用 Python 和开放网络技术HTML/JS/CSS
### Zadka: 您是如何开始开源的?
Leidel作为大学艺术项目的一部分我需要一种与各种 Web 服务对话并与一些电子设备交互的方法,但发现我之前的 PHP 技能无法胜任这项任务。因此,我参加了有关使用 Python 编程的课程,并对学习更多有关框架如何工作产生兴趣——与库相比——因为它们进一步体现了我想了解的最佳实践。特别是,新生的 Django Web 框架对我很有吸引力,因为它支持务实的方法,并为如何开发 Web 应用程序提供了大量指导。 2007 年,我作为学生参与了 Google Summer of Code for Django后来为 Django 及其可重用组件生态系统做出了更多贡献——不久我也成为 Django 核心开发人员。在完成学位期间,我能够利用这些技能成为一名自由职业者,并花时间在 Django 社区的许多不同部分工作。在那时,横向移动到更广泛的 Python 社区不过是很自然的。
### Zadka: 你的日常工作是什么?
Leidel我是 Mozilla 的一名高级软件工程师,致力于为 Firefox 数据管道开发数据工具。实际上,这意味着我在更广泛的 Firefox 工程团队中从事各种内部和面向公众的基于 Web 的项目,这些项目帮助 Mozilla 员工和社区成员理解 Firefox Web 浏览器发送的遥测数据。我目前的部分重点是维护我们的数据分析和可视化平台,该平台基于开源项目 [Redash][15],并对其做出贡献。我参与的其他项目是我们的下一代遥测系统 [Glean][16] 和一个允许您在浏览器(包括 Scientific Python 堆栈)中进行数据科学的工具 [Iodide][17]。
### Zadka: 您是如何参与 Jazzband 的?
Leidel早在 2015 年,我就对单独维护很多人所依赖的项目感到沮丧,并看到我的许多社区同行都在为类似的问题苦苦挣扎。我不知道有什么好方法可以接触到社区中更多可能对长期维护感兴趣的人。在某些情况下,我觉得新的“社会编码”范例很少是社会性的,而且常常是孤立的,有时甚至对新老贡献者来说都是创伤。我相信我们社区中我现在无法容忍的不平等在当时更加猖獗,这使得为贡献者提供一个安全的环境变得困难——我们现在知道这对于稳定的项目维护至关重要。我想知道我们是否缺少一种更具协作性和包容性的软件开发方法。
Jazzband 项目的启动是为了降低进入维护的门槛,并简化其中一些较无聊的方面(例如,围绕 [CI][18] 的最佳实践)。
### Zadka: 您最喜欢 Jazzband 的什么?
Leidel我最喜欢 Jazzband 的一点是,我们确保了许多人所依赖的许多项目的维护,同时还确保任何经验水平的新贡献者都可以加入。
### Zadka: Jazzband 的“巡回乐队管理员”的工作是什么?
Leidel当谈到 Jazzband 幕后的所有事情时“roadie”是一个寻求协助的人。这意味着例如处理新项目的入职、维护处理用户管理和项目发布的 Jazzband 网站、充当安全或行为准则事件的第一响应者等等。“roadies”这个词是从音乐和活动行业借来的指的是支持人员他们负责在巡回演出中几乎所有需要做的事情除了实际的艺术表演。在 Jazzband他们在那里确保成员可以在项目上工作。这也意味着某些任务是部分或完全自动化的这是有意义的并且最佳实践应用于大多数 Jazzband 项目,如打包设置、文档托管或持续集成。
### Zadka: 作为 Jazzband 的巡回乐队管理员,您工作中最具挑战性的方面是什么?
Leidel目前我作为"巡回乐队管理员"的工作中最具挑战性的方面是实施社区成员提出的 Jazzband 改进而不会冒他们所依赖的工作流程的风险。换句话说Jazzband 越大,在概念级别上扩展项目变得越困难。具有讽刺意味的是,我是目前唯一的"巡回乐队管理员",独自处理一些任务,而 Jazzband 试图阻止其项目发生这种情况。这是 Jazzband 未来的一大担忧。
### Zadka: 对于有兴趣想知道能否加入 Jazzband 的人,您有什么想说的?
Leidel如果您有兴趣加入一群相信协作工作比单独工作更好的人或者如果您一直在为自己的维护负担而苦苦挣扎并且不知道如何继续请考虑加入 Jazzband。它简化了新贡献者的入职流程提供了一个争议框架并自动发布到 [PyPI][19]。有许多最佳实践可以很好地降低项目无法维护的风险。
### Zadka: 您还有什么想告诉我们的读者的吗?
Leidel我鼓励每个从事开源项目的人都考虑屏幕另一边的人。要有同理心记住你自己的经历可能不是你同龄人的经历。了解您是全球多元化社区的成员这要求我们始终尊重我们之间的差异。
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/2/python-maintained
作者:[Moshe Zadka][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/moshez
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/migration_innovation_computer_software.png?itok=VCFLtd0q (and old computer and a new computer, representing migration to new software or hardware)
[2]: https://jazzband.co/
[3]: https://opensource.com/resources/python
[4]: https://opensource.com/article/18/8/django-framework
[5]: https://www.djangoproject.com/foundation/
[6]: https://opensource.com/article/19/11/python-pip-cheat-sheet
[7]: https://virtualenv.pypa.io/en/latest/
[8]: https://www.pypa.io/en/latest/
[9]: https://pypi.org/
[10]: https://djangocon.eu/
[11]: https://www.python.org/psf/
[12]: http://opensource.com/article/18/1/why-i-love-perl-5
[13]: https://opensource.com/life/16/10/all-things-open-interview-dave-stokes
[14]: http://opensource.com/business/16/4/save-development-time-and-effort-ruby
[15]: https://redash.io/
[16]: https://firefox-source-docs.mozilla.org/toolkit/components/telemetry/start/report-gecko-telemetry-in-glean.html
[17]: https://alpha.iodide.io/
[18]: https://opensource.com/article/19/12/cicd-resources
[19]: https://opensource.com/downloads/7-essential-pypi-libraries

View File

@ -0,0 +1,59 @@
[#]: collector: (lujun9972)
[#]: translator: (baddate)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Learn Bash with this book of puzzles)
[#]: via: (https://opensource.com/article/20/4/bash-it-out-book)
[#]: author: (Carlos Aguayo https://opensource.com/users/hwmaster1)
用这本谜题书学习 Bash
======
>“Bash it out”使用 16 个谜题,涵盖了基本、中级和高级 Bash 脚本。
![Puzzle pieces coming together to form a computer screen][1]
计算机既是我的爱好,也是我的职业。我的公寓里散布着大约 10 个,它们都运行 Linux包括我的 Mac。由于我喜欢升级我的电脑和提升我的电脑技能当我遇到 Sylvain Leroux 的[_Bash it out_][2]时,我抓住了购买它的机会。我在 Debian Linux 上经常使用命令行,这似乎是扩展我的 Bash 知识的好机会。当作者在前言中解释他使用 Debian Linux 时,我笑了,这是我最喜欢的两个发行版之一。
Bash 可让你自动执行任务,因此它是一种省力、有趣且有用的工具。在阅读本书之前,我已经有相当多的 Unix 和 Linux 上的 Bash 经验。我不是专家,部分原因是脚本语言非常广泛和强大。当我在基于 Arch 的 Linux 发行版[EndeavourOS][3]的欢迎屏幕上看到 Bash 时,我第一次对 Bash 产生了兴趣。
以下屏幕截图显示了 EndeavourOS 的一些选项。不管你信不信,这些面板只指向 Bash 脚本,每个脚本都完成一些相对复杂的任务。而且因为它都是开源的,所以我可以根据需要修改这些脚本中的任何一个。
![EndeavourOS after install][4]
![EndeavourOS install apps][5]
### 总有东西要学
我对这本书的印象非常好。虽然不长,但经过了深思熟虑。作者对 Bash 有非常广泛的了解,并且具有解释如何使用它的不可思议的能力。这本书使用 16 个谜题涵盖了基本、中级和高级 Bash 脚本,他称之为“挑战”。这教会了我将 Bash 脚本视为需要解决的编程难题,这让我玩起来更有趣。
Bash 一个令人兴奋的方面是它与 Linux 系统深度集成。虽然它的部分能力在于它的语法,但它也很强大,因为它可以访问很多系统资源。你可以编写重复性任务或简单但厌倦了手动执行的任务的脚本。没有什么太大或太小的事,*Bash it out*可以帮助你了解可以做什么以及如何实现它。
如果我不提及 David Both 的免费资源[_A sysadmin's guide to Bash scripting_][6]on Opensource.com这篇评论就不会完整。这个 17 页的 PDF 指南与Bash it out不同但它们共同构成了任何想要了解它的人的成功组合。
我不是计算机程序员,但*Bash it out*增加了我进入更高级 Bash 脚本水平的欲望——虽然没有这个打算,但我可能最终无意中成为一名计算机程序员。
我喜欢 Linux 的原因之一是因为它的操作系统功能强大且用途广泛。无论我对 Linux 了解多少,总有一些新东西需要学习,这让我更加欣赏 Linux。
在竞争激烈且不断变化的就业市场中,我们所有人都应该不断更新我们的技能。这本书帮助我以非常实际的方式学习了 Bash。几乎感觉作者和我在同一个房间里耐心地指导我学习。
作者 Leroux 具有不可思议的能力去吸引读者。这是一份难得的天赋,我认为比他的技术专长更有价值。事实上,我写这篇书评是为了感谢作者预见了我自己的学习需求;虽然我们从未见过面,但我从他的天赋中受益匪浅。
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/4/bash-it-out-book
作者:[Carlos Aguayo][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/baddates)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/hwmaster1
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/puzzle_computer_solve_fix_tool.png?itok=U0pH1uwj (Puzzle pieces coming together to form a computer screen)
[2]: https://www.amazon.com/Bash-Out-Strengthen-challenges-difficulties/dp/1521773262/
[3]: https://endeavouros.com/
[4]: https://opensource.com/sites/default/files/uploads/endeavouros-welcome.png (EndeavourOS after install)
[5]: https://opensource.com/sites/default/files/uploads/endeavouros-install-apps.png (EndeavourOS install apps)
[6]: https://opensource.com/downloads/bash-scripting-ebook

View File

@ -0,0 +1,215 @@
[#]: collector: "lujun9972"
[#]: translator: "zepoch"
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
[#]: subject: "Use Python to solve a charity's business problem"
[#]: via: "https://opensource.com/article/20/9/solve-problem-python"
[#]: author: "Chris Hermansen https://opensource.com/users/clhermansen"
使用 Python 来解决慈善机构的业务问题
======
比较不同的编程语言如何解决同一个问题是一个很有趣的事情,也很有指导意义。接下来,我们就来讲一讲 Python。
![Python programming language logo with question marks][1]
在我这一系列的[第一篇文章][2]里,我描述了这样子的一个问题,如何将一大批的救助物资分为具有相同价值的物品,并将其分发给社区中的困难住户。我也曾写过用不同的编程语言写一些小程序来解决这样子的小问题以及比较这些程序时如何工作的。
在第一篇文章中,我是使用了 [Groovy][3] 语言来解决问题的。Groovy 在很多方面都与 [Python][4] 很相似,但是在语法上她更像 C 语言和 Java。因此使用 Python 来创造一个相同的解决方案应该会很有趣且更有意义。
### 使用 Python 的解决方案
使用 Java 时,我会声明一个 utility 类来保存元组数据(新的特征记录器将会很好地解决这个问题)。使用 Groovy 时,我就是用了 maps 中的映射,我也将在 Python 使用相同的映射
使用一个字典来保存从批发商处批发来的货物:
```
packs = [
{'item':'Rice','brand':'Best Family','units':10,'price':5650,'quantity':1},
{'item':'Spaghetti','brand':'Best Family','units':1,'price':327,'quantity':10},
{'item':'Sardines','brand':'Fresh Caught','units':3,'price':2727,'quantity':3},
{'item':'Chickpeas','brand':'Southern Style','units':2,'price':2600,'quantity':5},
{'item':'Lentils','brand':'Southern Style','units':2,'price':2378,'quantity':5},
{'item':'Vegetable oil','brand':'Crafco','units':12,'price':10020,'quantity':1},
{'item':'UHT milk','brand':'Atlantic','units':6,'price':4560,'quantity':2},
{'item':'Flour','brand':'Neighbor Mills','units':10,'price':5200,'quantity':1},
{'item':'Tomato sauce','brand':'Best Family','units':1,'price':190,'quantity':10},
{'item':'Sugar','brand':'Good Price','units':1,'price':565,'quantity':10},
{'item':'Tea','brand':'Superior','units':5,'price':2720,'quantity':2},
{'item':'Coffee','brand':'Colombia Select','units':2,'price':4180,'quantity':5},
{'item':'Tofu','brand':'Gourmet Choice','units':1,'price':1580,'quantity':10},
{'item':'Bleach','brand':'Blanchite','units':5,'price':3550,'quantity':2},
{'item':'Soap','brand':'Sunny Day','units':6,'price':1794,'quantity':2}]
```
大米有一包,每包中有 10 袋大米,意大利面条有十包,每包中有一袋意大利面条。上述代码中,变量 `packs` 被设置为 Python 字典列表。这与Groovy的方法非常相似。关于 Groovy 和 Python 之间的区别,有几点需要注意:
1. 在 Python 中,无需关键字来定义变量 `packs`Python 变量初始化时需要设置一个值。
2. Python 字典中的词键(例如,`item`, `brand`, `units`, `price`, `quantity`需要引号来表明它们是字符串Groovy 假定这些是字符串,但也接受引号。
3. 在 Python 中,符号 `{ ... }` 表明一个字典声明; Groovy 使用与列表相同的方括号,但两种情况下的结构都必须具有键值对。
当然,表中的价格不是以美元计算的。
接下来,打开散装包。 例如,打开大米的单个散装包装,将产出 10 单位大米; 也就是说,产出的单位总数是`单位 * 数量`。 Groovy 脚本使用一个名为 `collectMany` 的方便的函数,该函数可用于展平列表列表。 据我所知Python 没有类似的东西,所以使用两个列表推导式来产生相同的结果:
```
units = [[{'item':pack['item'],'brand':pack['brand'],
'price':(pack['price'] / pack['units'])}] *
(pack['units'] * pack['quantity']) for pack in packs]
units = [x for sublist in units for x in sublist]
```
第一个列表可理解为(分配给单元)构建字典列表列表。 第二个将其“扁平化”为字典列表。 请注意Python 和 Groovy 都提供了一个 `*` 运算符,它接受左侧的列表和右侧的数字 `N`,并复制列表 `N` 次。
后一步是将这些单位的大米之类的重新包装到 hamper 中以进行分发。 就像在 Groovy 版本中一样,您需要更具体地了解理想的 hamper 值,当您只剩下几个单位时,您最好不要过度限制,即可以做一些随机分配:
```python
valueIdeal = 5000
valueMax = valueIdeal * 1.1
```
很好! 重新包装包裹。
```python
import random
hamperNumber = 0 # [1]
while len(units) &gt; 0: # [2]
hamperNumber += 1
hamper = []
value = 0
canAdd = True # [2.1]
while canAdd: # [2.2]
u = random.randint(0,len(units)-1) # [2.2.1]
canAdd = False # [2.2.2]
o = 0 # [2.2.3]
while o &lt; len(units): # [2.2.4]
uo = (u + o) % len(units)
unit = units[uo]
unitPrice = unit['price'] # [2.2.4.1]
if len(units) &lt; 3 or not (unit in hamper) and (value + unitPrice) &lt; valueMax:
# [2.2.4.2]
hamper.append(unit)
value += unitPrice
units.pop(u) # [2.2.4.3]
canAdd = len(units) &gt; 0
break # [2.2.4.4]
o += 1 # [2.2.4.5]
# [2.2.5]
print('')
print('Hamper',hamperNumber,'value',value)
for item in hamper:
print('%-25s%-25s%7.2f' % (item['item'],item['brand'],item['price'])) # [2.3]
print('Remaining units',len(units)) # [2.4]
```
一些澄清上面注释中括号中的数字例如_[1]_对应于以下澄清
* 1\. 导入 Python 的随机数生成器工具并初始化 hampers 数。
* 2\. 只要有更多可用的单元,这个`while` 循环就会将单元重新分配到 hampers 中:
* 2.1 增加 hamper 编号得到一个新的空hamper单位列表并将其值设为0 开始假设您可以向 hamper 中添加更多物品。
* 2.2 这个 `while` 循环将尽可能多地向 Hamper 添加单元Groovy 代码使用了 `for` 循环,但 Python 的 `for` 循环期望迭代某些东西,而 Groovy 则是为更传统的 C 形式的 `for` 循环形式):
* 2.2.1 获取一个介于 0 和剩余单位数减 1 之间的随机数。
* 2.2.2 假设您找不到更多要添加的单位。
* 2.2.3 创建一个变量,用于从您正在寻找要放入 hamper 中的物品的起点的偏移量。
* 2.2.4 从随机选择的索引开始,这个 `while` 循环将尝试找到一个可以添加到 hamper 的单元再次注意Python `for` 循环可能不适合这里,因为列表的长度将在迭代中中发生变化)。
* 2.2.4.1 找出要查看的单位(随机起点+偏移量)并获得其价格。
* 2.2.4.2 如果只剩下几个,或者添加单位后篮子的价值不太高,您可以将此单位添加到 Hamper 中。
* 2.2.4.3 将单位添加到 Hamper 中,按单价增加 Hamper 价值,从可用单位列表中删除该单位。
* 2.2.4.4 只要还有剩余单位,您就可以添加更多单位,因此可以跳出此循环继续寻找。
* 2.2.4.5 增加偏移量,。
* 2.2.5 在退出这个 `while` 循环时,如果你检查了所有剩余的单元并且找不到单元可以添加到 hamper 中,那么 hamper 就完成了搜索; 否则,您找到了一个,可以继续寻找更多。
* 2.3 打印出 hamper 的内容。
* 2.4 打印出剩余的单位信息。
运行此代码时,输出看起来与 Groovy 程序的输出非常相似:
```python
Hamper 1 value 5304.0
UHT milk Atlantic 760.00
Tomato sauce Best Family 190.00
Rice Best Family 565.00
Coffee Colombia Select 2090.00
Sugar Good Price 565.00
Vegetable oil Crafco 835.00
Soap Sunny Day 299.00
Remaining units 148
Hamper 2 value 5428.0
Tea Superior 544.00
Lentils Southern Style 1189.00
Flour Neighbor Mills 520.00
Tofu Gourmet Choice 1580.00
Vegetable oil Crafco 835.00
UHT milk Atlantic 760.00
Remaining units 142
Hamper 3 value 5424.0
Soap Sunny Day 299.00
Chickpeas Southern Style 1300.00
Sardines Fresh Caught 909.00
Rice Best Family 565.00
Vegetable oil Crafco 835.00
Spaghetti Best Family 327.00
Lentils Southern Style 1189.00
Remaining units 135
Hamper 21 value 5145.0
Tomato sauce Best Family 190.00
Tea Superior 544.00
Chickpeas Southern Style 1300.00
Spaghetti Best Family 327.00
UHT milk Atlantic 760.00
Vegetable oil Crafco 835.00
Lentils Southern Style 1189.00
Remaining units 4
Hamper 22 value 2874.0
Sardines Fresh Caught 909.00
Vegetable oil Crafco 835.00
Rice Best Family 565.00
Rice Best Family 565.00
Remaining units 0
```
最后一个 hamper 在内容和价值上有所简化。
### 结论
乍一看,这个程序的 Python 和 Groovy 版本之间没有太大区别。 两者都有一组相似的结构,这使得处理列表和字典非常简单。 两者都不需要很多“样板代码”或其他“繁杂”操作。
此外,使用 Groovy 时,向 Hamper 中添加单元还是一件比较繁琐的事情。 您需要在单位列表中随机选择一个位置,然后从该位置开始,遍历列表,直到找到一个价格允许的且包含它的单位,或者直到您用完列表为止。 当只剩下几件物品时,您需要将它们扔到最后一个 Hamper 里。
另一个值得一提的问题是:这不是一种特别有效的方法。 从列表中删除元素、极其多的重复表达式还有一些其它的问题使得这不太适合解决这种大数据重新分配问题。 尽管如此,它仍然在我的老机器上运行。
如果你觉得我在这段代码中使用 `while` 循环并改变其中的数据感到不舒服,您可能希望我让它更有用一些。 我想不出一种方法不使用 Python 中的 map 和 reduce 函数,并结合随机选择的单元进行重新打包。 你可以吗?
在下一篇文章中,我将使用 Java 重新执行此操作,以了解 Groovy 和 Python 的工作量减少了多少,未来的文章将介绍 Julia 和 Go。
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/9/solve-problem-python
作者:[Chris Hermansen][a]
选题:[lujun9972][b]
译者:[zepoch](https://github.com/zepoch)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/clhermansen
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/python_programming_question.png?itok=cOeJW-8r "Python programming language logo with question marks"
[2]: https://opensource.com/article/20/8/solving-problem-groovy
[3]: https://groovy-lang.org/
[4]: https://www.python.org/

View File

@ -0,0 +1,82 @@
[#]: subject: (What is a CI/CD pipeline?)
[#]: via: (https://opensource.com/article/21/6/what-cicd-pipeline)
[#]: author: (Will Kelly https://opensource.com/users/willkelly)
[#]: collector: (lujun9972)
[#]: translator: (baddate)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
CI/CD 管道是什么?
======
你如何定义持续集成/持续部署管道取决于你组织的要求。
![Plumbing tubes in many directions][1]
持续集成/持续部署 (CI/CD) 管道是每个 DevOps 计划的基础。 CI/CD 管道打破了传统的开发孤岛,使开发和运营团队能够在整个软件开发生命周期中进行协作。
更好的是,转向 DevOps 和 CI/CD 管道可以帮助你的组织以更高的速度更安全地[交付软件][2]。
### Breaking down the CI/CD pipeline
CI/CD 管道有很多定义,所以我总是建议组织定义自己的 CI/CD 管道版本和其他 DevOps 概念,而不是使用其他人的。开源 CI/CD 工具为你提供构建满足组织要求的 CI/CD 管道的自由和选择。
形成 CI/CD 管道的阶段是将不同的任务子集分组为 _管道阶段_。典型的管道阶段包括:
* **构建**:开发人员编译应用程序代码。
* **测试**:质量保证 (QA) 团队使用自动化测试工具和策略测试应用程序代码。
* **发布**:开发团队将应用程序代码交付到代码库。
* **部署**DevOps 团队将应用程序代码分阶段投入生产。
* **安全性和合规性**QA 团队根据项目要求验证构建。这是组织部署容器扫描工具的阶段,这些工具根据常见漏洞和暴露 (CVE) 检查图像的质量。
这些是 CI/CD 管道的标准阶段,但一些组织调整 CI/CD 管道模型以满足他们的要求。例如,为医疗保健市场构建应用程序的组织,具有严格的合规性标准,可以在整个工具链中分发测试、验证和合规性门。
其他示例可能是依赖于具有开源软件 (OSS) 的复杂软件供应链的组织。商业组件可能会设立一个门槛,开发团队成员可以在其中为 OSS 包生成[软件物料清单][3] (SBOM),或者外部商业软件供应商必须将 SBOM 作为其合同可交付成果的一部分进行交付。
### CI/CD 管道的障碍
实施 CI/CD 管道会改变团队的流程和文化。尽管许多开发人员愿意接受某些任务和测试的自动化,但人员可能成为采用 CI/CD 的障碍。
从瀑布式流程转向 CI/CD 可能会动摇某些组织中基本的和隐含的权力结构。由于 CI/CD 管道提高了软件交付速度,旧手动流程的“守门人”可能会受到这种变化的威胁。
### 整合机会
随着你在文化、流程和工具中达到更高的 DevOps 成熟度水平,包含 CI/CD 工具链的工具的开源根源为一些激动人心的集成创造了机会。
分析公司 Forrester 在 2020 年预测,即时学习将加入 CI/CD 管道。如果你考虑一下,会发现这是有道理的。在当前远程工作的时代,甚至对于新员工的远程入职,这更有意义。例如,组织可以将文档 wiki 与内部流程文档集成到其管道中。
更雄心勃勃的组织可以将学习管理系统 (LMS)(例如 [Moodle][4])集成到其 CI/CD 管道中。它可以使用 LMS 发布有关新 DevOps 工具链功能的简短视频,开发人员在加入时或在整个管道中更新工具时需要学习这些功能。
一些组织正在将群聊和其他协作工具直接集成到他们的 CI/CD 管道中。聊天平台提供警报并支持团队之间的协作和沟通。将 Mattermost、Rocket.Chat 或其他[企业聊天][5]平台集成到你的 CI/CD 管道中需要预先规划和分析,以确保管道用户不会被警报淹没。
另一个需要探索的集成机会是将分析和高级报告构建到你的 CI/CD 管道中。这有助于你利用通过管道传输的数据。
### 最后的想法
CI/CD 管道是 DevOps 的基础。开源使其能够适应并灵活地满足你在 DevOps 之旅中实施的运营变更所产生的新需求。
我希望看到对统一 DevOps 平台趋势的开源响应,在这种趋势中,组织寻求端到端的 CI/CD 解决方案。这种解决方案的要素就在那里。毕竟GitLab 和 GitHub 将他们的平台追溯到开源根源。
最后,不要忘记每一个成功的 CI/CD 工具链背后的教育和外展。记录你的工具链和相关流程将改善开发人员入职和持续的 DevOps 团队培训。
你和你的组织如何定义你的 CI/CD 工具链?请在评论中分享你的反馈。
--------------------------------------------------------------------------------
via: https://opensource.com/article/21/6/what-cicd-pipeline
作者:[Will Kelly][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/baddate)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/willkelly
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/plumbing_pipes_tutorial_how_behind_scenes.png?itok=F2Z8OJV1 (Plumbing tubes in many directions)
[2]: https://techbeacon.com/devops/5-reasons-why-cicd-vital-your-organizations-value-stream
[3]: https://www.ntia.gov/SBOM
[4]: https://moodle.org/
[5]: https://opensource.com/alternatives/slack

View File

@ -0,0 +1,129 @@
[#]: subject: (How to Set Up Razer Devices on Linux for Lighting Effects and Other Configurations)
[#]: via: (https://itsfoss.com/set-up-razer-devices-linux/)
[#]: author: (Ankush Das https://itsfoss.com/author/ankush/)
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
如何在 Linux 上设置雷蛇设备的灯光效果和其他配置
======
你有一个闪亮的新雷蛇硬件,但你找不到 Linux 的 Razer Synapse 软件。而你最终没有正确的 RGB 同步,也没有办法定制它。你会怎么做呢?
好吧,对于某些功能,比如给你的鼠标添加宏,你仍然需要访问 Razer Synapse在 Windows 或 MacOS上
但是,要调整其他一些选项,如键盘的宏,改变鼠标的 DPI或灯光效果你可以在 Linux 上轻松设置你的雷蛇外设。
![My Razer Basilisk V2 with lighting effect][1]
这里有一些鼠标和鼠标垫的照片。这是同样的设置,但有不同的照明方案。点击图片可以看到更大的图片。
![][2]
![][3]
![][4]
雷蛇 Basilisk 是一款不错的游戏鼠标。如果你想,你可以从亚马逊订购或从当地商店获得。
如果你已经拥有一个雷蛇设备,让我展示一下配置它的步骤,就像我在这里做的那样。
### 步骤 1安装 OpenRazer
**OpenRazer** 是一个开源的驱动程序,使雷蛇硬件在 Linux 上工作。它支持几种功能来定制和控制你的设备,包括 RGB 鼠标垫。
虽然这不是官方 Linux 驱动,但它在各种设备上工作良好。
**它为各种 Linux 发行版提供支持,包括 Solus、openSUSE、Fedora、Debian、Arch Linux、Ubuntu 和其他一些发行版。**
在这里,我将重点介绍在任何基于 Ubuntu 的发行版上安装它的步骤,对于其他发行版,你可能想参考[官方说明][8]。
你需要在 Ubuntu 上[使用 PPA][9] 安装 OpenRazer下面是如何做的
```
sudo apt install software-properties-gtk
sudo add-apt-repository ppa:openrazer/stable
sudo apt update
sudo apt install openrazer-meta
```
它也提供了一个[守护进程][10],你可以选择让它工作,你要把你的用户加入到 **plugdev** 组,它给了设备的特权访问:
```
sudo gpasswd -a $USER plugdev
```
我不需要用上述命令中配置/添加一个守护程序,但我仍然可以很好地使用这些设备。守护进程主要是确保驱动保持活跃。
[下载 OpenRazer][11]
### 步骤 2安装一个 GUI 来管理和调整选项
现在驱动已经安装完毕,你所需要的是一个图形用户界面 GUI 来帮助你定制你的雷蛇硬件。
你可以找到一些可用的选择,但我将推荐安装 [Polychromatic][12],它提供了一个有吸引力的用户界面,而且运行良好。
![][13]
Polychromatic 是我能推荐的最接近 Razer Synapse 的应用,而且效果不错。
对于基于 Ubuntu 的发行版,你需要做的就是使用 PPA 安装它:
```
sudo add-apt-repository ppa:polychromatic/stable
sudo apt update
sudo apt install polychromatic
```
对于 Arch Linux 用户,你可以在 [AUR][14] 中找到它。关于更多的安装说明,你可以参考[官方下载页面][15]。
[下载 Polychromatic][16]
你会得到不同设备的不同选项。在这里,我试着改变 DPI自定义颜色周期以及我的雷蛇 Basilisk v2 鼠标的轮询率,它完全正常。
![Customization options for a mouse][17]
如果你知道你想做什么,它还为你提供了轻松重启或停止[守护进程][10]、改变小程序图标和执行高级配置选项的能力。
另外,你可以试试 [RazerGenie][18]、[Snake][19] 或 [OpenRGB][20] (用于改变颜色)来调整鼠标的颜色或任何其他设置。
### 总结
现在你可以轻松地定制你的雷蛇硬件了,希望你能玩得开心!
虽然你可能会找到一些其他的选择来配置你的雷蛇设备,但我没有找到任何其他效果这么好的选择。
如果你遇到了一些有用的东西,值得在这里为所有的雷蛇用户提一下,请在下面的评论中告诉我。
--------------------------------------------------------------------------------
via: https://itsfoss.com/set-up-razer-devices-linux/
作者:[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://i2.wp.com/itsfoss.com/wp-content/uploads/2021/06/Razer-Basilisk-V2.jpg?resize=800%2C600&ssl=1
[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/razer-mouse-pad-lighting-effect-3-com.jpg?resize=800%2C600&ssl=1
[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/razer-mouse-pad-lighting-effect-2-com.jpg?resize=800%2C600&ssl=1
[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/razer-mouse-pad-lighting-effect-1-com.jpg?resize=800%2C600&ssl=1
[8]: https://openrazer.github.io/#download
[9]: https://itsfoss.com/ppa-guide/
[10]: https://itsfoss.com/linux-daemons/
[11]: https://openrazer.github.io/
[12]: https://polychromatic.app
[13]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/06/polychromatic-app-1.png?resize=800%2C500&ssl=1
[14]: https://itsfoss.com/aur-arch-linux/
[15]: https://polychromatic.app/download/
[16]: https://polychromatic.app/
[17]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/razer-basilisk-polychromatic.png?resize=800%2C505&ssl=1
[18]: https://github.com/z3ntu/RazerGenie
[19]: https://github.com/bithatch/snake
[20]: https://itsfoss.com/openrgb/

View File

@ -1,227 +0,0 @@
[#]: subject: (Systemd Timers for Scheduling Tasks)
[#]: via: (https://fedoramagazine.org/systemd-timers-for-scheduling-tasks/)
[#]: author: (Richard England https://fedoramagazine.org/author/rlengland/)
[#]: collector: (lujun9972)
[#]: translator: (dcoliversun)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
用于调度任务的 Systemd 定时器
======
![][1]
Systemd 提供定时器有一段时间了,定时器替代了 _cron_ 功能,这一特性值得看看。本文将向你介绍在系统启动后如何使用 _systemd_ 中的定时器来运行任务,此后重复运行。这不是对 _systemd_ 的全面讨论,只是介绍这一特性。
### Cron、anacron 与 systemd快速回顾
_Cron_ 可以将任务调度以几分钟到几个月或更长时间的粒度运行。设置起来相对简单,只需要一个配置文件。虽然配置过程有些深奥,但一般用户也可以使用。
然而,如果您的系统在需要执行的时间没有运行,那么 _Cron_ 会失败。
_Anacron_ 克服了“系统不运行”问题。它确保你的系统再次启动时,任务将执行。虽然它旨在管理员使用,但有些系统允许普通用户访问 _Anacron_
但是_anacron_ 的执行频率不能低于每天一次。
_cron_ 和 _anacron_ 都存在执行上下文一致性的问题。必须注意任务运行时有效的环境与测试时使用的环境完全相同。必须提供相同的 shell、环境变量和路径。这意味着测试和调试有时会很困难。
_Systemd_ 定时器提供了 _cron__anacron_ 的优点,允许调度到分钟粒度。确保在系统再次运行时执行任务,即使在预期的执行时间内任务处于关闭状态。对所有用户都可用。你可以在它将要运行的环境中测试和调试执行。
但是,配置更加复杂,至少需要两个配置文件。
如果你的 _cron_ and _anacron_ 配置很好地为你服务,那么可能没有理由改变。但是 _systemd_ 至少值得研究,因为它可以简化任何当前的 _cron_/_anacron_ 工作方式。
### 配置
_Systemd_ 定时器执行的函数至少需要两个文件。这两个是“<ruby>定时器<rt>timer unit</rt></ruby>”和“<ruby>系统服务<rt>service unit</rt></ruby>”。动作不仅仅是简单的命令,你还需要一个“作业”文件或脚本来执行必要的功能。
定时器文件定义调度表,而系统服务文件定义执行的任务。有关的更多详细信息参考 “man systemd.timer” 中提供的 .timer unit。服务单元的详细信息可在 “man systemd.service” 中找到。
There are several locations where unit files exist (listed in the man page). Perhaps the easiest location for the general user, however, is “~/.config/systemd/user”. Note that “user” here, is the literal string “user”.
单元文件存在于几个位置(在 man page 中列出)。然而,对于普通用户来说,最容易找到的位置可能是 “~/.config/systemd/user”。请注意这里的“用户”是字符串“用户”。
### 示例
此示例是一个创建用户调度作业而不是系统调度作业(以root用户身份运行)的简单示例。它将消息、日期和时间打印到文件中。
1. 首先创建一个执行任务的 shell 脚本。在你的本地 “bin” 目录中创建它,例如在 “~/bin/schedule-test.sh” 中。
创建文件:
```
touch ~/bin/schedule-test.sh
```
然后将以下内容添加到你刚刚创建的文件中。
```
#!/bin/sh
echo "This is only a test: $(date)" >> "$HOME/schedule-test-output.txt"
```
记住赋予你的 shell 脚本执行权限。
2. 创建 .service 调用上面的脚本。在以下位置创建目录与文件:“~/.config/systemd/user/schedule-test.service
```
[Unit]
Description=A job to test the systemd scheduler
[Service]
Type=simple
ExecStart=/home/<user>/bin/schedule-test.sh
[Install]
WantedBy=default.target
```
请注意&lt;用户&gt;应该是你的 @HOME 地址,但是资源文件路径名中的“用户”实际上是字符串“用户”。
_ExecStart_ 应该提供一个没有变量的绝对地址。例外情况是,对于 _用户_,您可以用 “%h” 替换 $HOME。换句话说你可以使用:
```
ExecStart=%h/bin/schedule-test.sh
```
这仅用于用户文件。这不适用于系统服务,因为在系统环境中运行时 “%h” 总是返回 “/root”。其他替换可在“说明符”下的 “man systemd.unit” 中找到。因为它超出了本文的范围,所以这就是我们目前需要了解的关于说明符的全部内容。
3\. 创建一个 .timer 文件,该文件实际上调度你创建的 .service。在 .service 文件相同位置 “~/.config/systemd/user/schedule-test.timer” 创建它。请注意,文件名仅在拓展名上有所不同,例如一个是 “.service”一个是 ".timer"。
```
[Unit]
Description=Schedule a message every 1 minute
RefuseManualStart=no # Allow manual starts
RefuseManualStop=no # Allow manual stops
[Timer]
#Execute job if it missed a run due to machine being off
Persistent=true
#Run 120 seconds after boot for the first time
OnBootSec=120
#Run every 1 minute thereafter
OnUnitActiveSec=60
#File describing job to execute
Unit=schedule-test.service
[Install]
WantedBy=timers.target
```
请注意,.timer 文件使用了 “OnUnitActiveSec” 来指定调度表。“OnCalendar” 选项更加灵活。例如:
```
# run on the minute of every minute every hour of every day
OnCalendar=*-*-* *:*:00
# run on the hour of every hour of every day
OnCalendar=*-*-* *:00:00
# run every day
OnCalendar=*-*-* 00:00:00
# run 11:12:13 of the first or fifth day of any month of the year
# 2012, but only if that day is a Thursday or Friday
OnCalendar=Thu,Fri 2012-*-1,5 11:12:13
```
有关 “OnCalendar” 的更多信息参见[这里][2]。
4\. 所有的部件都已就位,但你应该进行测试,以确保一切正常。首先,启用用户服务:
```
$ systemctl --user enable schedule-test.service
```
这将导致类似如下的输出:
```
Created symlink /home/<user>/.config/systemd/user/default.target.wants/schedule-test.service → /home/<user>/.config/systemd/user/schedule-test.service.
```
现在执行测试工作:
```
$ systemctl --user start schedule-test.service
```
检查你的输出文件($HOME/schedule-test-output.txt),确保你的脚本运行正常。应该只有一个条目,因为我们还没有启动定时器。必要时进行调试。如果你需要更改 .service 文件,而不是更改它调用的 shell 脚本,请不要忘记再次启用该服务。
5\. 一旦作业正常运行,通过为服务启用、启动用户定时器来实时调度作业:
```
$ systemctl --user enable schedule-test.timer
$ systemctl --user start schedule-test.timer
```
请注意你已经在上面的步骤4中启动、启用了服务因此只需要为它启用、启动定时器。
启用命令会产生如下输出:
```
Created symlink /home/<user>/.config/systemd/user/timers.target.wants/schedule-test.timer → /home/<user>/.config/systemd/user/schedule-test.timer.
```
启动命令将返回命令行界面提示。
### 其他操作
你可以检查和监控服务。如果你从系统服务收到错误,下面的第一个命令特别有用:
```
$ systemctl --user status schedule-test
$ systemctl --user list-unit-files
```
手动停止服务:
```
$ systemctl --user stop schedule-test.service
```
永久停止并禁用定时器和服务,重新加载守护程序配置并重置任何失败通知:
```
$ systemctl --user stop schedule-test.timer
$ systemctl --user disable schedule-test.timer
$ systemctl --user stop schedule-test.service
$ systemctl --user disable schedule-test.service
$ systemctl --user daemon-reload
$ systemctl --user reset-failed
```
### 总结
本文以 _systemd_ 定时器为出发点,但是 _systemd_ 的内容远不止于此。这篇文章应该为你提供一个基础。你可以从[Fedora Magazine systemd系列][3]开始探索更多。
参考 —— 更多阅读:
* man systemd.timer
* man systemd.service
* [Use systemd timers instead of cronjobs][4]
* [Understanding and administering systemd][5]
* <https://opensource.com/> 内有 systemd 快捷查询列表
--------------------------------------------------------------------------------
via: https://fedoramagazine.org/systemd-timers-for-scheduling-tasks/
作者:[Richard England][a]
选题:[lujun9972][b]
译者:[dcoliversun](https://github.com/dcoliversun)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://fedoramagazine.org/author/rlengland/
[b]: https://github.com/lujun9972
[1]: https://fedoramagazine.org/wp-content/uploads/2021/06/schedule_with_systemd_timer-816x345.jpg
[2]: https://www.freedesktop.org/software/systemd/man/systemd.time.html#Calendar%20Events
[3]: https://fedoramagazine.org/what-is-an-init-system/
[4]: https://opensource.com/article/20/7/systemd-timers
[5]: https://docs.fedoraproject.org/en-US/quick-docs/understanding-and-administering-systemd/

View File

@ -0,0 +1,110 @@
[#]: subject: (KTorrent: An Incredibly Useful BitTorrent Application by KDE)
[#]: via: (https://itsfoss.com/ktorrent/)
[#]: author: (Ankush Das https://itsfoss.com/author/ankush/)
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
KTorrentKDE 的一个非常有用的 BitTorrent 应用
======
Linux 中有各种各样的 BitTorrent 应用。但是,找到一个好的、提供许多功能的应用应该可以为你节省一些时间。
KDE 的 KTorrent 就是这样一个为 Linux 打造的 BitTorrent 应用。
虽然有 [Linux 有几个 torrent 客户端][1],但我最近发现 KTorrent 对我而言很有趣。
### KTorrent: 适用于 Linux 的开源 BitTorrent 客户端
![][2]
KTorrent 是一个成熟的 torrent 客户端,主要为 KDE 桌面定制。无论你使用什么桌面环境,它都能很好地工作。
当然使用KDE桌面你可以得到一个无缝的用户体验。
让我们来看看它的所有功能。
### KTorrent 的功能
![][3]
对于普通的 torrent 用户来说,拥有一套全面的功能使事情变得简单。而 KTorrent 也不例外。在这里,我将列出 KTorrent 的主要亮点:
* 在一个队列中添加 torrent 下载
* 能够控制每次下载(或整体)的速度限制
* 视频和音频文件预览选项
* 支持导入下载文件(部分/全部)。
* 在下载多个文件时,能够对 torrent 下载进行优先排序
* 为多文件 torrent 选择要下载的特定文件
* IP 过滤器,可选择踢走/禁止 peer。
* 支持 UDP 跟踪器
* 支持 µTorrent peer
* 支持协议加密
* 能够创建无 tracker 的 torrent
* 脚本支持
* 系统托盘集成
* 通过代理连接
* 增加了插件支持
* 支持 IPv6
KTorrent 听起来很有用,作为一个 torrent 客户端,你可以日常控制它在一个地方管理所有的 torrent 下载。
![][4]
除了上面提到的功能外,它还对客户端的行为提供了很大的控制。例如,调整指示下载/暂停/tracker 服务器的颜色。
如果你想禁用完成 torrent 下载的声音或得到活动通知,你还可以设置通知。
![][5]
虽然像协议加密支持这样的功能可能无法取代一些[最好的 VPN][6] 服务,但它对桌面客户端来说是一个重要的补充。
### 在 Linux 中安装 KTorrent
KTorrent 应该可以通过包管理器(如 [Synaptic][7])或默认的仓库获得。你也可以在你的软件中心找到它并轻松安装。
除此之外,它还在 [Flathub][9] 上提供了一个适用于任何 Linux 发行版的 [Flatpak][8] 官方包。如果你需要帮助,我们有一个 [Flatpak 指南][10]供参考。
如果你喜欢的话,你也可以尝试可用的 [snap包][11]。
要探索更多关于它和源码的信息,请前往它的[官方 KDE 应用页面][12]。
[KTorrent][12]
### 结束语
KTorrent 是 Linux 中一个出色的 torrent 客户端。我在我的 Linux Mint 系统的 Cinnamon 桌面上试用了它,它运行得很好。
我喜欢它的简单和可配置性。尽管我不是每天都在使用 torrent 客户端,但在我短暂的测试中,我没有发现 KTorrent 有什么奇怪的地方。
你认为 KTorrent 作为 Linux 的 torrent 客户端怎么样?你喜欢用什么呢?
--------------------------------------------------------------------------------
via: https://itsfoss.com/ktorrent/
作者:[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://itsfoss.com/best-torrent-ubuntu/
[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/ktorrent-download.png?resize=850%2C582&ssl=1
[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/06/ktorrent-configure.png?resize=850%2C656&ssl=1
[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/06/ktorrent-speed-limit.png?resize=850%2C585&ssl=1
[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/06/ktorrent-plugins.png?resize=850%2C643&ssl=1
[6]: https://itsfoss.com/best-vpn-linux/
[7]: https://itsfoss.com/synaptic-package-manager/
[8]: https://itsfoss.com/what-is-flatpak/
[9]: https://flathub.org/apps/details/org.kde.ktorrent
[10]: https://itsfoss.com/flatpak-guide/
[11]: https://snapcraft.io/ktorrent
[12]: https://apps.kde.org/ktorrent/