From 00a2bad73443736870e148db76d52cae18cdf0db Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 18 Mar 2019 11:05:22 +0800 Subject: [PATCH 01/12] =?UTF-8?q?=E9=80=89=E9=A2=98:=2020190315=20How=20to?= =?UTF-8?q?=20create=20portable=20documents=20with=20CBZ=20and=20DjVu=20so?= =?UTF-8?q?urces/tech/20190315=20How=20to=20create=20portable=20documents?= =?UTF-8?q?=20with=20CBZ=20and=20DjVu.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...te portable documents with CBZ and DjVu.md | 317 ++++++++++++++++++ 1 file changed, 317 insertions(+) create mode 100644 sources/tech/20190315 How to create portable documents with CBZ and DjVu.md diff --git a/sources/tech/20190315 How to create portable documents with CBZ and DjVu.md b/sources/tech/20190315 How to create portable documents with CBZ and DjVu.md new file mode 100644 index 0000000000..70f292e827 --- /dev/null +++ b/sources/tech/20190315 How to create portable documents with CBZ and DjVu.md @@ -0,0 +1,317 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to create portable documents with CBZ and DjVu) +[#]: via: (https://opensource.com/article/19/3/comic-book-archive-djvu) +[#]: author: (Seth Kenlon (Red Hat, Community Moderator) https://opensource.com/users/seth) + +How to create portable documents with CBZ and DjVu +====== + +Stop using PDFs with these two smart digital archive formats. + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/books_stack_library_reading.jpg?itok=uulcS8Sw) + +Recently, I discovered that my great-great-grandfather wrote two books near the turn of the 20th century: one about sailing and the other about his career as [New York City's fire chief][1]. The books have a niche audience, but since they are part of my family history, I wanted to preserve a digital copy of each. But, I wondered, what portable document format is best suited for such an endeavor? + +I decided early on that PDF was not an option. The format, while good for printing preflight, seems condemned to nonstop feature bloat, and it produces documents that are difficult to introspect and edit. I wanted a smarter format with similar features. Two came to mind: comic book archive and DjVu. + +### Comic book archive + +[Comic book archive][2] is a simple format most often used, as the name suggests, for comic books. You can see examples of comic book archives on sites like [Comic Book Plus][3] and [The Digital Comic Museum][4]. + +The greatest feature of a comic book archive is also its weakest: it's so simple, it's almost more of a convention than a format. In fact, a comic book archive is just a ZIP, TAR, 7Z, or RAR archive given the extension .cbz, .cbt, .cb7, or .cbr, respectively. It has no standard for storing metadata. + +They are, however, very easy to create. + +#### Creating comic book archives + + 1. Create a directory full of image files, and rename the images so that they have an inherent order: + +``` +$ n=0 && for i in *.png ; do mv $i `printf %04d $n`.png ; done +``` + + + + 2. Archive the files using your favorite archive tool. In my experience, CBZ is best supported. + +``` +$ zip comicbook.zip -r *.png +``` + + + + 3. Finally, rename the file with the appropriate extension. + +``` +$ mv comicbook.zip comicbook.cbz +``` + + + + +The resulting file should open on most of your devices. On Linux, both [Evince][5] and [Okular][6] can open CBZ files. On Android, [Document Viewer][7] and [Bubble][8] can open them. + +#### Uncompressing comic book archives + +Getting your data back out of a comic book archive is also easy: just unarchive the CBZ file. + +Since your favorite archive tool may not recognize the .cbz extension as a valid archive, it's best to rename it back to its native extension: +``` + +``` + +$ mv comicbook.cbz comicbook.zip +$ unzip comicbook.zip + +### DjVu + +A more advanced format, developed more than 20 years ago by AT&T, is [DjVu][9] (pronounced "déjà vu"). It's a digital document format with advanced compression technology and is viewable in more applications than you probably realize, including [Evince][5], [Okular][6], [DjVu.js][10] online, the [DjVu.js viewer][11] Firefox extension, [GNU Emacs][12], [Document Viewer][7] on Android, and the open source, cross-platform [DjView][13] viewer on Sourceforge. + +You can read more about DjVu and find sample .djvu files, at [djvu.org][14]. + +DjVu has several appealing features, including image compression, outline (bookmark) structure, and support for embedded text. It's easy to introspect and edit using free and open source tools. + +#### Installing DjVu + +The open source toolchain is [DjVuLibre][15], which you can find in your distribution's software repository. For example, on Fedora: + +``` +$ sudo dnf install dvjulibre +``` + +#### Creating a DjVu file + +A .djvu is an image that has been encoded as a DjVu file. A .djvu can contain one or more images (stored as "pages"). + +To manually produce a DjVu, you can use one of two encoders: **c44** for high-quality images or **cjb2** for simple bi-tonal images. Each encoder accepts a different image format: c44 can process .pnm or .jpeg files, while cjb2 can process .pbm or .tiff images. + +If you need to preprocess an image, you can do that in a terminal with [Image Magick][16], using the **-density** option to define your desired resolution: + +``` +$ convert -density 200 foo.png foo.pnm +``` + +Then you can convert it to DjVu: + +``` +$ c44 -dpi 200 foo.pnm foo.djvu +``` + +If your image is simple, like black text on a white page, you can try to convert it using the simpler encoder. If necessary, use Image Magick first to convert it to a compatible intermediate format: + +``` +$ convert -density 200 foo.png foo.pbm +``` + +And then convert it to DjVu: + +``` +$ cjb2 -dpi 200 foo.pbm foo.djvu +``` + +You now have a simple, single-page .djvu document. + +#### Creating a multi-page DjVu file + +While a single-page DjVu can be useful, given DjVu's sometimes excellent compression, it's most commonly used as a multi-page format. + +Assuming you have a directory of many .djvu files, you can bundle them together with the **djvm** command: + +``` +$ djvm -c pg_1.djvu two.djvu 003.djvu mybook.djvu +``` + +Unlike a CBZ archive, the names of the bundled images have no effect on their order in the DjVu document, rather it preserves the order you provide in the command. If you had the foresight to name them in a natural sorting order (001.djvu, 002.djvu, 003.djvu, 004.djvu, and so on), you can use a wildcard: + +``` +$ djvm -c *.djvu mybook.djvu +``` + +#### Manipulating a DjVu document + +It's easy to edit DjVu documents with **djvm**. For instance, you can insert a page into an existing DjVu document: + +``` +$ djvm -i mybook.djvu newpage.djvu 2 +``` + +In this example, the page _newpage.djvu_ becomes the new page 2 in the file _mybook.djvu_. + +You can also delete a page. For example, to delete page 4 from _mybook.djvu_ : + +``` +$ djvm -d mybook.djvu 4 +``` + +#### Setting an outline + +You can add metadata to a DjVu file, such as an outline (commonly called "bookmarks"). To do this manually, create a plaintext file with the document's outline. A DjVu outline is expressed in a [Lisp][17]-like structure, with an opening **bookmarks** element followed by bookmark names and page numbers: +``` +(bookmarks +("Front cover" "#1") +("Chapter 1" "#3") +("Chapter 2" "#18") +("Chapter 3" "#26") +) +``` + +The parentheses define levels in the outline. The outline currently has only top-level bookmarks, but any section can have a subsection by delaying its closing parenthesis. For example, to add a subsection to Chapter 1: +``` +(bookmarks +("Front cover" "#1") +("Chapter 1" "#3" +("Section 1" "#6")) +("Chapter 2" "#18") +("Chapter 3" "#26") +) +``` + +Once the outline is complete, save the file and apply it to your DjVu file using the **djvused** command: + +``` +$ djvused -e 'set-outline outline.txt' -s mybook.djvu +``` + +Open the DjVu file to see the outline. + +![A DjVu with an outline as viewed in Okular][19] + +#### Embedding text + +If you want to store the text of a document you're creating, you can embed text elements ("hidden text" in **djvused** terminology) in your DjVu file so that applications like Okular or DjView can select and copy the text to a user's clipboard. + +This is a complex operation because, in order to embed text, you must first have text. If you have access to a good OCR application (or the time and dedication to transcribe the printed page), you may have that data, but then you must map the text to the bitmap image. + +Once you have the text and the coordinates for each line (or, if you prefer, for each word), you can write a **djvused** script with blocks for each page: +``` +select; remove-ant; remove-txt +# ------------------------- +select "p0004.djvu" # page 4 +set-txt +(page 0 0 2550 3300 +(line 1661 2337 2235 2369 "Fires and Fire-fighters") +(line 1761 2337 2235 2369 "by John Kenlon")) + +. +# ------------------------- +select "p0005.djvu" # page 5 +set-txt +(page 0 0 2550 3300 +(line 294 2602 1206 2642 "Some more text here, blah blah blah.")) +``` + +The integers for each line represent the minimum and maximum locations for the X and Y coordinates of each line ( **xmin** , **ymin** , **xmax** , **ymax** ). Each line is a rectangle measured in pixels, with an origin at the _bottom-left_ corner of the page. + +You can define embedded text elements as words, lines, and hyperlinks, and you can map complex regions with shapes other than just rectangles. You can also embed specially defined metadata, such as BibTex keys, which are expressed in lowercase (year, booktitle, editor, author, and so on), and DocInfo keys, borrowed from the PDF spec, always starting with an uppercase letter (Title, Author, Subject, Creator, Produced, CreationDate, ModDate, and so on). + +#### Automating DjVu creation + +While it's nice to be able to handcraft a finely detailed DjVu document, if you adopt DjVu as an everyday format, you'll notice that your applications lack some of the conveniences available in the more ubiquitous PDF. For instance, few (if any) applications offer a convenient _Print to DjVu_ or _Export to DjVu_ option, as they do for PDF. + +However, you can still use DjVu by leveraging PDF as an intermediate format. + +Unfortunately, the library required for easy, automated DjVu conversion is licensed under the CPL, which has requirements that cannot be satisfied by the GPL code in the toolchain. For this reason, it can't be distributed as a compiled library, but you're free to compile it yourself. + +The process is relatively simple due to an excellent build script provided by the DjVuLibre team. + + 1. First, prepare your system with software development tools. On Fedora, the quick-and-easy way is with a DNF group: + +``` +$ sudo dnf group install @c-development +``` + +On Ubuntu: + +``` +$ sudo apt-get install build-essential +``` + + + + 2. Next, download the [**GSDjVu** source code][20] from Sourceforge. Be sure to download **GSDjVu** , not **DjVuLibre** (in other words, don't click on the big green button at the top of the file listing, but on the latest file instead). + + + 3. Unarchive the file you just downloaded, and change directory into it: +``` +$ cd ~/Downloads +$ tar xvf gsdjvu-X.YY.tar.gz +$ cd gsdjvu-X.YY +``` + + + + 4. Create a directory called **BUILD**. It must be called **BUILD** , so quell your creativity: +``` +$ mkdir BUILD +$ cd BUILD +``` + + + + 5. Download the additional source packages required to build the **GSDjVu **application. Specifically, you must download the source for **Ghostscript** (you almost certainly already have this installed, but you need its source to build against). Additionally, your system must have source packages for **jpeg** , **libpng** , **openjpeg** , and **zlib**. If you think your system already has the source packages for these projects, you can run the build script; if the sources are not found, the script will fail and let you correct the error before trying again. + + + 6. Run the interactive **build-gsdjvu** build script included in the download. This script unpacks the source files, patches Ghostscript with the **gdevdjvu** driver, compiles Ghostscript, and prunes unnecessary files from the build results. + + + 7. You can install **GSDjVu **anywhere in your path. If you don't know what your **PATH** variable is, you can see it with **echo $PATH**. For example, to install it to the **/usr/local** prefix: +``` +$ sudo cp -r BUILD/INST/gsdjvu /usr/local/lib64 +$ cd /usr/local/bin +$ sudo ln -s ../lib64/gsdjvu/gsdjvu gsdjvu +``` + + + + +#### Converting a PDF to DjVu + +Now that you've built the Ghostscript driver, converting a PDF to DjVu requires just one command: + +``` +$ djvudigital --words mydocument.pdf mydocument.djvu +``` + +This transforms all pages, bookmarks, and embedded text in a PDF into a DjVu file. The `--words` option maps all mapped embedded PDF text to the corresponding points in the DjVu file. If there is no embedded PDF, then no embedded text is carried over. Using this tool, you can use convenient PDF functions from your applications and end up with DjVu files. + +### Why DjVu and CBZ? + +DjVu and comic book archive are great additional document formats for your archival arsenal. It seems silly to stuff a series of images into a PostScript format, like PDF, or a format clearly meant mostly for text, like EPUB, so it's nice to have CBZ and DjVu as additional options. They might not be right for all of your documents, but it's good to get comfortable with them so you can use one when it makes the most sense. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/3/comic-book-archive-djvu + +作者:[Seth Kenlon (Red Hat, Community Moderator)][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://www.fireengineering.com/articles/print/volume-56/issue-27/features/chief-john-kenlon-of-new-york-city.html +[2]: https://en.wikipedia.org/wiki/Comic_book_archive +[3]: https://comicbookplus.com/ +[4]: https://digitalcomicmuseum.com/ +[5]: https://wiki.gnome.org/Apps/Evince +[6]: https://okular.kde.org +[7]: https://f-droid.org/en/packages/org.sufficientlysecure.viewer/ +[8]: https://f-droid.org/en/packages/com.nkanaev.comics/ +[9]: http://djvu.org/ +[10]: http://djvu.js.org/ +[11]: https://github.com/RussCoder/djvujs +[12]: https://elpa.gnu.org/packages/djvu.html +[13]: http://djvu.sourceforge.net/djview4.html +[14]: http://djvu.org +[15]: http://djvu.sourceforge.net +[16]: https://www.imagemagick.org/ +[17]: https://en.wikipedia.org/wiki/Lisp_(programming_language) +[18]: /file/426061 +[19]: https://opensource.com/sites/default/files/uploads/outline.png (A DjVu with an outline as viewed in Okular) +[20]: https://sourceforge.net/projects/djvu/files/GSDjVu/1.10/ From 021cbf308981e16775adaacc82f6f4ed3e8d7563 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 18 Mar 2019 11:09:34 +0800 Subject: [PATCH 02/12] =?UTF-8?q?=E9=80=89=E9=A2=98:=2020190315=20Sweet=20?= =?UTF-8?q?Home=203D:=20An=20open=20source=20tool=20to=20help=20you=20deci?= =?UTF-8?q?de=20on=20your=20dream=20home=20sources/tech/20190315=20Sweet?= =?UTF-8?q?=20Home=203D-=20An=20open=20source=20tool=20to=20help=20you=20d?= =?UTF-8?q?ecide=20on=20your=20dream=20home.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...l to help you decide on your dream home.md | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 sources/tech/20190315 Sweet Home 3D- An open source tool to help you decide on your dream home.md diff --git a/sources/tech/20190315 Sweet Home 3D- An open source tool to help you decide on your dream home.md b/sources/tech/20190315 Sweet Home 3D- An open source tool to help you decide on your dream home.md new file mode 100644 index 0000000000..63c9e5f282 --- /dev/null +++ b/sources/tech/20190315 Sweet Home 3D- An open source tool to help you decide on your dream home.md @@ -0,0 +1,73 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Sweet Home 3D: An open source tool to help you decide on your dream home) +[#]: via: (https://opensource.com/article/19/3/tool-find-home) +[#]: author: (Jeff Macharyas (Community Moderator) ) + +Sweet Home 3D: An open source tool to help you decide on your dream home +====== + +Interior design application makes it easy to render your favorite house—real or imaginary. + +![Houses in a row][1] + +I recently accepted a new job in Virginia. Since my wife was working and watching our house in New York until it sold, it was my responsibility to go out and find a new house for us and our cat. A house that she would not see until we moved into it! + +I contracted with a real estate agent and looked at a few houses, taking many pictures and writing down illegible notes. At night, I would upload the photos into a Google Drive folder, and my wife and I would review them simultaneously over the phone while I tried to remember whether the room was on the right or the left, whether it had a fan, etc. + +Since this was a rather tedious and not very accurate way to present my findings, I went in search of an open source solution to better illustrate what our future dream house would look like that wouldn't hinge on my fuzzy memory and blurry photos. + +[Sweet Home 3D][2] did exactly what I wanted it to do. Sweet Home 3D is available on Sourceforge and released under the GNU General Public License. The [website][3] is very informative, and I was able to get it up and running in no time. Sweet Home 3D was developed by Paris-based Emmanuel Puybaret of eTeks. + +### Hanging the drywall + +I downloaded Sweet Home 3D onto my MacBook Pro and added a PNG version of a flat floorplan of a house to use as a background base map. + +From there, it was a simple matter of using the Rooms palette to trace the pattern and set the "real life" dimensions. After I mapped the rooms, I added the walls, which I could customize by color, thickness, height, etc. + +![Sweet Home 3D floorplan][5] + +Now that I had the "drywall" built, I downloaded various pieces of "furniture" from a large array that includes actual furniture as well as doors, windows, shelves, and more. Each item downloads as a ZIP file, so I created a folder of all my uncompressed pieces. I could customize each piece of furniture, and repetitive items, such as doors, were easy to copy-and-paste into place. + +Once I had all my walls and doors and windows in place, I used the application's 3D view to navigate through the house. Drawing upon my photos and memory, I made adjustments to all the objects until I had a close representation of the house. I could have spent more time modifying the house by adding textures, additional furniture, and objects, but I got it to the point I needed. + +![Sweet Home 3D floorplan][7] + +After I finished, I exported the plan as an OBJ file, which can be opened in a variety of programs, such as [Blender][8] and Preview on the Mac, to spin the house around and examine it from various angles. The Video function was most useful, as I could create a starting point, draw a path through the house, and record the "journey." I exported the video as a MOV file, which I opened and viewed on the Mac using QuickTime. + +My wife was able to see (almost) exactly what I saw, and we could even start arranging furniture ahead of the move, too. Now, all I have to do is load up the moving truck and head south. + +Sweet Home 3D will also prove useful at my new job. I was looking for a way to improve the map of the college's buildings and was planning to just re-draw it in [Inkscape][9] or Illustrator or something. However, since I have the flat map, I can use Sweet Home 3D to create a 3D version of the floorplan and upload it to our website to make finding the bathrooms so much easier! + +### An open source crime scene? + +An interesting aside: according to the [Sweet Home 3D blog][10], "the French Forensic Police Office (Scientific Police) recently chose Sweet Home 3D as a tool to design plans [to represent roads and crime scenes]. This is a concrete application of the recommendation of the French government to give the preference to free open source solutions." + +This is one more bit of evidence of how open source solutions are being used by citizens and governments to create personal projects, solve crimes, and build worlds. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/3/tool-find-home + +作者:[Jeff Macharyas (Community Moderator)][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/house_home_colors_live_building.jpg?itok=HLpsIfIL (Houses in a row) +[2]: https://sourceforge.net/projects/sweethome3d/ +[3]: http://www.sweethome3d.com/ +[4]: /file/426441 +[5]: https://opensource.com/sites/default/files/uploads/virginia-house-create-screenshot.png (Sweet Home 3D floorplan) +[6]: /file/426451 +[7]: https://opensource.com/sites/default/files/uploads/virginia-house-3d-screenshot.png (Sweet Home 3D floorplan) +[8]: https://opensource.com/article/18/5/blender-hotkey-cheat-sheet +[9]: https://opensource.com/article/19/1/inkscape-cheat-sheet +[10]: http://www.sweethome3d.com/blog/2018/12/10/customization_for_the_forensic_police.html From 02326a55c1ca79e5408cf829d3cba2727be0267b Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 18 Mar 2019 14:53:23 +0800 Subject: [PATCH 03/12] =?UTF-8?q?=E9=80=89=E9=A2=98:=2020190314=20Why=20fe?= =?UTF-8?q?edback,=20not=20metrics,=20is=20critical=20to=20DevOps=20source?= =?UTF-8?q?s/talk/20190314=20Why=20feedback,=20not=20metrics,=20is=20criti?= =?UTF-8?q?cal=20to=20DevOps.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ack, not metrics, is critical to DevOps.md | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 sources/talk/20190314 Why feedback, not metrics, is critical to DevOps.md diff --git a/sources/talk/20190314 Why feedback, not metrics, is critical to DevOps.md b/sources/talk/20190314 Why feedback, not metrics, is critical to DevOps.md new file mode 100644 index 0000000000..b2a79226ed --- /dev/null +++ b/sources/talk/20190314 Why feedback, not metrics, is critical to DevOps.md @@ -0,0 +1,84 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Why feedback, not metrics, is critical to DevOps) +[#]: via: (https://opensource.com/article/19/3/devops-feedback-not-metrics) +[#]: author: (Ranjith Varakantam (Red Hat) https://opensource.com/users/ranjith) + +Why feedback, not metrics, is critical to DevOps +====== + +Metrics can tell you some things, but not the most important things about how your products and teams are doing. + +![CICD with gears][1] + +Most managers and agile coaches depend on metrics over feedback from their teams, users, and even customers. In fact, quite a few use feedback and metrics synonymously, where they present feedback from teams or customers as a bunch of numbers or a graphical representation of those numbers. This is not only unfortunate, but it can be misleading as it presents only part of the story and not the entire truth. + +When it comes to two critical factors—how we manage or guide our teams and how we operate and influence the product that our teams are developing—few exceptional leaders and teams get it right. For one thing, it has become very easy to get your hands on data and metrics. Furthermore, it's still hard to get real feedback from teams and users. It requires significant investments and energy, and unless everyone understands the critical need for it, getting and giving feedback tends to be a low priority and keeps getting pushed to the back burner. + +### How to manage and guide teams + +With the acceptance of agile, a lot of teams have put a ridiculously high value on metrics, such as velocity, burndown charts, cumulative flow diagram (CFD), etc., instead of the value delivered by the team in each iteration or deployment. The focus is on the delivery or output produced without a clear understanding of how this relates to personal performance or implications for the project, product, or service. + +A few managers and agile coaches even abuse the true spirit of agile by misusing metrics to chastise or even penalize their teams. Instead of creating an environment of empowerment, they are slipping back into the command-and-control method where metrics are used to bully teams into submission. + +In our group, the best managers have weekly one-on-one meetings with every team member. These meetings not only give them a real pulse on team morale but also a profound understanding of the project and the decisions being made to move it forward. This weekly feedback loop also helps the team members communicate technical, functional, and even personal issues better. As a result, the team is much more cohesive in understanding the overall project needs and able to make decisions promptly. + +These leaders also skip levels—reaching out to team members two or three levels below them—and have frequent conversations with other group members who interact with their teams on a regular basis. These actions give the managers a holistic picture, which they couldn't get if they relied on feedback from one manager or lead, and help them identify any blind spots the leads and managers may have. + +These one-on-one meetings effectively transform a manager into a coach who has a close understanding of every team member. Like a good coach, these managers both give and receive feedback from the team members regarding the product, decision-making transparency, places where the team feels management is lagging, and areas that are being ignored. This empowers the teams by giving them a voice, not once in a while in an annual meeting or an annual survey, but every week. This is the level where DevOps teams should be in order to deliver their commitments successfully. + +This demands significant investments of time and energy, but the results more than justify it. The alternative is to rely on metrics and annual reviews and surveys, which has failed miserably. Unless we begin valuing feedback over metrics, we will keep seeing the metrics we want to see but failed projects and miserable team morale. + +### Influencing projects and product development + +We see similar behavior on the project or product side, with too few conversations with the users and developers and too much focus on metrics. Let's take the example of a piece of software that was released to the community or market, and the primary success metric is the number of downloads or installs. This can be deceiving for several reasons: + + 1. This product was packaged into another piece of software that users installed; even though the users are not even aware of your product's existence or purpose, it is still counted as a win and something the user needs. + + 2. The marketing team spent a huge budget promoting the product—and even offered an incentive to developers to download it. The _incentive_ drives the downloads, not user need or desire, but the metric is still considered a measure of success. + + 3. Software updates are counted as downloads, even when they are involuntary updates pushed rather than initiated by the user. This keeps bumping up the number, even though the user might have used it once, a year ago, for a specific task. + + + + +In these cases, the user automatically becomes a metric that's used to report how well the product is doing, just based on the fact it was downloaded and it's accepting updates, regardless of whether the user likes or uses the software. Instead, we should be focusing on actual usage of the product and the feedback these users have to offer us, rather than stopping short at the download numbers. + +The same holds true for SaaS products—instead of counting the number of signups, we should look at how often users use the product or service. Signups by themselves have little meaning, especially to the DevOps team where the focus is on getting constant feedback and striving for continuous improvements. + +### Gathering feedback + +So, why do we rely on metrics so much? My guess is they are easy to collect, and the marketing team is more interested in getting the product into the users' hands than evaluating how it is fairing. Unless the engineering team invests quite a bit of time in collecting feedback with tracing, which captures how often the program is executed and which components are used most often, it can be difficult to collect feedback. + +A big advantage of working in an open source community is that we first release the piece of software into a community where we can get feedback. Most open source enthusiasts take the time to log issues and bugs based on their experience with the product. If we can supplement this data with tracing, the team has an accurate record of how the product is used. + +Open as many channels of communication as possible–chat, email, Twitter, etc.—and allow users to choose their feedback channel. + +A few DevOps teams have integrated blue-green deployments, A/B testing, and canary releases to shorten the feedback loop. Setting up these frameworks it is not a trivial matter and calls for a huge upfront investment and constant updates to make them seamlessly work. But once everything is set up and data begins to flow, the team can act upon real feedback based on real user interactions with every new bit of software released. + +Most agile practitioners and lean movement activists push for a build-deploy-measure-learn cycle, and for this to happen, we need to collect feedback in addition to metrics. It might seem expensive and time consuming in the short term, but in the long run, it is a foolproof way of learning. + +### Proof that feedback pays off + +Whether it pertains to people or projects, it pays to rely on first-hand feedback rather than metrics, which are seldom interpreted in impartial ways. We have ample proof of this in other industries, where companies such as Zappos and the Virgin Group have done wonders for their business simply by listening to their customers. There is no reason we cannot follow suit, especially those of us working in open source communities. + +Feedback is the only effective way we can uncover our blind spots. Metrics are not of much help in this regard, as we can't find out what's wrong when we are dealing with unknowns. Blind spots can create serious gaps between reality and what we think we know. Feedback not only encourages continuous improvement, whether it's on a personal or a product level, but the simple act of listening and acting on it increases trust and loyalty. + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/3/devops-feedback-not-metrics + +作者:[Ranjith Varakantam (Red Hat)][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/ranjith +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/cicd_continuous_delivery_deployment_gears.png?itok=kVlhiEkc (CICD with gears) From cf8575f619eb6692482263e678bb966463d62850 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 18 Mar 2019 15:01:11 +0800 Subject: [PATCH 04/12] =?UTF-8?q?=E9=80=89=E9=A2=98:=2020190316=20Program?= =?UTF-8?q?=20the=20real=20world=20using=20Rust=20on=20Raspberry=20Pi=20so?= =?UTF-8?q?urces/tech/20190316=20Program=20the=20real=20world=20using=20Ru?= =?UTF-8?q?st=20on=20Raspberry=20Pi.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...e real world using Rust on Raspberry Pi.md | 141 ++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 sources/tech/20190316 Program the real world using Rust on Raspberry Pi.md diff --git a/sources/tech/20190316 Program the real world using Rust on Raspberry Pi.md b/sources/tech/20190316 Program the real world using Rust on Raspberry Pi.md new file mode 100644 index 0000000000..773fd1cc10 --- /dev/null +++ b/sources/tech/20190316 Program the real world using Rust on Raspberry Pi.md @@ -0,0 +1,141 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Program the real world using Rust on Raspberry Pi) +[#]: via: (https://opensource.com/article/19/3/physical-computing-rust-raspberry-pi) +[#]: author: (Rahul Thakoor https://opensource.com/users/rahul27) + +Program the real world using Rust on Raspberry Pi +====== + +rust_gpizero uses the Rust programming language to do physical computing on the Raspberry Pi. + +![][1] + +If you own a Raspberry Pi, chances are you may already have experimented with physical computing—writing code to interact with the real, physical world, like blinking some LEDs or [controlling a servo motor][2]. You may also have used [GPIO Zero][3], a Python library that provides a simple interface to GPIO devices from Raspberry Pi with a friendly Python API. GPIO Zero is developed by [Opensource.com][4] community moderator [Ben Nuttall][5]. + +I am working on [**rust_gpiozero**][6], a port of the awesome GPIO Zero library that uses the Rust programming language. It is still a work in progress, but it already includes some useful components. + +[Rust][7] is a systems programming language developed at Mozilla. It is focused on performance, reliability, and productivity. The Rust website has [great resources][8] if you'd like to learn more about it. + +### Getting started + +Before starting with rust_gpiozero, it's smart to have a basic grasp of the Rust programming language. I recommend working through at least the first three chapters in [The Rust Programming Language][9] book. + +I recommend [installing Rust][10] on your Raspberry Pi using [**rustup**][11]. Alternatively, you can set up a cross-compilation environment using [cross][12] (which works only on an x86_64 Linux host) or [this how-to][13]. + +After you've installed Rust, create a new Rust project by entering: + +``` +cargo new rust_gpiozero_demo +``` + +Add **rust_gpiozero** as a dependency (currently in v0.2.0) by adding the following to the dependencies section in your **Cargo.toml** file + +``` +rust_gpiozero = "0.2.0" +``` + +Next, blink an LED—the "hello world" of physical computing by modifying the **main.rs** file with the following: +``` +use rust_gpiozero::*; +use std::thread; +use std::time::Duration; + +fn main() { + // Create a new LED attached to Pin 17 + let led = LED::new(17); + + // Blink the LED 5 times + for _ in 0.. 5{ + led.on(); + thread::sleep(Duration::from_secs(1)); + led.off(); + thread::sleep(Duration::from_secs(1)); + } +} +``` + +rust_gpiozero provides an easier interface for blinking an LED. You can use the blink method, providing the number of seconds it should stay on and off. This simplifies the code to the following: +``` +use rust_gpiozero::*; +fn main() { + // Create a new LED attached to Pin 17 + let mut led = LED::new(17); + + // on_time = 2 secs, off_time=3 secs + led.blink(2.0,3.0); + + // prevent program from exiting immediately + led.wait(); +} +``` + +### Other components + +rust_gpiozero provides several components that are similar to GPIO Zero for controlling output and input devices. These include [LED][14], [Buzzer][15], [Motor][16], Pulse Width Modulation LED ([PWMLED][17]), [Servo][18], and [Button][19]. + +Support for other components, sensors, and devices will be added eventually. You can refer to the [documentation][20] for further usage information. + +### More resources + +rust_gpiozero is still a work in progress. If you need more resources for getting started with Rust on your Raspberry Pi, here are some useful links: + +#### Raspberry Pi Peripheral Access Library (RPPAL) + +Similar to GPIO Zero, which is based on the [RPi.GPIO][21] library, rust_gpiozero builds upon the awesome **[RPPAL][22]** library by [Rene van der Meer][23]. If you want more control for your projects using Rust, you should definitely try RPPAL. It has support for GPIO, Inter-Integrated Circuit (I 2C), hardware and software Pulse Width Modulation (PWM), and Serial Peripheral Interface (SPI). Universal asynchronous receiver-transmitter (UART) support is currently in development. + +#### Sense HAT support + +**[Sensehat-rs][24]** is a library by [Jonathan Pallant][25] ([@therealjpster][26]) that provides Rust support for the Raspberry Pi [Sense HAT][27] add-on board. Jonathan also has a [starter workshop][28] for using the library and he wrote a beginner's intro to use Rust on Raspberry Pi, "Read Sense HAT with Rust," in [Issue 73 of _The MagPi_][29] magazine. + +### Wrap Up + +Hopefully, this has inspired you to use the Rust programming language for physical computing on your Raspberry Pi. rust_gpiozero is a library which provides useful components such as LED, Buzzer, Motor, PWMLED, Servo, and Button. More features are planned and you can follow me on [twitter][30] or check out [my blog][31] to stay tuned. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/3/physical-computing-rust-raspberry-pi + +作者:[Rahul Thakoor][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003784_02_os.comcareers_os_rh2x.png?itok=jbRfXinl +[2]: https://projects.raspberrypi.org/en/projects/grandpa-scarer/4 +[3]: https://gpiozero.readthedocs.io/en/stable/# +[4]: http://Opensource.com +[5]: https://opensource.com/users/bennuttall +[6]: https://crates.io/crates/rust_gpiozero +[7]: https://www.rust-lang.org/ +[8]: https://www.rust-lang.org/learn +[9]: https://doc.rust-lang.org/book/ +[10]: https://www.rust-lang.org/tools/install +[11]: https://rustup.rs/ +[12]: https://github.com/rust-embedded/cross +[13]: https://github.com/kunerd/clerk/wiki/How-to-use-HD44780-LCD-from-Rust#setting-up-the-cross-toolchain +[14]: https://docs.rs/rust_gpiozero/0.2.0/rust_gpiozero/output_devices/struct.LED.html +[15]: https://docs.rs/rust_gpiozero/0.2.0/rust_gpiozero/output_devices/struct.Buzzer.html +[16]: https://docs.rs/rust_gpiozero/0.2.0/rust_gpiozero/output_devices/struct.Motor.html +[17]: https://docs.rs/rust_gpiozero/0.2.0/rust_gpiozero/output_devices/struct.PWMLED.html +[18]: https://docs.rs/rust_gpiozero/0.2.0/rust_gpiozero/output_devices/struct.Servo.html +[19]: https://docs.rs/rust_gpiozero/0.2.0/rust_gpiozero/input_devices/struct.Button.html +[20]: https://docs.rs/rust_gpiozero/ +[21]: https://pypi.org/project/RPi.GPIO/ +[22]: https://github.com/golemparts/rppal +[23]: https://twitter.com/golemparts +[24]: https://crates.io/crates/sensehat +[25]: https://github.com/thejpster +[26]: https://twitter.com/therealjpster +[27]: https://www.raspberrypi.org/products/sense-hat/ +[28]: https://github.com/thejpster/pi-workshop-rs/ +[29]: https://www.raspberrypi.org/magpi/issues/73/ +[30]: https://twitter.com/rahulthakoor +[31]: https://rahul-thakoor.github.io/ From 385fc136b563ef1efdb234aa1eb76895cadbf78c Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 18 Mar 2019 15:26:04 +0800 Subject: [PATCH 05/12] =?UTF-8?q?=E9=80=89=E9=A2=98:=2020190314=2014=20day?= =?UTF-8?q?s=20of=20celebrating=20the=20Raspberry=20Pi=20sources/tech/2019?= =?UTF-8?q?0314=2014=20days=20of=20celebrating=20the=20Raspberry=20Pi.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...14 days of celebrating the Raspberry Pi.md | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 sources/tech/20190314 14 days of celebrating the Raspberry Pi.md diff --git a/sources/tech/20190314 14 days of celebrating the Raspberry Pi.md b/sources/tech/20190314 14 days of celebrating the Raspberry Pi.md new file mode 100644 index 0000000000..42ea4ab03e --- /dev/null +++ b/sources/tech/20190314 14 days of celebrating the Raspberry Pi.md @@ -0,0 +1,77 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (14 days of celebrating the Raspberry Pi) +[#]: via: (https://opensource.com/article/19/3/happy-pi-day) +[#]: author: (Anderson Silva (Red Hat) https://opensource.com/users/ansilva) + +14 days of celebrating the Raspberry Pi +====== + +In the 14th and final article in our series on getting started with the Raspberry Pi, take a look back at all the things we've learned. + +![][1] + +**Happy Pi Day!** + +Every year on March 14th, we geeks celebrate Pi Day. In the way we abbreviate dates—MMDD—March 14 is written 03/14, which numerically reminds us of 3.14, or the first three numbers of [pi][2]. What many Americans don't realize is that virtually no other country in the world uses this [date format][3], so Pi Day pretty much only works in the US, though it is celebrated globally. + +Wherever you are in the world, let's celebrate the Raspberry Pi and wrap up this series by reviewing the topics we've covered in the past two weeks: + + * Day 1: [Which Raspberry Pi should you choose?][4] + * Day 2: [How to buy a Raspberry Pi][5] + * Day 3: [How to boot up a new Raspberry Pi][6] + * Day 4: [Learn Linux with the Raspberry Pi][7] + * Day 5: [5 ways to teach kids to program with Raspberry Pi][8] + * Day 6: [3 popular programming languages you can learn with Raspberry Pi][9] + * Day 7: [How to keep your Raspberry Pi updated][10] + * Day 8: [How to use your Raspberry Pi for entertainment][11] + * Day 9: [Play games on the Raspberry Pi][12] + * Day 10: [Let's get physical: How to use GPIO pins on the Raspberry Pi][13] + * Day 11: [Learn about computer security with the Raspberry Pi][14] + * Day 12: [Do advanced math with Mathematica on the Raspberry Pi][15] + * Day 13: [Contribute to the Raspberry Pi community][16] + + + +![Pi Day illustration][18] + +I'll end this series by thanking everyone who was brave enough to follow along and especially those who learned something from it during these past 14 days! I also want to encourage everyone to keep expanding their knowledge about the Raspberry Pi and all of the open (and closed) source technology that has been built around it. + +I also encourage you to learn about other cultures, philosophies, religions, and worldviews. What makes us human is this amazing (and sometimes amusing) ability that we have to adapt not only to external environmental circumstances—but also intellectual ones. + +No matter what you do, keep learning! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/3/happy-pi-day + +作者:[Anderson Silva (Red Hat)][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/raspberry-pi-juggle.png?itok=oTgGGSRA +[2]: https://www.piday.org/million/ +[3]: https://en.wikipedia.org/wiki/Date_format_by_country +[4]: https://opensource.com/article/19/3/which-raspberry-pi-choose +[5]: https://opensource.com/article/19/3/how-buy-raspberry-pi +[6]: https://opensource.com/article/19/3/how-boot-new-raspberry-pi +[7]: https://opensource.com/article/19/3/learn-linux-raspberry-pi +[8]: https://opensource.com/article/19/3/teach-kids-program-raspberry-pi +[9]: https://opensource.com/article/19/3/programming-languages-raspberry-pi +[10]: https://opensource.com/article/19/3/how-raspberry-pi-update +[11]: https://opensource.com/article/19/3/raspberry-pi-entertainment +[12]: https://opensource.com/article/19/3/play-games-raspberry-pi +[13]: https://opensource.com/article/19/3/gpio-pins-raspberry-pi +[14]: https://opensource.com/article/19/3/learn-about-computer-security-raspberry-pi +[15]: https://opensource.com/article/19/3/do-math-raspberry-pi +[16]: https://opensource.com/article/19/3/contribute-raspberry-pi-community +[17]: /file/426561 +[18]: https://opensource.com/sites/default/files/uploads/raspberrypi_14_piday.jpg (Pi Day illustration) From ff6080d1a675c1254d9b9017f4a98ba96ce59261 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 18 Mar 2019 15:37:45 +0800 Subject: [PATCH 06/12] =?UTF-8?q?=E9=80=89=E9=A2=98:=2020190315=20How=20To?= =?UTF-8?q?=20Parse=20And=20Pretty=20Print=20JSON=20With=20Linux=20Command?= =?UTF-8?q?line=20Tools=20sources/tech/20190315=20How=20To=20Parse=20And?= =?UTF-8?q?=20Pretty=20Print=20JSON=20With=20Linux=20Commandline=20Tools.m?= =?UTF-8?q?d?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Print JSON With Linux Commandline Tools.md | 264 ++++++++++++++++++ 1 file changed, 264 insertions(+) create mode 100644 sources/tech/20190315 How To Parse And Pretty Print JSON With Linux Commandline Tools.md diff --git a/sources/tech/20190315 How To Parse And Pretty Print JSON With Linux Commandline Tools.md b/sources/tech/20190315 How To Parse And Pretty Print JSON With Linux Commandline Tools.md new file mode 100644 index 0000000000..6cf53bdbca --- /dev/null +++ b/sources/tech/20190315 How To Parse And Pretty Print JSON With Linux Commandline Tools.md @@ -0,0 +1,264 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How To Parse And Pretty Print JSON With Linux Commandline Tools) +[#]: via: (https://www.ostechnix.com/how-to-parse-and-pretty-print-json-with-linux-commandline-tools/) +[#]: author: (EDITOR https://www.ostechnix.com/author/editor/) + +How To Parse And Pretty Print JSON With Linux Commandline Tools +====== + +**JSON** is a lightweight and language independent data storage format, easy to integrate with most programming languages and also easy to understand by humans, of course when properly formatted. The word JSON stands for **J** ava **S** cript **O** bject **N** otation, though it starts with JavaScript, and primarily used to exchange data between server and browser, but now being used in many fields including embedded systems. Here we’re going to parse and pretty print JSON with command line tools on Linux. It’s extremely useful for handling large JSON data in a shell scripts, or manipulating JSON data in a shell script. + +### What is pretty printing? + +The JSON data is structured to be somewhat more human readable. However in most cases, JSON data is stored in a single line, even without a line ending character. + +Obviously that’s not very convenient for reading and editing manually. + +That’s when pretty print is useful. The name is quite self explanatory, re-formatting the JSON text to be more legible by humans. This is known as **JSON pretty printing**. + +### Parse And Pretty Print JSON With Linux Commandline Tools + +JSON data could be parsed with command line text processors like **awk** , **sed** and **gerp**. In fact JSON.awk is an awk script to do that. However there are some dedicated tools for the same purpose. + + 1. **jq** or **jshon** , JSON parser for shell, both of them are quite useful. + + 2. Shell scripts like **JSON.sh** or **jsonv.sh** to parse JSON in bash, zsh or dash shell. + + 3. **JSON.awk** , JSON parser awk script. + + 4. Python modules like **json.tool**. + + 5. **underscore-cli** , Node.js and javascript based. + + + + +In this tutorial I’m focusing only on **jq** , which is quite powerful JSON parser for shells with advanced filtering and scripting capability. + +### JSON pretty printing + +JSON data could be in one and nearly illegible for humans, so to make it somewhat readable, JSON pretty printing is here. + +**Example:** A data from **jsonip.com** , to get external IP address in JSON format, use **curl** or **wget** tools like below. + +``` +$ wget -cq http://jsonip.com/ -O - +``` + +The actual data looks like this: + +``` +{"ip":"111.222.333.444","about":"/about","Pro!":"http://getjsonip.com"} +``` + +Now pretty print it with jq: + +``` +$ wget -cq http://jsonip.com/ -O - | jq '.' +``` + +This should look like below, after filtering the result with jq. + +``` +{ + + "ip": "111.222.333.444", + + "about": "/about", + + "Pro!": "http://getjsonip.com" + +} +``` + +The Same thing could be done with python **json.tool** module. Here is an example: + +``` +$ cat anything.json | python -m json.tool +``` + +This Python based solution should be fine for most users, but it’s not that useful where Python is not pre-installed or could not be installed, like on embedded systems. + +However the json.tool python module has a distinct advantage, it’s cross platform. So, you can use it seamlessly on Windows, Linux or mac OS. + + +### How to parse JSON with jq + +First, you need to install jq, it’s already picked up by most GNU/Linux distributions, install it with their respective package installer commands. + +On Arch Linux: + +``` +$ sudo pacman -S jq +``` + +On Debian, Ubuntu, Linux Mint: + +``` +$ sudo apt-get install jq +``` + +On Fedora: + +``` +$ sudo dnf install jq +``` + +On openSUSE: + +``` +$ sudo zypper install jq +``` + +For other OS or platforms, see the [official installation instructions][1]. + +**Basic filters and identifiers of jq** + +jq could read the JSON data either from **stdin** or a **file**. You’ve to use both depending on the situation. + +The single symbol of **.** is the most basic filter. These filters are also called as **object identifier-index**. Using a single **.** along with jq basically pretty prints the input JSON file. + +**Single quotes** – You don’t have to use the single quote always. But if you’re combining several filters in a single line, then you must use them. + +**Double quotes** – You’ve to enclose any special character like **@** , **#** , **$** within two double quotes, like this example, **jq .foo.”@bar”** + +**Raw data print** – For any reason, if you need only the final parsed data, not enclosed within a double quote, use the -r flag with the jq command, like this. **– jq -r .foo.bar**. + +**Parsing specific data** + +To filter out a specific part of JSON, you’ve to look into the pretty printed JSON file’s data hierarchy. + +An example of JSON data, from Wikipedia: + +``` +{ + + "firstName": "John", + + "lastName": "Smith", + + "age": 25, + + "address": { + + "streetAddress": "21 2nd Street", + + "city": "New York", + + "state": "NY", + + "postalCode": "10021" + +}, + + "phoneNumber": [ + +{ + + "type": "home", + + "number": "212 555-1234" + +}, + +{ + + "type": "fax", + + "number": "646 555-4567" + +} + +], + + "gender": { + + "type": "male" + + } + +} +``` + +I’m going to use this JSON data as an example in this tutorial, saved this as **sample.json**. + +Let’s say I want to filter out the address from sample.json file. So the command should be like: + +``` +$ jq .address sample.json +``` + +**Sample output:** + +``` +{ + + "streetAddress": "21 2nd Street", + + "city": "New York", + + "state": "NY", + + "postalCode": "10021" + +} +``` + +Again let’s say I want the postal code, then I’ve to add another **object identifier-index** , i.e. another filter. + +``` +$ cat sample.json | jq .address.postalCode +``` + +Also note that the **filters are case sensitive** and you’ve to use the exact same string to get something meaningful output instead of null. + +**Parsing elements from JSON array** + +Elements of JSON array are enclosed within square brackets, undoubtedly quite versatile to use. + +To parse elements from a array, you’ve to use the **[]identifier** along with other object identifier-index. + +In this sample JSON data, the phone numbers are stored inside an array, to get all the contents from this array, you’ve to use only the brackets, like this example. + +``` +$ jq .phoneNumber[] sample.json +``` + +Let’s say you just want the first element of the array, then use the array object numbers starting for 0, for the first item, use **[0]** , for the next items, it should be incremented by one each step. + +``` +$ jq .phoneNumber[0] sample.json +``` + +**Scripting examples** + +Let’s say I want only the the number for home, not entire JSON array data. Here’s when scripting within jq command comes handy. + +``` +$ cat sample.json | jq -r '.phoneNumber[] | select(.type == "home") | .number' +``` + +Here first I’m piping the results of one filer to another, then using the select attribute to select a particular type of data, again piping the result to another filter. + +Explaining every type of jq filters and scripting is beyond the scope and purpose of this tutorial. It’s highly suggested to read the JQ manual for better understanding given below. + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-parse-and-pretty-print-json-with-linux-commandline-tools/ + +作者:[EDITOR][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/editor/ +[b]: https://github.com/lujun9972 +[1]: https://stedolan.github.io/jq/download/ From b42b89b05c67be8568f886b5fbe78d874c5f929e Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 18 Mar 2019 15:41:15 +0800 Subject: [PATCH 07/12] =?UTF-8?q?=E9=80=89=E9=A2=98:=2020190315=20How=20To?= =?UTF-8?q?=20Navigate=20Inside=20A=20Directory/Folder=20In=20Linux=20With?= =?UTF-8?q?out=20CD=20Command=3F=20sources/tech/20190315=20How=20To=20Navi?= =?UTF-8?q?gate=20Inside=20A=20Directory-Folder=20In=20Linux=20Without=20C?= =?UTF-8?q?D=20Command.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...tory-Folder In Linux Without CD Command.md | 169 ++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 sources/tech/20190315 How To Navigate Inside A Directory-Folder In Linux Without CD Command.md diff --git a/sources/tech/20190315 How To Navigate Inside A Directory-Folder In Linux Without CD Command.md b/sources/tech/20190315 How To Navigate Inside A Directory-Folder In Linux Without CD Command.md new file mode 100644 index 0000000000..d0d21adeb8 --- /dev/null +++ b/sources/tech/20190315 How To Navigate Inside A Directory-Folder In Linux Without CD Command.md @@ -0,0 +1,169 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How To Navigate Inside A Directory/Folder In Linux Without CD Command?) +[#]: via: (https://www.2daygeek.com/navigate-switch-directory-without-using-cd-command-in-linux/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +How To Navigate Inside A Directory/Folder In Linux Without CD Command? +====== + +As everybody know that we can’t navigate inside a directory in Linux without CD command. + +Yes that’s true but we have the Linux built-in command called `shopt` that help us to solve this issue. + +[shopt][1] is a shell builtin command to set and unset various bash shell options, which is installed so, we no need to install it again. + +Yes we can navigate inside a directory without CD command after enabling this option. + +We will show you, how to do this in this article. This is a small tweak but it’s very useful for newbies who all are moving from Windows to Linux. + +This is not useful for Linux administrator because we won’t navigate to the directory without CD command, as we had a good practices on this. + +If you are trying to navigate a directory/folder in Linux without cd command, you will be getting the following error message. This is common in Linux. + +``` +$ Documents/ +bash: Documents/: Is a directory +``` + +To achieve this, we need to append the following values in a user `.bashrc` file. + +### What Is the .bashrc File? + +The “.bashrc” file is a shell script which is run every time a user opens a new shell in interactive mode. + +You can add any command in that file that you want to type at the command prompt. + +The .bashrc file itself contains a series of configurations for the terminal session. This includes setting up or enabling: colouring, completion, the shell history, command aliases and more. + +``` +$ vi ~/.bashrc + +shopt -s autocd +``` + +Run the following command to make the changes to take effect. + +``` +$ source ~/.bashrc +``` + +We have done all the configuration. Simple do the testing on this to confirm whether this working or not. + +``` +$ Documents/ +cd -- Documents/ + +$ daygeek/ +cd -- daygeek/ + +$ /home/daygeek/Documents/daygeek +cd -- /home/daygeek/Documents/daygeek + +$ pwd +/home/daygeek/Documents/daygeek +``` + +![][3] +Yes, it’s working fine as expected. + +However, it’s working fine in `fish shell` without making any changes in the `.bashrc` file. +![][4] + +If you would like to perform this action for temporarily then use the following commands (set/unset). This will go away when you reboot the system. + +``` +# shopt -s autocd + +# shopt | grep autocd +autocd on + +# shopt -u autocd + +# shopt | grep autocd +autocd off +``` + +shopt command is offering so many other options and if you want to verify those, run the following command. + +``` +$ shopt +autocd on +assoc_expand_once off +cdable_vars off +cdspell on +checkhash off +checkjobs off +checkwinsize on +cmdhist on +compat31 off +compat32 off +compat40 off +compat41 off +compat42 off +compat43 off +compat44 off +complete_fullquote on +direxpand off +dirspell off +dotglob off +execfail off +expand_aliases on +extdebug off +extglob off +extquote on +failglob off +force_fignore on +globasciiranges on +globstar off +gnu_errfmt off +histappend on +histreedit off +histverify off +hostcomplete on +huponexit off +inherit_errexit off +interactive_comments on +lastpipe off +lithist off +localvar_inherit off +localvar_unset off +login_shell off +mailwarn off +no_empty_cmd_completion off +nocaseglob off +nocasematch off +nullglob off +progcomp on +progcomp_alias off +promptvars on +restricted_shell off +shift_verbose off +sourcepath on +xpg_echo off +``` + +I had found few other utilities, that are help us to navigate a directory faster in Linux compared with cd command. + +Those are pushd, popd, up shell script and bd utility. We will cover these topics in the upcoming articles. + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/navigate-switch-directory-without-using-cd-command-in-linux/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html +[2]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[3]: https://www.2daygeek.com/wp-content/uploads/2019/03/navigate-switch-directory-without-using-cd-command-in-linux-1.jpg +[4]: https://www.2daygeek.com/wp-content/uploads/2019/03/navigate-switch-directory-without-using-cd-command-in-linux-2.jpg From 01920a58fb699ec57de4be30ed3380ac3e6e5fa7 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 18 Mar 2019 16:01:54 +0800 Subject: [PATCH 08/12] =?UTF-8?q?=E9=80=89=E9=A2=98:=2020170414=205=20proj?= =?UTF-8?q?ects=20for=20Raspberry=20Pi=20at=20home=20sources/tech/20170414?= =?UTF-8?q?=205=20projects=20for=20Raspberry=20Pi=20at=20home.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...414 5 projects for Raspberry Pi at home.md | 146 ++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 sources/tech/20170414 5 projects for Raspberry Pi at home.md diff --git a/sources/tech/20170414 5 projects for Raspberry Pi at home.md b/sources/tech/20170414 5 projects for Raspberry Pi at home.md new file mode 100644 index 0000000000..37c9fde3db --- /dev/null +++ b/sources/tech/20170414 5 projects for Raspberry Pi at home.md @@ -0,0 +1,146 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (5 projects for Raspberry Pi at home) +[#]: via: (https://opensource.com/article/17/4/5-projects-raspberry-pi-home) +[#]: author: (Ben Nuttall (Community Moderator) ) + +5 projects for Raspberry Pi at home +====== + +![5 projects for Raspberry Pi at home][1] + +The [Raspberry Pi][2] computer can be used in all kinds of settings and for a variety of purposes. It obviously has a place in education for helping students with learning programming and maker skills in the classroom and the hackspace, and it has plenty of industrial applications in the workplace and in factories. I'm going to introduce five projects you might want to build in your own home. + +### Media center + +One of the most common uses for Raspberry Pi in people's homes is behind the TV running media center software serving multimedia files. It's easy to set this up, and the Raspberry Pi provides plenty of GPU (Graphics Processing Unit) power to render HD TV shows and movies to your big screen TV. [Kodi][3] (formerly XBMC) on a Raspberry Pi is a great way to playback any media you have on a hard drive or network-attached storage. You can also install a plugin to play YouTube videos. + +There are a few different options available, most prominently [OSMC][4] (Open Source Media Center) and [LibreELEC][5], both based on Kodi. They both perform well at playing media content, but OSMC has a more visually appearing user interface, while LibreElec is much more lightweight. All you have to do is choose a distribution, download the image and install on an SD card (or just use [NOOBS][6]), boot it up, and you're ready to go. + +![LibreElec ][7] + +LibreElec; Raspberry Pi Foundation, CC BY-SA + +![OSMC][8] + +OSMC.tv, Copyright, Used with permission + +Before proceeding you'll need to decide [w][9][hich Raspberry Pi model to use][9]. These distributions will work on any Pi (1, 2, 3, or Zero), and video playback will essentially be matched on each of these. Apart from the Pi 3 (and Zero W) having built-in Wi-Fi, the only noticeable difference is the reaction speed of the user interface, which will be much faster on a Pi 3. A Pi 2 will not be much slower, so that's fine if you don't need Wi-Fi, but the Pi 3 will noticeably outperform the Pi 1 and Zero when it comes to flicking through the menus. + +### SSH gateway + +If you want to be able to access computers and devices on your home network from outside over the internet, you have to open up ports on those devices to allow outside traffic. Opening ports to the internet is a security risk, meaning you're always at risk of attack, misuse, or any kind of unauthorized access. However, if you install a Raspberry Pi on your network and set up port forwarding to allow only SSH access to that Pi, you can use that as a secure gateway to hop onto other Pis and PCs on the network. + +Most routers allow you to configure port-forwarding rules. You'll need to give your Pi a fixed internal IP address and set up port 22 on your router to map to port 22 on your Raspberry Pi. If your ISP provides you with a static IP address, you'll be able to SSH into it with this as the host address (for example, **ssh pi@123.45.56.78** ). If you have a domain name, you can configure a subdomain to point to this IP address, so you don't have to remember it (for example, **ssh[pi@home.mydomain.com][10]** ). + +![][11] + +However, if you're going to expose a Raspberry Pi to the internet, you should be very careful not to put your network at risk. There are a few simple procedures you can follow to make it sufficiently secure: + +1\. Most people suggest you change your login password (which makes sense, seeing as the default password “raspberry” is well known), but this does not protect against brute-force attacks. You could change your password and add a two-factor authentication (so you need your password _and_ a time-dependent passcode generated by your phone), which is more secure. However, I believe the best way to secure your Raspberry Pi from intruders is to [disable][12] [“password authentication”][12] in your SSH configuration, so you allow only SSH key access. This means that anyone trying to SSH in by guessing your password will never succeed. Only with your private SSH key can anyone gain access. Similarly, most people suggest changing the SSH port from the default 22 to something unexpected, but a simple [Nmap][13] of your IP address will reveal your true SSH port. + +2\. Ideally, you would not run much in the way of other software on this Pi, so you don't end up accidentally exposing anything else. If you want to run other software, you might be better running it on another Pi on the network that is not exposed to the internet. Ensure that you keep your packages up to date by upgrading regularly, particularly the **openssh-server** package, so that any security vulnerabilities are patched. + +3\. Install [sshblack][14] or [fail2ban][15] to blacklist any users who seem to be acting maliciously, such as attempting to brute force your SSH password. + +Once you've secured your Raspberry Pi and put it online, you'll be able to log in to your network from anywhere in the world. Once you're on your Raspberry Pi, you can SSH into other devices on the network using their local IP address (for example, 192.168.1.31). If you have passwords on these devices, just use the password. If they're also SSH-key-only, you'll need to ensure your key is forwarded over SSH by using the **-A** flag: **ssh -A pi@123.45.67.89**. + +### CCTV / pet camera + +Another great home project is to set up a camera module to take photos or stream video, capture and save files, or streamed internally or to the internet. There are many reasons you might want to do this, but two common use cases are for a homemade security camera or to monitor a pet. + +The [Raspberry Pi camera module][16] is a brilliant accessory. It provides full HD photo and video, lots of advanced configuration, and is [easy to][17] [program][17]. The [infrared camera][18] is ideal for this kind of use, and with an infrared LED (which the Pi can control) you can see in the dark! + +If you want to take still images on a regular basis to keep an eye on things, you can just write a short [Python][19] script or use the command line tool [raspistill][20], and schedule it to recur in [Cron][21]. You might want to have it save them to [Dropbox][22] or another web service, upload them to a web server, or you can even create a [web app][23] to display them. + +If you want to stream video, internally or externally, that's really easy, too. A simple MJPEG (Motion JPEG) example is provided in the [picamera documentation][24] (under “web streaming”). Just download or copy that code into a file, run it and visit the Pi's IP address at port 8000, and you'll see your camera's output live. + +A more advanced streaming project, [pistreaming][25], is available, which uses [JSMpeg][26] (a JavaScript video player) with the web server and a websocket for the camera stream running separately. This method is more performant and is just as easy to get running as the previous example, but there is more code involved and if set up to stream on the internet, requires you to open two ports. + +Once you have web streaming set up, you can position the camera where you want it. I have one set up to keep an eye on my pet tortoise: + +![Tortoise ][27] + +Ben Nuttall, CC BY-SA + +If you want to be able to control where the camera actually points, you can do so using servos. A neat solution is to use Pimoroni's [Pan-Tilt HAT][28], which allows you to move the camera easily in two dimensions. To integrate this with pistreaming, see the project's [pantilthat branch][29]. + +![Pan-tilt][30] + +Pimoroni.com, Copyright, Used with permission + +If you want to position your Pi outside, you'll need a waterproof enclosure and some way of getting power to the Pi. PoE (Power-over-Ethernet) cables can be a good way of achieving this. + +### Home automation and IoT + +It's 2017 and there are internet-connected devices everywhere, especially in the home. Our lightbulbs have Wi-Fi, our toasters are smarter than they used to be, and our tea kettles are at risk of attack from Russia. As long as you keep your devices secure, or don't connect them to the internet if they don't need to be, then you can make great use of IoT devices to automate tasks around the home. + +There are plenty of services you can buy or subscribe to, like Nest Thermostat or Philips Hue lightbulbs, which allow you to control your heating or your lighting from your phone, respectively—whether you're inside or away from home. You can use a Raspberry Pi to boost the power of these kinds of devices by automating interactions with them according to a set of rules involving timing or even sensors. One thing you can't do with Philips Hue is have the lights come on when you enter the room, but with a Raspberry Pi and a motion sensor, you can use a Python API to turn on the lights. Similarly, you can configure your Nest to turn on the heating when you're at home, but what if you only want it to turn on if there's at least two people home? Write some Python code to check which phones are on the network and if there are at least two, tell the Nest to turn on the heat. + +You can do a great deal more without integrating with existing IoT devices and with only using simple components. A homemade burglar alarm, an automated chicken coop door opener, a night light, a music box, a timed heat lamp, an automated backup server, a print server, or whatever you can imagine. + +### Tor proxy and blocking ads + +Adafruit's [Onion Pi][31] is a [Tor][32] proxy that makes your web traffic anonymous, allowing you to use the internet free of snoopers and any kind of surveillance. Follow Adafruit's tutorial on setting up Onion Pi and you're on your way to a peaceful anonymous browsing experience. + +![Onion-Pi][33] + +Onion-pi from Adafruit, Copyright, Used with permission + +![Pi-hole][34]You can install a Raspberry Pi on your network that intercepts all web traffic and filters out any advertising. Simply download the [Pi-hole][35] software onto the Pi, and all devices on your network will be ad-free (it even blocks in-app ads on your mobile devices). + +There are plenty more uses for the Raspberry Pi at home. What do you use Raspberry Pi for at home? What do you want to use it for? + +Let us know in the comments. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/17/4/5-projects-raspberry-pi-home + +作者:[Ben Nuttall (Community Moderator)][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/raspberry_pi_home_automation.png?itok=2TnmJpD8 (5 projects for Raspberry Pi at home) +[2]: https://www.raspberrypi.org/ +[3]: https://kodi.tv/ +[4]: https://osmc.tv/ +[5]: https://libreelec.tv/ +[6]: https://www.raspberrypi.org/downloads/noobs/ +[7]: https://opensource.com/sites/default/files/libreelec_0.png (LibreElec ) +[8]: https://opensource.com/sites/default/files/osmc.png (OSMC) +[9]: https://opensource.com/life/16/10/which-raspberry-pi-should-you-choose-your-project +[10]: mailto:pi@home.mydomain.com +[11]: https://opensource.com/sites/default/files/resize/screenshot_from_2017-04-07_15-13-01-700x380.png +[12]: http://stackoverflow.com/questions/20898384/ssh-disable-password-authentication +[13]: https://nmap.org/ +[14]: http://www.pettingers.org/code/sshblack.html +[15]: https://www.fail2ban.org/wiki/index.php/Main_Page +[16]: https://www.raspberrypi.org/products/camera-module-v2/ +[17]: https://opensource.com/life/15/6/raspberry-pi-camera-projects +[18]: https://www.raspberrypi.org/products/pi-noir-camera-v2/ +[19]: http://picamera.readthedocs.io/ +[20]: https://www.raspberrypi.org/documentation/usage/camera/raspicam/raspistill.md +[21]: https://www.raspberrypi.org/documentation/linux/usage/cron.md +[22]: https://github.com/RZRZR/plant-cam +[23]: https://github.com/bennuttall/bett-bot +[24]: http://picamera.readthedocs.io/en/release-1.13/recipes2.html#web-streaming +[25]: https://github.com/waveform80/pistreaming +[26]: http://jsmpeg.com/ +[27]: https://opensource.com/sites/default/files/tortoise.jpg (Tortoise) +[28]: https://shop.pimoroni.com/products/pan-tilt-hat +[29]: https://github.com/waveform80/pistreaming/tree/pantilthat +[30]: https://opensource.com/sites/default/files/pan-tilt.gif (Pan-tilt) +[31]: https://learn.adafruit.com/onion-pi/overview +[32]: https://www.torproject.org/ +[33]: https://opensource.com/sites/default/files/onion-pi.jpg (Onion-Pi) +[34]: https://opensource.com/sites/default/files/resize/pi-hole-250x250.png (Pi-hole) +[35]: https://pi-hole.net/ From 7594b0c11d7d6b0c65fbfb33561be7a57cfd1e58 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 18 Mar 2019 16:04:39 +0800 Subject: [PATCH 09/12] =?UTF-8?q?=E9=80=89=E9=A2=98:=2020180919=20Host=20y?= =?UTF-8?q?our=20own=20cloud=20with=20Raspberry=20Pi=20NAS=20sources/tech/?= =?UTF-8?q?20180919=20Host=20your=20own=20cloud=20with=20Raspberry=20Pi=20?= =?UTF-8?q?NAS.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...st your own cloud with Raspberry Pi NAS.md | 128 ++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 sources/tech/20180919 Host your own cloud with Raspberry Pi NAS.md diff --git a/sources/tech/20180919 Host your own cloud with Raspberry Pi NAS.md b/sources/tech/20180919 Host your own cloud with Raspberry Pi NAS.md new file mode 100644 index 0000000000..5d34623e8c --- /dev/null +++ b/sources/tech/20180919 Host your own cloud with Raspberry Pi NAS.md @@ -0,0 +1,128 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Host your own cloud with Raspberry Pi NAS) +[#]: via: (https://opensource.com/article/18/9/host-cloud-nas-raspberry-pi?extIdCarryOver=true) +[#]: author: (Manuel Dewald https://opensource.com/users/ntlx) + +Host your own cloud with Raspberry Pi NAS +====== + +Protect and secure your data with a self-hosted cloud powered by your Raspberry Pi. + +![Tree clouds][1] + +In the first two parts of this series, we discussed the [hardware and software fundamentals][2] for building network-attached storage (NAS) on a Raspberry Pi. We also put a proper [backup strategy][3] in place to secure the data on the NAS. In this third part, we will talk about a convenient way to store, access, and share your data with [Nextcloud][4]. + +![Raspberry Pi NAS infrastructure with Nextcloud][6] + +### Prerequisites + +To use Nextcloud conveniently, you have to meet a few prerequisites. First, you should have a domain you can use for the Nextcloud instance. For the sake of simplicity in this how-to, we'll use **nextcloud.pi-nas.com**. This domain should be directed to your Raspberry Pi. If you want to run it on your home network, you probably need to set up dynamic DNS for this domain and enable port forwarding of ports 80 and 443 (if you go for an SSL setup, which is highly recommended; otherwise port 80 should be sufficient) from your router to the Raspberry Pi. + +You can automate dynamic DNS updates from the Raspberry Pi using [ddclient][7]. + +### Install Nextcloud + +To run Nextcloud on your Raspberry Pi (using the setup described in the [first part][2] of this series), install the following packages as dependencies to Nextcloud using **apt**. + +``` +sudo apt install unzip wget php apache2 mysql-server php-zip php-mysql php-dom php-mbstring php-gd php-curl +``` + +The next step is to download Nextcloud. [Get the latest release's URL][8] and copy it to download via **wget** on the Raspberry Pi. In the first article in this series, we attached two disk drives to the Raspberry Pi, one for current data and one for backups. Install Nextcloud on the data drive to make sure data is backed up automatically every night. +``` +sudo mkdir -p /nas/data/nextcloud +sudo chown pi /nas/data/nextcloud +cd /nas/data/ +wget -O /nas/data/nextcloud.zip +unzip nextcloud.zip +sudo ln -s /nas/data/nextcloud /var/www/nextcloud +sudo chown -R www-data:www-data /nas/data/nextcloud +``` + +When I wrote this, the latest release (as you see in the code above) was 14. Nextcloud is under heavy development, so you may find a newer version when installing your copy of Nextcloud onto your Raspberry Pi. + +### Database setup + +When we installed Nextcloud above, we also installed MySQL as a dependency to use it for all the metadata Nextcloud generates (for example, the users you create to access Nextcloud). If you would rather use a Postgres database, you'll need to adjust some of the modules installed above. + +To access the MySQL database as root, start the MySQL client as root: + +``` +sudo mysql +``` + +This will open a SQL prompt where you can insert the following commands—substituting the placeholder with the password you want to use for the database connection—to create a database for Nextcloud. +``` +CREATE USER nextcloud IDENTIFIED BY ''; +CREATE DATABASE nextcloud; +GRANT ALL ON nextcloud.* TO nextcloud; +``` + + +You can exit the SQL prompt by pressing **Ctrl+D** or entering **quit**. + +### Web server configuration + +Nextcloud can be configured to run using Nginx or other web servers, but for this how-to, I decided to go with the Apache web server on my Raspberry Pi NAS. (Feel free to try out another alternative and let me know if you think it performs better.) + +To set it up, configure a virtual host for the domain you created for your Nextcloud instance **nextcloud.pi-nas.com**. To create a virtual host, create the file **/etc/apache2/sites-available/001-nextcloud.conf** with content similar to the following. Make sure to adjust the ServerName to your domain and paths, if you didn't use the ones suggested earlier in this series. +``` + +ServerName nextcloud.pi-nas.com +ServerAdmin [admin@pi-nas.com][9] +DocumentRoot /var/www/nextcloud/ + + +AllowOverride None + + +``` + + +To enable this virtual host, run the following two commands. +``` +a2ensite 001-nextcloud +sudo systemctl reload apache2 +``` + + +With this configuration, you should now be able to reach the web server with your domain via the web browser. To secure your data, I recommend using HTTPS instead of HTTP to access Nextcloud. A very easy (and free) way is to obtain a [Let's Encrypt][10] certificate with [Certbot][11] and have a cron job automatically refresh it. That way you don't have to mess around with self-signed or expiring certificates. Follow Certbot's simple how-to [instructions to install it on your Raspberry Pi][12]. During Certbot configuration, you can even decide to automatically forward HTTP to HTTPS, so visitors to **** will be redirected to ****. Please note, if your Raspberry Pi is running behind your home router, you must have port forwarding enabled for ports 443 and 80 to obtain Let's Encrypt certificates. + +### Configure Nextcloud + +The final step is to visit your fresh Nextcloud instance in a web browser to finish the configuration. To do so, open your domain in a browser and insert the database details from above. You can also set up your first Nextcloud user here, the one you can use for admin tasks. By default, the data directory should be inside the Nextcloud folder, so you don't need to change anything for the backup mechanisms from the [second part of this series][3] to pick up the data stored by users in Nextcloud. + +Afterward, you will be directed to your Nextcloud and can log in with the admin user you created previously. To see a list of recommended steps to ensure a performant and secure Nextcloud installation, visit the Basic Settings tab in the Settings page (in our example: settings/admin) and see the Security & Setup Warnings section. + +Congratulations! You've set up your own Nextcloud powered by a Raspberry Pi. Go ahead and [download a Nextcloud client][13] from the Nextcloud page to sync data with your client devices and access it offline. Mobile clients even provide features like instant upload of pictures you take, so they'll automatically sync to your desktop PC without wondering how to get them there. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/host-cloud-nas-raspberry-pi?extIdCarryOver=true + +作者:[Manuel Dewald][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/ntlx +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/life_tree_clouds.png?itok=b_ftihhP (Tree clouds) +[2]: https://opensource.com/article/18/7/network-attached-storage-Raspberry-Pi +[3]: https://opensource.com/article/18/8/automate-backups-raspberry-pi +[4]: https://nextcloud.com/ +[5]: /file/409336 +[6]: https://opensource.com/sites/default/files/uploads/nas_part3.png (Raspberry Pi NAS infrastructure with Nextcloud) +[7]: https://sourceforge.net/p/ddclient/wiki/Home/ +[8]: https://nextcloud.com/install/#instructions-server +[9]: mailto:admin@pi-nas.com +[10]: https://letsencrypt.org/ +[11]: https://certbot.eff.org/ +[12]: https://certbot.eff.org/lets-encrypt/debianother-apache +[13]: https://nextcloud.com/install/#install-clients From c36858753eaeadf55e7ba651713fa17ef810b2ff Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 18 Mar 2019 19:35:07 +0800 Subject: [PATCH 10/12] =?UTF-8?q?=E9=80=89=E9=A2=98:=2020190318=20Install?= =?UTF-8?q?=20MEAN.JS=20Stack=20In=20Ubuntu=2018.04=20LTS=20sources/tech/2?= =?UTF-8?q?0190318=20Install=20MEAN.JS=20Stack=20In=20Ubuntu=2018.04=20LTS?= =?UTF-8?q?.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...stall MEAN.JS Stack In Ubuntu 18.04 LTS.md | 266 ++++++++++++++++++ 1 file changed, 266 insertions(+) create mode 100644 sources/tech/20190318 Install MEAN.JS Stack In Ubuntu 18.04 LTS.md diff --git a/sources/tech/20190318 Install MEAN.JS Stack In Ubuntu 18.04 LTS.md b/sources/tech/20190318 Install MEAN.JS Stack In Ubuntu 18.04 LTS.md new file mode 100644 index 0000000000..925326e0d7 --- /dev/null +++ b/sources/tech/20190318 Install MEAN.JS Stack In Ubuntu 18.04 LTS.md @@ -0,0 +1,266 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Install MEAN.JS Stack In Ubuntu 18.04 LTS) +[#]: via: (https://www.ostechnix.com/install-mean-js-stack-ubuntu/) +[#]: author: (sk https://www.ostechnix.com/author/sk/) + +Install MEAN.JS Stack In Ubuntu 18.04 LTS +====== + +![Install MEAN.JS Stack][1] + +**MEAN.JS** is an Open-Source, full-Stack JavaScript solution for building fast, and robust web applications. **MEAN.JS** stack consists of **MongoDB** (NoSQL database), **ExpressJs** (NodeJS server-side application web framework), **AngularJS** (Client-side web application framework), and **Node.js** (JavaScript run-time, popular for being a web server platform). In this tutorial, we will be discussing how to install MEAN.JS stack in Ubuntu. This guide was tested in Ubuntu 18.04 LTS server. However, it should work on other Ubuntu versions and Ubuntu variants. + +### Install MongoDB + +**MongoDB** is a free, cross-platform, open source, NoSQL document-oriented database. To install MongoDB on your Ubuntu system, refer the following guide: + + * [**Install MongoDB Community Edition In Linux**][2] + + + +### Install Node.js + +**NodeJS** is an open source, cross-platform, and lightweight JavaScript run-time environment that can be used to build scalable network applications. + +To install NodeJS on your system, refer the following guide: + + * [**How To Install NodeJS On Linux**][3] + + + +After installing, MongoDB, and Node.js, we need to install the other required components such as **Yarn** , **Grunt** , and **Gulp** for MEAN.js stack. + +### Install Yarn package manager + +Yarn is a package manager used by MEAN.JS stack to manage front-end packages. + +To install Bower, run the following command: + +``` +$ npm install -g yarn +``` + +### Install Grunt Task Runner + +Grunt Task Runner is used to to automate the development process. + +To install Grunt, run: + +``` +$ npm install -g grunt-cli +``` + +To verify if Yarn and Grunt have been installed, run: + +``` +$ npm list -g --depth=0 /home/sk/.nvm/versions/node/v11.11.0/lib ├── [email protected] ├── [email protected] └── [email protected] +``` + +### Install Gulp Task Runner (Optional) + +This is optional. You can use Gulp instead of Grunt. To install Gulp Task Runner, run the following command: + +``` +$ npm install -g gulp +``` + +We have installed all required prerequisites. Now, let us deploy MEAN.JS stack. + +### Download and Install MEAN.JS Stack + +Install Git if it is not installed already: + +``` +$ sudo apt-get install git +``` + +Next, git clone the MEAN.JS repository with command: + +``` +$ git clone https://github.com/meanjs/mean.git meanjs +``` + +**Sample output:** + +``` +Cloning into 'meanjs'... +remote: Counting objects: 8596, done. +remote: Compressing objects: 100% (12/12), done. +remote: Total 8596 (delta 3), reused 0 (delta 0), pack-reused 8584 Receiving objects: 100% (8596/8596), 2.62 MiB | 140.00 KiB/s, done. +Resolving deltas: 100% (4322/4322), done. +Checking connectivity... done. +``` + +The above command will clone the latest version of the MEAN.JS repository to **meanjs** folder in your current working directory. + +Go to the meanjs folder: + +``` +$ cd meanjs/ +``` + +Run the following command to install the Node.js dependencies required for testing and running our application: + +``` +$ npm install +``` + +This will take some time. Please be patient. + +* * * + +**Troubleshooting:** + +When I run the above command in Ubuntu 18.04 LTS, I get the following error: + +``` +Downloading binary from https://github.com/sass/node-sass/releases/download/v4.5.3/linux-x64-67_binding.node +Cannot download "https://github.com/sass/node-sass/releases/download/v4.5.3/linux-x64-67_binding.node": + +HTTP error 404 Not Found + +[....] +``` + +If you ever get these type of common errors like “node-sass and gulp-sass”, do the following: + +First uninstall the project and global gulp-sass modules using the following commands: + +``` +$ npm uninstall gulp-sass +$ npm uninstall -g gulp-sass +``` + +Next uninstall the global node-sass module: + +``` +$ npm uninstall -g node-sass +``` + +Install the global node-sass first. Then install the gulp-sass module at the local project level. + +``` +$ npm install -g node-sass +$ npm install gulp-sass +``` + +Now try the npm install again from the project folder using command: + +``` +$ npm install +``` + +Now all dependencies will start to install without any issues. + +* * * + +Once all dependencies are installed, run the following command to install all the front-end modules needed for the application: + +``` +$ yarn --allow-root --config.interactive=false install +``` + +Or, + +``` +$ yarn --allow-root install +``` + +You will see the following message at the end if the installation is successful. + +``` +[...] +> meanjs@0.6.0 snyk-protect /home/sk/meanjs +> snyk protect + +Successfully applied Snyk patches + +Done in 99.47s. +``` + +### Test MEAN.JS + +MEAN.JS stack has been installed. We can now able to start a sample application using command: + +``` +$ npm start +``` + +After a few seconds, you will see a message like below. This means MEAN.JS stack is working! + +``` +[...] +MEAN.JS - Development Environment + +Environment: development +Server: http://0.0.0.0:3000 +Database: mongodb://localhost/mean-dev +App version: 0.6.0 +MEAN.JS version: 0.6.0 +``` + +![][4] + +To verify, open up the browser and navigate to **** or ****. You should see a screen something like below. + +![][5] + +Mean stack test page + +Congratulations! MEAN.JS stack is ready to start building web applications. + +For further details, I recommend you to refer **[MEAN.JS stack official documentation][6]**. + +* * * + +Want to setup MEAN.JS stack in CentOS, RHEL, Scientific Linux? Check the following link for more details. + + * **[Install MEAN.JS Stack in CentOS 7][7]** + + + +* * * + +And, that’s all for now, folks. Hope this tutorial will help you to setup MEAN.JS stack. + +If you find this tutorial useful, please share it on your social, professional networks and support OSTechNix. + +More good stuffs to come. Stay tuned! + +Cheers! + +**Resources:** + + * **[MEAN.JS website][8]** + * [**MEAN.JS GitHub Repository**][9] + + + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/install-mean-js-stack-ubuntu/ + +作者:[sk][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[1]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[2]: https://www.ostechnix.com/install-mongodb-linux/ +[3]: https://www.ostechnix.com/install-node-js-linux/ +[4]: http://www.ostechnix.com/wp-content/uploads/2016/03/meanjs.png +[5]: http://www.ostechnix.com/wp-content/uploads/2016/03/mean-stack-test-page.png +[6]: http://meanjs.org/docs.html +[7]: http://www.ostechnix.com/install-mean-js-stack-centos-7/ +[8]: http://meanjs.org/ +[9]: https://github.com/meanjs/mean From eda05a64f51f74ad06978cfa1232bd0ff8840a15 Mon Sep 17 00:00:00 2001 From: Liwen Jiang Date: Mon, 18 Mar 2019 06:43:15 -0500 Subject: [PATCH 11/12] Apply for Translatting Apply for Translatting --- .../20180329 Python ChatOps libraries- Opsdroid and Errbot.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sources/tech/20180329 Python ChatOps libraries- Opsdroid and Errbot.md b/sources/tech/20180329 Python ChatOps libraries- Opsdroid and Errbot.md index 5f409956f7..438057f08e 100644 --- a/sources/tech/20180329 Python ChatOps libraries- Opsdroid and Errbot.md +++ b/sources/tech/20180329 Python ChatOps libraries- Opsdroid and Errbot.md @@ -1,3 +1,4 @@ +tomjlw is translating Python ChatOps libraries: Opsdroid and Errbot ====== @@ -211,7 +212,7 @@ Have you used Errbot or Opsdroid? If so, please leave a comment with your impres via: https://opensource.com/article/18/3/python-chatops-libraries-opsdroid-and-errbot 作者:[Jeff Triplett][a] -译者:[译者ID](https://github.com/译者ID) +译者:[tomjlw](https://github.com/tomjlw) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 8275cae67ee808f56f3fdbcfd0f41a261715af75 Mon Sep 17 00:00:00 2001 From: David Max <42110350+DavidMax2006@users.noreply.github.com> Date: Mon, 18 Mar 2019 21:31:24 +0800 Subject: [PATCH 12/12] Translate Request I want to translate this article. --- sources/tech/20180629 100 Best Ubuntu Apps.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20180629 100 Best Ubuntu Apps.md b/sources/tech/20180629 100 Best Ubuntu Apps.md index 581d22b527..487ebd6e7d 100644 --- a/sources/tech/20180629 100 Best Ubuntu Apps.md +++ b/sources/tech/20180629 100 Best Ubuntu Apps.md @@ -1,3 +1,4 @@ +DaivdMax2006 is translating 100 Best Ubuntu Apps ======