mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-28 23:20:10 +08:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
210f3f67c9
@ -0,0 +1,104 @@
|
||||
[#]: subject: (Wrong Time Displayed in Windows-Linux Dual Boot Setup? Here’s How to Fix it)
|
||||
[#]: via: (https://itsfoss.com/wrong-time-dual-boot/)
|
||||
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13276-1.html)
|
||||
|
||||
如何解决 Windows-Linux 双启动设置中显示时间错误的问题
|
||||
======
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/202104/08/102102xaup3iofozn2uvbf.jpg)
|
||||
|
||||
如果你 [双启动 Windows 和 Ubuntu][1] 或任何其他 Linux 发行版,你可能会注意到两个操作系统之间的时间差异。
|
||||
|
||||
当你 [使用 Linux][2] 时,它会显示正确的时间。但当你进入 Windows 时,它显示的时间是错误的。有时,情况正好相反,Linux 显示的是错误的时间,而 Windows 的时间是正确的。
|
||||
|
||||
特别奇怪的是,因为你已连接到互联网,并且已将日期和时间设置为自动使用。
|
||||
|
||||
别担心!你并不是唯一一个遇到这种问题的人。你可以在 Linux 终端上使用以下命令来解决这个问题:
|
||||
|
||||
```
|
||||
timedatectl set-local-rtc 1
|
||||
```
|
||||
|
||||
同样,不要担心。我会解释为什么你在双启动设置中会遇到时间差。我会向你展示上面的命令是如何修复 Windows 双启动后的时间错误问题的。
|
||||
|
||||
### 为什么 Windows 和 Linux 在双启动时显示不同的时间?
|
||||
|
||||
一台电脑有两个主要时钟:系统时钟和硬件时钟。
|
||||
|
||||
硬件时钟也叫 RTC([实时时钟][3])或 CMOS/BIOS 时钟。这个时钟在操作系统之外,在电脑的主板上。即使在你的系统关机后,它也会继续运行。
|
||||
|
||||
系统时钟是你在操作系统内看到的。
|
||||
|
||||
当计算机开机时,硬件时钟被读取并用于设置系统时钟。之后,系统时钟被用于跟踪时间。如果你的操作系统对系统时钟做了任何改变,比如改变时区等,它就会尝试将这些信息同步到硬件时钟上。
|
||||
|
||||
默认情况下,Linux 认为硬件时钟中存储的时间是 UTC,而不是本地时间。另一方面,Windows 认为硬件时钟上存储的时间是本地时间。这就是问题的开始。
|
||||
|
||||
让我用例子来解释一下。
|
||||
|
||||
你看我在加尔各答 UTC+5:30 时区。安装后,当我把 [Ubuntu 中的时区][4] 设置为加尔各答时区时,Ubuntu 会把这个时间信息同步到硬件时钟上,但会有 5:30 的偏移,因为对于 Linux 来说它必须是 UTC。
|
||||
|
||||
假设加尔各答时区的当前时间是 15:00,这意味着 UTC 时间是 09:30。
|
||||
|
||||
现在当我关闭系统并启动到 Windows 时,硬件时钟有 UTC 时间(本例中为 09:30)。但是 Windows 认为硬件时钟已经存储了本地时间。因此,它改变了系统时钟(应该显示为 15:00),而使用 UTC 时间(09:30)作为本地时间。因此,Windows 显示时间为 09:30,这比实际时间(我们的例子中为 15:00)早了 5:30。
|
||||
|
||||
![][5]
|
||||
|
||||
同样,如果我在 Windows 中通过自动时区和时间按钮来设置正确的时间,你知道会发生什么吗?现在它将在系统上显示正确的时间(15:00),并将此信息(注意图片中的“同步你的时钟”选项)同步到硬件时钟。
|
||||
|
||||
如果你启动到 Linux,它会从硬件时钟读取时间,而硬件时钟是当地时间(15:00),但由于 Linux 认为它是 UTC 时间,所以它在系统时钟上增加了 5:30 的偏移。现在 Linux 显示的时间是 20:30,比实际时间超出晚了 5:30。
|
||||
|
||||
现在你了解了双启动中时差问题的根本原因,是时候看看如何解决这个问题了。
|
||||
|
||||
### 修复 Windows 在 Linux 双启动设置中显示错误时间的问题
|
||||
|
||||
有两种方法可以处理这个问题:
|
||||
|
||||
* 让 Windows 将硬件时钟作为 UTC 时间
|
||||
* 让 Linux 将硬件时钟作为本地时间
|
||||
|
||||
在 Linux 中进行修改是比较容易的,因此我推荐使用第二种方法。
|
||||
|
||||
现在 Ubuntu 和大多数其他 Linux 发行版都使用 systemd,因此你可以使用 `timedatectl` 命令来更改设置。
|
||||
|
||||
你要做的是告诉你的 Linux 系统将硬件时钟(RTC)作为本地时间。你可以通过 `set-local-rtc` (为 RTC 设置本地时间)选项来实现:
|
||||
|
||||
```
|
||||
timedatectl set-local-rtc 1
|
||||
```
|
||||
|
||||
如下图所示,RTC 现在使用本地时间。
|
||||
|
||||
![][6]
|
||||
|
||||
现在如果你启动 Windows,它把硬件时钟当作本地时间,而这个时间实际上是正确的。当你在 Linux 中启动时,你的 Linux 系统知道硬件时钟使用的是本地时间,而不是 UTC。因此,它不会尝试添加这个时间的偏移。
|
||||
|
||||
这就解决了 Linux 和 Windows 双启动时的时差问题。
|
||||
|
||||
你会看到一个关于 RTC 不使用本地时间的警告。对于桌面设置,它不应该引起任何问题。至少,我想不出有什么问题。
|
||||
|
||||
希望我把事情给你讲清楚了。如果你还有问题,请在下面留言。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/wrong-time-dual-boot/
|
||||
|
||||
作者:[Abhishek Prakash][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/abhishek/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://itsfoss.com/install-ubuntu-1404-dual-boot-mode-windows-8-81-uefi/
|
||||
[2]: https://itsfoss.com/why-use-linux/
|
||||
[3]: https://www.computerhope.com/jargon/r/rtc.htm
|
||||
[4]: https://itsfoss.com/change-timezone-ubuntu/
|
||||
[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/03/set-time-windows.jpg?resize=800%2C491&ssl=1
|
||||
[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/03/set-local-time-for-rtc-ubuntu.png?resize=800%2C490&ssl=1
|
@ -3,16 +3,18 @@
|
||||
[#]: author: "Bill Dyer https://itsfoss.com/author/bill/"
|
||||
[#]: collector: "lujun9972"
|
||||
[#]: translator: "lxbwolf"
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
[#]: reviewer: "wxy"
|
||||
[#]: publisher: "wxy"
|
||||
[#]: url: "https://linux.cn/article-13274-1.html"
|
||||
|
||||
在 Linux 中把多个 Markdown 文件转换成 HTML 或其他格式
|
||||
======
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/202104/07/095441bztj6cz68j89568u.jpg)
|
||||
|
||||
很多时候我与 Markdown 打交道的方式是,先写完一个文件,然后把它转换成 HTML 或其他格式。也有些时候,需要创建一些新的文件。当我要写多个 Markdown 文件时,通常要把他们全部写完之后才转换它们。
|
||||
|
||||
我用 pandoc 来转换文件,它可以一次性地转换所有 Markdown 文件。
|
||||
我用 `pandoc` 来转换文件,它可以一次性地转换所有 Markdown 文件。
|
||||
|
||||
Markdown 格式的文件可以转换成 .html 文件,有时候我需要把它转换成其他格式,如 epub,这个时候 [pandoc][1] 就派上了用场。我更喜欢用命令行,因此本文我会首先介绍它,然而你还可以使用 [VSCodium][2] 在非命令行下完成转换。后面我也会介绍它。
|
||||
|
||||
@ -24,7 +26,7 @@ Markdown 格式的文件可以转换成 .html 文件,有时候我需要把它
|
||||
sudo apt-get install pandoc
|
||||
```
|
||||
|
||||
本例中,在名为 md_test 目录下我有四个 Markdown 文件需要转换。
|
||||
本例中,在名为 `md_test` 目录下我有四个 Markdown 文件需要转换。
|
||||
|
||||
```
|
||||
[email protected]:~/Documents/md_test$ ls -l *.md
|
||||
@ -35,20 +37,18 @@ sudo apt-get install pandoc
|
||||
[email protected]:~/Documents/md_test$
|
||||
```
|
||||
|
||||
现在还没有 HTML 文件。现在我要对这些文件使用 pandoc。我会运行一行命令来实现:
|
||||
现在还没有 HTML 文件。现在我要对这些文件使用 `pandoc`。我会运行一行命令来实现:
|
||||
|
||||
* 调用 pandoc
|
||||
* 调用 `pandoc`
|
||||
* 读取 .md 文件并导出为 .html
|
||||
|
||||
|
||||
|
||||
下面是我要运行的命令:
|
||||
|
||||
```
|
||||
for i in *.md ; do echo "$i" && pandoc -s $i -o $i.html ; done
|
||||
```
|
||||
|
||||
如果你不太理解上面的命令中的 `;`,可以参考[在 Linux 中一次执行多个命令][3]。
|
||||
如果你不太理解上面的命令中的 `;`,可以参考 [在 Linux 中一次执行多个命令][3]。
|
||||
|
||||
我执行命令后,运行结果如下:
|
||||
|
||||
@ -74,34 +74,22 @@ file04.md
|
||||
|
||||
转换很成功,现在你已经有了四个 HTML 文件,它们可以用在 Web 服务器上。
|
||||
|
||||
pandoc 功能相当多,你可以通过指定输出文件的扩展名来把 markdown 文件转换成其他支持的格式。不难理解它为什么会被认为是[最好的写作开源工具][4]。
|
||||
|
||||
**推荐阅读:**
|
||||
|
||||
![][5]
|
||||
|
||||
#### [Linux 下 11 个最好的 Markdown 编辑器][6]
|
||||
|
||||
列出了 Linux 不同发行版本下好看且功能多样的最好的 Markdown 编辑器。
|
||||
pandoc 功能相当多,你可以通过指定输出文件的扩展名来把 Markdown 文件转换成其他支持的格式。不难理解它为什么会被认为是[最好的写作开源工具][4]。
|
||||
|
||||
### 使用 VSCodium 把 Markdown 文件转换成 HTML(GUI 方式)
|
||||
|
||||
就像我们前面说的那样,我通常使用命令行,但是对于批量转换,我不会使用命令行,你也不必。VSCode 或 [VSCodium][7] 可以完成批量操作。你只需要安装一个 _Markdown-All-in-One_ 扩展,就可以在一次运行中转换多个 Markdown 文件。
|
||||
就像我们前面说的那样,我通常使用命令行,但是对于批量转换,我不会使用命令行,你也不必。VSCode 或 [VSCodium][7] 可以完成批量操作。你只需要安装一个 Markdown-All-in-One 扩展,就可以在一次运行中转换多个 Markdown 文件。
|
||||
|
||||
有两种方式安装这个扩展:
|
||||
|
||||
* VSCodium 的终端
|
||||
* VSCodium 的插件管理器
|
||||
|
||||
|
||||
|
||||
通过 VSCodium 的终端安装该扩展:
|
||||
|
||||
1. 点击菜单栏的 `终端`。会打开终端面板
|
||||
2. 输入,或[复制下面的命令并粘贴到终端][8]:
|
||||
|
||||
|
||||
|
||||
```
|
||||
codium --install-extension yzhang.markdown-all-in-one
|
||||
```
|
||||
@ -113,9 +101,7 @@ codium --install-extension yzhang.markdown-all-in-one
|
||||
第二种安装方式是通过 VSCodium 的插件/扩展管理器:
|
||||
|
||||
1. 点击 VSCodium 窗口左侧的块区域。会出现一个扩展列表,列表最上面有一个搜索框。
|
||||
2. 在搜索框中输入 `Markdown All in One`。在列表最上面会出现该扩展。点击 `安装` 按钮来安装它。如果你已经安装过,在安装按钮的位置会出现一个齿轮图标。
|
||||
|
||||
|
||||
2. 在搜索框中输入 “Markdown All in One”。在列表最上面会出现该扩展。点击 “安装” 按钮来安装它。如果你已经安装过,在安装按钮的位置会出现一个齿轮图标。
|
||||
|
||||
![][10]
|
||||
|
||||
@ -123,7 +109,7 @@ codium --install-extension yzhang.markdown-all-in-one
|
||||
|
||||
点击 VSCodium 窗口左侧的纸张图标。你可以选择文件夹。打开文件夹后,你需要打开至少一个文件。你也可以打开多个文件,但是最少打开一个。
|
||||
|
||||
当打开文件后,按下 `CTRL+SHIFT+P` 唤起命令面板。然后,在出现的搜索框中输入 `Markdown`。当你输入时,会出现一列 Markdown 相关的命令。其中有一个是 `Markdown All in One: Print documents to HTML` 命令。点击它:
|
||||
当打开文件后,按下 `CTRL+SHIFT+P` 唤起命令面板。然后,在出现的搜索框中输入 `Markdown`。当你输入时,会出现一列 Markdown 相关的命令。其中有一个是 `Markdown All in One: Print documents to HTML` 命令。点击它:
|
||||
|
||||
![][11]
|
||||
|
||||
@ -140,7 +126,7 @@ via: https://itsfoss.com/convert-markdown-files/
|
||||
作者:[Bill Dyer][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[lxbwolf](https://github.com/lxbwolf)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
@ -1,71 +0,0 @@
|
||||
[#]: subject: (5 signs you might be a Rust programmer)
|
||||
[#]: via: (https://opensource.com/article/21/3/rust-programmer)
|
||||
[#]: author: (Mike Bursell https://opensource.com/users/mikecamel)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
5 signs you might be a Rust programmer
|
||||
======
|
||||
During my journey to learning Rust, I've noticed a few common behaviors
|
||||
of fellow Rustaceans.
|
||||
![name tag that says hello my name is open source][1]
|
||||
|
||||
I'm a fairly recent [convert to Rust][2], which I started to learn around the end of April 2020. But, like many converts, I'm an enthusiastic evangelist. I'm also not a very good Rustacean, truth be told, in that my coding style isn't great, and I don't write particularly idiomatic Rust. I suspect this is partly because I never really finished learning Rust before diving in and writing quite a lot of code (some of which is coming back to haunt me) and partly because I'm just not that good a programmer.
|
||||
|
||||
But I love Rust, and so should you. It's friendly—well, more friendly than C or C++; it's ready for low-level systems tasks—more so than Python, it's well-structured—more than Perl; and, best of all, it's completely open source from the design level up—much more than Java, for instance.
|
||||
|
||||
Despite my lack of expertise, I noticed a few things that I suspect are common to many Rust enthusiasts and programmers. If you say "yes" to the following five signs (the first of which was sparked by some exciting recent news), you, too, might be a Rust programmer.
|
||||
|
||||
### 1\. The word "foundation" excites you
|
||||
|
||||
For Rust programmers, the word "foundation" will no longer be associated first and foremost with Isaac Asimov but with the newly formed [Rust Foundation][3]. Microsoft, Huawei, Google, AWS, and Mozilla are providing the directors (and presumably most of the initial funding) for the Foundation, which will look after all aspects of the language, "heralding Rust's arrival as an enterprise production-ready technology," [according to interim executive director][4] Ashley Williams. (On a side note, it's great to see a woman heading up such a major industry initiative.)
|
||||
|
||||
The Foundation seems committed to safeguarding the philosophy of Rust and ensuring that everybody has the opportunity to get involved. Rust is, in many ways, a poster-child example of an open source project. Not that it's perfect (neither the language nor the community), but in that there seem to be sufficient enthusiasts who are dedicated to preserving the high-involvement, low-bar approach to community, which I think of as core to much of open source. I strongly welcome the move, which I think can only help promote Rust's adoption and maturity over the coming years and months.
|
||||
|
||||
### 2\. You get frustrated by newsfeed references to Rust (the game)
|
||||
|
||||
There's another computer-related thing out there that goes by the name "Rust," and it's a "multi-player only survival video game." It's newer than Rust the language (having been announced in 2013 and released in 2018), but I was once searching for Rust-related swag and made the mistake of searching for the game by that name. The interwebs being what they are, this meant that my news feed is now infected with this alternative Rust beast, and I now get random updates from their fandom and PR folks. This is low-key annoying, but I'm pretty sure I'm not alone in the Rust (language) community. I strongly suggest that if you _do_ want to find out more about this upstart in the computing world, you use a privacy-improving (I refuse to say "privacy-preserving") [open source browser][5] to do your research.
|
||||
|
||||
### 3\. The word "unsafe" makes you recoil in horror
|
||||
|
||||
Rust (the language, again) does a _really_ good job of helping you do the Right Thing™, certainly in terms of memory safety, which is a major concern within C and C++ (not because it's impossible but because it's really hard to get right consistently). Dave Herman wrote a post in 2016 on why safety is such a positive attribute of the Rust language: [_Safety is Rust's fireflower_][6]. Safety (memory, type safety) may not be glamourous, but it's something you become used to—and grateful for—as you write more Rust, particularly if you're involved in any systems programming, which is where Rust often excels.
|
||||
|
||||
Now, Rust doesn't _stop_ you from doing the Wrong Thing™, but it does make you make a conscious decision when you wish to go outside the bounds of safety by making you use the `unsafe` keyword. This is good not only for you, as it will (hopefully) make you think really, really carefully about what you're putting in any code block that uses it; it is also good for anyone reading your code. It's a trigger-word that makes any half-sane Rustacean shiver at least slightly, sit upright in their chair, and think, "hmm, what's going on here? I need to pay special attention." If you're lucky, the person reading your code may be able to think of ways of rewriting it such that it _does_ make use of Rust's safety features or at least reduces the amount of unsafe code that gets committed and released.
|
||||
|
||||
### 4\. You wonder why there's no emoji for `?;` or `{:?}` or `::<>`
|
||||
|
||||
Everybody loves (to hate) the turbofish (`::<>`) but there are other semantic constructs that you see regularly in Rust code. In particular, `{:?}` (for string formatting) and `?;` (`?` is a way of propagating errors up the calling stack, and `;` ends the line/block, so you often see them together). They're so common in Rust code that you just learn to parse them as you go, and they're also so useful that I sometimes wonder why they've not made it into normal conversation, at least as emojis. There are probably others, too. What would be your suggestions?
|
||||
|
||||
### 5\. Clippy is your friend (and not an animated paperclip)
|
||||
|
||||
Clippy, the Microsoft animated paperclip, was a "feature" that Office users learned very quickly to hate and has become the starting point for many [memes][7]. On the other hand, `cargo clippy` is one of those [amazing Cargo commands][8] that should become part of every Rust programmer's toolkit. Clippy is a language linter and helps improve your code to make it cleaner, tidier, more legible, more idiomatic, and generally less embarrassing when you share it with your colleagues or the rest of the world. Cargo has arguably rehabilitated the name "Clippy," and although it's not something I'd choose to name one of my kids, I don't feel a sense of unease whenever I come across the term on the web anymore.
|
||||
|
||||
* * *
|
||||
|
||||
_This article was originally published on [Alice, Eve, and Bob][9] and is reprinted with the author's permission._
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/3/rust-programmer
|
||||
|
||||
作者:[Mike Bursell][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/mikecamel
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/EDU_OSDC_IntroOS_520x292_FINAL.png?itok=woiZamgj (name tag that says hello my name is open source)
|
||||
[2]: https://opensource.com/article/20/6/why-rust
|
||||
[3]: https://foundation.rust-lang.org/
|
||||
[4]: https://foundation.rust-lang.org/posts/2021-02-08-hello-world/
|
||||
[5]: https://opensource.com/article/19/7/open-source-browsers
|
||||
[6]: https://www.thefeedbackloop.xyz/safety-is-rusts-fireflower/
|
||||
[7]: https://knowyourmeme.com/memes/clippy
|
||||
[8]: https://opensource.com/article/20/11/commands-rusts-cargo
|
||||
[9]: https://aliceevebob.com/2021/02/09/5-signs-that-you-may-be-a-rust-programmer/
|
@ -2,7 +2,7 @@
|
||||
[#]: via: (https://itsfoss.com/plausible/)
|
||||
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
@ -1,190 +0,0 @@
|
||||
[#]: subject: (Why I love using the IPython shell and Jupyter notebooks)
|
||||
[#]: via: (https://opensource.com/article/21/3/ipython-shell-jupyter-notebooks)
|
||||
[#]: author: (Ben Nuttall https://opensource.com/users/bennuttall)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
Why I love using the IPython shell and Jupyter notebooks
|
||||
======
|
||||
Jupyter notebooks take the IPython shell to the next level.
|
||||
![Computer laptop in space][1]
|
||||
|
||||
The Jupyter project started out as IPython and the IPython Notebook. It was originally a Python-specific interactive shell and notebook environment, which later branched out to become language-agnostic, supporting Julia, Python, and R—and potentially anything else.
|
||||
|
||||
![Jupyter][2]
|
||||
|
||||
(Ben Nuttall, [CC BY-SA 4.0][3])
|
||||
|
||||
IPython is a Python shell—similar to what you get when you type `python` or `python3` at the command line—but it's more clever and more helpful. If you've ever typed a multi-line command into the Python shell and wanted to repeat it, you'll understand the frustration of having to scroll through your history one line at a time. With IPython, you can scroll back through whole blocks at a time while still being able to navigate line-by-line and edit parts of those blocks.
|
||||
|
||||
![iPython][4]
|
||||
|
||||
(Ben Nuttall, [CC BY-SA 4.0][3])
|
||||
|
||||
It has autocompletion and provides context-aware suggestions:
|
||||
|
||||
![iPython offers suggestions][5]
|
||||
|
||||
(Ben Nuttall, [CC BY-SA 4.0][3])
|
||||
|
||||
It pretty-prints by default:
|
||||
|
||||
![iPython pretty prints][6]
|
||||
|
||||
(Ben Nuttall, [CC BY-SA 4.0][3])
|
||||
|
||||
It even allows you to run shell commands:
|
||||
|
||||
![IPython shell commands][7]
|
||||
|
||||
(Ben Nuttall, [CC BY-SA 4.0][3])
|
||||
|
||||
It also provides helpful features like adding `?` to an object as a shortcut for running `help()` without breaking your flow:
|
||||
|
||||
![IPython help][8]
|
||||
|
||||
(Ben Nuttall, [CC BY-SA 4.0][3])
|
||||
|
||||
If you're using a virtual environment (see my post on [virtualenvwrapper][9], install it with pip in the environment):
|
||||
|
||||
|
||||
```
|
||||
`pip install ipython`
|
||||
```
|
||||
|
||||
To install it system-wide, you can use apt on Debian, Ubuntu, or Raspberry Pi:
|
||||
|
||||
|
||||
```
|
||||
`sudo apt install ipython3`
|
||||
```
|
||||
|
||||
or with pip:
|
||||
|
||||
|
||||
```
|
||||
`sudo pip3 install ipython`
|
||||
```
|
||||
|
||||
### Jupyter notebooks
|
||||
|
||||
Jupyter notebooks take the IPython shell to the next level. First of all, they're browser-based, not terminal-based. To get started, install `jupyter`.
|
||||
|
||||
If you're using a virtual environment, install it with pip in the environment:
|
||||
|
||||
|
||||
```
|
||||
`pip install jupyter`
|
||||
```
|
||||
|
||||
To install it system-wide, you can use apt on Debian, Ubuntu, or Raspberry Pi:
|
||||
|
||||
|
||||
```
|
||||
`sudo apt install jupyter-notebook`
|
||||
```
|
||||
|
||||
or with pip:
|
||||
|
||||
|
||||
```
|
||||
`sudo pip3 install jupyter`
|
||||
```
|
||||
|
||||
Launch the notebook with:
|
||||
|
||||
|
||||
```
|
||||
`jupyter notebook`
|
||||
```
|
||||
|
||||
This will open in your browser:
|
||||
|
||||
![Jupyter Notebook][10]
|
||||
|
||||
(Ben Nuttall, [CC BY-SA 4.0][3])
|
||||
|
||||
You can create a new Python 3 notebook using the **New** dropdown:
|
||||
|
||||
![Python 3 in Jupyter Notebook][11]
|
||||
|
||||
(Ben Nuttall, [CC BY-SA 4.0][3])
|
||||
|
||||
Now you can write and execute commands in the `In[ ]` fields. Use **Enter** for a newline within the block and **Shift+Enter** to execute:
|
||||
|
||||
![Executing commands in Jupyter][12]
|
||||
|
||||
(Ben Nuttall, [CC BY-SA 4.0][3])
|
||||
|
||||
You can edit and rerun blocks. You can reorder them, delete them, copy/paste, and so on. You can run blocks in any order—but be aware that any variables created will be in scope according to the time of execution, rather than the order they appear within the notebook. You can restart and clear output or restart and run all blocks from within the **Kernel** menu.
|
||||
|
||||
Using the `print` function will output every time. But if you only have a single statement that's not assigned or your last statement is unassigned, it will be output anyway:
|
||||
|
||||
![Jupyter output][13]
|
||||
|
||||
(Ben Nuttall, [CC BY-SA 4.0][3])
|
||||
|
||||
You can even refer to `In` and `Out` as indexable objects:
|
||||
|
||||
![Jupyter output][14]
|
||||
|
||||
(Ben Nuttall, [CC BY-SA 4.0][3])
|
||||
|
||||
All the IPython features are available and are often presented a little nicer, too:
|
||||
|
||||
![Jupyter supports IPython features][15]
|
||||
|
||||
(Ben Nuttall, [CC BY-SA 4.0][3])
|
||||
|
||||
You can even do inline plots using [Matplotlib][16]:
|
||||
|
||||
![Graphing in Jupyter Notebook][17]
|
||||
|
||||
(Ben Nuttall, [CC BY-SA 4.0][3])
|
||||
|
||||
Finally, you can save your notebooks and include them in Git repositories, and if you push to GitHub, they will render as completed notebooks—outputs, graphs, and all (as in [this example][18]):
|
||||
|
||||
![Saving Notebook to GitHub][19]
|
||||
|
||||
(Ben Nuttall, [CC BY-SA 4.0][3])
|
||||
|
||||
* * *
|
||||
|
||||
_This article originally appeared on Ben Nuttall's [Tooling Tuesday blog][20] and is reused with permission._
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/3/ipython-shell-jupyter-notebooks
|
||||
|
||||
作者:[Ben Nuttall][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/bennuttall
|
||||
[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://opensource.com/sites/default/files/uploads/jupyterpreview.png (Jupyter)
|
||||
[3]: https://creativecommons.org/licenses/by-sa/4.0/
|
||||
[4]: https://opensource.com/sites/default/files/uploads/ipython-loop.png (iPython)
|
||||
[5]: https://opensource.com/sites/default/files/uploads/ipython-suggest.png (iPython offers suggestions)
|
||||
[6]: https://opensource.com/sites/default/files/uploads/ipython-pprint.png (iPython pretty prints)
|
||||
[7]: https://opensource.com/sites/default/files/uploads/ipython-ls.png (IPython shell commands)
|
||||
[8]: https://opensource.com/sites/default/files/uploads/ipython-help.png (IPython help)
|
||||
[9]: https://opensource.com/article/21/2/python-virtualenvwrapper
|
||||
[10]: https://opensource.com/sites/default/files/uploads/jupyter-notebook-1.png (Jupyter Notebook)
|
||||
[11]: https://opensource.com/sites/default/files/uploads/jupyter-python-notebook.png (Python 3 in Jupyter Notebook)
|
||||
[12]: https://opensource.com/sites/default/files/uploads/jupyter-loop.png (Executing commands in Jupyter)
|
||||
[13]: https://opensource.com/sites/default/files/uploads/jupyter-cells.png (Jupyter output)
|
||||
[14]: https://opensource.com/sites/default/files/uploads/jupyter-cells-2.png (Jupyter output)
|
||||
[15]: https://opensource.com/sites/default/files/uploads/jupyter-help.png (Jupyter supports IPython features)
|
||||
[16]: https://matplotlib.org/
|
||||
[17]: https://opensource.com/sites/default/files/uploads/jupyter-graph.png (Graphing in Jupyter Notebook)
|
||||
[18]: https://github.com/piwheels/stats/blob/master/2020.ipynb
|
||||
[19]: https://opensource.com/sites/default/files/uploads/savenotebooks.png (Saving Notebook to GitHub)
|
||||
[20]: https://tooling.bennuttall.com/the-ipython-shell-and-jupyter-notebooks/
|
@ -1,104 +0,0 @@
|
||||
[#]: subject: (Wrong Time Displayed in Windows-Linux Dual Boot Setup? Here’s How to Fix it)
|
||||
[#]: via: (https://itsfoss.com/wrong-time-dual-boot/)
|
||||
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
Wrong Time Displayed in Windows-Linux Dual Boot Setup? Here’s How to Fix it
|
||||
======
|
||||
|
||||
If you [dual boot Windows and Ubuntu][1] or any other Linux distribution, you might have noticed a time difference between the two operating systems.
|
||||
|
||||
When you [use Linux][2], it shows the correct time. But when you boot into Windows, it shows the wrong time. Sometimes, it is the opposite and Linux shows the wrong time and Windows has the correct time.
|
||||
|
||||
That’s strange specially because you are connected to the internet and your date and time is set to be used automatically.
|
||||
|
||||
Don’t worry! You are not the only one to face this issue. You can fix it by using the following command in the Linux terminal:
|
||||
|
||||
```
|
||||
timedatectl set-local-rtc 1
|
||||
```
|
||||
|
||||
Again, don’t worry. I’ll explain why you encounter a time difference in a dual boot setup. I’ll show you how the above command fixes the wrong time issue in Windows after dual boot.
|
||||
|
||||
### Why Windows and Linux show different time in dual boot?
|
||||
|
||||
A computer has two main clocks: a system clock and a hardware clock.
|
||||
|
||||
A hardware clock which is also called RTC ([real time clock][3]) or CMOS/BIOS clock. This clock is outside the operating system, on your computer’s motherboard. It keeps on running even after your system is powered off.
|
||||
|
||||
The system clock is what you see inside your operating system.
|
||||
|
||||
When your computer is powered on, the hardware clock is read and used to set the system clock. Afterwards, the system clock is used for tracking time. If your operating system makes any changes to system clock, like changing time zone etc, it tries to sync this information to the hardware clock.
|
||||
|
||||
By default, Linux assumes that the time stored in the hardware clock is in UTC, not the local time. On the other hand, Windows thinks that the time stored on the hardware clock is local time. That’s where the trouble starts.
|
||||
|
||||
Let me explain with examples.
|
||||
|
||||
You see I am in Kolkata time zone which is UTC+5:30. After installing when I set the [timezon][4][e][4] [in Ubuntu][4] to the Kolkata time zone, Ubuntu syncs this time information to the hardware clock but with an offset of 5:30 because it has to be in UTC for Linux.
|
||||
|
||||
Let’ say the current time in Kolkata timezone is 15:00 which means that the UTC time is 09:30.
|
||||
|
||||
Now when I turn off the system and boot into Windows, the hardware clock has the UTC time (09:30 in this example). But Windows thinks the hardware clock has stored the local time. And thus it changes the system clock (which should have shown 15:00) to use the UTC time (09:30) as the local time. And hence, Windows shows 09:30 as the time which is 5:30 hours behind the actual time (15:00 in our example).
|
||||
|
||||
![][5]
|
||||
|
||||
Again, if I set the correct time in Windows by toggling the automatic time zone and time buttons, you know what is going to happen? Now it will show the correct time on the system (15:00) and sync this information (notice the “Synchronize your clock” option in the image) to the hardware clock.
|
||||
|
||||
If you boot into Linux, it reads the time from the hardware clock which is in local time (15:00) but since Linux believes it to be the UTC time, it adds an offset of 5:30 to the system clock. Now Linux shows a time of 20:30 which is 5:30 hours ahead of the actual time.
|
||||
|
||||
Now that you understand the root cause of the time difference issues in dual boot, it’s time to see how to fix the issue.
|
||||
|
||||
### Fixing Windows Showing Wrong Time in a Dual Boot Setup With Linux
|
||||
|
||||
There are two ways you can go about handling this issue:
|
||||
|
||||
* Make Windows use UTC time for the hardware clock
|
||||
* Make Linux use local time for the hardware clock
|
||||
|
||||
|
||||
|
||||
It is easier to make the changes in Linux and hence I’ll recommend going with the second method.
|
||||
|
||||
Ubuntu and most other Linux distributions use systemd these days and hence you can use timedatectl command to change the settings.
|
||||
|
||||
What you are doing is to tell your Linux system to use the local time for the hardware clock (RTC). You do that with the `set-local-rtc` (set local time for RTC) option:
|
||||
|
||||
```
|
||||
timedatectl set-local-rtc 1
|
||||
```
|
||||
|
||||
As you can notice in the image below, the RTC now uses the local time.
|
||||
|
||||
![][6]
|
||||
|
||||
Now if you boot into Windows, it takes the hardware clock to be as local time which is actually correct this time. When you boot into Linux, your Linux system knows that the hardware clock is using local time, not UTC. And hence, it doesn’t try to add the off-set this time.
|
||||
|
||||
This fixes the time difference issue between Linux and Windows in dual boot.
|
||||
|
||||
You see a warning about not using local time for RTC. For desktop setups, it should not cause any issues. At least, I cannot think of one.
|
||||
|
||||
I hope I made things clear for you. If you still have questions, please leave a comment below.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/wrong-time-dual-boot/
|
||||
|
||||
作者:[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/install-ubuntu-1404-dual-boot-mode-windows-8-81-uefi/
|
||||
[2]: https://itsfoss.com/why-use-linux/
|
||||
[3]: https://www.computerhope.com/jargon/r/rtc.htm
|
||||
[4]: https://itsfoss.com/change-timezone-ubuntu/
|
||||
[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/03/set-time-windows.jpg?resize=800%2C491&ssl=1
|
||||
[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/03/set-local-time-for-rtc-ubuntu.png?resize=800%2C490&ssl=1
|
179
sources/tech/20210405 Scaling Microservices on Kubernetes.md
Normal file
179
sources/tech/20210405 Scaling Microservices on Kubernetes.md
Normal file
@ -0,0 +1,179 @@
|
||||
[#]: subject: (Scaling Microservices on Kubernetes)
|
||||
[#]: via: (https://www.linux.com/news/scaling-microservices-on-kubernetes/)
|
||||
[#]: author: (Dan Brown https://training.linuxfoundation.org/announcements/scaling-microservices-on-kubernetes/)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
Scaling Microservices on Kubernetes
|
||||
======
|
||||
|
||||
_By Ashley Davis_
|
||||
|
||||
_*This article was originally published at [TheNewStack][1]_
|
||||
|
||||
Applications built on microservices can be scaled in multiple ways. We can scale them to support development by larger development teams and we can also scale them up for better performance. Our application can then have a higher capacity and can handle a larger workload.
|
||||
|
||||
Using microservices gives us granular control over the performance of our application. We can easily measure the performance of our microservices to find the ones that are performing poorly, are overworked, or are overloaded at times of peak demand. Figure 1 shows how we might use the [Kubernetes dashboard][2] to understand CPU and memory usage for our microservices.
|
||||
|
||||
<https://cdn.thenewstack.io/media/2021/03/748d12fb-image9.png>
|
||||
|
||||
_Figure 1: Viewing CPU and memory usage for microservices in the Kubernetes dashboard_
|
||||
|
||||
If we were using a monolith, however, we would have limited control over performance. We could vertically scale the monolith, but that’s basically it.
|
||||
|
||||
Horizontally scaling a monolith is much more difficult; and we simply can’t independently scale any of the “parts” of a monolith. This isn’t ideal, because it might only be a small part of the monolith that causes the performance problem. Yet, we would have to vertically scale the entire monolith to fix it. Vertically scaling a large monolith can be an expensive proposition.
|
||||
|
||||
Instead, with microservices, we have numerous options for scaling. For instance, we can independently fine-tune the performance of small parts of our system to eliminate bottlenecks and achieve the right mix of performance outcomes.
|
||||
|
||||
There are also many advanced ways we could tackle performance issues, but in this post, we’ll overview a handful of relatively simple techniques for scaling our microservices using [Kubernetes][3]:
|
||||
|
||||
1. Vertically scaling the entire cluster
|
||||
2. Horizontally scaling the entire cluster
|
||||
3. Horizontally scaling individual microservices
|
||||
4. Elastically scaling the entire cluster
|
||||
5. Elastically scaling individual microservices
|
||||
|
||||
|
||||
|
||||
Scaling often requires risky configuration changes to our cluster. For this reason, you shouldn’t try to make any of these changes directly to a production cluster that your customers or staff are depending on.
|
||||
|
||||
Instead, I would suggest that you create a new cluster and use **blue-green deployment**, or a similar deployment strategy, to buffer your users from risky changes to your infrastructure.
|
||||
|
||||
### **Vertically Scaling the Cluster**
|
||||
|
||||
As we grow our application, we might come to a point where our cluster generally doesn’t have enough compute, memory or storage to run our application. As we add new microservices (or replicate existing microservices for redundancy), we will eventually max out the nodes in our cluster. (We can monitor this through our cloud vendor or the Kubernetes dashboard.)
|
||||
|
||||
At this point, we must increase the total amount of resources available to our cluster. When scaling microservices on a [Kubernetes cluster][4], we can just as easily make use of either vertical or horizontal scaling. Figure 2 shows what vertical scaling looks like for Kubernetes.
|
||||
|
||||
<https://cdn.thenewstack.io/media/2021/03/00c4f89c-image8.png>
|
||||
|
||||
_Figure 2: Vertically scaling your cluster by increasing the size of the virtual machines (VMs)_
|
||||
|
||||
We scale up our cluster by increasing the size of the virtual machines (VMs) in the node pool. In this example, we increased the size of three small-sized VMs so that we now have three large-sized VMs. We haven’t changed the number of VMs; we’ve just increased their size — scaling our VMs vertically.
|
||||
|
||||
Listing 1 is an extract from Terraform code that provisions a cluster on Azure; we change the vm_size field from Standard_B2ms to Standard_B4ms. This upgrades the size of each VM in our Kubernetes node pool. Instead of two CPUs, we now have four (one for each VM). As part of this change, memory and hard-drive for the VM also increase. If you are deploying to AWS or GCP, you can use this technique to vertically scale, but those cloud platforms offer different options for varying VM sizes.
|
||||
|
||||
We still only have a single VM in our cluster, but we have increased our VM’s size. In this example, scaling our cluster is as simple as a code change. This is the power of infrastructure-as-code, the technique where we store our infrastructure configuration as code and make changes to our infrastructure by committing code changes that trigger our continuous delivery (CD) pipeline
|
||||
|
||||
<https://cdn.thenewstack.io/media/2021/03/32f268d3-image2.png>
|
||||
|
||||
_Listing 1: Vertically scaling the cluster with Terraform (an extract)_
|
||||
|
||||
### Horizontally Scaling the Cluster
|
||||
|
||||
In addition to vertically scaling our cluster, we can also scale it horizontally. Our VMs can remain the same size, but we simply add more VMs.
|
||||
|
||||
By adding more VMs to our cluster, we spread the load of our application across more computers. Figure 3 illustrates how we can take our cluster from three VMs up to six. The size of each VM remains the same, but we gain more computing power by having more VMs.
|
||||
|
||||
<https://cdn.thenewstack.io/media/2021/03/81dea0ef-image1.png>
|
||||
|
||||
_Figure 3: Horizontally scaling your cluster by increasing the number of VMs_
|
||||
|
||||
Listing 2 shows an extract of Terraform code to add more VMs to our node pool. Back in listing 1, we had node_count set to 1, but here we have changed it to 6. Note that we reverted the vm_size field to the smaller size of Standard_B2ms. In this example, we increase the number of VMs, but not their size; although there is nothing stopping us from increasing both the number and the size of our VMs.
|
||||
|
||||
Generally, though, we might prefer horizontal scaling because it is less expensive than vertical scaling. That’s because using many smaller VMs is cheaper than using fewer but bigger and higher-priced VMs.
|
||||
|
||||
<https://cdn.thenewstack.io/media/2021/03/31716e5c-image6.png>
|
||||
|
||||
_Listing 2: Horizontal scaling the cluster with Terraform (an extract)_
|
||||
|
||||
### Horizontally Scaling an Individual Microservice
|
||||
|
||||
Assuming our cluster is scaled to an adequate size to host all the microservices with good performance, what do we do when individual microservices become overloaded? (This can be monitored in the Kubernetes dashboard.)
|
||||
|
||||
Whenever a microservice becomes a performance bottleneck, we can horizontally scale it to distribute its load over multiple instances. This is shown in figure 4.
|
||||
|
||||
<https://cdn.thenewstack.io/media/2021/03/39ee5bd0-image4.png>
|
||||
|
||||
_Figure 4: Horizontally scaling a microservice by replicating it_
|
||||
|
||||
We are effectively giving more compute, memory and storage to this particular microservice so that it can handle a bigger workload.
|
||||
|
||||
Again, we can use code to make this change. We can do this by setting the replicas field in the specification for our Kubernetes deployment or pod as shown in listing 3.
|
||||
|
||||
<https://cdn.thenewstack.io/media/2021/03/5acaf6b1-image5.png>
|
||||
|
||||
_Listing 3: Horizontally scaling a microservice with Terraform (an extract)_
|
||||
|
||||
Not only can we scale individual microservices for performance, we can also horizontally scale our microservices for redundancy, creating a more fault-tolerant application. By having multiple instances, there are others available to pick up the load whenever any single instance fails. This allows the failed instance of a microservice to restart and begin working again.
|
||||
|
||||
### Elastic Scaling for the Cluster
|
||||
|
||||
Moving into more advanced territory, we can now think about elastic scaling. This is a technique where we automatically and dynamically scale our cluster to meet varying levels of demand.
|
||||
|
||||
Whenever a demand is low, [Kubernetes][5] can automatically deallocate resources that aren’t needed. During high-demand periods, new resources are allocated to meet the increased workload. This generates substantial cost savings because, at any given moment, we only pay for the resources necessary to handle our application’s workload at that time.
|
||||
|
||||
We can use elastic scaling at the cluster level to automatically grow our clusters that are nearing their resource limits. Yet again, when using Terraform, this is just a code change. Listing 4 shows how we can enable the Kubernetes autoscaler and set the minimum and maximum size of our node pool.
|
||||
|
||||
Elastic scaling for the cluster works by default, but there are also many ways we can customize it. Search for “auto_scaler_profile” in [the Terraform documentation][6] to learn more.
|
||||
|
||||
<https://cdn.thenewstack.io/media/2021/03/feb61037-image3.png>
|
||||
|
||||
_Listing 4: Enabling elastic scaling for the cluster with Terraform (an extract)_
|
||||
|
||||
### Elastic Scaling for an Individual Microservice
|
||||
|
||||
We can also enable elastic scaling at the level of an individual microservice.
|
||||
|
||||
Listing 5 is a sample of Terraform code that gives microservices a “burstable” capability. The number of replicas for the microservice is expanded and contracted dynamically to meet the varying workload for the microservice (bursts of activity).
|
||||
|
||||
The scaling works by default, but can be customized to use other metrics. See the [Terraform documentation][7] to learn more. To learn more about pod auto-scaling in Kubernetes, [see the Kubernetes docs][8].
|
||||
|
||||
<https://cdn.thenewstack.io/media/2021/03/d4bd53af-image7.png>
|
||||
|
||||
_Listing 5: Enabling elastic scaling for a microservice with Terraform_
|
||||
|
||||
### About the Book: Bootstrapping Microservices
|
||||
|
||||
You can learn about building applications with microservices with [Bootstrapping Microservices][9].
|
||||
|
||||
Bootstrapping Microservices is a practical and project-based guide to building applications with microservices. It will take you all the way from building one single microservice all the way up to running a microservices application in production on [Kubernetes][10], ending up with an automated continuous delivery pipeline and using _infrastructure-as-code_ to push updates into production.
|
||||
|
||||
### Other Kubernetes Resources
|
||||
|
||||
This post is an extract from _Bootstrapping Microservices_ and has been a short overview of the ways we can scale microservices when running them on Kubernetes.
|
||||
|
||||
We specify the configuration for our infrastructure using Terraform. Creating and updating our infrastructure through code in this way is known as **intrastructure-as-code**, as a technique that turns working with infrastructure into a coding task and paved the way for the DevOps revolution.
|
||||
|
||||
To learn more about [Kubernetes][11], please see [the Kubernetes documentation][12] and the free [Introduction to Kubernetes][13] training course.
|
||||
|
||||
To learn more about working with Kubernetes using Terraform, please see [the Terraform documentation][14].
|
||||
|
||||
**About the Author, Ashley Davis**
|
||||
|
||||
Ashley is a software craftsman, entrepreneur, and author with over 20 years of experience in software development, from coding to managing teams, then to founding companies. He is the CTO of Sortal, a product that automatically sorts digital assets through the magic of machine learning.
|
||||
|
||||
The post [Scaling Microservices on Kubernetes][15] appeared first on [Linux Foundation – Training][16].
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.linux.com/news/scaling-microservices-on-kubernetes/
|
||||
|
||||
作者:[Dan Brown][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://training.linuxfoundation.org/announcements/scaling-microservices-on-kubernetes/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://thenewstack.io/scaling-microservices-on-kubernetes/
|
||||
[2]: https://coding-bootcamps.com/blog/kubernetes-evolution-from-virtual-servers-and-kubernetes-architecture.html
|
||||
[3]: https://learn.coding-bootcamps.com/p/complete-live-training-for-mastering-devops-and-all-of-its-tools
|
||||
[4]: https://blockchain.dcwebmakers.com/blog/advance-topics-for-deploying-and-managing-kubernetes-containers.html
|
||||
[5]: http://myhsts.org/tutorial-review-of-17-essential-topics-for-mastering-kubernetes.php
|
||||
[6]: https://www.terraform.io/docs/providers/azurerm/r/kubernetes_cluster.html
|
||||
[7]: http://www.terraform.io/docs/providers/kubernetes/r/horizontal_pod_autoscaler.html
|
||||
[8]: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/
|
||||
[9]: https://www.manning.com/books/bootstrapping-microservices-with-docker-kubernetes-and-terraform
|
||||
[10]: https://coding-bootcamps.com/blog/build-containerized-applications-with-golang-on-kubernetes.html
|
||||
[11]: https://learn.coding-bootcamps.com/p/live-training-class-for-mastering-kubernetes-containers-and-cloud-native
|
||||
[12]: https://kubernetes.io/docs/home/
|
||||
[13]: https://training.linuxfoundation.org/training/introduction-to-kubernetes/
|
||||
[14]: https://registry.terraform.io/providers/hashicorp/kubernetes/latest
|
||||
[15]: https://training.linuxfoundation.org/announcements/scaling-microservices-on-kubernetes/
|
||||
[16]: https://training.linuxfoundation.org/
|
@ -0,0 +1,144 @@
|
||||
[#]: subject: (Experiment on your code freely with Git worktree)
|
||||
[#]: via: (https://opensource.com/article/21/4/git-worktree)
|
||||
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
Experiment on your code freely with Git worktree
|
||||
======
|
||||
Get freedom to try things out alongside the security of having a new,
|
||||
linked clone of your repository if your experiment goes wrong.
|
||||
![Science lab with beakers][1]
|
||||
|
||||
Git is designed in part to enable experimentation. Once you know that your work is safely being tracked and safe states exist for you to fall back upon if something goes horribly wrong, you're not afraid to try new ideas. Part of the price of innovation, though, is that you're likely to make a mess along the way. Files get renamed, moved, removed, changed, and cut into pieces. New files are introduced. Temporary files that you don't intend to track take up residence in your working directory.
|
||||
|
||||
In short, your workspace becomes a house of cards, balancing precariously between _"it's almost working!"_ and _"oh no, what have I done?"_. So what happens when you need to get your repository back to a known state for an afternoon so that you can get some _real_ work done? The classic commands git branch and [git stash][2] come immediately to mind, but neither is designed to deal, one way or another, with untracked files, and changed file paths and other major shifts can make it confusing to just stash your work away for later. The answer is Git worktree.
|
||||
|
||||
### What is a Git worktree
|
||||
|
||||
A Git worktree is a linked copy of your Git repository, allowing you to have multiple branches checked out at a time. A worktree has a separate path from your main working copy, but it can be in a different state and on a different branch. The advantage of a new worktree in Git is that you can make a change unrelated to your current task, commit the change, and then merge it at a later date, all without disturbing your current work environment.
|
||||
|
||||
The canonical example, straight from the `git-worktree` man page, is that you're working on an exciting new feature for a project when your project manager tells you there's an urgent fix required. The problem is that your working repository (your "worktree") is in disarray because you're developing a major new feature. You don't want to "sneak" the fix into your current sprint, and you don't feel comfortable stashing changes to create a new branch for the fix. Instead, you decide to create a fresh worktree so that you can make the fix there:
|
||||
|
||||
|
||||
```
|
||||
$ git branch | tee
|
||||
* dev
|
||||
trunk
|
||||
$ git worktree add -b hotfix ~/code/hotfix trunk
|
||||
Preparing ../hotfix (identifier hotfix)
|
||||
HEAD is now at 62a2daf commit
|
||||
```
|
||||
|
||||
In your `code` directory, you now have a new directory called `hotfix`, which is a Git worktree linked to your main project repository, with its `HEAD` parked at the branch called `trunk`. You can now treat this worktree as if it were your main workspace. You can change directory into it, make the urgent fix, commit it, and eventually remove the worktree:
|
||||
|
||||
|
||||
```
|
||||
$ cd ~/code/hotfix
|
||||
$ sed -i 's/teh/the/' hello.txt
|
||||
$ git commit --all --message 'urgent hot fix'
|
||||
```
|
||||
|
||||
Once you've finished your urgent work, you can return to your previous task. You're in control of when your hotfix gets integrated into the main project. For instance, you can push the change directly from its worktree to the project's remote repo:
|
||||
|
||||
|
||||
```
|
||||
$ git push origin HEAD
|
||||
$ cd ~/code/myproject
|
||||
```
|
||||
|
||||
Or you can archive the worktree as a TAR or ZIP file:
|
||||
|
||||
|
||||
```
|
||||
$ cd ~/code/myproject
|
||||
$ git archive --format tar --output hotfix.tar master
|
||||
```
|
||||
|
||||
Or you can fetch the changes locally from the separate worktree:
|
||||
|
||||
|
||||
```
|
||||
$ git worktree list
|
||||
/home/seth/code/myproject 15fca84 [dev]
|
||||
/home/seth/code/hotfix 09e585d [master]
|
||||
```
|
||||
|
||||
From there, you can merge your changes using whatever strategy works best for you and your team.
|
||||
|
||||
### Listing active worktrees
|
||||
|
||||
You can get a list of the worktrees and see what branch each has checked out using the `git worktree list` command:
|
||||
|
||||
|
||||
```
|
||||
$ git worktree list
|
||||
/home/seth/code/myproject 15fca84 [dev]
|
||||
/home/seth/code/hotfix 09e585d [master]
|
||||
```
|
||||
|
||||
You can use this from within either worktree. Worktrees are always linked (unless you manually move them, breaking Git's ability to locate a worktree, and therefore severing the link).
|
||||
|
||||
### Moving a worktree
|
||||
|
||||
Git tracks the locations and states of a worktree in your project's `.git` directory:
|
||||
|
||||
|
||||
```
|
||||
$ cat ~/code/myproject/.git/worktrees/hotfix/gitdir
|
||||
/home/seth/code/hotfix/.git
|
||||
```
|
||||
|
||||
If you need to relocate a worktree, you must do that using `git worktree move`; otherwise, when Git tries to update the worktree's status, it fails:
|
||||
|
||||
|
||||
```
|
||||
$ mkdir ~/Temp
|
||||
$ git worktree move hotfix ~/Temp
|
||||
$ git worktree list
|
||||
/home/seth/code/myproject 15fca84 [dev]
|
||||
/home/seth/Temp/hotfix 09e585d [master]
|
||||
```
|
||||
|
||||
### Removing a worktree
|
||||
|
||||
When you're finished with your work, you can remove it with the `remove` subcommand:
|
||||
|
||||
|
||||
```
|
||||
$ git worktree remove hotfix
|
||||
$ git worktree list
|
||||
/home/seth/code/myproject 15fca84 [dev]
|
||||
```
|
||||
|
||||
To ensure your `.git` directory is clean, use the `prune` subcommand after removing a worktree:
|
||||
|
||||
|
||||
```
|
||||
`$ git worktree remove prune`
|
||||
```
|
||||
|
||||
### When to use worktrees
|
||||
|
||||
As with many options, whether it's tabs or bookmarks or automatic backups, it's up to you to keep track of the data you generate, or it could get overwhelming. Don't use worktrees so often that you end up with 20 copies of your repo, each in a slightly different state. I find it best to create a worktree, do the task that requires it, commit the work, and then remove the tree. Keep it simple and focused.
|
||||
|
||||
The important thing is that worktrees provide improved flexibility for how you manage a Git repository. Use them when you need them, and never again scramble to preserve your working state just to check something on another branch.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/4/git-worktree
|
||||
|
||||
作者:[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/science_experiment_beaker_lab.png?itok=plKWRhlU (Science lab with beakers)
|
||||
[2]: https://opensource.com/article/21/4/git-stash
|
82
sources/tech/20210406 Teach anyone how to code with Hedy.md
Normal file
82
sources/tech/20210406 Teach anyone how to code with Hedy.md
Normal file
@ -0,0 +1,82 @@
|
||||
[#]: subject: (Teach anyone how to code with Hedy)
|
||||
[#]: via: (https://opensource.com/article/21/4/hedy-teach-code)
|
||||
[#]: author: (Joshua Allen Holm https://opensource.com/users/holmja)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
Teach anyone how to code with Hedy
|
||||
======
|
||||
Hedy is a new programming language designed specifically for teaching
|
||||
people to code.
|
||||
![Teacher or learner?][1]
|
||||
|
||||
Learning to code involves learning both the programming logic and the syntax of a specific programming language. When I took my first programming class in college, the language taught was C++. The first code example, the basic "Hello World" program, looked like the example below.
|
||||
|
||||
|
||||
```
|
||||
#include <iostream>
|
||||
|
||||
int main() {
|
||||
std::cout << "Hello World!";
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
The instructor would not explain most of the code until several lessons later. The expectation was that we would just type in the code and eventually learn why things were required and how they worked.
|
||||
|
||||
The complex syntax of C++ (and other, similar languages) is why Python is often suggested as an easier language for teaching programming. Here is the same example in Python:
|
||||
|
||||
|
||||
```
|
||||
`print("Hello World!")`
|
||||
```
|
||||
|
||||
While the basic "Hello World" example in Python is much simpler, it still has complex and precise syntax rules. The `print` function requires parentheses and quotes around the string. This can still confuse those who have no experience with programming. Python has fewer "I'll explain later" syntax issues than C++, but it still has them.
|
||||
|
||||
[Hedy][2], a new language designed specifically for teaching coding, addresses the issue of syntax complexity by building multiple levels of complexity into the language. Instead of providing the full features of the language right away, Hedy takes a gradual approach and slowly becomes more complex as students work through Hedy's levels. As the levels progress, the language gains new features and eventually becomes more Python-like. There are currently seven levels available, but more are planned.
|
||||
|
||||
At level 1, a Hedy program cannot do anything except print a statement (which does not require quotes or parentheses), ask a question, and echo back an answer. Level 1 has no variables, no loops, and minimal structure. Echo works almost like a variable but only for the last user input. This allows students to become comfortable with basic concepts without having to learn everything all at once.
|
||||
|
||||
This is a level 1 Hedy "Hello World" program:
|
||||
|
||||
|
||||
```
|
||||
`print Hello World`
|
||||
```
|
||||
|
||||
Level 2 introduces variables, but because the `print` function does not use quotes, there can be some interesting outcomes. If the variable used to store a person's name is `name`, it is impossible to print the output "Your name is [name]" because both the first use of name, which is intended to be a string, and the second use, which is a variable, are both interpreted as a variable. If `name` is set to `John Doe`, the output of `print Your name is name.` would be "Your John Doe is John Doe." As odd as this sounds, it is a good way for to introduce the concept of variables, which just happens to be a feature added in Level 3.
|
||||
|
||||
Level 3 requires quotation marks around strings, which makes variables function like they do in Python. It is now possible to output strings combined with variables to make complex statements without worrying about conflicts between variable names and words in a string. This level does away with the `echo` function, which does seem like something that might frustrate some learners. They should be using variables, which is better code, but it could be confusing if an `ask`/`echo` block of code becomes invalid syntax.
|
||||
|
||||
Level 4 adds basic `if`/`else` functionality. Students can move from simple ask/answer code to complex interactions. For example, a prompt that asks, "What is your favorite color?" can accept different replies depending on what the user enters. If they enter green, the reply can be "Green! That's also my favorite color." If they enter anything else, the reply could be different. The `if`/`else` block is a basic programming concept, which Hedy introduces without having to worry about complex syntax or overly precise formatting.
|
||||
|
||||
Level 5 has a `repeat` function, which adds a basic loop to the features available. This loop can only repeat the same command multiple times, so it is not as powerful as loops in Python, but it lets the students get used to the general concept of repeating commands. It's one more programming concept introduced without bogging things down with needless complexity. The students can grasp the basics of the concept before moving on to more powerful, complex versions of the same thing.
|
||||
|
||||
At level 6, Hedy can now do basic math calculations. Addition, subtraction, multiplication, and division are supported, but more advanced math features are not. It is not possible to use exponents, modulo, or anything else that Python and other languages handle. As yet, no higher level of Hedy adds more complex math.
|
||||
|
||||
Level 7 brings in Python-style indenting, which means `repeat` can work with multiple lines of code. Students worked with code line by line up to this point, but now they can work with blocks of code. This Hedy level still falls way short of what a non-teaching programming language can do, but it can teach students a lot.
|
||||
|
||||
The easiest way to get started with Hedy is to access the [lessons][3] on the Hedy website, which is currently available in Dutch, English, French, German, Portuguese, and Spanish. This makes the learning process accessible to anyone with a web browser. It is also possible to download Hedy from [GitHub][4] and run the interpreter from the command line or run a local copy of the Hedy website with its interactive lessons. The web-based version is more approachable, but both the web and command-line versions support running Hedy programs targeted at its various levels of complexity.
|
||||
|
||||
Hedy will never compete with Python, C++, or other languages as the language of choice for coding for real-world projects, but it is an excellent way to teach coding. The programs students write as part of the learning process are real and possibly even complex. Hedy can foster learning and creativity without confusing students with too much information too soon in the learning process. Like math classes, which start with counting, adding, etc., long before getting to calculus (a process that takes years), programming does not have to start with "I'll explain later" for programming language syntax issues that must be followed precisely to produce even the most basic program in the language.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/4/hedy-teach-code
|
||||
|
||||
作者:[Joshua Allen Holm][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/holmja
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/5538035618_4e19c9787c_o.png?itok=naiD1z1S (Teacher or learner?)
|
||||
[2]: https://www.hedycode.com/
|
||||
[3]: https://www.hedycode.com/hedy?lang=en
|
||||
[4]: https://github.com/felienne/hedy
|
@ -0,0 +1,145 @@
|
||||
[#]: subject: (Use Apache Superset for open source business intelligence reporting)
|
||||
[#]: via: (https://opensource.com/article/21/4/business-intelligence-open-source)
|
||||
[#]: author: (Maxime Beauchemin https://opensource.com/users/mistercrunch)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
Use Apache Superset for open source business intelligence reporting
|
||||
======
|
||||
Since its creation in 2015 at an Airbnb hackathon, Apache Superset has
|
||||
matured into a leading open source BI solution.
|
||||
![metrics and data shown on a computer screen][1]
|
||||
|
||||
They say software is eating the world, but it's equally clear that open source is taking over software.
|
||||
|
||||
Simply put, open source is a superior approach for building and distributing software because it provides important guarantees around how software can be discovered, tried, operated, collaborated on, and packaged. For those reasons, it is not surprising that it has taken over most of the modern data stack: Infrastructure, databases, orchestration, data processing, AI/ML, and beyond.
|
||||
|
||||
Looking back, the main reason why I originally created both [Apache Airflow][2] and [Apache Superset][3] while I was at Airbnb from 2014-17 is that the vendors in the data space were failing to:
|
||||
|
||||
* Keep up with the pace of innovation in the data ecosystem
|
||||
* Give power to users who wanted to satisfy their more advanced use cases
|
||||
|
||||
|
||||
|
||||
As is often the case with open source, the capacity to integrate and extend was always at the core of how we approached the architecture of those two projects.
|
||||
|
||||
### Headaches with Tableau
|
||||
|
||||
More specifically, for Superset, the main driver to start the project at the time was the fact that Tableau (which was, at the time, our main data visualization tool) couldn't connect natively to [Apache Druid][4] and [Trino][5]/[Presto][6]. These were our data engines of choice that provided the properties and guarantees that we needed to satisfy our data use cases.
|
||||
|
||||
With Tableau's "Live Mode" misbehaving in intricate ways at the time (I won't get into this!), we were steered towards using Tableau Extracts. Extracts crumbled under the data volumes we had at Airbnb, creating a whole lot of challenges around non-additive metrics (think distinct user counts) and forcing us to intricately pre-compute multiple "grouping sets," which broke down some of the Tableau paradigms and confused users. Secondarily, we had a limited number of licenses for Tableau and generally had an order of magnitude more employees that wanted/needed access to our internal than our contract allowed. That's without mentioning the fact that for a cloud-native company, Tableau's Windows-centric approach at the time didn't work well for the team.
|
||||
|
||||
Some of the above premises have since changed, but the power of open source and the core principles on which it's built have only grown. In this blog post, I will explain why the future of business intelligence is open source.
|
||||
|
||||
## Benefits of open source
|
||||
|
||||
If I could only use a single word to describe why the time is right for organizations to adopt open source BI, the word would be _freedom_. Flowing from the principle of freedom comes a few more concrete superpowers for an organization:
|
||||
|
||||
* The power to customize, extend and integrate
|
||||
* The power of the community
|
||||
* Avoid vendor lock-in
|
||||
|
||||
|
||||
|
||||
### Extend, customize, and integrate
|
||||
|
||||
Airbnb wanted to integrate in-house tools like Dataportal and Minerva with a dashboarding tool to enable data democratization within their organization. Because Superset is open source and Airbnb actively contributes to the project, they could supercharge Superset with in-house components with relative ease.
|
||||
|
||||
On the visualization side, organizations like Nielsen create new visualizations and deploy them in their Superset environments. They're going a step further by empowering their engineers to contribute to Superset's customizability and extensibility. The Superset platform is now flexible enough so that anyone can build their [own custom visualization plugins][7], a benefit that is unmatched in the marketplace.
|
||||
|
||||
Many report using the rich [REST API that ships with Superset][8] within the wider community, allowing them full programmatic control over all aspects of the platform. Given that pretty much everything that users can do in Superset can be done through the API, the sky is the limit for automating processes in and around Superset.
|
||||
|
||||
Around the topic of integration, members from the Superset community have added support for over 30 databases ([and growing!][9]) by submitting code and documentation contributions. Because the core contributors bet on the right open source components ([SQLAlchemy][10] and Python [DB-API 2.0][11]), the Superset community both gives and receives to/from the broader Python community.
|
||||
|
||||
### The power of the community
|
||||
|
||||
Open source communities are composed of a diverse group of people who come together over a similar set of needs. This group is empowered to contribute to the common good. Vendors, on the other hand, tend to focus on their most important customers. Open source is a fundamentally different model that's much more collaborative and frictionless. As a result of this fundamentally de-centralized model, communities are very resilient to changes that vendor-led products struggle with. As contributors and organizations come and go, the community lives on!
|
||||
|
||||
At the core of the community are the active contributors that typically operate as a dynamic meritocracy. Network effects attract attention and talent, and communities welcome and offer guidance to newcomers because their goals are aligned. With the rise of platforms like Gitlab and Github, software is pretty unique in that engineers and developers from around the world seem to be able to come together and work collaboratively with minimal overhead. Those dynamics are fairly well understood and accepted as a disruptive paradigm shift in how people collaborate to build modern software.
|
||||
|
||||
![Growth in Monthly Unique Contributors][12]
|
||||
|
||||
Growth in Monthly Unique Contributors
|
||||
|
||||
Beyond the software at the core of the project, dynamic communities contribute in all sorts of ways that provide even more value. Here are some examples:
|
||||
|
||||
* Rich and up-to-date documentation
|
||||
* Example use cases and testimonials, often in the form of blog posts
|
||||
* Bug reports and bug fixes, contributing to stability and quality
|
||||
* Ever-growing online knowledge bases and FAQs
|
||||
* How-to videos and conference talks
|
||||
* Real-time support networks of enthusiasts and experts in forums and on [chat platforms][13]
|
||||
* Dynamic mailing lists where core contributors propose and debate over complex issues
|
||||
* Feedback loops, ways to suggest features and influence roadmaps
|
||||
|
||||
|
||||
|
||||
### Avoid lock-in
|
||||
|
||||
Recently, [Atlassian acquired the proprietary BI platform Chart.io][14], started to downsize the Chart.io team, and announced their intention to shut down the platform. Their customers now have to scramble and find a new home for their analytics assets that they now have to rebuild.
|
||||
|
||||
![Chart.io Shutting Down][15]
|
||||
|
||||
Chart.io Shutting Down
|
||||
|
||||
This isn't a new phenomenon. Given how mature and dynamic the BI market is, consolidation has been accelerating over the past few years:
|
||||
|
||||
* Tableau was acquired by Salesforce
|
||||
* Looker was acquired by Google Cloud
|
||||
* Periscope was acquired by Sisense
|
||||
* Zoomdata was acquired by Logi Analytics
|
||||
|
||||
|
||||
|
||||
While consolidation is likely to continue, these concerns don't arise when your BI platform is open source. If you're self-hosting, you are essentially immune to vendor lock-in. If you choose to partner with a commercial open source software (COSS), you should have an array of options from alternative vendors to hiring expertise in the marketplace, all the way to taking ownership and operating the software on your own.
|
||||
|
||||
For example, if you were using Apache Airflow service to take care of your Airflow needs, and your cloud provider decided to shut down the service, you'd be left with a set of viable options:
|
||||
|
||||
* Select and migrate to another service provider in the space, such as Apache Airflow specialist [Astronomer][16].
|
||||
* Hire or consult Airflow talent that can help you take control. The community has fostered a large number of professionals who know and love Airflow and can help your organization.
|
||||
* Learn and act. That is, take control and tap into the community's amazing resources to run the software on your own (Docker, Helm, k8s operator, and so on.)
|
||||
|
||||
|
||||
|
||||
Even at [Preset][17], where we offer a cloud-hosted version of Superset, we don't fork the Superset code and instead run the same Superset that's available to everyone. In the Preset cloud, you can freely import and export data sources, charts, and dashboards. This is not unique to Preset. Many vendors understand that "no lock-in!" is integral to their value proposition and are incentivized to provide clear guarantees around this.
|
||||
|
||||
## Open source for your data
|
||||
|
||||
Open source is disruptive in the best of ways, providing freedom, and a set of guarantees that really matter when it comes to adopting software. These guarantees fully apply when it comes to business intelligence. In terms of business intelligence, Apache Superset has matured to a level where it's a compelling choice over any proprietary solution. Since its creation in 2015 at an Airbnb hackathon, the project has come a very long way indeed. Try it yourself to discover a combination of features and guarantees unique to open source BI. To learn more, visit and [join our growing community][18].
|
||||
|
||||
In this article, I review some of the top open source business intelligence (BI) and reporting...
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/4/business-intelligence-open-source
|
||||
|
||||
作者:[Maxime Beauchemin][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/mistercrunch
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/metrics_data_dashboard_system_computer_analytics.png?itok=oxAeIEI- (metrics and data shown on a computer screen)
|
||||
[2]: https://airflow.apache.org/
|
||||
[3]: https://superset.apache.org/
|
||||
[4]: https://druid.apache.org/
|
||||
[5]: https://trino.io/
|
||||
[6]: https://prestodb.io/
|
||||
[7]: https://preset.io/blog/2020-07-02-hello-world/
|
||||
[8]: https://superset.apache.org/docs/rest-api/
|
||||
[9]: https://superset.apache.org/docs/databases/installing-database-drivers
|
||||
[10]: https://www.sqlalchemy.org/
|
||||
[11]: https://www.python.org/dev/peps/pep-0249/
|
||||
[12]: https://opensource.com/sites/default/files/uniquecontributors.png
|
||||
[13]: https://opensource.com/article/20/7/mattermost
|
||||
[14]: https://www.atlassian.com/blog/announcements/atlassian-acquires-chartio
|
||||
[15]: https://opensource.com/sites/default/files/chartio.jpg
|
||||
[16]: https://www.astronomer.io/
|
||||
[17]: https://preset.io/
|
||||
[18]: https://superset.apache.org/community/
|
225
sources/tech/20210407 Get started with batch files in FreeDOS.md
Normal file
225
sources/tech/20210407 Get started with batch files in FreeDOS.md
Normal file
@ -0,0 +1,225 @@
|
||||
[#]: subject: (Get started with batch files in FreeDOS)
|
||||
[#]: via: (https://opensource.com/article/21/3/batch-files-freedos)
|
||||
[#]: author: (Kevin O'Brien https://opensource.com/users/ahuka)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
Get started with batch files in FreeDOS
|
||||
======
|
||||
Batch files are a great way to write your own simple programs and
|
||||
automate tasks that normally require lots of typing.
|
||||
![Computer screen with files or windows open][1]
|
||||
|
||||
On Linux, it's common to create _shell scripts_ to automate repetitive tasks. Similarly, on [FreeDOS][2], the open source implementation of old DOS operating systems, you can create a _batch file_ containing several FreeDOS commands. Then you can run your batch file to execute each command in order.
|
||||
|
||||
You create a batch file by using an ASCII text editor, such as the FreeDOS Edit application. Once you create a batch file, you save it with a file name and the extension `.bat`. The file name should be unique. If you use a FreeDOS command name as your own file name, the FreeDOS command probably will execute instead of your batch file.
|
||||
|
||||
Virtually all internal and external FreeDOS commands can be used in a batch file. When you create a batch file, you are essentially writing a program. FreeDOS batch files may not have the power of a structured programming language, but they can be very handy for quick but repetitive tasks.
|
||||
|
||||
### Commenting your code
|
||||
|
||||
The No. 1 good habit for any programmer to learn is to put comments in a program to explain what the code is doing. This is a very good thing to do, but you need to be careful not to fool the operating system into executing your comments. The way to avoid this is to place `REM` (short for "remark") at the beginning of a comment line.
|
||||
|
||||
FreeDOS ignores lines starting with `REM`. But anyone who looks at the source code (the text you've written in your batch file) can read your comments and understand what it's doing. This is also a way to temporarily disable a command without deleting it. Just open your batch file for editing, place `REM` at the beginning of the line you want to disable, and save it. When you want to re-enable that command, just open the file for editing and remove `REM`. This technique is sometimes referred to as "commenting out" a command.
|
||||
|
||||
### Get set up
|
||||
|
||||
Before you start writing your own batch files, I suggest creating a temporary directory in FreeDOS. This can be a safe space for you to play around with batch files without accidentally deleting, moving, or renaming important system files or directories. On FreeDOS, you [create a directory][3] with the `MD` command:
|
||||
|
||||
|
||||
```
|
||||
C:\>MD TEMP
|
||||
C:\>CD TEMP
|
||||
C:\TEMP>
|
||||
```
|
||||
|
||||
The `ECHO` FreeDOS command controls what is shown on the screen when you run a batch file. For instance, here is a simple one-line batch file:
|
||||
|
||||
|
||||
```
|
||||
`ECHO Hello world`
|
||||
```
|
||||
|
||||
If you create this file and run it, you will see the sentence displayed on the screen. The quickest way to do this is from the command line: Use the `COPY` command to take the input from your keyboard (`CON`) and place it into the file `TEST1.BAT`. Then press **Ctrl**+**Z** to stop the copy process, and press Return or Enter on your keyboard to return to a prompt.
|
||||
|
||||
Try creating this file as `TEST1.BAT` in your temporary directory, and then run it:
|
||||
|
||||
|
||||
```
|
||||
C:\TEMP>COPY CON TEST1.BAT
|
||||
CON => TEST1.BAT
|
||||
ECHO Hello world
|
||||
^Z
|
||||
|
||||
C:\TEMP>TEST1
|
||||
Hello world
|
||||
```
|
||||
|
||||
This can be useful when you want to display a piece of text. For instance, you might see a message on your screen telling you to wait while a program finishes its task, or in a networked environment, you might see a login message.
|
||||
|
||||
What if you want to display a blank line? You might think that the `ECHO` command all by itself would do the trick, but the `ECHO` command alone asks FreeDOS to respond whether `ECHO` is on or off:
|
||||
|
||||
|
||||
```
|
||||
C:\TEMP>ECHO
|
||||
ECHO is on
|
||||
```
|
||||
|
||||
The way to get a blank line is to use a `+` sign immediately after `ECHO`:
|
||||
|
||||
|
||||
```
|
||||
C:\TEMP>ECHO+
|
||||
|
||||
C:\TEMP>
|
||||
```
|
||||
|
||||
### Batch file variables
|
||||
|
||||
A variable is a holding place for information you need your batch file to remember temporarily. This is a vital function of programming because you don't always know what data you want your batch file to use. Here's a simple example to demonstrate.
|
||||
|
||||
Create `TEST3.BAT`:
|
||||
|
||||
|
||||
```
|
||||
@MD BACKUPS
|
||||
COPY %1 BACKUPS\%1
|
||||
```
|
||||
|
||||
Variables are signified by the use of the percentage symbol followed by a number, so this batch file creates a `BACKUPS` subdirectory in your current directory and then copies a variable `%1` into a `BACKUPS` folder. What is this variable? That's up to you to decide when you run the batch file:
|
||||
|
||||
|
||||
```
|
||||
C:\TEMP>TEST3 TEMP1.BAT
|
||||
TEST1.BAT => BACKUPS\TEST1.BAT
|
||||
```
|
||||
|
||||
Your batch file has copied `TEST1.BAT` into a subdirectory called `BACKUPS` because you identified that file as an argument when running your batch file. Your batch file substituted `TEST1.BAT` for `%1`.
|
||||
|
||||
Variables are positional. The variable `%1` is the first argument you provide to your command, while `%2` is the second, and so on. Suppose you create a batch file to list the contents of a directory:
|
||||
|
||||
|
||||
```
|
||||
`DIR %1`
|
||||
```
|
||||
|
||||
Try running it:
|
||||
|
||||
|
||||
```
|
||||
C:\TEMP>TEST4.BAT C:\HOME
|
||||
ARTICLES
|
||||
BIN
|
||||
CHEATSHEETS
|
||||
GAMES
|
||||
DND
|
||||
```
|
||||
|
||||
That works as expected. But this fails:
|
||||
|
||||
|
||||
```
|
||||
C:\TEMP>TEST4.BAT C:\HOME C:\DOCS
|
||||
ARTICLES
|
||||
BIN
|
||||
CHEATSHEETS
|
||||
GAMES
|
||||
DND
|
||||
```
|
||||
|
||||
If you try that, you get the listing of the first argument (`C:\HOME`) but not of the second (`C:\DOCS`). This is because your batch file is only looking for one variable (`%1`), and besides, the `DIR` command can take only one directory.
|
||||
|
||||
Also, you don't really need to specify a batch file's extension when you run it—unless you are unlucky enough to pick a name for the batch file that matches one of the FreeDOS external commands or something similar. When FreeDOS executes commands, it goes in the following order:
|
||||
|
||||
1. Internal commands
|
||||
2. External commands with the *.COM extension
|
||||
3. External commands with the *.EXE extension
|
||||
4. Batch files
|
||||
|
||||
|
||||
|
||||
### Multiple arguments
|
||||
|
||||
OK, now rewrite the `TEST4.BAT` file to use a command that takes two arguments so that you can see how this works. First, create a simple text file called `FILE1.TXT` using the `EDIT` application. Put a sentence of some kind inside (e.g., "Hello world"), and save the file in your `TEMP` working directory.
|
||||
|
||||
Next, use `EDIT` to change your `TEST4.BAT` file:
|
||||
|
||||
|
||||
```
|
||||
COPY %1 %2
|
||||
DIR
|
||||
```
|
||||
|
||||
Save it, then execute the command:
|
||||
|
||||
|
||||
```
|
||||
`C:\TEMP\>TEST4 FILE1.TXT FILE2.TXT`
|
||||
```
|
||||
|
||||
Upon running your batch file, you see a directory listing of your `TEMP` directory. Among the files listed, you have `FILE1.TXT` and `FILE2.TXT`, which were created by your batch file.
|
||||
|
||||
### Nested batch files
|
||||
|
||||
Another feature of batch files is that they can be "nested," meaning that one batch file can be called and run inside another batch file. To see how this works, start with a simple pair of batch files.
|
||||
|
||||
The first file is called `NBATCH1.BAT`:
|
||||
|
||||
|
||||
```
|
||||
@ECHO OFF
|
||||
ECHO Hello
|
||||
CALL NBATCH2.BAT
|
||||
ECHO world
|
||||
```
|
||||
|
||||
The first line (`@ECHO OFF`) quietly tells the batch file to show only the output of the commands (not the commands themselves) when you run it. You probably noticed in previous examples that there was a lot of feedback about what the batch file was doing; in this case, you're permitting your batch file to display only the results.
|
||||
|
||||
The second batch file is called NBATCH2.BAT:
|
||||
|
||||
|
||||
```
|
||||
`echo from FreeDOS`
|
||||
```
|
||||
|
||||
Create both of these files using `EDIT`, and save them in your TEMP subdirectory. Run `NBATCH1.BAT` to see what happens:
|
||||
|
||||
|
||||
```
|
||||
C:\TEMP\>NBATCH1.BAT
|
||||
Hello
|
||||
from FreeDOS
|
||||
world
|
||||
```
|
||||
|
||||
Your second batch file was executed from within the first by the `CALL` command, which provided the string "from FreeDOS" in the middle of your "Hello world" message.
|
||||
|
||||
### FreeDOS scripting
|
||||
|
||||
Batch files are a great way to write your own simple programs and automate tasks that normally require lots of typing. The more you use FreeDOS, the more familiar you'll become with its commands, and once you know the commands, it's just a matter of listing them in a batch file to make your FreeDOS system make your life easier. Give it a try!
|
||||
|
||||
* * *
|
||||
|
||||
_Some of the information in this article was previously published in [DOS lesson 15: Introduction to batch files][4] and [DOS lesson 17: Batch file variables; nested batch files][5] (both CC BY-SA 4.0)._
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/3/batch-files-freedos
|
||||
|
||||
作者:[Kevin O'Brien][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/ahuka
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_screen_windows_files.png?itok=kLTeQUbY (Computer screen with files or windows open)
|
||||
[2]: https://www.freedos.org/
|
||||
[3]: https://opensource.com/article/21/2/freedos-commands-you-need-know
|
||||
[4]: https://www.ahuka.com/dos-lessons-for-self-study-purposes/dos-lesson-15-introduction-to-batch-files/
|
||||
[5]: https://www.ahuka.com/dos-lessons-for-self-study-purposes/dos-lesson-17-batch-file-variables-nested-batch-files/
|
@ -0,0 +1,105 @@
|
||||
[#]: subject: (Show CPU Details Beautifully in Linux Terminal With CPUFetch)
|
||||
[#]: via: (https://itsfoss.com/cpufetch/)
|
||||
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
Show CPU Details Beautifully in Linux Terminal With CPUFetch
|
||||
======
|
||||
|
||||
There are [ways to check CPU information on Linux][1]. Probably the most common is the `lscpu` command that gives you plenty of information about all the CPU cores on your system.
|
||||
|
||||
![lscpu command output][2]
|
||||
|
||||
You may find CPU information there without installing any additional packages. That works of course. However, I recently stumbled upon a new tool that displays the CPU details in Linux in a beautiful manner.
|
||||
|
||||
The ASCII art of the processor manufacturer makes it look cool.
|
||||
|
||||
![][3]
|
||||
|
||||
This looks beautiful, isn’t it? This is similar to [Neoftech or Screenfetch tools that show the system information in beautiful ASCII art in Linux][4]. Similar to those tools, you can use CPUFetch if you are showcasing your desktop screenshot.
|
||||
|
||||
The tool outputs the ASCII art of the processor manufacturer, its name, microarchitecture, frequency, cores, threads, peak performance, cache sizes, [Advanced Vector Extensions][5], and more.
|
||||
|
||||
You can use custom colors apart from a few themes it provides. This gives you additional degree of freedom when you are ricing your desktop and want to color match all the elements on your Linux setup.
|
||||
|
||||
### Installing CPUFetch on Linux
|
||||
|
||||
Unfortunately, CPUFetch is rather new, and it is not included in your distribution’s repository. It doesn’t even provide ready to use DEB/RPM binaries, PPAs, Snap or Flatpak packages.
|
||||
|
||||
Arch Linux users can [find][6] it in [AUR][7] but for others, the only way forward here is to [build from source code][8].
|
||||
|
||||
Don’t worry. Installation as well as removal is not that complicated. Let me show you the steps.
|
||||
|
||||
I am using Ubuntu and you would [need to install Git on Ubuntu first][9]. Some other distributions come preinstalled with it, if not use your distribution’s package manager to install it.
|
||||
|
||||
Now, clone the Git repository wherever you want. Home directory is fine as well.
|
||||
|
||||
```
|
||||
git clone https://github.com/Dr-Noob/cpufetch
|
||||
```
|
||||
|
||||
Switch to the directory you just cloned:
|
||||
|
||||
```
|
||||
cd cpufetch
|
||||
```
|
||||
|
||||
You’ll see a make file here. Use it to compile the code.
|
||||
|
||||
```
|
||||
make
|
||||
```
|
||||
|
||||
![CPUFetch Installation][10]
|
||||
|
||||
Now you’ll see a new executable file named `cpufetch`. You run this executable to display the CPU information in the terminal.
|
||||
|
||||
```
|
||||
./cpufetch
|
||||
```
|
||||
|
||||
This is what it showed for my system. AMD logo looks a lot cooler in ASCII, don’t you think?
|
||||
|
||||
![][11]
|
||||
|
||||
How do you remove Cpufetch? It’s pretty simple. When you compiled the code, it produced just one file and that too in the same directory as the rest of the code.
|
||||
|
||||
So, to remove CPUFetch from your system, simply remove its entire folder. You know how to [remove a directory in Linux terminal][12], don’t you? Come out of the cpufetch directory and use the rm command:
|
||||
|
||||
```
|
||||
rm -rf cpufetch
|
||||
```
|
||||
|
||||
That was simple, thankfully because removing software installed from source code could be really tricky at times.
|
||||
|
||||
Back to cpufetch. I think it’s a utility for those who like to show off their desktop screenshots in various Linux group. Since we have Neofetch for the distribution and CPUFetch for CPU, I wonder if we could have a GPU fetch with ASCII art of Nvidia as well :)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/cpufetch/
|
||||
|
||||
作者:[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://linuxhandbook.com/check-cpu-info-linux/
|
||||
[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/04/lscpu-command-output.png?resize=800%2C415&ssl=1
|
||||
[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/04/cpufetch-1.png?resize=800%2C307&ssl=1
|
||||
[4]: https://itsfoss.com/display-linux-logo-in-ascii/
|
||||
[5]: https://software.intel.com/content/www/us/en/develop/articles/introduction-to-intel-advanced-vector-extensions.html
|
||||
[6]: https://aur.archlinux.org/packages/cpufetch-git
|
||||
[7]: https://itsfoss.com/aur-arch-linux/
|
||||
[8]: https://itsfoss.com/install-software-from-source-code/
|
||||
[9]: https://itsfoss.com/install-git-ubuntu/
|
||||
[10]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/04/cpufetch-installation.png?resize=800%2C410&ssl=1
|
||||
[11]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/04/cpufetch-for-itsfoss.png?resize=800%2C335&ssl=1
|
||||
[12]: https://linuxhandbook.com/remove-files-directories/
|
@ -0,0 +1,288 @@
|
||||
[#]: subject: (Using network bound disk encryption with Stratis)
|
||||
[#]: via: (https://fedoramagazine.org/network-bound-disk-encryption-with-stratis/)
|
||||
[#]: author: (briansmith https://fedoramagazine.org/author/briansmith/)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
Using network bound disk encryption with Stratis
|
||||
======
|
||||
|
||||
![][1]
|
||||
|
||||
Photo by [iMattSmart][2] on [Unsplash][3]
|
||||
|
||||
In an environment with many encrypted disks, unlocking them all is a difficult task. Network bound disk encryption (NBDE) helps automate the process of unlocking Stratis volumes. This is a critical requirement in large environments. Stratis version 2.1 added support for encryption, which was introduced in the article “[Getting started with Stratis encryption][4].” Stratis version 2.3 recently introduced support for Network Bound Disk Encryption (NBDE) when using encrypted Stratis pools, which is the topic of this article.
|
||||
|
||||
The [Stratis website][5] describes Stratis as an “_easy to use local storage management for Linux_.” The short video [“Managing Storage With Stratis”][6] gives a quick demonstration of the basics. The video was recorded on a Red Hat Enterprise Linux 8 system, however, the concepts shown in the video also apply to Stratis in Fedora Linux.
|
||||
|
||||
### Prerequisites
|
||||
|
||||
This article assumes you are familiar with Stratis, and also Stratis pool encryption. If you aren’t familiar with these topics, refer to this [article][4] and the [Stratis overview video][6] previously mentioned.
|
||||
|
||||
NBDE requires Stratis 2.3 or later. The examples in this article use a pre-release version of Fedora Linux 34. The Fedora Linux 34 final release will include Stratis 2.3.
|
||||
|
||||
### Overview of network bound disk encryption (NBDE)
|
||||
|
||||
One of the main challenges of encrypting storage is having a secure method to unlock the storage again after a system reboot. In large environments, typing in the encryption passphrase manually doesn’t scale well. NBDE addresses this and allows for encrypted storage to be unlocked in an automated manner.
|
||||
|
||||
At a high level, NBDE requires a Tang server in the environment. Client systems (using Clevis Pin) can automatically decrypt storage as long as they can establish a network connection to the Tang server. If there is no network connectivity to the Tang server, the storage would have to be decrypted manually.
|
||||
|
||||
The idea behind this is that the Tang server would only be available on an internal network, thus if the encrypted device is lost or stolen, it would no longer have access to the internal network to connect to the Tang server, therefore would not be automatically decrypted.
|
||||
|
||||
For more information on Tang and Clevis, see the man pages (man tang, man clevis) , the [Tang GitHub page][7], and the [Clevis GitHub page][8].
|
||||
|
||||
### Setting up the Tang server
|
||||
|
||||
This example uses another Fedora Linux system as the Tang server with a hostname of tang-server. Start by installing the tang package:
|
||||
|
||||
```
|
||||
dnf install tang
|
||||
```
|
||||
|
||||
Then enable and start the tangd.socket with systemctl:
|
||||
|
||||
```
|
||||
systemctl enable tangd.socket --now
|
||||
```
|
||||
|
||||
Tang uses TCP port 80, so you also need to open that in the firewall:
|
||||
|
||||
```
|
||||
firewall-cmd --add-port=80/tcp --permanent
|
||||
firewall-cmd --add-port=80/tcp
|
||||
```
|
||||
|
||||
Finally, run _tang-show-keys_ to display the output signing key thumbprint. You’ll need this later.
|
||||
|
||||
```
|
||||
# tang-show-keys
|
||||
l3fZGUCmnvKQF_OA6VZF9jf8z2s
|
||||
```
|
||||
|
||||
### Creating the encrypted Stratis Pool
|
||||
|
||||
The previous article on Stratis encryption goes over how to setup an encrypted Stratis pool in detail, so this article won’t cover that in depth.
|
||||
|
||||
The first step is capturing a key that will be used to decrypt the Stratis pool. Even when using NBDE, you need to set this, as it can be used to manually unlock the pool in the event that the NBDE server is unreachable. Capture the pool1 key with the following command:
|
||||
|
||||
```
|
||||
# stratis key set --capture-key pool1key
|
||||
Enter key data followed by the return key:
|
||||
```
|
||||
|
||||
Then I’ll create an encrypted Stratis pool (using the pool1key just created) named pool1 using the _/dev/vdb_ device:
|
||||
|
||||
```
|
||||
# stratis pool create --key-desc pool1key pool1 /dev/vdb
|
||||
```
|
||||
|
||||
Next, create a filesystem in this Stratis pool named filesystem1, create a mount point, mount the filesystem, and create a testfile in it:
|
||||
|
||||
```
|
||||
# stratis filesystem create pool1 filesystem1
|
||||
# mkdir /filesystem1
|
||||
# mount /dev/stratis/pool1/filesystem1 /filesystem1
|
||||
# cd /filesystem1
|
||||
# echo "this is a test file" > testfile
|
||||
```
|
||||
|
||||
### Binding the Stratis pool to the Tang server
|
||||
|
||||
At this point, we have the encrypted Stratis pool created, and also have a filesystem created in the pool. The next step is to bind your Stratis pool to the Tang server that you just setup. Do this with the _stratis pool bind nbde_ command.
|
||||
|
||||
When you make the Tang binding, you need to pass several parameters to the command:
|
||||
|
||||
* the pool name (in this example, pool1)
|
||||
* the key descriptor name (in this example, pool1key)
|
||||
* the Tang server name (in this example, <http://tang-server>)
|
||||
|
||||
|
||||
|
||||
Recall that on the Tang server, you previously ran _tang-show-keys_ which showed the Tang output signing key thumbprint is _l3fZGUCmnvKQF_OA6VZF9jf8z2s_. In addition to the previous parameters, you either need to pass this thumbprint with the parameter _–thumbprint l3fZGUCmnvKQF_OA6VZF9jf8z2s_, or skip the verification of the thumbprint with the _–trust-url_ parameter. ****
|
||||
|
||||
It is more secure to use the _–thumbprint_ parameter. For example:
|
||||
|
||||
```
|
||||
# stratis pool bind nbde pool1 pool1key http://tang-server --thumbprint l3fZGUCmnvKQF_OA6VZF9jf8z2s
|
||||
```
|
||||
|
||||
### Unlocking the Stratis Pool with NBDE
|
||||
|
||||
Next reboot the host, and validate that you can unlock the Stratis pool with NBDE, without requiring the use of the key passphrase. After rebooting the host, the pool is no longer available:
|
||||
|
||||
```
|
||||
# stratis pool list
|
||||
Name Total Physical Properties
|
||||
```
|
||||
|
||||
To unlock the pool using NBDE, run the following command:
|
||||
|
||||
```
|
||||
# stratis pool unlock clevis
|
||||
```
|
||||
|
||||
Note that you did not need to use the key passphrase. This command could be automated to run during the system boot up.
|
||||
|
||||
At this point, the pool is now available:
|
||||
|
||||
```
|
||||
# stratis pool list
|
||||
Name Total Physical Properties
|
||||
pool1 4.98 GiB / 583.65 MiB / 4.41 GiB ~Ca, Cr
|
||||
```
|
||||
|
||||
You can mount the filesystem and access the file that was previously created:
|
||||
|
||||
```
|
||||
# mount /dev/stratis/pool1/filesystem1 /filesystem1/
|
||||
# cat /filesystem1/testfile
|
||||
this is a test file
|
||||
```
|
||||
|
||||
### Rotating Tang server keys
|
||||
|
||||
Best practices recommend that you periodically rotate the Tang server keys and update the Stratis client servers to use the new Tang keys.
|
||||
|
||||
To generate new Tang keys, start by logging in to your Tang server and look at the current status of the /var/db/tang directory. Then, run the _tang-show-keys_ command:
|
||||
|
||||
```
|
||||
# ls -al /var/db/tang
|
||||
total 8
|
||||
drwx------. 1 tang tang 124 Mar 15 15:51 .
|
||||
drwxr-xr-x. 1 root root 16 Mar 15 15:48 ..
|
||||
-rw-r--r--. 1 tang tang 361 Mar 15 15:51 hbjJEDXy8G8wynMPqiq8F47nJwo.jwk
|
||||
-rw-r--r--. 1 tang tang 367 Mar 15 15:51 l3fZGUCmnvKQF_OA6VZF9jf8z2s.jwk
|
||||
# tang-show-keys
|
||||
l3fZGUCmnvKQF_OA6VZF9jf8z2s
|
||||
```
|
||||
|
||||
To generate new keys, run tangd-keygen and point it to the /var/db/tang directory:
|
||||
|
||||
```
|
||||
# /usr/libexec/tangd-keygen /var/db/tang
|
||||
```
|
||||
|
||||
If you look at the /var/db/tang directory again, you will see two new files:
|
||||
|
||||
```
|
||||
# ls -al /var/db/tang
|
||||
total 16
|
||||
drwx------. 1 tang tang 248 Mar 22 10:41 .
|
||||
drwxr-xr-x. 1 root root 16 Mar 15 15:48 ..
|
||||
-rw-r--r--. 1 tang tang 361 Mar 15 15:51 hbjJEDXy8G8wynMPqiq8F47nJwo.jwk
|
||||
-rw-r--r--. 1 root root 354 Mar 22 10:41 iyG5HcF01zaPjaGY6L_3WaslJ_E.jwk
|
||||
-rw-r--r--. 1 root root 349 Mar 22 10:41 jHxerkqARY1Ww_H_8YjQVZ5OHao.jwk
|
||||
-rw-r--r--. 1 tang tang 367 Mar 15 15:51 l3fZGUCmnvKQF_OA6VZF9jf8z2s.jwk
|
||||
```
|
||||
|
||||
And if you run _tang-show-keys_, it will show the keys being advertised by Tang:
|
||||
|
||||
```
|
||||
# tang-show-keys
|
||||
l3fZGUCmnvKQF_OA6VZF9jf8z2s
|
||||
iyG5HcF01zaPjaGY6L_3WaslJ_E
|
||||
```
|
||||
|
||||
You can prevent the old key (starting with l3fZ) from being advertised by renaming the two original files to be hidden files, starting with a period. With this method, the old key will no longer be advertised, however it will still be usable by any existing clients that haven’t been updated to use the new key. Once all clients have been updated to use the new key, these old key files can be deleted.
|
||||
|
||||
```
|
||||
# cd /var/db/tang
|
||||
# mv hbjJEDXy8G8wynMPqiq8F47nJwo.jwk .hbjJEDXy8G8wynMPqiq8F47nJwo.jwk
|
||||
# mv l3fZGUCmnvKQF_OA6VZF9jf8z2s.jwk .l3fZGUCmnvKQF_OA6VZF9jf8z2s.jwk
|
||||
```
|
||||
|
||||
At this point, if you run _tang-show-keys_ again, only the new key is being advertised by Tang:
|
||||
|
||||
```
|
||||
# tang-show-keys
|
||||
iyG5HcF01zaPjaGY6L_3WaslJ_E
|
||||
```
|
||||
|
||||
Next, switch over to your Stratis system and update it to use the new Tang key. Stratis supports doing this while the filesystem(s) are online.
|
||||
|
||||
First, unbind the pool:
|
||||
|
||||
```
|
||||
# stratis pool unbind pool1
|
||||
```
|
||||
|
||||
Next, set the key with the original passphrase used when the encrypted pool was created:
|
||||
|
||||
```
|
||||
# stratis key set --capture-key pool1key
|
||||
Enter key data followed by the return key:
|
||||
```
|
||||
|
||||
Finally, bind the pool to the Tang server with the updated key thumbprint:
|
||||
|
||||
```
|
||||
# stratis pool bind nbde pool1 pool1key http://tang-server --thumbprint iyG5HcF01zaPjaGY6L_3WaslJ_E
|
||||
```
|
||||
|
||||
The Stratis system is now configured to use the updated Tang key. Once any other client systems using the old Tang key have been updated, the two original key files that were renamed to hidden files in the /var/db/tang directory on the Tang server can be backed up and deleted.
|
||||
|
||||
### What if the Tang server is unavailable?
|
||||
|
||||
Next, shutdown the Tang server to simulate it being unavailable, then reboot the Stratis system.
|
||||
|
||||
Again, after the reboot, the Stratis pool is not available:
|
||||
|
||||
```
|
||||
# stratis pool list
|
||||
Name Total Physical Properties
|
||||
```
|
||||
|
||||
If you try to unlock it with NBDE, this fails because the Tang server is unavailable:
|
||||
|
||||
```
|
||||
# stratis pool unlock clevis
|
||||
Execution failed:
|
||||
An iterative command generated one or more errors: The operation 'unlock' on a resource of type pool failed. The following errors occurred:
|
||||
Partial action "unlock" failed for pool with UUID 4d62f840f2bb4ec9ab53a44b49da3f48: Cryptsetup error: Failed with error: Error: Command failed: cmd: "clevis" "luks" "unlock" "-d" "/dev/vdb" "-n" "stratis-1-private-42142fedcb4c47cea2e2b873c08fcf63-crypt", exit reason: 1 stdout: stderr: /dev/vdb could not be opened.
|
||||
```
|
||||
|
||||
At this point, without the Tang server being reachable, the only option to unlock the pool is to use the original key passphrase:
|
||||
|
||||
```
|
||||
# stratis key set --capture-key pool1key
|
||||
Enter key data followed by the return key:
|
||||
```
|
||||
|
||||
You can then unlock the pool using the key:
|
||||
|
||||
```
|
||||
# stratis pool unlock keyring
|
||||
```
|
||||
|
||||
Next, verify the pool was successfully unlocked:
|
||||
|
||||
```
|
||||
# stratis pool list
|
||||
Name Total Physical Properties
|
||||
pool1 4.98 GiB / 583.65 MiB / 4.41 GiB ~Ca, Cr
|
||||
```
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://fedoramagazine.org/network-bound-disk-encryption-with-stratis/
|
||||
|
||||
作者:[briansmith][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://fedoramagazine.org/author/briansmith/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://fedoramagazine.org/wp-content/uploads/2021/03/stratis-nbde-816x345.jpg
|
||||
[2]: https://unsplash.com/@imattsmart?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText
|
||||
[3]: https://unsplash.com/s/photos/lock?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText
|
||||
[4]: https://fedoramagazine.org/getting-started-with-stratis-encryption/
|
||||
[5]: https://stratis-storage.github.io/
|
||||
[6]: https://www.youtube.com/watch?v=CJu3kmY-f5o
|
||||
[7]: https://github.com/latchset/tang
|
||||
[8]: https://github.com/latchset/clevis
|
200
sources/tech/20210407 What is Git cherry-picking.md
Normal file
200
sources/tech/20210407 What is Git cherry-picking.md
Normal file
@ -0,0 +1,200 @@
|
||||
[#]: subject: (What is Git cherry-picking?)
|
||||
[#]: via: (https://opensource.com/article/21/4/cherry-picking-git)
|
||||
[#]: author: (Rajeev Bera https://opensource.com/users/acompiler)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
What is Git cherry-picking?
|
||||
======
|
||||
Learn the what, why, and how of the git cherry-pick command.
|
||||
![Measuring and baking a cherry pie recipe][1]
|
||||
|
||||
Whenever you're working with a group of programmers on a project, whether small or large, handling changes between multiple Git branches can become difficult. Sometimes, instead of combining an entire Git branch into a different one, you want to select and move a couple of specific commits. This procedure is known as "cherry-picking."
|
||||
|
||||
This article will cover the what, why, and how of cherry-picking.
|
||||
|
||||
So let's start.
|
||||
|
||||
### What is cherry-pick?
|
||||
|
||||
With the `cherry-pick` command, Git lets you incorporate selected individual commits from any branch into your current [Git HEAD][2] branch.
|
||||
|
||||
When performing a `git merge` or `git rebase`, all the commits from a branch are combined. The `cherry-pick` command allows you to select individual commits for integration.
|
||||
|
||||
### Benefits of cherry-pick
|
||||
|
||||
The following situation might make it easier to comprehend the way cherry-picking functions.
|
||||
|
||||
Imagine you are implementing new features for your upcoming weekly sprint. When your code is ready, you will push it into the remote branch, ready for testing.
|
||||
|
||||
However, the customer is not delighted with all of the modifications and requests that you present only certain ones. Because the client hasn't approved all changes for the next launch, `git rebase` wouldn't create the desired results. Why? Because `git rebase` or `git merge` will incorporate every adjustment from the last sprint.
|
||||
|
||||
Cherry-picking is the answer! Because it focuses only on the changes added in the commit, cherry-picking brings in only the approved changes without adding other commits.
|
||||
|
||||
There are several other reasons to use cherry-picking:
|
||||
|
||||
* It is essential for bug fixing because bugs are set in the development branch using their commits.
|
||||
* You can avoid unnecessary battles by using `git cherry-pick` instead of other options that apply changes in the specified commits, e.g., `git diff`.
|
||||
* It is a useful tool if a full branch unite is impossible because of incompatible versions in the various Git branches.
|
||||
|
||||
|
||||
|
||||
### Using the cherry-pick command
|
||||
|
||||
In the `cherry-pick` command's simplest form, you can just use the [SHA][3] identifier for the commit you want to integrate into your current HEAD branch.
|
||||
|
||||
To get the commit hash, you can use the `git log` command:
|
||||
|
||||
|
||||
```
|
||||
`$ git log --oneline`
|
||||
```
|
||||
|
||||
Once you know the commit hash, you can use the `cherry-pick` command.
|
||||
|
||||
The syntax is:
|
||||
|
||||
|
||||
```
|
||||
`$ git cherry-pick <commit sha>`
|
||||
```
|
||||
|
||||
For example:
|
||||
|
||||
|
||||
```
|
||||
`$ git cherry-pick 65be1e5`
|
||||
```
|
||||
|
||||
This will dedicate the specified change to your currently checked-out branch.
|
||||
|
||||
If you'd like to make further modifications, you can also instruct Git to add commit changes to your working copy.
|
||||
|
||||
The syntax is:
|
||||
|
||||
|
||||
```
|
||||
`$ git cherry-pick <commit sha> --no-commit`
|
||||
```
|
||||
|
||||
For example:
|
||||
|
||||
|
||||
```
|
||||
`$ git cherry-pick 65be1e5 --no-commit`
|
||||
```
|
||||
|
||||
If you would like to select more than one commit simultaneously, add their commit hashes separated by a space:
|
||||
|
||||
|
||||
```
|
||||
`$ git cherry-pick hash1 hash3`
|
||||
```
|
||||
|
||||
When cherry-picking commits, you can't use the `git pull` command because it fetches _and_ automatically merges commits from one repository into another. The `cherry-pick` command is a tool you use to specifically not do that; instead, use `git fetch`, which fetches commits but does not apply them. There's no doubt that `git pull` is convenient, but it's imprecise.
|
||||
|
||||
### Try it yourself
|
||||
|
||||
To try the process, launch a terminal and generate a sample project:
|
||||
|
||||
|
||||
```
|
||||
$ mkdir fruit.git
|
||||
$ cd fruit.git
|
||||
$ git init .
|
||||
```
|
||||
|
||||
Create some data and commit it:
|
||||
|
||||
|
||||
```
|
||||
$ echo "Kiwifruit" > fruit.txt
|
||||
$ git add fruit.txt
|
||||
$ git commit -m 'First commit'
|
||||
```
|
||||
|
||||
Now, represent a remote developer by creating a fork of your project:
|
||||
|
||||
|
||||
```
|
||||
$ mkdir ~/fruit.fork
|
||||
$ cd !$
|
||||
$ echo "Strawberry" >> fruit.txt
|
||||
$ git add fruit.txt
|
||||
$ git commit -m 'Added a fruit"
|
||||
```
|
||||
|
||||
That's a valid commit. Now, create a bad commit to represent something you wouldn't want to merge into your project:
|
||||
|
||||
|
||||
```
|
||||
$ echo "Rhubarb" >> fruit.txt
|
||||
$ git add fruit.txt
|
||||
$ git commit -m 'Added a vegetable that tastes like a fruit"
|
||||
```
|
||||
|
||||
Return to your authoritative repo and fetch the commits from your imaginary developer:
|
||||
|
||||
|
||||
```
|
||||
$ cd ~/fruit.git
|
||||
$ git remote add dev ~/fruit.fork
|
||||
$ git fetch dev
|
||||
remote: Counting objects: 6, done.
|
||||
remote: Compressing objects: 100% (2/2), done.
|
||||
remote: Total 6 (delta 0), reused 0 (delta 0)
|
||||
Unpacking objects: 100% (6/6), done...
|
||||
|
||||
[/code] [code]
|
||||
|
||||
$ git log –oneline dev/master
|
||||
e858ab2 Added a vegetable that tastes like a fruit
|
||||
0664292 Added a fruit
|
||||
b56e0f8 First commit
|
||||
```
|
||||
|
||||
You've fetched the commits from your imaginary developer, but you haven't merged them into your repository yet. You want to accept the second commit but not the third, so use `cherry-pick`:
|
||||
|
||||
|
||||
```
|
||||
`$ git cherry-pick 0664292`
|
||||
```
|
||||
|
||||
The second commit is now in your repository:
|
||||
|
||||
|
||||
```
|
||||
$ cat fruit.txt
|
||||
Kiwifruit
|
||||
Strawberry
|
||||
```
|
||||
|
||||
Push your changes to your remote server, and you're done!
|
||||
|
||||
### Reasons to avoid cherry-picking
|
||||
|
||||
Cherry-picking is usually discouraged in the developer community. The primary reason is that it creates duplicate commits, but you also lose the ability to track your commit history.
|
||||
|
||||
If you're cherry-picking a lot of commits out of order, those commits will be recorded in your branch, and it might lead to undesirable results in your Git branch.
|
||||
|
||||
Cherry-picking is a powerful command that might cause problems if it's used without a proper understanding of what might occur. However, it may save your life (or at least your day job) when you mess up and make commits to the wrong branches.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/4/cherry-picking-git
|
||||
|
||||
作者:[Rajeev Bera][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/acompiler
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/pictures/cherry-picking-recipe-baking-cooking.jpg?itok=XVwse6hw (Measuring and baking a cherry pie recipe)
|
||||
[2]: https://acompiler.com/git-head/
|
||||
[3]: https://en.wikipedia.org/wiki/Secure_Hash_Algorithms
|
@ -0,0 +1,114 @@
|
||||
[#]: subject: (Why I love using bspwm for my Linux window manager)
|
||||
[#]: via: (https://opensource.com/article/21/4/bspwm-linux)
|
||||
[#]: author: (Stephen Adams https://opensource.com/users/stevehnh)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
Why I love using bspwm for my Linux window manager
|
||||
======
|
||||
Install, configure, and start using the bspwm window manager on Fedora
|
||||
Linux.
|
||||
![Tall building with windows][1]
|
||||
|
||||
Some folks like to rearrange furniture. Other folks like to try new shoes or redecorate their bedroom on the regular. Me? I try out Linux desktops.
|
||||
|
||||
After drooling over some of the incredible desktop environments I've seen online, I got curious about one window manager in particular: [bspwm][2].
|
||||
|
||||
![bspwm desktop][3]
|
||||
|
||||
(Stephen Adams, [CC BY-SA 4.0][4])
|
||||
|
||||
I've been a fan of the [i3][5] window manager for quite a while, and I enjoy the way everything is laid out and the ease of getting started. But something about bspwm called to me. There are a few reasons I decided to try it out:
|
||||
|
||||
* It is _only_ a window manager.
|
||||
* It is managed by a few easy-to-configure scripts.
|
||||
* It supports gaps between windows by default.
|
||||
|
||||
|
||||
|
||||
The first reason—that it is simply a window manager—is probably the top thing to point out. Like i3, there are no graphical bells and whistles applied by default. You can certainly customize it to your heart's content, but _you_ will be putting in all the work to make it look like you want. That's part of its appeal to me.
|
||||
|
||||
Although it is available on many distributions, my examples use Fedora Linux.
|
||||
|
||||
### Install bspwm
|
||||
|
||||
Bspwm is packaged in most common distributions, so you can install it with your system's package manager. This command also installs [sxkhd][6], a daemon for the X Window System "that reacts to input events by executing commands," and [dmenu][7], a generic X Window menu:
|
||||
|
||||
|
||||
```
|
||||
`dnf install bspwm sxkhd dmenu`
|
||||
```
|
||||
|
||||
Since bspwm is _just_ a window manager, there aren't any built-in shortcuts or keyboard commands. This is where it stands in contrast to something like i3. sxkhd makes it easier to get going. So, go ahead and configure sxkhd before you fire up the window manager for the first time:
|
||||
|
||||
|
||||
```
|
||||
systemctl start sxkhd
|
||||
systemctl enable sxkhd
|
||||
```
|
||||
|
||||
This enables sxkhd at login, but you also need a configuration with some basic functionality ready to go:
|
||||
|
||||
|
||||
```
|
||||
`curl https://raw.githubusercontent.com/baskerville/bspwm/master/examples/sxhkdrc --output ~/.config/sxkhd/sxkhdrc`
|
||||
```
|
||||
|
||||
It's worth taking a look at this file before you get much further, as some commands that the scripts call may not exist on your system. A good example is the `super + Return` shortcut that calls `urxvt`. Change this to your preferred terminal, especially if you do not have urxvt installed:
|
||||
|
||||
|
||||
```
|
||||
#
|
||||
# wm independent hotkeys
|
||||
#
|
||||
|
||||
# terminal emulator
|
||||
super + Return
|
||||
urxvt
|
||||
|
||||
# program launcher
|
||||
super + @space
|
||||
dmenu_run
|
||||
```
|
||||
|
||||
If you are using GDM, LightDM, or another display manager, just choose bspwm before logging in.
|
||||
|
||||
### Configure bspwm
|
||||
|
||||
Once you are logged in, you'll see a whole lot of nothing on the screen. That's not a sense of emptiness you feel. It's possibility! You are now ready to start fiddling with all the parts of a desktop environment that you have taken for granted all these years. Building from scratch is not easy, but it's very rewarding once you get the hang of it.
|
||||
|
||||
The most difficult thing about any window manager is getting a handle on the shortcuts. You're going to be slow to start, but in a short time, you'll be flying around your system using your keyboard alone and looking like an ultimate hacker to your friends and family.
|
||||
|
||||
You can tailor the system as much as you want by editing `~/.config/bspwm/bspwmrc` to add apps at launch, set up your desktops and monitors, and set rules for how your windows should behave. There are a few examples set by default to get you going. Keyboard shortcuts are all managed by the **sxkhdrc** file.
|
||||
|
||||
There are plenty more open source projects to install to really get things looking nice—like [Feh][8] for desktop backgrounds, [Polybar][9] for that all-important status bar, [Rofi][10] to really help your app launcher pop, and [Compton][11] to give you the shadows and transparency to get things nice and shiny.
|
||||
|
||||
Happy hacking!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/4/bspwm-linux
|
||||
|
||||
作者:[Stephen Adams][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/stevehnh
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/windows_building_sky_scale.jpg?itok=mH6CAX29 (Tall building with windows)
|
||||
[2]: https://github.com/baskerville/bspwm
|
||||
[3]: https://opensource.com/sites/default/files/uploads/bspwm-desktop.png (bspwm desktop)
|
||||
[4]: https://creativecommons.org/licenses/by-sa/4.0/
|
||||
[5]: https://i3wm.org/
|
||||
[6]: https://github.com/baskerville/sxhkd
|
||||
[7]: https://linux.die.net/man/1/dmenu
|
||||
[8]: https://github.com/derf/feh
|
||||
[9]: https://github.com/polybar/polybar
|
||||
[10]: https://github.com/davatorium/rofi
|
||||
[11]: https://github.com/chjj/compton
|
@ -0,0 +1,73 @@
|
||||
[#]: subject: (5 signs you might be a Rust programmer)
|
||||
[#]: via: (https://opensource.com/article/21/3/rust-programmer)
|
||||
[#]: author: (Mike Bursell https://opensource.com/users/mikecamel)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (wxy)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
你可能是 Rust 程序员的五个迹象
|
||||
======
|
||||
|
||||
> 在我学习 Rust 的过程中,我注意到了 Rust 一族的一些常见行为。
|
||||
|
||||
![name tag that says hello my name is open source][1]
|
||||
|
||||
我是最近才 [皈依 Rust][2] 的,我大约在 2020 年 4 月底开始学习。但是,像许多皈依者一样,我还是一个热情的布道者。说实话,我也不是一个很好的 Rust 人,因为我的编码风格不是很好,我写的也不是特别符合 Rust 习惯。我猜想这一方面是因为我在写大量代码之前还没有没有真正学完 Rust(其中一些代码又困扰了我),另一方面是因为我并不是那么优秀的程序员。
|
||||
|
||||
但我喜欢 Rust,你也应该喜欢。它很友好,比 C 或 C++ 更友好;它为低级系统任务做好了准备,这比 Python 做的更好;而且结构良好,这要超过 Perl;而且,最重要的是,它从设计层面开始,它就是完全开源的,这要比 Java 那些语言好得多。
|
||||
|
||||
尽管我缺乏专业知识,但我注意到了一些我认为是许多 Rust 爱好者和程序员的共同点。如果你对以下五个迹象说“是”(其中第一个迹象是由最近的一些令人兴奋的新闻引发的),那么你也可能是一个 Rust 程序员。
|
||||
|
||||
### 1、“基金会”一词会使你兴奋
|
||||
|
||||
对于 Rust 程序员来说,“基金会”一词将不再与<ruby>艾萨克·阿西莫夫<rt>Isaac Asimov</rt></ruby>关联在一起,而是与新成立的 [Rust 基金会][3] 关联。微软、华为、谷歌、AWS 和Mozilla 正在为该基金会提供了董事(大概也是大部分初始资金),该基金会将负责该语言的各个方面,“预示着 Rust 成为企业生产级技术的到来”,[根据临时执行董事][4] Ashley Williams 说。(顺便说一句,很高兴看到一位女士领导这样一项重大的行业计划。)
|
||||
|
||||
该基金会似乎致力于维护 Rust 的理念,并确保每个人都有参与的机会。在许多方面,Rust 都是开源项目的典型示例。并不是说它是完美的(无论是语言还是社区),而是因为似乎有足够的爱好者致力于维护高参与度、低门槛的社区方法,我认为这是许多开源项目的核心。我强烈欢迎此举,我认为此举只会帮助促进 Rust 在未来数年和数月内的采用和成熟。
|
||||
|
||||
### 2、你会因为新闻源中提到 Rust 游戏而感到沮丧
|
||||
|
||||
还有一款和电脑有关的东西,也叫做“Rust”,它是一款“只限多玩家的生存电子游戏”。它比 Rust 这个语言更新一些(2013 年宣布,2018 年发布),但我曾经在搜索 Rust 相关的内容时,犯了一个错误,这个名字搜索了游戏。互联网络就是这样的,这意味着我的新闻源现在被这个另类的 Rust 野兽感染了,我现在会从它的影迷和公关人员那里随机得到一些更新消息。这是个低调的烦恼,但我很确定在 Rust(语言)社区中并不是就我一个人这样。我强烈建议,如果你确实想了解更多关于这个计算世界的后起之秀的信息,你可以使用一个提高隐私(我拒绝说 "保护隐私")的 [开源浏览器][5] 来进行研究。
|
||||
|
||||
### 3、“不安全”这个词会让你感到恐惧。
|
||||
|
||||
Rust(语言,再次强调)在帮助你做**正确的事情**™方面做得非常好,当然,在内存安全方面,这是 C 和 C++ 内部的主要关注点(不是因为不可能做到,而是因为真的很难持续正确)。Dave Herman 在 2016 年写了一篇文章,讲述了为什么安全是 Rust 语言的一个积极属性:《[Safety is Rust's fireflower][6]》。安全性(内存、类型安全)可能并不赏心悦目,但随着你写的 Rust 越多,你就会习惯并感激它,尤其是当你参与任何系统编程时,这也是 Rust 经常擅长的地方。
|
||||
|
||||
现在,Rust 并不能阻止你做**错误的事情**™,但它确实通过让你使用 `unsafe` 关键字,让你在希望超出安全范围的时候做出一个明智的决定。这不仅对你有好处,因为它(希望)会让你非常、非常仔细地思考你在任何使用它的代码块中放入了什么;它对任何阅读你的代码的人也有好处,这是一个触发词,它能让任何不太清醒的 Rust 人至少微微打起精神,在椅子上坐直,然后想:“嗯,这里发生了什么?我需要特别注意。”如果幸运的话,读你代码的人也许能想到重写它的方法,使它利用到 Rust 的安全特性,或者至少减少了提交和发布的不安全代码的数量。
|
||||
|
||||
### 4、你想知道为什么没有 `?;`、`{:?}` 、`::<>` 这样的表情符号
|
||||
|
||||
人们喜欢(或讨厌)涡轮鱼(`::<>`),但在 Rust 代码中你经常还会看到其他的语义结构。特别是 `{:?}` (用于字符串格式化)和 `?;`(`?` 是向调用栈传播错误的一种方式,`;` 则是行/块的结束符,所以你经常会看到它们在一起)。它们在 Rust 代码中很常见,你只需边走边学,边走边解析,而且它们也很有用,我有时会想,为什么它们没有被纳入到正常对话中,至少作为表情符号。可能还有其他的。你有什么建议?
|
||||
|
||||
### 5、Clippy 是你的朋友(而不是一个动画回形针)
|
||||
|
||||
微软的动画回形针 Clippy 可能是 Office 用户很快就觉得讨厌的“功能”,并成为许多 [模因][7] 的起点。另一方面,`cargo clippy` 是那些 [很棒的 Cargo 命令][8] 之一,应该成为每个 Rust 程序员工具箱的一部分。Clippy 是一个语言整洁器,它可以帮助改进你的代码,使它更干净、更整洁、更易读、更惯用,让你与同事或其他人分享 Rust 代码时,不会感到尴尬。Cargo 可以说是让 “Clippy” 这个名字恢复了声誉,虽然我不会选择给我的孩子起这个名字,但现在每当我在网络上遇到这个词的时候,我不会再有一种不安的感觉。
|
||||
|
||||
* * *
|
||||
|
||||
这篇文章最初发表在 [Alice, Eve, and Bob] [9]上,经作者许可转载。
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/3/rust-programmer
|
||||
|
||||
作者:[Mike Bursell][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[wxy](https://github.com/wxy)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/mikecamel
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/EDU_OSDC_IntroOS_520x292_FINAL.png?itok=woiZamgj (name tag that says hello my name is open source)
|
||||
[2]: https://opensource.com/article/20/6/why-rust
|
||||
[3]: https://foundation.rust-lang.org/
|
||||
[4]: https://foundation.rust-lang.org/posts/2021-02-08-hello-world/
|
||||
[5]: https://opensource.com/article/19/7/open-source-browsers
|
||||
[6]: https://www.thefeedbackloop.xyz/safety-is-rusts-fireflower/
|
||||
[7]: https://knowyourmeme.com/memes/clippy
|
||||
[8]: https://opensource.com/article/20/11/commands-rusts-cargo
|
||||
[9]: https://aliceevebob.com/2021/02/09/5-signs-that-you-may-be-a-rust-programmer/
|
@ -0,0 +1,191 @@
|
||||
[#]: subject: (Why I love using the IPython shell and Jupyter notebooks)
|
||||
[#]: via: (https://opensource.com/article/21/3/ipython-shell-jupyter-notebooks)
|
||||
[#]: author: (Ben Nuttall https://opensource.com/users/bennuttall)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
为什么我喜欢使用 IPython shell 和 Jupyter Notebook
|
||||
======
|
||||
Jupyter Notebook 将IPython shell 提升到一个新的高度。
|
||||
![Computer laptop in space][1]
|
||||
|
||||
Jupyter 项目最初是以 IPython 和 IPython Notebook 的形式出现的。它最初是一个专门针对 Python 的交互式 shell 和笔记本环境,后来扩展为不分语言的环境,支持 Julia、Python 和 R,以及其他任何语言。
|
||||
|
||||
![Jupyter][2]
|
||||
|
||||
(Ben Nuttall, [CC BY-SA 4.0][3])
|
||||
|
||||
IPython 是一个 Python shell,类似于你在命令行输入 `python` 或者 `python3` 时看到的,但它更聪明,更有用。如果你曾经在 Python shell 中输入过多行命令,并且想重复它,你就会理解每次都要一行一行地滚动浏览历史记录的挫败感。有了 IPython,你可以一次滚动浏览整个块,同时还可以逐行浏览和编辑这些块的部分内容。
|
||||
|
||||
![iPython][4]
|
||||
|
||||
(Ben Nuttall, [CC BY-SA 4.0][3])
|
||||
|
||||
它具有自动补全,并提供上下文感知的建议:
|
||||
|
||||
![iPython offers suggestions][5]
|
||||
|
||||
(Ben Nuttall, [CC BY-SA 4.0][3])
|
||||
|
||||
它默认漂亮输出:
|
||||
|
||||
![iPython pretty prints][6]
|
||||
|
||||
(Ben Nuttall, [CC BY-SA 4.0][3])
|
||||
|
||||
它甚至允许你运行 shell 命令:
|
||||
|
||||
![IPython shell commands][7]
|
||||
|
||||
(Ben Nuttall, [CC BY-SA 4.0][3])
|
||||
|
||||
它还提供了一些有用的功能,比如将 `?` 添加到对象中,作为运行 `help()` 的快捷方式,而不会破坏你的流程:
|
||||
|
||||
![IPython help][8]
|
||||
|
||||
(Ben Nuttall, [CC BY-SA 4.0][3])
|
||||
|
||||
如果你使用的是虚拟环境(参见我关于 [virtualenvwrapper][9] 的帖子),在环境中用 pip 安装:
|
||||
|
||||
|
||||
```
|
||||
`pip install ipython`
|
||||
```
|
||||
|
||||
要在全系统范围内安装,你可以在 Debian、Ubuntu 或树莓派上使用apt:
|
||||
|
||||
|
||||
```
|
||||
`sudo apt install ipython3`
|
||||
```
|
||||
|
||||
或使用 pip:
|
||||
|
||||
|
||||
```
|
||||
`sudo pip3 install ipython`
|
||||
```
|
||||
|
||||
### Jupyter Notebook
|
||||
|
||||
Jupyter Notebook 将 IPython shell 提升到了一个新的高度。首先,它们是基于浏览器的,而不是基于终端的。要开始使用,请安装 `jupyter`。
|
||||
|
||||
如果你使用的是虚拟环境,请在环境中使用 pip 进行安装:
|
||||
|
||||
|
||||
```
|
||||
`pip install jupyter`
|
||||
```
|
||||
|
||||
要在全系统范围内安装,你可以在 Debian、Ubuntu 或树莓派上使用 apt:
|
||||
|
||||
|
||||
```
|
||||
`sudo apt install jupyter-notebook`
|
||||
```
|
||||
|
||||
或使用 pip:
|
||||
|
||||
|
||||
```
|
||||
`sudo pip3 install jupyter`
|
||||
```
|
||||
|
||||
启动 Notebook:
|
||||
|
||||
|
||||
```
|
||||
`jupyter notebook`
|
||||
```
|
||||
|
||||
这将在你的浏览器中打开:
|
||||
|
||||
![Jupyter Notebook][10]
|
||||
|
||||
(Ben Nuttall, [CC BY-SA 4.0][3])
|
||||
|
||||
你可以使用 **New** 下拉菜单创建一个新的 Python 3 Notebook:
|
||||
|
||||
![Python 3 in Jupyter Notebook][11]
|
||||
|
||||
(Ben Nuttall, [CC BY-SA 4.0][3])
|
||||
|
||||
现在你可以在 `In[ ]` 字段中编写和执行命令。使用**回车**在代码块中换行,使用 **Shift+回车**来执行:
|
||||
|
||||
![Executing commands in Jupyter][12]
|
||||
|
||||
(Ben Nuttall, [CC BY-SA 4.0][3])
|
||||
|
||||
你可以编辑和重新运行代码块,你可以重新排序、删除,复制/粘贴,等等。你可以以任何顺序运行代码块,但是要注意的是,任何创建的变量的作用域都将根据执行的时间而不是它们在 Notebook 中出现的顺序。你可以在 **Kernel** 菜单中重启并清除输出或重启并运行所有的代码块。
|
||||
|
||||
使用 `print` 函数每次都会输出。但是如果你有一条没有分配的语句,或者最后一条语句没有分配,那么它总是会输出:
|
||||
|
||||
![Jupyter output][13]
|
||||
|
||||
(Ben Nuttall, [CC BY-SA 4.0][3])
|
||||
|
||||
你甚至可以把 `In `和 `Out` 作为可索引对象:
|
||||
|
||||
![Jupyter output][14]
|
||||
|
||||
(Ben Nuttall, [CC BY-SA 4.0][3])
|
||||
|
||||
All the IPython features are available and are often presented a little nicer, too:
|
||||
所有的 IPython 功能都可以使用,而且通常也会表现得更漂亮一些:
|
||||
|
||||
![Jupyter supports IPython features][15]
|
||||
|
||||
(Ben Nuttall, [CC BY-SA 4.0][3])
|
||||
|
||||
你甚至可以使用 [Matplotlib][16] 进行内联绘图:
|
||||
|
||||
![Graphing in Jupyter Notebook][17]
|
||||
|
||||
(Ben Nuttall, [CC BY-SA 4.0][3])
|
||||
|
||||
最后,你可以保存您的笔记本,并将其包含在 Git 仓库中,如果你将其推送到 GitHub,它们将作为已完成的 Notebook 被渲染:输出、图形和所有一切(如 [本例][18]):
|
||||
|
||||
![Saving Notebook to GitHub][19]
|
||||
|
||||
(Ben Nuttall, [CC BY-SA 4.0][3])
|
||||
|
||||
* * *
|
||||
|
||||
_本文原载于 Ben Nuttall 的 [Tooling Tuesday 博客][20],经许可后重用。_
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/3/ipython-shell-jupyter-notebooks
|
||||
|
||||
作者:[Ben Nuttall][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/bennuttall
|
||||
[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://opensource.com/sites/default/files/uploads/jupyterpreview.png (Jupyter)
|
||||
[3]: https://creativecommons.org/licenses/by-sa/4.0/
|
||||
[4]: https://opensource.com/sites/default/files/uploads/ipython-loop.png (iPython)
|
||||
[5]: https://opensource.com/sites/default/files/uploads/ipython-suggest.png (iPython offers suggestions)
|
||||
[6]: https://opensource.com/sites/default/files/uploads/ipython-pprint.png (iPython pretty prints)
|
||||
[7]: https://opensource.com/sites/default/files/uploads/ipython-ls.png (IPython shell commands)
|
||||
[8]: https://opensource.com/sites/default/files/uploads/ipython-help.png (IPython help)
|
||||
[9]: https://opensource.com/article/21/2/python-virtualenvwrapper
|
||||
[10]: https://opensource.com/sites/default/files/uploads/jupyter-notebook-1.png (Jupyter Notebook)
|
||||
[11]: https://opensource.com/sites/default/files/uploads/jupyter-python-notebook.png (Python 3 in Jupyter Notebook)
|
||||
[12]: https://opensource.com/sites/default/files/uploads/jupyter-loop.png (Executing commands in Jupyter)
|
||||
[13]: https://opensource.com/sites/default/files/uploads/jupyter-cells.png (Jupyter output)
|
||||
[14]: https://opensource.com/sites/default/files/uploads/jupyter-cells-2.png (Jupyter output)
|
||||
[15]: https://opensource.com/sites/default/files/uploads/jupyter-help.png (Jupyter supports IPython features)
|
||||
[16]: https://matplotlib.org/
|
||||
[17]: https://opensource.com/sites/default/files/uploads/jupyter-graph.png (Graphing in Jupyter Notebook)
|
||||
[18]: https://github.com/piwheels/stats/blob/master/2020.ipynb
|
||||
[19]: https://opensource.com/sites/default/files/uploads/savenotebooks.png (Saving Notebook to GitHub)
|
||||
[20]: https://tooling.bennuttall.com/the-ipython-shell-and-jupyter-notebooks/
|
Loading…
Reference in New Issue
Block a user