From bb8dbc59a6edb1194598a86345d24c0c1715c55d Mon Sep 17 00:00:00 2001 From: lkxed Date: Sun, 12 Jun 2022 10:39:10 +0800 Subject: [PATCH 01/78] Delete 20220610 To Favor Microsoft VS Code, Microsoft-s GitHub is Killing GitHub-s Atom Editor.md --- ... GitHub is Killing GitHub-s Atom Editor.md | 80 ------------------- 1 file changed, 80 deletions(-) delete mode 100644 sources/news/20220610 To Favor Microsoft VS Code, Microsoft-s GitHub is Killing GitHub-s Atom Editor.md diff --git a/sources/news/20220610 To Favor Microsoft VS Code, Microsoft-s GitHub is Killing GitHub-s Atom Editor.md b/sources/news/20220610 To Favor Microsoft VS Code, Microsoft-s GitHub is Killing GitHub-s Atom Editor.md deleted file mode 100644 index c10578130c..0000000000 --- a/sources/news/20220610 To Favor Microsoft VS Code, Microsoft-s GitHub is Killing GitHub-s Atom Editor.md +++ /dev/null @@ -1,80 +0,0 @@ -[#]: subject: "To Favor Microsoft VS Code, Microsoft’s GitHub is Killing GitHub’s Atom Editor" -[#]: via: "https://news.itsfoss.com/atom-being-discontinued/" -[#]: author: "Abhishek https://news.itsfoss.com/author/root/" -[#]: collector: "lkxed" -[#]: translator: " " -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " - -To Favor Microsoft VS Code, Microsoft’s GitHub is Killing GitHub’s Atom Editor -====== -We all knew this day would be coming sooner or later. - -![Microsoft kills GitHub's Atom][1] - -Coder, coder in the hall, which is the best editor of them all! - -Sorry for the really cheesy opening line. I could not prevent myself from writing that. Just as we all could not prevent the certain demise of the most loved open source code editor of the last decade, Atom. - -### A brief history of Atom - -Atom, released in 2014 by the then independent Git Hub team, was a huge hit among the programmers. - -Its neat UI, features, and numerous add-ons made it the hot favorite of the developers. - -It continued its popular run despite getting tough competition from Microsoft’s recently open-sourced VS Code editor. - -Atom’s loyal fanbase didn’t budge despite the rising popularity of the VS Code until[Microsoft acquired GitHub in 2018][2]. - -People started wondering how long will Microsoft continue developing two similar projects that don’t make any money for it directly. - -In the last four years, it did seem that Atom was losing its charm. It didn’t have any significant feature development while VS Code got more attractive as features after features landed in every release. - -The writing was on the wall. Microsoft branded VS Code was being favored over Atom. - -Though I don’t have any stats to back my claim, it did seem that Atom’s userbase was declining in the last couple of years. VS Code is like the default editor for young developers. - -It was only time that Microsoft pulled the plug on Atom and it did that finally. - -### GitHub discontinues Atom - -On June 8, Microsoft-owned GitHub [announced][3] that it is going to archive the entire Atom project on December 15, 2022. - -> …we’ve decided to retire Atom in order to further our commitment to bringing fast and reliable software development to the cloud via Microsoft Visual Studio Code and GitHub Codespaces. - -The stated reason is the same we all know; “Atom has not had significant feature development for the past several years” and “focus on enhancing the developer experience in the cloud with GitHub Codespaces”. - -The Atom project was more than just an editor though. For good or bad, whatever you feel like, Atom also gave birth to Electron framework. - -> It’s worth reflecting that Atom has served as the foundation for the Electron framework, which paved the way for the creation of thousands of apps, including Microsoft Visual Studio Code, Slack, and our very own GitHub Desktop. However, reliability, security, and performance are core to GitHub, and in order to best serve the developer community, we are archiving Atom to prioritize technologies that enable the future of software development. - -### Atom dies a slow death and its fork will likely meet the same fate - -Atom is open source so it’s not going to ‘rest in peace’ immediately. It will be resurrected (read forked) for sure. - -However, even if someone forks the project and continues to keep it alive, it’s not going to match up to VS Code anymore. At best, it will get a few bug fixes and minor new features. That’s not entirely bad for the hard-core Atom lovers but it won’t attract newer, younger coders. - -Ultimately, the forked projects will also be shut down eventually. It’s not possible for a couple of volunteer developers to match the might of a billion-dollar organization with huge infrastructure. [Atom won’t get compared to VS Code][4] any longer. - -Atom will be missed. Maybe not by as many people as it would have been if it was to discontinue in 2018. The noose was tightened around its neck slowly and we all witnessed it. - -Anyway, are you still using Atom? Will you move to VS Code or choose some other non-Microsoft editor? - --------------------------------------------------------------------------------- - -via: https://news.itsfoss.com/atom-being-discontinued/ - -作者:[Abhishek][a] -选题:[lkxed][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/root/ -[b]: https://github.com/lkxed -[1]: https://news.itsfoss.com/wp-content/uploads/2022/06/microsoft-kills-github-atom.png -[2]: https://itsfoss.com/microsoft-github/ -[3]: https://github.blog/2022-06-08-sunsetting-atom/ -[4]: https://itsfoss.com/visual-studio-code-vs-atom/ From 72a090dafe34d3b62d0f2c09769cc4fc92650823 Mon Sep 17 00:00:00 2001 From: lkxed Date: Sun, 12 Jun 2022 10:42:20 +0800 Subject: [PATCH 02/78] =?UTF-8?q?[=E7=94=B3=E9=A2=86=E5=8E=9F=E6=96=87][ne?= =?UTF-8?q?ws]:=2020220607=20OpenInfra=20Foundation=20Launches=20-directed?= =?UTF-8?q?=20funding-=20To=20Support=20Open=20Source=20Projects.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...unches -directed funding- To Support Open Source Projects.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/news/20220607 OpenInfra Foundation Launches -directed funding- To Support Open Source Projects.md b/sources/news/20220607 OpenInfra Foundation Launches -directed funding- To Support Open Source Projects.md index 887fd972a7..8275cdbda4 100644 --- a/sources/news/20220607 OpenInfra Foundation Launches -directed funding- To Support Open Source Projects.md +++ b/sources/news/20220607 OpenInfra Foundation Launches -directed funding- To Support Open Source Projects.md @@ -2,7 +2,7 @@ [#]: via: "https://www.opensourceforu.com/2022/06/openinfra-foundation-launches-directed-funding-to-support-open-source-projects/" [#]: author: "Laveesh Kocher https://www.opensourceforu.com/author/laveesh-kocher/" [#]: collector: "lkxed" -[#]: translator: " " +[#]: translator: "lkxed" [#]: reviewer: " " [#]: publisher: " " [#]: url: " " From b4c2df3e9a15e086885ea88f435e46b0dfd375f5 Mon Sep 17 00:00:00 2001 From: lkxed Date: Sun, 12 Jun 2022 11:05:24 +0800 Subject: [PATCH 03/78] =?UTF-8?q?[=E6=8F=90=E4=BA=A4=E8=AF=91=E6=96=87][ne?= =?UTF-8?q?ws]:=2020220607=20OpenInfra=20Foundation=20Launches=20-directed?= =?UTF-8?q?=20funding-=20To=20Support=20Open=20Source=20Projects.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...unding- To Support Open Source Projects.md | 47 ------------------- ...unding- To Support Open Source Projects.md | 47 +++++++++++++++++++ 2 files changed, 47 insertions(+), 47 deletions(-) delete mode 100644 sources/news/20220607 OpenInfra Foundation Launches -directed funding- To Support Open Source Projects.md create mode 100644 translated/news/20220607 OpenInfra Foundation Launches -directed funding- To Support Open Source Projects.md diff --git a/sources/news/20220607 OpenInfra Foundation Launches -directed funding- To Support Open Source Projects.md b/sources/news/20220607 OpenInfra Foundation Launches -directed funding- To Support Open Source Projects.md deleted file mode 100644 index 8275cdbda4..0000000000 --- a/sources/news/20220607 OpenInfra Foundation Launches -directed funding- To Support Open Source Projects.md +++ /dev/null @@ -1,47 +0,0 @@ -[#]: subject: "OpenInfra Foundation Launches ‘directed funding’ To Support Open Source Projects" -[#]: via: "https://www.opensourceforu.com/2022/06/openinfra-foundation-launches-directed-funding-to-support-open-source-projects/" -[#]: author: "Laveesh Kocher https://www.opensourceforu.com/author/laveesh-kocher/" -[#]: collector: "lkxed" -[#]: translator: "lkxed" -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " - -OpenInfra Foundation Launches ‘directed funding’ To Support Open Source Projects -====== -![open-infra-berlin-event][1] - -The OpenInfra Foundation, formerly known as the OpenStack Foundation until it expanded its scope beyond its flagship project a few years ago, announced today an intriguing new way for companies to fund open source projects within the foundation. Corporate members of open source foundations have traditionally supported the organisation by paying a membership fee, which the foundations then distribute as they see fit. The OpenInfra foundation is now launching a new ‘Directed Funding’ model that allows members to direct their funds directly to a project. - -The foundation previously did not allow this because, as Bryce pointed out, it can create mixed incentives and a pay-for-play dynamic, which the organisation has always tried to avoid. However, there was a lot of interest in the community to support specific projects, which makes sense given that the foundation is now home to a wider variety of projects, but not every member is heavily invested in every project. - -Bryce stated that the foundation’s leadership and board spent a significant amount of time considering how to reconcile the foundation’s core principles with this new model. As a result, the model tries to combine the best of the OpenStack/OpenInfra technical governance model, which has worked well over the last decade, with these new financial considerations. - -Under this ‘directed funding’ model, each new project will have its own legal entity that will hold the project funding. To ensure that the new projects are legitimate, an OpenInfra Platinum member (currently nine, including Ant Group, Huawei, Meta, Microsoft, and Red Hat) must serve as the project’s sponsor, after which other organisations can join the project fund. If a sponsoring company is not already an OpenInfra member, it must become one. All of these funding members then form a project fund governing board, which decides on the fees for creating a budget. Meanwhile, the OpenInfra Foundation will provide these projects with community-building services. - -This new model will, for the time being, only apply to new projects that join the foundation. Bryce and Collier noted that there may be some existing projects where the organisation could retroactively apply this new model, but that is not currently on the roadmap. - -The OpenInfra foundation has added projects such as Kata Containers for increased container security, Airship for infrastructure lifecycle management, the Startling X edge compute stack, and the Zuul CI/CD platform since it expanded beyond OpenStack. - -“The most important thing we’ve learned from each of these successful projects is that collaboration is key and the more breadth in the ecosystem of support the better,” said Thierry Carrez, general manager of the OpenInfra Foundation. “In fact, we’ve found that the most successful open source projects are funded by multiple companies, because they are able to combine their resources to achieve a much stronger rate of return.” - -This new model is clearly a way for the OpenInfra Foundation to bring new projects — and new members — into the fold. Its models for managing open source projects in a multi-party ecosystem — both through the new directed funds and its more traditional approach — may not be suitable for every project, as the leadership team readily admits. Even if the OpenInfra Foundation only receives a small percentage of projects, the number of open-source projects is increasing as the demand for these sophisticated cloud infrastructure projects grows, all while they become more complex. - -The Foundation also announced a couple of milestone releases for its various projects, including version 2.0 of Kata Containers, version 5.0 of Zuul, and the release of StarlingX 6.0. - -“The Foundation celebrates its 10 anniversary this year, and as we look to our next decade of open infrastructure, we’re building momentum on what makes our model so successful: aligning companies and individuals who wish to work together, providing them with a framework and tools to effectively collaborate, and helping them invest their funds to best help the project they care about,” said Collier. - --------------------------------------------------------------------------------- - -via: https://www.opensourceforu.com/2022/06/openinfra-foundation-launches-directed-funding-to-support-open-source-projects/ - -作者:[Laveesh Kocher][a] -选题:[lkxed][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.opensourceforu.com/author/laveesh-kocher/ -[b]: https://github.com/lkxed -[1]: https://www.opensourceforu.com/wp-content/uploads/2022/06/open-infra-berlin-event.png diff --git a/translated/news/20220607 OpenInfra Foundation Launches -directed funding- To Support Open Source Projects.md b/translated/news/20220607 OpenInfra Foundation Launches -directed funding- To Support Open Source Projects.md new file mode 100644 index 0000000000..afb2eadb4f --- /dev/null +++ b/translated/news/20220607 OpenInfra Foundation Launches -directed funding- To Support Open Source Projects.md @@ -0,0 +1,47 @@ +[#]: subject: "OpenInfra Foundation Launches ‘directed funding’ To Support Open Source Projects" +[#]: via: "https://www.opensourceforu.com/2022/06/openinfra-foundation-launches-directed-funding-to-support-open-source-projects/" +[#]: author: "Laveesh Kocher https://www.opensourceforu.com/author/laveesh-kocher/" +[#]: collector: "lkxed" +[#]: translator: "lkxed" +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +OpenInfra 基金会启动“定向资助”以支持开源项目 +====== +![OpenInfra][1] + +OpenInfra 基金会的前身为 OpenStack 基金会,几年前它将范围扩展到其旗舰项目之外,于是改了名字。今天(2022 年 6 月 7 日),它宣布了一种有趣的新方式,以供公司在基金会内资助开源项目。一般来说,开源基金会的企业成员通过支付会员费来支持该组织,然后基金会按照他们认为合适的方式分发这些费用。OpenInfra 基金会现在推出了一种新的“定向资助”模式,允许成员将他们的资金直接用于项目。 + +此前,基金会并不允许这样做,因为正如 Bryce 指出的那样,它可能会产生混合激励和付费游戏动态,而该组织一直试图避免这种情况。然而,社区对支持特定项目有很大的兴趣,这是有道理的,因为该基金会现在拥有更多种类的项目,但并不是每个成员都对每个项目进行了投入了大量精力。 + +Bryce 表示,基金会的领导层和董事会,花费了大量时间来考虑,如何使基金会的核心原则与这种新模式相协调。因此,该模型试图将过去十年运行良好的 OpenStack/OpenInfra 技术治理模型的优点,与这些新的财务考虑相结合。 + +在这种“定向资助”模式下,每个新项目都将拥有自己的法人实体来持有项目资金。为确保新项目的合法性,OpenInfra Platinum 会员(目前为 9 家,包括蚂蚁集团、华为、Meta、微软和红帽)必须担任项目的发起人,之后其他组织才能加入项目基金。如果赞助公司还不是 OpenInfra 成员,则必须成为其中的成员。然后,所有这些资助成员组成一个项目基金管理委员会,决定创建预算的费用。与此同时,OpenInfra 基金会将为这些项目提供社区建设服务。 + +这种新模式暂时只适用于加入基金会的新项目。 Bryce 和 Collier 指出,组织可能会在一些现有项目中追溯应用这种新模式,但这个考虑目前不在路线图上。 + +自从将范围扩展到 OpenStack 之后,OpenInfra 基金会增加了一些新项目,例如用于提高容器安全性的 Kata Containers、用于基础设施生命周期管理的 Airship、Startling X 边缘计算堆栈以及 Zuul CI/CD 平台。 + +“我们从每个成功的项目中学到的最重要的一点是,协作是关键,支持生态系统的范围越广越好,” OpenInfra 基金会总经理 Thierry Carrez 说, “事实上,我们发现最成功的开源项目是由多家公司资助的,因为他们能够整合资源以实现更高的回报率。” + +这种新模式显然是 OpenInfra 基金会引入新项目和新成员的一种方式。正如领导团队欣然承认的那样,其在多方生态系统中管理开源项目的模型 —— 无论是通过新的定向资金还是更传统的方法 —— 可能并不适合每个项目。即使 OpenInfra 基金会只收到一小部分项目,随着对这些复杂云基础设施项目需求的增长,开源项目的数量也在增加,同时它们也变得更加复杂。 + +基金会还宣布了其各个项目的几个里程碑版本,包括 Kata Containers 2.0 版、Zuul 5.0 版和 StarlingX 6.0 的发布。 + +Collier 说:“基金会今年庆祝成立 10 周年,在展望下一个十年的开放基础设施之际,我们正在推动我们的模型如此成功的关键,那就是:将希望合作的公司和个人联合起来,为他们提供一个框架和有效协作的工具,并帮助他们投资资金以最好地帮助他们关心的项目。” + +-------------------------------------------------------------------------------- + +via: https://www.opensourceforu.com/2022/06/openinfra-foundation-launches-directed-funding-to-support-open-source-projects/ + +作者:[Laveesh Kocher][a] +选题:[lkxed][b] +译者:[lkxed](https://github.com/lkxed) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.opensourceforu.com/author/laveesh-kocher/ +[b]: https://github.com/lkxed +[1]: https://www.opensourceforu.com/wp-content/uploads/2022/06/open-infra-berlin-event.png From aa08bec3bab9f9f45bc92b88f6850ffe448ca609 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=AD=E5=BC=80=E7=AE=B1?= Date: Sun, 12 Jun 2022 11:06:56 +0800 Subject: [PATCH 04/78] Update 20220607 OpenInfra Foundation Launches -directed funding- To Support Open Source Projects.md --- ...ches -directed funding- To Support Open Source Projects.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/translated/news/20220607 OpenInfra Foundation Launches -directed funding- To Support Open Source Projects.md b/translated/news/20220607 OpenInfra Foundation Launches -directed funding- To Support Open Source Projects.md index afb2eadb4f..19d35cc4fb 100644 --- a/translated/news/20220607 OpenInfra Foundation Launches -directed funding- To Support Open Source Projects.md +++ b/translated/news/20220607 OpenInfra Foundation Launches -directed funding- To Support Open Source Projects.md @@ -19,11 +19,11 @@ Bryce 表示,基金会的领导层和董事会,花费了大量时间来考 在这种“定向资助”模式下,每个新项目都将拥有自己的法人实体来持有项目资金。为确保新项目的合法性,OpenInfra Platinum 会员(目前为 9 家,包括蚂蚁集团、华为、Meta、微软和红帽)必须担任项目的发起人,之后其他组织才能加入项目基金。如果赞助公司还不是 OpenInfra 成员,则必须成为其中的成员。然后,所有这些资助成员组成一个项目基金管理委员会,决定创建预算的费用。与此同时,OpenInfra 基金会将为这些项目提供社区建设服务。 -这种新模式暂时只适用于加入基金会的新项目。 Bryce 和 Collier 指出,组织可能会在一些现有项目中追溯应用这种新模式,但这个考虑目前不在路线图上。 +这种新模式暂时只适用于加入基金会的新项目。Bryce 和 Collier 指出,组织可能会在一些现有项目中追溯应用这种新模式,但这个考虑目前不在路线图上。 自从将范围扩展到 OpenStack 之后,OpenInfra 基金会增加了一些新项目,例如用于提高容器安全性的 Kata Containers、用于基础设施生命周期管理的 Airship、Startling X 边缘计算堆栈以及 Zuul CI/CD 平台。 -“我们从每个成功的项目中学到的最重要的一点是,协作是关键,支持生态系统的范围越广越好,” OpenInfra 基金会总经理 Thierry Carrez 说, “事实上,我们发现最成功的开源项目是由多家公司资助的,因为他们能够整合资源以实现更高的回报率。” +“我们从每个成功的项目中学到的最重要的一点是,协作是关键,支持生态系统的范围越广越好,” OpenInfra 基金会总经理 Thierry Carrez 说,“事实上,我们发现最成功的开源项目是由多家公司资助的,因为他们能够整合资源以实现更高的回报率。” 这种新模式显然是 OpenInfra 基金会引入新项目和新成员的一种方式。正如领导团队欣然承认的那样,其在多方生态系统中管理开源项目的模型 —— 无论是通过新的定向资金还是更传统的方法 —— 可能并不适合每个项目。即使 OpenInfra 基金会只收到一小部分项目,随着对这些复杂云基础设施项目需求的增长,开源项目的数量也在增加,同时它们也变得更加复杂。 From c41cd568259bcf8cd5df3e0d9c5aaec4ea192a04 Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Sun, 12 Jun 2022 11:07:29 +0800 Subject: [PATCH 05/78] RP @robsean https://linux.cn/article-14699-1.html --- ...al Boot Ubuntu 22.04 LTS and Windows 11.md | 68 ++++++++++--------- 1 file changed, 35 insertions(+), 33 deletions(-) rename {translated/tech => published}/20220516 How to Dual Boot Ubuntu 22.04 LTS and Windows 11.md (66%) diff --git a/translated/tech/20220516 How to Dual Boot Ubuntu 22.04 LTS and Windows 11.md b/published/20220516 How to Dual Boot Ubuntu 22.04 LTS and Windows 11.md similarity index 66% rename from translated/tech/20220516 How to Dual Boot Ubuntu 22.04 LTS and Windows 11.md rename to published/20220516 How to Dual Boot Ubuntu 22.04 LTS and Windows 11.md index 0a27cd46b5..3908d3ef57 100644 --- a/translated/tech/20220516 How to Dual Boot Ubuntu 22.04 LTS and Windows 11.md +++ b/published/20220516 How to Dual Boot Ubuntu 22.04 LTS and Windows 11.md @@ -3,45 +3,47 @@ [#]: author: "James Kiarie https://www.linuxtechi.com/author/james/" [#]: collector: "lkxed" [#]: translator: "robsean" -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14699-1.html" 如何双启动 Ubuntu 22.04 LTS 和 Windows 11 ====== -嗨,伙计们,在这篇指南中,我们将演示如何在 Windows 11 的旁侧配置 Ubuntu 22.04 LTS (Jammy Jellyfish) 的双启动设置 -为使其能工作,你需要在你的计算机上安装 windows 11 。接下来,你将需要在你的硬盘驱动器上创建一个单独的分区,你将在此分区上安装 Ubuntu 22.04 。我们将包含这点知识,因此不要担心。 +![](https://img.linux.net.cn/data/attachment/album/202206/12/110546fff10ck07e2p0z2f.jpg) -##### 必要条件  +嗨,伙计们,在这篇指南中,我们将演示如何在 Windows 11 的之外配置 Ubuntu 22.04 LTS(Jammy Jellyfish)的双启动设置。 -在设置双启动前,这些是你所需要的。 +为使其能工作,你需要在你的计算机上已经安装好了 Windows 11 。接下来,你将需要在你的硬盘驱动器上创建一个单独的分区,你将在此分区上安装 Ubuntu 22.04 。我们将包含这点知识,因此不要担心。 -* 一个 Ubuntu 22.04 的可启动 USB 驱动器,你可以转到 [Ubuntu 22.04 下载页面][1] 来下载 Ubuntu 22.04 的 ISO 镜像文件。在 ISO 镜像文件到位后,抓取一个 16GB USB 驱动器,并使用 Rufus 应用程序来使其可启动。 +**前置条件:** -* 快速稳定的因特网连接 +在设置双启动前,这些是你所需要的: + +* 一个 Ubuntu 22.04 的可启动 USB 驱动器,你可以转到 [Ubuntu 22.04 下载页面][1] 来下载 Ubuntu 22.04 的 ISO 镜像文件。在 ISO 镜像文件到位后,拿一个 16GB USB 驱动器,并使用 Rufus 应用程序来使其可启动。 +* 快速稳定的互联网连接 ### 步骤 1、在你的硬盘驱动器上创建一个可用的分区  正如介绍中所提到的,我们首先需要在硬盘驱动器上创建一个单独的分区,我们将在其中安装 Ubuntu 22.04 。 -因此,通过按下 **Windows + R** 组合键来打开磁盘管理器实用程序 +因此,通过按下 `Windows + R` 组合键来打开磁盘管理器实用程序。 -在对话框中,输入 diskmgmt.msc ,并按下 回车键ENTER 按键。 +在对话框中,输入 `diskmgmt.msc` ,并按下回车键。 ![][2] - 磁盘管理disk management控制台将显示当前磁盘分区,如你将在下面所看到的一样。我们将通过压缩 ‘卷 E’ 来创建一个用于安装 Ubuntu 的分区。这在你的安装过程中可能有所不同,但是只需要跟着做,你就会理解其中的大体意思。 +磁盘管理disk management控制台将显示当前磁盘分区,如你将在下面所看到的一样。我们将通过压缩 “卷 E” 来创建一个用于安装 Ubuntu 的分区。这在你的安装过程中可能有所不同,但是只需要跟着做,你就会理解其中的大体意思。 ![][3] -因此,在你想要压缩的磁盘驱动器卷上右键,并在弹出的菜单中选择 压缩卷Shrink 选项。 +因此,在你想要压缩的磁盘驱动器卷上点击鼠标右键,并在弹出的菜单中选择 压缩卷Shrink 选项。 ![][4] -一个弹出对话框将会出现,如下所示。具体指定压缩的控件大小(以 MB 为单位),并单 压缩卷Shrink 。 +将会出现一个弹出对话框,如下所示。具体指定压缩的控件大小(以 MB 为单位),并单击 压缩卷Shrink 。 -这是指定给 Ubuntu 22.04 安装所用的空间. +这是指定给 Ubuntu 22.04 安装所用的空间。 ![][5] @@ -49,11 +51,11 @@ ![][6] -随着可用空间的到来,现在将可启动 USB 媒介盘插入到你的 PC ,并重新启动你的系统。此外,要确保访问 BIOS 设置,并修改启动优先级,来使 USB 驱动器成为第一优先级。保存 BIOS 更改并继续启动。 +随着有了可用空间,现在将可启动 USB 驱动器插入到你的 PC ,并重新启动你的系统。此外,要确保访问 BIOS 设置,并修改启动优先级,来使 USB 驱动器成为第一优先级。保存 BIOS 更改并继续启动。 ### 步骤 2、开始安装 -在第一屏幕中,你将得到如图所示的 GRUB 菜单。选择第一个选项 尝试或安装 UbuntuTry or Install Ubuntu ,并按下 回车键ENTER 按键。 +在第一个屏幕中,你将得到如图所示的 GRUB 菜单。选择第一个选项 尝试或安装 UbuntuTry or Install Ubuntu ,并按下 回车键ENTER 按键。 ![][7] @@ -69,7 +71,7 @@ Ubuntu 22.04 将开始加载,如下所示。这最多需要一分钟。 ![][10] -在 更新和其它软件Updates and Other Software 步骤中,选择 正常安装Normal Installation以便安装 Ubuntu的 GUI 版本,通过勾选其它剩余选项来允许下载更新和安装第三方的针对于图像、WIFI 硬件和其它实用程序的软件包 +在 更新和其它软件Updates and Other Software 步骤中,选择 正常安装Normal Installation 以便安装 Ubuntu的 GUI 版本,通过勾选其它剩余选项来允许下载更新和安装第三方的针对于图像、WIFI 硬件和其它实用程序的软件包。 接下来,单击 继续Continue 按钮。 @@ -85,29 +87,29 @@ Ubuntu 22.04 将开始加载,如下所示。这最多需要一分钟。 针对 Ubuntu 22.04 ,我们将创建下面的分区: -* /boot        –        1 GB -* /home        –        10 GB -* /            –        12 GB -* Swap         –         2 GB -* EFI          –       300 MB +* `/boot`        –        1 GB +* `/home`        –        10 GB +* `/`            –        12 GB +* 交换分区        –         2 GB +* EFI           –       300 MB -为开始使用这些分区,单击 可用空间Free Space分区下面的 [ + ] 符号。 +为开始使用这些分区,单击 可用空间Free Space分区下面的 “+” 符号。 ![][13] -如图显示填写 /boot 分区的详细信息,然后单击 确定OK 按钮。 +如图显示填写 `/boot` 分区的详细信息,然后单击 确定OK 按钮。 ![][14] -接下来,具体指定 /home 分区,并单击 确定OK 按钮。 +接下来,具体指定 `/home` 分区,并单击 确定OK 按钮。 ![][15] -接下来,定义 / ( root ) 分区,并单击 确定OK 按钮。 +接下来,定义 `/`(根)分区,并单击 确定OK 按钮。 ![][16] -为定义 swap 空间,设置大小,并在 使用为Use as:选项中选择 交换区域Swap area。 +为定义交换空间,设置大小,并在 使用为Use as:选项中选择 交换区域Swap area。 ![][17] @@ -115,7 +117,7 @@ Ubuntu 22.04 将开始加载,如下所示。这最多需要一分钟。 ![][18] -下图是一份我们的分区表的分区摘要。 +下图是一份我们的分区表的分区摘要: ![][19] @@ -141,13 +143,13 @@ Ubuntu 22.04 将开始加载,如下所示。这最多需要一分钟。 ![][24] -在这时,移除你的可启动 USB 驱动器,并按下 回车键ENTER 按键。 +在这时,移除你的可启动 USB 驱动器,并按下回车键。 ![][25] -在系统重新启动时,你将找到 Ubuntu 和 Windows 11 的所有选项。 +在系统重新启动时,你将找到包括 Ubuntu 和 Windows 11 在内的各种选项。 -选择 ‘Ubuntu’ 来启动到你的新 Ubuntu 22.04 安装。为启动到 Windows 11,选择标有 Windows 恢复环境Windows Recovery Environment 的条目。 +选择 “Ubuntu” 来启动到你的新 Ubuntu 22.04 安装。要启动到 Windows 11,请选择标有 Windows 恢复环境Windows Recovery Environment 的条目。 ![][26] @@ -160,7 +162,7 @@ via: https://www.linuxtechi.com/dual-boot-ubuntu-22-04-and-windows-11/ 作者:[James Kiarie][a] 选题:[lkxed][b] 译者:[robsean](https://github.com/robsean) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 2db2ad64f7329cbd45361a7be510dab084ddaa8f Mon Sep 17 00:00:00 2001 From: lkxed Date: Sun, 12 Jun 2022 11:07:44 +0800 Subject: [PATCH 06/78] =?UTF-8?q?[=E7=94=B3=E9=A2=86=E5=8E=9F=E6=96=87][ne?= =?UTF-8?q?ws]:=2020220609=20Cloudflare=20Has=20Something=20New=20to=20Rep?= =?UTF-8?q?lace=20Annoying=20CAPTCHAs=20on=20the=20Internet.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...omething New to Replace Annoying CAPTCHAs on the Internet.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/news/20220609 Cloudflare Has Something New to Replace Annoying CAPTCHAs on the Internet.md b/sources/news/20220609 Cloudflare Has Something New to Replace Annoying CAPTCHAs on the Internet.md index 80fe54aece..6016018ea8 100644 --- a/sources/news/20220609 Cloudflare Has Something New to Replace Annoying CAPTCHAs on the Internet.md +++ b/sources/news/20220609 Cloudflare Has Something New to Replace Annoying CAPTCHAs on the Internet.md @@ -2,7 +2,7 @@ [#]: via: "https://news.itsfoss.com/cloudflare-pat/" [#]: author: "Jacob Crume https://news.itsfoss.com/author/jacob/" [#]: collector: "lkxed" -[#]: translator: " " +[#]: translator: "lkxed" [#]: reviewer: " " [#]: publisher: " " [#]: url: " " From 6e9bf784792a54cb214e1bf9cdec52a11f272c53 Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Sun, 12 Jun 2022 11:11:03 +0800 Subject: [PATCH 07/78] R --- ...20220516 How to Dual Boot Ubuntu 22.04 LTS and Windows 11.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/published/20220516 How to Dual Boot Ubuntu 22.04 LTS and Windows 11.md b/published/20220516 How to Dual Boot Ubuntu 22.04 LTS and Windows 11.md index 3908d3ef57..4004bcb938 100644 --- a/published/20220516 How to Dual Boot Ubuntu 22.04 LTS and Windows 11.md +++ b/published/20220516 How to Dual Boot Ubuntu 22.04 LTS and Windows 11.md @@ -153,7 +153,7 @@ Ubuntu 22.04 将开始加载,如下所示。这最多需要一分钟。 ![][26] -就这样。我们演示了如何双启动 Windows 11 和 Ubuntu 22.04. +就这样。我们演示了如何双启动 Windows 11 和 Ubuntu 22.04。 -------------------------------------------------------------------------------- From 4f45bc2638fc688a6968d67092c3fe82eec22f68 Mon Sep 17 00:00:00 2001 From: lkxed Date: Sun, 12 Jun 2022 11:54:59 +0800 Subject: [PATCH 08/78] =?UTF-8?q?[=E6=8F=90=E4=BA=A4=E8=AF=91=E6=96=87][ne?= =?UTF-8?q?ws]:=2020220609=20Cloudflare=20Has=20Something=20New=20to=20Rep?= =?UTF-8?q?lace=20Annoying=20CAPTCHAs=20on=20the=20Internet.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...place Annoying CAPTCHAs on the Internet.md | 86 ------------------- ...place Annoying CAPTCHAs on the Internet.md | 86 +++++++++++++++++++ 2 files changed, 86 insertions(+), 86 deletions(-) delete mode 100644 sources/news/20220609 Cloudflare Has Something New to Replace Annoying CAPTCHAs on the Internet.md create mode 100644 translated/news/20220609 Cloudflare Has Something New to Replace Annoying CAPTCHAs on the Internet.md diff --git a/sources/news/20220609 Cloudflare Has Something New to Replace Annoying CAPTCHAs on the Internet.md b/sources/news/20220609 Cloudflare Has Something New to Replace Annoying CAPTCHAs on the Internet.md deleted file mode 100644 index 6016018ea8..0000000000 --- a/sources/news/20220609 Cloudflare Has Something New to Replace Annoying CAPTCHAs on the Internet.md +++ /dev/null @@ -1,86 +0,0 @@ -[#]: subject: "Cloudflare Has Something New to Replace Annoying CAPTCHAs on the Internet" -[#]: via: "https://news.itsfoss.com/cloudflare-pat/" -[#]: author: "Jacob Crume https://news.itsfoss.com/author/jacob/" -[#]: collector: "lkxed" -[#]: translator: "lkxed" -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " - -Cloudflare Has Something New to Replace Annoying CAPTCHAs on the Internet -====== -Don’t want to complete CAPTCHA challenges to prove that you are a human? Cloudflare might have a solution for that. - -![cloudflare][1] - -Cloudflare, the internet services giant, has [just announced][2] Private Access Tokens. These aim to reduce the number of CAPTCHAs you see on the web while improving your privacy. - -As you may have found out, CAPTCHAs are a horrible experience on mobile. They often end up occupying the entire screen and can be impossible to complete at times. - -As an alternative, websites can elect to collect uniquely identifying data to prove that you are a human. Of course, from a privacy standpoint, this practice is terrible, leaving many privacy-valuing companies with little to prevent them from bot attacks. - -Fortunately, the release of Private Access Tokens, or PATs, is set to change this. - -### What Impact Will Private Access Tokens Have? - -In short, PATs will: - -* Reduce the number of CAPTCHAs on supported devices -* Increase user privacy -* Allow website owners to ensure that visitors are coming from actual devices - -However, diving in a little deeper, we can see that PATs are much more impactful than at first glance. With traditional CAPTCHAs, there are multiple entities that can access your data. - -Firstly, the website you are visiting knows your IP address and the URL you are visiting. Of course, this data is the minimum required to establish a connection. Additionally, for more advanced functionality, websites are also sent some user agent data, which is not uniquely identifiable. - -However, the second party, the CAPTCHA provider, can collect a lot more data. Like with the website you want to visit, it knows your IP address, user agent data, and the URL you visit. Unfortunately, they also collect additional data, like your device information and interaction data. When tied back with previous times you have completed a CAPTCHA, they can build up an astonishingly detailed profile of you. - -Fortunately, PATs by Cloudflare prevent such data from being collected, by ultimately bypassing the CAPTCHA altogether. - -### How Do PATs Work? - -![][3] - -Unlike the CAPTCHA method of aggregating as much data as possible, PATs decentralize the data so that no single party can uniquely identify you. Before you mention data sharing, Cloudflare has specifically mentioned that data is not shared between parties. - -When you go on to a website utilizing Cloudflare and PATs, a total of three parties will handle different portions of your data. - -1. The website. This will only know your IP, URL, and user agent, which again, is required for establishing a connection. -2. Your device manufacturer. This will only know the device data required to verify that your device is genuine. They will NOT know what website you are visiting, or your IP address. After verifying your device, they will generate a token, which will be sent to Cloudflare. -3. Cloudflare. Cloudflare will receive the token, which does not contain any of your device data, only a ‘guarantee’ of sorts from the manufacturer that it is genuine. The only other data they know is the website you are visiting, which is required to serve you the content. - -The result of this is a system that gives Cloudflare confidence in you being a human, without ever having to touch your data. - -### Supported Operating Systems: No Linux? - -As you may have realized, PATs need specific operating system features to work. Currently, they are only present on the latest operating systems by Apple, namely iOS and iPadOS 16, as well as macOS Ventura. This is because Apple’s operating systems run on a limited set of hardware, making device verification significantly easier. - -Linux, on the other hand, is a general-purpose operating system designed to run on a wide range of hardware. As a result, I don’t expect to see it support PATs in the near future. - -Going back to Apple, it occurs to me that PATs could also cause some issues with consumers’ right to repair their devices. If, for example, I replaced a worn-out iPhone battery with a non-genuine one, would this be flagged by the PAT system? - -What about Linux Phones? Manufacturers of these, like Pine64 and Purism, may not have the infrastructure to support such a system. Will it be possible to use PATs on these? - -In the [announcement post][4], Cloudflare mentions: - -> We are actively working to get other clients and device makers utilizing the PAT framework as well. Any time a new client begins utilizing the PAT framework, traffic coming to your site from that client will automatically start asking for tokens, and your visitors will automatically see fewer CAPTCHAs. - -So, we hope to see it being adopted by more devices, and operating systems. What do you think about PATs by Cloudflare? Let me know your thoughts in the comments down below. - --------------------------------------------------------------------------------- - -via: https://news.itsfoss.com/cloudflare-pat/ - -作者:[Jacob Crume][a] -选题:[lkxed][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/jacob/ -[b]: https://github.com/lkxed -[1]: https://news.itsfoss.com/wp-content/uploads/2022/06/cloudflare-private-access-tokens.jpg -[2]: https://blog.cloudflare.com/eliminating-captchas-on-iphones-and-macs-using-new-standard/ -[3]: https://news.itsfoss.com/wp-content/uploads/2022/06/PAT-Data-transfer-chart-1024x650.png -[4]: https://blog.cloudflare.com/eliminating-captchas-on-iphones-and-macs-using-new-standard/ diff --git a/translated/news/20220609 Cloudflare Has Something New to Replace Annoying CAPTCHAs on the Internet.md b/translated/news/20220609 Cloudflare Has Something New to Replace Annoying CAPTCHAs on the Internet.md new file mode 100644 index 0000000000..cd45d29858 --- /dev/null +++ b/translated/news/20220609 Cloudflare Has Something New to Replace Annoying CAPTCHAs on the Internet.md @@ -0,0 +1,86 @@ +[#]: subject: "Cloudflare Has Something New to Replace Annoying CAPTCHAs on the Internet" +[#]: via: "https://news.itsfoss.com/cloudflare-pat/" +[#]: author: "Jacob Crume https://news.itsfoss.com/author/jacob/" +[#]: collector: "lkxed" +[#]: translator: "lkxed" +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +Cloudflare 有了一个新东西,它可以替代互联网上烦人的验证码 +====== +不想通过正确输入 验证码CAPTCHA 来证明自己是个人类吗?Cloudflare 可能有了一个解决方案。 + +![Cloudflare][1] + +互联网服务巨头 Cloudflare(在 6 月 9 日)[刚刚宣布了][2] 私有访问令牌Private Access Tokens 功能。这项功能旨在减少你在网络上看到的验证码数量,同时改善你的隐私。 + +你可能已经发现,验证码在移动设备上是一种可怕的体验。通常,它们会最终会占据整个屏幕,有时甚至也无法完成。 + +作为替代方案,网站可以选择收集唯一识别数据,以证明你是人类。当然,从隐私的角度来看,这种做法是很糟糕的。如果这么做,许多重视隐私的公司都几乎无法避免 僵尸攻击bot attacks。 + +幸运的是,私有访问令牌(PATs)的发布将改变这一点。 + +### 私有访问令牌会产生什么影响? + +简而言之,私有访问令牌能够做到下面这些事: + +* 在支持设备上减少验证码数量 +* 增强用户隐私 +* 允许网站所有者确保访问者来自真实设备 + +然而,深入观察,我们可以看到私有访问令牌的影响力远不止于此。若使用传统的验证码,就有多个实体可以访问你的数据。 + +首先,你正在访问的网站知道你的 IP 地址和你正在访问的 URL。当然,这些数据是建立连接所需的最低要求。此外,对于更高级的功能,网站还会发送一些用户代理数据,还好这些数据并不是唯一可识别的。 + +然而,另一方,也就是验证码提供者,却可以收集更多的数据。与你要访问的网站一样,它也知道你的 IP 地址、用户代理数据和你访问的 URL。不幸的是,除此之外,他们还会收集其他数据,例如你的设备信息和交互数据。如果把这些信息,与你之前完成验证码的时间联系起来,你就会惊讶的发现,他们可以建立一个非常详细的属于你的个人资料。 + +幸运的是,有了 Cloudflare 的私有访问令牌,你就可以完全绕过验证码,从而阻止验证码提供者收集此类数据。 + +### 私有访问令牌是如何工作的? + +![][3] + +验证码的理念是集中尽可能多的数据,私人访问令牌则恰恰相反,它将数据去中心化,因此任何一方都无法唯一识别你。在你提到数据共享之前,Cloudflare 就已经特别指出了,数据不会在各方之间共享。 + +当你访问使用 Cloudflare 和私人访问令牌的网站的时候,共有三方将处理你的数据的不同部分。 + +1. 网站。它只会知道你的 IP、URL 和用户代理,这也是建立连接所必需的。 +2. 你的设备制造商。他们只会知道那些用于验证设备是否真实所需的设备数据,而不会知道你正在访问哪个网站,或你的 IP 地址是什么。验证了你的设备后,他们将生成一个令牌,该令牌将发送到 Cloudflare。 +3. Cloudflare。他们将收到这个令牌,令牌中不包含你的任何设备数据,只有制造商对它是正品的“保证”。他们知道的唯一其他数据,就是你正在访问的网站,同样,这是为你提供内容所必需的。 + +通过这种方式,Cloudflare 无需接触你的数据,就可以对“你是一个人”充满信心。 + +### 支持的操作系统:没有 Linux? + +你可能已经意识到,私人访问令牌需要特定的操作系统功能才能工作。目前,它们仅存在于苹果最新的操作系统上,即 iOS 和 iPadOS 16,以及 macOS Ventura。这是因为苹果的操作系统只在有限的硬件上运行,设备验证会更加容易。 + +另一方面,Linux 是一种通用操作系统,旨在在各种硬件上运行。因此,我认为,在可预见的未来,它都不会支持私人访问令牌。 + +回到苹果,我想到私人访问令牌也可能导致消费者维修设备的权利出现一些问题。例如,如果我用第三方的非正品电池更换了老旧的 iPhone 原装电池,私人访问令牌系统会特殊对待这种情况吗? + +如果是 Linux 手机呢?这些制造商,如 Pine64 和 Purism,可能没有支持这样一个系统的基础设施。是否可以在这些上使用私人访问令牌呢? + +Cloudflare 在 [公告帖][4] 中提到: + +> 我们正在积极努力让其他客户和设备制造商也使用私人访问令牌框架。每当新客户开始使用它时,从该客户进入你网站的流量将自动开始要求令牌,你的访问者将自动看到更少的验证码。 + +因此,我们希望看到它被更多的设备和操作系统采用。你如何看待 Cloudflare 的私人访问令牌呢?在下面的评论中发表你的看法吧! + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/cloudflare-pat/ + +作者:[Jacob Crume][a] +选题:[lkxed][b] +译者:[lkxed](https://github.com/lkxed) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://news.itsfoss.com/author/jacob/ +[b]: https://github.com/lkxed +[1]: https://news.itsfoss.com/wp-content/uploads/2022/06/cloudflare-private-access-tokens.jpg +[2]: https://blog.cloudflare.com/eliminating-captchas-on-iphones-and-macs-using-new-standard/ +[3]: https://news.itsfoss.com/wp-content/uploads/2022/06/PAT-Data-transfer-chart-1024x650.png +[4]: https://blog.cloudflare.com/eliminating-captchas-on-iphones-and-macs-using-new-standard/ From 2b85954120dab9ce1e957d666f6c66106e3e35c1 Mon Sep 17 00:00:00 2001 From: lkxed Date: Sun, 12 Jun 2022 14:27:21 +0800 Subject: [PATCH 09/78] =?UTF-8?q?[=E6=8F=90=E4=BA=A4=E8=AF=91=E6=96=87][te?= =?UTF-8?q?ch]:=2020220607=20How=20Garbage=20Collection=20works=20inside?= =?UTF-8?q?=20a=20Java=20Virtual=20Machine.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ion works inside a Java Virtual Machine.md | 155 ----------------- ...ion works inside a Java Virtual Machine.md | 157 ++++++++++++++++++ 2 files changed, 157 insertions(+), 155 deletions(-) delete mode 100644 sources/tech/20220607 How Garbage Collection works inside a Java Virtual Machine.md create mode 100644 translated/tech/20220607 How Garbage Collection works inside a Java Virtual Machine.md diff --git a/sources/tech/20220607 How Garbage Collection works inside a Java Virtual Machine.md b/sources/tech/20220607 How Garbage Collection works inside a Java Virtual Machine.md deleted file mode 100644 index c99ed4df0e..0000000000 --- a/sources/tech/20220607 How Garbage Collection works inside a Java Virtual Machine.md +++ /dev/null @@ -1,155 +0,0 @@ -[#]: subject: "How Garbage Collection works inside a Java Virtual Machine" -[#]: via: "https://opensource.com/article/22/6/garbage-collection-java-virtual-machine" -[#]: author: "Jayashree Huttanagoudar https://opensource.com/users/jayashree-huttanagoudar" -[#]: collector: "lkxed" -[#]: translator: "lkxed" -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " - -How Garbage Collection works inside a Java Virtual Machine -====== -Understanding how Java handles memory isn't always necessary, but it can help you envision how the JVM deals with your variables and class instances. - -![Coffee beans][1] - -Image by: Pixabay. CC0. - -Automatic Garbage Collection (GC) is one of the most important features that makes Java so popular. This article explains why GC is essential. It includes automatic and generational GC, how the Java Virtual Machine (JVM) divides heap memory, and finally, how GC works inside the JVM. - -### Java memory allocation - -Java memory is divided into four sections: - -1. Heap: The memory for object instances is allocated in the heap. When the object declaration is made, there won't be any memory allocated in the heap. Instead, a reference is created for that object in the stack. -2. Stack: This section allocates the memory for methods, local variables, and class instance variables. -3. Code: Bytecode resides in this section. -4. Static: Static data and methods are placed in this section. - -### What is automatic Garbage Collection (GC)? - -Automatic GC is a process in which the referenced and unreferenced objects in heap memory are identified, and then unreferenced objects are considered for deletion. The term *referenced objects* means some part of your program is using those objects. *Unreferenced objects* are not currently being used by the program. - -Programming languages like C and C++ require manual allocation and deallocation of memory. This is automatically handled by GC in Java, although you can trigger GC manually with the `system.gc();` call in your code. - -The fundamental steps of GC are: - -#### 1. Mark used and unused objects - -In this step, the used and unused objects are marked separately. This is a time-consuming process, as all objects in memory must be scanned to determine whether they're in use or not. - -![Marking used and unused objects][2] - -#### 2. Sweep/Delete objects - -There are two variations of sweep and delete. - -**Simple deletion**: Only unreferenced objects are removed. However, the memory allocation for new objects becomes difficult as the free space is scattered across available memory. - -![Normal deleting process][3] - -**Deletion with compaction**: Apart from deleting unreferenced objects, referenced objects are compacted. Memory allocation for new objects is relatively easy, and memory allocation performance is improved. - -![Deletion with compacting][4] - -### What is generational Garbage Collection (GC), and why is it needed? - -As seen in the sweep and delete model, scanning all objects for memory reclamation from unused objects becomes difficult once the objects keep growing. An experimental study shows that most objects created during the program execution are short-lived. - -The existence of short-lived objects can be used to improve the performance of GC. For that, the JVM divides the memory into different generations. Next, it categorizes the objects based on these memory generations and performs the GC accordingly. This approach is known as *generational GC*. - -### Heap memory generations and the generational Garbage Collection (GC) process - -To improve the performance of the GC mark and sweep steps, the JVM divides the heap memory into three generations: - -* Young Generation -* Old Generation -* Permanent Generation - -![Hotspot heap structure][5] - -Here is a description of each generation and its key features. - -#### Young Generation - -All created objects are present here. The young generation is further divided into: - -1. Eden: All newly created objects are allocated with the memory here. -2. Survivor space (S0 and S1): After surviving one GC, the live objects are moved to one of these survivor spaces. - -![Object allocation][6] - -The generational GC that happens in the Young Generation is known as *Minor GC*. All Minor GC cycles are "Stop the World" events that cause the other applications to pause until it completes the GC cycle. This is why Minor GC cycles are faster. - -To summarize: Eden space has all newly created objects. Once Eden is full, the first Minor GC cycle is triggered. - -![Filling Eden space][7] - -Minor GC: The live and dead objects are marked during this cycle. The live objects are moved to survivor space S0. Once all live objects are moved to S0, the unreferenced objects are deleted. - -![Copying referenced objects][8] - -The age of objects in S0 is 1 because they have survived one Minor GC. Now Eden and S1 are empty. - -Once cleared, the Eden space is again filled with new live objects. As time elapses, some objects in Eden and S0 become dead (unreferenced), and Eden's space is full again, triggering the Minor GC. - -![Object aging][9] - -This time the dead and live objects in Eden and S0 are marked. The live objects from Eden are moved to S1 with an age increment of 1. The live objects from S0 are also moved to S1 with an age increment of 2 (because they've now survived two Minor GCs). At this point, S0 and Eden are empty. After every Minor GC, Eden and one of the survivor spaces are empty. - -The same cycle of creating new objects in Eden continues. When the next Minor GC occurs, Eden and S1 are cleared by moving the aged objects to S0. The survivor spaces switch after every Minor GC. - -![Additional aging][10] - -This process continues until the age of one of the surviving objects reaches a certain threshold, at which point it is moved to the so-called the Old Generation with a process called *promotion*. - -Further, the `-Xmn` flag sets the Young Generation size. - -### Old Generation (Tenured Generation) - -This generation contains the objects that have survived several Minor GCs and aged to reach an expected threshold. - -![Promotion][11] - -In the example diagram above, the threshold is 8. The GC in the Old Generation is known as a *Major GC*. Use the flags `-Xms` and `-Xmx` to set the initial and maximum size of the heap memory. - -### Permanent Generation - -The Permanent Generation space stores metadata related to library classes and methods of an application, J2SE, and what's in use by the JVM itself. The JVM populates this data at runtime based on which classes and methods are in use. Once the JVM finds the unused classes, they are unloaded or collected, making space for used classes. - -Use the flags `-XX:PermGen` and `-XX:MaxPermGen` to set the initial and maximum size of the Permanent Generation. - -#### Metaspace - -Metaspace was introduced in Java 8u and replaced PermGen. The advantage of this is automatic resizing, which avoids OutOfMemory errors. - -### Wrap up - -This article discusses the various memory generations of JVM and how they are helpful for automatic generational Garbage Collection (GC). Understanding how Java handles memory isn't always necessary, but it can help you envision how the JVM deals with your variables and class instances. This understanding allows you to plan and troubleshoot your code and comprehend potential limitations inherent in a specific platform. - -Image by: (Jayashree Huttanagoudar, CC BY-SA 4.0) - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/22/6/garbage-collection-java-virtual-machine - -作者:[Jayashree Huttanagoudar][a] -选题:[lkxed][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/jayashree-huttanagoudar -[b]: https://github.com/lkxed -[1]: https://opensource.com/sites/default/files/lead-images/java-coffee-beans.jpg -[2]: https://opensource.com/sites/default/files/2022-06/1Marking.png -[3]: https://opensource.com/sites/default/files/2022-06/2NormalDeletion.png -[4]: https://opensource.com/sites/default/files/2022-06/3DeletionwithCompacting.png -[5]: https://opensource.com/sites/default/files/2022-06/4Hotspot.png -[6]: https://opensource.com/sites/default/files/2022-06/5ObjAllocation.png -[7]: https://opensource.com/sites/default/files/2022-06/6FillingEden.png -[8]: https://opensource.com/sites/default/files/2022-06/7CopyingRefdObjs.png -[9]: https://opensource.com/sites/default/files/2022-06/8ObjAging.png -[10]: https://opensource.com/sites/default/files/2022-06/9AddlAging.png -[11]: https://opensource.com/sites/default/files/2022-06/10Promotion.png diff --git a/translated/tech/20220607 How Garbage Collection works inside a Java Virtual Machine.md b/translated/tech/20220607 How Garbage Collection works inside a Java Virtual Machine.md new file mode 100644 index 0000000000..97ab13a20c --- /dev/null +++ b/translated/tech/20220607 How Garbage Collection works inside a Java Virtual Machine.md @@ -0,0 +1,157 @@ +[#]: subject: "How Garbage Collection works inside a Java Virtual Machine" +[#]: via: "https://opensource.com/article/22/6/garbage-collection-java-virtual-machine" +[#]: author: "Jayashree Huttanagoudar https://opensource.com/users/jayashree-huttanagoudar" +[#]: collector: "lkxed" +[#]: translator: "lkxed" +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +JVM 垃圾回收的工作原理 +====== +对于程序员来说,掌握 Java 的内存管理机制并不是必须的,但它能够帮助你更好地理解 JVM 是如何处理程序中的变量和类实例的。 + +![咖啡豆][1] + +图源:Pixabay. CC0. + +Java 之所以能够如此流行,自动 垃圾回收Garbage Collection(GC)功不可没,它也是 Java 最重要的几个特性之一。在这篇文章中,我将说明为什么垃圾回收如此重要。本文的主要内容为:自动的分代垃圾回收、JVM 划分内存的依据,以及 JVM 垃圾回收的工作原理。 + +### Java 内存分配 + +Java 程序的内存空间被划分为以下四个区域: + +1. 堆区(Heap):对象实例就是在这个区域分配的。不过,当我们声明一个对象时,堆中不会有任何内存分配发生,只是在栈中创建了一个对象的引用而已。 +2. 栈区(Stack):方法、局部变量和类的实例变量就是在这个区域分配的。 +3. 代码区(Code):这个区域存放了程序的字节码。 +4. 静态区(Static):这个区域存放了程序的静态数据和静态方法。 + +### 什么是自动垃圾回收? + +自动垃圾回收是这样一个过程:首先,堆中的所有对象会被分类为“被引用的”和“未被引用的”;接着,“未被引用的对象”就会被做上标记,以待之后删除。其中,“被引用的对象”是指程序中的某一部分仍在使用的对象,“未被引用的对象”是指目前没有正在被使用的对象。 + +许多编程语言,例如 C 和 C++,都需要程序员手动管理内存的分配和释放。在 Java 中,这一过程是通过垃圾回收机制来自动完成的(尽管你也可以在代码中调用 `system.gc();` 来手动触发垃圾回收)。 + +垃圾回收的基本步骤如下: + +#### 1. 标记已使用和未使用的对象 + +在这一步骤中,已使用和未使用的对象会被分别做上标记。这是一个及其耗时的过程,因为需要扫描内存中的所有对象,才能够确定它们是否正在被使用。 + +![标记已使用和未使用的对象][2] + +#### 2. 扫描/删除对象 + +有两种不同的扫描和删除算法: + +**简单删除(标记清除)**:它的过程很简单,我们只需要删除未被引用的对象即可。但是,后续给新对象分配内存就会变得很困难了,因为可用空间被分割成了一块块碎片。 + +![标记清除的过程][3] + +**删除压缩(标记整理)**:除了会删除未被引用的对象,我们还会压缩被引用的对象(未被删除的对象)。这样以来,新对象的内存分配就相对容易了,并且内存分配的效率也有了提升。 + +![标记整理的过程][4] + +### 什么是分代垃圾收集,为什么需要它? + +正如我们在“扫描删除”模型中所看到的,一旦对象不断增长,我们就很难扫描所有未使用的对象以回收内存。不过,有一项实验性研究指出,在程序执行期间创建的大多数对象,它们的存活时间都很短。 + +既然大多数对象的存活时间都很短,那么我们就可以利用这个事实,从而提升垃圾回收的效率。该怎么做呢?首先,JVM 将内存划分为不同的“代”。接着,它将所有的对象都分类到这些内存“代”中,然后对这些“代”分别执行垃圾回收。这就是“分代垃圾回收”。 + +### 堆内存的“代”和分代垃圾回收过程 + +为了提升垃圾回收中的“标记清除”的效率,JVM 将对内存划分成以下三个“代”: + +* 年轻代 +* 老年代 +* 永久代 + +![Hotspot 堆内存结构][5] + +下面我将介绍每个“代”及其主要特征。 + +#### 年轻代 + +所有创建不久的对象都存放在这里。年轻代被进一步分为以下两个区域: + +1. 伊甸区(Eden):所有新创建的对象都在此处分配内存。 +2. 幸存者区(Survivor,分为 S0 和 S1):经历过一次垃圾回收后,仍然存活的对象会被移动到两个幸存者区中的一个。 + +![对象分配][6] + +在年轻代发生的分代垃圾收集被称为 “Minor GC”。Minor GC 过程中的每个阶段都是“停止世界Stop The World”(STW)的,这会导致其他应用程序暂停运行,直到垃圾回收结束。这也是 Minor GC 更快的原因。 + +一句话总结:伊甸区存放了所有新创建的对象,当它的可用空间被耗尽,第一次垃圾回收就会被触发。 + +![填充伊甸区][7] + +Minor GC:在该垃圾回收过程中,所有存活和死亡的对象都会被做上标记。其中,存活对象会被移动到 S0 幸存者区。当所有存活对象都被移动到了 S0,未被引用的对象就会被删除。 + +![拷贝被引用的对象][8] + +S0 中的对象年龄为 1,因为它们挺过了一次 Minor GC。此时,伊甸区和 S1 都是空的。 + +每当完成清理后,伊甸区就会再次接受新的存活对象。随着时间的推移,伊甸区和 S0 中的某些对象被宣判死亡(不再被引用),并且伊甸区的可用空间也再次耗尽(填满了),那么 Minor GC 又将再次被触发。 + +![对象年龄增长][9] + +这一次,伊甸区和 S0 中的死亡和存活的对象会被做上标记。其中,伊甸区的存活对象会被移动到 S1,并且年龄增加至 1。S0 中的存活对象也会被移动到 S1,并且年龄增加至 2(因为它们挺过了两次 Minor GC)。此时,伊甸区和 S0 又是空的了。每次 Minor GC 之后,伊甸区和两个幸存者区中的一个都会是空的。 + +新对象总是在伊甸区被创建,周而复始。当下一次垃圾回收发生时,伊甸区和 S1 都会被清理,它们中的存活对象会被移动到 S0 区。每次 Minor GC 之后,这两个幸存者区(S0 和 S1)就会交换一次。 + +![额外年龄增长][10] + +这个过程会一直进行下去,直到某个存活对象的年龄达到了某个阈值,然后它就会被移动到一个叫做“老年代”的地方,这是通过一个叫做“晋升”的过程来完成的。 + +使用 `-Xmn` 选项可以设置年轻代的大小。 + +### 老年代 + +这个区域存放着那些挺过了许多次 Minor GC,并且达到了某个年龄阈值的对象。 + +![晋升][11] + +在上面这个示例图表中,晋升的年龄阈值为 8。在老年代发生的垃圾回收被称为 “Major GC”。 + +使用 `-Xms` 和 `-Xmx` 选项可以分别设置堆内存大小的初始值和最大值。(LCTT 译注:结合上面的 `-Xmn` 选项,就可以间接设置老年代的大小了。) + +### 永久代 + +永久代存放着一些元数据,它们与应用程序、Java 标准环境以及 JVM 自用的库类及其方法相关。JVM 会在运行时,用到了什么类和方法,就会填充相应的数据。当 JVM 发现有未使用的类,就会卸载或是回收它们,从而为正在使用的类腾出空间。 + +使用 `-XX:PermGen` 和 `-XX:MaxPerGen` 选项可以分别设置永久代大小的初始值和最大值。 + +#### 元空间 + +Java 8 引入了元空间,并用它替换了永久代。这么做的好处是自动调整大小,避免了 内存不足OutOfMemory(OOM)错误。 + +### 总结 + +本文讨论了各种不同的 JVM 内存“代”,以及它们是如何在分代垃圾回收算法中起作用的。对于程序员来说,掌握 Java 的内存管理机制并不是必须的,但它能够帮助你更好地理解 JVM 处理程序中的变量和类实例的方式。这种理解使你能够规划和排除代码故障,并理解特定平台固有的潜在限制。 + +正文配图来自:Jayashree Huttanagoudar,CC BY-SA 4.0 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/22/6/garbage-collection-java-virtual-machine + +作者:[Jayashree Huttanagoudar][a] +选题:[lkxed][b] +译者:[lkxed](https://github.com/lkxed) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jayashree-huttanagoudar +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/java-coffee-beans.jpg +[2]: https://opensource.com/sites/default/files/2022-06/1Marking.png +[3]: https://opensource.com/sites/default/files/2022-06/2NormalDeletion.png +[4]: https://opensource.com/sites/default/files/2022-06/3DeletionwithCompacting.png +[5]: https://opensource.com/sites/default/files/2022-06/4Hotspot.png +[6]: https://opensource.com/sites/default/files/2022-06/5ObjAllocation.png +[7]: https://opensource.com/sites/default/files/2022-06/6FillingEden.png +[8]: https://opensource.com/sites/default/files/2022-06/7CopyingRefdObjs.png +[9]: https://opensource.com/sites/default/files/2022-06/8ObjAging.png +[10]: https://opensource.com/sites/default/files/2022-06/9AddlAging.png +[11]: https://opensource.com/sites/default/files/2022-06/10Promotion.png From 965a0978e10460c98ec1c093c737cd52cafa7e88 Mon Sep 17 00:00:00 2001 From: lkxed Date: Sun, 12 Jun 2022 14:32:17 +0800 Subject: [PATCH 10/78] Update 20220607 How Garbage Collection works inside a Java Virtual Machine.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 统一使用“垃圾回收”而不是“垃圾收集” --- ... Garbage Collection works inside a Java Virtual Machine.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/translated/tech/20220607 How Garbage Collection works inside a Java Virtual Machine.md b/translated/tech/20220607 How Garbage Collection works inside a Java Virtual Machine.md index 97ab13a20c..e102895b7c 100644 --- a/translated/tech/20220607 How Garbage Collection works inside a Java Virtual Machine.md +++ b/translated/tech/20220607 How Garbage Collection works inside a Java Virtual Machine.md @@ -52,7 +52,7 @@ Java 程序的内存空间被划分为以下四个区域: ![标记整理的过程][4] -### 什么是分代垃圾收集,为什么需要它? +### 什么是分代垃圾回收,为什么需要它? 正如我们在“扫描删除”模型中所看到的,一旦对象不断增长,我们就很难扫描所有未使用的对象以回收内存。不过,有一项实验性研究指出,在程序执行期间创建的大多数对象,它们的存活时间都很短。 @@ -79,7 +79,7 @@ Java 程序的内存空间被划分为以下四个区域: ![对象分配][6] -在年轻代发生的分代垃圾收集被称为 “Minor GC”。Minor GC 过程中的每个阶段都是“停止世界Stop The World”(STW)的,这会导致其他应用程序暂停运行,直到垃圾回收结束。这也是 Minor GC 更快的原因。 +在年轻代发生的分代垃圾回收被称为 “Minor GC”。Minor GC 过程中的每个阶段都是“停止世界Stop The World”(STW)的,这会导致其他应用程序暂停运行,直到垃圾回收结束。这也是 Minor GC 更快的原因。 一句话总结:伊甸区存放了所有新创建的对象,当它的可用空间被耗尽,第一次垃圾回收就会被触发。 From 34dc20c1125b6131a129961baa19b287a00d3059 Mon Sep 17 00:00:00 2001 From: lkxed Date: Sun, 12 Jun 2022 14:51:31 +0800 Subject: [PATCH 11/78] Update 20210503 Learn the Lisp programming language in 2021.md --- ...n the Lisp programming language in 2021.md | 173 ++++++++---------- 1 file changed, 79 insertions(+), 94 deletions(-) diff --git a/sources/tech/20210503 Learn the Lisp programming language in 2021.md b/sources/tech/20210503 Learn the Lisp programming language in 2021.md index a1de95ead8..b4694df247 100644 --- a/sources/tech/20210503 Learn the Lisp programming language in 2021.md +++ b/sources/tech/20210503 Learn the Lisp programming language in 2021.md @@ -1,83 +1,79 @@ -[#]: subject: (Learn the Lisp programming language in 2021) -[#]: via: (https://opensource.com/article/21/5/learn-lisp) -[#]: author: (Seth Kenlon https://opensource.com/users/seth) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: subject: "Learn the Lisp programming language in 2021" +[#]: via: "https://opensource.com/article/21/5/learn-lisp" +[#]: author: "Seth Kenlon https://opensource.com/users/seth" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " -Learn the Lisp programming language in 2021 +Learn the Lisp programming language in 2022 ====== -A lot of Lisp code lurks inside big codebases, so it's smart to get -familiar with the language. -![Woman sitting in front of her laptop][1] +A lot of Lisp code lurks inside big codebases, so it's smart to get familiar with the language. + +![Women in tech and computing][1] + +Image by: kris krüg Lisp was invented in 1958, which makes it the second-oldest computer programming language. It has spawned several modern derivatives, including Common Lisp, Emacs Lisp (Elisp), Clojure, Racket, Scheme, Fennel, and GNU Guile. -People who love thinking about the design of programming languages often love Lisp because of how its syntax and data share the same structure: Lisp code is essentially a list of lists, and its name is an acronym for _LISt Processing_. People who love thinking about the aesthetics of programming languages often hate Lisp because of its frequent use of parentheses for scoping; in fact, it's a common joke that Lisp stands for _Lots of Irritating Superfluous Parentheses_. +People who love thinking about the design of programming languages often love Lisp because of how its syntax and data share the same structure: Lisp code is essentially a list of lists, and its name is an acronym for *LISt Processing*. People who love thinking about the aesthetics of programming languages often hate Lisp because of its frequent use of parentheses for scoping; in fact, it's a common joke that Lisp stands for *Lots of Irritating Superfluous Parentheses*. Whether you love or hate its design philosophies, Lisp is an interesting glimpse at the past and, thanks to Clojure and Guile, into the future. You might be surprised how much Lisp code there is lurking within big codebases in any given industry, so it's a good idea to have at least a passing familiarity with the language. ### Install Lisp -There are many implementations of Lisp. Popular open source versions include [SBCL][2] and [GNU Common Lisp][3] (GCL). You can install either of these with your distribution's package manager. +There are many implementations of Lisp. Popular open source versions include [SBCL][2], [GNU Lisp][3], and [GNU Common Lisp][4] (GCL). You can install any of these with your distribution's package manager, but for this article I use `clisp`. On Fedora Linux: - ``` -`$ sudo dnf install gcl` +$ sudo dnf install clisp ``` On Debian: - ``` -`$ sudo apt install gcl` +$ sudo apt install clisp ``` -For macOS, you can use [MacPorts][4] or [Homebrew][5]: - +For macOS, you can use [MacPorts][5] or [Homebrew][6]: ``` -`$ sudo port install gcl` +$ sudo port install clisp ``` -For Windows, download a binary from [gnu.org/software/gcl][6]. +For Windows, you can either use [clisp on Cygwin][7] or download a GCL binary from [gnu.org/software/gcl][8]. -For this article, I'm using GCL and its `clisp` command, but most of the principles apply to any Lisp. +Even though I'm using the `clisp` command, most of the principles in this article apply to any Lisp. Should you choose to use a different Lisp implementation, the command to run Lisp code is different from what I use in this article (`gcl` or `sbcl` instead of `clisp`, for example) but everything else is the same. ### List processing -The basic unit of Lisp source code is an _expression_, which is written as a list. For instance, this is a list of an operator (`+`) and two integers (`1` and `2`): - +The basic unit of Lisp source code is an *expression*, which is written as a list. For instance, this is a list of an operator (`+` ) and two integers (`1` and `2` ): ``` -`(+ 1 2)` +(+ 1 2) ``` -It's also a Lisp expression, using a symbol (`+`) that evaluates to a function (addition) and two arguments (`1` and `2`). You can run this expression and others in an interactive Common Lisp environment called REPL (read-eval-print loop). If you're familiar with Python's IDLE, Lisp's REPL should feel somewhat familiar to you. +It's also a Lisp expression, using a symbol (`+` ) that evaluates to a function (addition) and two arguments (`1` and `2` ). You can run this expression and others in an interactive Common Lisp environment called REPL (read-eval-print loop). If you're familiar with Python's IDLE, Lisp's REPL should feel somewhat familiar to you. To launch a REPL, launch Common Lisp: - ``` $ clisp -[1]> +[1]> ``` At the REPL prompt, type a few expressions: - ``` -[1]> (+ 1 2) +[1]> (+ 1 2) 3 -[2]> (- 1 2) +[2]> (- 1 2) -1 -[3]> (- 2 1) +[3]> (- 2 1) 1 -[4]> (+ 2 3 4) +[4]> (+ 2 3 4) 9 ``` @@ -85,109 +81,100 @@ At the REPL prompt, type a few expressions: Now that you know the basic structure of a Lisp expression, you can utilize Lisp functions in useful ways. The `print` function takes any argument you provide and displays it on your terminal, while the `pprint` function "pretty" prints it. There are other variations on the print function, but `pprint` is nice in REPL: - ``` -[1]> (pprint "hello world") +[1]> (pprint "hello world") "hello world" -[2]> +[2]> ``` You can create your own functions with `defun`. The `defun` function requires a name for your function and any parameters you want your function to accept: - ``` -[1]> (defun myprinter (s) (pprint s)) +[1]> (defun myprinter (s) (pprint s)) MYPRINTER -[2]> (myprinter "hello world") +[2]> (myprinter "hello world") "hello world" -[3]> +[3]> ``` ### Variables -You can create variables in Lisp with `setf`: - +You can create variables in Lisp with `setf` : ``` -[1]> (setf foo "hello world") +[1]> (setf foo "hello world") "hello world" -[2]> (pprint foo) +[2]> (pprint foo) "hello world" -[3]> +[3]> ``` You can nest expressions within expressions in a kind of pipeline. For instance, you can pretty print the contents of your variable after invoking the `string-upcase` function to convert its characters to uppercase: - ``` -[3]> (pprint (string-upcase foo)) +[3]> (pprint (string-upcase foo)) "HELLO WORLD" -[4]> +[4]> ``` Lisp is dynamically typed in the sense that you don't have to declare variable types when setting them. Lisp treats integers as integers by default: - ``` -[1]> (setf foo 2) -[2]> (setf bar 3) -[3]> (+ foo bar) +[1]> (setf foo 2) +[2]> (setf bar 3) +[3]> (+ foo bar) 5 ``` If you intend for an integer to be interpreted as a string, you can quote it: - ``` -[4]> (setf foo "2")                                                                                                                       -"2"                                                                                                                                       -[5]> (setf bar "3")                                                                                                                       +[4]> (setf foo "2") +"2" +[5]> (setf bar "3") "3" -[6]> (+ foo bar) +[6]> (+ foo bar) *** - +: "2" is not a number The following restarts are available: USE-VALUE      :R1      Input a value to be used instead. ABORT          :R2      Abort main loop -Break 1 [7]> +Break 1 [7]> ``` In this sample REPL session, both `foo` and `bar` are set to quoted numbers, so Lisp interprets them as strings. Math operators can't be used on strings, so REPL drops into a debugger mode. To get out of the debugger, press **Ctrl+D** on your keyboard. -You can do some introspection on objects using the `typep` function, which tests for a specific data type. The tokens `T` and `NIL` represent _True_ and _False_, respectively. - +You can do some introspection on objects using the `typep` function, which tests for a specific data type. The tokens `T` and `NIL` represent *True* and *False*, respectively. ``` -[4]> (typep foo 'string) +[4]> (typep foo 'string) NIL -[5]> (typep foo 'integer) +[5]> (typep foo 'integer) T ``` -The single quote (`'`) before `string` and `integer` prevents Lisp from (incorrectly) evaluating those keywords as variables: - +The single quote (`'` ) before `string` and `integer` prevents Lisp from (incorrectly) evaluating those keywords as variables: ``` -[6]> (typep foo string) +[6]> (typep foo string) *** - SYSTEM::READ-EVAL-PRINT: variable STRING has no value [...] ``` It's a shorthand way to protect the terms, normally done with the `quote` function: - ``` -[7]> (typep foo (quote string)) +[7]> (typep foo (quote string)) NIL -[5]> (typep foo (quote integer)) +[5]> (typep foo (quote integer)) T ``` @@ -195,19 +182,17 @@ T Unsurprisingly, you can also create lists in Lisp: - ``` -[1]> (setf foo (list "hello" "world")) +[1]> (setf foo (list "hello" "world")) ("hello" "world") ``` Lists can be indexed with the `nth` function: - ``` -[2]> (nth 0 foo) +[2]> (nth 0 foo) "hello" -[3]> (pprint (string-capitalize (nth 1 foo))) +[3]> (pprint (string-capitalize (nth 1 foo))) "World" ``` @@ -216,19 +201,17 @@ Lists can be indexed with the `nth` function: To end a REPL session, press **Ctrl+D** on your keyboard, or use the `quit` keyword in Lisp: - ``` -[99]> (quit) +[99]> (quit) $ ``` ### Scripting -Lisp can be compiled or used as an interpreted scripting language. The latter is probably the easiest option when you're starting, especially if you're already familiar with Python or [shell scripting][7]. +Lisp can be compiled or used as an interpreted scripting language. The latter is probably the easiest option when you're starting, especially if you're already familiar with Python or [shell scripting][9]. Here's a simple dice roller script written in GNU Common Lisp: - ``` #!/usr/bin/clisp @@ -241,26 +224,24 @@ Here's a simple dice roller script written in GNU Common Lisp: (roller userput) ``` -The first line tells your [POSIX][8] terminal what executable to use to run the script. +The first line tells your [POSIX][10] terminal what executable to use to run the script. The `roller` function, created with `defun`, uses the `random` function to print a pseudo-random number up to, and not including, the zeroth item of the `num` list. The `num` list hasn't been created yet in the script, but the function doesn't get executed until it's called. The next line assigns any argument provided to the script at launch time to a variable called `userput`. The `userput` variable is a list, and it's what becomes `num` once it's passed to the `roller` function. -The penultimate line of the script starts a _random seed_. This provides Lisp with enough entropy to generate a mostly random number. +The penultimate line of the script starts a *random seed*. This provides Lisp with enough entropy to generate a mostly random number. The final line invokes the custom `roller` function, providing the `userput` list as its sole argument. Save the file as `dice.lisp` and mark it executable: - ``` -`$ chmod +x dice.lisp` +$ chmod +x dice.lisp ``` Finally, try running it, providing it with a maximum number from which to choose its random number: - ``` $ ./dice.lisp 21 @@ -275,9 +256,11 @@ $ ./dice.lisp 21 Not bad! +You may notice that your emulated die has a pontential value of 0, and never reaches the maximum number you provide to it as an argument. In other words, this script never rolls 20 on a 20-sided die (unless you count 0 as 20). There's a simple fix to this, and you only need the knowledge gained from this article to do it. Can you fix this bug? + ### Learn Lisp -Whether you can imagine using Lisp as a utilitarian language for personal scripts, to advance your career, or just as a fun experiment, you can see some particularly inventive uses at the annual [Lisp Game Jam][9] (most submissions are open source, so you can view the code to learn from what you play). +Whether you can imagine using Lisp as a utilitarian language for personal scripts, to advance your career, or just as a fun experiment, you can see some particularly inventive uses at the annual [Lisp Game Jam][11] (most submissions are open source, so you can view the code to learn from what you play). Lisp is a fun and unique language with an ever-growing developer base and enough historic and emerging dialects to keep programmers from all disciplines happy. @@ -286,20 +269,22 @@ Lisp is a fun and unique language with an ever-growing developer base and enough via: https://opensource.com/article/21/5/learn-lisp 作者:[Seth Kenlon][a] -选题:[lujun9972][b] +选题:[lkxed][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_4.png?itok=VGZO8CxT (Woman sitting in front of her laptop) +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/OSDC_women_computing_4.png [2]: http://sbcl.org -[3]: https://www.gnu.org/software/gcl/ -[4]: https://opensource.com/article/20/11/macports -[5]: https://opensource.com/article/20/6/homebrew-linux -[6]: http://mirror.lagoon.nc/gnu/gcl/binaries/stable -[7]: https://opensource.com/article/20/4/bash-programming-guide -[8]: https://opensource.com/article/19/7/what-posix-richard-stallman-explains -[9]: https://itch.io/jam/spring-lisp-game-jam-2021 +[3]: http://clisp.org +[4]: https://www.gnu.org/software/gcl/ +[5]: https://opensource.com/article/20/11/macports +[6]: https://opensource.com/article/20/6/homebrew-linux +[7]: https://cygwin.fandom.com/wiki/Clisp +[8]: http://mirror.lagoon.nc/gnu/gcl/binaries/stable +[9]: https://opensource.com/article/20/4/bash-programming-guide +[10]: https://opensource.com/article/19/7/what-posix-richard-stallman-explains +[11]: https://itch.io/jam/spring-lisp-game-jam-2021 From 1daa2dd5a938888edc81ae17628180b27cf1fb0b Mon Sep 17 00:00:00 2001 From: lkxed Date: Sun, 12 Jun 2022 15:02:54 +0800 Subject: [PATCH 12/78] Update 20210503 Learn the Lisp programming language in 2021.md --- .../20210503 Learn the Lisp programming language in 2021.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/tech/20210503 Learn the Lisp programming language in 2021.md b/sources/tech/20210503 Learn the Lisp programming language in 2021.md index b4694df247..6f73c62d9c 100644 --- a/sources/tech/20210503 Learn the Lisp programming language in 2021.md +++ b/sources/tech/20210503 Learn the Lisp programming language in 2021.md @@ -7,7 +7,7 @@ [#]: publisher: " " [#]: url: " " -Learn the Lisp programming language in 2022 +Let's learn the Lisp programming language ====== A lot of Lisp code lurks inside big codebases, so it's smart to get familiar with the language. From c30ef8918f3b517b17cd406b14243725062d7015 Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Sun, 12 Jun 2022 15:59:55 +0800 Subject: [PATCH 13/78] RP @geekpi https://linux.cn/article-14700-1.html --- ... That Just Plays Music and Nothing Else.md | 43 ++++++++++--------- 1 file changed, 23 insertions(+), 20 deletions(-) rename {translated/tech => published}/20220606 Amberol is a Stunning Looking Music Player for Linux That Just Plays Music and Nothing Else.md (68%) diff --git a/translated/tech/20220606 Amberol is a Stunning Looking Music Player for Linux That Just Plays Music and Nothing Else.md b/published/20220606 Amberol is a Stunning Looking Music Player for Linux That Just Plays Music and Nothing Else.md similarity index 68% rename from translated/tech/20220606 Amberol is a Stunning Looking Music Player for Linux That Just Plays Music and Nothing Else.md rename to published/20220606 Amberol is a Stunning Looking Music Player for Linux That Just Plays Music and Nothing Else.md index 772796fee7..0ccbb7c9bc 100644 --- a/translated/tech/20220606 Amberol is a Stunning Looking Music Player for Linux That Just Plays Music and Nothing Else.md +++ b/published/20220606 Amberol is a Stunning Looking Music Player for Linux That Just Plays Music and Nothing Else.md @@ -3,15 +3,18 @@ [#]: author: "Abhishek Prakash https://itsfoss.com/author/abhishek/" [#]: collector: "lkxed" [#]: translator: "geekpi" -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14700-1.html" Amberol 是一款外观漂亮的 Linux 音乐播放器,只播放音乐,不做其他事情 ====== + +![](https://img.linux.net.cn/data/attachment/album/202206/12/155846b0sbsvtt1et70ttf.jpg) + 虽然音乐世界被流媒体服务所主导,但这并没有阻止开发者为桌面电脑创建音乐播放器。 -最近,我发现了一个外观漂亮的新的 Linux 桌面音乐播放器。它名为 Amberol,我被它的美丽所震撼了。 +最近,我发现了一个外观漂亮的新的 Linux 桌面音乐播放器。它名为 Amberol,我被它的美丽所震撼。 ![amberol music player interface][1] @@ -21,41 +24,41 @@ Amberol 是一款外观漂亮的 Linux 音乐播放器,只播放音乐,不 看起来不错是它所做的两件(或几件)事情中的一件。另一件事是播放音乐。 -这就是它。[Amberol][2] 没有额外的花哨(和有用)的功能,如生成专辑封面、元数据编辑、歌词显示或播放列表和库管理。 +这就是它,[Amberol][2] 没有额外的花哨(和有用)的功能,如生成专辑封面、元数据编辑、歌词显示或播放列表和库管理。 -这些功能也不像会在未来的版本中加入。Amberol 只想播放音乐。就是这样。 +这些功能也不像是会在未来的版本中加入。Amberol 只想播放音乐。就是这样。 #### 令人惊叹的用户界面 Amberol 和大多数新的 GNOME 应用一样,是用 Rust 和 GTK 编写的。 -它有一个自适应的用户界面,可以根据你正在播放的专辑颜色来改变颜色。渐变效果给了它一个现代、时尚的外观,肯定会成为你的 Linux rice 截图的一部分。 +它有一个自适应的用户界面,可以根据你正在播放的专辑颜色来改变颜色。渐变效果给了它一个现代、时尚的外观,肯定会成为你的 Linux 美化Ricing截图的一部分。 ![amberol music player][3] -由于 UI 没有传统的手柄和菜单,它给应用一个统一的外观。 +由于其 UI 没有传统的手柄和菜单,它给应用一个统一的外观。 #### 播放列表 -它从你添加的文件夹中存在的文件自动生成一个播放列表。它显示在左手边的侧边栏。 +它会从你添加的文件夹中的文件自动生成一个播放列表,显示在左手边的侧边栏。 ![amberol playlist][4] -你可以在左上角看到整个播放列表将播放多长时间的音乐。点击“勾选符号”,你可以选择歌曲,并从播放列表中删除它们。 +你可以在左上角看到整个播放列表将播放多长时间的音乐。点击“勾选”符号,你可以选择歌曲,并从播放列表中删除它们。 -如果你愿意,你可以隐藏播放列表的侧边栏。 +如果你愿意,可以隐藏播放列表的侧边栏。 ![amberol without playlist][5] #### 音乐播放选项 -你可以在界面上看到歌曲的进度。该播放器与键盘上的媒体控制按钮整合得很好。你可以用专用的媒体键播放/暂停和改变曲目(如果你的系统上有)。 +你可以在界面上看到歌曲的进度。该播放器与键盘上的媒体控制按钮整合得很好。你可以用专用的媒体键来播放、暂停和改变曲目(如果你的系统上有)。 -Amberol 为你提供了一些播放音乐的选项。你可以打开随机播放功能,按随机顺序播放音乐。你也可以把一首歌放在重复的位置,一直播放,直到你厌倦它。 +Amberol 为你提供了一些播放音乐的选项。你可以打开随机播放功能,按随机顺序播放音乐。你也可以单曲循环,直到你厌倦它。 ![amberol music playing options][6] -底部的手柄菜单让你可以选择添加文件或文件夹,并显示可用的键盘快捷方式。 +底部的汉堡菜单让你可以选择添加文件或文件夹,并显示可用的键盘快捷方式。 ![amberol keyboard shortcuts][7] @@ -63,7 +66,7 @@ Amberol 为你提供了一些播放音乐的选项。你可以打开随机播放 ### 在 Linux 上安装 Amberol -Amberol 是[以 Flatpak 形式提供][8]。请确保[你的系统已启用 Flatpak 支持][9]。 +Amberol 是 [以 Flatpak 形式提供的][8]。请确保 [你的系统已启用 Flatpak 支持][9]。 要安装 Amberol,请打开终端并使用以下命令: @@ -73,17 +76,17 @@ flatpak install flathub io.bassi.Amberol 安装完毕后,在菜单中搜索该应用,并点击启动。 -第一次运行时,它会要求你添加音乐文件或文件夹。你也可以拖放文件。 +第一次运行时,它会要求你添加音乐文件或文件夹。你也可以拖放文件播放。 ![amberol first run][10] ### 总结 -就个人而言,我更喜欢流媒体服务,因为我没有一个很好的本地音乐收藏。但我知道有的人有/有大量的 CD 收藏,现在都保存在硬盘上。 +就个人而言,我更喜欢流媒体服务,因为我没有本机音乐珍藏。但我知道有的人有大量的 CD 收藏,现在都保存在硬盘上。 -Amberol 是一个外观漂亮的应用,对于播放本地音乐来说,它足够好。最吸引人的是基于专辑封面的自适应用户界面。 +Amberol 是一个外观漂亮的应用,对于播放本机音乐来说,它足够好。最吸引人的是它基于专辑封面的自适应用户界面。 -我请你试试它,并在评论区分享你的经验。 +请你试试它,并在评论区分享你的经验。 -------------------------------------------------------------------------------- @@ -92,7 +95,7 @@ via: https://itsfoss.com/amberol-music-player/ 作者:[Abhishek Prakash][a] 选题:[lkxed][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/) 荣誉推出 From a328549a9f11323152f89bd0bebbf18844432645 Mon Sep 17 00:00:00 2001 From: Donkey-Hao Date: Sun, 12 Jun 2022 20:31:54 +0800 Subject: [PATCH 14/78] translated --- ...e a countdown clock with a Raspberry Pi.md | 393 ------------------ ...e a countdown clock with a Raspberry Pi.md | 384 +++++++++++++++++ 2 files changed, 384 insertions(+), 393 deletions(-) delete mode 100644 sources/tech/20210319 Create a countdown clock with a Raspberry Pi.md create mode 100644 translated/tech/20210319 Create a countdown clock with a Raspberry Pi.md diff --git a/sources/tech/20210319 Create a countdown clock with a Raspberry Pi.md b/sources/tech/20210319 Create a countdown clock with a Raspberry Pi.md deleted file mode 100644 index 6b042c6d86..0000000000 --- a/sources/tech/20210319 Create a countdown clock with a Raspberry Pi.md +++ /dev/null @@ -1,393 +0,0 @@ -[#]: subject: (Create a countdown clock with a Raspberry Pi) -[#]: via: (https://opensource.com/article/21/3/raspberry-pi-countdown-clock) -[#]: author: (Chris Collins https://opensource.com/users/clcollins) -[#]: collector: (lujun9972) -[#]: translator: ( Donkey-Hao ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) - -Create a countdown clock with a Raspberry Pi -====== -Start counting down the days to your next holiday with a Raspberry Pi -and an ePaper display. -![Alarm clocks with different time][1] - -For 2021, [Pi Day][2] has come and gone, leaving fond memories and [plenty of Raspberry Pi projects][3] to try out. The days after any holiday can be hard when returning to work after high spirits and plenty of fun, and Pi Day is no exception. As we look into the face of the Ides of March, we can long for the joys of the previous, well, day. But fear no more, dear Pi Day celebrant! For today, we begin the long countdown to the next Pi Day! - -OK, but seriously. I made a Pi Day countdown timer, and you can too! - -A while back, I purchased a [Raspberry Pi Zero W][4] and recently used it to [figure out why my WiFi was so bad][5]. I was also intrigued by the idea of getting an ePaper display for the little Zero W. I didn't have a good use for one, but, dang it, it looked like fun! I purchased a little 2.13" [Waveshare display][6], which fit perfectly on top of the Raspberry Pi Zero W. It's easy to install: Just slip the display down onto the Raspberry Pi's GIPO headers and you're good to go. - -I used [Raspberry Pi OS][7] for this project, and while it surely can be done with other operating systems, the `raspi-config` command, used below, is most easily available on Raspberry Pi OS. - -### Set up the Raspberry Pi and the ePaper display - -Setting up the Raspberry Pi to work with the ePaper display requires you to enable the Serial Peripheral Interface (SPI) in the Raspberry Pi software, install the BCM2835 C libraries (to access the GPIO functions for the Broadcom BCM 2835 chip on the Raspberry Pi), and install Python GPIO libraries to control the ePaper display. Finally, you need to install the Waveshare libraries for working with the 2.13" display using Python. - -Here's a step-by-step walkthrough of how to do these tasks. - -#### Enable SPI - -The easiest way to enable SPI is with the Raspberry Pi `raspi-config` command. The SPI bus allows serial data communication to be used with devices—in this case, the ePaper display: - - -``` -`$ sudo raspi-config` -``` - -From the menu that pops up, select **Interfacing Options** -> **SPI** -> **Yes** to enable the SPI interface, then reboot. - -#### Install BCM2835 libraries - -As mentioned above, the BCM2835 libraries are software for the Broadcom BCM2385 chip on the Raspberry Pi, which allows access to the GPIO pins and the ability to use them to control devices. - -As I'm writing this, the latest version of the Broadcom BCM 2835 libraries for the Raspberry Pi is v1.68. To install the libraries, you need to download the software tarball and build and install the software with `make`: - - -``` -# Download the BCM2853 libraries and extract them -$ curl -sSL -o - | tar -xzf - - -# Change directories into the extracted code -$ pushd bcm2835-1.68/ - -# Configure, build, check and install the BCM2853 libraries -$ sudo ./configure -$ sudo make check -$ sudo make install - -# Return to the original directory -$ popd -``` - -#### Install required Python libraries - -You also need some Python libraries to use Python to control the ePaper display, the `RPi.GPIO` pip package. You also need the `python3-pil` package for drawing shapes. Apparently, the PIL package is all but dead, but there is an alternative, [Pillow][8]. I have not tested Pillow for this project, but it may work: - - -``` -# Install the required Python libraries -$ sudo apt-get update -$ sudo apt-get install python3-pip python3-pil -$ sudo pip3 install RPi.GPIO -``` - -_Note: These instructions are for Python 3. You can find Python 2 instructions on Waveshare's website_ - -#### Download Waveshare examples and Python libraries - -Waveshare maintains a Git repository with Python and C libraries for working with its ePaper displays and some examples that show how to use them. For this countdown clock project, you will clone this repository and use the libraries for the 2.13" display: - - -``` -# Clone the WaveShare e-Paper git repository -$ git clone -``` - -If you're using a different display or a product from another company, you'll need to use the appropriate software for your display. - -Waveshare provides instructions for most of the above on its website: - - * [WaveShare ePaper setup instructions][9] - * [WaveShare ePaper libraries install instructions][10] - - - -#### Get a fun font (optional) - -You can display your timer however you want, but why not do it with a little style? Find a cool font to work with! - -There's a ton of [Open Font License][11] fonts available out there. I am particularly fond of Bangers. You've seen this if you've ever watched YouTube—it's used _all over_. It can be downloaded and dropped into your user's local shared fonts directory to make it available for any application, including this project: - - -``` -# The "Bangers" font is a Open Fonts License licensed font by Vernon Adams () from Google Fonts -$ mkdir -p ~/.local/share/fonts -$ curl -sSL -o fonts/Bangers-Regular.ttf -``` - -### Create a Pi Day countdown timer - -Now that you have installed the software to work with the ePaper display and a fun font to use, you can build something cool with it: a timer to count down to the next Pi Day! - -If you want, you can just grab the [countdown.py][12] Python file from this project's [GitHub repo][13] and skip to the end of this article. - -For the curious, I'll break down that file, section by section. - -#### Import some libraries - - -``` -#!/usr/bin/python3 -# -*- coding:utf-8 -*- -import logging -import os -import sys -import time - -from datetime import datetime -from pathlib import Path -from PIL import Image,ImageDraw,ImageFont - -logging.basicConfig(level=logging.INFO) - -basedir = Path(__file__).parent -waveshare_base = basedir.joinpath('e-Paper', 'RaspberryPi_JetsonNano', 'python') -libdir = waveshare_base.joinpath('lib') -``` - -At the start, the Python script imports some standard libraries used later in the script. You also need to add `Image`, `ImageDraw`, and `ImageFont` from the PIL package, which you'll use to draw some simple geometric shapes. Finally, set some variables for the local `lib` directory that contains the Waveshare Python libraries for working with the 2.13" display, and which you can use later to load the library from the local directory. - -#### Font size helper function - -The next part of the script has a helper function for setting the font size for your chosen font: Bangers-Regular.ttf. It takes an integer for the font size and returns an ImageFont object you can use with the display: - - -``` -def set_font_size(font_size): -    logging.info("Loading font...") -    return ImageFont.truetype(f"{basedir.joinpath('Bangers-Regular.ttf').resolve()}", font_size) -``` - -#### Countdown logic - -Next is a small function that calculates the meat of this project: how long it is until the next Pi Day. If it were, say, January, it would be relatively straightforward to count how many days are left, but you also need to consider whether Pi Day has already passed for the year (sadface), and if so, count how very, very many days are ahead until you can celebrate again: - - -``` -def countdown(now): -    piday = datetime(now.year, 3, 14) - -    # Add a year if we're past PiDay -    if piday < now: -        piday = datetime((now.year + 1), 3, 14) - -    days = (piday - now).days - -    logging.info(f"Days till piday: {days}") -    return day -``` - -#### The main function - -Finally, you get to the main function, which initializes the display and begins writing data to it. In this case, you'll write a welcome message and then begin the countdown to the next Pi Day. But first, you need to load the Waveshare library: - - -``` -def main(): - -    if os.path.exists(libdir): -        sys.path.append(f"{libdir}") -        from waveshare_epd import epd2in13_V2 -    else: -        logging.fatal(f"not found: {libdir}") -        sys.exit(1) -``` - -The snippet above checks to make sure the library has been downloaded to a directory alongside the countdown script, and then it loads the `epd2in13_V2` library. If you're using a different display, you will need to use a different library. You can also write your own if you are so inclined. I found it kind of interesting to read the Python code that Waveshare provides with the display. It's considerably less complicated than I would have imagined it to be, if somewhat tedious. - -The next bit of code creates an EPD (ePaper Display) object to interact with the display and initializes the hardware: - - -``` -    logging.info("Starting...") -    try: -        # Create an a display object -        epd = epd2in13_V2.EPD() - -        # Initialize the displace, and make sure it's clear -        # ePaper keeps it's state unless updated! -        logging.info("Initialize and clear...") -        epd.init(epd.FULL_UPDATE) -        epd.Clear(0xFF) -``` - -An interesting aside about ePaper: It uses power only when it changes a pixel from white to black or vice-versa. This means when the power is removed from the device or the application stops for whatever reason, whatever was on the screen remains. That's great from a power-consumption perspective, but it also means you need to clear the display when starting up, or your script will just write over whatever is already on the screen. Hence, `epd.Clear(0xFF)` is used to clear the display when the script starts. - -Next, create a "canvas" where you will draw the rest of your display output: - - -``` -    # Create an image object -    # NOTE: The "epd.heigh" is the LONG side of the screen -    # NOTE: The "epd.width" is the SHORT side of the screen -    # Counter-intuitive... -    logging.info(f"Creating canvas - height: {epd.height}, width: {epd.width}") -    image = Image.new('1', (epd.height, epd.width), 255)  # 255: clear the frame -    draw = ImageDraw.Draw(image) -``` - -This matches the width and height of the display—but it is somewhat counterintuitive, in that the short side of the display is the width. I think of the long side as the width, so this is just something to note. Note that the `epd.height` and `epd.width` are set by the Waveshare library to correspond to the device you're using. - -#### Welcome message - -Next, you'll start to draw something. This involves setting data on the "canvas" object you created above. This doesn't draw it to the ePaper display yet—you're just building the image you want right now. Create a little welcome message celebrating Pi Day, with an image of a piece of pie, drawn by yours truly just for this project: - -![drawing of a piece of pie][14] - -(Chris Collins, [CC BY-SA 4.0][15]) - -Cute, huh? - - -``` -    logging.info("Set text text...") -    bangers64 = set_font_size(64) -    draw.text((0, 30), 'PI DAY!', font = bangers64, fill = 0) - -    logging.info("Set BMP...") -    bmp = Image.open(basedir.joinpath("img", "pie.bmp")) -    image.paste(bmp, (150,2)) -``` - -Finally, _finally_, you get to display the canvas you drew, and it's a little bit anti-climactic: - - -``` -    logging.info("Display text and BMP") -    epd.display(epd.getbuffer(image)) -``` - -That bit above updates the display to show the image you drew. - -Next, prepare another image to display your countdown timer. - -#### Pi Day countdown timer - -First, create a new image object that you can use to draw the display. Also, set some new font sizes to use for the image: - - -``` -    logging.info("Pi Date countdown; press CTRL-C to exit") -    piday_image = Image.new('1', (epd.height, epd.width), 255) -    piday_draw = ImageDraw.Draw(piday_image) - -    # Set some more fonts -    bangers36 = set_font_size(36) -    bangers64 = set_font_size(64) -``` - -To display a ticker like a countdown, it's more efficient to update part of the image, changing the display for only what has changed in the data you want to draw. The next bit of code prepares the display to function this way: - - -``` -    # Prep for updating display -    epd.displayPartBaseImage(epd.getbuffer(piday_image)) -    epd.init(epd.PART_UPDATE) -``` - -Finally, you get to the timer bit, starting an infinite loop that checks how long it is until the next Pi Day and displays the countdown on the ePaper display. If it actually _is_ Pi Day, you can handle that with a little celebration message: - - -``` -    while (True): -        days = countdown(datetime.now()) -        unit = get_days_unit(days) - -        # Clear the bottom half of the screen by drawing a rectangle filld with white -        piday_draw.rectangle((0, 50, 250, 122), fill = 255) - -        # Draw the Header -        piday_draw.text((10,10), "Days till Pi-day:", font = bangers36, fill = 0) - -        if days == 0: -            # Draw the Pi Day celebration text! -            piday_draw.text((0, 50), f"It's Pi Day!", font = bangers64, fill = 0) -        else: -            # Draw how many days until Pi Day -            piday_draw.text((70, 50), f"{str(days)} {unit}", font = bangers64, fill = 0) - -        # Render the screen -        epd.displayPartial(epd.getbuffer(piday_image)) -        time.sleep(5) -``` - -The last bit of the script does some error handling, including some code to catch keyboard interrupts so that you can stop the infinite loop with **Ctrl**+**C** and a small function to print "day" or "days" depending on whether or not the output should be singular (for that one, single day each year when it's appropriate): - - -``` -    except IOError as e: -        logging.info(e) - -    except KeyboardInterrupt: -        logging.info("Exiting...") -        epd.init(epd.FULL_UPDATE) -        epd.Clear(0xFF) -        time.sleep(1) -        epd2in13_V2.epdconfig.module_exit() -        exit() - -def get_days_unit(count): -    if count == 1: -        return "day" - -    return "days" - -if __name__ == "__main__": -    main() -``` - -And there you have it! A script to count down and display how many days are left until Pi Day! Here's an action shot on my Raspberry Pi (sped up by 86,400; I don't have nearly enough disk space to save a day-long video): - -![Pi Day Countdown Timer In Action][16] - -(Chris Collins, [CC BY-SA 4.0][15]) - -#### Install the systemd service (optional) - -If you'd like the countdown display to run whenever the system is turned on and without you having to be logged in and run the script, you can install the optional systemd unit as a [systemd user service][17]). - -Copy the [piday.service][18] file on GitHub to `${HOME}/.config/systemd/user`, first creating the directory if it doesn't exist. Then you can enable the service and start it: - - -``` -$ mkdir -p ~/.config/systemd/user -$ cp piday.service ~/.config/systemd/user -$ systemctl --user enable piday.service -$ systemctl --user start piday.service - -# Enable lingering, to create a user session at boot -# and allow services to run after logout -$ loginctl enable-linger $USER -``` - -The script will output to the systemd journal, and the output can be viewed with the `journalctl` command. - -### It's beginning to look a lot like Pi Day! - -And _there_ you have it! A Pi Day countdown timer, displayed on an ePaper display using a Raspberry Pi Zero W, and starting on system boot with a systemd unit file! Now there are just 350-something days until we can once again come together and celebrate the fantastic device that is the Raspberry Pi. And we can see exactly how many days at a glance with our tiny project. - -But in truth, anyone can hold Pi Day in their hearts year-round, so enjoy creating some fun and educational projects with your own Raspberry Pi! - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/21/3/raspberry-pi-countdown-clock - -作者:[Chris Collins][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/clcollins -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/clocks_time.png?itok=_ID09GDk (Alarm clocks with different time) -[2]: https://en.wikipedia.org/wiki/Pi_Day -[3]: https://opensource.com/tags/raspberry-pi -[4]: https://www.raspberrypi.org/products/raspberry-pi-zero-w/ -[5]: https://opensource.com/article/21/3/troubleshoot-wifi-go-raspberry-pi -[6]: https://www.waveshare.com/product/displays/e-paper.htm -[7]: https://www.raspberrypi.org/software/operating-systems/ -[8]: https://pypi.org/project/Pillow/ -[9]: https://www.waveshare.com/wiki/2.13inch_e-Paper_HAT -[10]: https://www.waveshare.com/wiki/Libraries_Installation_for_RPi -[11]: https://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL -[12]: https://github.com/clcollins/epaper-pi-ex/blob/main/countdown.py -[13]: https://github.com/clcollins/epaper-pi-ex/ -[14]: https://opensource.com/sites/default/files/uploads/pie.png (drawing of a piece of pie) -[15]: https://creativecommons.org/licenses/by-sa/4.0/ -[16]: https://opensource.com/sites/default/files/uploads/piday_countdown.gif (Pi Day Countdown Timer In Action) -[17]: https://wiki.archlinux.org/index.php/systemd/User -[18]: https://github.com/clcollins/epaper-pi-ex/blob/main/piday.service diff --git a/translated/tech/20210319 Create a countdown clock with a Raspberry Pi.md b/translated/tech/20210319 Create a countdown clock with a Raspberry Pi.md new file mode 100644 index 0000000000..a888429ccd --- /dev/null +++ b/translated/tech/20210319 Create a countdown clock with a Raspberry Pi.md @@ -0,0 +1,384 @@ +[#]: subject: (Create a countdown clock with a Raspberry Pi) +[#]: via: (https://opensource.com/article/21/3/raspberry-pi-countdown-clock) +[#]: author: (Chris Collins https://opensource.com/users/clcollins) +[#]: collector: (lujun9972) +[#]: translator: (Donkey-Hao) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +使用树莓派做一个倒计时闹钟 +====== +使用树莓派和 ePaper 显示器开始倒计时您的下一个假期。 +![Alarm clocks with different time][1] + +2021年[ Pi Day ][2]来了又走,留下美好的回忆以及[许多树莓派项目][3]等待我们去尝试。在任何令人精神振奋、充满欢乐的假期后回到工作中都很难, Pi Day 也不例外。当我们回望三月的时候,渴望那些天的快乐。但是不用害怕,亲爱的 Pi Day 庆祝者们,我们开始下一个 Pi Day 的漫长倒计时! + +好了,严肃点。我做了一个 Pi Day 倒计时器,你也可以! + +不久前,我购买了一个 [树莓派 Zero W][4] 并且用它来 [解决 WiFi 较差的原因][5] 。我也对使用 ePaper 来作为显示器十分感兴趣。而我却没有一个很好的用途,但是那看起来很有趣!我买了一个十分适合放在树莓派的顶部的 2.13 英寸的 [ WaveShare 显示器][6] 。安装很简单:只需要将显示器接到树莓派的 GPIO 上即可。 + +我使用 [树莓派系统][7] 来实现该项目,虽然其他的操作系统肯定也能完成。但是下面的 `raspi-config` 指令在树莓派系统上很容易使用。 + +### 设置树莓派和 ePaper 显示器 + +设置树莓派和 ePaper 显示器一起工作,需要你在树莓派上启用串行外设接口 (SPI) 软件,安装 BCM2835 C 库(来访问树莓派上的 Broadcom BCM 2835 芯片的 GPIO 函数),安装 Python GPIO 库来控制 ePaper 显示器。最后,你需要安装 WaveShare 的库来使用 Python 控制 2.13 英寸的显示器。 + +下面是完成这些的步骤。 + +#### 启用 SPI + +树莓派上启用 SPI 最简单的方式是使用`raspi-config` 命令。SPI 总线允许串行数据通信与设备一起使用——在本例中,ePaper 显示: + + +``` +`$ sudo raspi-config` +``` + +从弹出的菜单中, 选择 **Interfacing Options** -> **SPI** -> **Yes** 来启用 SPI 接口,然后启动。 + +#### 安装 BCM2835 库 + +如上所述,BCM2835 库是用在树莓派 Broadcom BCM2385 芯片的软件,它允许访问 GPIO 引脚来控制设备。 + +在我写这篇文章之时,用于树莓派的最新 Broadcom BCM2385 库版本是 v1.68 。安装此库需要下载软件压缩包然后使用 `make` 来安装: + + +``` +# 下载 BCM2853 库并解压 +$ curl -sSL -o - | tar -xzf - + +# 进入解压后的文件夹 +$ pushd bcm2835-1.68/ + +# 配置、检查并安装 BCM2853 库 +$ sudo ./configure +$ sudo make check +$ sudo make install + +# 返回上级目录 +$ popd +``` + +#### 安装需要的 Python 库 + +你用 Python 控制 ePaper 显示器需要安装 Python 库 `RPi.GPIO` ,还需要 `python3-pil` 包画图。显然, PIL 包已经不行了, Pillow 可以作为代替方案。我还没有为该项目测试 Pillow ,但它可行: + + +``` +# 安装需要的 Python 库 +$ sudo apt-get update +$ sudo apt-get install python3-pip python3-pil +$ sudo pip3 install RPi.GPIO +``` + +_注意:这些是 Python3 的指令。你可以在 WaveShare 网站查到 Python2 的指令。_ + +#### 下载 WaveShare 示例和 Python 库 + +Waveshare 维护一个 Python 和 C 的 Git 库,用于使用其 ePaper 显示器和一些展示如何使用它们的示例。对这个倒计时时钟而言,你需要克隆这个库并用于 2.13 英寸的显示器: + +``` +# 克隆这个 WaveShare e-Paper git 库 +$ git clone +``` + +如果你用不同的显示器或者其他公司产品,需要使用适配软件。 + +Waveshare 提供了很多指导: + + * [WaveShare ePaper 设置指导][9] + * [WaveShare ePaper 库安装指导][10] + + + +#### 获得有趣的字体(选做) + +你可以随心所欲的使用显示器,为什么不搞点花样?找一个炫酷的字体! + +这有大量 [开放字体许可][11] 的字体可用。我十分喜爱 Bangers 字体。如果你看过 YouTube 那你见过这种字体了,它十分流行。你可以下载到本地的共享字体目录文件中,并且所有的应用都可以使用,包括这个项目: + +``` +# “Bangers” 字体是 Vernon Adams 用 Google 字体开放许可授权的字体 +$ mkdir -p ~/.local/share/fonts +$ curl -sSL -o fonts/Bangers-Regular.ttf +``` + +### 创建一个 Pi Day 倒计时器 + +现在你已经安装好了软件,可以使用带有炫酷字体的 ePaper 显示器了。你可以创建一个有趣的项目:倒计时到下一个 Pi Day ! + +如果你想,你可以从该项目的 [GitHub repo][13] 直接下载 [countdown.py][12] 这个 Python 文件并跳到文章结尾。 + +为了满足大家的好奇心,我将逐步讲解。 + +#### 导入一些库 + + +``` +#!/usr/bin/python3 +# -*- coding:utf-8 -*- +import logging +import os +import sys +import time + +from datetime import datetime +from pathlib import Path +from PIL import Image,ImageDraw,ImageFont + +logging.basicConfig(level=logging.INFO) + +basedir = Path(__file__).parent +waveshare_base = basedir.joinpath('e-Paper', 'RaspberryPi_JetsonNano', 'python') +libdir = waveshare_base.joinpath('lib') +``` + +开始先导入一些标准库之后脚本中用。也需要你添加一些 PIL 的包: `Image`, `ImageDraw` ,和 `ImageFont` ,你会 用到这些包来画一些简单的图形。最后,为包含用于 2.13 英寸显示器的 Waveshare Python 库的本地 `lib` 目录设置一些变量,稍后你可以使用这些变量从本地目录加载库。 + +#### 字体大小辅助函数 + +下一部分是为你选择的字体建立一个修改大小的辅助函数: Bangers-Regular.ttf 。该函数将整型变量作为大小参数并返回一个图形字体对象来用于显示: + +``` +def set_font_size(font_size): +    logging.info("Loading font...") +    return ImageFont.truetype(f"{basedir.joinpath('Bangers-Regular.ttf').resolve()}", font_size) +``` + +#### 倒计时逻辑 + +接下来是计算这个项目的一个函数:距下次 Pi Day 还有多久。如果 Pi Day 在一月,那么计算剩余天数将很简单。但是你需要考虑是否今年的 Pi Day 这一天已经过去了。如果是这样的话,那么计算量将会很大: + + +``` +def countdown(now): +    piday = datetime(now.year, 3, 14) + +    # 如果错过了就增加一年 +    if piday < now: +        piday = datetime((now.year + 1), 3, 14) + +    days = (piday - now).days + +    logging.info(f"Days till piday: {days}") +    return day +``` + +#### 主函数 + +最后,到了主函数,需要初始化显示器并向它写数据。这时,你应该写一个欢迎语然后再开始倒计时。但是首先,你需要加载 Waveshare 库: + + +``` +def main(): + +    if os.path.exists(libdir): +        sys.path.append(f"{libdir}") +        from waveshare_epd import epd2in13_V2 +    else: +        logging.fatal(f"not found: {libdir}") +        sys.exit(1) +``` + +上面的代码片段检查以确保该库已下载到倒计时脚本旁边的目录中,然后加载“epd2in13_V2”库。 如果你使用不同的显示器,则需要使用不同的库。 如果你愿意,也可以自己编写。我发现阅读 Waveshare 随显示器提供的 Python 代码很有趣,它比我想象的要简单得多。 + +下一段代码创建一个 EPD( ePaper 显示器)对象以与显示器交互并初始化硬件: + +``` +    logging.info("Starting...") +    try: +        # 创建一个显示对象 +        epd = epd2in13_V2.EPD() + +        # 初始化并清空显示 +        # ePaper 保持它的状态处分更新 +        logging.info("Initialize and clear...") +        epd.init(epd.FULL_UPDATE) +        epd.Clear(0xFF) +``` + +关于 ePaper 的一个有趣之处:它仅在将像素从白色变为黑色或从黑色变为白色时才使用电源。这意味着当设备断电或应用程序因任何原因停止时,屏幕上的任何内容都会保留下来。从功耗的角度来看,这很好,但这也意味着您需要在启动时清除显示,否则您的脚本只会覆盖屏幕上已有的内容。 因此,`epd.Clear(0xFF)` 用于在脚本启动时清除显示。 + +接下来,创建一个“画布”来绘制剩余的显示输出: + + +``` +    # 创建一个图形对象 + # 注意:"epd.heigh" 是屏幕的长边 + # 注意:"epd.width" 是屏幕的短边 +    # 真是反直觉… +    logging.info(f"Creating canvas - height: {epd.height}, width: {epd.width}") +    image = Image.new('1', (epd.height, epd.width), 255)  # 255: clear the frame +    draw = ImageDraw.Draw(image) +``` + +这与显示器的宽度和高度相匹配——但它有点反直觉,因为显示器的短边是宽度。我认为长边是宽度,所以这只是需要注意的一点。 请注意,`epd.height` 和 `epd.width` 由 Waveshare 库设置以对应于你使用的设备。 + +#### 欢迎语 + +接下来,你将开始画一些画。这涉及在你之前创建的“画布”对象上设置数据。这还没有将它绘制到 ePaper 显示器上——你现在只是在构建你想要的图像。由你为这个项目绘制带有一块馅饼的图像,来创建一个庆祝 Pi Day 的欢迎信息: + +![画一块馅饼][14] + +(Chris Collins, [CC BY-SA 4.0][15]) + +很可爱,不是吗? + + +``` +    logging.info("Set text text...") +    bangers64 = set_font_size(64) +    draw.text((0, 30), 'PI DAY!', font = bangers64, fill = 0) + +    logging.info("Set BMP...") +    bmp = Image.open(basedir.joinpath("img", "pie.bmp")) +    image.paste(bmp, (150,2)) +``` +最后,_最后_,你可以展示你画的图画: + +``` +    logging.info("Display text and BMP") +    epd.display(epd.getbuffer(image)) +``` + +That bit above updates the display to show the image you drew. + +接下来,准备另一幅图像展示你的倒计时: + +#### Pi Day 倒计时 +首先,创建一个用来展示倒计时的项目。也需要设置数字的字体大小: + + +``` +    logging.info("Pi Date countdown; press CTRL-C to exit") +    piday_image = Image.new('1', (epd.height, epd.width), 255) +    piday_draw = ImageDraw.Draw(piday_image) + +    # 设置字体大小 +    bangers36 = set_font_size(36) +    bangers64 = set_font_size(64) +``` + +为了使它显示的时候更像一个倒计时,更新图像的一部分是更加有效的手段,仅更改已经改变的显示数据部分。下面的代码准备以这样方式运行: + + +``` +    # 准备更新显示 +    epd.displayPartBaseImage(epd.getbuffer(piday_image)) +    epd.init(epd.PART_UPDATE) +``` + +最后,需要计时,开始一个无限循环来检查据下次 Pi Day 还有多久并显示在 ePaper上。如果到了 Pi Day ,你可以输出一些庆祝短语: + + +``` +    while (True): +        days = countdown(datetime.now()) +        unit = get_days_unit(days) + +        # 通过绘制一个填充有白色的矩形来清除屏幕的下半部分 +        piday_draw.rectangle((0, 50, 250, 122), fill = 255) + +        # 绘制页眉 +        piday_draw.text((10,10), "Days till Pi-day:", font = bangers36, fill = 0) + +        if days == 0: +            # 绘制庆祝语 +            piday_draw.text((0, 50), f"It's Pi Day!", font = bangers64, fill = 0) +        else: +            # 绘制距下一次 Pi Day 的时间 +            piday_draw.text((70, 50), f"{str(days)} {unit}", font = bangers64, fill = 0) + +        # 渲染屏幕 +        epd.displayPartial(epd.getbuffer(piday_image)) +        time.sleep(5) +``` + +脚本最后做了一些错误处理,包括捕获键盘中断,这样你可以使用 **Ctrl**+**C** 来结束无限循环,以及一个根据计数来打印 'day' 或 'days' 的函数: + +``` +    except IOError as e: +        logging.info(e) + +    except KeyboardInterrupt: +        logging.info("Exiting...") +        epd.init(epd.FULL_UPDATE) +        epd.Clear(0xFF) +        time.sleep(1) +        epd2in13_V2.epdconfig.module_exit() +        exit() + +def get_days_unit(count): +    if count == 1: +        return "day" + +    return "days" + +if __name__ == "__main__": +    main() +``` + +现在你已经拥有一个倒计时脚本并显示剩余天数!这是在我的树莓派上的显示(视频经过加速,我没有足够的磁盘空间来保存一整天的视频): + +![Pi Day Countdown Timer In Action][16] + +(Chris Collins, [CC BY-SA 4.0][15]) + +#### 安装 systemd 服务(选做) + +如果你希望在系统打开时运行倒计时显示并且无需登录并运行脚本,您可以将可选的 systemd 单元安装为 [systemd 用户服务][17]. + +将 GitHub 上的 [piday.service][18] 文件复制到 `${HOME}/.config/systemd/user`,如果该目录不存在,请先创建该目录。然后你可以启用该服务并启动它: + + +``` +$ mkdir -p ~/.config/systemd/user +$ cp piday.service ~/.config/systemd/user +$ systemctl --user enable piday.service +$ systemctl --user start piday.service + +# Enable lingering, to create a user session at boot +# and allow services to run after logout +$ loginctl enable-linger $USER +``` + +该脚本将输出到 systemd 日志,可以使用 `journalctl` 命令查看输出。 + +### 它开始看起来很像 Pi Day ! + +现在你拥有了一个树莓派 Zero W 显示在 ePaper显示器上的 Pi Day 倒计时器!并在系统启动时使用 systemd 单元文件启动!现在只有 350 天左右我们才可以再次相聚庆祝奇妙的设备———树莓派。通过我们的小项目,我们可以一目了然地看到确切的天数。 + +但事实上,任何人都可以全年都在心中举行 Pi Day,因此请享受使用自己的树莓派创建一些有趣且具有教育意义的项目吧! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/3/raspberry-pi-countdown-clock + +作者:[Chris Collins][a] +选题:[lujun9972][b] +译者:[Donkey](https://github.com/Donkey-Hao) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/clcollins +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/clocks_time.png?itok=_ID09GDk (Alarm clocks with different time) +[2]: https://en.wikipedia.org/wiki/Pi_Day +[3]: https://opensource.com/tags/raspberry-pi +[4]: https://www.raspberrypi.org/products/raspberry-pi-zero-w/ +[5]: https://opensource.com/article/21/3/troubleshoot-wifi-go-raspberry-pi +[6]: https://www.waveshare.com/product/displays/e-paper.htm +[7]: https://www.raspberrypi.org/software/operating-systems/ +[8]: https://pypi.org/project/Pillow/ +[9]: https://www.waveshare.com/wiki/2.13inch_e-Paper_HAT +[10]: https://www.waveshare.com/wiki/Libraries_Installation_for_RPi +[11]: https://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL +[12]: https://github.com/clcollins/epaper-pi-ex/blob/main/countdown.py +[13]: https://github.com/clcollins/epaper-pi-ex/ +[14]: https://opensource.com/sites/default/files/uploads/pie.png (drawing of a piece of pie) +[15]: https://creativecommons.org/licenses/by-sa/4.0/ +[16]: https://opensource.com/sites/default/files/uploads/piday_countdown.gif (Pi Day Countdown Timer In Action) +[17]: https://wiki.archlinux.org/index.php/systemd/User +[18]: https://github.com/clcollins/epaper-pi-ex/blob/main/piday.service From 4afc372fb3fd9fe2fa32ad4294cb02d9c9ce786b Mon Sep 17 00:00:00 2001 From: lkxed Date: Sun, 12 Jun 2022 22:08:26 +0800 Subject: [PATCH 15/78] =?UTF-8?q?[=E6=89=8B=E5=8A=A8=E9=80=89=E9=A2=98][te?= =?UTF-8?q?ch]:=2020220612=20LibreOffice=207.4-=20Top=20New=20Features=20a?= =?UTF-8?q?nd=20Release=20Details.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4- Top New Features and Release Details.md | 151 ++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 sources/tech/20220612 LibreOffice 7.4- Top New Features and Release Details.md diff --git a/sources/tech/20220612 LibreOffice 7.4- Top New Features and Release Details.md b/sources/tech/20220612 LibreOffice 7.4- Top New Features and Release Details.md new file mode 100644 index 0000000000..cd0c22d2a7 --- /dev/null +++ b/sources/tech/20220612 LibreOffice 7.4- Top New Features and Release Details.md @@ -0,0 +1,151 @@ +[#]: subject: "LibreOffice 7.4: Top New Features and Release Details" +[#]: via: "https://www.debugpoint.com/2022/06/libreoffice-7-4/" +[#]: author: "Arindam https://www.debugpoint.com/author/admin1/" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +LibreOffice 7.4: Top New Features and Release Details +====== +This post contains the top new features of LibreOffice 7.4 (upcoming) across Writer, Calc, Impress and other core modules. + +**This post contains the top new features of LibreOffice 7.4 (upcoming) across Writer, Calc, Impress and other core modules.** + +The LibreOffice team improves the famous free and open-source office product with each iteration. Perhaps the only stable and well-managed open-source project as a replacement to Microsoft Office. + +The LibreOffice 7.4 version (planned in August), bringing regular updates to core modules including Calc, Writer and Impress with features and enhancements. Furthermore, in this release, the compatibility with Microsoft Office improved with changes to the core filters and platform updates. + +Before we round up the new features, here’s a tentative schedule for LibreOffice 7.4: + +### Schedule + +| Milestone | Release Date | +| :- | :- | +| Alpha 1 | May 9, 2022 – May 15, 2022 | +| Feature Freeze | Jun 6, 2022 – Jun 12, 2022 | +| Beta 1 | Jun 6, 2022 – Jun 12, 2022 | +| RC1 | Jul 4, 2022 – Jul 10, 2022 | +| RC2 | Jul 25, 2022 – Jul 31, 2022 | +| RC3 | Aug 8, 2022 – Aug 14, 2022 | +| Release 7.4 | Aug 15, 2022 – Aug 21, 2022 | + +### LibreOffice 7.4 Features + +#### Calc + +First and foremost, the most crucial change coming in 7.4 is the support of 16k columns in LibreOffice Calc. It was available in earlier LibreOffice 7.3 but hidden as an experimental option. Finally, it is open to support 16384 columns, i.e. up to XFD. Additional columns are going to help several high-volume data work. + +![LibreOffice 7.4 Calc now supports 16k columns.][1] + +Second, the Autosum button gets the following [additional functions][2] to improve productivity and save time. + +* COUNTA +* PRODUCT +* STDEV +* STDEVP +* VAR +* VARP + +![Additional options in Autosum button][3] + +Moreover, the height of the formula bar is now part of the *.ods files. Hence, you can see the height retained after saving the file and opening it. Earlier, it was being reset to the default height. It is one of the small changes but has a more significant impact on heavy Calc users. + +![Height of Calc Formula bar][4] + +In addition, a new menu option `Sheet > Navigate > Go to Sheet` shows an entire new dialog which is similar to the Writer’s Go to Page. + +#### Writer + +Firstly, the hyphenation settings get three new options. You can now specify the size of the hyphenation zone, minimum word length and ability to stop hyphenating the last word. + +![New Hyphenation settings][5] + +*Image credit: LibreOffice Team* + +Secondly, the menu item Tools > Update > Update now updates the preview of all OLE objects. Also, if you are importing a DOCX file in LibreOffice 7.4, the paragraph borders bring more clarity. In addition, the import also improves the Rich text and checkbox contents inside the text box for DOCX imports. Moreover, Write 7.4 now supports clearing breaks from Word files improving layout consistency. + +Secondly, the menu item `Tools > Update > Update all` now updates the preview of all OLE objects. + +Also, if you are importing a DOCX file in LibreOffice 7.4, the paragraph borders bring more clarity. In addition, the import also improves the Rich text and checkbox contents inside the text box for DOCX imports. + +Moreover, Writer 7.4 now supports clearing breaks from Word files improving layout consistency. + +#### Impress + +The significant change in Impress is a new Theme tab in the Slide properties for the master slide. It contains several accent colour options which control all the sildes in your presentation. It will be a really neat feature in this version. + +![New Theme option in Slide Master Properties][6] + +### Common Updates (across all modules) + +Firstly, the most important change as a standard feature is LibreOffice now supports WEBP images officially. You can directly export and import WebP images across Writer, Calc, Draw etc. Now you do not need additional software to convert WEBP images, especially in Linux systems. + +Moreover, the support for Windows compressed enhanced meta file (EMZ/WMZ) also lands in this release. + +![New WEBP Image Support][7] + +Secondly, the Fille > Recent Documents can remember the state of the last opened document, whether it was read-only or editable. + +The 3D shapes lighting gets some bug fixes and corrections corresponding to the ODF specifications. + +### Performance Updates + +A bunch of performance boosts also makes this an important release of LibreOffice. Here’s a quick recap of the performance boosts. + +* [The Text Layout performance gets around a 60% boost][8] +* [Calc formula re-calculation][9] +* Improved performance of [VLOOKUP][10], COUNTIF and SUMIF +* [And CSV file import][11] + +That’s not all. LibreOffice 7.4 also brings a huge set of filters (export and import) for Microsoft Office 365 file types, extended PDF export options (such as a sign) via command line, updated language support and API changes. + +### Download LibreOffice 7.4 for Testing + +You can download the development version of LibreOffice 7.4 using the respective links and help to test. + +* [RPM Package for Fedora and related distributions][12] +* [DEB packages for Ubuntu, Linux Mint and others][13] +* [Windows 10, 11 – 64-bit][14] +* [macOS 64 bit][15] +* [Mac OS X – ARM and Apple SIlicon, M1][16] + +If you need assistance, you can refer to our [guide here][17] to install the development version in Linux. Make sure to report any issues or bugs in the [official bug tracker.][18] + +LibreOffice 7.4 is planned for release between Aug 15, 2022, and Aug 21, 2022. + +*[Via Release Notes][19]* + +-------------------------------------------------------------------------------- + +via: https://www.debugpoint.com/2022/06/libreoffice-7-4/ + +作者:[Arindam][a] +选题:[lkxed][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.debugpoint.com/author/admin1/ +[b]: https://github.com/lkxed +[1]: https://www.debugpoint.com/wp-content/uploads/2022/06/LibreOffice-7.4-Calc-now-supports-16k-columns.jpg +[2]: https://bugs.documentfoundation.org/show_bug.cgi?id=139602 +[3]: https://www.debugpoint.com/wp-content/uploads/2022/06/Additional-formula-in-Autosum-tool.jpg +[4]: https://www.debugpoint.com/wp-content/uploads/2022/06/Height-of-Calc-Formula-bar.jpg +[5]: https://www.debugpoint.com/wp-content/uploads/2022/06/New-Hyphenation-settings.jpg +[6]: https://www.debugpoint.com/wp-content/uploads/2022/06/New-Theme-option-in-Slide-Master-Properties.jpg +[7]: https://www.debugpoint.com/wp-content/uploads/2022/06/New-WEBP-Image-Support.jpg +[8]: http://llunak.blogspot.com/2022/04/improving-text-layout-performance.html +[9]: https://bugs.documentfoundation.org/show_bug.cgi?id=119083 +[10]: https://bugs.documentfoundation.org/show_bug.cgi?id=146546 +[11]: https://bugs.documentfoundation.org/show_bug.cgi?id=94677 +[12]: https://www.libreoffice.org/download/download/?type=rpm-x86_64&version=7.4.0&lang=en-US +[13]: https://www.libreoffice.org/download/download/?type=deb-x86_64&version=7.4.0&lang=en-US +[14]: https://www.libreoffice.org/download/download/?type=win-x86_64&version=7.4.0&lang=en-US +[15]: https://www.libreoffice.org/download/download/?type=mac-x86_64&version=7.4.0&lang=en-US +[16]: https://www.libreoffice.org/download/download/?type=mac-aarch64&version=7.4.0&lang=en-US +[17]: https://www.debugpoint.com/2022/06/install-latest-libreoffice-ubuntu-linux/ +[18]: https://bugs.documentfoundation.org/ +[19]: https://wiki.documentfoundation.org/ReleaseNotes/7.4 From 3c26deb6bcee45e2f40b2c6a3a03681ad5ea604e Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 13 Jun 2022 08:41:20 +0800 Subject: [PATCH 16/78] translatedd --- ...untu 22.04 into Rescue - Emergency Mode.md | 85 ------------------- ...untu 22.04 into Rescue - Emergency Mode.md | 85 +++++++++++++++++++ 2 files changed, 85 insertions(+), 85 deletions(-) delete mode 100644 sources/tech/20220607 How to Boot Ubuntu 22.04 into Rescue - Emergency Mode.md create mode 100644 translated/tech/20220607 How to Boot Ubuntu 22.04 into Rescue - Emergency Mode.md diff --git a/sources/tech/20220607 How to Boot Ubuntu 22.04 into Rescue - Emergency Mode.md b/sources/tech/20220607 How to Boot Ubuntu 22.04 into Rescue - Emergency Mode.md deleted file mode 100644 index 70ff4e6105..0000000000 --- a/sources/tech/20220607 How to Boot Ubuntu 22.04 into Rescue - Emergency Mode.md +++ /dev/null @@ -1,85 +0,0 @@ -[#]: subject: "How to Boot Ubuntu 22.04 into Rescue / Emergency Mode" -[#]: via: "https://www.linuxtechi.com/boot-ubuntu-22-04-rescue-emergency-mode/" -[#]: author: "Pradeep Kumar https://www.linuxtechi.com/author/pradeep/" -[#]: collector: "lkxed" -[#]: translator: "geekpi" -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " - -How to Boot Ubuntu 22.04 into Rescue / Emergency Mode -====== -Hello geeks, booting Ubuntu 22.04 (Jammy Jellyfish) into rescue and emergency mode helps to reset the forgotten user password, fix the file system errors and disabling or enabling systemd service during boot. - -In this post, we will learn how to boot Ubuntu 22.04 LTS system into rescue and emergency mode. Rescue mode is similar to single user mode where are all troubleshooting steps are executed. Rescue mode loads the minimal environment and mount root file system. - -Whereas in emergency mode, we get the single user shell without starting any system services. So emergency mode is required when we can’t boot the system into rescue mode. - -### Boot Ubuntu 22.04 into Rescue or Single User Mode - -Head to target system which you want to boot into rescue or single user mode. At the boot press ‘SHIFT & ESC’ key to enter into grub bootloader screen. - -![Default-Grub-Screen-Ubuntu-22-04][1] - -Choose the first option Ubuntu and press ‘e’ to enter edit mode. - -Go the end of line which starts with linux and delete the string ‘$vt_handoff’ and add the string ‘systemd.unit=rescue.target’ - -![rescue-target-ubuntu-22-04][2] - -After making the changes, either press Ctrl+x or F10 to boot in rescue mode, - -![Troubleshooting-Commands-in-Rescue-Mode][3] - -Once you enter into rescue mode, run all troubleshooting commands and to reboot the system run ‘systemctl reboot’ command - -### Alternate Way to Boot System into Rescue Mode - -Reboot the system and press ‘ESC & Shift’ Key to go to grub boot screen. - -Choose the 2nd option ‘Advanced Options for Ubuntu’ –> Choose recovery mode option and hit enter –> Choose Root (Drop to root shell prompt). - -Example is show below - -![Boot-Ubuntu-22-04-Rescue-Mode][4] - -Once you have root shell, run commands to recover and fix the system issues and finally use ‘systemctl reboot’ to reboot the system. - -### Boot Ubuntu 22.04 into Emergency Mode - -To boot the system into emergency mode, first go to grub screen. - -![Default-Grub-Screen-Ubuntu-22-04][5] - -Select the first option as ‘Ubuntu’ and press ‘e’ to edit. Look for the line which starts with linux word, go to the end of that line, remove the string $vt_handoff and add the string ‘systemd.unit=emergency.target’ - -![Emergency-Mode-Ubuntu-22-04][6] - -Press Ctrl+x or F10 to boot the system into emergency mode, - -![Command-in-Emergency-Mode-Ubuntu-22-04][7] - -Similarly in rescue mode, you can perform all the troubleshooting in this mode and once done reboot the system with command ‘systemctl reboot’. - -That’s all from this post. I found it informative and don’t hesitate to share this among your technical friends. Kindly post your queries and feedback in below comments section. - --------------------------------------------------------------------------------- - -via: https://www.linuxtechi.com/boot-ubuntu-22-04-rescue-emergency-mode/ - -作者:[Pradeep Kumar][a] -选题:[lkxed][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.linuxtechi.com/author/pradeep/ -[b]: https://github.com/lkxed -[1]: https://www.linuxtechi.com/wp-content/uploads/2022/06/Default-Grub-Screen-Ubuntu-22-04.png -[2]: https://www.linuxtechi.com/wp-content/uploads/2022/06/rescue-target-ubuntu-22-04.png -[3]: https://www.linuxtechi.com/wp-content/uploads/2022/06/Troubleshooting-Commands-in-Rescue-Mode.png -[4]: https://www.linuxtechi.com/wp-content/uploads/2022/06/Boot-Ubuntu-22-04-Rescue-Mode.gif -[5]: https://www.linuxtechi.com/wp-content/uploads/2022/06/Default-Grub-Screen-Ubuntu-22-04.png -[6]: https://www.linuxtechi.com/wp-content/uploads/2022/06/Emergency-Mode-Ubuntu-22-04.png -[7]: https://www.linuxtechi.com/wp-content/uploads/2022/06/Command-in-Emergency-Mode-Ubuntu-22-04.png diff --git a/translated/tech/20220607 How to Boot Ubuntu 22.04 into Rescue - Emergency Mode.md b/translated/tech/20220607 How to Boot Ubuntu 22.04 into Rescue - Emergency Mode.md new file mode 100644 index 0000000000..86f542b747 --- /dev/null +++ b/translated/tech/20220607 How to Boot Ubuntu 22.04 into Rescue - Emergency Mode.md @@ -0,0 +1,85 @@ +[#]: subject: "How to Boot Ubuntu 22.04 into Rescue / Emergency Mode" +[#]: via: "https://www.linuxtechi.com/boot-ubuntu-22-04-rescue-emergency-mode/" +[#]: author: "Pradeep Kumar https://www.linuxtechi.com/author/pradeep/" +[#]: collector: "lkxed" +[#]: translator: "geekpi" +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +如何启动 Ubuntu 22.04 进入救援/紧急模式 +====== +极客们好,将 Ubuntu 22.04(Jammy Jellyfish)启动到救援和紧急模式有助于重置忘记的用户密码,修复文件系统错误以及在启动过程中禁用或启用 systemd 服务。 + +在这篇文章中,我们将学习如何启动 Ubuntu 22.04 LTS 系统进入救援和应急模式。救援模式类似于单用户模式,所有的故障排除步骤都在这里进行。救援模式加载最小的环境并挂载根文件系统。 + +而在紧急模式下,我们得到的是单用户 shell,而不启动任何系统服务。因此,当我们无法启动系统进入救援模式时,就需要紧急模式。 + +### 启动 Ubuntu 22.04 进入救援或单用户模式 + +前往你想启动到救援或单用户模式的目标系统。在启动时按下 “SHIFT+ESC” 键,进入 grub bootloader 页面。 + +![Default-Grub-Screen-Ubuntu-22-04][1] + +选择第一个选项 Ubuntu,并按 “e” 键进入编辑模式。 + +在以 linux 开头的一行末尾,删除字符串 “$vt_handoff” 并添加字符串 “systemd.unit=rescue.target”。 + +![rescue-target-ubuntu-22-04][2] + +做完修改后,按 Ctrl+x 或 F10 在救援模式下启动。 + +![Troubleshooting-Commands-in-Rescue-Mode][3] + +进入救援模式后,运行所有的故障排除命令,并运行 “systemctl reboot” 命令来重启系统。 + +### 另一种启动系统进入救援模式的方法 + +重新启动系统并按下 “ESC+Shift” 键,进入 grub 启动界面。 + +选择第二个选项 “Advanced Options for Ubuntu”->选择恢复模式选项并点击回车->选择 Root(进入 root shell 提示)。 + +下面是一个例子 + +![Boot-Ubuntu-22-04-Rescue-Mode][4] + +当你有了 root shell,运行命令来恢复和修复系统问题,最后使用 “systemctl reboot” 来重启系统。 + +### 引导 Ubuntu 22.04 进入紧急模式 + +要启动系统进入紧急模式,首先进入 grub 页面。 + +![Default-Grub-Screen-Ubuntu-22-04][5] + +选择第一个选项 “Ubuntu” 并按 “e” 键进行编辑。寻找以 linux 开头的一行,移到该行的末尾,删除字符串 $vt_handoff 并添加字符串 “systemd.unit=emergency.target”。 + +![Emergency-Mode-Ubuntu-22-04][6] + +按 Ctrl+x 或 F10 将系统启动到紧急模式。 + +![Command-in-Emergency-Mode-Ubuntu-22-04][7] + +同样,在救援模式下,你可以在这个模式下执行所有的故障排除,完成后,就用 “systemctl reboot” 命令重启系统。 + +这篇文章的内容就这些。我发现它内容丰富,不要犹豫,在你的技术朋友中分享这个。请在下面的评论区发表你的疑问和反馈。 + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/boot-ubuntu-22-04-rescue-emergency-mode/ + +作者:[Pradeep Kumar][a] +选题:[lkxed][b] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxtechi.com/author/pradeep/ +[b]: https://github.com/lkxed +[1]: https://www.linuxtechi.com/wp-content/uploads/2022/06/Default-Grub-Screen-Ubuntu-22-04.png +[2]: https://www.linuxtechi.com/wp-content/uploads/2022/06/rescue-target-ubuntu-22-04.png +[3]: https://www.linuxtechi.com/wp-content/uploads/2022/06/Troubleshooting-Commands-in-Rescue-Mode.png +[4]: https://www.linuxtechi.com/wp-content/uploads/2022/06/Boot-Ubuntu-22-04-Rescue-Mode.gif +[5]: https://www.linuxtechi.com/wp-content/uploads/2022/06/Default-Grub-Screen-Ubuntu-22-04.png +[6]: https://www.linuxtechi.com/wp-content/uploads/2022/06/Emergency-Mode-Ubuntu-22-04.png +[7]: https://www.linuxtechi.com/wp-content/uploads/2022/06/Command-in-Emergency-Mode-Ubuntu-22-04.png From ffba8cfc77911c24e748747126a873cb2923068e Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 13 Jun 2022 08:44:14 +0800 Subject: [PATCH 17/78] translating --- .../tech/20220610 Manage Flatpak Permission Using Flatseal.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/tech/20220610 Manage Flatpak Permission Using Flatseal.md b/sources/tech/20220610 Manage Flatpak Permission Using Flatseal.md index 0101e22235..893db83b87 100644 --- a/sources/tech/20220610 Manage Flatpak Permission Using Flatseal.md +++ b/sources/tech/20220610 Manage Flatpak Permission Using Flatseal.md @@ -2,7 +2,7 @@ [#]: via: "https://www.debugpoint.com/2022/06/manage-flatpak-permission-flatseal/" [#]: author: "Arindam https://www.debugpoint.com/author/admin1/" [#]: collector: "lkxed" -[#]: translator: " " +[#]: translator: "geekpi" [#]: reviewer: " " [#]: publisher: " " [#]: url: " " From b3c33934e3577e1e6b813c4739f32e6a8ae3bf9b Mon Sep 17 00:00:00 2001 From: lkxed Date: Mon, 13 Jun 2022 11:23:54 +0800 Subject: [PATCH 18/78] =?UTF-8?q?=E6=B8=85=E7=90=86=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...210722 Write your first JavaScript code.md | 182 ++++++++---------- 1 file changed, 82 insertions(+), 100 deletions(-) diff --git a/sources/tech/20210722 Write your first JavaScript code.md b/sources/tech/20210722 Write your first JavaScript code.md index d02ca214cd..9e1af727df 100644 --- a/sources/tech/20210722 Write your first JavaScript code.md +++ b/sources/tech/20210722 Write your first JavaScript code.md @@ -1,18 +1,19 @@ -[#]: subject: (Write your first JavaScript code) -[#]: via: (https://opensource.com/article/21/7/javascript-cheat-sheet) -[#]: author: (Seth Kenlon https://opensource.com/users/seth) -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: subject: "Write your first JavaScript code" +[#]: via: "https://opensource.com/article/21/7/javascript-cheat-sheet" +[#]: author: "Seth Kenlon https://opensource.com/users/seth" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " Write your first JavaScript code ====== -JavaScript was created for the web, but it can do so much more. Learn -the basics, then download our cheat sheet so you always have the details -at hand. -![Code with javascript on white background][1] +JavaScript was created for the web, but it can do so much more. Learn the basics, then download our cheat sheet so you always have the details at hand. + +![open source programming][1] + +Image by: Opensource.com JavaScript is a programming language full of pleasant surprises. Many people first encounter JavaScript as a language for the web. There's a JavaScript engine in all the major browsers, there are popular frameworks such as JQuery, Cash, and Bootstrap to help make web design easier, and there are even programming environments written in JavaScript. It seems to be everywhere on the internet, but it turns out that it's also a useful language for projects like [Electron][2], an open source toolkit for building cross-platform desktop apps with JavaScript. @@ -26,50 +27,44 @@ As you progress with JavaScript, you may find yourself wanting advanced JavaScri To write your first JavaScript code, open your favorite text editor, such as [Notepad++][3], [Atom][4], or [VSCode][5]. Because it was developed for the web, JavaScript works well with HTML, so first, just try some basic HTML: - ``` -<[html][6]> -  <[head][7]> -    <[title][8]>JS</[title][8]> -  </[head][7]> -  <[body][9]> -    <[p][10] id="example">Nothing here.</[p][10]> -  </[body][9]> -</[html][6]> + +  +    JS +  +  +   

Nothing here.

+  + ``` Save the file, and then open it in a web browser. -![HTML displayed in browser][11] - -(Seth Kenlon, [CC BY-SA 4.0][12]) - -To add JavaScript to this simple HTML page, you can either create a JavaScript file and refer to it in the page's `head` or just embed your JavaScript code in the HTML using the ` + +  + ``` Reload the page in your browser. -![HTML with JavaScript displayed in browser][14] - -(Seth Kenlon, [CC BY-SA 4.0][12]) +![HTML with JavaScript displayed in browser][7] As you can see, the `

` tag as written still contains the string "Nothing here," but when it's rendered, JavaScript alters it so that it contains "Hello world" instead. Yes, JavaScript has the power to rebuild (or just help build) a webpage. @@ -77,30 +72,29 @@ The JavaScript in this simple script does two things. First, it creates a variab Of course, using a custom variable isn't necessary. It's just as easy to populate the HTML element with something being dynamically created. For instance, you could populate it with a timestamp: - ``` -<[html][6]> -  <[head][7]> -    <[title][8]>JS</[title][8]> -  </[head][7]> -  <[body][9]> -    <[p][10] id="example">Date and time appears here.</[p][10]> + +  +    JS +  +  +   

Date and time appears here.

-    <[script][13]> +    +    +  + ``` Reload the page to see a timestamp generated at the moment the page is rendered. Reload a few times to watch the seconds increment. ### JavaScript syntax -In programming, **syntax** refers to the rules of how sentences (or "lines") are written. In JavaScript, each line of code must end in a semicolon (`;`) so that the JavaScript engine running your code understands when to stop reading. +In programming, **syntax** refers to the rules of how sentences (or "lines") are written. In JavaScript, each line of code must end in a semicolon (`;` ) so that the JavaScript engine running your code understands when to stop reading. -Words (or "strings") must be enclosed in quotation marks (`"`), while numbers (or "integers") go without. +Words (or "strings") must be enclosed in quotation marks (`"` ), while numbers (or "integers") go without. Almost everything else is a convention of the JavaScript language, such as variables, arrays, conditional statements, objects, functions, and so on. @@ -110,95 +104,83 @@ Variables are containers for data. You can think of a variable as a box where yo JavaScript's built-in `typeof` function can help you identify what kind of data a variable contains. Using the first example, you can find out what kind of data `myvariable` contains by modifying the displayed text to: - ``` -<string> + let myvariable = "Hello world!"; document.getElementById("example").innerHTML = typeof(myvariable); -</string> + ``` This renders "string" in your web browser because the variable contains "Hello world!" Storing different kinds of data (such as an integer) in `myvariable` would cause a different data type to be printed to your sample web page. Try changing the contents of `myvariable` to your favorite number and then reloading the page. ### Creating functions in JavaScript -Functions in programming are self-contained data processors. They're what makes programming _modular_. It's because functions exist that programmers can write generic libraries that, for instance, resize images or keep track of the passage of time for other programmers (like you) to use in their own code. +Functions in programming are self-contained data processors. They're what makes programming *modular*. It's because functions exist that programmers can write generic libraries that, for instance, resize images or keep track of the passage of time for other programmers (like you) to use in their own code. You create a function by providing a custom name for your function followed by any amount of code enclosed within braces. -Here's a simple web page featuring a resized image and a button that analyzes the image and returns the true image dimensions. In this example code, the ` +    +    +   
+      +   
    -    <[div][15]> -      <[img][17] style="width: 15%" id="myimg" src="penguin.png" /> -    </[div][15]> -    -    <[script][13]> +    +    +  + ``` Save the file and load it into your web browser to try the code. -![Custom get_size function returns image dimensions][18] - -(Seth Kenlon, [CC BY-SA 4.0][12]) +![Custom get_size function returns image dimensions][8] ### Cross-platform apps with JavaScript You can see from the code sample how JavaScript and HTML work closely together to create a cohesive user experience. This is one of the great strengths of JavaScript. When you write code in JavaScript, you inherit one of the most common user interfaces of modern computing regardless of platform: the web browser. Your code is cross-platform by nature, so your application, whether it's just a humble image size analyzer or a complex image editor, video game, or whatever else you dream up, can be used by everyone with a web browser (or a desktop, if you deliver an Electron app). -Learning JavaScript is easy and fun. There are lots of websites with tutorials available. There are also over a million JavaScript libraries to help you interface with devices, peripherals, the Internet of Things, servers, file systems, and lots more. And as you're learning, keep our [**JavaScript cheat sheet**][19] close by so you remember the fine details of syntax and structure. +Learning JavaScript is easy and fun. There are lots of websites with tutorials available. There are also over a million JavaScript libraries to help you interface with devices, peripherals, the Internet of Things, servers, file systems, and lots more. And as you're learning, keep our [JavaScript cheat sheet][9] close by so you remember the fine details of syntax and structure. + +Image by: (Seth Kenlon, CC BY-SA 4.0) -------------------------------------------------------------------------------- via: https://opensource.com/article/21/7/javascript-cheat-sheet 作者:[Seth Kenlon][a] -选题:[lujun9972][b] -译者:[lixin555](https://github.com/lixin555) +选题:[lkxed][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/code2.png?itok=JCJTJszs (Code with javascript on white background) +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/code2.png [2]: https://www.electronjs.org/ [3]: https://opensource.com/article/16/12/notepad-text-editor [4]: https://opensource.com/article/20/12/atom [5]: https://opensource.com/article/20/6/open-source-alternatives-vs-code -[6]: http://december.com/html/4/element/html.html -[7]: http://december.com/html/4/element/head.html -[8]: http://december.com/html/4/element/title.html -[9]: http://december.com/html/4/element/body.html -[10]: http://december.com/html/4/element/p.html -[11]: https://opensource.com/sites/default/files/pictures/plain-html.jpg (HTML displayed in browser) -[12]: https://creativecommons.org/licenses/by-sa/4.0/ -[13]: http://december.com/html/4/element/script.html -[14]: https://opensource.com/sites/default/files/uploads/html-javascript.jpg (HTML with JavaScript displayed in browser) -[15]: http://december.com/html/4/element/div.html -[16]: http://december.com/html/4/element/button.html -[17]: http://december.com/html/4/element/img.html -[18]: https://opensource.com/sites/default/files/uploads/get-size.jpg (Custom get_size function returns image dimensions) -[19]: https://opensource.com/downloads/javascript-cheat-sheet +[6]: https://opensource.com/sites/default/files/pictures/plain-html.jpg +[7]: https://opensource.com/sites/default/files/uploads/html-javascript.jpg +[8]: https://opensource.com/sites/default/files/uploads/get-size.jpg +[9]: https://opensource.com/downloads/javascript-cheat-sheet From c8b31062dd2c060d39b0bb6772a7ca9996a7ba39 Mon Sep 17 00:00:00 2001 From: lkxed Date: Mon, 13 Jun 2022 11:26:40 +0800 Subject: [PATCH 19/78] =?UTF-8?q?[=E7=94=B3=E9=A2=86=E5=8E=9F=E6=96=87][te?= =?UTF-8?q?ch]:=2020210722=20Write=20your=20first=20JavaScript=20code.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sources/tech/20210722 Write your first JavaScript code.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/tech/20210722 Write your first JavaScript code.md b/sources/tech/20210722 Write your first JavaScript code.md index 9e1af727df..0b74edb1d2 100644 --- a/sources/tech/20210722 Write your first JavaScript code.md +++ b/sources/tech/20210722 Write your first JavaScript code.md @@ -2,7 +2,7 @@ [#]: via: "https://opensource.com/article/21/7/javascript-cheat-sheet" [#]: author: "Seth Kenlon https://opensource.com/users/seth" [#]: collector: "lkxed" -[#]: translator: " " +[#]: translator: "lkxed" [#]: reviewer: " " [#]: publisher: " " [#]: url: " " From ecf91319c392bc62e1e71afd248f2c762eab208d Mon Sep 17 00:00:00 2001 From: lkxed Date: Mon, 13 Jun 2022 12:33:59 +0800 Subject: [PATCH 20/78] =?UTF-8?q?[=E6=8F=90=E4=BA=A4=E8=AF=91=E6=96=87][te?= =?UTF-8?q?ch]:=2020210722=20Write=20your=20first=20JavaScript=20code.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...210722 Write your first JavaScript code.md | 186 ----------------- ...210722 Write your first JavaScript code.md | 187 ++++++++++++++++++ 2 files changed, 187 insertions(+), 186 deletions(-) delete mode 100644 sources/tech/20210722 Write your first JavaScript code.md create mode 100644 translated/tech/20210722 Write your first JavaScript code.md diff --git a/sources/tech/20210722 Write your first JavaScript code.md b/sources/tech/20210722 Write your first JavaScript code.md deleted file mode 100644 index 0b74edb1d2..0000000000 --- a/sources/tech/20210722 Write your first JavaScript code.md +++ /dev/null @@ -1,186 +0,0 @@ -[#]: subject: "Write your first JavaScript code" -[#]: via: "https://opensource.com/article/21/7/javascript-cheat-sheet" -[#]: author: "Seth Kenlon https://opensource.com/users/seth" -[#]: collector: "lkxed" -[#]: translator: "lkxed" -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " - -Write your first JavaScript code -====== -JavaScript was created for the web, but it can do so much more. Learn the basics, then download our cheat sheet so you always have the details at hand. - -![open source programming][1] - -Image by: Opensource.com - -JavaScript is a programming language full of pleasant surprises. Many people first encounter JavaScript as a language for the web. There's a JavaScript engine in all the major browsers, there are popular frameworks such as JQuery, Cash, and Bootstrap to help make web design easier, and there are even programming environments written in JavaScript. It seems to be everywhere on the internet, but it turns out that it's also a useful language for projects like [Electron][2], an open source toolkit for building cross-platform desktop apps with JavaScript. - -JavaScript is a surprisingly multipurpose language with a wide assortment of libraries for much more than just making websites. Learning the basics of the language is easy, and it's a gateway to building whatever you imagine. - -### Install JavaScript - -As you progress with JavaScript, you may find yourself wanting advanced JavaScript libraries and runtimes. When you're just starting, though, you don't have to install JavaScript at all. All major web browsers include a JavaScript engine to run the code. You can write JavaScript using your favorite text editor, load it into your web browser, and see what your code does. - -### Get started with JavaScript - -To write your first JavaScript code, open your favorite text editor, such as [Notepad++][3], [Atom][4], or [VSCode][5]. Because it was developed for the web, JavaScript works well with HTML, so first, just try some basic HTML: - -``` - -  -    JS -  -  -   

Nothing here.

-  - -``` - -Save the file, and then open it in a web browser. - -![HTML displayed in browser][6] - -To add JavaScript to this simple HTML page, you can either create a JavaScript file and refer to it in the page's `head`  or just embed your JavaScript code in the HTML using the ` - -  - -``` - -Reload the page in your browser. - -![HTML with JavaScript displayed in browser][7] - -As you can see, the `

` tag as written still contains the string "Nothing here," but when it's rendered, JavaScript alters it so that it contains "Hello world" instead. Yes, JavaScript has the power to rebuild (or just help build) a webpage. - -The JavaScript in this simple script does two things. First, it creates a variable called `myvariable` and places the string "Hello world!" into it. Finally, it searches the current document (the web page as the browser is rendering it) for any HTML element with the ID `example`. When it locates `example`, it uses the `innerHTML` function to replace the contents of the HTML element with the contents of `myvariable`. - -Of course, using a custom variable isn't necessary. It's just as easy to populate the HTML element with something being dynamically created. For instance, you could populate it with a timestamp: - -``` - -  -    JS -  -  -   

Date and time appears here.

- -    -    -  - -``` - -Reload the page to see a timestamp generated at the moment the page is rendered. Reload a few times to watch the seconds increment. - -### JavaScript syntax - -In programming, **syntax** refers to the rules of how sentences (or "lines") are written. In JavaScript, each line of code must end in a semicolon (`;` ) so that the JavaScript engine running your code understands when to stop reading. - -Words (or "strings") must be enclosed in quotation marks (`"` ), while numbers (or "integers") go without. - -Almost everything else is a convention of the JavaScript language, such as variables, arrays, conditional statements, objects, functions, and so on. - -### Creating variables in JavaScript - -Variables are containers for data. You can think of a variable as a box where you can put data to share with your program. Creating a variable in JavaScript is done with two keywords you choose based on how you intend to use the variable: `let` and `var`. The `var` keyword denotes a variable intended for your entire program to use, while `let` creates variables for specific purposes, usually inside functions or loops. - -JavaScript's built-in `typeof` function can help you identify what kind of data a variable contains. Using the first example, you can find out what kind of data `myvariable` contains by modifying the displayed text to: - -``` - -let myvariable = "Hello world!"; -document.getElementById("example").innerHTML = typeof(myvariable); - -``` - -This renders "string" in your web browser because the variable contains "Hello world!" Storing different kinds of data (such as an integer) in `myvariable` would cause a different data type to be printed to your sample web page. Try changing the contents of `myvariable` to your favorite number and then reloading the page. - -### Creating functions in JavaScript - -Functions in programming are self-contained data processors. They're what makes programming *modular*. It's because functions exist that programmers can write generic libraries that, for instance, resize images or keep track of the passage of time for other programmers (like you) to use in their own code. - -You create a function by providing a custom name for your function followed by any amount of code enclosed within braces. - -Here's a simple web page featuring a resized image and a button that analyzes the image and returns the true image dimensions. In this example code, the ` -    -    -   
-      -   
-    -    -    -  - -``` - -Save the file and load it into your web browser to try the code. - -![Custom get_size function returns image dimensions][8] - -### Cross-platform apps with JavaScript - -You can see from the code sample how JavaScript and HTML work closely together to create a cohesive user experience. This is one of the great strengths of JavaScript. When you write code in JavaScript, you inherit one of the most common user interfaces of modern computing regardless of platform: the web browser. Your code is cross-platform by nature, so your application, whether it's just a humble image size analyzer or a complex image editor, video game, or whatever else you dream up, can be used by everyone with a web browser (or a desktop, if you deliver an Electron app). - -Learning JavaScript is easy and fun. There are lots of websites with tutorials available. There are also over a million JavaScript libraries to help you interface with devices, peripherals, the Internet of Things, servers, file systems, and lots more. And as you're learning, keep our [JavaScript cheat sheet][9] close by so you remember the fine details of syntax and structure. - -Image by: (Seth Kenlon, CC BY-SA 4.0) - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/21/7/javascript-cheat-sheet - -作者:[Seth Kenlon][a] -选题:[lkxed][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/lkxed -[1]: https://opensource.com/sites/default/files/lead-images/code2.png -[2]: https://www.electronjs.org/ -[3]: https://opensource.com/article/16/12/notepad-text-editor -[4]: https://opensource.com/article/20/12/atom -[5]: https://opensource.com/article/20/6/open-source-alternatives-vs-code -[6]: https://opensource.com/sites/default/files/pictures/plain-html.jpg -[7]: https://opensource.com/sites/default/files/uploads/html-javascript.jpg -[8]: https://opensource.com/sites/default/files/uploads/get-size.jpg -[9]: https://opensource.com/downloads/javascript-cheat-sheet diff --git a/translated/tech/20210722 Write your first JavaScript code.md b/translated/tech/20210722 Write your first JavaScript code.md new file mode 100644 index 0000000000..4d607cb6f1 --- /dev/null +++ b/translated/tech/20210722 Write your first JavaScript code.md @@ -0,0 +1,187 @@ +[#]: subject: "Write your first JavaScript code" +[#]: via: "https://opensource.com/article/21/7/javascript-cheat-sheet" +[#]: author: "Seth Kenlon https://opensource.com/users/seth" +[#]: collector: "lkxed" +[#]: translator: "lkxed" +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +编写你的第一段 JavaScript 代码 +====== +JavaScript 是为 Web 而生的,但它可以做的事远不止于此。本文将带领你了解它的基础知识,然后你可以下载我们的备忘清单,以便随时掌握详细信息。 + +![开源编程][1] + +图源:Opensource.com + +JavaScript 是一种充满惊喜的编程语言。许多人第一次遇到 JavaScript 时,它通常是作为一种 Web 语言出现的。所有主流浏览器都有一个 JavaScript 引擎;并且,还有一些流行的框架,如 JQuery、Cash 和 Bootstrap 等,它们可以帮助简化网页设计;甚至还有用 JavaScript 编写的编程环境。它似乎在互联网上无处不在,但事实证明,它对于 [Electron][2] 等项目来说也是一种有用的语言。Electron 是一个构建跨平台桌面应用程序的开源工具包,它使用的语言就是 JavaScript。 + +JavaScript 语言的用途多到令人惊讶,它拥有各种各样的库,而不仅仅是用于制作网站。它的基础知识十分容易掌握,因此,它可以一个起点,助你跨出构建你想象中的东西的第一步。 + +### 安装 JavaScript + +随着你的 JavaScript 水平不断提高,你可能会发现自己需要高级的 JavaScript 库和运行时。不过,刚开始学习的时候,你是根本不需要安装 JavaScript 的。因为所有主流的 Web 浏览器都包含一个 JavaScript 引擎来运行代码。你可以使用自己喜欢的文本编辑器编写 JavaScript,将其加载到 Web 浏览器中,接着你就能看到代码的作用。 + +### 上手 JavaScript + +要编写你的第一个 JavaScript 代码,请打开你喜欢的文本编辑器,例如 [Notepad++][3]、[Atom][4] 或 [VSCode][5] 等。因为它是为 Web 开发的,所以 JavaScript 可以很好地与 HTML 配合使用。因此,我们先来尝试一些基本的 HTML: + +``` + +  +    JS +  +  +   

Nothing here.

+  + +``` + +保存这个文件,然后在 Web 浏览器中打开它。 + +![浏览器中显示的 HTML][6] + +要将 JavaScript 添加到这个简单的 HTML 页面,你可以创建一个 JavaScript 文件并在页面的 `` 中引用它,或者只需使用 ` + +  + +``` + +在浏览器中重新加载页面。 + +![在浏览器中显示带有 JavaScript 的 HTML][7] + +如你所见,`

` 标签仍然包含字符串 “Nothing here”,但是当它被渲染时,JavaScript 会改变它,使其包含 “Hello world”。是的,JavaScript 具有重建​​(或只是帮助构建)网页的能力。 + +这个简单脚本中的 JavaScript 做了两件事。首先,它创建一个名为 `myvariable` 的变量,并将字符串 “Hello world!” 放置其中。然后,它会在当前文档(浏览器呈现的网页)中搜索 ID 为 “example” 的所有 HTML 元素。当它找到 `example` 时,它使用了 `innerHTML` 函数将 HTML 元素的内容替换为 `myvariable` 的内容。 + +当然,我们也可以不用自定义变量。因为,使用动态创建的内容来填充 HTML 元素也是容易的。例如,你可以使用当前时间戳来填充它: + +``` + +  +    JS +  +  +   

Date and time appears here.

+ +    +    +  + +``` + +重新加载页面,你就可以看到在呈现页面时生成的时间戳。再重新加载几次,你可以观察到秒数会不断增加。 + +### JavaScript 语法 + +在编程中,语法syntax 指的是如何编写句子(或“行”)的规则。在 JavaScript 中,每行代码必须以分号(`;`)结尾,以便运行代码的 JavaScript 引擎知道何时停止阅读。(LCTT 译注:从实用角度看,此处的“必须”其实是不正确的,大多数 JS 引擎都支持不加分号。Vue.js 的作者尤雨溪认为“没有应该不应该,只有你自己喜欢不喜欢”,他同时表示,“Vue.js 的代码全部不带分号”。详情可以查看他在知乎上对于此问题的 [回答][10]。) + +单词(或 “字符串”strings)必须用引号(`"`)括起来,而数字(或 “整数”integers)则不用。 + +几乎所有其他东西都是 JavaScript 语言的约定,例如变量、数组、条件语句、对象、函数等等。 + +### 在 JavaScript 中创建变量 + +变量是数据的容器。你可以将变量视为一个盒子,你在其中放置数据,以便与程序的其他部分共享它。要在 JavaScript 中创建变量,你可以选用关键字 `let` 和 `var` 中的一个,请根据你打算如何使用变量来选择:`var` 关键字用于创建一个供整个程序使用的变量,而 `let` 只为特定目的创建变量,通常在函数或循环的内部使用。(LCTT 译注:还有 `const` 关键字,它用于创建一个常量。) + +JavaScript 内置的 `typeof` 函数可以帮助你识别变量包含的数据的类型。使用第一个示例,你可以修改显示文本,来显示 `myvariable` 包含的数据的类型: + +``` + +let myvariable = "Hello world!"; +document.getElementById("example").innerHTML = typeof(myvariable); + +``` + +接着,你就会发现 Web 浏览器中显示出 “string” 字样,因为该变量包含的数据是 “Hello world!”。在 `myvariable` 中存储不同类型的数据(例如整数),浏览器就会把不同的数据类型打印到示例网页上。尝试将 `myvariable` 的内容更改为你喜欢的数字,然后重新加载页面。 + +### 在 JavaScript 中创建函数 + +编程中的函数是独立的数据处理器。正是它们使编程得以 *模块化*。因为函数的存在,程序员可以编写通用库,例如​​,调整图像大小或统计时间花费的库,以供其他和你一样的程序员在他们的代码中使用。 + +要创建一个函数,你可以为函数提供一个自定义名称,后面跟着用大括号括起来的、任意数量的代码。 + +下面是一个简单的网页,其中包含了一个剪裁过的图像,还有一个分析图像并返回真实图像尺寸的按钮。在这个示例代码中,` +    +    +   
+      +   
+    +    +    +  + +``` + +保存这个文件,并将其加载到 Web 浏览器中以尝试这段代码。 + +![自定义的 get_size 函数返回了图像尺寸][8] + +### 使用 JavaScript 的跨平台应用程序 + +您可以从代码示例中看到,JavaScript 和 HTML 紧密协作,从而创建了有凝聚力的用户体验。这是 JavaScript 的一大优势。当您使用 JavaScript 编写代码时,您继承了现代计算中最常见的用户界面之一,而它与平台无关,那就是 Web 浏览器。您的代码本质上是跨平台的,因此您的应用程序,无论是简单的图像大小分析器还是复杂的图像编辑器、视频游戏,或者您梦想的任何其他东西,都可以被所有人使用,无论是通过 Web 浏览器,还是桌面(如果你同时提供了一个 Electron 应用)。 + +学习 JavaScript 既简单又有趣。网络上有很多网站提供了相关教程,还有超过一百万个 JavaScript 库可帮助您与设备、外围设备、物联网、服务器、文件系统等进行交互。在您学习的过程中,请将我们的 [JavaScript 备忘单][9] 放在身边,以便记住语法和结构的细节。 + +正文配图源自:Seth Kenlon,CC BY-SA 4.0 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/7/javascript-cheat-sheet + +作者:[Seth Kenlon][a] +选题:[lkxed][b] +译者:[lkxed](https://github.com/lkxed) +校对:[校对者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/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/code2.png +[2]: https://www.electronjs.org/ +[3]: https://opensource.com/article/16/12/notepad-text-editor +[4]: https://opensource.com/article/20/12/atom +[5]: https://opensource.com/article/20/6/open-source-alternatives-vs-code +[6]: https://opensource.com/sites/default/files/pictures/plain-html.jpg +[7]: https://opensource.com/sites/default/files/uploads/html-javascript.jpg +[8]: https://opensource.com/sites/default/files/uploads/get-size.jpg +[9]: https://opensource.com/downloads/javascript-cheat-sheet +[10]: https://www.zhihu.com/question/20298345/answer/49551142 From f14f9ceae59d3827ea742037047180af697d23e9 Mon Sep 17 00:00:00 2001 From: lkxed Date: Mon, 13 Jun 2022 12:36:43 +0800 Subject: [PATCH 21/78] Update 20210722 Write your first JavaScript code.md --- translated/tech/20210722 Write your first JavaScript code.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translated/tech/20210722 Write your first JavaScript code.md b/translated/tech/20210722 Write your first JavaScript code.md index 4d607cb6f1..ea49e75a22 100644 --- a/translated/tech/20210722 Write your first JavaScript code.md +++ b/translated/tech/20210722 Write your first JavaScript code.md @@ -17,7 +17,7 @@ JavaScript 是为 Web 而生的,但它可以做的事远不止于此。本文 JavaScript 是一种充满惊喜的编程语言。许多人第一次遇到 JavaScript 时,它通常是作为一种 Web 语言出现的。所有主流浏览器都有一个 JavaScript 引擎;并且,还有一些流行的框架,如 JQuery、Cash 和 Bootstrap 等,它们可以帮助简化网页设计;甚至还有用 JavaScript 编写的编程环境。它似乎在互联网上无处不在,但事实证明,它对于 [Electron][2] 等项目来说也是一种有用的语言。Electron 是一个构建跨平台桌面应用程序的开源工具包,它使用的语言就是 JavaScript。 -JavaScript 语言的用途多到令人惊讶,它拥有各种各样的库,而不仅仅是用于制作网站。它的基础知识十分容易掌握,因此,它可以一个起点,助你跨出构建你想象中的东西的第一步。 +JavaScript 语言的用途多到令人惊讶,它拥有各种各样的库,而不仅仅是用于制作网站。它的基础知识十分容易掌握,因此,它可以作为一个起点,助你跨出构建你想象中的东西的第一步。 ### 安装 JavaScript From 6fdf7f091c27fb342cf784c6a90a77931d1aca07 Mon Sep 17 00:00:00 2001 From: lkxed Date: Mon, 13 Jun 2022 12:37:52 +0800 Subject: [PATCH 22/78] Update 20210722 Write your first JavaScript code.md --- translated/tech/20210722 Write your first JavaScript code.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translated/tech/20210722 Write your first JavaScript code.md b/translated/tech/20210722 Write your first JavaScript code.md index ea49e75a22..ef08bc948a 100644 --- a/translated/tech/20210722 Write your first JavaScript code.md +++ b/translated/tech/20210722 Write your first JavaScript code.md @@ -42,7 +42,7 @@ JavaScript 语言的用途多到令人惊讶,它拥有各种各样的库,而 ![浏览器中显示的 HTML][6] -要将 JavaScript 添加到这个简单的 HTML 页面,你可以创建一个 JavaScript 文件并在页面的 `` 中引用它,或者只需使用 `