mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-03-27 02:30:10 +08:00
Merge remote-tracking branch 'LCTT/master'
This commit is contained in:
commit
265056e812
published
20180705 Building a Messenger App- Schema.md20190916 How to start developing with .NET.md20190923 Introduction to the Linux chgrp and newgrp commands.md
sources
talk
20181218 The Rise and Demise of RSS.md20190924 Java still relevant, Linux desktop, and more industry trends.md
tech
translated/tech
20190812 Cloud-native Java, open source security, and more industry trends.md20190909 How to use Terminator on Linux to run multiple terminals in one window.md20190912 An introduction to Markdown.md20190916 How to start developing with .NET.md20190923 Getting started with data science using Python.md20190923 Introduction to the Linux chgrp and newgrp commands.md
@ -1,15 +1,18 @@
|
||||
[#]: collector: "lujun9972"
|
||||
[#]: translator: "PsiACE"
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
[#]: reviewer: "wxy"
|
||||
[#]: publisher: "wxy"
|
||||
[#]: url: "https://linux.cn/article-11396-1.html"
|
||||
[#]: subject: "Building a Messenger App: Schema"
|
||||
[#]: via: "https://nicolasparada.netlify.com/posts/go-messenger-schema/"
|
||||
[#]: author: "Nicolás Parada https://nicolasparada.netlify.com/"
|
||||
|
||||
# 构建一个即时消息应用:模式
|
||||
构建一个即时消息应用(一):模式
|
||||
========
|
||||
|
||||
这是一系列关于构建「即时消息」应用的新帖子。你应该对这类应用并不陌生。有了它们的帮助,我们才可以与朋友畅聊无忌。[Facebook Messenger][1], [WhatsApp][2] 和 [Skype][3] 就是其中的几个例子。正如你所看到的那样,这些应用允许我们发送图片、传输视频、录制音频、以及和一大帮子人聊天等等。当然,我们的教程应用将会尽量保持简单,只在两个用户之间发送文本消息。
|
||||

|
||||
|
||||
这是一系列关于构建“即时消息”应用的新帖子。你应该对这类应用并不陌生。有了它们的帮助,我们才可以与朋友畅聊无忌。[Facebook Messenger][1]、[WhatsApp][2] 和 [Skype][3] 就是其中的几个例子。正如你所看到的那样,这些应用允许我们发送图片、传输视频、录制音频、以及和一大帮子人聊天等等。当然,我们的教程应用将会尽量保持简单,只在两个用户之间发送文本消息。
|
||||
|
||||
我们将会用 [CockroachDB][4] 作为 SQL 数据库,用 [Go][5] 作为后端语言,并且用 JavaScript 来制作 web 应用。
|
||||
|
||||
@ -49,7 +52,7 @@ CREATE TABLE participants (
|
||||
|
||||
尽管之前我提到过对话只会在两个用户之间进行,但我们还是采用了允许向对话中添加多个参与者的设计。因此,在对话和用户之间有一个参与者表。
|
||||
|
||||
为了知道用户是否有未读消息,我们在消息表中添加了「读取时间」`messages_read_at` 字段。每当用户在对话中读取消息时,我们都会更新它的值,这样一来,我们就可以将它与对话中最后一条消息的「创建时间」`created_at` 字段进行比较。
|
||||
为了知道用户是否有未读消息,我们在消息表中添加了“读取时间”(`messages_read_at`)字段。每当用户在对话中读取消息时,我们都会更新它的值,这样一来,我们就可以将它与对话中最后一条消息的“创建时间”(`created_at`)字段进行比较。
|
||||
|
||||
```
|
||||
CREATE TABLE messages (
|
||||
@ -62,7 +65,7 @@ CREATE TABLE messages (
|
||||
);
|
||||
```
|
||||
|
||||
尽管我们将消息表放在最后,但它在应用中相当重要。我们用它来保存对创建它的用户以及它所出现的对话的引用。而且还可以根据「创建时间」`created_at` 来创建索引以完成对消息的排序。
|
||||
尽管我们将消息表放在最后,但它在应用中相当重要。我们用它来保存对创建它的用户以及它所出现的对话的引用。而且还可以根据“创建时间”(`created_at`)来创建索引以完成对消息的排序。
|
||||
|
||||
```
|
||||
ALTER TABLE conversations
|
||||
@ -87,11 +90,9 @@ cockroach sql --insecure -e "CREATE DATABASE messenger"
|
||||
cat schema.sql | cockroach sql --insecure -d messenger
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
这篇帖子就到这里。在接下来的部分中,我们将会介绍「登录」,敬请期待。
|
||||
|
||||
[Souce Code][7]
|
||||
- [源代码][7]
|
||||
|
||||
---
|
||||
|
||||
@ -100,7 +101,7 @@ via: https://nicolasparada.netlify.com/posts/go-messenger-schema/
|
||||
作者:[Nicolás Parada][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[PsiACE](https://github.com/PsiACE)
|
||||
校对:[校对者 ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux 中国](https://linux.cn/) 荣誉推出
|
||||
|
160
published/20190916 How to start developing with .NET.md
Normal file
160
published/20190916 How to start developing with .NET.md
Normal file
@ -0,0 +1,160 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-11397-1.html)
|
||||
[#]: subject: (How to start developing with .NET)
|
||||
[#]: via: (https://opensource.com/article/19/9/getting-started-net)
|
||||
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
|
||||
|
||||
如何在 Linux/Windows/MacOS 上使用 .NET 进行开发
|
||||
======
|
||||
|
||||
> 了解 .NET 开发平台启动和运行的基础知识。
|
||||
|
||||

|
||||
|
||||
.NET 框架由 Microsoft 于 2000 年发布。该平台的开源实现 [Mono][2] 在 21 世纪初成为了争议的焦点,因为微软拥有 .NET 技术的多项专利,并且可能使用这些专利来终止 Mono 项目。幸运的是,在 2014 年,微软宣布 .NET 开发平台从此成为 MIT 许可下的开源平台,并在 2016 年收购了开发 Mono 的 Xamarin 公司。
|
||||
|
||||
.NET 和 Mono 已经同时可用于 C#、F#、GTK+、Visual Basic、Vala 等的跨平台编程环境。使用 .NET 和 Mono 创建的程序已经应用于 Linux、BSD、Windows、MacOS、Android,甚至一些游戏机。你可以使用 .NET 或 Mono 来开发 .NET 应用。这两个都是开源的,并且都有活跃和充满活力的社区。本文重点介绍微软的 .NET 环境。
|
||||
|
||||
### 如何安装 .NET
|
||||
|
||||
.NET 下载被分为多个包:一个仅包含 .NET 运行时,另一个 .NET SDK 包含了 .NET Core 和运行时。根据架构和操作系统版本,这些包可能有多个版本。要开始使用 .NET 进行开发,你必须[安装该 SDK][3]。它为你提供了 [dotnet][4] 终端或 PowerShell 命令,你可以使用它们来创建和生成项目。
|
||||
|
||||
#### Linux
|
||||
|
||||
要在 Linux 上安装 .NET,首先将微软 Linux 软件仓库添加到你的计算机。
|
||||
|
||||
在 Fedora 上:
|
||||
|
||||
```
|
||||
$ sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
|
||||
$ sudo wget -q -O /etc/yum.repos.d/microsoft-prod.repo https://packages.microsoft.com/config/fedora/27/prod.repo
|
||||
```
|
||||
|
||||
在 Ubuntu 上:
|
||||
|
||||
```
|
||||
$ wget -q https://packages.microsoft.com/config/ubuntu/19.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
|
||||
$ sudo dpkg -i packages-microsoft-prod.deb
|
||||
```
|
||||
|
||||
接下来,使用包管理器安装 SDK,将 `<X.Y>` 替换为当前版本的 .NET 版本:
|
||||
|
||||
在 Fedora 上:
|
||||
|
||||
```
|
||||
$ sudo dnf install dotnet-sdk-<X.Y>
|
||||
```
|
||||
|
||||
在 Ubuntu 上:
|
||||
|
||||
```
|
||||
$ sudo apt install apt-transport-https
|
||||
$ sudo apt update
|
||||
$ sudo apt install dotnet-sdk-<X.Y>
|
||||
```
|
||||
|
||||
下载并安装所有包后,打开终端并输入下面命令确认安装:
|
||||
|
||||
```
|
||||
$ dotnet --version
|
||||
X.Y.Z
|
||||
```
|
||||
|
||||
#### Windows
|
||||
|
||||
如果你使用的是微软 Windows,那么你可能已经安装了 .NET 运行时。但是,要开发 .NET 应用,你还必须安装 .NET Core SDK。
|
||||
|
||||
首先,[下载安装程序][3]。请认准下载 .NET Core 进行跨平台开发(.NET Framework 仅适用于 Windows)。下载 .exe 文件后,双击该文件启动安装向导,然后单击两下进行安装:接受许可证并允许安装继续。
|
||||
|
||||
![Installing dotnet on Windows][5]
|
||||
|
||||
然后,从左下角的“应用程序”菜单中打开 PowerShell。在 PowerShell 中,输入测试命令:
|
||||
|
||||
```
|
||||
PS C:\Users\osdc> dotnet
|
||||
```
|
||||
|
||||
如果你看到有关 dotnet 安装的信息,那么说明 .NET 已正确安装。
|
||||
|
||||
#### MacOS
|
||||
|
||||
如果你使用的是 Apple Mac,请下载 .pkg 形式的 [Mac 安装程序][3]。下载并双击该 .pkg 文件,然后单击安装程序。你可能需要授予安装程序权限,因为该软件包并非来自 App Store。
|
||||
|
||||
下载并安装所有软件包后,请打开终端并输入以下命令来确认安装:
|
||||
|
||||
```
|
||||
$ dotnet --version
|
||||
X.Y.Z
|
||||
```
|
||||
|
||||
### Hello .NET
|
||||
|
||||
`dotnet` 命令提供了一个用 .NET 编写的 “hello world” 示例程序。或者,更准确地说,该命令提供了示例应用。
|
||||
|
||||
首先,使用 `dotnet` 命令以及 `new` 和 `console` 参数创建一个控制台应用的项目目录及所需的代码基础结构。使用 `-o` 选项指定项目名称:
|
||||
|
||||
```
|
||||
$ dotnet new console -o hellodotnet
|
||||
```
|
||||
|
||||
这将在当前目录中创建一个名为 `hellodotnet` 的目录。进入你的项目目录并看一下:
|
||||
|
||||
```
|
||||
$ cd hellodotnet
|
||||
$ dir
|
||||
hellodotnet.csproj obj Program.cs
|
||||
```
|
||||
|
||||
`Program.cs` 是一个空的 C# 文件,它包含了一个简单的 Hello World 程序。在文本编辑器中打开查看它。微软的 Visual Studio Code 是一个使用 dotnet 编写的跨平台的开源应用,虽然它不是一个糟糕的文本编辑器,但它会收集用户的大量数据(在它的二进制发行版的许可证中授予了自己权限)。如果要尝试使用 Visual Studio Code,请考虑使用 [VSCodium][6],它是使用 Visual Studio Code 的 MIT 许可的源码构建的版本,而*没有*远程收集(请阅读[此文档][7]来禁止此构建中的其他形式追踪)。或者,只需使用现有的你最喜欢的文本编辑器或 IDE。
|
||||
|
||||
新控制台应用中的样板代码为:
|
||||
|
||||
```
|
||||
using System;
|
||||
|
||||
namespace hellodotnet
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Hello World!");
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
要运行该程序,请使用 `dotnet run` 命令:
|
||||
|
||||
```
|
||||
$ dotnet run
|
||||
Hello World!
|
||||
```
|
||||
|
||||
这是 .NET 和 `dotnet` 命令的基本工作流程。这里有完整的 [.NET C# 指南][8],并且都是与 .NET 相关的内容。关于 .NET 实战示例,请关注 [Alex Bunardzic][9] 在 opensource.com 中的变异测试文章。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/9/getting-started-net
|
||||
|
||||
作者:[Seth Kenlon][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/seth
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_laptop_hack_work.png?itok=aSpcWkcl (Coding on a computer)
|
||||
[2]: https://www.monodevelop.com/
|
||||
[3]: https://dotnet.microsoft.com/download
|
||||
[4]: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet?tabs=netcore21
|
||||
[5]: https://opensource.com/sites/default/files/uploads/dotnet-windows-install.jpg (Installing dotnet on Windows)
|
||||
[6]: https://vscodium.com/
|
||||
[7]: https://github.com/VSCodium/vscodium/blob/master/DOCS.md
|
||||
[8]: https://docs.microsoft.com/en-us/dotnet/csharp/tutorials/intro-to-csharp/
|
||||
[9]: https://opensource.com/users/alex-bunardzic (View user profile.)
|
@ -0,0 +1,131 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-11399-1.html)
|
||||
[#]: subject: (Introduction to the Linux chgrp and newgrp commands)
|
||||
[#]: via: (https://opensource.com/article/19/9/linux-chgrp-and-newgrp-commands)
|
||||
[#]: author: (Alan Formy-Duval https://opensource.com/users/alanfdoss)
|
||||
|
||||
chgrp 和 newgrp 命令简介
|
||||
======
|
||||
|
||||
> chgrp 和 newgrp 命令可帮助你管理需要维护组所有权的文件。
|
||||
|
||||

|
||||
|
||||
在最近的一篇文章中,我介绍了 [chown][2] 命令,它用于修改系统上的文件所有权。回想一下,所有权是分配给一个对象的用户和组的组合。`chgrp` 和 `newgrp` 命令为管理需要维护组所有权的文件提供了帮助。
|
||||
|
||||
### 使用 chgrp
|
||||
|
||||
`chgrp` 只是更改文件的组所有权。这与 `chown :<group>` 命令相同。你可以使用:
|
||||
|
||||
```
|
||||
$chown :alan mynotes
|
||||
```
|
||||
|
||||
或者:
|
||||
|
||||
```
|
||||
$chgrp alan mynotes
|
||||
```
|
||||
|
||||
#### 递归
|
||||
|
||||
`chgrp` 和它的一些参数可以用在命令行和脚本中。就像许多其他 Linux 命令一样,`chgrp` 有一个递归参数 `-R`。如下所示,你需要它来对文件夹及其内容进行递归操作。我加了 `-v`(详细)参数,因此 `chgrp` 会告诉我它在做什么:
|
||||
|
||||
|
||||
```
|
||||
$ ls -l . conf
|
||||
.:
|
||||
drwxrwxr-x 2 alan alan 4096 Aug 5 15:33 conf
|
||||
|
||||
conf:
|
||||
-rw-rw-r-- 1 alan alan 0 Aug 5 15:33 conf.xml
|
||||
# chgrp -vR delta conf
|
||||
changed group of 'conf/conf.xml' from alan to delta
|
||||
changed group of 'conf' from alan to delta
|
||||
```
|
||||
|
||||
#### 参考
|
||||
|
||||
当你要更改文件的组以匹配特定的配置,或者当你不知道具体的组时(比如你运行一个脚本时),可使用参考文件 (`--reference=RFILE`)。你可以复制另外一个作为参考的文件(RFILE)的组。比如,为了撤销上面的更改 (请注意,点 `.` 代表当前工作目录):
|
||||
|
||||
```
|
||||
$ chgrp -vR --reference=. conf
|
||||
```
|
||||
|
||||
#### 报告更改
|
||||
|
||||
大多数命令都有用于控制其输出的参数。最常见的是 `-v` 来启用详细信息,而且 `chgrp` 命令也拥有详细模式。它还具有 `-c`(`--changes`)参数,指示 `chgrp` 仅在进行了更改时报告。`chgrp` 还会报告其他内容,例如是操作不被允许时。
|
||||
|
||||
参数 `-f`(`--silent`、`--quiet`)用于禁止显示大部分错误消息。我将在下一节中使用此参数和 `-c` 来显示实际更改。
|
||||
|
||||
#### 保持根目录
|
||||
|
||||
Linux 文件系统的根目录(`/`)应该受到高度重视。如果命令在此层级犯了一个错误,那么后果可能是可怕的,并会让系统无法使用。尤其是在运行一个会递归修改甚至删除的命令时。`chgrp` 命令有一个可用于保护和保持根目录的参数。它是 `--preserve-root`。如果在根目录中将此参数和递归一起使用,那么什么也不会发生,而是会出现一条消息:
|
||||
|
||||
```
|
||||
[root@localhost /]# chgrp -cfR --preserve-root a+w /
|
||||
chgrp: it is dangerous to operate recursively on '/'
|
||||
chgrp: use --no-preserve-root to override this failsafe
|
||||
```
|
||||
|
||||
不与递归(-R)结合使用时,该选项无效。但是,如果该命令由 `root` 用户运行,那么 `/` 的权限将会更改,但其下的其他文件或目录的权限则不会被更改:
|
||||
|
||||
```
|
||||
[alan@localhost /]$ chgrp -c --preserve-root alan /
|
||||
chgrp: changing group of '/': Operation not permitted
|
||||
[root@localhost /]# chgrp -c --preserve-root alan /
|
||||
changed group of '/' from root to alan
|
||||
```
|
||||
|
||||
令人惊讶的是,它似乎不是默认参数。而选项 `--no-preserve-root` 是默认的。如果你在不带“保持”选项的情况下运行上述命令,那么它将默认为“无保持”模式,并可能会更改不应更改的文件的权限:
|
||||
|
||||
```
|
||||
[alan@localhost /]$ chgrp -cfR alan /
|
||||
changed group of '/dev/pts/0' from tty to alan
|
||||
changed group of '/dev/tty2' from tty to alan
|
||||
changed group of '/var/spool/mail/alan' from mail to alan
|
||||
```
|
||||
|
||||
### 关于 newgrp
|
||||
|
||||
`newgrp` 命令允许用户覆盖当前的主要组。当你在所有文件必须有相同的组所有权的目录中操作时,`newgrp` 会很方便。假设你的内网服务器上有一个名为 `share` 的目录,不同的团队在其中存储市场活动照片。组名为 `share`。当不同的用户将文件放入目录时,文件的主要组可能会变得混乱。每当添加新文件时,你都可以运行 `chgrp` 将错乱的组纠正为 `share`:
|
||||
|
||||
```
|
||||
$ cd share
|
||||
ls -l
|
||||
-rw-r--r--. 1 alan share 0 Aug 7 15:35 pic13
|
||||
-rw-r--r--. 1 alan alan 0 Aug 7 15:35 pic1
|
||||
-rw-r--r--. 1 susan delta 0 Aug 7 15:35 pic2
|
||||
-rw-r--r--. 1 james gamma 0 Aug 7 15:35 pic3
|
||||
-rw-rw-r--. 1 bill contract 0 Aug 7 15:36 pic4
|
||||
```
|
||||
|
||||
我在 [chmod 命令][3]的文章中介绍了 `setgid` 模式。它是解决此问题的一种方法。但是,假设由于某种原因未设置 `setgid` 位。`newgrp` 命令在此时很有用。在任何用户将文件放入 `share` 目录之前,他们可以运行命令 `newgrp share`。这会将其主要组切换为 `share`,因此他们放入目录中的所有文件都将有 `share` 组,而不是用户自己的主要组。完成后,用户可以使用以下命令切换回常规主要组(举例):
|
||||
|
||||
```
|
||||
newgrp alan
|
||||
```
|
||||
|
||||
### 总结
|
||||
|
||||
了解如何管理用户、组和权限非常重要。最好知道一些替代方法来解决可能遇到的问题,因为并非所有环境都以相同的方式设置。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/9/linux-chgrp-and-newgrp-commands
|
||||
|
||||
作者:[Alan Formy-Duval][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/alanfdosshttps://opensource.com/users/sethhttps://opensource.com/users/alanfdosshttps://opensource.com/users/seth
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/community-penguins-osdc-lead.png?itok=BmqsAF4A (Penguins walking on the beach )
|
||||
[2]: https://opensource.com/article/19/8/linux-chown-command
|
||||
[3]: https://opensource.com/article/19/8/linux-chmod-command
|
@ -1,5 +1,5 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (beamrolling)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
@ -1,5 +1,5 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: translator: (laingke)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
@ -50,7 +50,7 @@ via: https://opensource.com/article/19/9/java-relevant-and-more-industry-trends
|
||||
|
||||
作者:[Tim Hildred][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
译者:[laingke](https://github.com/laingke)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
@ -1,88 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (laingke)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Cloud-native Java, open source security, and more industry trends)
|
||||
[#]: via: (https://opensource.com/article/19/8/cloud-native-java-and-more)
|
||||
[#]: author: (Tim Hildred https://opensource.com/users/thildred)
|
||||
|
||||
Cloud-native Java, open source security, and more industry trends
|
||||
======
|
||||
A weekly look at open source community and industry trends.
|
||||
![Person standing in front of a giant computer screen with numbers, data][1]
|
||||
|
||||
As part of my role as a senior product marketing manager at an enterprise software company with an open source development model, I publish a regular update about open source community, market, and industry trends for product marketers, managers, and other influencers. Here are five of my and their favorite articles from that update.
|
||||
|
||||
## [Why is modern web development so complicated?][2]
|
||||
|
||||
> Modern frontend web development is a polarizing experience: many love it, others despise it.
|
||||
>
|
||||
> I am a huge fan of modern web development, though I would describe it as "magical"—and magic has its upsides and downsides... Recently I’ve been needing to explain “modern web development workflows” to folks who only have a cursory of vanilla web development workflows and… It is a LOT to explain! Even a hasty explanation ends up being pretty long. So in the effort of writing more of my explanations down, here is the beginning of a long yet hasty explanation of the evolution of web development..
|
||||
|
||||
**The impact:** Specific enough to be useful to (especially new) frontend developers, but simple and well explained enough to help non-developers understand better some of the frontend developer problems. By the end, you'll (kinda) know the difference between Javascript and WebAPIs and how 2019 Javascript is different than 2006 Javascript.
|
||||
|
||||
## [Open sourcing the Kubernetes security audit][3]
|
||||
|
||||
> Last year, the Cloud Native Computing Foundation (CNCF) began the process of performing and open sourcing third-party security audits for its projects in order to improve the overall security of our ecosystem. The idea was to start with a handful of projects and gather feedback from the CNCF community as to whether or not this pilot program was useful. The first projects to undergo this process were [CoreDNS][4], [Envoy][5] and [Prometheus][6]. These first public audits identified security issues from general weaknesses to critical vulnerabilities. With these results, project maintainers for CoreDNS, Envoy and Prometheus have been able to address the identified vulnerabilities and add documentation to help users.
|
||||
>
|
||||
> The main takeaway from these initial audits is that a public security audit is a great way to test the quality of an open source project along with its vulnerability management process and more importantly, how resilient the open source project’s security practices are. With CNCF [graduated projects][7] especially, which are used widely in production by some of the largest companies in the world, it is imperative that they adhere to the highest levels of security best practices.
|
||||
|
||||
**The impact:** A lot of companies are placing big bets on Kubernetes being to the cloud what Linux is to that data center. Seeing 4 of those companies working together to make sure the project is doing what it should be from a security perspective inspires confidence. Sharing that research shows that open source is so much more than code in a repository; it is the capturing and sharing of expert opinions in a way that benefits the community at large rather than the interests of a few.
|
||||
|
||||
## [Quarkus—what's next for the lightweight Java framework?][8]
|
||||
|
||||
> What does “container first” mean? What are the strengths of Quarkus? What’s new in 0.20.0? What features can we look forward to in the future? When will version 1.0.0 be released? We have so many questions about Quarkus and Alex Soto was kind enough to answer them all. _With the release of Quarkus 0.20.0, we decided to get in touch with [JAX London speaker][9], Java Champion, and Director of Developer Experience at Red Hat – Alex Soto. He was kind enough to answer all our questions about the past, present, and future of Quarkus. It seems like we have a lot to look forward to with this exciting lightweight framework!_
|
||||
|
||||
**The impact**: Someone clever recently told me that Quarkus has the potential to make Java "possibly one of the best languages for containers and serverless environments". That made me do a double-take; while Java is one of the most popular programming languages ([if not the most popular][10]) it probably isn't the first one that jumps to mind when you hear the words "cloud native." Quarkus could extend and grow the value of the skills held by a huge chunk of the developer workforce by allowing them to apply their experience to new challenges.
|
||||
|
||||
## [Julia programming language: Users reveal what they love and hate the most about it][11]
|
||||
|
||||
> The most popular technical feature of Julia is speed and performance followed by ease of use, while the most popular non-technical feature is that users don't have to pay to use it.
|
||||
>
|
||||
> Users also report their biggest gripes with the language. The top one is that packages for add-on features aren't sufficiently mature or well maintained to meet their needs.
|
||||
|
||||
**The impact:** The Julia 1.0 release has been out for a year now, and has seen impressive growth in a bunch of relevant metrics (downloads, GitHub stars, etc). It is a language aimed squarely at some of our biggest current and future challenges ("scientific computing, machine learning, data mining, large-scale linear algebra, distributed and parallel computing") so finding out how it's users are feeling about it gives an indirect read on how well those challenges are being addressed.
|
||||
|
||||
## [Multi-cloud by the numbers: 11 interesting stats][12]
|
||||
|
||||
> If you boil our recent dive into [interesting stats about Kubernetes][13] down to its bottom line, it looks something like this: [Kubernetes'][14] popularity will continue for the foreseeable future.
|
||||
>
|
||||
> Spoiler alert: When you dig up recent numbers about [multi-cloud][15] usage, they tell a similar story: Adoption is soaring.
|
||||
>
|
||||
> This congruity makes sense. Perhaps not every organization will use Kubernetes to manage its multi-cloud and/or [hybrid cloud][16] infrastructure, but the two increasingly go hand-in-hand. Even when they don’t, they both reflect a general shift toward more distributed and heterogeneous IT environments, as well as [cloud-native development][17] and other overlapping trends.
|
||||
|
||||
**The impact**: Another explanation of increasing adoption of "multi-cloud strategies" is they retroactively legitimize decisions taken in separate parts of an organization without consultation as "strategic." "Wait, so you bought hours from who? And you bought hours from the other one? Why wasn't that in the meeting minutes? I guess we're a multi-cloud company now!" Of course I'm joking, I'm sure most big companies are a lot better coordinated than that, right?
|
||||
|
||||
_I hope you enjoyed this list of what stood out to me from last week and come back next Monday for more open source community, market, and industry trends._
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/8/cloud-native-java-and-more
|
||||
|
||||
作者:[Tim Hildred][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[laingke](https://github.com/laingke)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/thildred
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr (Person standing in front of a giant computer screen with numbers, data)
|
||||
[2]: https://www.vrk.dev/2019/07/11/why-is-modern-web-development-so-complicated-a-long-yet-hasty-explanation-part-1/
|
||||
[3]: https://www.cncf.io/blog/2019/08/06/open-sourcing-the-kubernetes-security-audit/
|
||||
[4]: https://coredns.io/2018/03/15/cure53-security-assessment/
|
||||
[5]: https://github.com/envoyproxy/envoy/blob/master/docs/SECURITY_AUDIT.pdf
|
||||
[6]: https://cure53.de/pentest-report_prometheus.pdf
|
||||
[7]: https://www.cncf.io/projects/
|
||||
[8]: https://jaxenter.com/quarkus-whats-next-for-the-lightweight-java-framework-160793.html
|
||||
[9]: https://jaxlondon.com/cloud-kubernetes-serverless/java-particle-acceleration-using-quarkus/
|
||||
[10]: https://opensource.com/article/19/8/possibly%20one%20of%20the%20best%20languages%20for%20containers%20and%20serverless%20environments.
|
||||
[11]: https://www.zdnet.com/article/julia-programming-language-users-reveal-what-they-love-and-hate-the-most-about-it/#ftag=RSSbaffb68
|
||||
[12]: https://enterprisersproject.com/article/2019/8/multi-cloud-statistics
|
||||
[13]: https://enterprisersproject.com/article/2019/7/kubernetes-statistics-13-compelling
|
||||
[14]: https://www.redhat.com/en/topics/containers/what-is-kubernetes?intcmp=701f2000000tjyaAAA
|
||||
[15]: https://www.redhat.com/en/topics/cloud-computing/what-is-multicloud?intcmp=701f2000000tjyaAAA
|
||||
[16]: https://enterprisersproject.com/hybrid-cloud
|
||||
[17]: https://enterprisersproject.com/article/2018/10/how-explain-cloud-native-apps-plain-english
|
@ -1,118 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How to use Terminator on Linux to run multiple terminals in one window)
|
||||
[#]: via: (https://www.networkworld.com/article/3436784/how-to-use-terminator-on-linux-to-run-multiple-terminals-in-one-window.html)
|
||||
[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/)
|
||||
|
||||
How to use Terminator on Linux to run multiple terminals in one window
|
||||
======
|
||||
Providing an option for multiple GNOME terminals within a single window frame, Terminator lets you flexibly align your workspace to suit your needs.
|
||||
Sandra Henry-Stocker
|
||||
|
||||
If you’ve ever wished that you could line up multiple terminal windows and organize them in a single window frame, we may have some good news for you. The Linux **Terminator** can do this for you. No problemo!
|
||||
|
||||
### Splitting windows
|
||||
|
||||
Terminator will initially open like a terminal window with a single window. Once you mouse click within that window, however, it will bring up an options menu that gives you the flexibility to make changes. You can choose “**split horizontally**” or “**split vertically**” to split the window you are currently position in into two smaller windows. In fact, with these menu choices, complete with tiny illustrations of the resultant split (resembling **=** and **||**), you can split windows repeatedly if you like. Of course, if you split the overall window into more than six or nine sections, you might just find that they're too small to be used effectively.
|
||||
|
||||
**[ Two-Minute Linux Tips: [Learn how to master a host of Linux commands in these 2-minute video tutorials][1] ]**
|
||||
|
||||
Using ASCII art to illustrate the process of splitting windows, you might see something like this:
|
||||
|
||||
```
|
||||
+-------------------+ +-------------------+ +-------------------+
|
||||
| | | | | |
|
||||
| | | | | |
|
||||
| | ==> |-------------------| ==> |-------------------|
|
||||
| | | | | | |
|
||||
| | | | | | |
|
||||
+-------------------+ +-------------------+ +-------------------+
|
||||
Original terminal Split horizontally Split vertically
|
||||
```
|
||||
|
||||
Another option for splitting windows is to use control sequences like **Ctrl+Shift+e** to split a window vertically and **Ctrl+Shift+o** (“o" as in “open”) to split the screen horizontally.
|
||||
|
||||
Once Terminator has split into smaller windows for you, you can click in any window to use it and move from window to window as your work dictates.
|
||||
|
||||
### Maximizing a window
|
||||
|
||||
If you want to ignore all but one of your windows for a while and focus on just one, you can click in that window and select the "**Maximize**" option from the menu. That window will then grow to claim all of the space. Click again and select "**Restore all terminals**" to return to the multi-window display. **Ctrl+Shift+x** will toggle between the normal and maximized settings.
|
||||
|
||||
The window size indicators (e.g., 80x15) on window labels display the number of characters per line and the number of lines per window that each window provides.
|
||||
|
||||
### Closing windows
|
||||
|
||||
To close any window, bring up the Terminator menu and select **Close**. Other windows will adjust themselves to take up the space until you close the last remaining window.
|
||||
|
||||
### Saving your customized setup(s)
|
||||
|
||||
Setting up your customized terminator settings as your default once you've split your overall window into multiple segments is quite easy. Select **Preferences** from the pop-up menu and then **Layouts** from the tab along the top of the window that opens. You should then see **New Layout** listed. Just click on the **Save** option at the bottom and **Close** on the bottom right. Terminator will save your settings in **~/.config/terminator/config** and will then use this file every time you use it.
|
||||
|
||||
You can also enlarge your overall window by stretching it with your mouse. Again, if you want to retain the changes, select **Preferences** from the menu, **Layouts** and then **Save** and **Close** again.
|
||||
|
||||
### Choosing between saved configurations
|
||||
|
||||
If you like, you can set up multiple options for your Terminator window arrangements by maintaining a number of config files, renaming each afterwards (e.g., config-1, config-2) and then moving your choice into place as **~/.config/terminator/config** when you want to use that layout. Here's an example script for doing something like this script. It lets you choose between three pre-configured window arrangements:
|
||||
|
||||
```
|
||||
#!/bin/bash
|
||||
|
||||
PS3='Terminator options: '
|
||||
options=("Split 1" "Split 2" "Split 3" "Quit")
|
||||
select opt in "${options[@]}"
|
||||
do
|
||||
case $opt in
|
||||
"Split 1")
|
||||
config=config-1
|
||||
break
|
||||
;;
|
||||
"Split 2")
|
||||
config=config-2
|
||||
break
|
||||
;;
|
||||
"Split 3")
|
||||
config=config-3
|
||||
break
|
||||
;;
|
||||
*)
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
cd ~/.config/terminator
|
||||
cp config config-
|
||||
cp $config config
|
||||
cd
|
||||
terminator &
|
||||
```
|
||||
|
||||
You could give the options more meaningful names than "config-1" if that helps.
|
||||
|
||||
### Wrap-up
|
||||
|
||||
Terminator is a good choice for setting up multiple windows to work on related tasks. If you've never used it, you'll probably need to install it first with a command such as "sudo apt install terminator" or "sudo yum install -y terminator".
|
||||
|
||||
Hopefully, you will enjoy using Terminator. And, as another character of the same name might say, "I'll be back!"
|
||||
|
||||
Join the Network World communities on [Facebook][2] and [LinkedIn][3] to comment on topics that are top of mind.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.networkworld.com/article/3436784/how-to-use-terminator-on-linux-to-run-multiple-terminals-in-one-window.html
|
||||
|
||||
作者:[Sandra Henry-Stocker][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://www.youtube.com/playlist?list=PL7D2RMSmRO9J8OTpjFECi8DJiTQdd4hua
|
||||
[2]: https://www.facebook.com/NetworkWorld/
|
||||
[3]: https://www.linkedin.com/company/network-world
|
@ -1,332 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (GraveAccent)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Getting started with data science using Python)
|
||||
[#]: via: (https://opensource.com/article/19/9/get-started-data-science-python)
|
||||
[#]: author: (Seth Kenlon https://opensource.com/users/sethhttps://opensource.com/users/jroakeshttps://opensource.com/users/tiwarinitish86)
|
||||
|
||||
Getting started with data science using Python
|
||||
======
|
||||
Doing data science with Python offers limitless potential for you to
|
||||
parse, interpret, and structure data in meaningful and enlightening
|
||||
ways.
|
||||
![Metrics and a graph illustration][1]
|
||||
|
||||
Data science is an exciting new field in computing that's built around analyzing, visualizing, correlating, and interpreting the boundless amounts of information our computers are collecting about the world. Of course, calling it a "new" field is a little disingenuous because the discipline is a derivative of statistics, data analysis, and plain old obsessive scientific observation.
|
||||
|
||||
But data science is a formalized branch of these disciplines, with processes and tools all its own, and it can be broadly applied across disciplines (such as visual effects) that had never produced big dumps of unmanageable data before. Data science is a new opportunity to take a fresh look at data from oceanography, meteorology, geography, cartography, biology, medicine and health, and entertainment industries and gain a better understanding of patterns, influences, and causality.
|
||||
|
||||
Like other big and seemingly all-inclusive fields, it can be intimidating to know where to start exploring data science. There are a lot of resources out there to help data scientists use their favorite programming languages to accomplish their goals, and that includes one of the most popular programming languages out there: Python. Using the [Pandas][2], [Matplotlib][3], and [Seaborn][4] libraries, you can learn the basic toolset of data science.
|
||||
|
||||
If you're not familiar with the basics of Python yet, read my [introduction to Python][5] before continuing.
|
||||
|
||||
### Creating a Python virtual environment
|
||||
|
||||
Programmers sometimes forget which libraries they have installed on their development machine, and this can lead them to ship code that worked on their computer but fails on all others for lack of a library. Python has a system designed to avoid this manner of unpleasant surprise: the virtual environment. A virtual environment intentionally ignores all the Python libraries you have installed, effectively forcing you to begin development with nothing more than stock Python.
|
||||
|
||||
To activate a virtual environment with **venv**, invent a name for your environment (I'll use **example**) and create it with:
|
||||
|
||||
|
||||
```
|
||||
`$ python3 -m venv example`
|
||||
```
|
||||
|
||||
Source the **activate** file in the environment's **bin** directory to activate it:
|
||||
|
||||
|
||||
```
|
||||
$ source ./example/bin/activate
|
||||
(example) $
|
||||
```
|
||||
|
||||
You are now "in" your virtual environment, a clean slate where you can build custom solutions to problems—with the added burden of consciously needing to install required libraries.
|
||||
|
||||
### Installing Pandas and NumPy
|
||||
|
||||
The first libraries you must install in your new environment are Pandas and NumPy. These libraries are common in data science, so this won't be the last time you'll install them. They're also not the only libraries you'll ever need in data science, but they're a good start.
|
||||
|
||||
Pandas is an open source, BSD-licensed library that makes it easy to process data structures for analysis. It depends on NumPy, a scientific library that provides multi-dimensional arrays, linear algebra, Fourier transforms, and much more. Install both using **pip3**:
|
||||
|
||||
|
||||
```
|
||||
`(example) $ pip3 install pandas`
|
||||
```
|
||||
|
||||
Installing Pandas also installs NumPy, so you don't need to specify both. Once you have installed them to your virtual environment once, the installation packages are cached so that when you install them again, you don't have to download them from the internet.
|
||||
|
||||
Those are the only libraries you need for now. Next, you need some sample data.
|
||||
|
||||
### Generating a sample dataset
|
||||
|
||||
Data science is all about data, and luckily there are lots of free and open datasets available from scientific, computing, and government organizations. While these datasets are a great resource for education, they have a lot more data than necessary for this simple example. You can create a sample and manageable dataset quickly with Python:
|
||||
|
||||
|
||||
```
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import random
|
||||
|
||||
def rgb():
|
||||
NUMBER=random.randint(0,255)/255
|
||||
return NUMBER
|
||||
|
||||
FILE = open('sample.csv','w')
|
||||
FILE.write('"red","green","blue"')
|
||||
for COUNT in range(10):
|
||||
FILE.write('\n{:0.2f},{:0.2f},{:0.2f}'.format(rgb(),rgb(),rgb()))
|
||||
```
|
||||
|
||||
This produces a file called **sample.csv**, consisting of randomly generated floats representing, in this example, RGB values (a commonly tracked value, among hundreds, in visual effects). You can use a CSV file as a data source for Pandas.
|
||||
|
||||
### Ingesting data with Pandas
|
||||
|
||||
One of Pandas' basic features is its ability to ingest data and process it without the programmer writing new functions just to parse input. If you're used to applications that do that automatically, this might not seem like it's very special—but imagine opening a CSV in [LibreOffice][6] and having to write formulas to split the values at each comma. Pandas shields you from low-level operations like that. Here's some simple code to ingest and print out a file of comma-separated values:
|
||||
|
||||
|
||||
```
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from pandas import read_csv, DataFrame
|
||||
import pandas as pd
|
||||
|
||||
FILE = open('sample.csv','r')
|
||||
DATAFRAME = pd.read_csv(FILE)
|
||||
print(DATAFRAME)
|
||||
```
|
||||
|
||||
The first few lines import components of the Pandas library. The Pandas library is extensive, so you'll refer to its documentation frequently when looking for functions beyond the basic ones in this article.
|
||||
|
||||
Next, a variable **f** is created by opening the **sample.csv** file you created. That variable is used by the Pandas module **read_csv** (imported in the second line) to create a _dataframe_. In Pandas, a dataframe is a two-dimensional array, commonly thought of as a table. Once your data is in a dataframe, you can manipulate it by column and row, query it for ranges, and do a lot more. The sample code, for now, just prints the dataframe to the terminal.
|
||||
|
||||
Run the code. Your output will differ slightly from this sample output because the numbers are randomly generated, but the format is the same:
|
||||
|
||||
|
||||
```
|
||||
(example) $ python3 ./parse.py
|
||||
red green blue
|
||||
0 0.31 0.96 0.47
|
||||
1 0.95 0.17 0.64
|
||||
2 0.00 0.23 0.59
|
||||
3 0.22 0.16 0.42
|
||||
4 0.53 0.52 0.18
|
||||
5 0.76 0.80 0.28
|
||||
6 0.68 0.69 0.46
|
||||
7 0.75 0.52 0.27
|
||||
8 0.53 0.76 0.96
|
||||
9 0.01 0.81 0.79
|
||||
```
|
||||
|
||||
Assume you need only the red values from your dataset. You can do this by declaring your dataframe's column names and selectively printing only the column you're interested in:
|
||||
|
||||
|
||||
```
|
||||
from pandas import read_csv, DataFrame
|
||||
import pandas as pd
|
||||
|
||||
FILE = open('sample.csv','r')
|
||||
DATAFRAME = pd.read_csv(FILE)
|
||||
|
||||
# define columns
|
||||
DATAFRAME.columns = [ 'red','green','blue' ]
|
||||
|
||||
print(DATAFRAME['red'])
|
||||
```
|
||||
|
||||
Run the code now, and you get just the red column:
|
||||
|
||||
|
||||
```
|
||||
(example) $ python3 ./parse.py
|
||||
0 0.31
|
||||
1 0.95
|
||||
2 0.00
|
||||
3 0.22
|
||||
4 0.53
|
||||
5 0.76
|
||||
6 0.68
|
||||
7 0.75
|
||||
8 0.53
|
||||
9 0.01
|
||||
Name: red, dtype: float64
|
||||
```
|
||||
|
||||
Manipulating tables of data is a great way to get used to how data can be parsed with Pandas. There are many more ways to select data from a dataframe, and the more you experiment, the more natural it becomes.
|
||||
|
||||
### Visualizing your data
|
||||
|
||||
It's no secret that many humans prefer to visualize information. It's the reason charts and graphs are staples of meetings with upper management and why "infographics" are popular in the news business. Part of a data scientist's job is to help others understand large samples of data, and there are libraries to help with this task. Combining Pandas with a visualization library can produce visual interpretations of your data. One popular open source library for visualization is [Seaborn][7], which is based on the open source [Matplotlib][3].
|
||||
|
||||
#### Installing Seaborn and Matplotlib
|
||||
|
||||
Your Python virtual environment doesn't yet have Seaborn and Matplotlib, so install them with pip3. Seaborn also installs Matplotlib along with many other libraries:
|
||||
|
||||
|
||||
```
|
||||
`(example) $ pip3 install seaborn`
|
||||
```
|
||||
|
||||
For Matplotlib to display graphics, you must also install [PyGObject][8] and [Pycairo][9]. This involves compiling code, which pip3 can do for you as long as you have the necessary header files and libraries installed. Your Python virtual environment has no awareness of these support libraries, so you can execute the installation command inside or outside the environment.
|
||||
|
||||
On Fedora and CentOS:
|
||||
|
||||
|
||||
```
|
||||
(example) $ sudo dnf install -y gcc zlib-devel bzip2 bzip2-devel readline-devel \
|
||||
sqlite sqlite-devel openssl-devel tk-devel git python3-cairo-devel \
|
||||
cairo-gobject-devel gobject-introspection-devel
|
||||
```
|
||||
|
||||
On Ubuntu and Debian:
|
||||
|
||||
|
||||
```
|
||||
(example) $ sudo apt install -y libgirepository1.0-dev build-essential \
|
||||
libbz2-dev libreadline-dev libssl-dev zlib1g-dev libsqlite3-dev wget \
|
||||
curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libcairo2-dev
|
||||
```
|
||||
|
||||
Once they are installed, you can install the GUI components needed by Matplotlib:
|
||||
|
||||
|
||||
```
|
||||
`(example) $ pip3 install PyGObject pycairo`
|
||||
```
|
||||
|
||||
### Displaying a graph with Seaborn and Matplotlib
|
||||
|
||||
Open a file called **vizualize.py** in your favorite text editor. To create a line graph visualization of your data, first, you must import the necessary Python modules: the Pandas modules you used in the previous code examples:
|
||||
|
||||
|
||||
```
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from pandas import read_csv, DataFrame
|
||||
import pandas as pd
|
||||
```
|
||||
|
||||
Next, import Seaborn, Matplotlib, and several components of Matplotlib so you can configure the graphics you produce:
|
||||
|
||||
|
||||
```
|
||||
import seaborn as sns
|
||||
import matplotlib
|
||||
import matplotlib.pyplot as plt
|
||||
from matplotlib import rcParams
|
||||
```
|
||||
|
||||
Matplotlib can export its output to many formats, including PDF, SVG, or just a GUI window on your desktop. For this example, it makes sense to send your output to the desktop, so you must set the Matplotlib backend to GTK3Agg. If you're not using Linux, you may need to use the TkAgg backend instead.
|
||||
|
||||
After setting the backend for the GUI window, set the size of the window and the Seaborn preset style:
|
||||
|
||||
|
||||
```
|
||||
matplotlib.use('GTK3Agg')
|
||||
rcParams['figure.figsize'] = 11,8
|
||||
sns.set_style('darkgrid')
|
||||
```
|
||||
|
||||
Now that your display is configured, the code is familiar. Ingest your **sample.csv** file with Pandas, and define the columns of your dataframe:
|
||||
|
||||
|
||||
```
|
||||
FILE = open('sample.csv','r')
|
||||
DATAFRAME = pd.read_csv(FILE)
|
||||
DATAFRAME.columns = [ 'red','green','blue' ]
|
||||
```
|
||||
|
||||
With the data in a useful format, you can plot it out in a graph. Use each column as input for a plot, then use **plt.show()** to draw the graph in a GUI window. The **plt.legend()** parameter associates the column header with each line on your graph (the **loc** parameter places the legend outside the chart rather than over it):
|
||||
|
||||
|
||||
```
|
||||
for i in DATAFRAME.columns:
|
||||
DATAFRAME[i].plot()
|
||||
|
||||
plt.legend(bbox_to_anchor=(1, 1), loc=2, borderaxespad=1)
|
||||
plt.show()
|
||||
```
|
||||
|
||||
Run the code to display the results.
|
||||
|
||||
![First data visualization][10]
|
||||
|
||||
Your graph accurately displays all the information contained in your CSV file: values are on the Y-axis, index numbers are on the X-axis, and the lines of the graph are identified so that you know what they represent. However, since this code is tracking color values (at least, it's pretending to), the colors of the lines are not just non-intuitive, but counterintuitive. If you never need to analyze color data, you may never run into this problem, but you're sure to run into something analogous. When visualizing data, you must consider the best way to present it to prevent the viewer from extrapolating false information from what you're presenting.
|
||||
|
||||
To fix this problem (and show off some of the customization available), the following code assigns each plotted line a specific color:
|
||||
|
||||
|
||||
```
|
||||
import matplotlib
|
||||
from pandas import read_csv, DataFrame
|
||||
import pandas as pd
|
||||
import seaborn as sns
|
||||
import matplotlib.pyplot as plt
|
||||
from matplotlib import rcParams
|
||||
|
||||
matplotlib.use('GTK3Agg')
|
||||
rcParams['figure.figsize'] = 11,8
|
||||
sns.set_style('whitegrid')
|
||||
|
||||
FILE = open('sample.csv','r')
|
||||
DATAFRAME = pd.read_csv(FILE)
|
||||
DATAFRAME.columns = [ 'red','green','blue' ]
|
||||
|
||||
plt.plot(DATAFRAME['red'],'r-')
|
||||
plt.plot(DATAFRAME['green'],'g-')
|
||||
plt.plot(DATAFRAME['blue'],'b-')
|
||||
plt.plot(DATAFRAME['red'],'ro')
|
||||
plt.plot(DATAFRAME['green'],'go')
|
||||
plt.plot(DATAFRAME['blue'],'bo')
|
||||
|
||||
plt.show()
|
||||
```
|
||||
|
||||
This uses special Matplotlib notation to create two plots per column. The initial plot of each column is assigned a color (**r** for red, **g** for green, and **b** for blue). These are built-in Matplotlib settings. The **-** notation indicates a solid line (a double dash, such as **r--**, creates a dashed line). A second plot is created for each column with the same colors but using **o** to denote dots or nodes. To demonstrate built-in Seaborn themes, change the value of **sns.set_style** to **whitegrid**.
|
||||
|
||||
![Improved data visualization][11]
|
||||
|
||||
### Deactivating your virtual environment
|
||||
|
||||
When you're finished exploring Pandas and plotting, you can deactivate your Python virtual environment with the **deactivate** command:
|
||||
|
||||
|
||||
```
|
||||
(example) $ deactivate
|
||||
$
|
||||
```
|
||||
|
||||
When you want to get back to it, just reactivate it as you did at the start of this article. You'll have to reinstall your modules when you reactivate your virtual environment, but they'll be installed from cache rather than downloaded from the internet, so you don't have to be online.
|
||||
|
||||
### Endless possibilities
|
||||
|
||||
The true power of Pandas, Matplotlib, Seaborn, and data science is the endless potential for you to parse, interpret, and structure data in a meaningful and enlightening way. Your next step is to explore simple datasets with the new tools you've learned in this article. There's a lot more to Matplotlib and Seaborn than just line graphs, so try creating a bar graph or a pie chart or something else entirely.
|
||||
|
||||
The possibilities are limitless once you understand your toolset and have some idea of how to correlate your data. Data science is a new way to find stories hidden within data; let open source be your medium.
|
||||
|
||||
Data visualization is the mechanism of taking tabular or spatial data and conveying it in a human-...
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/9/get-started-data-science-python
|
||||
|
||||
作者:[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/sethhttps://opensource.com/users/jroakeshttps://opensource.com/users/tiwarinitish86
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/metrics_graph_stats_blue.png?itok=OKCc_60D (Metrics and a graph illustration)
|
||||
[2]: https://pandas.pydata.org/
|
||||
[3]: https://matplotlib.org/
|
||||
[4]: https://seaborn.pydata.org/index.html
|
||||
[5]: https://opensource.com/article/17/10/python-101
|
||||
[6]: http://libreoffice.org
|
||||
[7]: https://seaborn.pydata.org/
|
||||
[8]: https://pygobject.readthedocs.io/en/latest/getting_started.html
|
||||
[9]: https://pycairo.readthedocs.io/en/latest/
|
||||
[10]: https://opensource.com/sites/default/files/uploads/seaborn-matplotlib-graph_0.png (First data visualization)
|
||||
[11]: https://opensource.com/sites/default/files/uploads/seaborn-matplotlib-graph_1.png (Improved data visualization)
|
@ -1,5 +1,5 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
@ -0,0 +1,88 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (laingke)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Cloud-native Java, open source security, and more industry trends)
|
||||
[#]: via: (https://opensource.com/article/19/8/cloud-native-java-and-more)
|
||||
[#]: author: (Tim Hildred https://opensource.com/users/thildred)
|
||||
|
||||
云原生 Java、开源安全以及更多行业趋势
|
||||
======
|
||||
开放源码社区和行业趋势的每周总览。
|
||||
![Person standing in front of a giant computer screen with numbers, data][1]
|
||||
|
||||
作为我在具有开放源代码开发模型的企业软件公司担任高级产品营销经理的角色的一部分,我为产品营销人员、经理和其他影响者定期发布有关开源社区,市场和行业趋势的定期更新。 以下是该更新中我和他们最喜欢的五篇文章。
|
||||
|
||||
## [为什么现代 web 开发如此复杂?][2]
|
||||
|
||||
> 现代前端 web 开发带来了一种两极分化的体验:许多人喜欢它,其他人则鄙视它。
|
||||
>
|
||||
> 我是现代Web开发的忠实拥护者,尽管我将其描述为“魔法”——而魔法也有其优点和缺点……。最近,我一直在向那些只具有粗略的原始 web 开发工作流程的人们讲解“现代 web 开发工作流程”……,但我发现需要解释的内容实在是太多了!甚至笼统的解释最终都会变得冗长。因此,在我努力写下更多解释的过程中,这里是对 web 开发演变的一个长期而笼统的解释的开始……
|
||||
|
||||
**影响**:足够具体,对前端开发人员非常有用(特别是对新开发人员),而足够简单,解释得足够好,可以帮助非开发人员更好地理解前端开发人员的一些问题。到最后,您将(有点)了解 Javascript 和 WebAPIs 之间的区别,以及 2019 年的 Javascript 与 2006 年的 Javascript 有何不同。
|
||||
|
||||
## [开源 Kubernetes 安全审核][3]
|
||||
|
||||
> 去年,云原生计算基金会(CNCF)开始为其项目执行并开源第三方安全审核,以提高我们生态系统的整体安全性。这个想法是从一些项目开始,从 CNCF 社区收集关于这个试点项目是否有用的反馈。第一批经历这个过程的项目是 [CoreDNS][4]、[Envoy][5] 和 [Prometheus][6]。这些首次公开审核发现了从一般漏洞到严重漏洞的安全问题。有了这些结果,CoreDNS、Envoy 和 Prometheus 的项目维护者就能够解决已发现的漏洞,并添加文档来帮助用户。
|
||||
>
|
||||
> 从这些初始审核中得出的主要结论是,公共安全审核是测试开放源码项目的质量及其漏洞管理过程的一个很好的方法,更重要的是,测试开放源码项目的安全实践有多大的弹性。特别是 CNCF 的[毕业项目][7],它被世界上一些最大的公司广泛应用于生产中,它们必须坚持最高级别的安全最佳实践。
|
||||
|
||||
**影响**:很多公司都把宝押在 Kubernetes 之于云计算,就像 Linux 之于数据中心一样。从安全的角度来看,看到其中 4 家公司以确保项目正在做应该做的事情,这激发了人们的信心。共享这项研究表明,开源远远不止是仓库中的代码;它是以一种有益于整个社区而不是少数人利益的方式获取和分享专家意见。
|
||||
|
||||
## [Quarkus——轻量级 Java 框架的下一步是什么?][8]
|
||||
|
||||
> “容器优先”是什么意思?Quarkus 有哪些优势?0.20.0 版本有什么新功能?未来我们可以期待哪些功能?1.0.0 版什么时候发布?我们对 Quarkus 有很多问题,而 Alex Soto 也很耐心地回答了所有问题。 _随着 Quarkus 0.20.0 的发布,我们决定与 [JAX 伦敦演讲者][9],Java 拥护者和红帽的开发人员体验总监 Alex Soto 保持联系。他很好地回答了我们关于 Quarkus 的过去、现在和未来的所有问题。看起来我们对这个令人兴奋的轻量级框架有很多期待!_
|
||||
|
||||
**影响**:最近有个聪明的人告诉我,Quarkus 有潜力使 Java “可能成为容器和无服务器环境的最佳语言之一”。那使我做了双重决定。 尽管 Java 是最流行的编程语言之一([如果不是最流行的][10]),但当您听到“云原生”一词时,它可能并不是第一个想到的语言。Quarkus 可以通过让开发人员将他们的经验应用到新的挑战中,从而扩展和提高他们所拥有的技能的价值。
|
||||
|
||||
## [Julia 编程语言:用户可以透露他们最喜欢和最讨厌它的地方][11]
|
||||
|
||||
> Julia 最受欢迎的技术特性是速度和性能,其次是易用性,而最受欢迎的非技术特性是使用者无需付费即可使用它。
|
||||
>
|
||||
> 用户还报告了他们对该语言最大的不满。排在首位的是使用者附加功能的包不够成熟,或者维护得不够好,无法满足他们的需求。
|
||||
|
||||
**影响**:Julia 1.0 版本已经发布了一年,并且在一系列相关指标(下载,GitHub 星级等)中取得了令人瞩目的增长。 它是一种直接针对我们当前和未来最大挑战(“科学计算,机器学习,数据挖掘,大规模线性代数,分布式和并行计算”)的语言,因此,了解用户对它的感受,就可以间接阅读有关这些挑战的应对情况。
|
||||
|
||||
## [多云数据解读:11 个有趣的统计数据][12]
|
||||
|
||||
> 如果你把我们最近对 [Kubernetes 的有趣数据][13]的深入研究归结为它的底线,它看起来是这样的: [Kubernetes][14] 的受欢迎程度在可预见的未来将持续下去。
|
||||
>
|
||||
> 剧透警报:当您挖掘有关[多云][15]使用情况的最新数据时,他们告诉您一个类似的描述:使用率正在飙升。
|
||||
>
|
||||
> 这种一致性是有道理的。 也许不是每个组织都将使用 Kubernetes 来管理其多云和/或[混合云][16]基础架构,但是两者越来越紧密地联系在一起。 即使不这样做,它们都反映了向更分散和异构 IT 环境的普遍转变,以及[云原生开发][17]和其他重叠趋势。
|
||||
|
||||
**影响**:越来越多地采用“多云战略”的另一种解释是,它们将组织中单独部分未经协商而作出的决策追溯为“战略”,从而使决策合法化。“等等,所以您从谁那里买了几个小时?又从另一个人那里买了几个小时?为什么在会议纪要中没有呢?我想我们现在是一家多云公司!”。当然,我在开玩笑,我敢肯定大多数大公司的协调能力远胜于此,对吗?
|
||||
|
||||
_我希望您喜欢这张上周让我印象深刻的列表,并在下周一回来了解更多的开放源码社区、市场和行业趋势。_
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/8/cloud-native-java-and-more
|
||||
|
||||
作者:[Tim Hildred][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[laingke](https://github.com/laingke)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/thildred
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr (Person standing in front of a giant computer screen with numbers, data)
|
||||
[2]: https://www.vrk.dev/2019/07/11/why-is-modern-web-development-so-complicated-a-long-yet-hasty-explanation-part-1/
|
||||
[3]: https://www.cncf.io/blog/2019/08/06/open-sourcing-the-kubernetes-security-audit/
|
||||
[4]: https://coredns.io/2018/03/15/cure53-security-assessment/
|
||||
[5]: https://github.com/envoyproxy/envoy/blob/master/docs/SECURITY_AUDIT.pdf
|
||||
[6]: https://cure53.de/pentest-report_prometheus.pdf
|
||||
[7]: https://www.cncf.io/projects/
|
||||
[8]: https://jaxenter.com/quarkus-whats-next-for-the-lightweight-java-framework-160793.html
|
||||
[9]: https://jaxlondon.com/cloud-kubernetes-serverless/java-particle-acceleration-using-quarkus/
|
||||
[10]: https://opensource.com/article/19/8/possibly%20one%20of%20the%20best%20languages%20for%20containers%20and%20serverless%20environments.
|
||||
[11]: https://www.zdnet.com/article/julia-programming-language-users-reveal-what-they-love-and-hate-the-most-about-it/#ftag=RSSbaffb68
|
||||
[12]: https://enterprisersproject.com/article/2019/8/multi-cloud-statistics
|
||||
[13]: https://enterprisersproject.com/article/2019/7/kubernetes-statistics-13-compelling
|
||||
[14]: https://www.redhat.com/en/topics/containers/what-is-kubernetes?intcmp=701f2000000tjyaAAA
|
||||
[15]: https://www.redhat.com/en/topics/cloud-computing/what-is-multicloud?intcmp=701f2000000tjyaAAA
|
||||
[16]: https://enterprisersproject.com/hybrid-cloud
|
||||
[17]: https://enterprisersproject.com/article/2018/10/how-explain-cloud-native-apps-plain-english
|
@ -0,0 +1,114 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How to use Terminator on Linux to run multiple terminals in one window)
|
||||
[#]: via: (https://www.networkworld.com/article/3436784/how-to-use-terminator-on-linux-to-run-multiple-terminals-in-one-window.html)
|
||||
[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/)
|
||||
|
||||
如何在 Linux 上使用 Terminator 在一个窗口中运行多个终端
|
||||
======
|
||||
Terminator 为在单窗口中运行多个 GNOME 终端提供了一个选择,让你可以灵活地调整工作空间来适应你的需求。
|
||||
|
||||
如果你曾经希望可以排列多个终端并将它们组织在一个窗口中,那么我们可能会给你带来一个好消息。 Linux **Terminator** 可以为你做到这一点。没有问题!
|
||||
|
||||
### 分割窗口
|
||||
|
||||
Terminator 最初像在单独窗口中打开终端一样。但是,一旦在该窗口中单击鼠标,它将弹出一个选项,让你可以灵活地进行更改。你可以选择“**水平分割**”或“**垂直分割**”将你当前所在的窗口分为两个较小的窗口。实际上,菜单旁会有小的分割结果图示(类似于**=** and **||**),你可以根据需要重复拆分窗口。当然,你如果将整个窗口分为六个或九个以上,那么你可能会发现它们太小而无法有效使用。
|
||||
|
||||
使用 ASCII 艺术来说明分割窗口的过程,你可能会看到类似以下的样子:
|
||||
|
||||
```
|
||||
+-------------------+ +-------------------+ +-------------------+
|
||||
| | | | | |
|
||||
| | | | | |
|
||||
| | ==> |-------------------| ==> |-------------------|
|
||||
| | | | | | |
|
||||
| | | | | | |
|
||||
+-------------------+ +-------------------+ +-------------------+
|
||||
原始终端 水平分割 垂直分割
|
||||
```
|
||||
|
||||
另一种拆分窗口的方法是使用控制序列,例如,使用**Ctrl+Shift+e** 垂直分割窗口,使用 **Ctrl+Shift+o**(“o” 表示“打开”)水平分割窗口。
|
||||
|
||||
在 Terminator 分割完成后,你可以点击任意窗口使用,并根据工作需求在窗口间移动。
|
||||
|
||||
### 最大化窗口
|
||||
|
||||
如果你想暂时忽略除了一个窗口外的其他窗口,你可以单击该窗口,然后从菜单中选择“**最大化**”选项。接着该窗口会撑满所有空间。再次单击并选择“**还原所有终端**”返回到多窗口显示。使用 **Ctrl+Shift+x** 将在正常和最大化设置之间切换。
|
||||
|
||||
窗口标签上的窗口大小指示(例如 80x15)显示了每行的字符数以及每个窗口的行数。
|
||||
|
||||
### 关闭窗口
|
||||
|
||||
要关闭任何窗口,请打开 Terminator 菜单,然后选择**关闭**。其他窗口将自行调整占用空间,直到你关闭最后一个窗口。
|
||||
|
||||
### 保存你的自定义设置
|
||||
|
||||
将窗口分为多个部分后,将自定义的 Terminator 设置设置为默认非常容易。从弹出菜单中选择**首选项**,然后从打开的窗口顶部的选项卡中选择**布局**。接着你应该看到列出了**新布局**。只需单击底部的**保存**,然后单击右下角的**关闭**。Terminator 会将您的设置保存在 **~/.config/terminator/config** 中,然后每次使用到时都会使用该文件。
|
||||
|
||||
你也可以通过使用鼠标拉伸来扩大整个窗口。再说一次,如果要保留更改,请从菜单中选择**首选项**,**布局**,接着选择**保存**和**关闭**。
|
||||
|
||||
### 在保存的配置之间进行选择
|
||||
|
||||
如果愿意,你可以通过维护多个配置文件来设置多种 Terminator 窗口布局,重命名每个配置文件(如 config-1、config-2),接着在你想使用它时将它移动到 **~/.config/terminator/config** 中。这有一个类似执行此任务的脚本。它让你在 3 个预配置的窗口布局之间进行选择。
|
||||
|
||||
```
|
||||
#!/bin/bash
|
||||
|
||||
PS3='Terminator options: '
|
||||
options=("Split 1" "Split 2" "Split 3" "Quit")
|
||||
select opt in "${options[@]}"
|
||||
do
|
||||
case $opt in
|
||||
"Split 1")
|
||||
config=config-1
|
||||
break
|
||||
;;
|
||||
"Split 2")
|
||||
config=config-2
|
||||
break
|
||||
;;
|
||||
"Split 3")
|
||||
config=config-3
|
||||
break
|
||||
;;
|
||||
*)
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
cd ~/.config/terminator
|
||||
cp config config-
|
||||
cp $config config
|
||||
cd
|
||||
terminator &
|
||||
```
|
||||
|
||||
如果有用的话,你可以给选项一个比 “config-1” 更有意义的名称。
|
||||
|
||||
### 总结
|
||||
|
||||
Terminator 是设置多窗口处理相关任务的不错选择。 如果你从未使用过它,那么可能需要先使用 “sudo apt install terminator” 或 “sudo yum install -y terminator” 之类的命令进行安装。
|
||||
|
||||
希望你喜欢使用 Terminator。还有,如另一个同名角色所说,“我会回来的!”
|
||||
|
||||
在 [Facebook][2] 和 [LinkedIn][3] 中加入 Network World 社区,评论热门主题。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.networkworld.com/article/3436784/how-to-use-terminator-on-linux-to-run-multiple-terminals-in-one-window.html
|
||||
|
||||
作者:[Sandra Henry-Stocker][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/
|
||||
[b]: https://github.com/lujun9972
|
||||
[2]: https://www.facebook.com/NetworkWorld/
|
||||
[3]: https://www.linkedin.com/company/network-world
|
@ -7,39 +7,38 @@
|
||||
[#]: via: (https://opensource.com/article/19/9/introduction-markdown)
|
||||
[#]: author: (Juan Islas https://opensource.com/users/xislashttps://opensource.com/users/mbbroberghttps://opensource.com/users/scottnesbitthttps://opensource.com/users/scottnesbitthttps://opensource.com/users/f%C3%A1bio-emilio-costahttps://opensource.com/users/don-watkinshttps://opensource.com/users/greg-phttps://opensource.com/users/marcobravohttps://opensource.com/users/alanfdosshttps://opensource.com/users/scottnesbitthttps://opensource.com/users/jamesf)
|
||||
|
||||
An introduction to Markdown
|
||||
一份 Markdown 简介
|
||||
======
|
||||
Write once and convert your text into multiple formats. Here's how to
|
||||
get started with Markdown.
|
||||
一次编辑便可将文本转换为多种格式。下面是如何开始使用 Markdown。
|
||||
![Woman programming][1]
|
||||
|
||||
For a long time, I thought all the files I saw on GitLab and GitHub with an **.md** extension were written in a file type exclusively for developers. That changed a few weeks ago when I started using Markdown. It quickly became the most important tool in my daily work.
|
||||
在很长一段时间里,我发现我在 GitLab 和 GitHub 上看到的所有文件都带有**.md**扩展名,这是是专门为开发人员编写的文件类型。几周前,当我开始使用Markdown时,我的观念发生了变化。它很快成为我日常工作中最重要的工具。
|
||||
|
||||
Markdown makes my life easier. I just need to add a few symbols to what I'm already writing and, with the help of a browser extension or an open source program, I can transform my text into a variety of commonly used formats such as ODT, email (more on that later), PDF, and EPUB.
|
||||
Markdown 使我的生活更简易。我只需要在已经编写的代码中添加一些符号,并且在浏览器扩展或开源程序的帮助下,即可将文本转换为各种常用格式,如 ODT、电子邮件(稍后将详细介绍)、PDF 和 EPUB。
|
||||
|
||||
### What is Markdown?
|
||||
### 什么是 Markdown?
|
||||
|
||||
A friendly reminder from [Wikipedia][2]:
|
||||
来自 [维基百科][2]的友情提示:
|
||||
|
||||
> Markdown is a lightweight markup language with plain text formatting syntax.
|
||||
> Markdown是一种轻量级标记语言,具有纯文本格式语法。
|
||||
|
||||
What this means to you is that by using just a few extra symbols in your text, Markdown helps you create a document with an explicit structure. When you take notes in plain text (in a notepad application, for example), there's nothing to indicate which text is meant to be bold or italic. In ordinary text, you might write a link as **<http://example.com>** one time, then as just **example.com**, and later **go to the website (example.com)**. There's no internal consistency.
|
||||
这意味着通过在文本中使用一些额外的符号,Markdown 可以帮助您创建具有特定结构和格式的文档。当您以纯文本(例如,在记事本应用程序中)做笔记时,没有任何东西表明哪个文本应该是粗体或斜体。在普通文本中,你在编写链接时需要将一个链接编写为**<http://example.com>**,或者编写为**example.com**,又或**访问网站(example.com)**。这样没有内在的一致性。
|
||||
|
||||
But if you write the way Markdown prescribes, your text has internal consistency. Computers like consistency because it enables them to follow strict instructions without worrying about exceptions.
|
||||
但是如果你按照Markdown的方式编写,你的文本就有了内在的一致性。计算机喜欢一致性,因为这使得它们能够遵循严格的指令而不用担心异常。
|
||||
|
||||
Trust me; once you learn to use Markdown, every writing task will be, in some way, easier and better than before. So let's learn it.
|
||||
相信我;一旦你学会使用Markdown,每一项写作任务在某种程度上都会比以前更容易、更好。让我们开始吧。
|
||||
|
||||
### Markdown basics
|
||||
### Markdown 基础
|
||||
|
||||
The following rules are the basics for writing in Markdown.
|
||||
以下是使用 Markdown 的基础语法。
|
||||
|
||||
1. Create a text file with an **.md** extension (for example, **example.md**.) You can use any text editor (even a word processor like LibreOffice or Microsoft Word), as long as you remember to save it as a _text_ file.
|
||||
1. 创建一个以 **.md**扩展名结尾的文本文件(例如,**example.md**)。你可以使用任何文本编辑器(甚至像 LibreOffice 或 Microsoft word 这样的文字处理程序亦可),只要记住将其保存为_text_文件。
|
||||
|
||||
|
||||
|
||||
![Names of Markdown files][3]
|
||||
|
||||
2. Write whatever you want, just as you usually do:
|
||||
2. 想写什么就写什么,就像往常一样:
|
||||
|
||||
|
||||
```
|
||||
@ -57,9 +56,9 @@ Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed
|
||||
Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.
|
||||
```
|
||||
|
||||
3. Make sure to place an empty line between paragraphs. That might feel unnatural if you're used to writing business letters or traditional prose, where paragraphs have only one new line and maybe even an indentation before the first word. For Markdown, an empty line (some word processors mark this with **¶**, called a Pilcrow symbol) guarantees a new paragraph is created when you convert it to another format like HTML.
|
||||
3. 确保在段落之间留有空行。如果你习惯写商务信函或传统散文,这可能会觉得不自然,因为段落只有一行,甚至在第一个单词前还有一个缩进。对于Markdown,空行(一些文字处理程序使用 **¶**,称为Pilcrow符号)保证在创建一个新段落应用另一种格式(如HTML)。
|
||||
|
||||
4. Designate titles and subtitles. For the document's title, add a pound or hash (**#**) symbol and a space before the text (e.g., **# Lorem ipsum**). The first subtitle level uses two (**## De Finibus Bonorum et Malorum**), the next level gets three (**### Third Subtitle**), and so on. Note that there is a space between the pound sign and the first word.
|
||||
4. 指定标题和副标题。对于文档的标题,在文本前面添加一个 # 或散列符号(**#**)和一个空格(例如**# Lorem ipsum**)。第一个副标题级别使用两个(**## De Finibus Bonorum et Malorum**),下一个级别使用三个(**### #第三个副标题**),以此类推。注意,在磅号和第一个单词之间有一个空格。
|
||||
|
||||
|
||||
```
|
||||
@ -77,63 +76,67 @@ Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed
|
||||
Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.
|
||||
```
|
||||
|
||||
5. If you want **bold** letters, just place the letters between two asterisks (stars) with no spaces: ****This will be in bold****.
|
||||
5. 如果你想使用**粗体**字符,只需将字母放在两个星号之间,没有空格:****对应的文本将以粗体****显示。
|
||||
|
||||
|
||||
|
||||
|
||||
![Bold text in Markdown][4]
|
||||
|
||||
6. For _italics_, put the text between underline symbols with no spaces: **_I want this text to be in italics_**.
|
||||
6. 对于 _斜体_, 将文本放在没有空格的下划线符号之间:
|
||||
**_I want this text to be in italics_**.
|
||||
|
||||
|
||||
|
||||
![Italics text in Markdown][5]
|
||||
|
||||
7. To insert a link (like [Markdown Tutorial][6]), put the text you want to link in brackets and the URL in parentheses with no spaces between them:
|
||||
7. 要插入一个链接(像[Markdown Tutorial][6]),把你想链接的文本放在括号里,URL放在括号里,中间没有空格:
|
||||
|
||||
**[Markdown Tutorial](<https://www.markdowntutorial.com/>)**.
|
||||
|
||||
|
||||
|
||||
![Hyperlinks in Markdown][7]
|
||||
|
||||
8. Blockquotes are written with a greater-than (**>**) symbol and a space before the text you want to quote: **> A famous quote**.
|
||||
8. 块引用是用大于号编写的 (**>**) 在你要引用的文本前加上符号和空格: **> A famous quote**.
|
||||
|
||||
|
||||
|
||||
![Blockquote text in Markdown][8]
|
||||
|
||||
### Markdown tutorials and tip sheets
|
||||
### Markdown 教程和技巧
|
||||
|
||||
These tips will get you started writing in Markdown, but it has a lot more functions than just bold and italics and links. The best way to learn Markdown is to use it, but I recommend investing 15 minutes stepping through the simple [Markdown Tutorial][6] to practice these rules and learn a couple more.
|
||||
这些技巧可以帮助你上手 Markdown ,但它涵盖了很多功能,不仅仅是粗体、斜体和链接。学习 Markdown 的最好方法是使用它,但是我建议你花15分钟来学习简单的[Markdown教程][6],学以致用,勤加练习。
|
||||
|
||||
Because modern Markdown is an amalgamation of many different interpretations of the idea of structured text, the [CommonMark][9] project defines a spec with a rigid set of rules to bring clarity to Markdown. It might be helpful to keep a [CommonMark-compliant cheatsheet][10] on hand when writing.
|
||||
由于现代 Markdown 是对结构化文本概念的许多不同解释的融合,[CommonMark][9]项目定义了一个规范,其中包含一组严格的规则,以使 Markdown 更加清晰。在编辑时手边准备一份[符合公共标记的快捷键列表][10]可能会有帮助。
|
||||
|
||||
### What you can do with Markdown
|
||||
### 你能用 Markdown 做什么
|
||||
|
||||
Markdown lets you write anything you want—once—and transform it into almost any kind of format you want to use. The following examples show how to turn simple text written in MD into different formats. You don't need multiple formats of your text—you can start from a single source and then… rule the world!
|
||||
Markdown 可以让你写任何你想写的东西,仅需一次编辑,就可以把它转换成几乎任何你想使用的格式。下面的示例演示如何将用 MD 编写简单的文本并转换为不同的格式。你不需要多种格式的文档-你可以仅仅编辑一次…然后拥有无限可能。
|
||||
|
||||
1. **Simple note-taking:** You can write your notes in Markdown and, the moment you save them, the open source note application [Turtl][11] interprets your text file and shows you the formatted result. You can have your notes anywhere!
|
||||
1. **简单的笔记:** 你可以用 Markdown 编写你的笔记,并且在保存笔记时,开源笔记应用程序[Turtl][11]将解释您的文本文件并显示为对应的格式。你可以把笔记存储在任何地方!
|
||||
|
||||
|
||||
|
||||
![Turtl application][12]
|
||||
|
||||
2. **PDF files:** With the [Pandoc][13] application, you can convert your Markdown into a PDF with one simple command: **pandoc <file.md> -o <file.pdf>**.
|
||||
2. **PDF 文件:** 使用[Pandoc][13]应用程序,你可以使用一个简单的命令将 Markdown 文件转换为PDF:
|
||||
|
||||
**pandoc <file.md> -o <file.pdf>**.
|
||||
|
||||
|
||||
|
||||
![Markdown text converted to PDF with Pandoc][14]
|
||||
|
||||
3. **Email:** You can also convert Markdown text into an HTML-formatted email by installing the browser extension [Markdown Here][15]. To use it, just select your Markdown text, use Markdown Here to translate it into HTML, and send your message using your favorite email client.
|
||||
3. **Email:** 你还可以通过安装浏览器扩展[Markdown Here][15]将Markdown 文本转换为 html 格式的电子邮件。要使用它,只需选择您的Markdown 文本,在这里使用 Markdown 将其转换为HTML,并使用你喜欢的电子邮件客户端发送消息。
|
||||
|
||||
|
||||
|
||||
![Markdown text converted to email with Markdown Here][16]
|
||||
|
||||
### Start using it
|
||||
### 现在就开始上手吧
|
||||
|
||||
You don't need a special application to use Markdown—you just need a text editor and the tips above. It's compatible with how you already write; all you need to do is use it, so give it a try.
|
||||
你不需要一个特殊的应用程序来使用 Markdown—你只需要一个文本编辑器和上面的技巧。它与你已有的写作方式兼容;你所需要做的就是使用它,所以试试吧。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
@ -1,170 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How to start developing with .NET)
|
||||
[#]: via: (https://opensource.com/article/19/9/getting-started-net)
|
||||
[#]: author: (Seth Kenlon https://opensource.com/users/sethhttps://opensource.com/users/alex-bunardzichttps://opensource.com/users/alex-bunardzic)
|
||||
|
||||
如何开始使用 .NET 进行开发
|
||||
======
|
||||
了解 .NET 开发平台启动和运行的基础知识。
|
||||
![Coding on a computer][1]
|
||||
|
||||
.NET 框架由 Microsoft 于 2000 年发布。该平台的开源实现 [Mono][2] 在 21 世纪初成为了争议的焦点,因为微软拥有 .NET 技术的多项专利,并且可能使用这些专利来结束 Mono。幸运的是,在 2014 年,微软宣布 .NET 开发平台从此成为 MIT 许可下的开源平台,并在 2016 年收购了开发 Mono 的 Xamarin 公司。
|
||||
|
||||
.NET 和 Mono 已经同时可用于 C#、F#、GTK+、Visual Basic、Vala 等的跨平台编程环境。使用 .NET 和 Mono 创建的程序已经应用于 Linux、BSD、Windows、MacOS、Android,甚至一些游戏机。你可以使用 .NET 或 Mono 来开发 .NET 应用。它们都是开源的,并且都有活跃和充满活力的社区。本文重点介绍 Microsoft .NET 环境实现。
|
||||
|
||||
### 如何安装 .NET
|
||||
|
||||
.NET 下载被分为多个包:一个仅包含 .NET 运行时,另一个包含了 .NET Core 和运行时 .NET SDK。根据架构和操作系统版本,这些包可能有多个版本。要开始使用 .NET 进行开发,你必须[安装 SDK][3]。它为您提供了 [dotnet][4] 终端或 PowerShell 命令,你可以使用它们来创建和生成项目。
|
||||
|
||||
#### Linux
|
||||
|
||||
要在 Linux 上安装 .NET,首先将 Microsoft Linux 软件仓库添加到你的计算机。
|
||||
|
||||
在 Fedora 上:
|
||||
|
||||
|
||||
```
|
||||
$ sudo rpm --import <https://packages.microsoft.com/keys/microsoft.asc>
|
||||
$ sudo wget -q -O /etc/yum.repos.d/microsoft-prod.repo <https://packages.microsoft.com/config/fedora/27/prod.repo>
|
||||
```
|
||||
|
||||
在 Ubuntu 上:
|
||||
|
||||
|
||||
```
|
||||
$ wget -q <https://packages.microsoft.com/config/ubuntu/19.04/packages-microsoft-prod.deb> -O packages-microsoft-prod.deb
|
||||
$ sudo dpkg -i packages-microsoft-prod.deb
|
||||
```
|
||||
|
||||
接下来,使用包管理器安装 SDK,将 **<X.Y>** 替换为当前版本的 .NET 版本:
|
||||
|
||||
在 Fedora 上:
|
||||
|
||||
|
||||
```
|
||||
`$ sudo dnf install dotnet-sdk-<X.Y>`
|
||||
```
|
||||
|
||||
在 Ubuntu 上:
|
||||
|
||||
|
||||
```
|
||||
$ sudo apt install apt-transport-https
|
||||
$ sudo apt update
|
||||
$ sudo apt install dotnet-sdk-<X.Y>
|
||||
```
|
||||
|
||||
下载并安装所有包后,打开终端并输入下面命令确认安装:
|
||||
|
||||
|
||||
```
|
||||
$ dotnet --version
|
||||
X.Y.Z
|
||||
```
|
||||
|
||||
#### Windows
|
||||
|
||||
如果你使用的是 Microsoft Windows,那么你可能已经安装了 .NET 运行时。但是,要开发 .NET 应用,你还必须安装 .NET Core SDK。
|
||||
|
||||
|
||||
首先,[下载安装程序][3]。请认准下载 .NET Core 进行跨平台开发(.NET Framework 仅适用于 Windows)。下载 **.exe** 文件后,双击该文件启动安装向导,然后单击两下进行安装:接受许可证并允许安装继续。
|
||||
|
||||
![Installing dotnet on Windows][5]
|
||||
|
||||
然后,从左下角的“应用程序”菜单中打开 PowerShell。在 PowerShell 中,输入测试命令:
|
||||
|
||||
|
||||
```
|
||||
`PS C:\Users\osdc> dotnet`
|
||||
```
|
||||
|
||||
如果你看到有关 dotnet 安装的信息,那么说明 .NET 已正确安装。
|
||||
|
||||
#### MacOS
|
||||
|
||||
如果你使用的是 Apple Mac,请下载 **.pkg**形式的 [Mac 安装程序][3]。下载并双击 **.pkg** 文件,然后单击安装程序。你可能需要授予安装程序权限,因为该软件包并非来自 App Store。
|
||||
|
||||
下载并安装所有软件包后,请打开终端并输入以下命令来确认安装:
|
||||
|
||||
|
||||
```
|
||||
$ dotnet --version
|
||||
X.Y.Z
|
||||
```
|
||||
|
||||
### Hello .NET
|
||||
|
||||
**dotnet** 命令提供了一个用 .NET 编写的 “hello world ” 示例程序。或者,更准确地说,该命令提供了示例应用。
|
||||
|
||||
首先,使用 **dotnet** 命令以及 **new** 和 **console** 参数创建一个控制台应用的项目目录及所需的代码基础结构。使用 **-o** 选项指定项目名称:
|
||||
|
||||
|
||||
```
|
||||
`$ dotnet new console -o hellodotnet`
|
||||
```
|
||||
|
||||
这将在当前目录中创建一个名为 **hellodotnet** 的目录。进入你的项目目录并看一下:
|
||||
|
||||
|
||||
```
|
||||
$ cd hellodotnet
|
||||
$ dir
|
||||
hellodotnet.csproj obj Program.cs
|
||||
```
|
||||
|
||||
**Program.cs** 是一个空的 C# 文件,它包含了一个简单的 Hello World 程序。在文本编辑器中打开浏览。微软的 Visual Studio Code 是一个使用 dotnet 编写的跨平台的开源应用,虽然它不是一个糟糕的文本编辑器,但它会收集用户的大量数据(在它的二进制发行版的许可证中授予了自己权限)。如果要尝试使用 Visual Studio Code,请考虑使用 [VSCodium][6],它是使用 Visual Studio Code 的 MIT 许可的源码构建的版本,而_没有_远程收集(请阅读[文档][7]来禁止此构建中的其他形式追踪)。或者,只需使用现有的你最喜欢的文本编辑器或 IDE。
|
||||
|
||||
新控制台应用中的样板代码为:
|
||||
|
||||
|
||||
```
|
||||
using System;
|
||||
|
||||
namespace hellodotnet
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Hello World!");
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
要运行该程序,请使用 **dotnet run** 命令:
|
||||
|
||||
|
||||
```
|
||||
$ dotnet run
|
||||
Hello World!
|
||||
```
|
||||
|
||||
这是 .NET 和 **dotnet** 命令的基本工作流程。这里有完整的 [.NET C# 指南][8],并且都是与 .NET 相关的内容。关于 .NET 实战示例,请关注 [Alex Bunardzic][9] 在 opensource.com 中的变异测试文章。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/9/getting-started-net
|
||||
|
||||
作者:[Seth Kenlon][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/sethhttps://opensource.com/users/alex-bunardzichttps://opensource.com/users/alex-bunardzic
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_laptop_hack_work.png?itok=aSpcWkcl (Coding on a computer)
|
||||
[2]: https://www.monodevelop.com/
|
||||
[3]: https://dotnet.microsoft.com/download
|
||||
[4]: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet?tabs=netcore21
|
||||
[5]: https://opensource.com/sites/default/files/uploads/dotnet-windows-install.jpg (Installing dotnet on Windows)
|
||||
[6]: https://vscodium.com/
|
||||
[7]: https://github.com/VSCodium/vscodium/blob/master/DOCS.md
|
||||
[8]: https://docs.microsoft.com/en-us/dotnet/csharp/tutorials/intro-to-csharp/
|
||||
[9]: https://opensource.com/users/alex-bunardzic (View user profile.)
|
@ -0,0 +1,327 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (GraveAccent)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Getting started with data science using Python)
|
||||
[#]: via: (https://opensource.com/article/19/9/get-started-data-science-python)
|
||||
[#]: author: (Seth Kenlon https://opensource.com/users/sethhttps://opensource.com/users/jroakeshttps://opensource.com/users/tiwarinitish86)
|
||||
|
||||
用 Python 入门数据科学
|
||||
======
|
||||
使用 Python 开展数据科学为你以有意义和启发性的方式解析、解释和组织数据提供了无限的潜力。
|
||||
![指标和图标展示][1]
|
||||
|
||||
数据科学是计算领域一个令人兴奋的新领域,它围绕分析、可视化和关联以解释我们的计算机收集的有关世界的无限信息而建立。当然,称其为“新”领域有点不诚实,因为该学科是统计学,数据分析和普通老式强迫性科学观察的派生。
|
||||
|
||||
但是数据科学是这些学科的形式化分支,拥有自己的流程和工具,并且可以广泛应用于以前从未产生过大量不可管理数据的学科(例如视觉效果)。数据科学是一个新的机会,可以重新审视海洋学,气象学,地理学,制图学,生物学,医学和健康以及娱乐行业的数据,并更好地了解其中的模式、影响和因果关系。
|
||||
|
||||
像其他大型且看似包罗万象的领域一样,知道从哪里开始探索数据科学可能会令人生畏。有很多资源可以帮助数据科学家使用自己喜欢的编程语言来实现其目标,其中包括最流行的编程语言之一:Python。使用[Pandas][2],[Matplotlib][3] 和 [Seaborn][4] 这些库,你可以学习数据科学的基本工具集。
|
||||
|
||||
如果你对 Python 的基本用法不是很熟悉,请在继续之前先阅读我的 [Python 介绍][5]。
|
||||
|
||||
### 创建 Python 虚拟环境
|
||||
|
||||
程序员有时会忘记在开发计算机上安装了哪些库,这可能导致他们提交在自己计算机上可以运行,但由于缺少库而无法在所有其它电脑上运行的代码。Python 有一个旨在避免这种令人不愉快的惊讶的系统:虚拟环境。虚拟环境会故意忽略你已安装的所有 Python库,从而有效地迫使你一开始使用现有的 Python 进行开发。
|
||||
|
||||
为了用 **venv** 激活虚拟环境, 为你的环境取个名字 (我会用 **example**) 并且用下面的指令创建它:
|
||||
|
||||
```
|
||||
`$ python3 -m venv example`
|
||||
```
|
||||
|
||||
Source 环境的 **bin** 目录里的 **activate** 文件以激活它:
|
||||
|
||||
```
|
||||
$ source ./example/bin/activate
|
||||
(example) $
|
||||
```
|
||||
|
||||
你现在位于你的虚拟环境中。这是一个干净的状态,你可以在其中构建针对问题的自定义解决方案-额外增加了自觉需要安装依赖库的负担。
|
||||
|
||||
### 安装 Pandas 和 NumPy
|
||||
|
||||
您必须在新环境中安装的第一个库是 Pandas 和 NumPy。这些库在数据科学中很常见,因此这不是你最后一次安装它们。它们也不是你在数据科学中唯一需要的库,但是它们是一个好的开始。
|
||||
|
||||
Pandas 是使用 BSD 许可证的开源库,可轻松处理数据结构以进行分析。它依赖于 NumPy,这是一个提供多维数组,线性代数和傅立叶变换等等的科学库。使用 **pip3** 安装两者:
|
||||
|
||||
```
|
||||
`(example) $ pip3 install pandas`
|
||||
```
|
||||
|
||||
安装 Pandas 还会安装 NumPy,因此你无需同时指定两者。一旦将它们安装到虚拟环境中,安装包就会被缓存,这样,当你再次安装它们时,就不必从因特网下载它们。
|
||||
|
||||
这些是你现在仅需的库。接下来,你需要一些样本数据。
|
||||
|
||||
### 生成样本数据集
|
||||
|
||||
数据科学都是关于数据的,幸运的是,科学、计算和政府组织可以提供许多免费和开放的数据集。虽然这些数据集是用于教育的重要资源,但它们具有比此简单示例所需的数据更多的数据。你可以使用 Python 快速创建示例和可管理的数据集:
|
||||
|
||||
|
||||
```python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import random
|
||||
|
||||
def rgb():
|
||||
NUMBER=random.randint(0,255)/255
|
||||
return NUMBER
|
||||
|
||||
FILE = open('sample.csv','w')
|
||||
FILE.write('"red","green","blue"')
|
||||
for COUNT in range(10):
|
||||
FILE.write('\n{:0.2f},{:0.2f},{:0.2f}'.format(rgb(),rgb(),rgb()))
|
||||
```
|
||||
|
||||
这将生成一个名为 **sample.csv** 的文件,该文件由随机生成的浮点数组成,这些浮点数在本示例中表示 RGB 值(在视觉效果中通常是数百个跟踪值)。你可以将 CSV 文件用作 Pandas 的数据源。
|
||||
|
||||
### 使用 Pandas 提取数据
|
||||
|
||||
Pandas 的基本功能之一是可以提取数据和处理数据而无需程序员编写仅用于解析输入的新函数。如果你习惯于自动执行此操作的应用程序,那么这似乎不是很特别,但请想象一下在 LibreOffice[6] 中打开 CSV 并且必须编写公式以在每个逗号处拆分值。Pandas 保护你免受此类低级操作的影响。以下是一些简单的代码,可用于提取和打印以逗号分隔的值的文件:
|
||||
|
||||
|
||||
```python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from pandas import read_csv, DataFrame
|
||||
import pandas as pd
|
||||
|
||||
FILE = open('sample.csv','r')
|
||||
DATAFRAME = pd.read_csv(FILE)
|
||||
print(DATAFRAME)
|
||||
```
|
||||
|
||||
一开始的几行导入 Pandas 库的组件。Pandas 库内容广泛,因此在寻找除本文中基本功能以外的功能时,你会经常参考它的文档。
|
||||
|
||||
接下来,通过打开你创建的 **sample.csv** 文件创建变量 **FILE**。Pandas 模块 **read_csv**(在第二行中导入)使用该变量来创建 _dataframe_。在 Pandas 中,数据帧(dataframe)是二维数组,通常被认为是表格。数据放入数据帧中后,你可以按列和行进行操作,查询其范围,然后执行更多操作。目前,示例代码仅将数据帧输出到终端。
|
||||
|
||||
运行代码。你的输出会和下面的输出有些许不同,因为这些数字都是随机生成的,但是格式都是一样的。
|
||||
|
||||
|
||||
```
|
||||
(example) $ python3 ./parse.py
|
||||
red green blue
|
||||
0 0.31 0.96 0.47
|
||||
1 0.95 0.17 0.64
|
||||
2 0.00 0.23 0.59
|
||||
3 0.22 0.16 0.42
|
||||
4 0.53 0.52 0.18
|
||||
5 0.76 0.80 0.28
|
||||
6 0.68 0.69 0.46
|
||||
7 0.75 0.52 0.27
|
||||
8 0.53 0.76 0.96
|
||||
9 0.01 0.81 0.79
|
||||
```
|
||||
|
||||
假设你只需要数据集中的红色值,你可以通过声明数据帧的列名称并有选择地仅打印你感兴趣的列来做到这一点:
|
||||
|
||||
|
||||
```python
|
||||
from pandas import read_csv, DataFrame
|
||||
import pandas as pd
|
||||
|
||||
FILE = open('sample.csv','r')
|
||||
DATAFRAME = pd.read_csv(FILE)
|
||||
|
||||
# define columns
|
||||
DATAFRAME.columns = [ 'red','green','blue' ]
|
||||
|
||||
print(DATAFRAME['red'])
|
||||
```
|
||||
|
||||
现在运行代码,你只会得到红色列:
|
||||
|
||||
|
||||
```
|
||||
(example) $ python3 ./parse.py
|
||||
0 0.31
|
||||
1 0.95
|
||||
2 0.00
|
||||
3 0.22
|
||||
4 0.53
|
||||
5 0.76
|
||||
6 0.68
|
||||
7 0.75
|
||||
8 0.53
|
||||
9 0.01
|
||||
Name: red, dtype: float64
|
||||
```
|
||||
|
||||
处理数据表是习惯使用 Pandas 解析数据的好方法。从数据帧中选择数据的方法有很多,你尝试的次数越多就越自然。
|
||||
|
||||
### 可视化你的数据
|
||||
|
||||
很多人偏爱可视化信息已不是什么秘密,这是图表和图形成为与高层管理人员开会的主要内容的原因,也是“图表”在新闻界如此流行的原因。数据科学家的工作之一是帮助其他人理解大量数据样本,并且有一些库可以帮助你完成这项任务。将 Pandas 与可视化库结合使用可以对数据进行可视化解释。一个流行的可视化开源库是 [Seaborn][7],它基于开源的 [Matplotlib][3]。
|
||||
|
||||
#### 安装 Seaborn 和 Matplotlib
|
||||
|
||||
你的 Python 虚拟环境还没有 Seaborn 和 Matplotlib,所以用 pip3 安装它们。安装 Seaborn 的时候,也会安装 Matplotlib 和很多其它的库。
|
||||
|
||||
|
||||
```
|
||||
`(example) $ pip3 install seaborn`
|
||||
```
|
||||
|
||||
为了使 Matplotlib 显示图形,你还必须安装 [PyGObject][8] 和 [Pycairo][9]。这涉及到编译代码,只要你安装了必需的头文件和库,pip3 便可以为你执行此操作。你的 Python 虚拟环境不了解这些依赖库,因此你可以在环境内部或外部执行安装命令。
|
||||
|
||||
在 Fedora 和 CentOS 上:
|
||||
|
||||
|
||||
```
|
||||
(example) $ sudo dnf install -y gcc zlib-devel bzip2 bzip2-devel readline-devel \
|
||||
sqlite sqlite-devel openssl-devel tk-devel git python3-cairo-devel \
|
||||
cairo-gobject-devel gobject-introspection-devel
|
||||
```
|
||||
|
||||
在 Ubuntu 和 Debian 上:
|
||||
|
||||
|
||||
```
|
||||
(example) $ sudo apt install -y libgirepository1.0-dev build-essential \
|
||||
libbz2-dev libreadline-dev libssl-dev zlib1g-dev libsqlite3-dev wget \
|
||||
curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libcairo2-dev
|
||||
```
|
||||
|
||||
一旦它们安装好了,你可以安装 Matplotlib 需要的 GUI 组件。
|
||||
|
||||
|
||||
```
|
||||
`(example) $ pip3 install PyGObject pycairo`
|
||||
```
|
||||
|
||||
### 用 Seaborn 和 Matplotlib 显示图形
|
||||
|
||||
在你最喜欢的文本编辑器打开一个叫 **vizualize.py** 的文件。要创建数据的线形图可视化,首先,你必须导入必要的 Python 模块:先前代码示例中使用的 Pandas 模块:
|
||||
|
||||
|
||||
```python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from pandas import read_csv, DataFrame
|
||||
import pandas as pd
|
||||
```
|
||||
|
||||
接下来,导入 Seaborn,Matplotlib 和 Matplotlib 的几个组件,以便你可以配置生成的图形:
|
||||
|
||||
|
||||
```python
|
||||
import seaborn as sns
|
||||
import matplotlib
|
||||
import matplotlib.pyplot as plt
|
||||
from matplotlib import rcParams
|
||||
```
|
||||
|
||||
Matplotlib 可以将其输出导出为多种格式,包括 PDF,SVG 和桌面上的 GUI 窗口。对于此示例,将输出发送到桌面很有意义,因此必须将 Matplotlib 后端设置为 GTK3Agg。如果你不使用 Linux,则可能需要使用 TkAgg 后端。
|
||||
|
||||
设置完 GUI 窗口以后,设置窗口大小和 Seaborn 预设样式:
|
||||
|
||||
|
||||
```python
|
||||
matplotlib.use('GTK3Agg')
|
||||
rcParams['figure.figsize'] = 11,8
|
||||
sns.set_style('darkgrid')
|
||||
```
|
||||
|
||||
现在,你的显示已配置完毕,代码已经很熟悉了。使用 Pandas 导入 **sample.csv** 文件,并定义数据帧的列:
|
||||
|
||||
|
||||
```python
|
||||
FILE = open('sample.csv','r')
|
||||
DATAFRAME = pd.read_csv(FILE)
|
||||
DATAFRAME.columns = [ 'red','green','blue' ]
|
||||
```
|
||||
|
||||
有了适当格式的数据,你可以将其绘制在图形中。将每一列用作绘图的输入,然后使用 **plt.show()** 在 GUI 窗口中绘制图形。**plt.legend()** 参数将列标题与图形上的每一行关联(**loc** 参数将图例放置在图表之外而不是在图表上方):
|
||||
|
||||
|
||||
```python
|
||||
for i in DATAFRAME.columns:
|
||||
DATAFRAME[i].plot()
|
||||
|
||||
plt.legend(bbox_to_anchor=(1, 1), loc=2, borderaxespad=1)
|
||||
plt.show()
|
||||
```
|
||||
|
||||
运行代码以获得结果。
|
||||
|
||||
![第一个数据可视化][10]
|
||||
|
||||
你的图形可以准确显示 CSV 文件中包含的所有信息:值在 Y 轴上,索引号在 X 轴上,并且可以识别图形中的线,以便你知道它们代表什么。然而,由于此代码正在跟踪颜色值(至少是假装),所以线条的颜色不仅不直观,而且违反直觉。如果你永远不需要分析颜色数据,则可能永远不会遇到此问题,但是你一定会遇到类似的问题。在可视化数据时,你必须考虑呈现数据的最佳方法,以防止观看者从你呈现的内容中推断出虚假信息。
|
||||
|
||||
为了解决此问题(并展示一些可用的自定义设置),以下代码为每条绘制的线分配了特定的颜色:
|
||||
|
||||
|
||||
```python
|
||||
import matplotlib
|
||||
from pandas import read_csv, DataFrame
|
||||
import pandas as pd
|
||||
import seaborn as sns
|
||||
import matplotlib.pyplot as plt
|
||||
from matplotlib import rcParams
|
||||
|
||||
matplotlib.use('GTK3Agg')
|
||||
rcParams['figure.figsize'] = 11,8
|
||||
sns.set_style('whitegrid')
|
||||
|
||||
FILE = open('sample.csv','r')
|
||||
DATAFRAME = pd.read_csv(FILE)
|
||||
DATAFRAME.columns = [ 'red','green','blue' ]
|
||||
|
||||
plt.plot(DATAFRAME['red'],'r-')
|
||||
plt.plot(DATAFRAME['green'],'g-')
|
||||
plt.plot(DATAFRAME['blue'],'b-')
|
||||
plt.plot(DATAFRAME['red'],'ro')
|
||||
plt.plot(DATAFRAME['green'],'go')
|
||||
plt.plot(DATAFRAME['blue'],'bo')
|
||||
|
||||
plt.show()
|
||||
```
|
||||
|
||||
这使用特殊的 Matplotlib 表示法为每列创建两个图。每列的初始图分配有一种颜色(红色为 **r**,绿色为 **g**,蓝色为 **b**)。这些是内置的 Matplotlib 设置。 **-** 表示实线(双破折号,例如**r-**,将创建虚线)。为每个具有相同颜色的列创建第二个图,但是使用 **o** 表示点或节点。为了演示内置的 Seaborn 主题,请将 **sns.set_style** 的值更改为 **whitegrid**。
|
||||
|
||||
![改进的数据可视化][11]
|
||||
|
||||
### 停用你的虚拟环境
|
||||
|
||||
探索完 Pandas 和绘图后,可以使用 **deactivate** 命令停用 Python 虚拟环境:
|
||||
|
||||
|
||||
```
|
||||
(example) $ deactivate
|
||||
$
|
||||
```
|
||||
|
||||
当你想重新使用它时,只需像在本文开始时一样重新激活它即可。重新激活虚拟环境时,你必须重新安装模块,但是它们是从缓存安装的,而不是从因特网下载的,因此你不必在线。
|
||||
|
||||
### 无尽的可能性
|
||||
|
||||
Pandas,Matplotlib,Seaborn 和数据科学的真正力量是无穷的潜力,使你能够以有意义和启发性的方式解析,解释和组织数据。下一步是使用你在本文中学到的新工具探索简单的数据集。Matplotlib 和 Seaborn 不仅有折线图,还有很多其他功能,因此,请尝试创建条形图或饼图或完全不一样的东西。
|
||||
|
||||
一旦你了解了你的工具集并对如何关联数据有了一些想法,则可能性是无限的。数据科学是寻找隐藏在数据中的故事的新方法。让开源成为你的媒体。
|
||||
|
||||
数据可视化是一种获取表格或空间数据并传达给人类的方式-...
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/9/get-started-data-science-python
|
||||
|
||||
作者:[Seth Kenlon][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[GraveAccent](https://github.com/graveaccent)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/sethhttps://opensource.com/users/jroakeshttps://opensource.com/users/tiwarinitish86
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/metrics_graph_stats_blue.png?itok=OKCc_60D (Metrics and a graph illustration)
|
||||
[2]: https://pandas.pydata.org/
|
||||
[3]: https://matplotlib.org/
|
||||
[4]: https://seaborn.pydata.org/index.html
|
||||
[5]: https://opensource.com/article/17/10/python-101
|
||||
[6]: http://libreoffice.org
|
||||
[7]: https://seaborn.pydata.org/
|
||||
[8]: https://pygobject.readthedocs.io/en/latest/getting_started.html
|
||||
[9]: https://pycairo.readthedocs.io/en/latest/
|
||||
[10]: https://opensource.com/sites/default/files/uploads/seaborn-matplotlib-graph_0.png (First data visualization)
|
||||
[11]: https://opensource.com/sites/default/files/uploads/seaborn-matplotlib-graph_1.png (Improved data visualization)
|
@ -1,136 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Introduction to the Linux chgrp and newgrp commands)
|
||||
[#]: via: (https://opensource.com/article/19/9/linux-chgrp-and-newgrp-commands)
|
||||
[#]: author: (Alan Formy-Duval https://opensource.com/users/alanfdosshttps://opensource.com/users/sethhttps://opensource.com/users/alanfdosshttps://opensource.com/users/seth)
|
||||
|
||||
Linux chgrp 和 newgrp 命令简介
|
||||
======
|
||||
chgrp 和 newgrp 命令可帮助你管理需要维护组所有权的文件。
|
||||
![Penguins walking on the beach ][1]
|
||||
|
||||
在最近的一篇文章中,我介绍了 [chown][2] 命令,它用于修改系统上的文件所有权。回想一下,所有权是分配一个对象的用户和组的组合。**chgrp** 和 **newgrp** 命令为管理需要维护组所有权的文件提供了帮助。
|
||||
|
||||
### 使用 chgrp
|
||||
|
||||
**chgrp** 只是更改文件的组所有权。这与 **chown :<group>** 命令相同。你可以使用:
|
||||
|
||||
|
||||
```
|
||||
`$chown :alan mynotes`
|
||||
```
|
||||
|
||||
或者:
|
||||
|
||||
|
||||
```
|
||||
`$chgrp alan mynotes`
|
||||
```
|
||||
|
||||
#### 递归
|
||||
|
||||
chgrp 的一些其他参数在命令行和脚本中都可能有用。就像许多其他 Linux 命令一样,chgrp 有一个递归参数 **-R**。如下所示,你需要它来对文件夹及其内容进行递归操作。我加了 **-v**(**verbose**)参数,因此 chgrp 会告诉我它在做什么:
|
||||
|
||||
|
||||
```
|
||||
$ ls -l . conf
|
||||
.:
|
||||
drwxrwxr-x 2 alan alan 4096 Aug 5 15:33 conf
|
||||
|
||||
conf:
|
||||
-rw-rw-r-- 1 alan alan 0 Aug 5 15:33 conf.xml
|
||||
# chgrp -vR delta conf
|
||||
changed group of 'conf/conf.xml' from alan to delta
|
||||
changed group of 'conf' from alan to delta
|
||||
```
|
||||
|
||||
#### 引用
|
||||
|
||||
引用文件 (**\--reference=RFILE**) 可用于更改匹配特定配置的文件的组,或者当你不知道组,比如你运行一个脚本时。你可以复制另外一个文件的组 (**RFILE**)。比如,为了撤销上面的更改 (请注意,点 [**.**] 指向当前工作目录):
|
||||
|
||||
```
|
||||
`$ chgrp -vR --reference=. conf`
|
||||
```
|
||||
|
||||
#### 报告更改
|
||||
|
||||
大多数命令都有用于控制其输出的参数。最常见的是 **-v** 来启用详细信息,并且 chgrp 命令拥有详细模式。它还具有 **-c**(**\--changes**)参数,表示 chgrp 仅在进行更改时报告。chgrp 还能报告其他内容,例如是否有不允许的操作。
|
||||
|
||||
参数 **-f**(**\--silent**、**\--quiet**)用于禁止显示大部分错误消息。我将在下一节中使用此参数和 **-c** 来显示实际更改。
|
||||
|
||||
#### 保留根目录
|
||||
|
||||
Linux 文件系统的根目录 (** / **) 应该受到高度重视。如果命令在此犯了一个错误,那么后果可能是可怕的,并会让系统无法使用。尤其是在运行一个会递归修改甚至删除的命令时。chgrp 命令有一个可用于保护和保留根目录的参数。它是 **\--preserve-root**。如果在根目录中将此参数和递归一起使用,那么什么也不会发生,而是会出现一条消息:
|
||||
|
||||
|
||||
```
|
||||
[root@localhost /]# chgrp -cfR --preserve-root a+w /
|
||||
chgrp: it is dangerous to operate recursively on '/'
|
||||
chgrp: use --no-preserve-root to override this failsafe
|
||||
```
|
||||
|
||||
不与递归结合使用时,该选项无效。但是,如果该命令由 root 用户运行,那么 **/** 的权限将会更改,但其中的其他文件或目录的权限则不会被更改:
|
||||
|
||||
|
||||
```
|
||||
[alan@localhost /]$ chgrp -c --preserve-root alan /
|
||||
chgrp: changing group of '/': Operation not permitted
|
||||
[root@localhost /]# chgrp -c --preserve-root alan /
|
||||
changed group of '/' from root to alan
|
||||
```
|
||||
|
||||
令人惊讶的是,它似乎不是默认参数。选项 **\--no-preserve-root** 是默认的。如果你在不带 “preserve” 选项的情况下运行上述命令,那么它将默认为“无保留”模式,并可能会更改不应更改的文件的权限:
|
||||
|
||||
|
||||
```
|
||||
[alan@localhost /]$ chgrp -cfR alan /
|
||||
changed group of '/dev/pts/0' from tty to alan
|
||||
changed group of '/dev/tty2' from tty to alan
|
||||
changed group of '/var/spool/mail/alan' from mail to alan
|
||||
```
|
||||
|
||||
### 关于 newgrp
|
||||
|
||||
**newgrp** 命令允许用户覆盖当前的主要组。当你在所有文件必须有相同组所有权的目录中操作时,newgrp 会很方便。假设你的内网服务器上有一个名为 _share_ 的目录,不同的团队在其中存储营销照片。组名为 “share”。当不同的用户将文件放入目录时,文件的主要组可能会变得混乱。每当添加新文件时,你都可以运行 **chgrp** 将错乱的组纠正为 **share**:
|
||||
|
||||
|
||||
```
|
||||
$ cd share
|
||||
ls -l
|
||||
-rw-r--r--. 1 alan share 0 Aug 7 15:35 pic13
|
||||
-rw-r--r--. 1 alan alan 0 Aug 7 15:35 pic1
|
||||
-rw-r--r--. 1 susan delta 0 Aug 7 15:35 pic2
|
||||
-rw-r--r--. 1 james gamma 0 Aug 7 15:35 pic3
|
||||
-rw-rw-r--. 1 bill contract 0 Aug 7 15:36 pic4
|
||||
```
|
||||
|
||||
我在 [**chmod** 命令][3]的文章中介绍了 **setgid**模式。它是解决此问题的一种方法。但是,假设由于某种原因未设置 setgid 位。newgrp 命令在此时很有用。在任何用户将文件放入 _share_ 目录之前,他们可以运行命令 **newgrp share**。这会将其主要组切换为 “share”,因此他们放入目录中的所有文件都将有 “share” 组,而不是用户的主要组。完成后,用户可以使用以下命令切换回常规主要组:
|
||||
|
||||
|
||||
```
|
||||
`newgrp alan`
|
||||
```
|
||||
|
||||
### 总结
|
||||
|
||||
了解如何管理用户、组和权限非常重要。最好知道一些替代方法来解决可能遇到的问题,因为并非所有环境都以相同的方式设置。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/9/linux-chgrp-and-newgrp-commands
|
||||
|
||||
作者:[Alan Formy-Duval][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/alanfdosshttps://opensource.com/users/sethhttps://opensource.com/users/alanfdosshttps://opensource.com/users/seth
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/community-penguins-osdc-lead.png?itok=BmqsAF4A (Penguins walking on the beach )
|
||||
[2]: https://opensource.com/article/19/8/linux-chown-command
|
||||
[3]: https://opensource.com/article/19/8/linux-chmod-command
|
Loading…
Reference in New Issue
Block a user