diff --git a/translated/tech/20200925 5 questions to ask yourself when writing project documentation.md b/published/20200925 5 questions to ask yourself when writing project documentation.md similarity index 61% rename from translated/tech/20200925 5 questions to ask yourself when writing project documentation.md rename to published/20200925 5 questions to ask yourself when writing project documentation.md index bbf3b907cc..3b59da6ca5 100644 --- a/translated/tech/20200925 5 questions to ask yourself when writing project documentation.md +++ b/published/20200925 5 questions to ask yourself when writing project documentation.md @@ -1,52 +1,52 @@ [#]: collector: (lujun9972) [#]: translator: (geekpi) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12691-1.html) [#]: subject: (5 questions to ask yourself when writing project documentation) [#]: via: (https://opensource.com/article/20/9/project-documentation) [#]: author: (Alexei Leontief https://opensource.com/users/alexeileontief) -编写项目文档时要问自己 5 个问题 +编写项目文档时要问自己的 5 个问题 ====== -使用一些有效沟通的基本原则可以帮助你创建与你的品牌一致的,编写良好,内容丰富的项目文档。 -![A person writing.][1] -在开始另一个开源项目文档的实际写作部分之前,甚至在采访专家之前,最好回答一些有关新文档的高级问题。 +> 使用有效沟通的一些基本原则可以帮助你创建与你的品牌一致的、编写良好、内容丰富的项目文档。 -著名的传播理论家 Harold Lasswell 在他 1948 年的文章《社会中的传播结构和功能》(_The Structure and Function of Communication in Society_)中写道: + -> (一个)描述沟通行为的方便方法是回答以下问题: +在开始实际撰写又一个开源项目的文档之前,甚至在采访专家之前,最好回答一些有关新文档的高级问题。 + +著名的传播理论家 Harold Lasswell 在他 1948 年的文章《社会中的传播结构和功能》中写道: + +> (一种)描述沟通行为的方便方法是回答以下问题: > > * 谁 > * 说什么 > * 在哪个渠道 > * 对谁 > * 有什么效果? -> +作为一名技术交流者,你可以运用 Lasswell 的理论,回答关于你文档的类似问题,以更好地传达你的信息,达到预期的效果。 -作为一名技术沟通者,你可以运用 Lasswell 的理论,回答关于你文档的类似问题,以更好地传达你的信息,达到预期的效果。 +### 谁:谁是文档的所有者? -### 谁—谁是文档的所有者? +或者说,文档背后是什么公司?它想向受众传达什么品牌形象?这个问题的答案将极大地影响你的写作风格。公司可能有自己的风格指南,或者至少有正式的使命声明,在这种情况下,你应该从这开始。 -或者说,文档背后是什么公司?它想向受众传达什么品牌形象?这个问题的答案将大大影响你的写作风格。公司也可能有自己的风格指南,或者至少有正式的使命声明,在这种情况下,你应该从这开始。 +如果公司刚刚起步,你可以向文件的主人提出上述问题。作为作者,将你为公司创造的声音和角色与你自己的世界观和信念结合起来是很重要的。这将使你的写作看起来更自然,而不像公司的行话。 -如果公司刚刚起步,你可以向文件的主人提出上述问题。作为作者,将你为公司创造的声音和角色与你自己的世界观和信仰结合起来是很重要的。这将使你的写作看起来更自然,而不像公司的行话。 +### 说什么:文件类型是什么? -### 说什么—文件类型是什么? +你需要传达什么信息?它是什么类型的文档:用户指南、API 参考、发布说明等?许多文档类型有模板或普遍认可的结构,这些结构为你提供一个开始的地方,并帮助确保包括所有必要的信息。 -你需要传达什么信息?它是什么类型的文档:用户指南、API 参考、发布说明等?许多文档类型将有模板或普遍认可的结构,它将让你从这开始,并帮助确保包括所有必要的信息。 - -### 在哪个渠道—文档的格式是什么? +### 在哪个渠道:文档的格式是什么? 对于技术文档,沟通的渠道通常会告诉你文档的最终格式,也就是 PDF、HTML、文本文件等。这很可能也决定了你应该使用什么工具来编写你的文档。 -### 对谁—目标受众是谁? +### 对谁:目标受众是谁? -谁会阅读这份文档?他们的知识水平如何?他们的工作职责和主要挑战是什么?这些问题将帮助你确定你应该覆盖什么,是否应该进入细节,是否可以使用任何特定的术语,等等。在某些情况下,这些问题的答案甚至可以影响你使用的语法的复杂性。 +谁会阅读这份文档?他们的知识水平如何?他们的工作职责和主要挑战是什么?这些问题将帮助你确定你应该覆盖什么内容,是否应该应该涉及细节,是否可以使用特定的术语,等等。在某些情况下,这些问题的答案甚至可以影响你使用的语法的复杂性。 -### 有什么效果-文档的目的是什么? +### 有什么效果:文档的目的是什么? 在这里,你应该定义这个文档要为它的潜在读者解决什么问题,或者它应该为他们回答什么问题。例如,你的文档的目的可以是教你的客户如何使用你的产品。 @@ -56,7 +56,7 @@ ### 总结 -上面的问题旨在帮助你形成有效沟通的基础,并确保你的文件涵盖了所有应该涵盖的内容。你可以把它们分解成你自己的问题清单,并把它们放在身边,以便在你有文件要创建的时候使用。当你面对空白页时,这份清单也可能会派上用场。希望它能激发你的灵感,帮助你产生想法。 +上面的问题旨在帮助你形成有效沟通的基础,并确保你的文件涵盖了所有应该涵盖的内容。你可以把它们分解成你自己的问题清单,并把它们放在身边,以便在你有文件要创建的时候使用。当你面对空白页无从着笔时,这份清单也可能会派上用场。希望它能激发你的灵感,帮助你产生想法。 -------------------------------------------------------------------------------- @@ -65,7 +65,7 @@ via: https://opensource.com/article/20/9/project-documentation 作者:[Alexei Leontief][a] 选题:[lujun9972][b] 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/sources/tech/20201006 5 Scratch code blocks to teach kids how to program a video game.md b/sources/tech/20201006 5 Scratch code blocks to teach kids how to program a video game.md new file mode 100644 index 0000000000..e8c825d5e7 --- /dev/null +++ b/sources/tech/20201006 5 Scratch code blocks to teach kids how to program a video game.md @@ -0,0 +1,165 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (5 Scratch code blocks to teach kids how to program a video game) +[#]: via: (https://opensource.com/article/20/10/advanced-scratch) +[#]: author: (Jess Weichler https://opensource.com/users/cyanide-cupcake) + +5 Scratch code blocks to teach kids how to program a video game +====== +Advance your Scratch skills with loops, conditional statements, +collision detection, and more in this article in a series about teaching +kids to code. +![Binary code on a computer screen][1] + +In the second article in this series, you [created your first few video game scripts in Scratch][2]. This article explores ways to expand programming's possibilities to create more advanced code. + +There are multiple ways to introduce these skills to kids, such as: + + 1. Introduce a task or challenge that requires children to use the skill. Use inquiry to help them find the solution, then reinforce their discoveries with a formal explanation. + 2. Encourage free experimentation by having children come up with their own projects. As they work through their code, go over skills as needed. + 3. Introduce the skill, then have children experiment with it. + + + +No matter which one you choose, always remember that the most important part of learning coding is making mistakes. Even skilled programmers don't get it right every time or know every possible line of code. It works best when educators, pupils, and peers are all learning to code together as a team. + +There are [10 categories][3] of code blocks in Scratch; here is how to use some of the most common. + +### Loops + +_This is the code that doesn't end; yes, it goes on and on, my friend!_ **Forever loops** and **repeat blocks** in [Scratch][4] are what you need to repeat lines of code automatically. Any code blocks placed inside a loop block continue to run until the game is stopped or, if you're using a repeat block, the number is reached. + +![Loops in Scratch][5] + +(Jess Weichler, [CC BY-SA 4.0][6]) + +### Conditional statements + +**Conditional statements** run only if certain conditions are met. "If you're cold, then put on a sweater" is a real-world example of a conditional statement: you put a sweater on only if you determine that it's cold. + +There are four conditional statement code blocks in Scratch: + + * if ... then + * if ... then ... else + * wait until... + * repeat until... + + + +Any code blocks placed inside a conditional statement run only if the condition is met. + +![Conditional statement blocks in Scratch][7] + +(Jess Weichler, [CC BY-SA 4.0][6]) + +Notice the diamond shapes in each conditional statement code block; can you find any code blocks that might fit inside? + +Diamond-shaped code blocks can be used to complete any of the four conditional-statement blocks. You can find diamond-shaped blocks in the [Sensing][8] and [Operators][9] block categories. + +![Diamond-shaped blocks in Scratch][10] + +(Jess Weichler, [CC BY-SA 4.0][6]) + +### Collision-detection loop + +Sometimes you may want to check to see if your sprite is touching another sprite or a specific color. To do so, use a [**collision-detection loop**][11]. + +A collision-detection loop combines loops and conditional statements to constantly check whether the sprite is touching another sprite (for example, a coin sprite). + +![Collision-detection script in Scratch][12] + +(Jess Weichler, [CC BY-SA 4.0][6]) + +Inside the inner `if ... then` block, place the action you want to happen when the condition is met. + +This type of algorithm is a **collision-detection script**. Collision-detection scripts sense when two sprites or objects are touching. A basic collision-detection script uses four main code blocks: + + * Event hat + * Forever loop + * If … then + * Touching + + + +You can place more code blocks inside the `if ... then` block. These blocks will run only if the active sprite is touching the sprite listed in the `touching` block. + +Can you figure out how to make an object "hide" when it collides with another sprite? This is a common technique to indicate that, for instance, a sprite has eaten some food or has picked up an item. + +### Variables and math + +A **variable** is a placeholder for a value, usually a number, that you don't know yet. In math, using a variable might look something like this: `x+12=15`. + +![Variables in Scratch][13] + +(Jess Weichler, [CC BY-SA 4.0][6]) + +If that doesn't make sense to you, that's okay. I didn't understand variables until I started coding as an adult. + +Here is one example of how you might use a variable in code: + +![Variables in Scratch][14] + +(Jess Weichler, [CC BY-SA 4.0][6]) + +### Coordinates + +Scratch uses a coordinate graph to measure the screen. The exact middle of the screen has a value of 0,0. The length of the screen (X-axis) is -240 to 240, the height (Y-axis) is -180 to 180. + +The X and Y **coordinates** control where each sprite is on the screen, and you can code a sprite's X and Y coordinates to set a specific place using **[motion blocks][15]**. + +![Coordinates in Scratch][16] + +(Jess Weichler, [CC BY-SA 4.0][6]) + +### Put it all together + +Think about the basics of any game; what are some elements you usually need? + +Here are some examples: + + * A goal + * A way to win + * A way to lose + * An obstacle + * A scoring system + + + +With the techniques above, you have everything you need to create a playable game with these elements and more. + +There are still heaps of code blocks in Scratch that I haven't mentioned. Keep exploring the possibilities. If you don't know what a code block does, put it in a script to see what happens! + +Coming up with an idea for a game can be difficult. The great thing about the open source community, Scratchers included, is that we love to build upon one another's work. With that in mind, in the next article, I'll look at some of my favorite user-made projects for inspiration. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/10/advanced-scratch + +作者:[Jess Weichler][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/cyanide-cupcake +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/binary_code_computer_screen.png?itok=7IzHK1nn (Binary code on a computer screen) +[2]: https://opensource.com/article/20/9/scratch +[3]: https://en.scratch-wiki.info/wiki/Categories +[4]: https://scratch.mit.edu/ +[5]: https://opensource.com/sites/default/files/uploads/codekids3_1.png (Loops in Scratch) +[6]: https://creativecommons.org/licenses/by-sa/4.0/ +[7]: https://opensource.com/sites/default/files/uploads/codekids3_2.png (Conditional statement blocks in Scratch) +[8]: https://en.scratch-wiki.info/wiki/Blocks#Sensing_blocks +[9]: https://en.scratch-wiki.info/wiki/Blocks#Operators_blocks +[10]: https://opensource.com/sites/default/files/uploads/codekids3_3.png (Diamond-shaped blocks in Scratch) +[11]: https://en.scratch-wiki.info/wiki/Making_Sprites_Detect_and_Sense_Other_Sprites +[12]: https://opensource.com/sites/default/files/uploads/codekids3_4.png (Collision-detection script in Scratch) +[13]: https://opensource.com/sites/default/files/uploads/codekids3_5.png (Variables in Scratch) +[14]: https://opensource.com/sites/default/files/uploads/codekids3_6.png (Variables in Scratch) +[15]: https://en.scratch-wiki.info/wiki/Motion_Blocks +[16]: https://opensource.com/sites/default/files/uploads/codekids3_7.png (Coordinates in Scratch) diff --git a/sources/tech/20201006 Simplify your web experience with this internet protocol alternative.md b/sources/tech/20201006 Simplify your web experience with this internet protocol alternative.md new file mode 100644 index 0000000000..6955aa001e --- /dev/null +++ b/sources/tech/20201006 Simplify your web experience with this internet protocol alternative.md @@ -0,0 +1,102 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Simplify your web experience with this internet protocol alternative) +[#]: via: (https://opensource.com/article/20/10/gemini-internet-protocol) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +Simplify your web experience with this internet protocol alternative +====== +Discover new corners of a quieter and simpler internet with the Gemini +Protocol. +![Person typing on a 1980's computer][1] + +If you've been on the internet for a very long time or you're just very resourceful, you might remember an early text-sharing protocol called [Gopher][2]. Gopher was eventually displaced by the HTTP protocol, which of course is the basis for the modern World Wide Web. For many people, the "internet" and the "World Wide Web" are the same thing, because many people don't consciously do anything online that's _not_ on the www subdomain. + +But there have always been a variety of network protocols to share information over an interconnected network: Telnet, FTP, SSH, Torrent, GNUnet, and many more. Recently, there's been an addition to this collection of alternatives, and it's called [Gemini][3]. + +The Gemini protocol, named after the space mission between the rudimentary experiments of Project Mercury and Project Apollo, is meant to sit peacefully between Gopher and HTTP. It doesn't aim to replace the modern web, by any means, but it does try to create both a simplified web and a modernized Gopher. + +This development, young though it may be, is significant for many reasons. People take issue with the modern web, of course, for reasons spanning the technical and the philosophical, but it's also just plain bloated. A million hits from a Google search can feel like overkill when all you really want is one reliable answer to a very specific question. + +Many people use Gopher for this very reason: it's small enough to allow for niche interests that are easy to find. However, Gopher is an old protocol that makes assumptions about programming, networking, and browsing that just aren't applicable anymore. Gemini aims to bring the best of the web to a format that approximates Gopher but is easy to program for. A simple Gemini browser can be written in a few hundred lines of code, and there's a very good one written in about 1,600 lines. That's a powerful feature for programmers, students, and minimalists alike. + +### How to browse Gemini + +Like the early web, Gemini is small enough that there is a list of known servers running Gemini sites. Just as browsing an HTTP site requires a web browser, accessing a Gemini site requires a Gemini browser. There are already several available, listed on the [Gemini website][4]. + +The simplest one to run is the [AV-98][5] client. It's written in Python and runs in a terminal. To try it out, download it: + + +``` +`$ git clone https://tildegit.org/solderpunk/AV-98.git` +``` + +Change directory into the downloaded directory and run AV-98: + + +``` +$ cd AV-98.git +$ python3 ./main.py +``` + +The client is an interactive prompt. It has limited commands, and the main one is simply `go` followed by a Gemini server address. Go to the list of known [Gemini servers][6], select one that seems interesting, and try visiting it: + + +``` +AV-98> go gemini://example.club + +Welcome to the example.club Gemini server! + +Here are some folders of ASCII art: + +[1] Penguins +[2] Wildebeests +[3] Demons +``` + +Navigation is a matter of following numbered links. For instance, to navigate to the Penguins directory, enter `1` and press Enter: + + +``` +AV-98> 1 + +[1] Gentoo +[2] Emperor +[3] Little Blue +``` + +To go back, type `back` and press Enter: + + +``` +`AV-98> back` +``` + +For more commands, just enter `help`. + +### Gemini as your web alternative + +The Gemini protocol is simple enough for beginner-level and intermediate programmers to write clients for, and it's an easy and quick way to share content on the internet. While the World Wide Web's ubiquity is advantageous for widespread distribution, there's always room for alternatives. Check out Gemini and discover new corners of a quieter and simpler internet. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/10/gemini-internet-protocol + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/1980s-computer-yearbook.png?itok=eGOYEKK- (Person typing on a 1980's computer) +[2]: https://en.wikipedia.org/wiki/Gopher_%28protocol%29 +[3]: https://gemini.circumlunar.space/ +[4]: https://gemini.circumlunar.space/clients.html +[5]: https://tildegit.org/solderpunk/AV-98 +[6]: https://portal.mozz.us/gemini/gemini.circumlunar.space/servers diff --git a/sources/tech/20201006 Start using virtual tables in Apache Cassandra 4.0.md b/sources/tech/20201006 Start using virtual tables in Apache Cassandra 4.0.md new file mode 100644 index 0000000000..5cd6aa97fa --- /dev/null +++ b/sources/tech/20201006 Start using virtual tables in Apache Cassandra 4.0.md @@ -0,0 +1,63 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Start using virtual tables in Apache Cassandra 4.0) +[#]: via: (https://opensource.com/article/20/10/virtual-tables-apache-cassandra) +[#]: author: (Ben Bromhead https://opensource.com/users/ben-bromhead) + +Start using virtual tables in Apache Cassandra 4.0 +====== +What they are and how to use them. +![Computer laptop in space][1] + +Among the [many additions][2] in the recent [Apache Cassandra 4.0 beta release][3], virtual tables is one that deserves some attention. + +In previous versions of Cassandra, users needed access to Java Management Extensions ([JMX][4]) to examine Cassandra details such as running compactions, clients, metrics, and a variety of configuration settings. Virtual tables removes these challenges. Cassandra 4.0 beta enables users to query those details and data as Cassandra Query Language (CQL) rows from a read-only system table. + +Here is how the JMX-based mechanism in previous Cassandra versions worked. Imagine a user wants to check on the compaction status of a particular node in a cluster. The user first has to establish a JMX connection to run `nodetool compactionstats` on the node. This requirement immediately presents the user with a few complications. Is the user's client configured for JMX access? Are the Cassandra nodes and firewall configured to allow JMX access? Are the proper measures for security and auditing prepared and in place? These are only some of the concerns users had to contend with when dealing with in previous versions of Cassandra. + +With Cassandra 4.0, virtual tables make it possible for users to query the information they need by utilizing their previously configured driver. This change removes all overhead associated with implementing and maintaining JMX access. + +Cassandra 4.0 creates two new keyspaces to help users leverage virtual tables: `system_views` and `system_virtual_schema`. The `system_views` keyspace contains all the valuable information that users seek, usefully stored in a number of tables. The `system_virtual_schema` keyspace, as the name implies, stores all necessary schema information for those virtual tables. + +![system_views and system_virtual_schema keyspaces and tables][5] + +(Ben Bromhead, [CC BY-SA 4.0][6]) + +It's important to understand that the scope of each virtual table is restricted to its node. Any query of virtual tables will return data that is valid only for the node that acts as its coordinator, regardless of consistency. To simplify for this requirement, support has been added to several drivers to specify the coordinator node in these queries (the Python, DataStax Java, and other drivers now offer this support). + +To illustrate, examine this `sstable_tasks` virtual table. This virtual table displays all operations on [SSTables][7], including compactions, cleanups, upgrades, and more. + +![Querying the sstable_tasks virtual table][8] + +(Ben Bromhead, [CC BY-SA 4.0][6]) + +If a user were to run `nodetool compactionstats` in a previous Cassandra version, this is the same type of information that would be displayed. Here, the query finds that the node currently has one active compaction. It also displays its progress and its keyspace and table. Thanks to the virtual table, a user can gather this information quickly, and just as efficiently gain the insight needed to correctly diagnose the cluster's health. + +To be clear, Cassandra 4.0 doesn't eliminate the need for JMX access: JMX is still the only option for querying some metrics. That said, users will welcome the ability to pull key cluster metrics simply by using CQL. Thanks to the convenience afforded by virtual tables, users may be able to reinvest time and resources previously devoted to JMX tools into Cassandra itself. Client-side tooling should also begin to leverage the advantages offered by virtual tables. + +If you are interested in the Cassandra 4.0 beta release and its virtual tables feature, [try it out][3]. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/10/virtual-tables-apache-cassandra + +作者:[Ben Bromhead][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/ben-bromhead +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_space_graphic_cosmic.png?itok=wu493YbB (Computer laptop in space) +[2]: https://www.instaclustr.com/apache-cassandra-4-0-beta-released/ +[3]: https://cassandra.apache.org/download/ +[4]: https://en.wikipedia.org/wiki/Java_Management_Extensions +[5]: https://opensource.com/sites/default/files/uploads/cassandra_virtual-tables.png (system_views and system_virtual_schema keyspaces and tables) +[6]: https://creativecommons.org/licenses/by-sa/4.0/ +[7]: https://cassandra.apache.org/doc/latest/architecture/storage_engine.html#sstables +[8]: https://opensource.com/sites/default/files/uploads/cassandra_virtual-tables_sstable_tasks.png (Querying the sstable_tasks virtual table) diff --git a/sources/tech/20201007 How to Clear Apt Cache and Reclaim Precious Disk Space.md b/sources/tech/20201007 How to Clear Apt Cache and Reclaim Precious Disk Space.md new file mode 100644 index 0000000000..83a0b2aafd --- /dev/null +++ b/sources/tech/20201007 How to Clear Apt Cache and Reclaim Precious Disk Space.md @@ -0,0 +1,123 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to Clear Apt Cache and Reclaim Precious Disk Space) +[#]: via: (https://itsfoss.com/clear-apt-cache/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +How to Clear Apt Cache and Reclaim Precious Disk Space +====== + +How do you clear the apt cache? You simply use this [apt-get command][1] option: + +``` +sudo apt-get clean +``` + +But there is more to cleaning apt cache than just running the above command. + +In this tutorial, I’ll explain what is apt cache, why is it used, why you would want to clean it and what other things you should know about purging apt cache. + +I am going to use Ubuntu here for reference but since this is about apt, it is applicable to [Debian][2] and other Debian and Ubuntu-based distributions like Linux Mint, Deepin and more. + +### What is apt cache? Why is it used? + +When you install a package using apt-get or [apt command][3] (or DEB packages in the software center), the apt [package manager][4] downloads the package and its dependencies in .deb format and keeps it in /var/cache/apt/archives folder. + +![][5] + +While downloading, apt keeps the deb package in /var/cache/apt/archives/partial directory. When the deb package is downloaded completely, it is moved out to /var/cache/apt/archives directory. + +Once the deb files for the package and its dependencies are downloaded, your system [installs the package from these deb files][6]. + +Now you see the use of cache? The system needs a place to keep the package files somewhere before installing them. If you are aware of the [Linux directory structure][7], you would understand that /var/cache is the appropriate here. + +#### Why keep the cache after installing the package? + +The downloaded deb files are not removed from the directory immediately after the installation is completed. If you remove a package and reinstall it, your system will look for the package in the cache and get it from here instead of downloading it again (as long as the package version in the cache is the same as the version in remote repository). + +This is much quicker. You can try this on your own and see how long a program takes to install the first time, remove it and install it again. You can [use the time command to find out how long does it take to complete a command][8]: _**time sudo apt install package_name**_. + +I couldn’t find anything concrete on the cache retention policy so I cannot say how long does Ubuntu keep the downloaded packages in the cache. + +#### Should you clean apt cache? + +It depends on you. If you are running out of disk space on root, you could clean apt cache and reclaim the disk space. It is one of the [several ways to free up disk space on Ubuntu][9]. + +Check how much space the cache takes with the [du command][10]: + +![][11] + +Sometime this could go in 100s of MB and this space could be crucial if you are running a server. + +#### How to clean apt cache? + +If you want to clear the apt cache, there is a dedicated command to do that. So don’t go about manually deleting the cache directory. Simply use this command: + +``` +sudo apt-get clean +``` + +This will remove the content of the /var/cache/apt/archives directory (except the lock file). Here’s a dry run (simulation) of what the apt-get clean command deletes: + +![][12] + +There is another command that deals with cleaning the apt cache: + +``` +sudo apt-get autoclean +``` + +Unlike clean, autoclean only removes the packages that are not possible to download from the repositories. + +Suppose you installed package xyz. Its deb files remain in the cache. If there is now a new version of xyz package available in the repository, this existing xyz package in the cache is now outdated and useless. The autoclean option will delete such useless packages that cannot be downloaded anymore. + +#### Is it safe to delete apt cache? + +![][13] + +Yes. It is completely safe to clear the cache created by apt. It won’t negatively impact the performance of the system. Maybe if you reinstall the package it will take a bit longer to download but that’s about it. + +Again, use the apt-get clean command. It is quicker and easier than manually deleting cache directory. + +You may also use graphical tools like [Stacer][14] or [Bleachbit][15] for this purpose. + +#### Conclusion + +At the time of writing this article, there is no built-in option with the newer apt command. However, keeping backward compatibility, _**apt clean**_ can still be run (which should be running apt-get clean underneath it). Please refer to this article to [know the difference between apt and apt-get][16]. + +I hope you find this explanation about apt cache interesting. It is not something essential but knowing this little things make you more knowledgeable about your Linux system. + +I welcome your feedback and suggestions in the comment section. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/clear-apt-cache/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/apt-get-linux-guide/ +[2]: https://www.debian.org/ +[3]: https://itsfoss.com/apt-command-guide/ +[4]: https://itsfoss.com/package-manager/ +[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/10/apt-get-clean-cache.png?resize=800%2C470&ssl=1 +[6]: https://itsfoss.com/install-deb-files-ubuntu/ +[7]: https://linuxhandbook.com/linux-directory-structure/ +[8]: https://linuxhandbook.com/time-command/ +[9]: https://itsfoss.com/free-up-space-ubuntu-linux/ +[10]: https://linuxhandbook.com/find-directory-size-du-command/ +[11]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/10/apt-cache-archive-size.png?resize=800%2C233&ssl=1 +[12]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/10/apt-get-clean-ubuntu.png?resize=800%2C339&ssl=1 +[13]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/10/Clear-Apt-Cache.png?resize=800%2C450&ssl=1 +[14]: https://itsfoss.com/optimize-ubuntu-stacer/ +[15]: https://itsfoss.com/use-bleachbit-ubuntu/ +[16]: https://itsfoss.com/apt-vs-apt-get-difference/ diff --git a/sources/tech/20180720 Building a Messenger App- Conversation Page.md b/translated/tech/20180720 Building a Messenger App- Conversation Page.md similarity index 66% rename from sources/tech/20180720 Building a Messenger App- Conversation Page.md rename to translated/tech/20180720 Building a Messenger App- Conversation Page.md index 811dd3c60e..b249c2dcfb 100644 --- a/sources/tech/20180720 Building a Messenger App- Conversation Page.md +++ b/translated/tech/20180720 Building a Messenger App- Conversation Page.md @@ -7,31 +7,31 @@ [#]: via: (https://nicolasparada.netlify.com/posts/go-messenger-conversation-page/) [#]: author: (Nicolás Parada https://nicolasparada.netlify.com/) -Building a Messenger App: Conversation Page +构建一个即时消息应用(九):Conversation 页面 ====== -This post is the 9th and last in a series: +本文是该系列的第九篇,也是最后一篇。 - * [Part 1: Schema][1] - * [Part 2: OAuth][2] - * [Part 3: Conversations][3] - * [Part 4: Messages][4] - * [Part 5: Realtime Messages][5] - * [Part 6: Development Login][6] - * [Part 7: Access Page][7] - * [Part 8: Home Page][8] + * [第一篇: 模式][1] + * [第二篇: OAuth][2] + * [第三篇: 对话][3] + * [第四篇: 消息][4] + * [第五篇: 实时消息][5] + * [第六篇: 仅用于开发的登录][6] + * [第七篇: Access 页面][7] + * [第八篇: Home 页面][8] -In this post we’ll code the conversation page. This page is the chat between the two users. At the top we’ll show info about the other participant, below, a list of the latest messages and a message form at the bottom. +在这篇文章中,我们将对对话页面进行编码。此页面是两个用户之间的聊天室。在顶部我们将显示其他参与者的信息,下面接着的是最新消息列表,以及底部的消息表单。 -### Chat heading +### 聊天标题 ![chat heading screenshot][9] -Let’s start by creating the file `static/pages/conversation-page.js` with the following content: +让我们从创建 `static/pages/conversation-page.js` 文件开始,它包含以下内容: -``` +```js import http from '../http.js' import { navigate } from '../router.js' import { avatar, escapeHTML } from '../shared.js' @@ -65,17 +65,17 @@ function getConversation(id) { } ``` -This page receives the conversation ID the router extracted from the URL. +此页面接收路由从 URL 中提取的会话 ID。 -First it does a GET request to `/api/conversations/{conversationID}` to get info about the conversation. In case of error, we show it and redirect back to `/`. Then we render info about the other participant. +首先,它向 `/api/ conversations/{conversationID}` 发起一个 GET 请求,以获取有关对话的信息。 如果出现错误,我们会将其显示,并重定向回 `/`。然后我们呈现有关其他参与者的信息。 -### Conversation List +### 对话列表 ![chat heading screenshot][10] -We’ll fetch the latest messages too to display them. +我们也会获取最新的消息并显示它们。 -``` +```js let conversation, messages try { [conversation, messages] = await Promise.all([ @@ -85,32 +85,32 @@ try { } ``` -Update the `conversationPage()` function to fetch the messages too. We use `Promise.all()` to do both request at the same time. +更新 `conversationPage()` 函数以获取消息。我们使用 `Promise.all()` 同时执行这两个请求。 -``` +```js function getMessages(conversationID) { return http.get(`/api/conversations/${conversationID}/messages`) } ``` -A GET request to `/api/conversations/{conversationID}/messages` gets the latest messages of the conversation. +发起对 `/api/conversations/{conversationID}/messages` 的 GET 请求可以获取对话中的最新消息。 -``` +```html