Merge remote-tracking branch 'LCTT/master'

This commit is contained in:
Xingyu Wang 2019-09-26 20:10:23 +08:00
commit 9968944e93
14 changed files with 1219 additions and 352 deletions

View File

@ -0,0 +1,93 @@
技术如何改变敏捷的规则
======
> 当我们开始推行敏捷时,还没有容器和 Kubernetes。但是它们改变了过去最困难的部分将敏捷性从小团队应用到整个组织。
![](https://img.linux.net.cn/data/attachment/album/201909/26/113910ytmoosx5tt79gan5.jpg)
越来越多的企业正因为一个非常明显的原因开始尝试敏捷和 [DevOps][1]: 企业需要通过更快的速度和更多的实验为创新和竞争性提供优势。而 DevOps 将帮助我们得到所需的创新速度。但是,在小团队或初创企业中实践 DevOps 与进行大规模实践完全是两码事。我们都明白这样的一个事实,那就是在十个人的跨职能团队中能够很好地解决问题的方案,当将相同的模式应用到一百个人的团队中时就可能无法奏效。这条道路是如此艰难,以至于 IT 领导者最简单的应对就是将敏捷方法的推行再推迟一年。
但那样的时代已经结束了。如果你已经尝试过,但是没有成功,那么现在是时候重新开始了。
到目前为止DevOps 需要为许多组织提供个性化的解决方案,因此往往需要进行大量的调整以及付出额外的工作。但在今天,[Linux 容器][2]和 Kubernetes 正在推动 DevOps 工具和过程的标准化。而这样的标准化将会加速整个软件开发过程。因此,我们用来实践 DevOps 工作方式的技术最终能够满足我们加快软件开发速度的愿望。
Linux 容器和 [Kubernetes][3] 正在改变团队交互的方式。此外,你可以在 Kubernetes 平台上运行任何能够在 Linux 运行的应用程序。这意味着什么呢?你可以运行大量的企业及应用程序(甚至可以解决以前令人烦恼的 Windows 和 Linux 之间的协调问题)。最后,容器和 Kubernetes 能够满足你未来将要运行的几乎所有工作。它们正在经受着未来的考验,以应对机器学习、人工智能和分析工作等下一代解决问题工具。
让我们以机器学习为例来思考一下。今天,人们可以在大量的企业数据中找到一些模式。当机器发现这些模式时(想想机器学习),你的员工就能更快地采取行动。随着人工智能的加入,机器不仅可以发现模式,还可以对模式进行操作。如今,一个积极的软件开发冲刺周期也就是三个星期而已。有了人工智能,机器每秒可以多次修改代码。创业公司会利用这种能力来“打扰你”。
考虑一下你需要多快才能参与到竞争当中。如果你对于无法对于 DevOps 和每周一个迭代周期充满信心,那么考虑一下当那个创业公司将 AI 驱动的过程指向你时会发生什么?现在是时候转向 DevOps 的工作方式了,否则就会像你的竞争对手一样被甩在后面。
### 容器技术如何改变团队的工作?
DevOps 使得许多试图将这种工作方式扩展到更大范围的团队感到沮丧。即使许多 IT和业务人员之前都听说过敏捷相关的语言、框架、模型如 DevOps而这些都有望彻底应用程序开发和 IT 流程,但他们还是对此持怀疑态度。
向你的受众“推销”快速开发冲刺也不是一件容易的事情。想象一下,如果你以这种方式买了一栋房子 —— 你将不再需要向开发商支付固定的金额,而是会得到这样的信息:“我们将在 4 周内浇筑完地基,其成本是 X之后再搭建房屋框架和铺设电路但是我们现在只能够知道地基完成的时间表。”人们已经习惯了买房子的时候有一个预先的价格和交付时间表。
挑战在于构建软件与构建房屋不同。同一个建筑商往往建造了成千上万个完全相同的房子,而软件项目从来都各不相同。这是你要克服的第一个障碍。
开发和运维团队的工作方式确实不同,我之所以知道这一点是因为我曾经从事过这两方面的工作。企业往往会用不同的方式来激励他们,开发人员会因为更改和创建而获得奖励,而运维专家则会因降低成本和确保安全性而获得奖励。我们会把他们分成不同的小组,并且尽量减少互动。而这些角色通常会吸引那些思维方式完全不同的技术人员。但是这样的解决方案注定会失败,你必须打破横亘在开发和运维之间的藩篱。
想想传统情况下会发生什么。业务会把需求扔过墙,这是因为他们在“买房”模式下运作,并且说上一句“我们 9 个月后见。”开发人员根据这些需求进行开发,并根据技术约束的需要进行更改。然后,他们把它扔过墙传递给运维人员,并说一句“搞清楚如何运行这个软件”。然后,运维人员勤就会勤奋地进行大量更改,使软件与基础设施保持一致。然而,最终的结果是什么呢?
通常情况下,当业务人员看到需求实现的最终结果时甚至根本辨认不出。在过去 20 年的大部分时间里,我们一次又一次地目睹了这种模式在软件行业中上演。而现在,是时候改变了。
Linux 容器能够真正地解决这样的问题,这是因为容器弥合开发和运维之间的鸿沟。容器技术允许两个团队共同理解和设计所有的关键需求,但仍然独立地履行各自团队的职责。基本上,我们去掉了开发人员和运维人员之间的电话游戏。
有了容器技术,我们可以使得运维团队的规模更小,但依旧能够承担起数百万应用程序的运维工作,并且能够使得开发团队可以更加快速地根据需要更改软件。(在较大的组织中,所需的速度可能比运维人员的响应速度更快。)
有了容器技术,你可以将所需要交付的内容与它运行的位置分开。你的运维团队只需要负责运行容器的主机和安全的内存占用,仅此而已。这意味着什么呢?
首先,这意味着你现在可以和团队一起实践 DevOps 了。没错,只需要让团队专注于他们已经拥有的专业知识,而对于容器,只需让团队了解所需集成依赖关系的必要知识即可。
如果你想要重新训练每个人,没有人会精通所有事情。容器技术允许团队之间进行交互,但同时也会为每个团队提供一个围绕该团队优势而构建的强大边界。开发人员会知道需要消耗什么资源,但不需要知道如何使其大规模运行。运维团队了解核心基础设施,但不需要了解应用程序的细节。此外,运维团队也可以通过更新应用程序来解决新的安全问题,以免你成为下一个数据泄露的热门话题。
想要为一个大型 IT 组织,比如 30000 人的团队教授运维和开发技能?那或许需要花费你十年的时间,而你可能并没有那么多时间。
当人们谈论“构建新的云原生应用程序将帮助我们摆脱这个问题”时,请批判性地进行思考。你可以在 10 个人的团队中构建云原生应用程序,但这对《财富》杂志前 1000 强的企业而言或许并不适用。除非你不再需要依赖现有的团队否则你无法一个接一个地构建新的微服务你最终将成为一个孤立的组织。这是一个诱人的想法但你不能指望这些应用程序来重新定义你的业务。我还没见过哪家公司能在如此大规模的并行开发中获得成功。IT 预算已经受到限制;在很长时间内,将预算翻倍甚至三倍是不现实的。
### 当奇迹发生时:你好,速度
Linux 容器就是为扩容而生的。一旦你开始这样做,[Kubernetes 之类的编制工具就会发挥作用][6],这是因为你将需要运行数千个容器。应用程序将不仅仅由一个容器组成,它们将依赖于许多不同的部分,所有的部分都会作为一个单元运行在容器上。如果不这样做,你的应用程序将无法在生产环境中很好地运行。
思考一下有多少小滑轮和杠杆组合在一起来支撑你的业务对于任何应用程序都是如此。开发人员负责应用程序中的所有滑轮和杠杆。如果开发人员没有这些组件你可能会在集成时做噩梦。与此同时无论是在线下还是在云上运维团队都会负责构成基础设施的所有滑轮和杠杆。做一个较为抽象的比喻使用Kubernetes你的运维团队就可以为应用程序提供运行所需的燃料但又不必成为所有方面的专家。
开发人员进行实验,运维团队则保持基础设施的安全和可靠。这样的组合使得企业敢于承担小风险,从而实现创新。不同于打几个孤注一掷的赌,公司中真正的实验往往是循序渐进的和快速的。
从个人经验来看,这就是组织内部发生的显著变化:因为人们说:“我们如何通过改变计划来真正地利用这种实验能力?”它会强制执行敏捷计划。
举个例子,使用 DevOps 模型、容器和 Kubernetes 的 KeyBank 如今每天都会部署代码。(观看[视频][7],其中主导了 KeyBank 持续交付和反馈的 John Rzeszotarski 将解释这一变化。类似地Macquarie 银行也借助 DevOps 和容器技术每天将一些东西投入生产环境。
一旦你每天都推出软件,它就会改变你计划的每一个方面,并且会[加速业务的变化速度][8]。Macquarie 银行和金融服务集团的 CDOLuis Uguina 表示:“创意可以在一天内触达客户。”(参见对 Red Hat 与 Macquarie 银行合作的[案例研究][9])。
### 是时候去创造一些伟大的东西了
Macquarie 的例子说明了速度的力量。这将如何改变你的经营方式记住Macquarie 不是一家初创企业。这是 CIO 们所面临的颠覆性力量,它不仅来自新的市场进入者,也来自老牌同行。
开发人员的自由还改变了运营敏捷商店的 CIO 们的人才方程式。突然之间大公司里的个体即使不是在最热门的行业或地区也可以产生巨大的影响。Macquarie 利用这一变动作为招聘工具,并向开发人员承诺,所有新招聘的员工将会在第一周内推出新产品。
与此同时,在这个基于云的计算和存储能力的时代,我们比以往任何时候都拥有更多可用的基础设施。考虑到[机器学习和人工智能工具将很快实现的飞跃][10],这是幸运的。
所有这些都说明现在正是打造伟大事业的好时机。考虑到市场创新的速度,你需要不断地创造伟大的东西来保持客户的忠诚度。因此,如果你一直在等待将赌注押在 DevOps 上,那么现在就是正确的时机。容器技术和 Kubernetes 改变了规则,并且对你有利。
--------------------------------------------------------------------------------
via: https://enterprisersproject.com/article/2018/1/how-technology-changes-rules-doing-agile
作者:[Matt Hicks][a]
译者:[JayFrank](https://github.com/JayFrank)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://enterprisersproject.com/user/matt-hicks
[1]:https://enterprisersproject.com/tags/devops
[2]:https://www.redhat.com/en/topics/containers?intcmp=701f2000000tjyaAAA
[3]:https://www.redhat.com/en/topics/containers/what-is-kubernetes?intcmp=701f2000000tjyaAAA
[4]:https://enterprisersproject.com/article/2017/8/4-container-adoption-patterns-what-you-need-know?sc_cid=70160000000h0aXAAQ
[5]:https://enterprisersproject.com/devops?sc_cid=70160000000h0aXAAQ
[6]:https://enterprisersproject.com/article/2017/11/how-enterprise-it-uses-kubernetes-tame-container-complexity
[7]:https://www.redhat.com/en/about/videos/john-rzeszotarski-keybank-red-hat-summit-2017?intcmp=701f2000000tjyaAAA
[8]:https://enterprisersproject.com/article/2017/11/dear-cios-stop-beating-yourselves-being-behind-transformation
[9]:https://www.redhat.com/en/resources/macquarie-bank-case-study?intcmp=701f2000000tjyaAAA
[10]:https://enterprisersproject.com/article/2018/1/4-ai-trends-watch
[11]:https://enterprisersproject.com/email-newsletter?intcmp=701f2000000tsjPAAQ

View File

@ -1,114 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (PsiACE)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Building a Messenger App: Schema)
[#]: via: (https://nicolasparada.netlify.com/posts/go-messenger-schema/)
[#]: author: (Nicolás Parada https://nicolasparada.netlify.com/)
Building a Messenger App: Schema
======
New post on building a messenger app. You already know this kind of app. They allow you to have conversations with your friends. [Facebook Messenger][1], [WhatsApp][2] and [Skype][3] are a few examples. Tho, these apps allows you to send pictures, stream video, record audio, chat with large groups of people, etc… Well try to keep it simple and just send text messages between two users.
Well use [CockroachDB][4] as the SQL database, [Go][5] as the backend language, and JavaScript to make a web app.
In this first post, were getting around the database design.
```
CREATE TABLE users (
id SERIAL NOT NULL PRIMARY KEY,
username STRING NOT NULL UNIQUE,
avatar_url STRING,
github_id INT NOT NULL UNIQUE
);
```
Of course, this app requires users. We will go with social login. I selected just [GitHub][6] so we keep a reference to the github user ID there.
```
CREATE TABLE conversations (
id SERIAL NOT NULL PRIMARY KEY,
last_message_id INT,
INDEX (last_message_id DESC)
);
```
Each conversation references the last message. Every time we insert a new message, well go and update this field. (Ill add the foreign key constraint below).
… You can say that we can group conversations and get the last message that way, but that will add much more complexity to the queries.
```
CREATE TABLE participants (
user_id INT NOT NULL REFERENCES users ON DELETE CASCADE,
conversation_id INT NOT NULL REFERENCES conversations ON DELETE CASCADE,
messages_read_at TIMESTAMPTZ NOT NULL DEFAULT now(),
PRIMARY KEY (user_id, conversation_id)
);
```
Even tho I said conversations will be between just two users, well go with a design that allow the possibility to add multiple participants to a conversation. Thats why we have a participants table between the conversation and users.
To know whether the user has unread messages we have the `messages_read_at` field. Every time the user read in a conversation, we update this value, so we can compare it with the conversation last message `created_at` field.
```
CREATE TABLE messages (
id SERIAL NOT NULL PRIMARY KEY,
content STRING NOT NULL,
user_id INT NOT NULL REFERENCES users ON DELETE CASCADE,
conversation_id INT NOT NULL REFERENCES conversations ON DELETE CASCADE,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
INDEX(created_at DESC)
);
```
Last but not least is the messages table, it saves a reference to the user who created it and the conversation in which it goes. Is has an index on `created_at` too to sort messages.
```
ALTER TABLE conversations
ADD CONSTRAINT fk_last_message_id_ref_messages
FOREIGN KEY (last_message_id) REFERENCES messages ON DELETE SET NULL;
```
And yep, the fk constraint I said.
These four tables will do the trick. You can save those queries to a file and pipe it to the Cockroach CLI. First start a new node:
```
cockroach start --insecure --host 127.0.0.1
```
Then create the database and tables:
```
cockroach sql --insecure -e "CREATE DATABASE messenger"
cat schema.sql | cockroach sql --insecure -d messenger
```
* * *
Thats it. In the next part well do the login. Wait for it.
[Souce Code][7]
--------------------------------------------------------------------------------
via: https://nicolasparada.netlify.com/posts/go-messenger-schema/
作者:[Nicolás Parada][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://nicolasparada.netlify.com/
[b]: https://github.com/lujun9972
[1]: https://www.messenger.com/
[2]: https://www.whatsapp.com/
[3]: https://www.skype.com/
[4]: https://www.cockroachlabs.com/
[5]: https://golang.org/
[6]: https://github.com/
[7]: https://github.com/nicolasparada/go-messenger-demo

View File

@ -1,106 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (A Quick Look at Elvish Shell)
[#]: via: (https://itsfoss.com/elvish-shell/)
[#]: author: (John Paul https://itsfoss.com/author/john/)
A Quick Look at Elvish Shell
======
Everyone who comes to this site has some knowledge (no matter how slight) of the Bash shell that comes default of so many systems. There have been several attempts to create shells that solve some of the shortcomings of Bash that have appeared over the years. One such shell is Elvish, which we will look at today.
### What is Elvish Shell?
![Pipelines In Elvish][1]
[Elvish][2] is more than just a shell. It is [also][3] “an expressive programming language”. It has a number of interesting features including:
* Written in Go
* Built-in file manager, inspired by the [Ranger file manager][4] (`Ctrl + N`)
* Searchable command history (`Ctrl + R`)
* History of directories visited (`Ctrl + L`)
* Powerful pipelines that support structured data, such as lists, maps, and functions
* Includes a “standard set of control structures: conditional control with `if`, loops with `for` and `while`, and exception handling with `try`
* Support for [third-party modules via a package manager to extend Elvish][5]
* Licensed under the BSD 2-Clause license
“Why is it named Elvish?” I hear you shout. Well, according to [their website][6], they chose their current name because:
> In roguelikes, items made by the elves have a reputation of high quality. These are usually called elven items, but “elvish” was chosen because it ends with “sh”, a long tradition of Unix shells. It also rhymes with fish, one of the shells that influenced the philosophy of Elvish.
### How to Install Elvish Shell
Elvish is available in several mainstream distributions.
Note that the software is very young. The most recent version is 0.12. According to the projects [GitHub page][3]: “Despite its pre-1.0 status, it is already suitable for most daily interactive use.”
![Elvish Control Structures][7]
#### Debian and Ubuntu
Elvish packages were introduced into Debian Buster and Ubuntu 17.10. Unfortunately, those packages are out of date and you will need to use a [PPA][8] to install the latest version. You will need to use the following commands:
```
sudo add-apt-repository ppa:zhsj/elvish
sudo apt update
sudo apt install elvish
```
#### Fedora
Elvish is not available in the main Fedora repos. You will need to add the [FZUG Repository][9] to install Evlish. To do so, you will need to use these commands:
```
sudo dnf config-manager --add-repo=http://repo.fdzh.org/FZUG/FZUG.repol
sudo dnf install elvish
```
#### Arch
Elvish is available in the [Arch User Repository][10].
I believe you know [how to change shell in Linux][11] so after installing you can switch to Elvish to use it.
### Final Thoughts on Elvish Shell
Personally, I have no reason to install Elvish on any of my systems. I can get most of its features by installing a couple of small command line programs or using already installed programs.
For example, the search past commands feature already exists in Bash and it works pretty well. If you want to improve your ability to search past commands, I would recommend installing [fzf][12] instead. Fzf uses fuzzy search, so you dont need to remember the exact command you are looking for. Fzf also allows you to preview and open files.
I do think that the fact that Elvish is also a programming language is neat, but Ill stick with Bash shell scripting until Elvish matures a little more.
Have you every used Elvish? Do you think it would be worthwhile to install Elvish? What is your favorite Bash replacement? Please let us know in the comments below.
If you found this article interesting, please take a minute to share it on social media, Hacker News or [Reddit][13].
--------------------------------------------------------------------------------
via: https://itsfoss.com/elvish-shell/
作者:[John Paul][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/john/
[b]: https://github.com/lujun9972
[1]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/05/pipelines-in-elvish.png?fit=800%2C421&ssl=1
[2]: https://elv.sh/
[3]: https://github.com/elves/elvish
[4]: https://ranger.github.io/
[5]: https://github.com/elves/awesome-elvish
[6]: https://elv.sh/ref/name.html
[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/05/Elvish-control-structures.png?fit=800%2C425&ssl=1
[8]: https://launchpad.net/%7Ezhsj/+archive/ubuntu/elvish
[9]: https://github.com/FZUG/repo/wiki/Add-FZUG-Repository
[10]: https://aur.archlinux.org/packages/elvish/
[11]: https://linuxhandbook.com/change-shell-linux/
[12]: https://github.com/junegunn/fzf
[13]: http://reddit.com/r/linuxusersgroup

View File

@ -1,5 +1,5 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: translator: (way-ww)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )

View File

@ -1,5 +1,5 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )

View File

@ -0,0 +1,70 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Fedora and CentOS Stream)
[#]: via: (https://fedoramagazine.org/fedora-and-centos-stream/)
[#]: author: (Matthew Miller https://fedoramagazine.org/author/mattdm/)
Fedora and CentOS Stream
======
![][1]
_From the desk of the Fedora Project Leader:_
Hi everyone! You may have seen the [announcement][2] about [changes over at the CentOS Project][3]. (If not, please go ahead and take a few minutes and read it — Ill wait!) And now you may be wondering: if CentOS is now upstream of RHEL, what happens to Fedora? Isnt that Fedoras role in the Red Hat ecosystem?
First, dont worry. There are changes to the big picture, but theyre all for the better.
![][4]
If youve been following the conference talks from Red Hat Enterprise Linux leadership about the relationship between Fedora, CentOS, and RHEL, you have heard about “the [Penrose Triangle][5]”. Thats a shape like something from an M. C. Escher drawing: its impossible in real life!
Weve been thinking for a while that _maybe_ impossible geometry is not actually the best model. 
For one thing, the imagined flow where contributions at the end would flow back into Fedora and grow in a “virtuous cycle” never actually worked that way. Thats a shame, because theres a huge, awesome CentOS community and many great people working on it — and theres a lot of overlap with the Fedora community too. Were missing out.
But that gap isnt the only one: theres not really been a consistent flow between the projects and product at all. So far, the process has gone like this: 
1. Some time after the previous RHEL release, Red Hat would suddenly turn more attention to Fedora than usual.
2. A few months later, Red Hat would split off a new RHEL version, developed internally.
3. After some months, thatd be put into the world, including all of the source — from which CentOS is built. 
4. Source drops continue for updates, and sometimes those updates include patches that were in Fedora — but theres no visible connection.
Each step here has its problems: intermittent attention, closed-door development, blind drops, and little ongoing transparency. But now Red Hat and CentOS Project are fixing that, and thats good news for Fedora, too.
**Fedora will remain the** [**first**][6] **upstream of RHEL.** Its where every RHEL came from, and is where RHEL 9 will come from, too. But after RHEL branches off, _CentOS_ will be upstream for ongoing work on those RHEL versions. I like to call it “the midstream”, but the marketing folks somehow dont, so thats going to be called “CentOS Stream”.
We — Fedora, CentOS, and Red Hat — still need to work out all of the technical details, but the idea is that these branches will live in the same package source repository. (The current plan is to make a “src.centos.org” with a  parallel view of the same data as [src.fedoraproject.org][7]). This change gives public visibility into ongoing work on released RHEL, and a place for developers and Red Hats partners to collaborate at that level.
[CentOS SIGs][8] — the special interest groups for virtualization, storage, config management and so on — will do their work in shared space right next to Fedora branches. This will allow much easier collaboration and sharing between the projects, and Im hoping well even be able to merge some of our similar SIGs to work together directly. Fixes from Fedora packages can be cherry-picked into the CentOS “midstream” ones — and where useful, vice versa.
Ultimately, Fedora, CentOS, and RHEL are part of the same big project family. This new, more natural flow opens possibilities for collaboration which were locked behind artificial (and extra-dimensional!) barriers. Im very excited for what we can now do together!
_— Matthew Miller, Fedora Project Leader_
--------------------------------------------------------------------------------
via: https://fedoramagazine.org/fedora-and-centos-stream/
作者:[Matthew Miller][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/mattdm/
[b]: https://github.com/lujun9972
[1]: https://fedoramagazine.org/wp-content/uploads/2019/09/centos-stream-816x345.jpg
[2]: http://redhat.com/en/blog/transforming-development-experience-within-centos
[3]: https://wiki.centos.org/Manuals/ReleaseNotes/CentOSStream
[4]: https://lh3.googleusercontent.com/5XMDU29DYPsFKIVLCexK46n9DqWZEa0nTjAnJcouzww-RSAzNshGW3yIxXBSBsd6KfAyUAGpxX9y0Dsh1hj21ygcAn5a7h55LrneKROkxsipdXO2gq8cgoFqz582ojOh8NU9Ix0X
[5]: https://www.youtube.com/watch?v=1JmgOkEznjw
[6]: https://docs.fedoraproject.org/en-US/project/#_first
[7]: https://src.fedoraproject.org/
[8]: https://wiki.centos.org/SpecialInterestGroup

View File

@ -0,0 +1,117 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Mirror your Android screen on your computer with Guiscrcpy)
[#]: via: (https://opensource.com/article/19/9/mirror-android-screen-guiscrcpy)
[#]: author: (Seth Kenlon https://opensource.com/users/sethhttps://opensource.com/users/scottnesbitthttps://opensource.com/users/holmjahttps://opensource.com/users/holmjahttps://opensource.com/users/rajaram121)
Mirror your Android screen on your computer with Guiscrcpy
======
Access your Android device from your PC with this open source
application based on scrcpy.
![Coding on a computer][1]
In the future, all the information you need will be just one gesture away, and it will all appear in midair as a hologram that you can interact with even while you're driving your flying car. That's the future, though, and until that arrives, we're all stuck with information spread across a laptop, a phone, a tablet, and a smart refrigerator. Unfortunately, that means when we need information from a device, we generally have to look at that device.
While not quite holographic terminals or flying cars, [guiscrcpy][2] by developer [Srevin Saju][3] is an application that consolidates multiple screens in one location and helps to capture that futuristic feeling.
Guiscrcpy is an open source (GNU GPLv3 licensed) project based on the award-winning [scrcpy][4] open source engine. With guiscrcpy, you can cast your Android screen onto your computer screen so you can view it along with everything else. Guiscrcpy supports Linux, Windows, and MacOS.
Unlike many scrcpy alternatives, Guiscrcpy is not a fork of scrcpy. The project prioritizes collaborating with other open source projects, so Guiscrcpy is an extension, or a graphical user interface (GUI) layer, for scrcpy. Keeping the Python 3 GUI separate from scrcpy ensures that nothing interferes with the efficiency of the scrcpy backend. You can screencast up to 1080p resolution and, because it uses ultrafast rendering and surprisingly little CPU, it works even on a relatively low-end PC.
Scrcpy, Guiscrcpy's foundation, is a command-line application, so it doesn't have GUI buttons to handle gestures, it doesn't provide a Back or Home button, and it requires familiarity with the [Linux terminal][5]. Guiscrcpy adds GUI panels to scrcpy, so any user can run it—and cast and control their device—without sending any information over the internet. Everything works over USB or WiFi (using only a local network). Guiscrcpy also adds a desktop launcher to Linux and Windows systems and provides compiled binaries for Linux and Windows.
### Installing Guiscrcpy
Before installing Guiscrcpy, you must install its dependencies, most notably scrcpy. Possibly the easiest way to install scrcpy is with [snap][6], which is available for most major Linux distributions. If you have snap installed and active, then you can install scrcpy with one easy command:
```
`$ sudo snap install scrcpy`
```
While it's installing, you can install the other dependencies. The [Simple DirectMedia Layer][7] (SDL 2.0) toolkit is required to display and interact with the phone screen, and the [Android Debug Bridge][8] (adb) command connects your computer to your Android phone.
On Fedora or CentOS:
```
`$ sudo dnf install SDL2 android-tools`
```
On Ubuntu or Debian:
```
`$ sudo apt install SDL2 android-tools-adb`
```
In another terminal, install the Python dependencies:
```
`$ python3 -m pip install -r requirements.txt --user`
```
### Setting up your phone
For your phone to accept an adb connection, it must have Developer Mode enabled. To enable Developer Mode on Android, go to **Settings** and select **About phone**. In **About phone**, find the **Build number** (it may be in the **Software information** panel). Believe it or not, to enable Developer Mode, tap **Build number** seven times in a row.
![Enabling Developer Mode][9]
For full instructions on all the many ways you can configure your phone for access from your computer, read the [Android developer documentation][10].
Once that's set up, plug your phone into a USB port on your computer (or ensure that you've configured it correctly to connect over WiFi).
### Using guiscrcpy
When you launch guiscrcpy, you see its main control window. In this window, click the **Start scrcpy** button. This connects to your phone, as long as it's set up in Developer Mode and connected to your computer over USB or WiFi.
![Guiscrcpy main screen][11]
It also includes a configuration-writing system, where you can write a configuration file to your **~/.config** directory to preserve your preferences between uses.
The bottom panel of guiscrcpy is a floating window that helps you perform basic controlling actions. It has buttons for Home, Back, Power, and more. These are common functions on Android devices, but an important feature of this module is that it doesn't interact with scrcpy's SDL, so it can function with no lag. In other words, this panel communicates directly with your connected device through adb rather than scrcpy.
![guiscrcpy's bottom panel][12]
The project is in active development and new features are still being added. The latest build has an interface for gestures and notifications.
With guiscrcpy, you not only _see_ your phone on your screen, but you can also interact with it, either by clicking the SDL window itself, just as you would tap your physical phone, or by using the buttons on the panels.
![guiscrcpy running on Fedora 30][13]
Guiscrcpy is a fun and useful application that provides features that ought to be official features of any modern device, especially a platform like Android. Try it out yourself, and add some futuristic pragmatism to your present-day digital life.
We took a look at 12 of the best open source Android games in the F-Droid repository.
All six apps are available from the F-Droid repository and licensed under the GPLv3, providing an...
--------------------------------------------------------------------------------
via: https://opensource.com/article/19/9/mirror-android-screen-guiscrcpy
作者:[Seth Kenlon][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/sethhttps://opensource.com/users/scottnesbitthttps://opensource.com/users/holmjahttps://opensource.com/users/holmjahttps://opensource.com/users/rajaram121
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_laptop_hack_work.png?itok=aSpcWkcl (Coding on a computer)
[2]: https://github.com/srevinsaju/guiscrcpy
[3]: http://opensource.com/users/srevinsaju
[4]: https://github.com/Genymobile/scrcpy
[5]: https://www.redhat.com/sysadmin/navigating-filesystem-linux-terminal
[6]: https://snapcraft.io/
[7]: https://www.libsdl.org/
[8]: https://developer.android.com/studio/command-line/adb
[9]: https://opensource.com/sites/default/files/uploads/developer-mode.jpg (Enabling Developer Mode)
[10]: https://developer.android.com/studio/debug/dev-options
[11]: https://opensource.com/sites/default/files/uploads/guiscrcpy-main.png (Guiscrcpy main screen)
[12]: https://opensource.com/sites/default/files/uploads/guiscrcpy-bottompanel.png (guiscrcpy's bottom panel)
[13]: https://opensource.com/sites/default/files/uploads/guiscrcpy-screenshot.jpg (guiscrcpy running on Fedora 30)

View File

@ -0,0 +1,163 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Mutation testing by example: Execute the test)
[#]: via: (https://opensource.com/article/19/9/mutation-testing-example-execute-test)
[#]: author: (Alex Bunardzic https://opensource.com/users/alex-bunardzic)
Mutation testing by example: Execute the test
======
Use the logic created so far in this series to implement functioning
code, then use failure and unit testing to make it better.
![A cat.][1]
The [second article][2] in this series demonstrated how to implement the logic for determining whether it's daylight or nighttime in a home automation system (HAS) application that controls locking and unlocking a cat door. This third article explains how to write code to use that logic in an application that locks a door at night and unlocks it during daylight hours.
As a reminder, set yourself up to follow along using the .NET xUnit.net testing framework by following the [instructions here][3].
### Disable the cat trap door during nighttime
Assume the cat door is a sophisticated Internet of Things (IoT) product that has an IP address and can be accessed by sending a request to its API. For the sake of brevity, this series doesn't go into how to program an IoT device; rather, it simulates the service to keep the focus on test-driven development (TDD) and mutation testing.
Start by writing a failing unit test:
```
[Fact]
public void GivenNighttimeDisableTrapDoor() {
   var expected = "Cat trap door disabled";
   var timeOfDay = dayOrNightUtility.GetDayOrNight(nightHour);
   var actual = catTrapDoor.Control(timeOfDay);
   Assert.Equal(expected, actual);
}
```
This describes a brand new component or service (**catTrapDoor**). That component (or service) has the capability to control the trap door given the current time. Now it's time to implement **catTrapDoor**.
To simulate this service, you must first describe its capabilities by using the interface. Create a new file in the app folder and name it **ICatTrapDoor.cs** (by convention, an interface name starts with an uppercase letter **I**). Add the following code to that file:
```
namespace app{
   public interface ICatTrapDoor {
       string Control(string dayOrNight);
   }
}
```
This interface is not capable of functioning. It merely describes your intention when building the **CatTrapDoor** service. Interfaces are a nice way to create abstractions of the services you are working with. In a way, you could regard this interface as an API of the **CatTrapDoor** service.
To implement the API, create a new file in the app folder and name it **FakeCatTrapDoor.cs**. Enter the following code into the class file:
```
namespace app{
   public class FakeCatTrapDoor : ICatTrapDoor {
       public string Control(string dayOrNight) {
           string trapDoorStatus = "Undetermined";
           if(dayOrNight == "Nighttime") {
               trapDoorStatus = "Cat trap door disabled";
           }
           return trapDoorStatus;
       }
   }
}
```
This new **FakeCatTrapDoor** class implements the interface **ICatTrapDoor**. Its method **Control** accepts string value **dayOrNight** and checks whether the value passed in is "Nighttime." If it is, it modifies **trapDoorStatus** from "Undetermined" to "Cat trap door disabled" and returns that value to the calling client.
Why is it called **FakeCatTrapDoor**? Because it's not a representation of the real cat trap door. The fake just helps you work out the processing logic. Once your logic is airtight, the fake service is replaced with the real service (this topic is reserved for the discipline of integration testing).
With everything implemented, all the unit tests pass when they run:
```
Starting test execution, please wait...
Total tests; 3. Passed: 3. failed: 0. Skipped: 0.
Test Run Successful.
Test execution time: 1.3913 Seconds
```
### Enable the cat trap door during daytime
It's time to look at the next scenario in our user story:
> _Scenario #2: Enable cat trap door during daylight_
>
> * Given that the clock detects the daylight
> * When the clock notifies the HAS
> * Then the HAS enables the cat trap door
>
This should be easy, just the flip side of the first scenario. First, write the failing test. Add the following unit test to your **UnitTest1.cs** file in the **unittest** folder:
```
[Fact]
public void GivenDaylightEnableTrapDoor() {
   var expected = "Cat trap door enabled";
   var timeOfDay = dayOrNightUtility.GetDayOrNight(dayHour);
   var actual = catTrapDoor.Control(timeOfDay);
   Assert.Equal(expected, actual);
}
```
You can expect to receive a "Cat trap door enabled" notification when sending the "Daylight" status to **catTrapDoor** service. When you run unit tests, you see the result you expect, which fails as expected:
```
Starting test execution, please wait...
[Xunit unittest.UnitTest1.UnitTest1.GivenDaylightEnableTrapDoor [FAIL]
Failed unittest.UnitTest1.UnitTest1.GivenDaylightEnableTrapDoor
[...]
```
The unit test expected to receive a "Cat trap door enabled" notification but instead was notified that the cat trap door status is "Undetermined." Cool; now's the time to fix this minor failure.
Adding three lines of code to the **FakeCatTrapDoor** does the trick:
```
if(dayOrNight == "Daylight") {
   trapDoorStatus = "Cat trap door enabled";
}
```
Run the unit tests again, and all tests pass:
```
Starting test execution, please wait...
Total tests: 4. Passed: 4. Failed: 0. Skipped: 0.
Test Run Successful.
Test execution time: 2.4888 Seconds
```
Awesome! Everything looks good, all the unit tests are in green, you have a rock-solid solution. Thank you, TDD!
### Not so fast!
Experienced engineers would not be convinced that the solution is rock-solid. Why? Because the solution hasn't been mutated yet. To dive deeply into what mutation is and why it's important, be sure to read the final article in this series.
--------------------------------------------------------------------------------
via: https://opensource.com/article/19/9/mutation-testing-example-execute-test
作者:[Alex Bunardzic][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/alex-bunardzic
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/cat_pet_animal.jpg?itok=HOrVTfBZ (A cat.)
[2]: https://opensource.com/article/19/9/mutation-testing-example-part-2-failure-experimentation
[3]: https://opensource.com/article/19/8/mutation-testing-evolution-tdd

View File

@ -0,0 +1,423 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How to Execute Commands on Remote Linux System over SSH)
[#]: via: (https://www.2daygeek.com/execute-run-linux-commands-remote-system-over-ssh/)
[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/)
How to Execute Commands on Remote Linux System over SSH
======
We may need to perform some commands on the remote machine.
To do so, log in to a remote system and do it, if its once in a while.
But every time you do this, it can irritate you
If so, what is the better way to get out of it.
Yes, you can do this from your local system instead of logging in to the remote system.
Will it benefit me? Yeah definitely. This will save you good time.
Hows that happening? Yes, SSH allows you to run a command on a remote machine without logging in to a computer.
**The general syntax is as follow:**
```
$ ssh [User_Name]@[Rremote_Host_Name or IP] [Command or Script]
```
### 1) How to Run the Command on a Remote Linux System Over SSH
The following example allows users to run the **[df command][1]** via ssh on a remote Linux machine
```
$ ssh [email protected] df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 27G 4.4G 23G 17% /
devtmpfs 903M 0 903M 0% /dev
tmpfs 920M 0 920M 0% /dev/shm
tmpfs 920M 9.3M 910M 2% /run
tmpfs 920M 0 920M 0% /sys/fs/cgroup
/dev/sda1 1014M 179M 836M 18% /boot
tmpfs 184M 8.0K 184M 1% /run/user/42
tmpfs 184M 0 184M 0% /run/user/1000
```
### 2) How to Run Multiple Commands on a Remote Linux System Over SSH
The following example allows users to run multiple commands at once over ssh on the remote Linux system.
Its running uptime command and free command on the remote Linux system simultaneously.
```
$ ssh [email protected] "uptime && free -m"
23:05:10 up 10 min, 0 users, load average: 0.00, 0.03, 0.03
total used free shared buffers cached
Mem: 1878 432 1445 1 100 134
-/+ buffers/cache: 197 1680
Swap: 3071 0 3071
```
### 3) How to Run the Command with sudo Privilege on a Remote Linux System Over SSH
The following example allows users to run the **fdisk** command with **[sudo][2]** [][2]**[privilege][2]** on the remote Linux system via ssh.
Normal users are not allowed to execute commands available under the system binary **(/usr/sbin/)** directory. Users need root privileges to run it.
So to run the **[fdisk command][3]** on a Linux system, you need root privileges.
The which command returns the full path of the executable of the given command.
```
$ which fdisk
/usr/sbin/fdisk
```
```
$ ssh -t [email protected] "sudo fdisk -l"
[sudo] password for daygeek:
Disk /dev/sda: 32.2 GB, 32212254720 bytes, 62914560 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000bf685
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 62914559 30407680 8e Linux LVM
Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/centos-root: 29.0 GB, 28982640640 bytes, 56606720 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Connection to centos7.2daygeek.com closed.
```
### 4) How to Run the Service Command with sudo Privilege on a Remote Linux System Over SSH
The following example allows users to run the service command with sudo privilege on the remote Linux system via ssh.
```
$ ssh -t [email protected] "sudo systemctl restart httpd"
[sudo] password for daygeek:
Connection to centos7.2daygeek.com closed.
```
### 5) How to Run the Command on a Remote Linux System Over SSH With Non-Standard Port
The following example allows users to run the **[hostnamectl command][4]** via ssh on a remote Linux machine with non-standard port.
```
$ ssh -p 2200 [email protected] hostnamectl
Static hostname: Ubuntu18.2daygeek.com
Icon name: computer-vm
Chassis: vm
Machine ID: 27f6c2febda84dc881f28fd145077187
Boot ID: bbeccdf932be41ddb5deae9e5f15183d
Virtualization: oracle
Operating System: Ubuntu 18.04.2 LTS
Kernel: Linux 4.15.0-60-generic
Architecture: x86-64
```
### 6) How to Save Output from Remote System to Local System
The following example allows users to remotely execute the **[top command][5]** on a Linux system via ssh and save the output to the local system.
```
$ ssh [email protected] "top -bc | head -n 35" > /tmp/top-output.txt
```
```
cat /tmp/top-output.txt
top - 01:13:11 up 18 min, 1 user, load average: 0.01, 0.05, 0.10
Tasks: 168 total, 1 running, 167 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.0 us, 6.2 sy, 0.0 ni, 93.8 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 1882300 total, 1176324 free, 342392 used, 363584 buff/cache
KiB Swap: 2097148 total, 2097148 free, 0 used. 1348140 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
4943 daygeek 20 0 162052 2248 1612 R 10.0 0.1 0:00.07 top -bc
1 root 20 0 128276 6936 4204 S 0.0 0.4 0:03.08 /usr/lib/sy+
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 [kthreadd]
3 root 20 0 0 0 0 S 0.0 0.0 0:00.25 [ksoftirqd/+
4 root 20 0 0 0 0 S 0.0 0.0 0:00.00 [kworker/0:+
5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [kworker/0:+
7 root rt 0 0 0 0 S 0.0 0.0 0:00.00 [migration/+
8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 [rcu_bh]
9 root 20 0 0 0 0 S 0.0 0.0 0:00.77 [rcu_sched]
10 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [lru-add-dr+
11 root rt 0 0 0 0 S 0.0 0.0 0:00.01 [watchdog/0]
13 root 20 0 0 0 0 S 0.0 0.0 0:00.00 [kdevtmpfs]
14 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [netns]
15 root 20 0 0 0 0 S 0.0 0.0 0:00.00 [khungtaskd]
16 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [writeback]
17 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [kintegrity+
18 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [bioset]
19 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [bioset]
20 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [bioset]
```
Alternatively, you can use the following format to run multiple commands on a remote system.
```
$ ssh [email protected] << EOF
hostnamectl
free -m
grep daygeek /etc/passwd
EOF
```
Output of the above command.
```
Pseudo-terminal will not be allocated because stdin is not a terminal.
Static hostname: CentOS7.2daygeek.com
Icon name: computer-vm
Chassis: vm
Machine ID: 002f47b82af248f5be1d67b67e03514c
Boot ID: dca9a1ba06374d7d96678f9461752482
Virtualization: kvm
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-957.el7.x86_64
Architecture: x86-64
total used free shared buff/cache available
Mem: 1838 335 1146 11 355 1314
Swap: 2047 0 2047
daygeek:x:1000:1000:2daygeek:/home/daygeek:/bin/bash
```
### 7) How to Execute Local Bash Scripts on Remote System
The following example allows users to run local **[bash script][6]** “remote-test.sh” via ssh on a remote Linux machine.
Create a shell script and execute it.
```
$ vi /tmp/remote-test.sh
#!/bin/bash
#Name: remote-test.sh
#--------------------
uptime
free -m
df -h
uname -a
hostnamectl
```
Output for the above command.
```
$ ssh [email protected] 'bash -s' < /tmp/remote-test.sh
01:17:09 up 22 min, 1 user, load average: 0.00, 0.02, 0.08
total used free shared buff/cache available
Mem: 1838 333 1148 11 355 1316
Swap: 2047 0 2047
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 27G 4.4G 23G 17% /
devtmpfs 903M 0 903M 0% /dev
tmpfs 920M 0 920M 0% /dev/shm
tmpfs 920M 9.3M 910M 2% /run
tmpfs 920M 0 920M 0% /sys/fs/cgroup
/dev/sda1 1014M 179M 836M 18% /boot
tmpfs 184M 12K 184M 1% /run/user/42
tmpfs 184M 0 184M 0% /run/user/1000
Linux CentOS7.2daygeek.com 3.10.0-957.el7.x86_64 #1 SMP Thu Nov 8 23:39:32 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
Static hostname: CentOS7.2daygeek.com
Icon name: computer-vm
Chassis: vm
Machine ID: 002f47b82af248f5be1d67b67e03514c
Boot ID: dca9a1ba06374d7d96678f9461752482
Virtualization: kvm
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-957.el7.x86_64
Architecture: x86-64
```
Alternatively, the pipe can be used. If you think the output is not good, add few changes to make it more elegant.
```
$ vi /tmp/remote-test-1.sh
#!/bin/bash
#Name: remote-test.sh
echo "---------System Uptime--------------------------------------------"
uptime
echo -e "\n"
echo "---------Memory Usage---------------------------------------------"
free -m
echo -e "\n"
echo "---------Disk Usage-----------------------------------------------"
df -h
echo -e "\n"
echo "---------Kernel Version-------------------------------------------"
uname -a
echo -e "\n"
echo "---------HostName Info--------------------------------------------"
hostnamectl
echo "------------------------------------------------------------------"
```
Output for the above script.
```
$ cat /tmp/remote-test.sh | ssh [email protected]
Pseudo-terminal will not be allocated because stdin is not a terminal.
---------System Uptime--------------------------------------------
03:14:09 up 2:19, 1 user, load average: 0.00, 0.01, 0.05
---------Memory Usage---------------------------------------------
total used free shared buff/cache available
Mem: 1838 376 1063 11 398 1253
Swap: 2047 0 2047
---------Disk Usage-----------------------------------------------
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 27G 4.4G 23G 17% /
devtmpfs 903M 0 903M 0% /dev
tmpfs 920M 0 920M 0% /dev/shm
tmpfs 920M 9.3M 910M 2% /run
tmpfs 920M 0 920M 0% /sys/fs/cgroup
/dev/sda1 1014M 179M 836M 18% /boot
tmpfs 184M 12K 184M 1% /run/user/42
tmpfs 184M 0 184M 0% /run/user/1000
tmpfs 184M 0 184M 0% /run/user/0
---------Kernel Version-------------------------------------------
Linux CentOS7.2daygeek.com 3.10.0-957.el7.x86_64 #1 SMP Thu Nov 8 23:39:32 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
---------HostName Info--------------------------------------------
Static hostname: CentOS7.2daygeek.com
Icon name: computer-vm
Chassis: vm
Machine ID: 002f47b82af248f5be1d67b67e03514c
Boot ID: dca9a1ba06374d7d96678f9461752482
Virtualization: kvm
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-957.el7.x86_64
Architecture: x86-64
```
### 8) How to Run Multiple Commands on Multiple Remote Systems Simultaneously
The following bash script allows users to run multiple commands on multiple remote systems simultaneously. Use simple for loop to achieve it.
For this purpose, you can try with with the **[PSSH command][7]** or **[ClusterShell command][8]** or **[DSH command][9]**
```
$ vi /tmp/multiple-host.sh
for host in CentOS7.2daygeek.com CentOS6.2daygeek.com
do
ssh [email protected]${host} "uname -a;uptime;date;w"
done
```
Output for the above script:
```
$ sh multiple-host.sh
Linux CentOS7.2daygeek.com 3.10.0-957.el7.x86_64 #1 SMP Thu Nov 8 23:39:32 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
01:33:57 up 39 min, 1 user, load average: 0.07, 0.06, 0.06
Wed Sep 25 01:33:57 CDT 2019
01:33:57 up 39 min, 1 user, load average: 0.07, 0.06, 0.06
USER TTY FROM [email protected] IDLE JCPU PCPU WHAT
daygeek pts/0 192.168.1.6 01:08 23:25 0.06s 0.06s -bash
Linux CentOS6.2daygeek.com 2.6.32-754.el6.x86_64 #1 SMP Tue Jun 19 21:26:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
23:33:58 up 39 min, 0 users, load average: 0.00, 0.00, 0.00
Tue Sep 24 23:33:58 MST 2019
23:33:58 up 39 min, 0 users, load average: 0.00, 0.00, 0.00
USER TTY FROM [email protected] IDLE JCPU PCPU WHAT
```
### 9) How to Add a Password Using the sshpass Command
If you are having trouble entering your password each time, I advise you to go with any one of the methods below as per your requirement.
If you are going to perform this type of activity frequently, I advise you to set up **[password-less authentication][10]** since its a standard and permanent solution.
If you only do these tasks a few times a month. I recommend you to use the **“sshpass”** utility.
Just provide a password as an argument using the **“-p”** option.
```
$ sshpass -p 'Your_Password_Here' ssh -p 2200 [email protected] ip a
1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:00:27:18:90:7f brd ff:ff:ff:ff:ff:ff
inet 192.168.1.12/24 brd 192.168.1.255 scope global dynamic eth0
valid_lft 86145sec preferred_lft 86145sec
inet6 fe80::a00:27ff:fe18:907f/64 scope link tentative dadfailed
valid_lft forever preferred_lft forever
```
--------------------------------------------------------------------------------
via: https://www.2daygeek.com/execute-run-linux-commands-remote-system-over-ssh/
作者:[Magesh Maruthamuthu][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.2daygeek.com/author/magesh/
[b]: https://github.com/lujun9972
[1]: https://www.2daygeek.com/linux-check-disk-space-usage-df-command/
[2]: https://www.2daygeek.com/how-to-configure-sudo-access-in-linux/
[3]: https://www.2daygeek.com/linux-fdisk-command-to-manage-disk-partitions/
[4]: https://www.2daygeek.com/four-methods-to-change-the-hostname-in-linux/
[5]: https://www.2daygeek.com/understanding-linux-top-command-output-usage/
[6]: https://www.2daygeek.com/category/shell-script/
[7]: https://www.2daygeek.com/pssh-parallel-ssh-run-execute-commands-on-multiple-linux-servers/
[8]: https://www.2daygeek.com/clustershell-clush-run-commands-on-cluster-nodes-remote-system-in-parallel-linux/
[9]: https://www.2daygeek.com/dsh-run-execute-shell-commands-on-multiple-linux-servers-at-once/
[10]: https://www.2daygeek.com/configure-setup-passwordless-ssh-key-based-authentication-linux/

View File

@ -0,0 +1,103 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (You Can Now Use OneDrive in Linux Natively Thanks to Insync)
[#]: via: (https://itsfoss.com/use-onedrive-on-linux/)
[#]: author: (Ankush Das https://itsfoss.com/author/ankush/)
You Can Now Use OneDrive in Linux Natively Thanks to Insync
======
[OneDrive][1] is a cloud storage service from Microsoft and it provides 5 GB of free storage to every user. This is integrated with Microsoft account and if you use Windows, you are have OneDrive preinstalled there.
OneDrive as a desktop application is not available on Linux. You can access your stored files via the web interface but you wont get that native feel of using the cloud storage in the file manager.
The good news is that you can now use an unofficial tool that lets you use OneDrive in Ubuntu or other Linux distributions.
[Insync][2] is a quite popular premium third-party sync tool when it comes to Google Drive cloud storage management on Linux. We already have a detailed review of [Insync with Google Drive][3] support for that matter.
However, recently, [Insync 3 was released][4] with OneDrive support. So, in this article, we are going to take a quick look at how OneDrive can be used with it and whats new in Insync 3.
Non-FOSS Alert
_Few developers take the pain of bringing their software to Linux. As a portal focusing on desktop Linux, we cover such software here even if they are not FOSS._
_Insync 3 is neither open source software nor it is free to use. You only get a 15-day trial to test it out._ _If you like it, you can purchase it for a lifetime fee of $29.99 per account._
_And no, we are not getting any money to promote them (in case you were going that way). We dont do that here._
### Get A Native OneDrive Experience in Linux With Insync
![][5]
Even though it is a premium tool the users who rely on OneDrive may want to get this for a seamless experience to sync OneDrive on their Linux system.
To get started, you have to download the suitable package for your Linux distribution from the [official download page][6].
[Download Insync][7]
You can also choose to add the repository and get it installed. You will get the instructions at Insyncs [official website][7].
Once you have it installed, just launch it and choose the OneDrive option.
![][8]
Also, it is worth noting that you need a separate license for each OneDrive or Google Drive account you add.
Now, after authorizing the OneDrive account, you have to select a base folder where you would want to sync everything which is a new feature in Insync 3.
![Insync 3 Base Folder][9]
In addition to this, you also get the ability to selectively sync files/folders locally or from the cloud after you set it up.
![Insync Selective Sync][10]
You can also customize the sync preference by adding your own rules to ignore/sync folders and files that you want it is totally optional.
![Insync Customize Sync Preferences][11]
Finally, you have it ready:
![Insync 3][12]
You can now start syncing files/folders using OneDrive across multiple platforms including your Linux desktop with Insync. In addition to all the new features/changes mentioned above, you also get a faster/smoother experience on Insync.
Also, with Insync 3, you can now take a look at the progress of your sync:
![][13]
**Wrapping Up**
Overall, Insync 3 is an impressive upgrade for those looking to sync OneDrive on their Linux system. In case you do not want to pay you can try other [free cloud services for Linux][14].
What do you think about Insync? If youre already using it, hows the experience so far? Let us know your thoughts in the comments below.
--------------------------------------------------------------------------------
via: https://itsfoss.com/use-onedrive-on-linux/
作者:[Ankush Das][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/ankush/
[b]: https://github.com/lujun9972
[1]: https://onedrive.live.com
[2]: https://www.insynchq.com
[3]: https://itsfoss.com/insync-linux-review/
[4]: https://www.insynchq.com/blog/insync-3/
[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/09/onedrive-linux.png?ssl=1
[6]: https://www.insynchq.com/downloads?start=true
[7]: https://www.insynchq.com/downloads
[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/09/insync-3one-drive-sync.png?ssl=1
[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/09/insync-3-base-folder-1.png?ssl=1
[10]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/09/insync-selective-syncs.png?ssl=1
[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/09/insync-customize-sync.png?ssl=1
[12]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/09/insync-homescreen.png?ssl=1
[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/09/insync-3-progress-bar.png?ssl=1
[14]: https://itsfoss.com/cloud-services-linux/

View File

@ -1,97 +0,0 @@
技术如何改变敏捷的规则
======
![](https://enterprisersproject.com/sites/default/files/styles/620x350/public/images/CIO%20Containers%20Ecosystem.png?itok=lDTaYXzk)
越来越多的企业正因为一个非常明显的原因开始尝试敏捷和[DevOps][1]: 企业需要通过更快的速度和更多的实验为创新和竞争性提供优势。而DevOps将帮助我们得到所需的创新速度。但是在小团队或初创企业中实践DevOps与进行大规模实践完全是两码事。我们都明白这样的一个事实那就是在10人的跨职能团队中能够很好地解决问题的方案当将相同的模式应用到100人的团队中时就可能无法奏效。这条道路是如此艰难以至于IT领导者很容易将敏捷方法的推行再推迟一年。
但那样的时代已经结束了。如果你已经尝试过,但是没有成功,那么现在是时候重新开始了。
直到现在DevOps需要为许多组织提供个性化的解决方案因此往往需要进行大量的调整以及付出额外的工作。但在今天[Linux容器][2]和Kubernetes正在推动DevOps工具和过程的标准化。而这样的标准化将会加速整个软件开发过程。因此我们用来实践DevOps工作方式的技术最终能够满足我们加快软件开发速度的愿望。
Linux容器和[Kubernetes][3]正在改变团队交互的方式。此外你可以在Kubernetes平台上运行任何能够在Linux运行的应用程序。这意味着什么呢你可以运行大量的企业及应用程序(甚至可以解决以前令人烦恼的Windows和Linux之间的协调问题)。最后容器和Kubernetes将能够满足未来所有运行内容的需求。它们正在经受着未来的考验以应对机器学习、人工智能和分析工作等下一代解决问题工具。
**[ 参考相关文章,[4 container adoption patterns: What you need to know. ] ][4]**
让我们以机器学习为例来思考一下。今天,人们可以在大量的企业数据中找到一些模式。当机器发现这些模式时(想想机器学习),你的员工就能更快地采取行动。随着人工智能的加入,机器不仅可以发现模式,还可以对模式进行操作。如今,三个星期已经成为了一个积极的软件开发冲刺周期。有了人工智能,机器每秒可以多次修改代码。创业公司会利用这种能力来“打扰你”。
考虑一下你需要多快才能参与到竞争当中。如果你对于无法对于DevOps和每周一个迭代周期充满信心那么考虑一下当那个创业公司将AI驱动的过程指向你时会发生什么现在是时候转向DevOps的工作方式了否认就会像你的竞争对手一样被甩在后面。
### 容器技术如何改变团队的工作?
DevOps使得许多试图将这种工作方式扩展到更大范围的团队感到沮丧。即使许多IT(和业务)人员之前都听说过敏捷相关的语言、框架、模型(如DevOps)等承诺将会彻底应用程序开发和IT过程的全部相关内容但他们还是对此持怀疑态度。
**[ 想要获取来自其他CIO们的建议吗不放参考下我们的综述性资源, [DevOps: The IT Leader's Guide][5]. ]**
向你的涉众“推销”快速开发冲刺也不是一件容易的事情。想象一下如果你以这种方式买了一栋房子你将不再需要向开发商支付固定的金额而是会得到这样的信息“我们将在4周内浇筑完地基其成本是X之后再搭建房屋框架和铺设电路但是我们现在只能够知道地基完成的时间表。”人们已经习惯了买房子的时候有一个预先的价格和交付时间表。
挑战在于构建软件与构建房屋不同。同一个建筑商往往建造了成千上万个完全相同的房子,而软件项目从来都各不相同。这是你要克服的第一个障碍。
开发和运维团队的工作方式确实不同,我之所以知道这一点是因为我曾经从事过这两方面的工作。企业往往会用不同的方式来激励他们,开发人员会因为更改和创建而获得奖励,而运维专家则会因降低成本和确保安全性而获得奖励。我们会把他们分成不同的小组,并且尽量减少互动。而这些角色通常会吸引那些思维方式完全不同的技术人员。但是这样的解决方案注定会失败,你必须打破横亘在开发和运维之间的藩篱。
想想传统情况下会发生什么。业务会把需求扔过墙这是因为他们在“买房”模式下运作并且说上一句“我们9个月后见。”开发人员根据这些需求进行开发并根据技术约束的需要进行更改。然后他们把它扔过墙传递给运维人员并说一句“搞清楚如何运行这个软件”。然后运维人员勤就会奋地进行大量更改使软件与基础设施保持一致。然而最终的结果是什么呢
通常情况下当业务人员看到需求实现的最终结果时甚至根本辨认不出。在过去20年的大部分时间里我们一次又一次地目睹了这种模式在软件行业中上演。而现在是时候改变了。
Linux容器能够真正地解决这样的问题这是因为容器缩小了开发和运维之间的间隙。容器技术允许两个团队共同理解和设计所有的关键需求但仍然独立地履行各自团队的职责。基本上我们去掉了开发人员和运维人员之间的电话游戏。
因为容器技术,我们可以使得运维团队的规模更小,但依旧能够承担起数百万应用程序的运维工作,并且能够使得开发团队可以更加快速地根据需要更改软件。(在较大的组织中,所需的速度可能比运维人员的响应速度更快。)
使用容器,您可以将所需要交付的内容与它运行的位置分开。你的运维团队只需要负责运行容器的主机和安全的内存占用,仅此而已。这意味着什么呢?
首先这意味着你现在可以和团队一起实践DevOps了。没错只需要让团队专注于他们已经拥有的专业知识而对于容器只需让团队了解所需集成依赖关系的必要知识即可。
如果你想要重新训练每个人,往往会收效甚微。容器技术允许团队之间进行交互,但同时也会为每个团队提供一个围绕该团队优势而构建的强大边界。开发人员会知道需要消耗什么,但不需要知道如何使其大规模运行。运维团队了解核心基础设施,但不需要了解应用程序的细节。此外,运维团队也可以通过更新应用程序来解决新的安全问题,以免你成为下一个数据泄露的热门话题。
想要为一个大型IT组织比如30000人的团队教授运维和开发技能那或许需要花费你十年的时间而你可能并没有那么多时间。
当人们谈论“构建新的云原生应用程序将帮助我们摆脱这个问题”时请批判性地进行思考。你可以在10个人的团队中构建云原生应用程序但这对《财富》杂志前1000强的企业而言或许并不适用。除非你不再需要依赖现有的团队否则你无法一个接一个地构建新的微服务你最终将得到一个竖井式的组织。这是一个诱人的想法但你不能指望这些应用程序来重新定义你的业务。我还没见过哪家公司能在如此大规模的并行开发中获得成功。IT预算已经受到限制在很长一段时间内将预算翻倍甚至三倍是不现实的。
### 当奇迹发生时: 你好, 速度
Linux容器就是为扩容而生的。一旦你开始这样做[Kubernetes之类的编制工具就会发挥作用][6],这是因为你将需要运行数千个容器。应用程序将不仅仅由一个容器组成,它们将依赖于许多不同的部分,所有的部分都会作为一个单元运行在容器上。如果不这样做,你的应用程序将无法在生产环境中很好地运行。
思考一下有多少小滑轮和杠杆组合在一起来支撑你的业务,对于任何应用程序都是如此。开发人员负责应用程序中的所有滑轮和杠杆。(如果开发人员没有这些组件,您可能会在集成时做噩梦。)与此同时无论是在线下还是在云上运维团队都会负责构成基础设施的所有滑轮和杠杆。做一个较为抽象的比喻使用Kubernetes你的运维团队就可以为应用程序提供运行所需的燃料但又不必成为所有方面的专家。
开发人员进行实验,运维团队则保持基础设施的安全和可靠。这样的组合使得企业敢于承担小风险,从而实现创新。不同于打几个孤注一掷的赌,公司中真正的实验往往是循序渐进的和快速的。
从个人经验来看,这就是组织内部发生的显著变化:因为人们说:“我们如何通过改变计划来真正地利用这种能力进行实验?”它强制执行敏捷计划。
举个例子使用DevOps模型、容器和Kubernetes的KeyBank如今每天都会部署代码。(观看视频[7]其中主导了KeyBank持续交付和反馈的John Rzeszotarski将解释这一变化。)类似地Macquarie银行也借助DevOps和容器技术每天将一些东西投入生产环境。
一旦你每天都推出软件,它就会改变你计划的每一个方面,并且会[加速业务的变化速度][8]。Macquarie银行和金融服务集团的CDOLuis Uguina表示“创意可以在一天内触达客户。”(参见[9]对Red Hat与Macquarie银行合作的案例研究)。
### 是时候去创造一些伟大的东西了
Macquarie的例子说明了速度的力量。这将如何改变你的经营方式记住Macquarie不是一家初创企业。这是CIO们所面临的颠覆性力量它不仅来自新的市场进入者也来自老牌同行。
开发人员的自由还改变了运营敏捷商店的CIO们的人才方程式。突然之间大公司里的个体(即使不是在最热门的行业或地区)也可以产生巨大的影响。Macquarie利用这一变动作为招聘工具并向开发人员承诺所有新招聘的员工将会在第一周内推出新产品。
与此同时,在这个基于云的计算和存储能力的时代,我们比以往任何时候都拥有更多可用的基础设施。考虑到[机器学习和人工智能工具将很快实现的飞跃][10],这是幸运的。
所有这些都说明现在正是打造伟大事业的好时机。考虑到市场创新的速度你需要不断地创造伟大的东西来保持客户的忠诚度。因此如果你一直在等待将赌注押在DevOps上那么现在就是正确的时机。容器技术和Kubernetes改变了规则并且对你有利。
**想要获取更多这样的智慧吗, IT领导者? [订阅每周邮件][11].**
--------------------------------------------------------------------------------
via: https://enterprisersproject.com/article/2018/1/how-technology-changes-rules-doing-agile
作者:[Matt Hicks][a]
译者:[JayFrank](https://github.com/JayFrank)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://enterprisersproject.com/user/matt-hicks
[1]:https://enterprisersproject.com/tags/devops
[2]:https://www.redhat.com/en/topics/containers?intcmp=701f2000000tjyaAAA
[3]:https://www.redhat.com/en/topics/containers/what-is-kubernetes?intcmp=701f2000000tjyaAAA
[4]:https://enterprisersproject.com/article/2017/8/4-container-adoption-patterns-what-you-need-know?sc_cid=70160000000h0aXAAQ
[5]:https://enterprisersproject.com/devops?sc_cid=70160000000h0aXAAQ
[6]:https://enterprisersproject.com/article/2017/11/how-enterprise-it-uses-kubernetes-tame-container-complexity
[7]:https://www.redhat.com/en/about/videos/john-rzeszotarski-keybank-red-hat-summit-2017?intcmp=701f2000000tjyaAAA
[8]:https://enterprisersproject.com/article/2017/11/dear-cios-stop-beating-yourselves-being-behind-transformation
[9]:https://www.redhat.com/en/resources/macquarie-bank-case-study?intcmp=701f2000000tjyaAAA
[10]:https://enterprisersproject.com/article/2018/1/4-ai-trends-watch
[11]:https://enterprisersproject.com/email-newsletter?intcmp=701f2000000tsjPAAQ

View File

@ -1,7 +1,3 @@
数码文件与文件夹收纳术(以照片为例)
======
更新 2014-05-14:增加了一些具体实例
@ -12,9 +8,17 @@
更新 2017-08-28: geeqier 视频缩略图的邮件评论
更新 2018-03-06:增加了zum Konzept von Julian Kahnert 的链接
更新 2018-05-06:增加了作者在 2018 Linuxtage Graz 大会上演讲的视频
更新 2018-06-05:关于 metadata 的邮件回复
更新 2019-07-09:关于在文件名中避免使用系谱和字符的邮件回复
每当度假或去哪游玩时我就会化身为一个富有激情的摄影师。所以,过去的几年中我积累了许多的 [JPEG][1] 文件。这篇文章中我会介绍我是如何避免[vendor lock-in][2]LCTT译注vendor lock-in 供应商锁定,原为经济学术语,这里引申为避免过于依赖某一服务平台)造成受限于那些临时性的解决方案及数据丢失。相反,我更倾向于使用那些可以让我投入时间和精力打理并能长久使用的解决方案。
这一(相当长的)攻略 **并不仅仅适用于图像文件** :我将进一步阐述像是文件夹结构,文件的命名规则,等等许多领域的事情。因此,这些规范适用于我所能接触到的所以类型的文件。
这一(相当长的)攻略 **并不仅仅适用于图像文件** :我将进一步阐述像是文件夹结构,文件的命名规则,等等许多领域的事情。因此,这些规范适用于我所能接触到的所类型的文件。
在我开始传授我的方法之前,我们应该先就我将要介绍方法的达成一个共识,那就是我们是否有相同的需求。如果你对[raw 图像格式][3]十分推崇,将照片存储在云端或其他你信赖的地方(对我而言可能不会),那么你可能不会认同这篇文章将要描述的方式了。请根据你的情况来灵活做出选择。
@ -32,7 +36,7 @@
就独立性和**避免锁定效应**而言,我不想使用那种一旦公司停止产品或服务就无法使用的工具。出于同样的原因,由于我是一个注重隐私的人,**我不想使用任何基于云的服务**。为了让自己对新的可能性保持开放的心态,我不希望仅在一个特定的操作系统平台上倾注全部的精力。**基本的东西必须在任何平台上可用**(查看、导航、……)。但是**全套需求必须在GNU/Linux上运行**且我选择Debian GNU/Linux。
在我传授当前针对上述大量需求的解决方案之前,我必须解释一下我的一般文件夹结构和文件命名约定,我也使用它来命名数码照片。但首先,你必须考虑一个重要的事实:
在我传授当前针对上述大量需求的解决方案之前,我必须解释一下我的一般文件夹结构和文件命名约定,我也使用它来命名数码照片。但首先,你必须认清一个重要的事实:
#### iPhoto, Picasa, 诸如此类应被认为是有害的
@ -42,20 +46,23 @@
如果你现在正打算更换 相应的工具你将会意识到iPhoto或Picasa确实分别存储原始图像文件和你对它们所做的所有操作。旋转图像向图像文件添加描述标签裁剪等等如果你不能导出并重新导入到新工具那么**所有的东西都将永远丢失**。而无损的进行转换和迁移几乎是不可能的。
我不想在一个锁住我工作的工具上投入任何精力。**我也拒绝把自己在任何专有工具上**。我是一个过来人,希望你们吸取我的经验。
我不想在一个锁住我工作的工具上投入任何精力。**我也拒绝把自己绑定在任何专有工具上**。我是一个过来人,希望你们吸取我的经验。
这就是我在文件名中保留时间戳、图像描述或标记的原因。文件名是永久性的除非我手动更改它们。当我把照片备份或复制到u盘或其他操作系统时它们不会丢失。每个人都能读懂。任何未来的系统都能够处理它们。
### 我的文件命名约定
### 我的文件命名规范
这里有一个我在 [2018 Linuxtage Graz 大会][44]上给出的[演讲][45],其中详细阐述了我的在本文中提到的想法和工作流程。
我所有的文件都与一个特定的日期或时间有关,根据所采用的[ISO 8601][7]规范,我采用的是**日期-标记**或**时间-标记**
带有日期戳和两个标签的示例文件名:`2014-05-09 42号项目的预算 -- 金融公司.csv`
带有时间戳(甚至包括可选秒)和两个标签的示例文件名:`2014-05-09T22.19.58 Susan展示她的新鞋子 -- 家庭衣物.jpg`
由于冒号不适用于Windows[文件系统NTFS][8]所以我必须使用已采用的ISO时间戳。因此我用点代替冒号以便将小时与分钟区别开来。
如果是**时间或日期持续时间**,我将两个日期或时间戳用两个负号分开:`2014-05-09—2014-05-13爵士音乐节Graz—folder 旅游音乐.pdf`。
如果是**时间或持续的一段时间**,我将两个日期或时间戳用两个负号分开:`2014-05-09—2014-05-13爵士音乐节Graz—folder 旅游音乐.pdf`。
文件名中的时间/日期戳的优点是,除非我手动更改它们,否则它们保持不变。当通过某些不处理这些元数据的软件进行处理时,包含在文件内容本身中的元数据(如[Exif][9])往往会丢失。此外,使用这样的日期/时间戳启动文件名可以确保文件按时间顺序显示,而不是按字母顺序显示。字母表是一种[完全人工的排序顺序][10],对于用户定位文件通常不太实用。
@ -89,7 +96,7 @@
### 我的工作流程
Tataaaa在你了解了我的文件夹结构和文件名约定之后下面是我当前的工作流程和工具我使用它们来满足我前面描述的需求。
请注意,**你必须知道你在做什么**。我这里的示例及文件夹路径和更多只**适用我的机器或我的设置的文件夹路径**你必须采用**相应的路径、文件名等**来满足你的需求!
请注意,**你必须知道你在做什么**。我这里的示例及文件夹路径和更多只**适用我的机器或我的设置的文件夹路径**你必须采用**相应的路径、文件名等**来满足你的需求!
#### 工作流程:将文件从SD卡移动到笔记本电脑旋转人像图像并重命名文件
@ -187,7 +194,7 @@ vk-filetags-interactive-removing-wrapper-with-gnome-terminal.sh
##### 在geeqie中使用文件标签
当我在geeqie文件浏览器中浏览图像文件时我选择要标记的文件(一到多个)并按`t`。然后,一个小窗口弹出,要求我提供一个或多个标签。在与` Return `确认后,这些标签被添加到文件名中。
当我在geeqie文件浏览器中浏览图像文件时我选择要标记的文件(一到多个)并按`t`。然后,一个小窗口弹出,要求我提供一个或多个标签。在 ` Return ` 命令确认后,这些标签被添加到文件名中。
删除标签也是一样:选择多个文件,按下`T`,输入要删除的标签,然后用`Return`确认。就是这样。几乎没有[更简单的方法来添加或删除标签到文件][29]。
@ -197,7 +204,7 @@ vk-filetags-interactive-removing-wrapper-with-gnome-terminal.sh
重命名一组大型文件可能是一个冗长乏味的过程。对于`2014-04-20T17.09.11_p1100386.jpg`这样的原始文件名,在文件名中添加描述的过程相当烦人。你将按`Ctrl-r`(重命名)在geeqie打开文件重命名对话框。默认情况下原始名称(没有文件扩展名的文件名称)被标记。因此,如果不希望删除/覆盖文件名(但要追加),则必须按下光标键` <right> `。然后,光标放在基本名称和扩展名之间。输入你的描述(不要忘记初始空格字符),并用`Return`进行确认。
##### 在geeqie使中用appendfilename
##### 在 geeqie 使中用 appendfilename
使用[appendfilename][30],我的过程得到了简化,可以获得将文本附加到文件名的最佳用户体验:当我在geeqie中按下` a ` (append)时,会弹出一个对话框窗口,询问文本。在`Return`确认后,输入的文本将放置在时间戳和可选标记之间。
@ -207,7 +214,7 @@ vk-filetags-interactive-removing-wrapper-with-gnome-terminal.sh
最好的部分是:当我想要将相同的文本添加到多个选定的文件中时也可以使用appendfilename。
##### 使用geeqie初始appendfilename
##### 使用 geeqie 初始 appendfilename
添加一个额外的编辑器到geeqie: ` Edit > Preferences > Configure editor…>New`。然后输入桌面文件定义:
@ -271,7 +278,7 @@ Categories=X-Geeqie;
```
当你将快捷方式`o`(见上文)与geeqie关联时你就能够打开与其关联的应用程序的视频文件(和其他文件)。
当你将快捷方式`o`(见上文)与geeqie关联时你就能够打开与其关联的应用程序的视频文件(和其他文件)。
##### 使用xdg-open打开电影文件(和其他文件)
@ -293,11 +300,11 @@ Categories=X-Geeqie;
因此,我(再次)编写了一个Python脚本它为我完成了这项工作:[move2archive][33](简而言之:` m2a `需要一个或多个文件作为命令行参数。然后,出现一个对话框,我可以在其中输入一个可选文件夹名。当我不输入任何东西,但按`Return`,文件被移动到相应年份的文件夹。当我输入一个类似`business marathon after show - party`的文件夹名称时,第一个图像文件的日期戳被附加到该文件夹(`$HOME/archive/events_memories/2014/2014-05-08 business marathon after show - party`),得到的文件夹是(`$HOME/archive/events_memories/2014/2014-05-08 Business-Marathon After-Show-Party`),并移动文件。
再一次:我在geeqie中选择一个或多个文件,按`m`(移动),或者只按`Return`(没有特殊的子文件夹),或者输入一个描述性文本,这是要创建的子文件夹的名称(可选不带日期戳)。
我在geeqie中再一次选择一个或多个文件,按`m`(移动),或者只按`Return`(没有特殊的子文件夹),或者输入一个描述性文本,这是要创建的子文件夹的名称(可选不带日期戳)。
**没有一个图像管理工具像我的geeqie一样通过快捷键快速且有趣的使用 appendfilename和move2archive完成工作。**
##### 在geeqie里初始化m2a的相关设置
##### 在 geeqie 里初始化 m2a 的相关设置
同样向geeqie添加`m2a`是一个手动步骤:“编辑>首选项>配置编辑器……”然后创建一个带有“New”的附加条目。在这里你可以定义一个新的桌面文件如下所示:
@ -526,7 +533,9 @@ Wow, 这是一篇很长的博客文章。难怪你可能已经忘了之前的概
### 最后
所以,这是一个详细描述我关于照片和电影的工作流程的叙述。你可能已经发现了我可能感兴趣的其他东西。所以请不要犹豫,请使用下面的链接留下评论或电子邮件。
我也希望得到反馈,如果我的工作流程适用于你。并且:如果你已经发布了你的工作流程或者找到了其他人工作流程的描述,也请留下评论!
及时行乐,莫让错误的工具或低效的方法浪费了我们的人生!
### 其他工具
@ -535,23 +544,6 @@ Wow, 这是一篇很长的博客文章。难怪你可能已经忘了之前的概
当你觉得你以上文中所叙述的符合你的需求时,请根据相关的建议来选择对应的工具。
### 邮件回复
> Date: Sat, 26 Aug 2017 22:05:09 +0200
> 你好卡尔,
我喜欢你的文章喜欢和memacs一起工作当然还有orgmode但是我对python不是很熟悉……在你的博客文章“管理数码照片”你写了关于打开视频与[Geeqie][26]。是的,但是我在浏览器里看不到任何视频缩略图。你有什么建议吗?
> 谢谢你,托马斯
你好托马斯,
谢谢你的美言。当有人发现我的工作对他/她的生活有用时,我总是感觉很棒。
不幸的是,大多数时候,我从未听到过这些。
是的我有时使用Geeqie来可视化文件夹这些文件夹不仅包含图像文件还包含电影文件。在这些情况下我没有看到任何视频的缩略图。你说得对有很多文件浏览器可以显示视频的预览图像。
坦白地说我从来没有想过视频缩略图我也不怀念它们。在我的首选项和搜索引擎上做了一个快速的研究并没有发现在Geeqie中启用视频预览的相关方法。所以这里要说声抱歉。
@ -609,3 +601,5 @@ via: http://karl-voit.at/managing-digital-photographs/
[41]:https://docs.kde.org/development/en/extragear-graphics/digikam/using-kapp.html#idp7659904
[42]:https://en.wikipedia.org/wiki/Symbolic_link
[43]:http://karl-voit.at/2017/02/19/gthumb
[44]:https://glt18.linuxtage.at
[45]:https://glt18-programm.linuxtage.at/events/321.html

View File

@ -0,0 +1,115 @@
[#]: collector: "lujun9972"
[#]: translator: "PsiACE"
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
[#]: subject: "Building a Messenger App: Schema"
[#]: via: "https://nicolasparada.netlify.com/posts/go-messenger-schema/"
[#]: author: "Nicolás Parada https://nicolasparada.netlify.com/"
# 构建一个即时消息应用:模式
这是一系列关于构建「即时消息」应用的新帖子。你应该对这类应用并不陌生。有了它们的帮助,我们才可以与朋友畅聊无忌。[Facebook Messenger][1], [WhatsApp][2] 和 [Skype][3] 就是其中的几个例子。正如你所看到的那样,这些应用允许我们发送图片、传输视频、录制音频、以及和一大帮子人聊天等等。当然,我们的教程应用将会尽量保持简单,只在两个用户之间发送文本消息。
我们将会用 [CockroachDB][4] 作为 SQL 数据库,用 [Go][5] 作为后端语言,并且用 JavaScript 来制作 web 应用。
这是第一篇帖子,我们将会讲述数据库的设计。
```
CREATE TABLE users (
id SERIAL NOT NULL PRIMARY KEY,
username STRING NOT NULL UNIQUE,
avatar_url STRING,
github_id INT NOT NULL UNIQUE
);
```
显然,这个应用需要一些用户。我们这里采用社交登录的形式。由于我选用了 [GitHub][6],所以这里需要保存一个对 GitHub 用户 ID 的引用。
```
CREATE TABLE conversations (
id SERIAL NOT NULL PRIMARY KEY,
last_message_id INT,
INDEX (last_message_id DESC)
);
```
每个对话都会引用最近一条消息。每当我们输入一条新消息时,我们都会更新这个字段。我会在后面添加外键约束。
… 你可能会想,我们可以先对对话进行分组,然后再通过这样的方式获取最近一条消息。但这样做会使查询变得更加复杂。
```
CREATE TABLE participants (
user_id INT NOT NULL REFERENCES users ON DELETE CASCADE,
conversation_id INT NOT NULL REFERENCES conversations ON DELETE CASCADE,
messages_read_at TIMESTAMPTZ NOT NULL DEFAULT now(),
PRIMARY KEY (user_id, conversation_id)
);
```
尽管之前我提到过对话只会在两个用户之间进行,但我们还是采用了允许向对话中添加多个参与者的设计。因此,在对话和用户之间有一个参与者表。
为了知道用户是否有未读消息,我们在消息表中添加了「读取时间」`messages_read_at` 字段。每当用户在对话中读取消息时,我们都会更新它的值,这样一来,我们就可以将它与对话中最后一条消息的「创建时间」`created_at` 字段进行比较。
```
CREATE TABLE messages (
id SERIAL NOT NULL PRIMARY KEY,
content STRING NOT NULL,
user_id INT NOT NULL REFERENCES users ON DELETE CASCADE,
conversation_id INT NOT NULL REFERENCES conversations ON DELETE CASCADE,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
INDEX(created_at DESC)
);
```
尽管我们将消息表放在最后,但它在应用中相当重要。我们用它来保存对创建它的用户以及它所出现的对话的引用。而且还可以根据「创建时间」`created_at` 来创建索引以完成对消息的排序。
```
ALTER TABLE conversations
ADD CONSTRAINT fk_last_message_id_ref_messages
FOREIGN KEY (last_message_id) REFERENCES messages ON DELETE SET NULL;
```
我在前面已经提到过这个外键约束了,不是吗:D
有这四张表就足够了。你也可以将这些查询保存到一个文件中,并将其通过管道传送到 Cockroach CLI。
首先,我们需要启动一个新节点:
```
cockroach start --insecure --host 127.0.0.1
```
然后创建数据库和这些表:
```
cockroach sql --insecure -e "CREATE DATABASE messenger"
cat schema.sql | cockroach sql --insecure -d messenger
```
---
这篇帖子就到这里。在接下来的部分中,我们将会介绍「登录」,敬请期待。
[Souce Code][7]
---
via: https://nicolasparada.netlify.com/posts/go-messenger-schema/
作者:[Nicolás Parada][a]
选题:[lujun9972][b]
译者:[PsiACE](https://github.com/PsiACE)
校对:[校对者 ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux 中国](https://linux.cn/) 荣誉推出
[a]: https://nicolasparada.netlify.com/
[b]: https://github.com/lujun9972
[1]: https://www.messenger.com/
[2]: https://www.whatsapp.com/
[3]: https://www.skype.com/
[4]: https://www.cockroachlabs.com/
[5]: https://golang.org/
[6]: https://github.com/
[7]: https://github.com/nicolasparada/go-messenger-demo

View File

@ -0,0 +1,106 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (A Quick Look at Elvish Shell)
[#]: via: (https://itsfoss.com/elvish-shell/)
[#]: author: (John Paul https://itsfoss.com/author/john/)
快速了解 Elvish Shell
======
每个来到这里的人都会对许多系统默认 Bash shell 有所了解(无论多少)。过去这些年已经有一些新的 shell 出现来解决 Bash 中的一些缺点。Elvish 就是其中之一,我们将在今天讨论它。
### 什么是 Elvish Shell
![Pipelines In Elvish][1]
[Elvish][2] 不只是一个 shell。它[也是][3]“一种表达性编程语言”。它有许多有趣的特性,包括:
* 使用 Go 语言编写
* 内置文件管理器,灵感来自 [Ranger 文件管理器][4]`Ctrl + N`
* 可搜索的命令历史记录(`Ctrl + R`
* 历史访问目录(`Ctrl + L`
* 支持结构化数据,例如列表、字典和函数的强大的管道
* 包含“一组标准的控制结构:有 `if` 条件控制、 `for``while` 循环,还有 `try` 的异常处理”
* 通过包管理器支持[第三方模块扩展 Elvish][5]
* BSD 2-Clause 许可
我听到了你的大叫,“为什么叫 Elvish”。好吧根据[他们的网站][6],他们之所以选择当前的名字,是因为:
> 在 Roguelike 中,精灵制造的物品质量很高。它们通常被称为“精灵物品”。但是之所以选择 “elvish” 是因为它以 “sh” 结尾,这是 Unix shell 的久远传统。这个与 fish 押韵,它是影响 Elvish 哲学的 shell 之一。
### 如何安装 Elvish Shell
Elvish 在几种主流发行版中都有。
请注意,该软件还很年轻。最新版本是 0.12。根据该项目的 [GitHub 页面][3]:“尽管还在 1.0 之前,但它已经适合大多数日常交互使用。”
![Elvish Control Structures][7]
#### Debian 和 Ubuntu
Elvish 包已引入 Debian Buster 和 Ubuntu 17.10。不幸的是,这些包已经过时,你将需要使用 [PPA][8] 安装最新版本。你需要使用以下命令:
```
sudo add-apt-repository ppa:zhsj/elvish
sudo apt update
sudo apt install elvish
```
#### Fedora
Elvish 在 Fedora 的主仓库中没有。你需要添加 [FZUG 仓库][9]安装 Evlish。为此你需要使用以下命令
```
sudo dnf config-manager --add-repo=http://repo.fdzh.org/FZUG/FZUG.repol
sudo dnf install elvish
```
#### Arch
Elvish 在 [Arch 用户仓库][10]中可用。
我相信你知道该[如何在 Linux 中更改 Shell][11],因此安装后可以切换到 Elvish 来使用它。
### 对 Elvish Shell 的想法
就个人而言,我没有理由在任何系统上安装 Elvish。我可以通过安装几个小的命令行程序或使用已经安装的程序来获得它的大多数功能。
例如Bash 中已经存在“搜索历史命令”功能,并且效果很好。如果要提高历史命令的能力,我建议安装 [fzf][12]。fzf 使用模糊搜索因此你无需记住要查找的确切命令。fzf 还允许你预览和打开文件。
我认为 Elvish 作为一种编程语言是不错的,但是我会坚持使用 Bash shell 脚本,直到 Elvish 变得更成熟。
你们都有用过 Elvish 么?你认为安装 Elvish 是否值得?你最喜欢的 Bash 替代品是什么?请在下面的评论中告诉我们。
如果你发现这篇文章有趣请花一点时间在社交媒体、Hacker News 或 [Reddit][13] 上分享它。
--------------------------------------------------------------------------------
via: https://itsfoss.com/elvish-shell/
作者:[John Paul][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/john/
[b]: https://github.com/lujun9972
[1]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/05/pipelines-in-elvish.png?fit=800%2C421&ssl=1
[2]: https://elv.sh/
[3]: https://github.com/elves/elvish
[4]: https://ranger.github.io/
[5]: https://github.com/elves/awesome-elvish
[6]: https://elv.sh/ref/name.html
[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/05/Elvish-control-structures.png?fit=800%2C425&ssl=1
[8]: https://launchpad.net/%7Ezhsj/+archive/ubuntu/elvish
[9]: https://github.com/FZUG/repo/wiki/Add-FZUG-Repository
[10]: https://aur.archlinux.org/packages/elvish/
[11]: https://linuxhandbook.com/change-shell-linux/
[12]: https://github.com/junegunn/fzf
[13]: http://reddit.com/r/linuxusersgroup