mirror of
https://github.com/LCTT/TranslateProject.git
synced 2026-09-04 04:32:49 +08:00
Merge branch 'master' of https://github.com/LCTT/TranslateProject into new
This commit is contained in:
@@ -1,53 +0,0 @@
|
||||
Mastering CI/CD at OpenDev
|
||||
======
|
||||
|
||||

|
||||
After launching in 2017, the [OpenDev Conference][1] is now an annual event. At the inaugural event last September, the conference focus was on edge computing. This year's event, taking place May 22-23, will be focused on Continuous Integration/Continuous Deployment (CI/CD) and will be co-located with the OpenStack Summit in Vancouver.
|
||||
|
||||
|
||||
|
||||
I was invited to participate in the program committee for OpenDev CI/CD based on my background on the CI/CD system for the OpenStack project and my recent move into the container space. Today I frequently talk about CI/CD pipelines using various open source technologies, including [Jenkins][3] [GitLab][2],[Spinnaker][4] , and [Artifactory][5]
|
||||
|
||||
This event is exciting for me because we're bringing two open source infrastructure ideas together into one event. First, we'll be discussing CI/CD tooling that can be used by any organization. To this end, in the [keynotes][6] we'll hear practical talks about open source CI/CD tooling, including a talk about Spinnaker from Boris Renski and one from Jim Blair on [Zuul][7]. The keynotes also will include higher-level talks about the preference for open technologies, especially across communities and inside open source projects themselves. From Fatih Degirmenci and Daniel Farrell we'll hear about sharing continuous delivery practices across communities, and Benjamin Mako Hill will join us to talk about why free software needs free tools.
|
||||
|
||||
Given the relative newness of CI/CD, the rest of the event is a mix of talks, workshops, and collaborative discussions. When selecting from talks and workshops submitted, and coming up with collaborative discussion topics, we wanted to make sure there was a diverse schedule so anyone on the open CI/CD spectrum would find something interesting.
|
||||
|
||||
The talks will be standard conference style, selected to cover key topics like crafting CI/CD pipelines, improving security when practicing DevOps, and more specific solutions like container-based [Aptomi][8] on Kubernetes and doing CI/CD in ETSI NFV environments. Many of these sessions will serve as an introduction to these topics, ideal for those who are new to the CI/CD space or any of these specific technologies.
|
||||
|
||||
The hands-on workshops are longer and will have specific outcomes in mind for attendees. These include "[Anomaly Detection in Continuous Integration Jobs][9]," "[How to Install Zuul and Configure Your First Jobs][10]," and "[Spinnaker 101: Releasing Software with Velocity and Confidence][11]." (Note that space is limited in these workshops, so an RSVP system has been set up. You'll find an RSVP button on the session links provided here.)
|
||||
|
||||
Perhaps what I'm most excited about are the collaborative discussions, and these take up over half of the conference schedule. The topics were chosen by the program committee based on what we've been seeing in our communities. These are "fishbowl"-style sessions, where several people get in a room together to discuss a specific topic around CI/CD.
|
||||
|
||||
The idea for this style of session was taken from developer summits that the Ubuntu community pioneered and the OpenStack community continued. Topics for these collaborative discussions include separate sessions for CI and CD fundamentals, improvements that can be made to encourage cross-community collaboration, driving CI/CD culture in organizations, and why open source CI/CD tooling is so important. Shared documents are used to take notes during these sessions to make sure that as much knowledge shared during the session is retained as possible. It's also common for action items to come from these discussions, so community members can push forward initiatives related to the topic being covered.
|
||||
|
||||
The event concludes with a [Joint Conclusion Session][12], which will be summarizing the key points from the collaborative discussions and identifying work areas that attendees wish to work on in future.
|
||||
|
||||
Registration for this event is included in [OpenStack Summit registration][13], or tickets for this event only can be purchased for $199 onsite at the Vancouver Convention Center. Learn more about tickets and the full agenda on the [OpenDev website][1].
|
||||
|
||||
I hope you'll join us in Vancouver for an exciting two days of learning, collaborating and making progress together on CI/CD.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/5/opendev
|
||||
|
||||
作者:[Elizabeth K.Joseph][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[译者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/pleia2
|
||||
[1]:http://2018.opendevconf.com/
|
||||
[2]:https://about.gitlab.com/
|
||||
[3]:https://jenkins.io/
|
||||
[4]:https://www.spinnaker.io/
|
||||
[5]:https://jfrog.com/artifactory/
|
||||
[6]:http://2018.opendevconf.com/schedule/
|
||||
[7]:https://zuul-ci.org/
|
||||
[8]:http://aptomi.io/
|
||||
[9]:https://www.openstack.org/summit/vancouver-2018/summit-schedule/events/21692/anomaly-detection-in-continuous-integration-jobs
|
||||
[10]:https://www.openstack.org/summit/vancouver-2018/summit-schedule/events/21693/how-to-install-zuul-and-configure-your-first-jobs
|
||||
[11]:https://www.openstack.org/summit/vancouver-2018/summit-schedule/events/21699/spinnaker-101-releasing-software-with-velocity-and-confidence
|
||||
[12]:https://www.openstack.org/summit/vancouver-2018/summit-schedule/events/21831/opendev-cicd-joint-collab-conclusion
|
||||
[13]:https://www.eventbrite.com/e/openstack-summit-may-2018-vancouver-tickets-40845826968?aff=VancouverSummit2018
|
||||
@@ -1,104 +0,0 @@
|
||||
15 command-line aliases to save you time
|
||||
======
|
||||
|
||||

|
||||
|
||||
Linux command-line aliases are great for helping you work more efficiently. Better still, some are included by default in your installed Linux distro.
|
||||
|
||||
This is an example of a command-line alias in Fedora 27:
|
||||
|
||||

|
||||
|
||||
The command `alias` shows the list of existing aliases. Setting an alias is as simple as typing:
|
||||
|
||||
`alias new_name="command"`
|
||||
|
||||
Here are 15 command-line aliases that will save you time:
|
||||
|
||||
1. To install any utility/application:
|
||||
|
||||
`alias install="sudo yum install -y"`
|
||||
|
||||
Here, `sudo` and `-y` are optional as per user’s preferences:
|
||||
|
||||
|
||||
![install alias.png][2]
|
||||
|
||||
2. To update the system:
|
||||
|
||||
`alias update="sudo yum update -y"`
|
||||
|
||||
3. To upgrade the system:
|
||||
|
||||
`alias upgrade="sudo yum upgrade -y"`
|
||||
|
||||
4. To change to the root user:
|
||||
|
||||
`alias root="sudo su -"`
|
||||
|
||||
5. To change to "user," where "user" is set as your username:
|
||||
|
||||
`alias user="su user"`
|
||||
|
||||
6. To display the list of all available ports, their status, and IP:
|
||||
|
||||
`alias myip="ip -br -c a"`
|
||||
|
||||
7. To `ssh` to the server `myserver`:
|
||||
|
||||
`alias myserver="ssh user@my_server_ip”`
|
||||
|
||||
8. To list all processes in the system:
|
||||
|
||||
`alias process="ps -aux"`
|
||||
|
||||
9. To check the status of any system service:
|
||||
|
||||
`alias sstatus="sudo systemctl status"`
|
||||
|
||||
10. To restart any system service:
|
||||
|
||||
`alias srestart="sudo systemctl restart"`
|
||||
|
||||
11. To kill any process by its name:
|
||||
|
||||
`alias kill="sudo pkill"`
|
||||
|
||||
![kill process alias.png][4]
|
||||
|
||||
12. To display the total used and free memory of the system:
|
||||
|
||||
`alias mem="free -h"`
|
||||
|
||||
13. To display the CPU architecture, number of CPUs, threads, etc. of the system:
|
||||
|
||||
`alias cpu="lscpu"`
|
||||
|
||||
14. To display the total disk size of the system:
|
||||
|
||||
`alias disk="df -h"`
|
||||
|
||||
15. To display the current system Linux distro (for CentOS, Fedora, and Red Hat):
|
||||
|
||||
`alias os="cat /etc/redhat-release"`
|
||||
|
||||
![system_details alias.png][6]
|
||||
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/8/time-saving-command-line-aliases
|
||||
|
||||
作者:[Aarchit Modi][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[译者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/architmodi
|
||||
[2]:https://opensource.com/sites/default/files/uploads/install.png (install alias.png)
|
||||
[4]:https://opensource.com/sites/default/files/uploads/kill.png (kill process alias.png)
|
||||
[6]:https://opensource.com/sites/default/files/uploads/system_details.png (system_details alias.png)
|
||||
@@ -0,0 +1,133 @@
|
||||
Translating by Ryze-Borgia
|
||||
|
||||
Linux vs Mac: 7 Reasons Why Linux is a Better Choice than Mac
|
||||
======
|
||||
Recently, we highlighted a few points about [why Linux is better than Windows][1]. Unquestionably, Linux is a superior platform. But, like other operating systems it has its drawbacks as well. For a very particular set of tasks (such as Gaming), Windows OS might prove to be better. And, likewise, for another set of tasks (such as video editing), a Mac-powered system might come in handy. It all trickles down to your preference and what you would like to do with your system. So, in this article, we will highlight a number of reasons why Linux is better than Mac.
|
||||
|
||||
If you’re already using a Mac or planning to get one, we recommend you to thoroughly analyze the reasons and decide whether you want to switch/keep using Linux or continue using Mac.
|
||||
|
||||
### 7 Reasons Why Linux is Better Than Mac
|
||||
|
||||
![Linux vs Mac: Why Linux is a Better Choice][2]
|
||||
|
||||
Both Linux and macOS are Unix-like OS and give access to Unix commands, BASH and other shells. Both of them have fewer applications and games than Windows. But the similarity ends here.
|
||||
|
||||
Graphic designers and video editors swear by macOS whereas Linux is a favorite of developers, sysadmins and devops.
|
||||
|
||||
So the question is should you use Linux over Mac? If yes, why? Let me give you some practical and some ideological reasons why Linux is better than Mac.
|
||||
|
||||
#### 1\. Price
|
||||
|
||||
![Linux vs Mac: Why Linux is a Better Choice][3]
|
||||
|
||||
Let’s suppose, you use the system only to browse stuff, watch movies, download photos, write a document, create a spreadsheet, and other similar stuff. And, in addition to those activities, you want to have a secure operating system.
|
||||
|
||||
In that case, you could choose to spend a couple of hundred bucks for a system to get things done. Or do you think spending more for a MacBook is a good idea? Well, you are the judge.
|
||||
|
||||
So, it really depends on what you prefer. Whether you want to spend on a Mac-powered system or get a budget laptop/PC and install any Linux distro for free. Personally, I’ll be happy with a Linux system except for editing videos and music production. In that case, Final Cut Pro (for video editing) and Logic Pro X (for music production) will be my preference.
|
||||
|
||||
#### 2\. Hardware Choices
|
||||
|
||||
![Linux vs Mac: Why Linux is a Better Choice][4]
|
||||
|
||||
Linux is free. You can install it on computers with any configuration. No matter how powerful/old your system is, Linux will work. [Even if you have an 8-year old PC laying around, you can have Linux installed and expect it to run smoothly by selecting the right distro][5].
|
||||
|
||||
But, Mac is as an Apple-exclusive. If you want to assemble a PC or get a budget laptop (with DOS) and expect to install Mac OS, it’s almost impossible. Mac comes baked in with the system Apple manufactures.
|
||||
|
||||
There are [ways to install macOS on non Apple devices][6]. However, the kind of expertise and troubles it requires, it makes you question whether it’s worth the effort.
|
||||
|
||||
You will have a wide range of hardware choices when you go with Linux but a minimal set of configurations when it comes to Mac OS.
|
||||
|
||||
#### 3\. Security
|
||||
|
||||
![Linux vs Mac: Why Linux is a Better Choice][7]
|
||||
|
||||
A lot of people are all praises for iOS and Mac for being a secure platform. Well, yes, it is secure in a way (maybe more secure than Windows OS), but probably not as secure as Linux.
|
||||
|
||||
I am not bluffing. There are malware and adware targeting macOS and the [number is growing every day][8]. I have seen not-so-techie users struggling with their slow mac. A quick investigation revealed that a [browser hijacking malware][9] was the culprit.
|
||||
|
||||
There are no 100% secure operating systems and Linux is not an exception. There are vulnerabilities in the Linux world as well but they are duly patched by the timely updates provided by Linux distributions.
|
||||
|
||||
Thankfully, we don’t have auto-running viruses or browser hijacking malwares in Linux world so far. And that’s one more reason why you should use Linux instead of a Mac.
|
||||
|
||||
#### 4\. Customization & Flexibility
|
||||
|
||||
![Linux vs Mac: Why Linux is a Better Choice][10]
|
||||
|
||||
You don’t like something? Customize it or remove it. End of the story.
|
||||
|
||||
For example, if you do not like the [Gnome desktop environment][11] on Ubuntu 18.04.1, you might as well change it to [KDE Plasma][11]. You can also try some of the [Gnome extensions][12] to enhance your desktop experience. You won’t find this level of freedom and customization on Mac OS.
|
||||
|
||||
Besides, you can even modify the source code of your OS to add/remove something (which requires necessary technical knowledge) and create your own custom OS. Can you do that on Mac OS?
|
||||
|
||||
Moreover, you get an array of Linux distributions to choose from as per your needs. For instance, if you need to mimic the workflow on Mac OS, [Elementary OS][13] would help. Do you want to have a lightweight Linux distribution installed on your old PC? We’ve got you covered in our list of [lightweight Linux distros][5]. Mac OS lacks this kind of flexibility.
|
||||
|
||||
#### 5\. Using Linux helps your professional career [For IT/Tech students]
|
||||
|
||||
![Linux vs Mac: Why Linux is a Better Choice][14]
|
||||
|
||||
This is kind of controversial and applicable to students and job seekers in the IT field. Using Linux doesn’t make you a super-intelligent being and could possibly get you any IT related job.
|
||||
|
||||
However, as you start using Linux and exploring it, you gain experience. As a techie, sooner or later you dive into the terminal, learning your way to move around the file system, installing applications via command line. You won’t even realize that you have learned the skills that newcomers in IT companies get trained on.
|
||||
|
||||
In addition to that, Linux has enormous scope in the job market. There are so many Linux related technologies (Cloud, Kubernetes, Sysadmin etc.) you can learn, earn certifications and get a nice paying job. And to learn these, you have to use Linux.
|
||||
|
||||
#### 6\. Reliability
|
||||
|
||||
![Linux vs Mac: Why Linux is a Better Choice][15]
|
||||
|
||||
Ever wondered why Linux is the best OS to run on any server? Because it is more reliable!
|
||||
|
||||
But, why is that? Why is Linux more reliable than Mac OS?
|
||||
|
||||
The answer is simple – more control to the user while providing better security. Mac OS does not provide you with the full control of its platform. It does that to make things easier for you simultaneously enhancing your user experience. With Linux, you can do whatever you want – which may result in poor user experience (for some) – but it does make it more reliable.
|
||||
|
||||
#### 7\. Open Source
|
||||
|
||||
![Linux vs Mac: Why Linux is a Better Choice][16]
|
||||
|
||||
Open Source is something not everyone cares about. But to me, the most important aspect of Linux being a superior choice is its Open Source nature. And, most of the points discussed below are the direct advantages of an Open Source software.
|
||||
|
||||
To briefly explain, you get to see/modify the source code yourself if it is an open source software. But, for Mac, Apple gets an exclusive control. Even if you have the required technical knowledge, you will not be able to independently take a look at the source code of Mac OS.
|
||||
|
||||
In other words, a Mac-powered system enables you to get a car for yourself but the downside is you cannot open up the hood to see what’s inside. That’s bad!
|
||||
|
||||
If you want to dive in deeper to know about the benefits of an open source software, you should go through [Ben Balter’s article][17] on OpenSource.com.
|
||||
|
||||
### Wrapping Up
|
||||
|
||||
Now that you’ve known why Linux is better than Mac OS. What do you think about it? Are these reasons enough for you to choose Linux over Mac OS? If not, then what do you prefer and why?
|
||||
|
||||
Let us know your thoughts in the comments below.
|
||||
|
||||
Note: The artwork here is based on Club Penguins.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/linux-vs-mac/
|
||||
|
||||
作者:[Ankush Das][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[译者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/
|
||||
[1]: https://itsfoss.com/linux-better-than-windows/
|
||||
[2]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/Linux-vs-mac-featured.png
|
||||
[3]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/linux-vs-mac-1.jpeg
|
||||
[4]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/linux-vs-mac-4.jpeg
|
||||
[5]: https://itsfoss.com/lightweight-linux-beginners/
|
||||
[6]: https://hackintosh.com/
|
||||
[7]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/linux-vs-mac-2.jpeg
|
||||
[8]: https://www.computerworld.com/article/3262225/apple-mac/warning-as-mac-malware-exploits-climb-270.html
|
||||
[9]: https://www.imore.com/how-to-remove-browser-hijack
|
||||
[10]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/linux-vs-mac-3.jpeg
|
||||
[11]: https://www.gnome.org/
|
||||
[12]: https://itsfoss.com/best-gnome-extensions/
|
||||
[13]: https://elementary.io/
|
||||
[14]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/linux-vs-mac-5.jpeg
|
||||
[15]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/linux-vs-mac-6.jpeg
|
||||
[16]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/linux-vs-mac-7.jpeg
|
||||
[17]: https://opensource.com/life/15/12/why-open-source
|
||||
@@ -1,3 +1,4 @@
|
||||
LuMing translating
|
||||
How To Configure SSH Key-based Authentication In Linux
|
||||
======
|
||||
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
7 Python libraries for more maintainable code
|
||||
======
|
||||
|
||||

|
||||
|
||||
> Readability counts.
|
||||
> — [The Zen of Python][1], Tim Peters
|
||||
|
||||
It's easy to let readability and coding standards fall by the wayside when a software project moves into "maintenance mode." (It's also easy to never establish those standards in the first place.) But maintaining consistent style and testing standards across a codebase is an important part of decreasing the maintenance burden, ensuring that future developers are able to quickly grok what's happening in a new-to-them project and safeguarding the health of the app over time.
|
||||
|
||||
### Check your code style
|
||||
|
||||
A great way to protect the future maintainability of a project is to use external libraries to check your code health for you. These are a few of our favorite libraries for [linting code][2] (checking for PEP 8 and other style errors), enforcing a consistent style, and ensuring acceptable test coverage as a project reaches maturity.
|
||||
|
||||
[PEP 8][3] is the Python code style guide, and it sets out rules for things like line length, indentation, multi-line expressions, and naming conventions. Your team might also have your own style rules that differ slightly from PEP 8. The goal of any code style guide is to enforce consistent standards across a codebase to make it more readable, and thus more maintainable. Here are three libraries to help prettify your code.
|
||||
|
||||
#### 1\. Pylint
|
||||
|
||||
[Pylint][4] is a library that checks for PEP 8 style violations and common errors. It integrates well with several popular [editors and IDEs][5] and can also be run from the command line.
|
||||
|
||||
To install, run `pip install pylint`.
|
||||
|
||||
To use Pylint from the command line, run `pylint [options] path/to/dir` or `pylint [options] path/to/module.py`. Pylint will output warnings about style violations and other errors to the console.
|
||||
|
||||
You can customize what errors Pylint checks for with a [configuration file][6] called `pylintrc`.
|
||||
|
||||
#### 2\. Flake8
|
||||
|
||||
[Flake8][7] is a "Python tool that glues together PEP8, Pyflakes (similar to Pylint), McCabe (code complexity checker), and third-party plugins to check the style and quality of some Python code."
|
||||
|
||||
To use Flake8, run `pip install flake8`. Then run `flake8 [options] path/to/dir` or `flake8 [options] path/to/module.py` to see its errors and warnings.
|
||||
|
||||
Like Pylint, Flake8 permits some customization for what it checks for with a [configuration file][8]. It has very clear docs, including some on useful [commit hooks][9] to automatically check your code as part of your development workflow.
|
||||
|
||||
Flake8 integrates with popular editors and IDEs, but those instructions generally aren't found in the docs. To integrate Flake8 with your favorite editor or IDE, search online for plugins (for example, [Flake8 plugin for Sublime Text][10]).
|
||||
|
||||
#### 3\. Isort
|
||||
|
||||
[Isort][11] is a library that sorts your imports alphabetically and breaks them up into [appropriate sections][12] (e.g., standard library imports, third-party library imports, imports from your own project, etc.). This increases readability and makes it easier to locate imports if you have a lot of them in your module.
|
||||
|
||||
Install isort with `pip install isort`, and run it with `isort path/to/module.py`. More configuration options are in the [documentation][13]. For example, you can [configure][14] how isort handles multi-line imports from one library in an `.isort.cfg` file.
|
||||
|
||||
Like Flake8 and Pylint, isort also provides plugins that integrate it with popular [editors and IDEs][15].
|
||||
|
||||
### Outsource your code style
|
||||
|
||||
Remembering to run linters manually from the command line for each file you change is a pain, and you might not like how a particular plugin behaves with your IDE. Also, your colleagues might prefer different linters or might not have plugins for their favorite editors, or you might be less meticulous about always running the linter and correcting the warnings. Over time, the codebase you all share will get messy and harder to read.
|
||||
|
||||
A great solution is to use a library that automatically reformats your code into something that passes PEP 8 for you. The three libraries we recommend all have different levels of customization and different defaults for how they format code. Some of these are more opinionated than others, so like with Pylint and Flake8, you'll want to test these out to see which offers the customizations you can't live without… and the unchangeable defaults you can live with.
|
||||
|
||||
#### 4\. Autopep8
|
||||
|
||||
[Autopep8][16] automatically formats the code in the module you specify. It will re-indent lines, fix indentation, remove extraneous whitespace, and refactor common comparison mistakes (like with booleans and `None`). See a full [list of corrections][17] in the docs.
|
||||
|
||||
To install, run `pip install --upgrade autopep8`. To reformat code in place, run `autopep8 --in-place --aggressive --aggressive <filename>`. The `aggressive` flags (and the number of them) indicate how much control you want to give autopep8 over your code style. Read more about [aggressive][18] options.
|
||||
|
||||
#### 5\. Yapf
|
||||
|
||||
[Yapf][19] is yet another option for reformatting code that comes with its own list of [configuration options][20]. It differs from autopep8 in that it doesn't just address PEP 8 violations. It also reformats code that doesn't violate PEP 8 specifically but isn't styled consistently or could be formatted better for readability.
|
||||
|
||||
To install, run `pip install yapf`. To reformat code, run, `yapf [options] path/to/dir` or `yapf [options] path/to/module.py`. There is also a full list of [customization options][20].
|
||||
|
||||
#### 6\. Black
|
||||
|
||||
[Black][21] is the new kid on the block for linters that reformat code in place. It's similar to autopep8 and Yapf, but way more opinionated. It has very few options for customization, which is kind of the point. The idea is that you shouldn't have to make decisions about code style; the only decision to make is to let Black decide for you. You can read about [limited customization options][22] and instructions on [storing them in a configuration file][23].
|
||||
|
||||
Black requires Python 3.6+ but can format Python 2 code. To use, run `pip install black`. To prettify your code, run: `black path/to/dir` or `black path/to/module.py`.
|
||||
|
||||
### Check your test coverage
|
||||
|
||||
You're writing tests, right? Then you will want to make sure new code committed to your codebase is tested and doesn't drop your overall amount of test coverage. While percentage of test coverage is not the only metric you should use to measure the effectiveness and sufficiency of your tests, it is one way to ensure basic testing standards are being followed in your project. For measuring test coverage, we have one recommendation: Coverage.
|
||||
|
||||
#### 7\. Coverage
|
||||
|
||||
[Coverage][24] has several options for the way it reports your test coverage to you, including outputting results to the console or to an HTML page and indicating which line numbers are missing test coverage. You can set up a [configuration file][25] to customize what Coverage checks for and make it easier to run.
|
||||
|
||||
To install, run `pip install coverage`. To run a program and see its output, run `coverage run [path/to/module.py] [args]`, and you will see your program's output. To see a report of which lines of code are missing coverage, run `coverage report -m`.
|
||||
|
||||
Continuous integration (CI) is a series of processes you can run to automatically check for linter errors and test coverage minimums before you merge and deploy code. There are lots of free or paid tools to automate this process, and a thorough walkthrough is beyond the scope of this article. But because setting up a CI process is an important step in removing blocks to more readable and maintainable code, you should investigate continuous integration tools in general; check out [Travis CI][26] and [Jenkins][27] in particular.
|
||||
|
||||
These are only a handful of the libraries available to check your Python code. If you have a favorite that's not on this list, please share it in the comments.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/7/7-python-libraries-more-maintainable-code
|
||||
|
||||
作者:[Jeff Triplett][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[译者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/laceynwilliams
|
||||
[1]:https://www.python.org/dev/peps/pep-0020/
|
||||
[2]:https://en.wikipedia.org/wiki/Lint_(software)
|
||||
[3]:https://www.python.org/dev/peps/pep-0008/
|
||||
[4]:https://www.pylint.org/
|
||||
[5]:https://pylint.readthedocs.io/en/latest/user_guide/ide-integration.html
|
||||
[6]:https://pylint.readthedocs.io/en/latest/user_guide/run.html#command-line-options
|
||||
[7]:http://flake8.pycqa.org/en/latest/
|
||||
[8]:http://flake8.pycqa.org/en/latest/user/configuration.html#configuration-locations
|
||||
[9]:http://flake8.pycqa.org/en/latest/user/using-hooks.html
|
||||
[10]:https://github.com/SublimeLinter/SublimeLinter-flake8
|
||||
[11]:https://github.com/timothycrosley/isort
|
||||
[12]:https://github.com/timothycrosley/isort#how-does-isort-work
|
||||
[13]:https://github.com/timothycrosley/isort#using-isort
|
||||
[14]:https://github.com/timothycrosley/isort#configuring-isort
|
||||
[15]:https://github.com/timothycrosley/isort/wiki/isort-Plugins
|
||||
[16]:https://github.com/hhatto/autopep8
|
||||
[17]:https://github.com/hhatto/autopep8#id4
|
||||
[18]:https://github.com/hhatto/autopep8#id5
|
||||
[19]:https://github.com/google/yapf
|
||||
[20]:https://github.com/google/yapf#usage
|
||||
[21]:https://github.com/ambv/black
|
||||
[22]:https://github.com/ambv/black#command-line-options
|
||||
[23]:https://github.com/ambv/black#pyprojecttoml
|
||||
[24]:https://coverage.readthedocs.io/en/latest/
|
||||
[25]:https://coverage.readthedocs.io/en/latest/config.html
|
||||
[26]:https://travis-ci.org/
|
||||
[27]:https://jenkins.io/
|
||||
@@ -1,159 +0,0 @@
|
||||
Installing Android on VirtualBox
|
||||
======
|
||||
If you are developing mobile apps Android can be a bit of a hassle. While iOS comes with its niceties, provided you are using macOS, Android comes with just Android Studio which is designed to support more than a few Android version, including wearables.
|
||||
|
||||
Needless to say, all the binaries, SDKs, frameworks and debuggers are going to pollute your filesystem with lots and lots of files, logs and other miscellaneous objects. An efficient work around for this is installing Android on your VirtualBox which takes away one of the sluggiest aspect of Android development — The device emulator. You can use this VM to run your test application or just fiddle with Android’s internals. So without further ado let’s set on up!
|
||||
|
||||
### Getting Started
|
||||
|
||||
To get started we will need to have VirtualBox installed on our system, you can get a copy for Windows, macOS or any major distro of Linux [here][1]. Next you would need a copy of Android meant to run on x86 hardware, because that’s what VirtualBox is going to offer to a Virtual Machine an x86 or an x86_64 (a.k.a AMD64) platform to run.
|
||||
|
||||
While most Android devices run on ARM, we can take help of the project [Android on x86][2]. These fine folks have ported Android to run on x86 hardware (both real and virtual) and we can get a copy of the latest release candidate (Android 7.1) for our purposes. You may prefer using a more stable release but in that case Android 6.0 is about as latest as you can get, at the time of this writing.
|
||||
|
||||
#### Creating VM
|
||||
|
||||
Open VirtualBox and click on “New” (top-left corner) and in the Create Virtual Machine window select the type to be Linux and version Linux 2.6 / 3.x /4.x (64-bit) or (32-bit) depending upon whether the ISO you downloaded was x86_64 or x86 respectively.
|
||||
|
||||
RAM size could be anywhere from 2 GB to as much as your system resources can allow. Although if you want to emulate real world devices you should allocate upto 6GB for memory and 32GB for disk size which are typical in Android devices.
|
||||
|
||||
![][3]
|
||||
|
||||
![][4]
|
||||
|
||||
Upon creation, you might want to tweak a few additional settings, add in an additional processor core and improve display memory for starters. To do this, right-click on the VM and open up settings. In the Settings → System → Processor section you can allocate a few more cores if your desktop can pull it off.
|
||||
|
||||
![][5]
|
||||
|
||||
And in Settings → Display → Video Memory you can allocate a decent chunk of memory and enable 3D acceleration for a more responsive experience.
|
||||
|
||||
![][6]
|
||||
|
||||
Now we are ready to boot the VM.
|
||||
|
||||
#### Installing Android
|
||||
|
||||
Starting the VM for the first time, VirtualBox will insist you to supply it with a bootable media. Select the Android iso that you previously downloaded to boot the machine of with.
|
||||
|
||||
![][7]
|
||||
|
||||
Next, select the Installation option if you wish to install Android on the VM for a long term use, otherwise feel free to log into the live media and play around with the environment.
|
||||
|
||||
![][8]
|
||||
|
||||
Hit <Enter>.
|
||||
|
||||
##### Partitioning the Drive
|
||||
|
||||
Partitioning is done using a textual interface, which means we don’t get the niceties of a GUI and we will have to use the follow careful at what is being shown on the screen. For example, in the first screen when no partition has been created and just a raw (virtual) disk is detected you will see the following.
|
||||
|
||||
![][9]
|
||||
|
||||
The red lettered C and D indicates that if you hit the key C you can create or modify partitions and D will detect additional devices. You can press D and the live media will detect the disks attached, but that is optional since it did a check during the boot.
|
||||
|
||||
Let’s hit C and create partitions in the virtual disk. The offical page recommends against using GPT so we will not use that scheme. Select No using the arrow keys and hit <Enter>.
|
||||
|
||||
![][10]
|
||||
|
||||
And now you will be ushered into the fdisk utility.
|
||||
|
||||
![][11]
|
||||
|
||||
We will create just a single giant partition so as to keep things simple. Using arrow keys navigate to the New option and hit <Enter>. Select primary as the type of partition, and hit <Enter> to confirm
|
||||
|
||||
![][12]
|
||||
|
||||
The maximum size will already be selected for you, hit <Enter> to confirm that.
|
||||
|
||||
![][13]
|
||||
|
||||
This partition is where Android OS will reside, so of course we want it to be bootable. So select Bootable and hit enter (Boot will appear in the flags section in the table above) and then you can navigate to the Write section and hit <Enter> to write the changes to the partitioning table.
|
||||
|
||||
![][14]
|
||||
|
||||
Then you can Quit the partitioning utility and move on with the installation.
|
||||
|
||||
![][15]
|
||||
|
||||
##### Formatting with Ext4 and installing Android
|
||||
|
||||
A new partition will come in the Choose Partition menu where we were before we down the partitioning digression. Let’s select this partition and hit OK.
|
||||
|
||||
![][16]
|
||||
|
||||
Select ext4 as the de facto file system in the next menu. Confirm the changes in the next window by selecting **Yes** and the formatting will begin. When asked, say **Yes** to the GRUB boot loader installation. Similarly, say **Yes** to allowing read-write operations on the /system directory. Now the installation will begin.
|
||||
|
||||
Once it is installed, you can safely reboot the system when prompted to reboot. You may have to power down the machine before the next reboot happens, go to Settings → Storage and remove the android iso if it is still attached to the VM.
|
||||
|
||||
![][17]
|
||||
|
||||
Remove the media and save the changes, before starting up the VM.
|
||||
|
||||
##### Running Android
|
||||
|
||||
In the GRUB menu you will get options for running the OS in debug mode or the normal way. Let’s take a tour of Android in a VM using the default option, as shown below:
|
||||
|
||||
![][18]
|
||||
|
||||
And if everything works fine, you will see this:
|
||||
|
||||
![][19]
|
||||
|
||||
Now Android uses touch screen as an interface instead of a mouse, as far as its normal use is concerned. While the x86 port does come with a mouse point-and-click support you may have to use arrow keys a lot in the beginning.
|
||||
|
||||
![][20]
|
||||
|
||||
Navigate to let’s go, and hit enter, if you are using arrow keys and then select Setup as New.
|
||||
|
||||
![][21]
|
||||
|
||||
It will check for updates and device info, before asking you to sign in using a Google account. You can skip this if you want and move on to setting up Data and Time and give your username to the device after that.
|
||||
|
||||
A few other options would be presented, similar to the options you see when setting up a new Android device. Select appropriate options for privacy, updates, etc and of course Terms of Service, which we might have to Agree to.
|
||||
|
||||
![][22]
|
||||
|
||||
After this, it may ask you to add another email account or set up “On-body detection” since it is a VM, neither of the options are of much use to us and we can click on “All Set”
|
||||
|
||||
It would ask you to select Home App after that, which is upto you to decide, as it is a matter of Preference and you will finally be in a virtualized Android system.
|
||||
|
||||
![][23]
|
||||
|
||||
You may benefit greatly from a touch screen laptop if you desire to do some intensive testing on this VM, since that would emulate a real world use case much closely.
|
||||
|
||||
Hope you have found this tutorial useful in case, you have any other similar request for us to write about, please feel free to reach out to us.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://linuxhint.com/install_android_virtualbox/
|
||||
|
||||
作者:[Ranvir Singh][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://linuxhint.com/author/sranvir155/
|
||||
[1]:https://www.virtualbox.org/wiki/Downloads
|
||||
[2]:http://www.android-x86.org/
|
||||
[3]:https://linuxhint.com/wp-content/uploads/2018/08/a.png
|
||||
[4]:https://linuxhint.com/wp-content/uploads/2018/08/a1.png
|
||||
[5]:https://linuxhint.com/wp-content/uploads/2018/08/a2.png
|
||||
[6]:https://linuxhint.com/wp-content/uploads/2018/08/a3.png
|
||||
[7]:https://linuxhint.com/wp-content/uploads/2018/08/a4.png
|
||||
[8]:https://linuxhint.com/wp-content/uploads/2018/08/a5.png
|
||||
[9]:https://linuxhint.com/wp-content/uploads/2018/08/a6.png
|
||||
[10]:https://linuxhint.com/wp-content/uploads/2018/08/a7.png
|
||||
[11]:https://linuxhint.com/wp-content/uploads/2018/08/a8.png
|
||||
[12]:https://linuxhint.com/wp-content/uploads/2018/08/a9.png
|
||||
[13]:https://linuxhint.com/wp-content/uploads/2018/08/a10.png
|
||||
[14]:https://linuxhint.com/wp-content/uploads/2018/08/a11.png
|
||||
[15]:https://linuxhint.com/wp-content/uploads/2018/08/a12.png
|
||||
[16]:https://linuxhint.com/wp-content/uploads/2018/08/a13.png
|
||||
[17]:https://linuxhint.com/wp-content/uploads/2018/08/a14.png
|
||||
[18]:https://linuxhint.com/wp-content/uploads/2018/08/a16.png
|
||||
[19]:https://linuxhint.com/wp-content/uploads/2018/08/a17.png
|
||||
[20]:https://linuxhint.com/wp-content/uploads/2018/08/a18.png
|
||||
[21]:https://linuxhint.com/wp-content/uploads/2018/08/a19.png
|
||||
[22]:https://linuxhint.com/wp-content/uploads/2018/08/a20.png
|
||||
[23]:https://linuxhint.com/wp-content/uploads/2018/08/a21.png
|
||||
@@ -1,3 +1,5 @@
|
||||
translated by hopefully2333
|
||||
|
||||
Steam Makes it Easier to Play Windows Games on Linux
|
||||
======
|
||||
![Steam Wallpaper][1]
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
Translating by z52527
|
||||
|
||||
|
||||
A Cat Clone With Syntax Highlighting And Git Integration
|
||||
======
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
HankChow translating
|
||||
|
||||
5 Ways to Take Screenshot in Linux [GUI and Terminal]
|
||||
======
|
||||
Here are several ways you can take screenshots and edit the screenshots by adding text, arrows etc. Instructions and mentioned screenshot tools are valid for Ubuntu and other major Linux distributions.
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
KevinSJ 翻译中
|
||||
6 open source tools for writing a book
|
||||
======
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
translating---geekpi
|
||||
|
||||
Autotrash – A CLI Tool To Automatically Purge Old Trashed Files
|
||||
======
|
||||
|
||||
|
||||
@@ -1,114 +0,0 @@
|
||||
What is ZFS? Why People Use ZFS? [Explained for Beginners]
|
||||
======
|
||||
Today, we will take a look at ZFS, an advanced file system. We will discuss where it came from, what it is, and why it is so popular among techies and enterprise.
|
||||
|
||||
Even though I’m from the US, I prefer to pronounce it ZedFS instead of ZeeFS because it sounds cooler. You are free to pronounce it however you like.
|
||||
|
||||
Note: You will see ZFS repeated many times in the article. When I talk about feature and installation, I’m talking about OpenZFS. ZFS (developed by Oracle) and OpenZFS have followed different paths since Oracle shutdown OpenSolaris. (More on that later.)
|
||||
|
||||
### History of ZFS
|
||||
|
||||
The Z File System (ZFS) was created by [Matthew Ahrens and Jeff Bonwick][1] in 2001. ZFS was designed to be a next generation file system for [Sun Microsystems’][2] [OpenSolaris][3]. In 2008, ZFS was ported to FreeBSD. The same year a project was started to port [ZFS to Linux][4]. However, since ZFS is licensed under the [Common Development and Distribution License][5], which is incompatible with the [GNU General Public License][6], it cannot be included in the Linux kernel. To get around this problem, most Linux distros offer methods to install ZFS.
|
||||
|
||||
Shortly after Oracle purchased Sun Microsystems, OpenSolaris became close-source. All further development of ZFS became closed source, as well. Many of the developers of ZFS where unhappy about this turn of events. [Two-thirds of the core ZFS devlopers][1], including Ahrens and Bonwick, left Oracle due to this decision. They joined other companies and created the [OpenZFS project][7] in September of 2013. The project has spearheaded the open-source development of ZFS.
|
||||
|
||||
Let’s go back to the license issue mentioned above. Since the OpenZFS project is separate from Oracle, some probably wonder why they don’t change the license to something that is compatible with the GPL so it can be included in the Linux kernel. According to the [OpenZFS website][8], changing the license would involve contacting anyone who contributed code to the current OpenZFS implementation (including the initial, common ZFS code till OpenSolaris) and get their permission to change the license. Since this job is near impossible (because some contributors may be dead or hard to find), they have decided to keep the license they have.
|
||||
|
||||
### What is ZFS? What are its features?
|
||||
|
||||
![ZFS filesystem][9]
|
||||
|
||||
As I said before, ZFS is an advanced file system. As such, it has some interesting [features][10]. Such as:
|
||||
|
||||
* Pooled storage
|
||||
* Copy-on-write
|
||||
* Snapshots
|
||||
* Data integrity verification and automatic repair
|
||||
* RAID-Z
|
||||
* Maximum 16 Exabyte file size
|
||||
* Maximum 256 Quadrillion Zettabytes storage
|
||||
|
||||
|
||||
|
||||
Let’s break down a couple of those features.
|
||||
|
||||
#### Pooled Storage
|
||||
|
||||
Unlike most files systems, ZFS combines the features of a file system and a volume manager. This means that unlike other file systems, ZFS can create a file system that spans across a series of drives or a pool. Not only that but you can add storage to a pool by adding another drive. ZFS will handle [partitioning and formatting][11].
|
||||
|
||||
![Pooled storage in ZFS][12]Pooled storage in ZFS
|
||||
|
||||
#### Copy-on-write
|
||||
|
||||
[Copy-on-write][13] is another interesting (and cool) features. On most files system, when data is overwritten, it is lost forever. On ZFS, the new information is written to a different block. Once the write is complete, the file systems metadata is updated to point to the new info. This ensures that if the system crashes (or something else happens) while the write is taking place, the old data will be preserved. It also means that the system does not need to run [fsck][14] after a system crash.
|
||||
|
||||
#### Snapshots
|
||||
|
||||
Copy-on-write leads into another ZFS feature: snapshots. ZFS uses snapshots to track changes in the file system. “[The snapshot][13] contains the original version of the file system, and the live filesystem contains any changes made since the snapshot was taken. No additional space is used. As new data is written to the live file system, new blocks are allocated to store this data.” It a file is deleted, the snapshot reference is removed, as well. So, snapshots are mainly designed to track changes to files, but not the addition and creation of files.
|
||||
|
||||
Snapshots can be mounted as read-only to recover a past version of a file. It is also possible to rollback the live system to a previous snapshot. All changes made since the snapshot will be lost.
|
||||
|
||||
#### Data integrity verification and automatic repair
|
||||
|
||||
Whenever new data is written to ZFS, it creates a checksum for that data. When that data is read, the checksum is verified. If the checksum does not match, then ZFS knows that an error has been detected. ZFS will then automatically attempt to correct the error.
|
||||
|
||||
#### RAID-Z
|
||||
|
||||
ZFS can handle RAID without requiring any extra software or hardware. Unsurprisingly, ZFS has its own implementation of RAID: RAID-Z. RAID-Z is actually a variation of RAID-5. However, it is designed to overcome the RAID-5 write hole error, “in which the data and parity information become inconsistent after an unexpected restart”. To use the basic [level of RAID-Z][15] (RAID-Z1) you need at least two disks for storage and one for [parity][16]. RAID-Z2 required at least two storage drives and two drive for parity. RAID-Z3 requires at least two storage drives and three drive for parity. When drives are added to the RAID-Z pools, they have to be added in multiples of two.
|
||||
|
||||
#### Huge Storage potential
|
||||
|
||||
When ZFS was created, it was designed to be [the last word in file systems][17]. At a time when most file systems where 64-bit, the ZFS creators decided to jump right to 128-bit to future proof it. This means that ZFS “offers 16 billion billion times the capacity of 32- or 64-bit systems”. In fact, Jeff Bonwick (one of the creators) said [that powering][18] a “fully populating a 128-bit storage pool would, literally, require more energy than boiling the oceans.”
|
||||
|
||||
### How to Install ZFS?
|
||||
|
||||
If you want to use ZFS out of the box, it would require installing either [FreeBSD][19] or an [operating system using the illumos kernel][20]. [illumos][21] is a fork of the OpenSolaris kernel.
|
||||
|
||||
In fact, support for [ZFS is one of the main reasons why some experienced Linux users opt for BSD][22].
|
||||
|
||||
If you want to try ZFS on Linux, you can only use it at your storage file system. As a far as I know, no Linux distro give you the option to install ZFS on your root out of the box. If you are interested in trying ZFS on Linux, the [ZFS on Linux project][4] has a number of tutorials on how to do that.
|
||||
|
||||
### Caveat
|
||||
|
||||
This article has sung the benefits of ZFS. Now let me tell you a quick problem with ZFS. Using RAID-Z [can be expensive][23] because of the number of drives you need to purchase to add storage space.
|
||||
|
||||
Have you every ZFS? What was your experience like? 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][24].
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/what-is-zfs/
|
||||
|
||||
作者:[John Paul][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[译者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/
|
||||
[1]: https://wiki.gentoo.org/wiki/ZFS
|
||||
[2]: http://en.wikipedia.org/wiki/Sun_Microsystems
|
||||
[3]: http://en.wikipedia.org/wiki/Opensolaris
|
||||
[4]: https://zfsonlinux.org/
|
||||
[5]: https://en.wikipedia.org/wiki/Common_Development_and_Distribution_License
|
||||
[6]: https://en.wikipedia.org/wiki/GNU_General_Public_License
|
||||
[7]: http://www.open-zfs.org/wiki/Main_Page
|
||||
[8]: http://www.open-zfs.org/wiki/FAQ#Do_you_plan_to_release_OpenZFS_under_a_license_other_than_the_CDDL.3F
|
||||
[9]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/what-is-zfs.png
|
||||
[10]: https://wiki.archlinux.org/index.php/ZFS
|
||||
[11]: https://www.howtogeek.com/175159/an-introduction-to-the-z-file-system-zfs-for-linux/
|
||||
[12]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/zfs-overview.png
|
||||
[13]: https://www.freebsd.org/doc/handbook/zfs-term.html
|
||||
[14]: https://en.wikipedia.org/wiki/Fsck
|
||||
[15]: https://wiki.archlinux.org/index.php/ZFS/Virtual_disks#Creating_and_Destroying_Zpools
|
||||
[16]: https://www.pcmag.com/encyclopedia/term/60364/raid-parity
|
||||
[17]: https://web.archive.org/web/20060428092023/http://www.sun.com/2004-0914/feature/
|
||||
[18]: https://blogs.oracle.com/bonwick/128-bit-storage:-are-you-high
|
||||
[19]: https://www.freebsd.org/
|
||||
[20]: https://wiki.illumos.org/display/illumos/Distributions
|
||||
[21]: https://wiki.illumos.org/display/illumos/illumos+Home
|
||||
[22]: https://itsfoss.com/why-use-bsd/
|
||||
[23]: http://louwrentius.com/the-hidden-cost-of-using-zfs-for-your-home-nas.html
|
||||
[24]: http://reddit.com/r/linuxusersgroup
|
||||
@@ -1,3 +1,5 @@
|
||||
heguangzhi Translating
|
||||
|
||||
3 open source log aggregation tools
|
||||
======
|
||||
Log aggregation systems can help with troubleshooting and other tasks. Here are three top options.
|
||||
|
||||
@@ -1,109 +0,0 @@
|
||||
Randomize your MAC address using NetworkManager
|
||||
======
|
||||
|
||||

|
||||
|
||||
Today, users run their notebooks everywhere. To stay connected you use the local wifi to access the internet, on the couch at home or in a little cafe with your favorite coffee. But modern hotspots track you based on your MAC address, [an address that is unique per network card][1], and in this way identifies your device. Read more below about how to avoid this kind of tracking.
|
||||
|
||||
Why is this a problem? Many people use the word “privacy” to talk about this issue. But the concern is not about someone accessing the private contents of your laptop (that’s a separate issue). Instead, it’s about legibility — in simple terms, the ability to be easily counted and tracked. You can and should [read more about legibility][2]. But the bottom line is legibility gives the tracker power over the tracked. For instance, timed WiFi leases at the airport can only be enforced when you’re legible.
|
||||
|
||||
Since a fixed MAC address for your laptop is so legible (easily tracked), you should change it often. A random address is a good choice. Since MAC-addresses are only used within a local network, a random MAC-address is unlikely to cause a [collision.][3]
|
||||
|
||||
### Configuring NetworkManager
|
||||
|
||||
To apply randomized MAC-addresses by default to all WiFi connections, create the following file /etc/NetworkManager/conf.d/00-macrandomize.conf :
|
||||
|
||||
```
|
||||
[device]
|
||||
wifi.scan-rand-mac-address=yes
|
||||
|
||||
[connection]
|
||||
wifi.cloned-mac-address=stable
|
||||
ethernet.cloned-mac-address=stable
|
||||
connection.stable-id=${CONNECTION}/${BOOT}
|
||||
|
||||
```
|
||||
|
||||
Afterward, restart NetworkManager:
|
||||
|
||||
```
|
||||
systemctl restart NetworkManager
|
||||
|
||||
```
|
||||
|
||||
Set cloned-mac-address to stable to generate the same hashed MAC every time a NetworkManager connection activates, but use a different MAC with each connection. To get a truly random MAC with every activation, use random instead.
|
||||
|
||||
The stable setting is useful to get the same IP address from DHCP, or a captive portal might remember your login status based on the MAC address. With random you may be required to re-authenticate (or click “I agree”) on every connect. You probably want “random” for that airport WiFi. See the NetworkManager [blog post][4] for a more detailed discussion and instructions for using nmcli to configure specific connections from the terminal.
|
||||
|
||||
To see your current MAC addresses, use ip link. The MAC follows the word ether.
|
||||
|
||||
```
|
||||
$ ip link
|
||||
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
|
||||
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
|
||||
2: enp2s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN mode DEFAULT group default qlen 1000
|
||||
link/ether 52:54:00:5f:d5:4e brd ff:ff:ff:ff:ff:ff
|
||||
3: wlp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DORMANT group default qlen 1000
|
||||
link/ether 52:54:00:03:23:59 brd ff:ff:ff:ff:ff:ff
|
||||
|
||||
```
|
||||
|
||||
### When not to randomize your MAC address
|
||||
|
||||
Naturally, there are times when you do need to be legible. For instance, on your home network, you may have configured your router to assign your notebook a consistent private IP for port forwarding. Or you might allow only certain MAC addresses to use the WiFi. Your employer probably requires legibility as well.
|
||||
To change a specific WiFi connection, use nmcli to see your NetworkManager connections and show the current settings:
|
||||
|
||||
```
|
||||
$ nmcli c | grep wifi
|
||||
Amtrak_WiFi 5f4b9f75-9e41-47f8-8bac-25dae779cd87 wifi --
|
||||
StaplesHotspot de57940c-32c2-468b-8f96-0a3b9a9b0a5e wifi --
|
||||
MyHome e8c79829-1848-4563-8e44-466e14a3223d wifi wlp1s0
|
||||
...
|
||||
$ nmcli c show 5f4b9f75-9e41-47f8-8bac-25dae779cd87 | grep cloned
|
||||
802-11-wireless.cloned-mac-address: --
|
||||
$ nmcli c show e8c79829-1848-4563-8e44-466e14a3223d | grep cloned
|
||||
802-11-wireless.cloned-mac-address: stable
|
||||
|
||||
```
|
||||
|
||||
This example uses a fully random MAC for Amtrak (which is currently using the default), and the permanent MAC for MyHome (currently set to stable). The permanent MAC was assigned to your network interface when it was manufactured. Network admins like to use the permanent MAC to see [manufacturer IDs on the wire][5].
|
||||
|
||||
Now, make the changes and reconnect the active interface:
|
||||
|
||||
```
|
||||
$ nmcli c modify 5f4b9f75-9e41-47f8-8bac-25dae779cd87 802-11-wireless.cloned-mac-address random
|
||||
$ nmcli c modify e8c79829-1848-4563-8e44-466e14a3223d 802-11-wireless.cloned-mac-address permanent
|
||||
$ nmcli c down e8c79829-1848-4563-8e44-466e14a3223d
|
||||
$ nmcli c up e8c79829-1848-4563-8e44-466e14a3223d
|
||||
$ ip link
|
||||
...
|
||||
|
||||
```
|
||||
|
||||
You can also install NetworkManager-tui to get the nmtui command for nice menus when editing connections.
|
||||
|
||||
### Conclusion
|
||||
|
||||
When you walk down the street, you should [stay aware of your surroundings][6], and on the [alert for danger][7]. In the same way, learn to be aware of your legibility when using public internet resources.
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://fedoramagazine.org/randomize-mac-address-nm/
|
||||
|
||||
作者:[sheogorath][a],[Stuart D Gathman][b]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[译者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/sheogorath/
|
||||
[b]: https://fedoramagazine.org/author/sdgathman/
|
||||
[1]: https://en.wikipedia.org/wiki/MAC_address
|
||||
[2]: https://www.ribbonfarm.com/2010/07/26/a-big-little-idea-called-legibility/
|
||||
[3]: https://serverfault.com/questions/462178/duplicate-mac-address-on-the-same-lan-possible
|
||||
[4]: https://blogs.gnome.org/thaller/2016/08/26/mac-address-spoofing-in-networkmanager-1-4-0/
|
||||
[5]: https://www.wireshark.org/tools/oui-lookup.html
|
||||
[6]: https://www.isba.org/committees/governmentlawyers/newsletter/2013/06/becomingmoreawareafewtipsonkeepingy
|
||||
[7]: http://www.selectinternational.com/safety-blog/aware-of-surroundings-can-reduce-safety-incidents
|
||||
@@ -1,3 +1,4 @@
|
||||
translating by name1e5s
|
||||
Know Your Storage: Block, File & Object
|
||||
======
|
||||
|
||||
|
||||
@@ -1,105 +0,0 @@
|
||||
XiatianSummer translating
|
||||
|
||||
Visualize Disk Usage On Your Linux System
|
||||
======
|
||||
|
||||

|
||||
|
||||
Finding disk space usage is no big deal in Unix-like operating systems. We have a built-in command named [**du**][1] that can be used to calculate and summarize the disk space usage in minutes. And, we have some third-party tools like [**Ncdu**][2] and [**Agedu**][3] which can also be used to track down the disk usage. As you already know, these are all command line utilities and you will see the disk usage results in plain-text format. However, some of you’d like to view the results in visual or kind of image format. No worries! I know one such GUI tool to find out the disk usage details. Say hello to **“Filelight”** , a graphical utility to visualize disk usage on your Linux system and displays the disk usage results in a colored radial layout. Filelight is one of the oldest project and it has been around for a long time. It is completely free to use and open source.
|
||||
|
||||
### Installing Filelight
|
||||
|
||||
Filelight is part of KDE applications and comes pre-installed with KDE-based Linux distributions.
|
||||
|
||||
If you’re using non-KDE distros, Filelight is available in the official repositories, so you can install it using the default package manager.
|
||||
|
||||
On Arch Linux and its variants such as Antergos, Manjaro Linux, Filelight can be installed as below.
|
||||
|
||||
```
|
||||
$ sudo pacman -S filelight
|
||||
```
|
||||
|
||||
On Debian, Ubuntu, Linux Mint:
|
||||
|
||||
```
|
||||
$ sudo apt install filelight
|
||||
```
|
||||
|
||||
On Fedora:
|
||||
|
||||
```
|
||||
$ sudo dnf install filelight
|
||||
```
|
||||
|
||||
On openSUSE:
|
||||
|
||||
```
|
||||
$ sudo zypper install filelight
|
||||
```
|
||||
|
||||
### Visualize Disk Usage On Your Linux System
|
||||
|
||||
Once installed, launch Filelight from Menu or application launcher.
|
||||
|
||||
FIlelight graphically represents your filesystem as a set of concentric segmented-rings.
|
||||
|
||||

|
||||
|
||||
As you can see, Filelight displays the disk usage of the **/** and **/boot** filesystems by default.
|
||||
|
||||
You can also scan the individual folders of your choice to view the disk usage of that particular folder. To do so, go to **Filelight - > Scan -> Scan Folder** and choose the folder you want to scan.
|
||||
|
||||
Filelight excludes the following directories from scanning:
|
||||
|
||||
* /dev
|
||||
* /proc
|
||||
* /sys
|
||||
* /root
|
||||
|
||||
|
||||
|
||||
This option is helpful to skip the directories that you may not have permissions to read, or folders that are part of a virtual filesystem, such as /proc.
|
||||
|
||||
If you want to add any folder in this list, go to **Filelight - > Settings -> Scanning** and click “add” button and choose the folder you want to add in this list.
|
||||
|
||||

|
||||
|
||||
Similarly, to remove a folder from the list, choose the folder and click on “Remove”.
|
||||
|
||||
If you want to change the way filelight looks, go to **Settings - > Appearance** tab and change the color scheme as per your liking.
|
||||
|
||||
Each segment in the radial layout is represented with different colors. The following image represents the entire radial layout of **/** filesystem. To view the full information of files and folders, just hover the mouse pointer over them.
|
||||
|
||||

|
||||
|
||||
You can navigate around the the filesystem by simply clicking on the respective segment. To view the disk usage of any file or folder, just click on them and you will get the complete disk usage details of that particular folder/file.
|
||||
|
||||
Not just local filesystem, Filelight can able to scan your local, remote and removable disks. If you’re using any KDE-based Linux distribution, it can be integrated into file managers like Konqueror, Dolphin and Krusader.
|
||||
|
||||
Unlike the CLI utilities, you don’t have to use any extra arguments or options to view the results in human-readable format. Filelight will display the disk usage in human-readable format by default.
|
||||
|
||||
### Conclusion
|
||||
|
||||
By using Filelight, you can quickly discover where exactly your diskspace is being used in your filesystem and free up the space wherever necessary by deleting the unwanted files or folders. If you are looking for some simple and user-learnedly graphical disk usage viewer, Filelight is worth trying.
|
||||
|
||||
And, that’s all for now. Hope this was useful. More good stuffs to come. Stay tuned!
|
||||
|
||||
Cheers!
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.ostechnix.com/filelight-visualize-disk-usage-on-your-linux-system/
|
||||
|
||||
作者:[SK][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.ostechnix.com/author/sk/
|
||||
[1]: https://www.ostechnix.com/find-size-directory-linux/
|
||||
[2]: https://www.ostechnix.com/check-disk-space-usage-linux-using-ncdu/
|
||||
[3]: https://www.ostechnix.com/agedu-find-out-wasted-disk-space-in-linux/
|
||||
77
sources/tech/20180913 ScreenCloud- The Screenshot-- App.md
Normal file
77
sources/tech/20180913 ScreenCloud- The Screenshot-- App.md
Normal file
@@ -0,0 +1,77 @@
|
||||
ScreenCloud: The Screenshot++ App
|
||||
======
|
||||
[ScreenCloud][1] is an amazing little app, that you don’t even know you need. The default screenshot procedure on desktop Linux is great (Prt Scr Button) and we even have some[powerful screenshot utilities][2]like [Shutter][3]. But ScreenCloud brings one more really simple yet really convenient feature that I just fell in love with. But before we get into it, let’s catch a little backstory.
|
||||
|
||||
I take a lot of screenshots. A lot more than average. Receipts, registration details, development work, screenshots of applications for articles, and lot more. The next thing I do is open a browser, browse to my favorite cloud storage and dump the important ones there so that I can access them on my phone and also across multiple operating systems on my PC. This also allows me to easily share screenshots of the apps that I’m working on with my team.
|
||||
|
||||
I had no complaints with this standard procedure of taking screenshots, opening a browser and logging into my cloud and then uploading the screenshots manually, until I came across ScreenCloud.
|
||||
|
||||
### ScreenCloud
|
||||
|
||||
ScreenCloud is cross-platform utility that provides easy screenshot capture and management along with flexible [cloud backup options][4]. including your own [FTP server][5].
|
||||
|
||||
![][6]
|
||||
|
||||
ScreenCloud is really streamlined with a lot of attention given to the smaller things. It provides you very easy to remember hotkeys to capture the full screen, the active window or capture an area selected with the mouse.
|
||||
|
||||
![][7]Default keyboard shortcuts for ScreenCloud
|
||||
|
||||
Once a screenshot is taken, you can either set ScreenCloud to ask what to do with the image or to directly upload it the cloud service of your choice. Even SFTP is supported. Once the screenshot it uploaded, generally within a couple of seconds, the link to the image is automatically copied to the clipboard, which you can easily share.
|
||||
|
||||
![][8]
|
||||
|
||||
You can also do some basic editing with ScreenCloud. For this, you should have “Save to” set to “Ask me”. This setting is available from the application indicator and is usually set by default. With this, when you take a screenshot, you’ll see the option for editing the file. Here, you can add arrows, text and numbers to the screenshot.
|
||||
|
||||
![Editing screenshots with ScreenCloud][9]Editing screenshots with ScreenCloud
|
||||
|
||||
### Installing ScreenCloud on Linux
|
||||
|
||||
ScreenCloud is available in the [Snap store][10]. So you can easily install it on Ubuntu and other [Snap enabled][11] distros by visiting the [Snap store][12] or by running the following command.
|
||||
|
||||
```
|
||||
sudo snap install screencloud
|
||||
|
||||
```
|
||||
|
||||
And for Linux distros which can’t install apps through Snap, You can download the AppImage [here][1]. The browse to the download location, right click and open a terminal there. Then run the command below.
|
||||
|
||||
```
|
||||
sudo chmod +x ScreenCloud-v1.4.0-x86_64.AppImage
|
||||
|
||||
```
|
||||
|
||||
You can then launch the app by double clicking on the downloaded file.
|
||||
|
||||
![][13]
|
||||
|
||||
### Wrapping up
|
||||
|
||||
Is ScreenCloud for everybody? Probably not. Is it better than the default screenshot? Probably yes. See if you’re taking a screenshot of something, then chances are, that it’s probably important or you intend to share it. ScreenCloud makes backing up or sharing that screenshot easier and considerably faster. So yeah, you should give ScreenCloud a try if you want these features.
|
||||
|
||||
Your thoughts and comments are always welcome, use the comments section below. And don’t forget to share this article with your friends. Cheers.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/screencloud-app/
|
||||
|
||||
作者:[Aquil Roshan][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[译者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/aquil/
|
||||
[1]: https://screencloud.net
|
||||
[2]: https://itsfoss.com/take-screenshot-linux/
|
||||
[3]: http://shutter-project.org
|
||||
[4]: https://itsfoss.com/cloud-services-linux/
|
||||
[5]: https://itsfoss.com/set-ftp-server-linux/
|
||||
[6]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/screencloud3.jpg
|
||||
[7]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/screencloud2.jpg
|
||||
[8]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/ScrenCloud6.jpg
|
||||
[9]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/editing-with-screencloud.png
|
||||
[10]: https://snapcraft.io/
|
||||
[11]: https://itsfoss.com/install-snap-linux/
|
||||
[12]: https://snapcraft.io/screencloud
|
||||
[13]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/ScrenCloud4.jpg
|
||||
57
sources/tech/20180914 A day in the life of a log message.md
Normal file
57
sources/tech/20180914 A day in the life of a log message.md
Normal file
@@ -0,0 +1,57 @@
|
||||
A day in the life of a log message
|
||||
======
|
||||
|
||||
Navigating a modern distributed system from the perspective of a log message.
|
||||
|
||||

|
||||
|
||||
Chaotic systems tend to be unpredictable. This is especially evident when architecting something as complex as a distributed system. Left unchecked, this unpredictability can waste boundless amounts of time. This is why every single component of a distributed system, no matter how small, must be designed to fit together in a streamlined way.
|
||||
|
||||
[Kubernetes][1] provides a promising model for abstracting compute resources—but even it must be reconciled with other distributed platforms such as [Apache Kafka][2] to ensure reliable data delivery. If someone were to integrate these two platforms, how would it work? Furthermore, if you were to trace something as simple as a log message through such a system, what would it look like? This article will focus on how a log message from an application running inside [OKD][3], the Origin Community Distribution of Kubernetes that powers Red Hat OpenShift, gets to a data warehouse through Kafka.
|
||||
|
||||
### OKD-defined environment
|
||||
|
||||
Such a journey begins in OKD, since the container platform completely overlays the hardware it abstracts. This means that the log message waits to be written to **stdout** or **stderr** streams by an application residing in a container. From there, the log message is redirected onto the node's filesystem by a container engine such as [CRI-O][4].
|
||||
|
||||

|
||||
|
||||
ithin OpenShift, one or more containers are encapsulated within virtual compute nodes known as pods. In fact, all applications running within OKD are abstracted as pods. This allows the applications to be manipulated in a uniform way. This also greatly simplifies communication between distributed components, since pods are systematically addressable through IP addresses and [load-balanced services][5] . So when the log message is taken from the node's filesystem by a log-collector application, it can easily be delivered to another pod running within OpenShift.
|
||||
|
||||
### Two peas in a pod
|
||||
|
||||
To ensure ubiquitous dispersal of the log message throughout the distributed system, the log collector needs to deliver the log message into a Kafka cluster data hub running within OpenShift. Through Kafka, the log message can be delivered to the consuming applications in a reliable and fault-tolerant way with low latency. However, in order to reap the benefits of Kafka within an OKD-defined environment, Kafka needs to be fully integrated into OKD.
|
||||
|
||||
Running a [Strimzi operator][6] will instantiate all Kafka components as pods and integrate them to run within an OKD environment. This includes Kafka brokers for queuing log messages, Kafka connectors for reading and writing from Kafka brokers, and Zookeeper nodes for managing the Kafka cluster state. Strimzi can also instantiate the log collector to double as a Kafka connector, allowing the log collector to feed the log messages directly into a Kafka broker pod running within OKD.
|
||||
|
||||
### Kafka inside OKD
|
||||
|
||||
When the log-collector pod delivers the log message to a Kafka broker, the collector writes to a single broker partition, appending the message to the end of the partition. One of the advantages of using Kafka is that it decouples the log collector from the log's final destination. Thanks to the decoupling, the log collector doesn't care whether the logs end up in [Elasticsearch][7], Hadoop, Amazon S3, or all of them at the same time. Kafka is well-connected to all infrastructure, so the Kafka connectors can take the log message wherever it needs to go.
|
||||
|
||||
Once written to a Kafka broker's partition, the log message is replicated across the broker partitions within the Kafka cluster. This is a very powerful concept on its own; combined with the self-healing features of the platform, it creates a very resilient distributed system. For example, when a node becomes unavailable, the applications running on the node are almost instantaneously spawned on healthy node(s). So even if a node with the Kafka broker is lost or damaged, the log message is guaranteed to survive as many deaths as it was replicated and a new Kafka broker will quickly take the original's place.
|
||||
|
||||
### Off to storage
|
||||
|
||||
After it is committed to a Kafka topic, the log message waits to be consumed by a Kafka connector sink, which relays the log message to either an analytics engine or logging warehouse. Upon delivery to its final destination, the log message could be studied for anomaly detection, queried for immediate root-cause analysis, or used for other purposes. Either way, the log message is delivered by Kafka to its destination in a safe and reliable manner.
|
||||
|
||||
OKD and Kafka are powerful distributed platforms that are evolving rapidly. It is vital to create systems that can abstract the complicated nature of distributed computing without compromising performance. After all, how can we boast of systemwide efficiency if we cannot simplify the journey of a single log message?
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/9/life-log-message
|
||||
|
||||
作者:[Josef Karásek][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[译者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/jkarasek
|
||||
[1]: https://kubernetes.io/
|
||||
[2]: https://kafka.apache.org/
|
||||
[3]: https://www.okd.io/
|
||||
[4]: http://cri-o.io/
|
||||
[5]: https://kubernetes.io/docs/concepts/services-networking/service/
|
||||
[6]: http://strimzi.io/
|
||||
[7]: https://www.elastic.co/
|
||||
@@ -0,0 +1,394 @@
|
||||
Convert files at the command line with Pandoc
|
||||
======
|
||||
|
||||
This guide shows you how to use Pandoc to convert your documents into many different file formats
|
||||
|
||||

|
||||
|
||||
Pandoc is a command-line tool for converting files from one markup language to another. Markup languages use tags to annotate sections of a document. Commonly used markup languages include Markdown, ReStructuredText, HTML, LaTex, ePub, and Microsoft Word DOCX.
|
||||
|
||||
In plain English, [Pandoc][1] allows you to convert a bunch of files from one markup language into another one. Typical examples include converting a Markdown file into a presentation, LaTeX, PDF, or even ePub.
|
||||
|
||||
This article will explain how to produce documentation in multiple formats from a single markup language (in this case Markdown) using Pandoc. It will guide you through Pandoc installation, show how to create several types of documents, and offer tips on how to write documentation that is easy to port to other formats. It will also explain the value of using meta-information files to create a separation between the content and the meta-information (e.g., author name, template used, bibliographic style, etc.) of your documentation.
|
||||
|
||||
### Installation and requirements
|
||||
|
||||
Pandoc is installed by default in most Linux distributions. This tutorial uses pandoc-2.2.3.2 and pandoc-citeproc-0.14.3. If you don't intend to generate PDFs, those two packages are enough. However, I recommend installing texlive as well, so you have the option to generate PDFs.
|
||||
|
||||
To install these programs on Linux, type the following on the command line:
|
||||
|
||||
```
|
||||
sudo apt-get install pandoc pandoc-citeproc texlive
|
||||
```
|
||||
|
||||
You can find [installation instructions][2] for other platforms on Pandoc's website.
|
||||
|
||||
I highly recommend installing [pandoc][3][-crossref][3], a "filter for numbering figures, equations, tables, and cross-references to them." The easiest option is to download a [prebuilt executable][4], but you can install it from Haskell's package manager, cabal, by typing:
|
||||
|
||||
```
|
||||
cabal update
|
||||
cabal install pandoc-crossref
|
||||
```
|
||||
|
||||
Consult pandoc-crossref's GitHub repository if you need additional Haskell [installation information][5].
|
||||
|
||||
### Some examples
|
||||
|
||||
I'll demonstrate how Pandoc works by explaining how to produce three types of documents:
|
||||
|
||||
* A website from a LaTeX file containing math formulas
|
||||
* A Reveal.js slideshow from a Markdown file
|
||||
* A contract agreement document that mixes Markdown and LaTeX
|
||||
|
||||
|
||||
|
||||
#### Create a website with math formulas
|
||||
|
||||
One of the ways Pandoc excels is displaying math formulas in different output file formats. For instance, let's generate a website from a LaTeX document (named math.tex) containing some math symbols (written in LaTeX).
|
||||
|
||||
The math.tex document looks like:
|
||||
|
||||
```
|
||||
% Pandoc math demos
|
||||
|
||||
$a^2 + b^2 = c^2$
|
||||
|
||||
$v(t) = v_0 + \frac{1}{2}at^2$
|
||||
|
||||
$\gamma = \frac{1}{\sqrt{1 - v^2/c^2}}$
|
||||
|
||||
$\exists x \forall y (Rxy \equiv Ryx)$
|
||||
|
||||
$p \wedge q \models p$
|
||||
|
||||
$\Box\diamond p\equiv\diamond p$
|
||||
|
||||
$\int_{0}^{1} x dx = \left[ \frac{1}{2}x^2 \right]_{0}^{1} = \frac{1}{2}$
|
||||
|
||||
$e^x = \sum_{n=0}^\infty \frac{x^n}{n!} = \lim_{n\rightarrow\infty} (1+x/n)^n$
|
||||
```
|
||||
|
||||
Convert the LaTeX document into a website named mathMathML.html by entering the following command:
|
||||
|
||||
```
|
||||
pandoc math.tex -s --mathml -o mathMathML.html
|
||||
```
|
||||
|
||||
The flag **-s** tells Pandoc to generate a standalone website (instead of a fragment, so it will include the head and body HTML tags), and the **–mathml** flag forces Pandoc to convert the math in LaTeX to MathML, which can be rendered by modern browsers.
|
||||
|
||||

|
||||
|
||||
Take a look at the [website result][6] and the [code][7]; the code repository contains a Makefile to make things even simpler.
|
||||
|
||||
#### Make a Reveal.js slideshow
|
||||
|
||||
It's easy to generate simple presentations from a Markdown file using Pandoc. The slides contain top-level slides and nested slides underneath. The presentation can be controlled from the keyboard, and you can jump from one top-level slide to the next top-level slide or show the nested slides on a per-top-level basis. This structure is typical in HTML-based presentation frameworks.
|
||||
|
||||
Let's create a slide document named SLIDES (see the [code repository][8]). First, add the slides' meta-information (e.g., title, author, and date) prepended by the **%** symbol:
|
||||
|
||||
```
|
||||
% Case Study
|
||||
% Kiko Fernandez Reyes
|
||||
% Sept 27, 2017
|
||||
```
|
||||
|
||||
This meta-information also creates the first slide. To add more slides, declare top-level slides using Markdown heading H1 (line 5 in the example below, [heading 1 in Markdown][9] , designated by).
|
||||
|
||||
For example, if we want to create a presentation with the title Case Study that starts with a top-level slide titled Wine Management System, write:
|
||||
|
||||
```
|
||||
% Case Study
|
||||
% Kiko Fernandez Reyes
|
||||
% Sept 27, 2017
|
||||
|
||||
# Wine Management System
|
||||
```
|
||||
|
||||
To put content (such as slides that explain a new management system and its implementation) inside this top-level section, use a Markdown header H2. Let's add two more slides (lines 7 and 14 below, [heading 2 in Markdown][9], designated by **##** ):
|
||||
|
||||
* The first second-level slide has the title Idea and shows an image of the Swiss flag
|
||||
* The second second-level slide has the title Implementation
|
||||
|
||||
|
||||
|
||||
```
|
||||
% Case Study
|
||||
% Kiko Fernandez Reyes
|
||||
% Sept 27, 2017
|
||||
|
||||
# Wine Management System
|
||||
|
||||
## <img src="img/SwissFlag.png" style="vertical-align:middle"/> Idea
|
||||
|
||||
## Implementation
|
||||
```
|
||||
|
||||
We now have a top-level slide ( **# Wine Management System** ) that contains two slides ( **## Idea** and **## Implementation** ).
|
||||
|
||||
Let's put some content in these two slides using incremental bulleted lists by creating a Markdown list prepended by the symbol **>**. Continuing from above, add two items in the first slide (lines 9–10 below) and five items in the second slide (lines 16–20):
|
||||
|
||||
```
|
||||
% Case Study
|
||||
% Kiko Fernandez Reyes
|
||||
% Sept 27, 2017
|
||||
|
||||
# Wine Management System
|
||||
|
||||
## <img src="img/SwissFlag.png" style="vertical-align:middle"/> Idea
|
||||
|
||||
>- Swiss love their **wine** and cheese
|
||||
>- Create a *simple* wine tracker system
|
||||
|
||||

|
||||
|
||||
## Implementation
|
||||
|
||||
>- Bottles have a RFID tag
|
||||
>- RFID reader (emits and read signal)
|
||||
>- **Raspberry Pi**
|
||||
>- **Server (online shop)**
|
||||
>- Mobile app
|
||||
```
|
||||
|
||||
We added an image of the Matterhorn mountain. Your slides can be improved by using plain Markdown or adding plain HTML.
|
||||
|
||||
To generate the slides, Pandoc needs to point to the Reveal.js library, so it must be in the same folder as the SLIDES file. The command to generate the slides is:
|
||||
|
||||
```
|
||||
pandoc -t revealjs -s --self-contained SLIDES \
|
||||
-V theme=white -V slideNumber=true -o index.html
|
||||
```
|
||||
|
||||

|
||||
|
||||
The above Pandoc command uses the following flags:
|
||||
|
||||
* **-t revealjs** specifies we are going to output a **revealjs** presentation
|
||||
* **-s** tells Pandoc to generate a standalone document
|
||||
* **\--self-contained** produces HTML with no external dependencies
|
||||
* **-V** sets the following variables:
|
||||
– **theme=white** sets the theme of the slideshow to **white**
|
||||
– **slideNumber=true** shows the slide number
|
||||
* **-o index.html** generates the slides in the file named **index.html**
|
||||
|
||||
|
||||
|
||||
To make things simpler and avoid typing this long command, create the following Makefile:
|
||||
|
||||
```
|
||||
all: generate
|
||||
|
||||
generate:
|
||||
pandoc -t revealjs -s --self-contained SLIDES \
|
||||
-V theme=white -V slideNumber=true -o index.html
|
||||
|
||||
clean: index.html
|
||||
rm index.html
|
||||
|
||||
.PHONY: all clean generate
|
||||
```
|
||||
|
||||
You can find all the code in [this repository][8].
|
||||
|
||||
#### Make a multi-format contract
|
||||
|
||||
Let's say you are preparing a document and (as things are nowadays) some people want it in Microsoft Word format, others use free software and would like an ODT, and others need a PDF. You do not have to use OpenOffice nor LibreOffice to generate the DOCX or PDF file. You can create your document in Markdown (with some bits of LaTeX if you need advanced formatting) and generate any of these file types.
|
||||
|
||||
As before, begin by declaring the document's meta-information (title, author, and date):
|
||||
|
||||
```
|
||||
% Contract Agreement for Software X
|
||||
% Kiko Fernandez-Reyes
|
||||
% August 28th, 2018
|
||||
```
|
||||
|
||||
Then write the document in Markdown (and add LaTeX if you require advanced formatting). For example, create a table that needs fixed separation space (declared in LaTeX with **\hspace{3cm}** ) and a line where a client and a contractor should sign (declared in LaTeX with **\hrulefill** ). After that, add a table written in Markdown.
|
||||
|
||||
Here's what the document will look like:
|
||||
|
||||

|
||||
|
||||
The code to create this document is:
|
||||
|
||||
```
|
||||
% Contract Agreement for Software X
|
||||
% Kiko Fernandez-Reyes
|
||||
% August 28th, 2018
|
||||
|
||||
...
|
||||
|
||||
### Work Order
|
||||
|
||||
\begin{table}[h]
|
||||
\begin{tabular}{ccc}
|
||||
The Contractor & \hspace{3cm} & The Customer \\
|
||||
& & \\
|
||||
& & \\
|
||||
\hrulefill & \hspace{3cm} & \hrulefill \\
|
||||
%
|
||||
Name & \hspace{3cm} & Name \\
|
||||
& & \\
|
||||
& & \\
|
||||
\hrulefill & \hspace{3cm} & \hrulefill \\
|
||||
...
|
||||
\end{tabular}
|
||||
\end{table}
|
||||
|
||||
\vspace{1cm}
|
||||
|
||||
+--------------------------------------------|----------|-------------+
|
||||
| Type of Service | Cost | Total |
|
||||
+:===========================================+=========:+:===========:+
|
||||
| Game Engine | 70.0 | 70.0 |
|
||||
| | | |
|
||||
+--------------------------------------------|----------|-------------+
|
||||
| | | |
|
||||
+--------------------------------------------|----------|-------------+
|
||||
| Extra: Comply with defined API functions | 10.0 | 10.0 |
|
||||
| and expected returned format | | |
|
||||
+--------------------------------------------|----------|-------------+
|
||||
| | | |
|
||||
+--------------------------------------------|----------|-------------+
|
||||
| **Total Cost** | | **80.0** |
|
||||
+--------------------------------------------|----------|-------------+
|
||||
```
|
||||
|
||||
To generate the three different output formats needed for this document, write a Makefile:
|
||||
|
||||
```
|
||||
DOCS=contract-agreement.md
|
||||
|
||||
all: $(DOCS)
|
||||
pandoc -s $(DOCS) -o $(DOCS:md=pdf)
|
||||
pandoc -s $(DOCS) -o $(DOCS:md=docx)
|
||||
pandoc -s $(DOCS) -o $(DOCS:md=odt)
|
||||
|
||||
clean:
|
||||
rm *.pdf *.docx *.odt
|
||||
|
||||
.PHONY: all clean
|
||||
```
|
||||
|
||||
Lines 4–7 contain the commands to generate the different outputs.
|
||||
|
||||
If you have several Markdown files and want to merge them into one document, issue a command with the files in the order you want them to appear. For example, when writing this article, I created three documents: an introduction document, three examples, and some advanced uses. The following tells Pandoc to merge these files together in the specified order and produce a PDF named document.pdf.
|
||||
|
||||
```
|
||||
pandoc -s introduction.md examples.md advanced-uses.md -o document.pdf
|
||||
```
|
||||
|
||||
### Templates and meta-information
|
||||
|
||||
Writing a complex document is no easy task. You need to stick to a set of rules that are independent from your content, such as using a specific template, writing an abstract, embedding specific fonts, and maybe even declaring keywords. All of this has nothing to do with your content: simply put, it is meta-information.
|
||||
|
||||
Pandoc uses templates to generate different output formats. There is a template for LaTeX, another for ePub, etc. These templates have unfulfilled variables that are set with the meta-information given to Pandoc. To find out what meta-information is available in a Pandoc template, type:
|
||||
|
||||
```
|
||||
pandoc -D FORMAT
|
||||
```
|
||||
|
||||
For example, the template for LaTeX would be:
|
||||
|
||||
```
|
||||
pandoc -D latex
|
||||
```
|
||||
|
||||
Which outputs something along these lines:
|
||||
|
||||
```
|
||||
$if(title)$
|
||||
\title{$title$$if(thanks)$\thanks{$thanks$}$endif$}
|
||||
$endif$
|
||||
$if(subtitle)$
|
||||
\providecommand{\subtitle}[1]{}
|
||||
\subtitle{$subtitle$}
|
||||
$endif$
|
||||
$if(author)$
|
||||
\author{$for(author)$$author$$sep$ \and $endfor$}
|
||||
$endif$
|
||||
$if(institute)$
|
||||
\providecommand{\institute}[1]{}
|
||||
\institute{$for(institute)$$institute$$sep$ \and $endfor$}
|
||||
$endif$
|
||||
\date{$date$}
|
||||
$if(beamer)$
|
||||
$if(titlegraphic)$
|
||||
\titlegraphic{\includegraphics{$titlegraphic$}}
|
||||
$endif$
|
||||
$if(logo)$
|
||||
\logo{\includegraphics{$logo$}}
|
||||
$endif$
|
||||
$endif$
|
||||
|
||||
\begin{document}
|
||||
```
|
||||
|
||||
As you can see, there are **title** , **thanks** , **author** , **subtitle** , and **institute** template variables (and many others are available). These are easily set using YAML metablocks. In lines 1–5 of the example below, we declare a YAML metablock and set some of those variables (using the contract agreement example above):
|
||||
|
||||
```
|
||||
---
|
||||
title: Contract Agreement for Software X
|
||||
author: Kiko Fernandez-Reyes
|
||||
date: August 28th, 2018
|
||||
---
|
||||
|
||||
(continue writing document as in the previous example)
|
||||
```
|
||||
|
||||
This works like a charm and is equivalent to the previous code:
|
||||
|
||||
```
|
||||
% Contract Agreement for Software X
|
||||
% Kiko Fernandez-Reyes
|
||||
% August 28th, 2018
|
||||
```
|
||||
|
||||
However, this ties the meta-information to the content; i.e., Pandoc will always use this information to output files in the new format. If you know you need to produce multiple file formats, you better be careful. For example, what if you need to produce the contract in ePub and in HTML, and the ePub and HTML need specific and different styling rules?
|
||||
|
||||
Let's consider the cases:
|
||||
|
||||
* If you simply try to embed the YAML variable **css: style-epub.css** , you would be excluding the one from the HTML version. This does not work.
|
||||
* Duplicating the document is obviously not a good solution either, as changes in one version would not be in sync with the other copy.
|
||||
* You can add variables to the Pandoc command line as follows:
|
||||
|
||||
|
||||
|
||||
```
|
||||
pandoc -s -V css=style-epub.css document.md document.epub
|
||||
pandoc -s -V css=style-html.css document.md document.html
|
||||
```
|
||||
|
||||
My opinion is that it is easy to overlook these variables from the command line, especially when you need to set tens of these (which can happen in complex documents). Now, if you put them all together under the same roof (a meta.yaml file), you only need to update or create a new meta-information file to produce the desired output. You would then write:
|
||||
|
||||
```
|
||||
pandoc -s meta-pub.yaml document.md document.epub
|
||||
pandoc -s meta-html.yaml document.md document.html
|
||||
```
|
||||
|
||||
This is a much cleaner version, and you can update all the meta-information from a single file without ever having to update the content of your document.
|
||||
|
||||
### Wrapping up
|
||||
|
||||
With these basic examples, I have shown how Pandoc can do a really good job at converting Markdown documents into other formats.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/9/intro-pandoc
|
||||
|
||||
作者:[Kiko Fernandez-Reyes][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[译者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/kikofernandez
|
||||
[1]: https://pandoc.org/
|
||||
[2]: http://pandoc.org/installing.html
|
||||
[3]: https://hackage.haskell.org/package/pandoc-crossref
|
||||
[4]: https://github.com/lierdakil/pandoc-crossref/releases/tag/v0.3.2.1
|
||||
[5]: https://github.com/lierdakil/pandoc-crossref#installation
|
||||
[6]: http://pandoc.org/demo/mathMathML.html
|
||||
[7]: https://github.com/kikofernandez/pandoc-examples/tree/master/math
|
||||
[8]: https://github.com/kikofernandez/pandoc-examples/tree/master/slides
|
||||
[9]: https://daringfireball.net/projects/markdown/syntax#header
|
||||
@@ -1,118 +0,0 @@
|
||||
Getting started with the i3 window manager on Linux
|
||||
======
|
||||
|
||||

|
||||
|
||||
In my article [5 reasons the i3 window manager makes Linux better][1], I shared the top five reasons I use and recommend the [i3 window manager][2] as an alternative Linux desktop experience.
|
||||
|
||||
In this post, I will walk through the installation and basic configuration of i3 on Fedora 28 Linux.
|
||||
|
||||
### 1\. Installation
|
||||
|
||||
Log into a Fedora workstation and open up a terminal. Use `dnf` to install the required package, like this:
|
||||
```
|
||||
[ricardo@f28i3 ~]$ sudo dnf install -y i3 i3-ipc i3status i3lock dmenu terminator --exclude=rxvt-unicode
|
||||
Last metadata expiration check: 1:36:15 ago on Wed 08 Aug 2018 12:04:31 PM EDT.
|
||||
Dependencies resolved.
|
||||
================================================================================================
|
||||
Package Arch Version Repository Size
|
||||
================================================================================================
|
||||
Installing:
|
||||
dmenu x86_64 4.8-1.fc28 fedora 33 k
|
||||
i3 x86_64 4.15-1.fc28 fedora 323 k
|
||||
i3-ipc noarch 0.1.4-12.fc28 fedora 14 k
|
||||
i3lock x86_64 2.9.1-2.fc28 fedora 33 k
|
||||
i3status x86_64 2.12-1.fc28 updates 62 k
|
||||
terminator noarch 1.91-4.fc28 fedora 570 k
|
||||
Installing dependencies:
|
||||
dzen2 x86_64 0.8.5-21.20100104svn.fc28 fedora 60 k
|
||||
|
||||
... Skipping dependencies/install messages
|
||||
|
||||
Complete!
|
||||
[ricardo@f28i3 ~]$
|
||||
```
|
||||
|
||||
**Note:** In this command, I'm explicitly excluding the package `rxvt-unicode` because I prefer `terminator` as my terminal emulator.
|
||||
|
||||
Depending on the status of your system, it may install many dependencies. Wait for the installation to complete successfully and then reboot your machine.
|
||||
|
||||
### 2. First login and initial setup
|
||||
|
||||
After your machine restarts, you're ready to log into i3 for the first time. In the GNOME Display Manager (GDM) screen, click on your username but—before typing the password to log in—click on the small gear icon and change the session to i3 instead of GNOME, like this:
|
||||
|
||||

|
||||
|
||||
Type your password and click `Sign In`. On your first login, you are presented with the i3 configuration screen:
|
||||
|
||||

|
||||
|
||||
Press `ENTER` to generate a config file in your `$HOME/.config/i3` directory. Later you can use this config file to further customize i3's behavior.
|
||||
|
||||
On the next screen, you need to select your `Mod` key. This is important, as the `Mod` key is used to trigger most of i3's keyboard shortcuts. Press `ENTER` to use the default `Win` key as the `Mod` key. If you don't have a `Win` key on your keyboard or prefer to use `Alt` instead, use the arrow key to select it and press `ENTER` to confirm.
|
||||
|
||||

|
||||
|
||||
You're now logged into your i3 session. Because i3 is a minimalist window manager, you see a black screen with the status bar on the bottom:
|
||||
|
||||

|
||||
|
||||
Next, let's look at navigating in i3.
|
||||
|
||||
### 3\. Basic shortcuts
|
||||
|
||||
Now that you're logged into an i3 session, you'll need a few basic keyboard shortcuts to get around.
|
||||
|
||||
The majority of i3 shortcuts use the `Mod` key you defined during the initial configuration. When I refer to `Mod` in the following examples, press the key you defined. This will usually be the `Win` key, but it can also be the `Alt` key.
|
||||
|
||||
First, to open up a terminal, use `Mod+ENTER`. Open more than one terminal and notice how i3 automatically tiles them to occupy all available space. By default, i3 splits the screen horizontally; use `Mod+v` to split vertically and press `Mod+h` to go back to the horizontal split.
|
||||
|
||||

|
||||
|
||||
To start other applications, press `Mod+d` to open `dmenu`, a simple text-based application menu. By default, `dmenu` presents a list of all applications available on your `$PATH`. Select the application you want to start by using the arrow keys or narrow down the search by typing parts of the application's name. Press `ENTER` to start the selected application.
|
||||
|
||||

|
||||
|
||||
If your application does not provide a way to close it, you can use i3 to kill a window by pressing `Mod+Shift+q`. Be careful, as you may lose unsaved work—this behavior depends on each application.
|
||||
|
||||
Finally, to end your session and exit i3, press `Mod+Shift+e`. You are presented with a confirmation message at the top of your screen. Click on `Yes, exit i3` to exit or `X` to cancel.
|
||||
|
||||

|
||||
|
||||
This is just an initial list of shortcuts you can use to get around i3. For many more, consult i3's official [documentation][3].
|
||||
|
||||
### 4\. Replacing GDM
|
||||
|
||||
Using i3 window manager reduces the memory utilization on your system; however, Fedora still uses the default GDM as its login screen. GDM loads several GNOME-related libraries and applications that consume memory.
|
||||
|
||||
If you want to further reduce your system's memory utilization, you can replace GDM with a more lightweight display manager, such as `lightdm`, like this:
|
||||
```
|
||||
[ricardo@f28i3 ~]$ sudo dnf install -y lightdm
|
||||
[ricardo@f28i3 ~]$ sudo systemctl disable gdm
|
||||
Removed /etc/systemd/system/display-manager.service.
|
||||
[ricardo@f28i3 ~]$ sudo systemctl enable lightdm
|
||||
Created symlink /etc/systemd/system/display-manager.service -> /usr/lib/systemd/system/lightdm.service.
|
||||
[ricardo@f28i3 ~]$
|
||||
```
|
||||
|
||||
Restart your machine to see the Lightdm login screen.
|
||||
|
||||
Now you're ready to log in and use i3.
|
||||
|
||||

|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/8/getting-started-i3-window-manager
|
||||
|
||||
作者:[Ricardo Gerardi][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[译者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/rgerardi
|
||||
[1]: https://opensource.com/article/18/8/i3-tiling-window-manager
|
||||
[2]: https://i3wm.org
|
||||
[3]: https://i3wm.org/docs/userguide.html#_default_keybindings
|
||||
Reference in New Issue
Block a user