mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-13 22:30:37 +08:00
Merge remote-tracking branch 'LCTT/master'
This commit is contained in:
commit
8d61ccd33a
125
published/20190605 What is GraphQL.md
Normal file
125
published/20190605 What is GraphQL.md
Normal file
@ -0,0 +1,125 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-12070-1.html)
|
||||
[#]: subject: (What is GraphQL?)
|
||||
[#]: via: (https://opensource.com/article/19/6/what-is-graphql)
|
||||
[#]: author: (Zach Lendon https://opensource.com/users/zachlendon)
|
||||
|
||||
什么是 GraphQL?
|
||||
======
|
||||
|
||||
> GraphQL 是一种查询语言、一个执行引擎,也是一种规范,它让开发人员重新思考如何构建客户端和 API 应用。
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/202004/04/112938odz6sbw6hzwsh7f6.jpg)
|
||||
|
||||
GraphQL 是当今软件技术中最大的流行语之一。但它*究竟*是什么?是像 [SQL][2] 一样的查询语言吗?是像 [JVM][3] 这样的执行引擎?还是像 [XML][4] 这样的规范?
|
||||
|
||||
如果你回答上面这些都是,那么你是对的![GraphQL][5] 是一种查询语言的语法、是一种编程语言无关的执行引擎,也是一种不断发展的规范。
|
||||
|
||||
让我们深入了解一下 GraphQL 如何成为所有这些东西的,并了解一下人们为什么对它感到兴奋。
|
||||
|
||||
### 查询语言
|
||||
|
||||
GraphQL 作为查询语言似乎是合理的 —— 毕竟 “QL” 似乎重要到出现在名称中。但是我们查询什么呢?看一个示例查询请求和相应的响应可能会有所帮助。
|
||||
|
||||
以下的用户查询:
|
||||
|
||||
```
|
||||
{
|
||||
user(id: 4) {
|
||||
name
|
||||
email
|
||||
phoneNumber
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
可能会返回下面的 JSON 结果:
|
||||
|
||||
```
|
||||
{
|
||||
"user": {
|
||||
"name": "Zach Lendon"
|
||||
“email”: “zach@hydrate.io”
|
||||
“phoneNumber”: “867-5309”
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
想象一下,客户端应用查询用户详细信息、获取结果,并使用它填充配置屏幕。作为查询语言,GraphQL 的核心优势之一是客户端应用可以*只请求它需要*的数据,并期望以一致的方式返回这些数据。
|
||||
|
||||
那么 GraphQL 响应返回的*什么*呢?这就是执行引擎发挥的作用,通常是以 GraphQL 服务器的形式出现。
|
||||
|
||||
### 执行引擎
|
||||
|
||||
![GraphQL execution engine][7]
|
||||
|
||||
GraphQL 执行引擎负责处理 GraphQL 查询并返回 JSON 响应。所有 GraphQL 服务器由两个核心组件组成,分别定义了执行引擎的结构和行为:模式和解析器。
|
||||
|
||||
GraphQL 模式是一种自定义类型语言,它公开哪些查询既允许(有效),又由 GraphQL 服务器实现处理。上面用户示例查询的模式可能如下所示:
|
||||
|
||||
```
|
||||
type User {
|
||||
name: String
|
||||
email: String
|
||||
phoneNumber: String
|
||||
}
|
||||
|
||||
type Query {
|
||||
user: User
|
||||
}
|
||||
```
|
||||
|
||||
此模式定义了一个返回用户的用户查询。客户端可以通过用户查询请求用户上的任何字段,并且 GraphQL 服务器将仅返回请求的字段。通过使用强类型模式,GraphQL 服务器可以根据定义的模式验证传入的查询,以确保是有效的。
|
||||
|
||||
确定查询有效后,就会由 GraphQL 服务器的解析器处理。解析器函数支持每个 GraphQL 类型的每个字段。我们的这个用户查询的示例解析器可能如下所示:
|
||||
|
||||
```
|
||||
Query: {
|
||||
user(obj, args, context, info) {
|
||||
return context.db.loadUserById(args.id).then(
|
||||
userData => new User(userData)
|
||||
)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
虽然上面的例子是用 JavaScript 编写的,但 GraphQL 服务器可以用任意语言编写。这是因为 GraphQL 也是*也是*一种规范!
|
||||
|
||||
### 规范
|
||||
|
||||
GraphQL 规范定义了 GraphQL 实现必须遵循的功能和特性。作为一个在开放网络基金会的最终规范协议([OWFa 1.0][8])下提供的开放规范,技术社区可以审查 GraphQL 实现必须符合规范的要求,并帮助制定 GraphQL 的未来。
|
||||
|
||||
虽然该规范对 GraphQL 的语法,什么是有效查询以及模式的工作方式进行了非常具体的说明,但它没有提供有关如何存储数据或 GraphQL 服务器应使用哪种编程语言实现的指导。这在软件领域是非常强大的,也是相对独特的。它允许以各种编程语言创建 GraphQL 服务器,并且由于它们符合规范,因此客户端会确切知道它们的工作方式。GraphQL 服务器已经有多种语言实现,人们不仅可以期望像 JavaScript、Java和 C# 这样的语言,还可以使用 Go、Elixir 和 Haskell 等。服务器实现所使用的语言不会成为采用过程的障碍。它不仅存在多种语言实现,而且它们都是开源的。如果没有你选择的语言的实现,那么可以自己实现。
|
||||
|
||||
### 总结
|
||||
|
||||
GraphQL 是开源 API 领域中一个令人兴奋的、相对较新的参与者。它将查询语言、执行引擎与开源规范结合在一起,它定义了 GraphQL 实现的外观和功能。
|
||||
|
||||
GraphQL 已经开始改变企业对构建客户端和 API 应用的看法。通过将 GraphQL 作为技术栈的一部分,前端开发人员可以自由地查询所需的数据,而后端开发人员可以将客户端应用需求与后端系统架构分离。通常,公司在使用 GraphQL 的过程中,首先会在其现有的后端服务之上构建一个 GraphQL API “层”。这使得客户端应用开始获得他们所追求的性能和运营效率,同时使后端团队有机会确定他们可能需要在 GraphQL 层后面的“幕后”进行哪些更改。通常,这些更改都是为了优化,这些优化有助于确保使用 GraphQL 的应用可以尽可能高效地运行。由于 GraphQL 提供了抽象性,因此系统团队可以进行更改的同时继续在其 GraphQL API 级别上遵守 GraphQL 的“合约”。
|
||||
|
||||
由于 GraphQL 相对较新,因此开发人员仍在寻找新颖而激动人心的方法来利用它构建更好的软件解决方案。GraphQL 将如何改变你构建应用的方式,它是否对得起众望所归?只有一种方法可以找到答案 —— 用 GraphQL 构建一些东西!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/6/what-is-graphql
|
||||
|
||||
作者:[Zach Lendon][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/zachlendon
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/analytics-graphs-charts.png?itok=sersoqbV (Analytics: Charts and Graphs)
|
||||
[2]: https://opensource.com/article/18/2/getting-started-sql
|
||||
[3]: https://www.cubrid.org/blog/understanding-jvm-internals/
|
||||
[4]: https://www.w3.org/TR/xml/
|
||||
[5]: http://graphql.org/
|
||||
[6]: mailto:zach@hydrate.io
|
||||
[7]: https://opensource.com/sites/default/files/pictures/graphql-execution-engine.png (GraphQL execution engine)
|
||||
[8]: http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0---patent-only
|
@ -0,0 +1,65 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Ansible streaming video series, open source security tools, and more industry trends)
|
||||
[#]: via: (https://opensource.com/article/20/4/ansible-security-more-industry-trends)
|
||||
[#]: author: (Tim Hildred https://opensource.com/users/thildred)
|
||||
|
||||
Ansible streaming video series, open source security tools, and more industry trends
|
||||
======
|
||||
A weekly look at open source community and industry trends.
|
||||
![Person standing in front of a giant computer screen with numbers, data][1]
|
||||
|
||||
As part of my role as a senior product marketing manager at an enterprise software company with an open source development model, I publish a regular update about open source community, market, and industry trends for product marketers, managers, and other influencers. Here are five of my and their favorite articles from that update.
|
||||
|
||||
## [Ansible 101 by Jeff Geerling: a YouTube streaming series][2]
|
||||
|
||||
> After the incredible response I got from [making my Ansible books free for the rest of March][3] to help people learn new automation skills, I tried to think of some other things I could do to help developers who may be experiencing hardship during the coronavirus pandemic and market upheaval.
|
||||
|
||||
**The impact**: Not everyone is a frontline worker in this crisis, but then not every problem it has created needs one. This is a great example of someone using their resources to help in a unique way.
|
||||
|
||||
## [Open source security tools for cloud and container applications][4]
|
||||
|
||||
> Open-source security tools play an important role in securing your container-based infrastructure. Tools such as Anchore can be used for strong governance capabilities, while on the other hand, Dagda can be used to perform static analysis of known vulnerabilities. Two other tools, OpenSCAP and Clair, also provide good capabilities for vulnerability scanning and compliance management. So, depending upon your business requirements and priorities, you can select the right tool to secure your container investments.
|
||||
|
||||
**The impact**: Containers are Linux, and container security is open source as well.
|
||||
|
||||
## [Cloud cover: Clearing up some misunderstandings about data centres][5]
|
||||
|
||||
> The [carbon footprint of data][6] is becoming more and more of a concern, but there appears to be little economic interest in decreasing the amount of data flowing around the world to mitigate this. In that scenario, finding the most energy-efficient and carbon-neutral ways to run purpose-built data centres could be the only answer.
|
||||
|
||||
**The impact**: I was talking to a colleague who manages a team of virtualization engineers about this very problem. He seemed optimistic about the amount of headway his team could make on improving the energy consumption of things like KVM at the kernel level; though at the moment customers aren't asking for it. I'd guess that if, for example, the price of carbon emissions were to go up for some reason, that situation would change pretty quickly.
|
||||
|
||||
## [Business culture is key in OpenStack network requirements][7]
|
||||
|
||||
> The main question is: What is your [culture][8]? Do you go to a vendor and say, 'Give me your design, tell me what to buy and how to support it'? Starting out, you evaluate systems. What are your options?
|
||||
>
|
||||
> If you have siloed folks that work on a particular model of equipment, then OpenStack is probably not for you. If you have people that function at a higher level with some fundamental understanding about the underlying architecture that makes things work, then OpenStack can be very useful for you, and you're much less restricted.
|
||||
|
||||
**The impact:** Not every organization can adopt a given technology. Certainly not without a willingness to change at a fundamental level.
|
||||
|
||||
_I hope you enjoyed this list and come back next week for more open source community, market, and industry trends._
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/4/ansible-security-more-industry-trends
|
||||
|
||||
作者:[Tim Hildred][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/thildred
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr (Person standing in front of a giant computer screen with numbers, data)
|
||||
[2]: https://www.jeffgeerling.com/blog/2020/ansible-101-jeff-geerling-youtube-streaming-series
|
||||
[3]: https://www.jeffgeerling.com/blog/2020/you-can-get-my-devops-books-free-rest-month
|
||||
[4]: http://techgenix.com/open-source-security-tools/
|
||||
[5]: https://www.siliconrepublic.com/enterprise/data-centres-seamus-dunne-interxion
|
||||
[6]: https://www.siliconrepublic.com/machines/data-carbon-footprint
|
||||
[7]: https://searchnetworking.techtarget.com/feature/Business-culture-is-key-in-OpenStack-network-requirements
|
||||
[8]: https://whatis.techtarget.com/definition/corporate-culture
|
@ -1,5 +1,5 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: translator: (messon007)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
@ -1,5 +1,5 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: translator: (messon007)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
101
sources/talk/20200402 When debugging, your attitude matters.md
Normal file
101
sources/talk/20200402 When debugging, your attitude matters.md
Normal file
@ -0,0 +1,101 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (When debugging, your attitude matters)
|
||||
[#]: via: (https://jvns.ca/blog/debugging-attitude-matters/)
|
||||
[#]: author: (Julia Evans https://jvns.ca/)
|
||||
|
||||
When debugging, your attitude matters
|
||||
======
|
||||
|
||||
A while back I wrote [What does debugging a program look like?][1] on what to do when debugging (change one thing at a time! check your assumptions!).
|
||||
|
||||
But I was debugging some CSS last week, and I think that post is missing something important: **your attitude**.
|
||||
|
||||
Now – I’m not a very good CSS developer yet. I’ve never written CSS professionally and I don’t understand a lot of basic CSS concepts (I think I finally understood for the first time recently how `position: absolute` works). And last week I was working on the most complicated CSS project I’d ever attempted.
|
||||
|
||||
While I was debugging my CSS, I noticed myself doing some bad things that I normally would not! I was:
|
||||
|
||||
* making random changes to my code in the hopes that it would work
|
||||
* googling a lot of things and trying them without understanding what they did
|
||||
* if something broke, reverting my changes and starting again
|
||||
|
||||
|
||||
|
||||
This strategy was exactly as effective as you might imagine (not very effective!), and it was because of my attitude about CSS! I had this unusual-for-me belief that CSS was Too Hard and impossible for me to understand. So let’s talk about that attitude a bit!
|
||||
|
||||
### the problem attitude: “this is too hard for me to understand”
|
||||
|
||||
One specific problem I was having was – I had 2 divs stacked on top of one another, and I wanted Div A to be on top of Div B. My model of CSS stacking order at the start of this was basically “if you want Thing A to be on top of Thing B, change the z-index to make it work”. So I changed the z-index of Div A to be 5 or something.
|
||||
|
||||
But it didn’t work! In Firefox, div A was on top, but in Chrome, Div B was on top. Argh! Why? CSS is impossible!!!
|
||||
|
||||
I googled a bit, and I found out that a possible reason z-index might not work was because Div A and Div B were actually in different “stacking contexts”. If that was true, even if I set the z-index of Div A to 999999 it would still not put it on top of Div B. ([here’s a small example of what this z-index problem looks like, though I think my specific bug had some extra complications][2])
|
||||
|
||||
I thought “man, this stacking context thing seems really complicated, why is it different between Firefox and Chrome, I’m not going to be able to figure this out”. So I tried a bunch of random things a bunch of blog posts suggested, which as usual did not work.
|
||||
|
||||
Finally I gave up this “change random things and pray” strategy and thought “well, what if I just read the documentation on stacking order, maybe it’s not that bad”.
|
||||
|
||||
So I read the [MDN page on stacking order][3], which says:
|
||||
|
||||
> When the z-index property is not specified on any element, elements are stacked in the following order (from bottom to top):
|
||||
> 1\. The background and borders of the root element
|
||||
> 2\. Descendant non-positioned blocks, in order of appearance in the HTML
|
||||
> 3\. Descendant positioned elements, in order of appearance in the HTML
|
||||
|
||||
This is SO SIMPLE! It just depends on the order in the HTML! I put Div A after Div B in the HTML (as a sibling) and it made everything work in both browsers.
|
||||
|
||||
### better attitude: “let’s learn the basics and see if that helps”
|
||||
|
||||
This whole stacking problem turned out to really not be that complicated – all I needed to do was read a very short and simple documentation page to understand how stacking works!
|
||||
|
||||
Of course, computer things are not always this simple (and even in this specific case the [rules about what creates a new stacking context][4] are pretty complicated.). But I did not need to understand those more complicated rules in order to put Div A on top of Div B! I only needed to know the much simpler 3 rules above.
|
||||
|
||||
So – calm down for a second, learn a few of the basics, and see if that helps.
|
||||
|
||||
### watching people who know what they’re doing is inspiring
|
||||
|
||||
Another area of CSS that I thought was “too hard” for me to understand was this whole `position: absolute` and `position: relative` business. I kept seeing (and sometimes using!) examples where people made complicated CSS things with `position: absolute` but I didn’t understand how they worked. Doesn’t `position: absolute` mean that the element is always in the same place on the screen? Why are these `position: absolute` things moving when I scroll like the rest of the document? (spoiler: no, that’s `position: fixed`.)
|
||||
|
||||
But last week, I paired with someone who’s a lot better at CSS than me on some code, and I saw that they were just typing in `position: absolute` and `position: relative` confidently into their code without seeming confused about it!! Could that be me?
|
||||
|
||||
I looked up the [documentation on MDN][5] on `position: absolute`, and it said:
|
||||
|
||||
> The element is removed from the normal document flow, and no space is created for the element in the page layout. It is positioned relative to its closest positioned ancestor… Its final position is determined by the values of top, right, bottom, and left.
|
||||
|
||||
So things with `position: absolute` are positioned relative to their closest positioned ancestor! And you just use `top/bottom/right/left` to pick where! That’s so simple!
|
||||
|
||||
### documentation that you can trust makes a big difference
|
||||
|
||||
I think another big source of my frustration with CSS is that I didn’t have the best grasp of where to find accurate information & advice. I knew that MDN was a reliable reference, but MDN doesn’t really help answer questions like “ok but seriously how do I center a div???” and I found myself reading a lot of random Stack Overflow answers/blog posts that I wasn’t 100% sure were correct.
|
||||
|
||||
This week I learned about [CSS Tricks][6] which has a lot of GREAT articles like [Centering in CSS: A Complete Guide][7] which seems very reputable and is written in a super clear way.
|
||||
|
||||
### that’s all!
|
||||
|
||||
I don’t really know why I started to believe that it was “impossible” to understand basic CSS concepts since I don’t believe that about computers in general. Maybe because I’ve been writing CSS at a beginner level for a very long time but hadn’t ever really tried to do a more involved CSS project than “let’s arrange some divs in a grid with flexbox”!
|
||||
|
||||
But this attitude really got in the way of me writing the CSS I wanted to write! And once I let go of it and used my normal debugging techniques I was able to get a lot more things to work the way I wanted.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://jvns.ca/blog/debugging-attitude-matters/
|
||||
|
||||
作者:[Julia Evans][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://jvns.ca/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://jvns.ca/blog/2019/06/23/a-few-debugging-resources/
|
||||
[2]: https://codepen.io/jvns-css-fun/pen/YzXMMdQ
|
||||
[3]: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/Stacking_without_z-index
|
||||
[4]: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context
|
||||
[5]: https://developer.mozilla.org/en-US/docs/Web/CSS/position
|
||||
[6]: https://css-tricks.com
|
||||
[7]: https://css-tricks.com/centering-css-complete-guide/
|
@ -1,5 +1,5 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: translator: (messon007)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
@ -1,5 +1,5 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: translator: (messon007)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
@ -0,0 +1,85 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Building a sensing prosthetic with the Raspberry Pi)
|
||||
[#]: via: (https://opensource.com/article/20/4/raspberry-pi-sensebreast)
|
||||
[#]: author: (Kathy Reid https://opensource.com/users/kathyreid)
|
||||
|
||||
Building a sensing prosthetic with the Raspberry Pi
|
||||
======
|
||||
SenseBreast is an early prototype of a sensing mastectomy prosthetic
|
||||
based on open hardware.
|
||||
![Open source doctor.][1]
|
||||
|
||||
_Content advisory: this article contains frank discussions of breast cancer._
|
||||
|
||||
What's the first question you ask your surgeon when you're discussing reconstruction options after breast cancer?
|
||||
|
||||
"How many USB ports can you give me?" is probably not the one that comes to mind for many people!
|
||||
|
||||
Although the remark was said jokingly, it sparked a thread that would ultimately become [SenseBreast][2]—an early prototype of a sensing mastectomy prosthetic, based on open hardware.
|
||||
|
||||
### How did SenseBreast come about?
|
||||
|
||||
All technology has a history—an origin story of experimentation, missteps, successes, setbacks, and breakthroughs. SenseBreast is no different. SenseBreast was developed as a term project for the Masters of Applied Cybernetics—a highly selective course at the Australian National University's [3A Institute][3]. The mission of the 3Ai is to bring artificial intelligence and cyber-physical systems safely, responsibly, and sustainably to scale. The purpose of the assignment was to explore the nexus between the electronic, virtual world, and the physical, tactile world.
|
||||
|
||||
### What is SenseBreast?
|
||||
|
||||
SenseBreast combines two distinct elements: a cyber component—electronics, sensors, and storage for gathering data, and a physical component—a breast form designed to be worn inside a mastectomy bra. SenseBreast is a rudimentary cyber-physical system. In cyber-physical systems, physical and software components are deeply intertwined and interact in different ways depending on context.
|
||||
|
||||
The SenseBreast draws on a rich heritage of open source hardware and software. Based on the Raspberry Pi 3B+, it uses the Debian-flavored Raspbian operating system, Python to interact with the onboard sensors, and d3.js to visualize the data that the sensors generate.
|
||||
|
||||
Early versions of the SenseBreast used the SenseHAT, but in the true spirit of open source collaboration, I partnered with Australian open source luminary Jon Oxer to develop a custom SenseBreast board. This contains an inertial motion unit (IMU) and temperature, humidity, and pressure sensors, just like the SenseHAT, but in addition, it contains the BME680 volatile gas sensor and a breakout for a heart rate monitor.
|
||||
|
||||
![SenseBreast open hardware board developed by Jon Oxer and Kathy Reid][4]
|
||||
|
||||
SenseBreast is wearable tech, so the physical form of the cyber-physical system is also important. Factors like comfort, texture, and fit in clothing are important in the design of wearables because technology isn't better unless it's better for people! The early attempts at building a housing for SenseBreast were spectacular failures; in fact, the very first iteration was put together using acrylic render and linen cloth, and held together with paper clips—in true hacker style! It wasn't comfortable to wear at all, but it served as a proof point for further exploration.
|
||||
|
||||
![First attempt at creating a breast form using acrylic render covered in linen cloth][5]
|
||||
|
||||
Later iterations used a different approach. This involved taking a cast of a breast, using quick-dry silicone supported by a plaster cast. The resulting mold was then used with slow-setting silicone to create a true-to-life shape. A recess was carved into the form to house the electronic components, and an additional silicone layer was added to protect the wearer's skin from contact with electronics.
|
||||
|
||||
### What did we learn from SenseBreast?
|
||||
|
||||
The key learning from SenseBreast is that data is partial. It only tells part of a story. It can be misleading and untrustworthy, which makes the decisions based on that data unreliable too. For example, the sensor data gathered by SenseBreast was affected by how hard the CPU was working. The graph below plots a sequence of 5 minutes of data from SenseBreast, just after the device has booted. You can see that the temperature decreases over time; this is because the CPU has to work harder as the Raspberry Pi boots, and then cools down after the boot operations are completed.
|
||||
|
||||
![Data visualisation of the readings in SenseBreast using the d3.js library][6]
|
||||
|
||||
These sorts of learnings have implications on a broader scale.
|
||||
|
||||
What if the SenseBreast were not an open source device, but a commercial wearable that stored data about me? What if part of the business model of that company was to sell the data that was harvested? What if my health insurer had access to that data? Or prospective employers? Now, more than ever, it's important that we have private, open solutions for sensing data about ourselves.
|
||||
|
||||
### What's next for the SenseBreast project?
|
||||
|
||||
The SenseBreast is a very early prototype, but it has the potential to develop through many different arcs. It could be used to assess range of movement post-surgery, to research how different garments and fabrics adjust to temperature and humidity, and to identify correlations between ambient air pressure and conditions such as lymphoedema. The path SenseBreast takes will be dependent on the passion, needs, and dedication of the incredible global open source community.
|
||||
|
||||
You can learn more about SenseBreast at [https://sensebreast.org][2] and see my presentation at [linux.conf.au][7] 2020 [here][8].
|
||||
|
||||
The code for SenseBreast is available on [GitHub][9].
|
||||
|
||||
Health IT has been surprisingly unwilling to deeply support open source software. Despite the huge...
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/4/raspberry-pi-sensebreast
|
||||
|
||||
作者:[Kathy Reid][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/kathyreid
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc_520x292_opensourcedoctor.png?itok=fk79NwpC (Open source doctor.)
|
||||
[2]: https://sensebreast.org/
|
||||
[3]: https://3ainstitute.cecs.anu.edu.au/
|
||||
[4]: https://opensource.com/sites/default/files/uploads/49427571178_bb5df37c3a_c.jpg (SenseBreast open hardware board developed by Jon Oxer and Kathy Reid)
|
||||
[5]: https://opensource.com/sites/default/files/uploads/49641040471_6d0cc91619_c.jpg (First attempt at creating a breast form using acrylic render covered in linen cloth)
|
||||
[6]: https://opensource.com/sites/default/files/uploads/49640513813_5a7d63803a_c.jpg (Data visualisation of the readings in SenseBreast using the d3.js library)
|
||||
[7]: http://linux.conf.au
|
||||
[8]: https://www.youtube.com/watch?v=G3QfZ11DCpc.
|
||||
[9]: https://github.com/KathyReid/sensebreast
|
@ -0,0 +1,162 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Scheduling tasks on Linux using the at command)
|
||||
[#]: via: (https://www.networkworld.com/article/3535808/scheduling-tasks-on-linux-using-the-at-command.html)
|
||||
[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/)
|
||||
|
||||
Scheduling tasks on Linux using the at command
|
||||
======
|
||||
The at command makes it easy to schedule Linux tasks to be run at any time or date you choose. Check out what it can do for you.
|
||||
romkaz / Getty Images
|
||||
|
||||
When you want commands or scripts to run at some particular time, you don’t have to sit with your fingers hovering over the keyboard waiting to press the enter key or even be at your desk at the right time. Instead, you can set your task to be run through the **at** command. In this post, we’ll look at how tasks are scheduled using **at**, how you can precisely select the time you want your process to run and how to view what’s been scheduled to run using **at**.
|
||||
|
||||
### at vs cron
|
||||
|
||||
For those who’ve been scheduling tasks on Linux systems using **cron**, the **at** command is something like **cron** in that you can schedule tasks to run at a selected time, but **cron** is used for jobs that are run periodically – even if that means only once a year. Most **cron** jobs are set up to be run daily, weekly or monthly, though you control how often and when.
|
||||
|
||||
The **at** command, on the other hand, is used for tasks which are run only once. Want to reboot your system at midnight tonight? No problem, **at** can do that for you assuming you have the proper permissions. If you want the system rebooted every Saturday night at 2 a.m., use **cron** instead.
|
||||
|
||||
### Using at
|
||||
|
||||
The **at** command is easy to use ,and there are only a few things to remember. A simple use of **at** might look like this:
|
||||
|
||||
```
|
||||
$ at 5:00PM
|
||||
at> date >> thisfile
|
||||
at> <EOT>
|
||||
```
|
||||
|
||||
After typing “at” and the time the command should be run, **at** prompts you for the command to be run (in this case, the **date** command). Type **^D** to complete your request.
|
||||
|
||||
Assuming we set up this **at** command earlier than 5 p.m., the date and time will be added to the end of a file named “thisfile” later the same day. Otherwise, the command will run at 5 p.m. the following day.
|
||||
|
||||
You can enter more than one command when interacting with the **at** command. If you want more than one command to be run at the same time, simply specify more than one command line:
|
||||
|
||||
[][1]
|
||||
|
||||
```
|
||||
$ at 6:22
|
||||
warning: commands will be executed using /bin/sh
|
||||
at> echo first >> thisfile
|
||||
at> echo second >> thisfile
|
||||
at> <EOT>
|
||||
```
|
||||
|
||||
In the commands above, we’re using a regular user account and adding some simple text to a file in that user’s home directory. If it’s after 6:22 a.m. when this command is run, the command will run the following day because 6:22 is taken to mean 6:22 a.m. If you want it to run at 6:22 p.m., either use 6:22 PM or 18:22. “6:22 PM” also works.
|
||||
|
||||
You can use **at** to schedule commands to run on specific dates either by specifying the dates or specifying dates and times like “10:00AM April 15 2021” or “noon + 5 days” (run at noon five days from today). Here are some examples:
|
||||
|
||||
```
|
||||
at 6PM tomorrow
|
||||
at noon April 15 2021
|
||||
at noon + 5 days
|
||||
at 9:15 + 1000 days
|
||||
```
|
||||
|
||||
After you specify the command to run and press **^D**, you will notice that the **at** command has assigned a job number to each request. This number will show up in the **at** command's job queue.
|
||||
|
||||
```
|
||||
$ at noon + 1000 days
|
||||
warning: commands will be executed using /bin/sh
|
||||
at> date >> thisfile
|
||||
at> <EOT>
|
||||
job 36 at Tue Dec 27 12:00:00 2022 <== job # is 36
|
||||
```
|
||||
|
||||
### Checking the queue
|
||||
|
||||
You can look at the queue of **at** jobs with the **atq** (at queue) command:
|
||||
|
||||
```
|
||||
$ atq
|
||||
32 Thu Apr 2 03:06:00 2020 a shs
|
||||
35 Mon Apr 6 12:00:00 2020 a shs
|
||||
36 Tue Dec 27 12:00:00 2022 a shs
|
||||
34 Thu Apr 2 18:00:00 2020 a shs
|
||||
```
|
||||
|
||||
If you need to cancel one of the jobs in the queue, use the **atrm** (at remove) command along with the job number.
|
||||
|
||||
```
|
||||
$ atrm 32
|
||||
$ atq
|
||||
35 Mon Apr 6 12:00:00 2020 a shs
|
||||
36 Tue Dec 27 12:00:00 2022 a shs
|
||||
34 Thu Apr 2 18:00:00 2020 a shs
|
||||
```
|
||||
|
||||
You can look into the details of a scheduled task using the **at -c** command. Additional details (the active search path, etc.) are also available, but the bottom lines of the output will show you what command has been scheduled to run.
|
||||
|
||||
```
|
||||
$ at -c 36 | tail -6
|
||||
cd /home/shs || {
|
||||
echo 'Execution directory inaccessible' >&2
|
||||
exit 1
|
||||
}
|
||||
date >> thisfile
|
||||
```
|
||||
|
||||
Notice that the command shown begins with testing whether the user’s directory can be entered with a **cd** command. The job will exit with an error if this is not the case. Otherwise the command specified when the **at** command was issued will be run. Read the command as "move into /home/shs OR exit with the error shown".
|
||||
|
||||
### Running jobs as root
|
||||
|
||||
To run **at** jobs as root, simply use **sudo** with your **at** command like this:
|
||||
|
||||
```
|
||||
$ sudo at 8PM
|
||||
[sudo] password for shs:
|
||||
warning: commands will be executed using /bin/sh
|
||||
at> reboot now
|
||||
at> <EOT>
|
||||
job 37 at Wed Apr 1 16:00:00 2020
|
||||
```
|
||||
|
||||
Notice that the root task shows up in the queue with **root** as the one to execute it.
|
||||
|
||||
```
|
||||
35 Mon Apr 6 12:00:00 2020 a shs
|
||||
36 Tue Dec 27 12:00:00 2022 a shs
|
||||
37 Wed Apr 1 20:00:00 2020 a root <==
|
||||
```
|
||||
|
||||
### Running scripts
|
||||
|
||||
You can also use the **at** command to run scripts. Here's an example:
|
||||
|
||||
```
|
||||
$ at 4:30PM
|
||||
warning: commands will be executed using /bin/sh
|
||||
at> bin/tryme
|
||||
at> <EOT>
|
||||
```
|
||||
|
||||
### Denying use of the at command
|
||||
|
||||
The **/etc/at.deny** file provides a way to disallow users from being able to make use of the **at** command. By default, it will probably include a list of disallowed accounts like **ftp** and **nobody**. An **/etc/at.allow** file could be used to do the opposite but, generally, only the **at.deny** file is configured.
|
||||
|
||||
**Wrap-Up**
|
||||
|
||||
The **at** command is very versatile and easy to use when you want to schedule a one-time task – even if you want it to run this afternoon or years in the future.
|
||||
|
||||
Join the Network World communities on [Facebook][2] and [LinkedIn][3] to comment on topics that are top of mind.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.networkworld.com/article/3535808/scheduling-tasks-on-linux-using-the-at-command.html
|
||||
|
||||
作者:[Sandra Henry-Stocker][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://www.networkworld.com/blog/itaas-and-the-corporate-storage-technology/?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE22140&utm_content=sidebar (ITAAS and Corporate Storage Strategy)
|
||||
[2]: https://www.facebook.com/NetworkWorld/
|
||||
[3]: https://www.linkedin.com/company/network-world
|
@ -0,0 +1,296 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Best Raspberry Pi Operating Systems for Various Purposes)
|
||||
[#]: via: (https://itsfoss.com/raspberry-pi-os/)
|
||||
[#]: author: (Ankush Das https://itsfoss.com/author/ankush/)
|
||||
|
||||
Best Raspberry Pi Operating Systems for Various Purposes
|
||||
======
|
||||
|
||||
[Raspberry Pi][1] is an indispensable single-board computer that comes in handy for a lot of work. Don’t believe me? Just [go through this list of Raspberry Pi projects][2] to get a gist of what this tiny device is capable of.
|
||||
|
||||
Considering how useful a Raspberry Pi is – it is an important task to choose the right operating system for it. Of course, you can do a lot of things with Linux but an OS specially configured for a specific purpose can save you considerable time and effort.
|
||||
|
||||
So, in this article, I will be mentioning some of the popular and useful operating systems tailored for Raspberry Pi.
|
||||
|
||||
### Installing any OS on Raspberry Pi is really easy thanks to the Raspberry Pi Imager tool
|
||||
|
||||
[Installing a Raspberry PI operating system on an SD card][3] is easier than ever before. You can simply get the [Raspberry Pi Imager][4] and get any Raspberry Pi OS installed quickly. Check the official video to see how easy it is.
|
||||
|
||||
You may also utilize [NOOBS][5] (New Out Of the Box Software) to easily install different operating systems on Raspberry Pi. You might also get a pre-installed SD card from the list of their supported retailers mentioned in their [official NOOBS download page][5].
|
||||
|
||||
Feel free to explore more about installing the operating systems in their [official documentation][6].
|
||||
|
||||
[Raspberry Pi OS Download][4]
|
||||
|
||||
Now that you know how to install it (and where to get it from), let me highlight a list of useful Raspberry Pi OS to help you out.
|
||||
|
||||
### Various operating systems for Raspberry Pi
|
||||
|
||||
Please keep in mind that I have taken some effort to list only those Raspberry Pi operating system projects that are being actively maintained. If a project gets discontinued in near future, let me know in the comment section and I’ll update this article.
|
||||
|
||||
Another thing is that I have focused on the latest Raspberry 4 but this should not be considered a list of Raspberry Pi 4 OS. You should be able to use it on Raspberry Pi 3, 3 B+ and other variants as well but please check the official project websites for the exact details.
|
||||
|
||||
**Note:** The list is in no particular order of ranking.
|
||||
|
||||
#### 1\. Raspbian OS: The official Raspberry Pi OS
|
||||
|
||||
![][7]
|
||||
|
||||
Raspbian is the officially supported OS for Raspberry Pi boards. It comes baked in with several tools for education, programming, and general use. Specifically, it includes Python, Scratch, Sonic Pi, Java, and several other important packages.
|
||||
|
||||
Originally, Raspbian is based on Debian and comes pre-installed with loads of useful packages. So, when you get this installed, you probably don’t need to install essentials separately – you should find almost everything pre-installed.
|
||||
|
||||
Raspbian OS is actively maintained and it is one of the most popular Raspberry Pi OS out there. You can install it using [NOOBS][5] or follow the [official documentation][6] to get it installed.
|
||||
|
||||
[Raspbian OS][8]
|
||||
|
||||
#### 2\. Ubuntu MATE: For general purpose computing
|
||||
|
||||
![][9]
|
||||
|
||||
Even though Raspbian is the officially supported OS, it does not feature the latest and greatest packages. So, if you want quicker updates and potentially latest packages, you can try Ubuntu MATE for Raspberry Pi.
|
||||
|
||||
Ubuntu MATE tailored as a Raspberry Pi OS is an incredibly lightweight distribution to have installed. It’s also popularly used on [NVIDIA’s Jetson Nano][10]. In other words, you can utilize it for several use-cases with the Raspberry Pi.
|
||||
|
||||
To help you out, we also have a detailed guide on [how to install Ubuntu MATE on Raspberry Pi][11].
|
||||
|
||||
[Ubuntu MATE for Raspberry Pi][12]
|
||||
|
||||
#### 3\. Ubuntu Server: To use it as a Linux server
|
||||
|
||||
![][13]
|
||||
|
||||
If you’re planning to use your Raspberry Pi as some sort of server for your project, Ubuntu Server can be a great choice to have installed.
|
||||
|
||||
You can find both 32-bit and 64-bit images of the OS. And, depending on what board you have (if it supports 64-bit), you can go ahead and install the same.
|
||||
|
||||
However, it is worth noting that Ubuntu Server isn’t tailored for desktop usage. So, you need to keep in mind that you will have no proper graphical user interface installed by default.
|
||||
|
||||
[Ubuntu Server][14]
|
||||
|
||||
#### 4\. LibreELEC: For media server
|
||||
|
||||
![][15]
|
||||
|
||||
While we already have a list of [media server software available for Linux][16], LibreELEC is one of them.
|
||||
|
||||
It’s a great lightweight OS system capable enough to have [KODI][17] on your Raspberry Pi. You can try installing it using the Raspberry Pi Imager.
|
||||
|
||||
You can easily head to their [official download webpage][18] and find a suitable installer image for your board.
|
||||
|
||||
[LibreELEC][19]
|
||||
|
||||
#### 5\. OSMC: For media server
|
||||
|
||||
![][20]
|
||||
|
||||
OSMC is yet another [popular media server software][16] for Linux. While considering the use of Raspberry Pi boards as media center devices, this is one of the best Raspberry Pi OS that you can recommend to someone.
|
||||
|
||||
Similar to LibreELEC, OSMC also runs KODI to help you manage your media files and enjoy watching the content you already have.
|
||||
|
||||
OSMC does not officially mention the support for **Raspberry Pi 4**. So, if you have Raspberry Pi 3 or lower, you should be good to go.
|
||||
|
||||
[OSMC][21]
|
||||
|
||||
#### 6\. RISC OS: The original ARM OS
|
||||
|
||||
![][22]
|
||||
|
||||
Originally crafted for ARM devices, RISC OS has been around for almost 30 years or so.
|
||||
|
||||
We also have a separate detailed article on [RISC OS][23], if you’re curious to know more about it. Long story short, RISC OS is also tailored for modern ARM-based single-board computers like the Raspberry Pi. It presents a simple user interface with a focus on performance.
|
||||
|
||||
Again, this is not something meant for the Raspberry Pi 4. So, only if you have a Raspberry Pi 3 or lower, you can give it a try.
|
||||
|
||||
[RISC OS][24]
|
||||
|
||||
#### 7\. Mozilla WebThings Gateway: For IoT projects
|
||||
|
||||
![][25]
|
||||
|
||||
As part of Mozilla’s [open-source implementation for IoT devices][26], WebThings Gateway lets you monitor and control all your connected IoT devices.
|
||||
|
||||
You can follow the [official documentation][27] to check the requirements and the instructions to get it installed on a Raspberry Pi. Definitely, one of the most useful Raspberry Pi OS for IoT applications.
|
||||
|
||||
[WebThings Gateway][28]
|
||||
|
||||
#### 8\. Ubuntu Core: For IoT projects
|
||||
|
||||
Yet another Raspberry Pi OS for potential [IoT][29] applications or just to simply test snaps – Ubuntu Core.
|
||||
|
||||
Ubuntu core is specifically tailored for IoT devices or specifically Raspberry Pi, here. I wouldn’t make any claims about it- but Ubuntu Core is a suitable secure OS for Raspberry Pi boards. You can give this a try for yourself!
|
||||
|
||||
[Ubuntu Core][30]
|
||||
|
||||
#### 9\. DietPi: Lightweight Raspberry Pi OS
|
||||
|
||||
![DietPi Screenshot via Distrowatch][31]
|
||||
|
||||
DietPi is a lightweight [Debian][32] operating system that also claims to be lighter than the “Raspbian Lite” OS.
|
||||
|
||||
While considering it as a lightweight Raspberry Pi OS, it offers a lot of features that could come in handy for several use-cases. Ranging from easy installers for software packages to a backup solution, there’s a lot to explore.
|
||||
|
||||
If you’re aiming to get an OS with a low footprint but potentially better performance, you could give this a try.
|
||||
|
||||
[DietPi][33]
|
||||
|
||||
#### 10\. Lakka Linux: Make a retro gaming console
|
||||
|
||||
![][34]
|
||||
|
||||
Looking for a way to turn your Raspberry Pi to a retro gaming console?
|
||||
|
||||
Lakka Linux distribution is originally built on the RetroArch emulator. So, you can have all your retro games on your Raspberry Pi in no time.
|
||||
|
||||
We also have a separate article on [Lakka Linux][35] – if you’re curious to know about it. Or else, just go right ahead and test it out!
|
||||
|
||||
[Lakka][36]
|
||||
|
||||
#### 11\. RetroPie: For retro gaming
|
||||
|
||||
![ ][37]
|
||||
|
||||
RetroPie is yet another popular Raspberry Pi OS that turns it into a retro gaming console. It features several configuration tools so that you can customize the theme or just tweak the emulator to have the best retro games.
|
||||
|
||||
It is worth noting that it does not include any copyrighted games. You can give it a try and see how it works!
|
||||
|
||||
[RetroPie][38]
|
||||
|
||||
#### 12\. Kali Linux: For hacking on budget
|
||||
|
||||
![][39]
|
||||
|
||||
Want to try and learn some ethical hacking skills on your Raspberry Pi? Kali Linux can be a perfect fit for it. And, yes, it usually supports the latest Raspberry Pi as soon as it launches.
|
||||
|
||||
Not just limited to Raspberry Pi, but you can get a long list of other supported devices as well. Try it out and have fun!
|
||||
|
||||
[Kali Linux][40]
|
||||
|
||||
#### 13\. OpenMediaVault: For Network Attached Storage (NAS)
|
||||
|
||||
![][41]
|
||||
|
||||
If you’re trying to set up a [NAS][42] (Network Attached Storage) solution on minimal hardware, Raspberry Pi can help.
|
||||
|
||||
Originally, based on Debian Linux, OpenMediaVault offers a bunch of features that include web-based administration capabilities, plugin support, and more. It does support most of the Raspberry Pi models – so you can try downloading it and get it installed!
|
||||
|
||||
[OpenMediaVault][43]
|
||||
|
||||
#### 14\. ROKOS: For crypto mining
|
||||
|
||||
![][44]
|
||||
|
||||
If you’re someone who’s interested in cryptocurrencies and bitcoins specifically, this could interest you.
|
||||
|
||||
ROKOS is a Debian-based OS that basically lets you turn your Raspberry Pi into a node while having pre-installed drivers and packages for the same. Of course, you need to know how it works before getting it installed. So, I suggest you do some research if you’re not sure what you’re doing.
|
||||
|
||||
[ROKOS][45]
|
||||
|
||||
#### 15\. Alpine Linux: Lightweight security-focused Linux
|
||||
|
||||
Nowadays, a lot of users are usually looking for security-focused and [privacy-focused distributions][46]. And, if you are one of them, you might as well try Alpine Linux for Raspberry Pi.
|
||||
|
||||
It may not be as user-friendly as you’d expect (or beginner-friendly) if you’re just getting started with Raspberry Pi. But, if you want something different to start with, you can try Alpine Linux, which is a security-focused Linux distribution.
|
||||
|
||||
[Alpine Linux][47]
|
||||
|
||||
#### 16\. Kano OS: Operating system for kids’education
|
||||
|
||||
![][48]
|
||||
|
||||
If you’re looking for an open-source OS for Raspberry Pi to make things interesting to learn and educate kids, Kano OS is a good choice.
|
||||
|
||||
It’s being actively maintained and the user experience for the desktop integration on Kano OS is quite simple and fun for someone to play and make kids learn from it.
|
||||
|
||||
[Kano OS][49]
|
||||
|
||||
#### 17\. KDE Plasma Bigscreen: To convert regular TVs into Smart TVs
|
||||
|
||||
![][50]
|
||||
|
||||
This is an under development project from KDE. With [KDE Plasma Bigscreen OS][51] installed on Raspberry Pi, you can use your regular TV like a smart TV.
|
||||
|
||||
You don’t need a special remote to control the TV. You can use the regular remote control.
|
||||
|
||||
Plasma Bigscreen also integrates [MyCroft open source AI][52] for voice control.
|
||||
|
||||
The project is in beta phase so expect some bugs and issues if you are willing to give it a try.
|
||||
|
||||
[Plasma Bigscreen][53]
|
||||
|
||||
#### Wrapping Up
|
||||
|
||||
I’m sure there are a lot of other operating systems tailored for Raspberry Pi – but I’ve tried to list the most popular or the useful ones that are actively maintained.
|
||||
|
||||
If you think I missed one of best suited Raspberry Pi OS, feel free to let me know about it in the comments below!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/raspberry-pi-os/
|
||||
|
||||
作者:[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://www.raspberrypi.org/
|
||||
[2]: https://itsfoss.com/raspberry-pi-projects/
|
||||
[3]: https://itsfoss.com/tutorial-how-to-install-raspberry-pi-os-raspbian-wheezy/
|
||||
[4]: https://www.raspberrypi.org/downloads/
|
||||
[5]: https://www.raspberrypi.org/downloads/noobs/
|
||||
[6]: https://www.raspberrypi.org/documentation/installation/installing-images/README.md
|
||||
[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/06/raspbian_home_screen.jpg?resize=800%2C492&ssl=1
|
||||
[8]: https://www.raspbian.org/
|
||||
[9]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/04/Desktop-ubuntu.jpg?resize=800%2C600&ssl=1
|
||||
[10]: https://www.nvidia.com/en-us/autonomous-machines/embedded-systems/jetson-nano/
|
||||
[11]: https://itsfoss.com/ubuntu-mate-raspberry-pi/
|
||||
[12]: https://ubuntu-mate.org/raspberry-pi/
|
||||
[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/ubunt-server.png?ssl=1
|
||||
[14]: https://ubuntu.com/download/raspberry-pi
|
||||
[15]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/02/libreelec.jpg?resize=800%2C600&ssl=1
|
||||
[16]: https://itsfoss.com/best-linux-media-server/
|
||||
[17]: https://kodi.tv/
|
||||
[18]: https://libreelec.tv/downloads_new/
|
||||
[19]: https://libreelec.tv/
|
||||
[20]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/osmc-server.jpg?resize=800%2C450&ssl=1
|
||||
[21]: https://osmc.tv/
|
||||
[22]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2018/10/riscos5.1.jpg?resize=800%2C600&ssl=1
|
||||
[23]: https://itsfoss.com/risc-os-is-now-open-source/
|
||||
[24]: https://www.riscosopen.org/content/
|
||||
[25]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/web-things-gateway.png?ssl=1
|
||||
[26]: https://iot.mozilla.org/about/
|
||||
[27]: https://iot.mozilla.org/docs/gateway-getting-started-guide.html
|
||||
[28]: https://iot.mozilla.org/gateway/
|
||||
[29]: https://en.wikipedia.org/wiki/Internet_of_things
|
||||
[30]: https://ubuntu.com/download/raspberry-pi-core
|
||||
[31]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/diet-pi.jpg?ssl=1
|
||||
[32]: https://www.debian.org/
|
||||
[33]: https://dietpi.com/
|
||||
[34]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2016/08/lakkaos.jpg?resize=1024%2C640&ssl=1
|
||||
[35]: https://itsfoss.com/lakka-retrogaming-linux/
|
||||
[36]: http://www.lakka.tv/
|
||||
[37]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/retro-pie.png?ssl=1
|
||||
[38]: https://retropie.org.uk/
|
||||
[39]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/kali-linux-pi.png?ssl=1
|
||||
[40]: https://www.offensive-security.com/kali-linux-arm-images/
|
||||
[41]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/openmediavault.jpg?ssl=1
|
||||
[42]: https://en.wikipedia.org/wiki/Network-attached_storage
|
||||
[43]: https://www.openmediavault.org/
|
||||
[44]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/rocos-bitcoin-pi.jpg?ssl=1
|
||||
[45]: https://rokos.space/
|
||||
[46]: https://itsfoss.com/privacy-focused-linux-distributions/
|
||||
[47]: https://alpinelinux.org/
|
||||
[48]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/kano-os-pi.jpeg?ssl=1
|
||||
[49]: https://kano.me/row/downloadable
|
||||
[50]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/plasma-bigscreen-menu.jpg?ssl=1
|
||||
[51]: https://itsfoss.com/kde-plasma-bigscreen/
|
||||
[52]: https://itsfoss.com/mycroft-mark-2/
|
||||
[53]: https://plasma-bigscreen.org/#download-jumpto
|
@ -0,0 +1,129 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Bodhi Linux 5.1 Review: Slightly Different Lightweight Linux)
|
||||
[#]: via: (https://itsfoss.com/bodhi-linux-review/)
|
||||
[#]: author: (John Paul https://itsfoss.com/author/john/)
|
||||
|
||||
Bodhi Linux 5.1 Review: Slightly Different Lightweight Linux
|
||||
======
|
||||
|
||||
Bodhi Linux is a [lightweight Linux distribution][1] based on Ubuntu. Unlike most other distributions, Bodhi uses its own Moksha desktop and focuses on providing you a minimal setup to run on older computers.
|
||||
|
||||
### What is Bodhi Linux?
|
||||
|
||||
![Bodhi Start Page][2]
|
||||
|
||||
[Bodhi Linux][3] was first introduced in 2011. It is designed with “[minimalism, resource efficiency, and user choice][4]” in mind. The devs strove to provide a “[system that is functional but not bloated][5]“. As such, it uses the lightweight Moksha Desktop and has only the basic applications preinstalled. The idea is to give the user a stable platform to build the system that they want. It is based on the latest Ubuntu LTS.
|
||||
|
||||
### Moksha Desktop
|
||||
|
||||
![Bodhi Desktop][6]
|
||||
|
||||
Originally Bodhi shipped with the [Enlightenment desktop environment][7]. Bodhi Linux has long been known as the “Enlightened” Linux distro. In fact, the word ‘bodhi’ is based on the Sanskrit word for “enlightenment”.
|
||||
|
||||
However, that changed when Enlightenment 18 was released. The release was in such bad shape that it was not included in Bodhi. Enlightenment 19 was released and fixed some of the problems, but still had issues.
|
||||
|
||||
After trying to work with the Enlightenment dev team and getting nowhere, the Bodhi devs [forked][8] Enlightenment 17 in 2015. The new desktop environment would be named [Moksha][9], which is based on the Sanskrit word for “emancipation, liberation, or release”. You can find the code for it on [GitHub][10].
|
||||
|
||||
### What is new in 5.1.0?
|
||||
|
||||
[Subscribe to our YouTube channel for more Linux videos][11]
|
||||
|
||||
[Bodhi 5.1.0][12] is the first release in two years and the second release to be based on Ubuntu 18.04. Besides updating packages, it also has new default icons and theme. This release makes several changes to the default applications. Leafpad comes preinstalled instead of epad and [GNOME Web][13] (also known as Epiphany) replaces [Midori][14]). The eepDater system updater was removed.
|
||||
|
||||
There are currently [four different versions][15] of Bodhi 5.1.0 available to [download][16]: Standard, Hwe, Legacy, and AppPack.
|
||||
|
||||
* Standard will work for systems made in the last decade. It does not push kernel updates.
|
||||
* Hwe (Hardware Enablement) edition is new to the Bodhi family and is designed to include support for newer hardware and will received kernel updates. The 5.1 release features the 5.3.0-42 kernel.
|
||||
* Legacy is the only edition that is 32-bit. It uses the “older 4.9.0-6-686 Linux kernel that is optimized for old (15+ years old) hardware. This kernel also does not include the PAE extension which is not supported on many older systems.”
|
||||
* The AppPack edition is for those who want a fully-loaded system out of the box and comes with many applications preinstalled.
|
||||
|
||||
|
||||
|
||||
### System Requirements for Bodhi Linux
|
||||
|
||||
Minimum system requirement
|
||||
|
||||
* 500 MHz processor
|
||||
* 256 MB of RAM
|
||||
* 5 GB of drive space
|
||||
|
||||
|
||||
|
||||
Recommended system requirement
|
||||
|
||||
* 1.0 GHz processor
|
||||
* 512 MB of RAM
|
||||
* 10 GB of drive space
|
||||
|
||||
|
||||
|
||||
### Experiencing Bodhi Linux
|
||||
|
||||
![Old Bodhi Linux][17]
|
||||
|
||||
Since it is based on Ubuntu, installing Bodhi was very simple. After I signed into Bodhi, I was surprised by the new theme and icon set. The last time I installed Bodhi (including 5.0 a couple of months ago) I thought that it needed a new look. There was nothing really wrong with the previous theme, but it looked like something from the early 2000. The new theme gives it a more modern look.
|
||||
|
||||
![Bodhi Linux 5.1][18]
|
||||
|
||||
I was also glad to see that Midori had been replaced by GNOME Web. I’m not a fan of [Midori browser][19]. It always seemed too minimal for me. (However, that might change in the future with [Midori Next][20].) Web felt more like the web browser I need. Most importantly it comes with Firefox Sync, so I can keep all of my bookmarks and passwords synced.
|
||||
|
||||
Unlike many Linux distros, Bodhi doesn’t really come with a stand-alone software center. Instead, if you click the AppCenter icon it opens the browser and navigates to the [AppCenter p][21][a][21][ge][21] of the Bodhi website. Here apps are sorted by category. Most of them are [lightweight applications][22].
|
||||
|
||||
![Bodhi Linux Appcenter][23]
|
||||
|
||||
If you click on one of the pages and click “Install”, Bodhi will install it (after to type in your passwords). This is achieved using a neat little program named [apturl][24] that “is a very simple way to install a software package from a web browser”. It’s pretty slick and I wish more Ubuntu-based distros would use it.
|
||||
|
||||
Overall, I like the Moksha desktop. It adheres to the desktop metaphor we have seen for decades (and which I am most comfortable with). It stays out of your way but is very easy to change and modify. The only thing I miss is that the application menu doesn’t open when I hit the super key. But I guess you can’t have everything in life.
|
||||
|
||||
### Final Thoughts
|
||||
|
||||
I was pleasantly surprised by this recent release of Bodhi Linux. In the past, I’ve played with it from time to time. I always liked it, but this last release has been the best so far. In a way, they have broken free of the idea that Bodhi is only for older system by adding support for newer kernels.
|
||||
|
||||
If you are looking for a change of scenery while staying close to the world of Ubuntu give [Bodhi Linux][3] a try.
|
||||
|
||||
Have you ever used Bodhi Linux? What is your favorite Ubuntu-based distro? 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][25].
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/bodhi-linux-review/
|
||||
|
||||
作者:[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://itsfoss.com/lightweight-linux-beginners/
|
||||
[2]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/bodhi-start-page.png?resize=800%2C500&ssl=1
|
||||
[3]: https://www.bodhilinux.com/
|
||||
[4]: https://www.bodhilinux.com/w/wiki/
|
||||
[5]: https://www.bodhilinux.com/w/what-is-bodhi-linux/
|
||||
[6]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/bodhi-desktop.jpg?resize=800%2C500&ssl=1
|
||||
[7]: https://www.enlightenment.org/start
|
||||
[8]: https://www.bodhilinux.com/2015/04/28/introducing-the-moksha-desktop/
|
||||
[9]: https://www.bodhilinux.com/moksha-desktop/
|
||||
[10]: https://github.com/JeffHoogland/moksha
|
||||
[11]: https://www.youtube.com/c/itsfoss?sub_confirmation=1
|
||||
[12]: https://www.bodhilinux.com/2020/03/25/bodhi-linux-5-1-0-released/
|
||||
[13]: https://wiki.gnome.org/Apps/Web/
|
||||
[14]: https://en.wikipedia.org/wiki/Midori_(web_browser
|
||||
[15]: https://www.bodhilinux.com/w/selecting-the-correct-iso-image/
|
||||
[16]: https://www.bodhilinux.com/download/
|
||||
[17]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/bodhi.png?resize=800%2C400&ssl=1
|
||||
[18]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/bodhi-Linux-5-1-screenshot.jpg?ssl=1
|
||||
[19]: https://itsfoss.com/midori-browser/
|
||||
[20]: https://www.midori-browser.org/2020/01/15/midori-next-come-on-yarovi-we-can/
|
||||
[21]: https://www.bodhilinux.com/a/
|
||||
[22]: https://itsfoss.com/lightweight-alternative-applications-ubuntu/
|
||||
[23]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/Bodhi-Linux-AppCenter.png?resize=800%2C500&ssl=1
|
||||
[24]: https://wiki.ubuntu.com/AptUrl
|
||||
[25]: https://reddit.com/r/linuxusersgroup
|
@ -0,0 +1,140 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (What is Arch User Repository (AUR)? How to Use AUR on Arch and Manjaro Linux?)
|
||||
[#]: via: (https://itsfoss.com/aur-arch-linux/)
|
||||
[#]: author: (Dimitrios Savvopoulos https://itsfoss.com/author/dimitrios/)
|
||||
|
||||
What is Arch User Repository (AUR)? How to Use AUR on Arch and Manjaro Linux?
|
||||
======
|
||||
|
||||
If you have been using [Arch Linux][1] or other distribution based on Arch such as Manjaro, you might have comes across the term AUR. You try to install a new software and someone suggests to install it from AUR. This leaves you confused.
|
||||
|
||||
What is this AUR? Why is it used? How to use AUR? I’ll answer these questions in this article.
|
||||
|
||||
### What is AUR?
|
||||
|
||||
![][2]
|
||||
|
||||
AUR stands for Arch User Repository. It is a community-driven repository for Arch-based Linux distributions users. It contains package descriptions named [PKGBUILDs][3] that allow you to compile a package from source with [makepkg][4] and then install it via [pacman][5] (package manager in Arch Linux).
|
||||
|
||||
The AUR was created to organize and share new packages from the community and to help accelerate popular packages’ inclusion into the [community repository][6].
|
||||
|
||||
A good number of new packages that enter the official repositories start in the AUR. In the AUR, users are able to contribute their own package builds (PKGBUILD and related files).
|
||||
|
||||
The AUR community has the ability to vote for packages in the AUR. If a package becomes popular enough — provided it has a compatible license and good packaging technique — it may be entered into the community repository directly accessible by pacman.
|
||||
|
||||
In short, AUR is the way for developers to make new software available to Arch Linux users before the software is officially included in Arch repositories.
|
||||
|
||||
### Should you use AUR? What’s the risk involved?
|
||||
|
||||
Using the AUR is like crossing the street. If you proceed with caution you should be fine.
|
||||
|
||||
If you are new to Linux it is advised to not to use the AUR until you build a foundation knowledge about Arch/Manjaro and Linux in general.
|
||||
|
||||
It is true that anyone can upload packages to the AUR but the [Trusted Users][7] (TUs) are charged with keeping an eye on what gets uploaded. Although TUs perform quality control to the uploaded packages, there is in no guarantee that packages in the AUR are well formed or not malicious.
|
||||
|
||||
In practice the AUR seems to be quite safe but in theory it can do some damage, but only if you are not careful. A smart Arch user, **always** inspects PKGBUILDs and *.install files when building packages from the AUR.
|
||||
|
||||
Additionally TUs (Trusted Users) also remove packages in the AUR that are included in core/extra/community so there should be no naming conflicts between them. The AUR will often contain developmental versions of packages (cvs/svn/git/etc) but they will have modified names such as foo-git.
|
||||
|
||||
As for the AUR packages, pacman handles dependency resolution and detects file conflicts so you never have to worry about overwriting files in one package with files from another package unless you use the “–force” option by default. If you do that, you probably have more serious problems than file conflicts.
|
||||
|
||||
### How to use AUR?
|
||||
|
||||
The simplest way to use AUR is through a AUR helper. An [AUR helper][8] is a command line tool (some has GUI as well) that lets you search for packages published on the AUR and install them.
|
||||
|
||||
##### Installing an AUR helper on Arch Linux
|
||||
|
||||
Let’s say you want to use [Yay AUR helper][9]. Make sure that you have git installed on Linux. And then clone the repository, go to the directory and build the package.
|
||||
|
||||
Use these commands one by one for that:
|
||||
|
||||
```
|
||||
sudo pacman -S git
|
||||
sudo git clone https://aur.archlinux.org/yay-git.git
|
||||
cd yay
|
||||
makepkg -si
|
||||
```
|
||||
|
||||
Once installed, you can use yay command like this to install a package:
|
||||
|
||||
```
|
||||
yay -S package_name
|
||||
```
|
||||
|
||||
It’s not that you must use AUR helper for installing packages from AUR. Expand the next section to see how to use AUR without AUR helper.
|
||||
|
||||
##### Installing AUR packages without AUR helpers
|
||||
|
||||
If you don’t want to use AUR helper, you can install packages from AUR on your own as well.
|
||||
|
||||
As soon as you find the package you want to install on [AUR page][10] it is advised to confirm “Licence”, “Popularity”, “Last Updated”, “Dependencies” and so on as an extra quality control step.
|
||||
|
||||
```
|
||||
git clone [package URL]
|
||||
cd [package name]
|
||||
makepkg -si
|
||||
```
|
||||
|
||||
For example. let’s say you want to install [telegram desktop package][11]:
|
||||
|
||||
```
|
||||
git clone https://aur.archlinux.org/telegram-desktop-git.git
|
||||
cd telegram-desktop-git
|
||||
makepkg -si
|
||||
```
|
||||
|
||||
#### Enabling AUR support in Manjaro Linux
|
||||
|
||||
AUR isn’t enabled by default and you have to enable it through pamac. My laptop runs [Manjaro][12] Cinnamon but the steps are same for all Manjaro flavors.
|
||||
|
||||
Open Pamac (listed as Add/Remove Software):
|
||||
|
||||
![][13]
|
||||
|
||||
Once you are in pamac go to preferences like shown below.
|
||||
|
||||
![][14]
|
||||
|
||||
In preferences dialog box go to AUR tab, enable the AUR support, enable check for updates and close the dialog box.
|
||||
|
||||
![][15]
|
||||
|
||||
You can now search for packages and those which belong to AUR can be identified by the tag under the package descriptions.
|
||||
|
||||
![][16]
|
||||
|
||||
I hope you find this article useful and keep an eye on social media for upcoming Arch related topics.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/aur-arch-linux/
|
||||
|
||||
作者:[Dimitrios Savvopoulos][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/dimitrios/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://www.archlinux.org/
|
||||
[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/what-is-aur.png?ssl=1
|
||||
[3]: https://wiki.archlinux.org/index.php/PKGBUILD
|
||||
[4]: https://wiki.archlinux.org/index.php/Makepkg
|
||||
[5]: https://wiki.archlinux.org/index.php/Pacman#Additional_commands
|
||||
[6]: https://wiki.archlinux.org/index.php/Community_repository
|
||||
[7]: https://wiki.archlinux.org/index.php/Trusted_Users
|
||||
[8]: https://itsfoss.com/best-aur-helpers/
|
||||
[9]: https://github.com/Jguer/yay
|
||||
[10]: https://aur.archlinux.org/
|
||||
[11]: https://aur.archlinux.org/packages/telegram-desktop-git
|
||||
[12]: https://manjaro.org/
|
||||
[13]: https://i1.wp.com/i.imgur.com/kFF6HtW.png?ssl=1
|
||||
[14]: https://i0.wp.com/i.imgur.com/47r963A.png?ssl=1
|
||||
[15]: https://i1.wp.com/i.imgur.com/UThiDHO.png?ssl=1
|
||||
[16]: https://i2.wp.com/i.imgur.com/RM5BKi2.png?ssl=1
|
@ -1,127 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (What is GraphQL?)
|
||||
[#]: via: (https://opensource.com/article/19/6/what-is-graphql)
|
||||
[#]: author: (Zach Lendon https://opensource.com/users/zachlendon)
|
||||
|
||||
什么是 GraphQL?
|
||||
======
|
||||
GraphQL 是一种查询语言、执行引擎和规范,它让开发人员重新思考如何构建客户端和 API
|
||||
应用。
|
||||
![Analytics: Charts and Graphs][1]
|
||||
|
||||
GraphQL 是当今软件技术中最大的流行语之一。但它_实际上_是什么?它是像 [SQL][2] 这样的查询语言吗?像 [JVM][3] 这样的执行引擎?像 [XML][4] 这样的规范?
|
||||
|
||||
如果你的回答是上面这些,那么你是对的![GraphQL][5] 是查询语言语法、编程语言无关的执行引擎和不断发展的规范。
|
||||
|
||||
让我们深入了解 GraphQL 如何成为这些,并了解人们为什么对此感到兴奋。
|
||||
|
||||
### 查询语言
|
||||
|
||||
GraphQL 作为查询语言似乎是合理的—”QL“ 似乎足够重要,毕竟它出现在名称中。但是我们在查询什么?查看示例查询请求和相应的响应可能会有所帮助。
|
||||
|
||||
以下的用户查询:
|
||||
|
||||
|
||||
```
|
||||
{
|
||||
user(id: 4) {
|
||||
name
|
||||
email
|
||||
phoneNumber
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
可能会返回下面的 JSON 结果:
|
||||
|
||||
|
||||
```
|
||||
{
|
||||
"user": {
|
||||
"name": "Zach Lendon"
|
||||
“email”: “[zach@hydrate.io][6]”
|
||||
“phoneNumber”: “867-5309”
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
想象一下,客户端应用查询用户详细信息,获取结果,并使用它填充配置文件。作为查询语言,GraphQL 的核心优势之一是客户端应用可以_只请求它需要_的数据,并期望以一致的方式返回这些数据。
|
||||
|
||||
那么_什么_返回了 GraphQL 响应?这就是执行引擎(通常以 GraphQL 服务器的形式)发挥作用的地方。
|
||||
|
||||
### 执行引擎
|
||||
|
||||
![GraphQL execution engine][7]
|
||||
|
||||
GraphQL 执行引擎负责处理 GraphQL 查询并返回 JSON 响应。所有 GraphQL 服务器由两个核心组件组成,分别定义了执行引擎的结构和行为:schema 和解析器。
|
||||
|
||||
GraphQL schema 是一种自定义类型语言,它公开哪些查询既允许(有效),又由 GraphQL 服务器实现处理。上面用户示例查询的 schema 可能如下所示:
|
||||
|
||||
|
||||
```
|
||||
type User {
|
||||
name: String
|
||||
email: String
|
||||
phoneNumber: String
|
||||
}
|
||||
|
||||
type Query {
|
||||
user: User
|
||||
}
|
||||
```
|
||||
|
||||
此 schema 定义返回用户的用户查询。客户端可以通过用户查询请求用户上的任何字段,并且 GraphQL 服务器将仅返回请求的字段。通过使用强类型架构,GraphQL 服务器可以验证传入查询,以确保它们基于定义的 schema 有效。
|
||||
|
||||
确定查询有效后,它由 GraphQL 服务器的解析器处理。解析器函数支持每个 GraphQL 类型的每个字段。用户查询的示例解析器可能如下所示:
|
||||
|
||||
```
|
||||
Query: {
|
||||
user(obj, args, context, info) {
|
||||
return context.db.loadUserById(args.id).then(
|
||||
userData => new User(userData)
|
||||
)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
虽然上面的例子是 JavaScript,但 GraphQL 服务器可以用任意语言编写。这是因为 GraphQL 也是_也是_一种规范!
|
||||
|
||||
### 规范
|
||||
|
||||
GraphQL 规范定义了 GraphQL 实现必须遵循的功能和特性。作为开放网络基金会最终规范协议([OWFa 1.0][8])所提供的开放规范,技术社区可以借此机会查看 GraphQL 实现必须符合规范的要求,并帮助制定 GraphQL 的未来。
|
||||
|
||||
虽然该规范对 GraphQL 的语法,什么是有效查询以及 schema 进行了非常具体的说明,但它没有提供有关如何存储数据或 GraphQL 服务器应使用哪种编程语言实现的指导。这在软件领域是非常强大且相对独特。它允许以多种编程语言创建 GraphQL 服务器,并且由于它们符合规范,因此客户端将确切知道它们的工作方式。GraphQL 服务器已经有多种语言实现,人们不仅可以期望像 JavaScript、Java和 C# 这样的语言,还可以使用Go、Elixir 和 Haskell 等。服务器实现所使用的语言不会成为采用过程的障碍。它不仅存在多种语言实现,而且它们都是开源的。如果没有你选择的语言的实现,那么可以自己实现。
|
||||
|
||||
### 总结
|
||||
|
||||
GraphQL 是开源 API 领域中一个令人兴奋的,相对较新的参与者。它将查询语言和执行引擎与开源规范结合在一起,它定义了 GraphQL 实现的功能。
|
||||
|
||||
GraphQL 已经开始改变公司对构建客户端和 API 应用的看法。通过将 GraphQL 作为技术栈的一部分,前端开发人员可以自由查询所需的数据,而后端开发人员可以将客户端应用需求与后端系统架构分离。通常,公司首先通过在其现有后端服务之上构建一个 GraphQL API “层”来使用 GraphQL。这使客户端应用开始获得寻求的性能和运营效率,同时使后端团队有机会在 GraphQL 层后面进行所需的“幕后”更改(如果有)。通常,这些更改将针对优化,这些优化将帮助确保使用 GraphQL 的应用可以尽可能高效地运行。由于 GraphQL 提供了抽象,因此系统团队可以进行更改的同时继续在其 GraphQL API 级别上遵守 GraphQL 的“合约”。
|
||||
|
||||
由于 GraphQL 相对较新,因此开发人员仍在寻找新颖而激动人心的方法来利用它构建更好的软件解决方案。GraphQL 将如何改变你构建应用的方式,它不会辜负宣传吗?只有一种方法可以找到答案。去使用 GraphQL 构建一些东西!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/6/what-is-graphql
|
||||
|
||||
作者:[Zach Lendon][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/zachlendon
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/analytics-graphs-charts.png?itok=sersoqbV (Analytics: Charts and Graphs)
|
||||
[2]: https://opensource.com/article/18/2/getting-started-sql
|
||||
[3]: https://www.cubrid.org/blog/understanding-jvm-internals/
|
||||
[4]: https://www.w3.org/TR/xml/
|
||||
[5]: http://graphql.org/
|
||||
[6]: mailto:zach@hydrate.io
|
||||
[7]: https://opensource.com/sites/default/files/pictures/graphql-execution-engine.png (GraphQL execution engine)
|
||||
[8]: http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0---patent-only
|
Loading…
Reference in New Issue
Block a user