Merge remote-tracking branch 'LCTT/master'

This commit is contained in:
Xingyu Wang 2021-01-02 10:50:45 +08:00
commit db8cfce94b
5 changed files with 544 additions and 308 deletions

View File

@ -1,112 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Try GNU nano, a lightweight alternative to Vim)
[#]: via: (https://opensource.com/article/20/12/gnu-nano)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
Try GNU nano, a lightweight alternative to Vim
======
Lightweight and straightforward, nano delivers a simple, intuitive
editor with no extra fuss.
![A pink typewriter][1]
Many Linux distributions bundle [Vim][2] as their default text editor. This appeals to many longtime Linux users, and those who dont like it can change it promptly after install anyway. Vim is a funny editor, though, as its one of the few that opens to a mode that doesnt permit text entry. Thats a puzzling choice for any user, and its confusing for a new one.
Thanks to GNU nano, theres a common alternative to Vim for a lightweight terminal-based text editor, and its so easy to use—it has its most important commands listed at the bottom of its window.
![Black nano terminal with white text][3]
### Installing
On Linux and macOS, you probably already have GNU nano installed. You can verify with the `which` command:
```
$ which nano
/bin/nano
```
If you dont have it installed, you can install it from your software repository, or you can [download its source code and compile it][4] yourself.
On Windows, you can [install GNU nano][5] using [Chocolatey][6].
### Launching nano
Launch nano from the terminal, either alone:
```
`$ nano`
```
Or you can also open a specific file by following your command with a path to a file. If the file you name doesnt already exist, its created:
```
`$ nano example.txt`
```
### Using nano
Nano is, with just a little reading, pretty self-explanatory. When you launch it, nano opens to either an empty buffer or the file you opened. At the bottom of the screen, theres a list of functions and their corresponding keyboard shortcuts. More functions are available by pressing **Ctrl+G** for Get Help.
Here are the most important application commands:
* **Ctrl+S** saves your work
* **Ctrl+W** save as
* **Ctrl+R** loads a file ("Read")
* **Ctrl+X** quits, or exits
* **Ctrl+G** get help
Here are the most common editing commands:
* **Alt+A** select ("mark") a region
* **Ctrl+K** cut marked text
* **Ctrl+U** paste ("uncut")
* **Alt+F** undo
* **Alt+E** redo
### Customizable
Nano isnt as extensible as Emacs or Vim, but you can make some significant customizations in a file called `~/.nanorc`. In this file, you can set global preferences, including word wrap settings, color schemes, line numbering, and more. You can also create your own key bindings, so if you want to use **Ctrl+V** to paste instead of nanos default **Ctrl+U**, you can change the binding assigned to the **paste** function:
```
`bind ^V paste all`
```
You can get a list of all available functions in the [GNU nano documentation][7].
### Simple and effective
GNU nano is a no-nonsense, straightforward text editor. Its easy to use and provides all the functionality you expect from a text editor. Try it out, and enjoy the simplicity of intuitive editing.
Vim offers great benefits to writers, regardless of whether they are technically minded or not.
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/12/gnu-nano
作者:[Seth Kenlon][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/seth
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc-docdish-typewriter-pink.png?itok=OXJBtyYf (A pink typewriter)
[2]: https://opensource.com/article/20/12/vi-text-editor
[3]: https://opensource.com/sites/default/files/uploads/nano-31_days-nano-opensource.png (Black nano terminal with white text)
[4]: http://nano-editor.org
[5]: https://opensource.com/article/20/12/%C2%A0https://chocolatey.org/packages/nano
[6]: https://opensource.com/article/20/3/chocolatey
[7]: https://www.nano-editor.org/dist/latest/nanorc.5.html

View File

@ -1,196 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Bring an old MacBook back to life with Linux)
[#]: via: (https://opensource.com/article/20/12/linux-macbook)
[#]: author: (Eric D. Schabell https://opensource.com/users/eschabell)
Bring an old MacBook back to life with Linux
======
It takes about an hour to make an outdated Mac useful again with Fedora.
![Digital images of a computer desktop][1]
Recently, I stumbled on an old MacBook Pro 13" from late 2011, with a 125GB SSD and 8GB RAM. I've taken this machine on trips around the world, and back in the day, I ran many a session, workshop, or demo to share all the AppDev goodness from JBoss technologies.
After verifying that its battery works, charging it up, and reinstalling a new OS X, it turns out that the Safari browser version is limited to an old security specification, which means it can't connect to a lot of HTTPS sites now. This renders this solution defunct.
What to do with this old thing?
It's been a few years since I worked solely on Linux workstations as a developer. I specifically worked on Fedora, so I decided to try to install the latest version on this MacBook Pro.
It took me just over an hour to get [Fedora 33][2] working on this laptop with the steps below.
### Download Fedora 33 and create a live USB
The first step is to find the right way to install Fedora. This machine has a CD slot, so you could burn an ISO and boot from it, but I chose to go straight to a bootable USB option.
I got on my other MacBook and visited the [Fedora Workstation site][3], which links to Fedora Media Writer. Click on the icon for your machine type (in my case, the Apple logo), and you get an installation package.
![Fedora Media Writer download screen][4]
(Eric D. Shabell, [CC BY-SA 4.0][5])
Start installing it to see a graphical user interface (GUI) that guides you through the process. Select the Fedora Workstation 33 option:
![Fedora Workstation download in Fedora Media Writer][6]
(Eric D. Shabell, [CC BY-SA 4.0][5])
Next, select the Create Live USB option in the top-right corner:
![Create Live USB button][7]
(Eric D. Shabell, [CC BY-SA 4.0][5])
The image will start to download, and you will see a drop-down menu to select where to install it:
![Downloading Fedora Workstation][8]
(Eric D. Shabell, [CC BY-SA 4.0][5])
Plug in a USB stick with enough space available, then after the download finishes, you can select and install the image on it. Once it's finished, close the GUI and remove the USB stick.
### Install Linux
Insert the USB stick you created into the port on the left side of your MacBook Pro, and restart it while holding down the **Option** (or **Alt**) key just to the left of the **Cmd** key. This opens a menu of options to start the machine; use the EFI option, as that's the USB image.
The laptop will boot from the USB device, and you can follow the [normal Fedora installation][9] process. It helps if you can plug the MacBook Pro into a network cable connection, as the Broadcom WiFi device will not work out of the box.
![MacBook Pro][10]
(Eric D. Shabell, [CC BY-SA 4.0][5])
You should get the opportunity to install Fedora to your hard drive and put it on your machine permanently.
![Installing Fedora on MacBook Pro][11]
(Eric D. Shabell, [CC BY-SA 4.0][5])
Once the installer completes, reboot your machine, and Fedora 33 should now be the option to boot from.
![MacBook Pro booting into Fedora][12]
(Eric D. Shabell, [CC BY-SA 4.0][5])
The only thing missing is a WiFi driver, so keep your network cable connected to install the development packages for the kernel you are running and to build the `broadcom-wl` driver for that kernel.
Verify the card you need for WiFi:
```
`$ lspci -vnn -d 14e4:`
```
There will be several items in the output, including something like:
```
Network controller [0280]: Broadcom Inc. and subsidiaries....
Subsystem: Apple Inc. AirPort Extreme...
```
Install a repository to pull the Broadcom stuff:
```
`$ su -c 'dnf install -y http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm'`
```
The next part is interesting: As you look at the running kernel, you'll see `v5.9.8-200.fc33`, but you will use the development kernel packages to build your Broadcom wireless driver. So, you need to install `v5.8.15-301.fc33` (available at the time of this writing). Check them using `uname -r`, and list the installed kernel packages using `sudo dnf list kernel`:
```
$ sudo dnf list kernel
kernel.x86_64                     5.8.15-301.fc33
kernel.x86_64                     5.9.8-200.fc33
```
Install the development packages:
```
`$ sudo dnf install -y akmods kernel-devel-5.8.15-301.fc33`
```
![Installing development packages][13]
(Eric D. Shabell, [CC BY-SA 4.0][5])
Install the Broadcom wireless package:
```
`$ sudo dnf install -y broadcom-wl`
```
Build the kernel module:
```
`$ sudo akmods`
```
![Building the kernel module][14]
(Eric D. Shabell, [CC BY-SA 4.0][5])
Reboot your machine, and you should be able to view the wireless driver (`wl`) with:
```
`$ lsmod | grep wl`
```
Set up your wireless connection in Fedora:
![Set up wireless connection][15]
(Eric D. Shabell, [CC BY-SA 4.0][5])
This article is a bit out of the ordinary for me, but I hope it might help someone else enjoy some fun on the weekend with some old hardware!
> Going off the beaten path now... installing [#Fedora][16] on a macbook pro from 2011. Wish me luck! [pic.twitter.com/zlsESnq2Px][17]
>
> — Eric D. Schabell (@ericschabell) [November 22, 2020][18]
* * *
_This originally appeared on [Schabell.org][19] and is republished with permission._
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/12/linux-macbook
作者:[Eric D. Schabell][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/eschabell
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_desk_home_laptop_browser.png?itok=Y3UVpY0l (Digital images of a computer desktop)
[2]: https://getfedora.org/en/
[3]: https://getfedora.org/en/workstation/download/
[4]: https://opensource.com/sites/default/files/uploads/fedoramediawriter.png (Fedora Media Writer download screen)
[5]: https://creativecommons.org/licenses/by-sa/4.0/
[6]: https://opensource.com/sites/default/files/uploads/fedoraworkstation33-installation.png (Fedora Workstation download in Fedora Media Writer)
[7]: https://opensource.com/sites/default/files/uploads/create-live-usb.png (Create Live USB button)
[8]: https://opensource.com/sites/default/files/uploads/download_fedora-workstation.png (Downloading Fedora Workstation)
[9]: https://docs.fedoraproject.org/en-US/fedora/f33/install-guide/install/Booting_the_Installation/
[10]: https://opensource.com/sites/default/files/uploads/macbook.jpeg (MacBook Pro)
[11]: https://opensource.com/sites/default/files/uploads/macbook_install-fedora.jpeg (Installing Fedora on MacBook Pro)
[12]: https://opensource.com/sites/default/files/uploads/macbook_fedora-boot.jpeg (MacBook Pro booting into Fedora)
[13]: https://opensource.com/sites/default/files/uploads/install-development-packages.jpeg (Installing development packages)
[14]: https://opensource.com/sites/default/files/uploads/build-kernel-module.jpeg (Building the kernel module)
[15]: https://opensource.com/sites/default/files/uploads/wireless-setup.jpeg (Set up wireless connection)
[16]: https://twitter.com/hashtag/Fedora?src=hash&ref_src=twsrc%5Etfw
[17]: https://t.co/zlsESnq2Px
[18]: https://twitter.com/ericschabell/status/1330434517883121665?ref_src=twsrc%5Etfw
[19]: https://www.schabell.org/2020/11/installing-fedora33-on-macbook-pro-13inch-late-2011.html

View File

@ -0,0 +1,275 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Solve a charity's problem with the Julia programming language)
[#]: via: (https://opensource.com/article/21/1/solve-problem-julia)
[#]: author: (Chris Hermansen https://opensource.com/users/clhermansen)
Solve a charity's problem with the Julia programming language
======
See how Julia differs from Java, Python, and Groovy to solve a food
bank's real-world problem.
![Puzzle pieces coming together to form a computer screen][1]
I have been writing a series of articles about solving a nice, small, and somewhat unusual problem in different programming languages ([Groovy][2], [Python][3], and [Java][4] so far).
Briefly, the problem is how to unpack bulk supplies into their units (for example, dividing a 10 pack of one-pound bags of your favorite coffee) and repackage them into hampers of similar value to distribute to struggling neighbors in the community.
The three solutions I have already explored constructed lists of the number of bulk packages acquired. I accomplished this by using maps in Groovy, dictionaries in Python, and tuples implemented as utility classes in Java. I used list-processing functionality in each language to unpack the bulk packages into a list of their constituents, which I modeled using maps, dictionaries, and tuples, respectively. I needed to take an iterative approach to move units from a list into hampers; this iterative approach was quite similar from one language to the other, with the minor difference that I could use `for {...}` loops in Groovy and Java and needed `while…:` in Python. But all in all, they used very similar solutions with hints of functional programming and behavior encapsulated in objects here and there.
### Meet Julia
In this article, I'll explore the same problem in [Julia][5], which (among other things) means leaving aside the object-oriented and functional programming paradigms I'm used to. I struggle with languages that aren't object-oriented. I've been programming in Java since around 1997 and in Groovy since about 2008, so I'm used to having data and behavior bundled together. Aside from just generally liking the look of code where method calls hang off objects or sometimes classes, I really like the way class documentation packages up what data is handled by the class and how it is handled. This seems so "natural" to me now that learning a language whose documentation describes types and functions separately seems difficult to me.
And speaking of learning a language, I'm a real neophyte when it comes to Julia. I like its orientation toward the kinds of problems I typically need to solve (e.g., data, computations, results). I like the desire for speed. I like the decision to make Julia a language in which complicated problems can be solved using a modular and iterative approach. I like the idea of making great existing analytical libraries available. But, my jury is still out on the non-object-oriented design. I also seem to use functional approaches in my Groovy and Java programming more often, so I think I might miss this in Julia.
But enough speculation, let's code something!
### The Julia solution
My first decision is how to implement the data model. Julia supports _composite types_, seemingly similar to `struct` in C, and Julia even uses the keyword `struct`. Of note is that a `struct` is immutable (unless declared a `mutable struct`), which is fine for this problem since the data doesn't need to be mutated.
By following the approach I took in the Java solution, the `Unit struct` can be defined as: 
```
struct Unit
       item::String
       brand::String
       price::Int
end
```
Similarly, `Pack` is defined as the bulk package of `Unit` instances:
```
struct Pack
      unit::Unit
      count::Int
      Pack(item, brand, unitCount,p ackPrice) =
            new(Unit(item, brand, [div][6](packPrice,unitCount)), unitCount)
end
```
There is an interesting thing here: a Julia "inner constructor." In the Java solution, I decided that the units inside bulk packages are (in my mind, anyway) a part of the bulk package and not something seen externally, so I decided I wanted to pass in the item, brand, number of units, and package price and have the `Pack` object create its unit internally. I'll do the same thing here.
Because Julia isn't object-oriented, I can't add methods to `Pack` to give unit price vs. pack price or to unpack it into a list of `Unit` instances. I can declare "getter" functions that accomplish the same tasks. (I probably don't need these, but I'll do it anyway to see how Julia methods work):
```
item(pack::Pack) = pack.unit.item
brand(pack::Pack) = pack.unit.brand
unitPrice(pack::Pack) = pack.unit.price
unitCount(pack::Pack) = pack.count
packPrice(pack::Pack) = pack.unit.price * pack.count
unpack(pack::Pack) = Iterators.collect(Iterators.repeated(pack.unit,pack.count))
```
The `unpack()` method is quite similar to the method of the same name I declared in the Java class `Pack`. The function `Iterators.repeated(thing,N)` creates an iterator that will deliver `N` copies of `thing`. The `Iterators.collect` (`iterator`) function processes the `iterator` to yield an array made up of the elements it delivers.
Finally, the `Bought struct`:
```
struct Bought
      pack::Pack
      count::Int
end
unpack(bought::Bought) =        
     Iterators.collect(Iterators.flatten(Iterators.repeated(unpack(bought.pack),
         bought.count)))
```
Once again, I'm creating an array of an array of unpacked `Pack` instances (i.e., units) and using `Iterators.flatten()` to turn that into a simple array.
Now I can construct the list of what I bought:
```
packs = [
        Bought(Pack("Rice","Best Family",10,5650),1),
        Bought(Pack("Spaghetti","Best Family",1,327),10),
        Bought(Pack("Sardines","Fresh Caught",3,2727),3),
        Bought(Pack("Chickpeas","Southern Style",2,2600),5),
        Bought(Pack("Lentils","Southern Style",2,2378),5),
        Bought(Pack("Vegetable oil","Crafco",12,10020),1),
        Bought(Pack("UHT milk","Atlantic",6,4560),2),
        Bought(Pack("Flour","Neighbor Mills",10,5200),1),
        Bought(Pack("Tomato sauce","Best Family",1,190),10),
        Bought(Pack("Sugar","Good Price",1,565),10),
        Bought(Pack("Tea","Superior",5,2720),2),
        Bought(Pack("Coffee","Colombia Select",2,4180),5),
        Bought(Pack("Tofu","Gourmet Choice",1,1580),10),
        Bought(Pack("Bleach","Blanchite",5,3550),2),
        Bought(Pack("Soap","Sunny Day",6,1794),2)]
```
I'm starting to see a pattern here… this looks surprisingly like the Java solution to this problem. As then, this shows that I bought one pack of Best Family Rice containing 10 units that cost 5650 (using those crazy monetary units, like in the other examples). I bought one bulk pack of 10 bags of rice, and I bought 10 bulk packs of one bag each of spaghetti.
With the list packs of what I bought, I can now unpack into the units before working on redistributing them:
```
`units = Iterators.collect(Iterators.flatten(unpack.(packs)))`
```
What's going on here? Well, a construct like `unpack.(packs)`—that is, the dot between the function name and the argument list—applies the function `unpack()` to each element in the list `packs`. This will generate a list of lists corresponding to the unpacked groups of `Packs` I bought. To turn that into a flat list of units, I apply `Iterators.flatten()`. Because `Iterators.flatten()` is lazy, to make the flatten thing happen, I wrap it in `Iterators.collect()`. This kind of composition of functions adheres to the spirit of functional programming, even though you don't see the functions chained together, as programmers who write functionally in JavaScript, Java, or what-have-you are familiar with.
One observation is that the list of units created here is actually an array whose starting index is 1, not 0.
With units being the list of units purchased and unpacked, I can now take on repacking them into hampers.
Here's the code, which is not exceptionally different than the versions in Groovy, Python, and Java:
```
 1      valueIdeal = 5000
 2      valueMax = round(valueIdeal * 1.1)
 3      hamperNumber = 0
       
 4      while length(units) > 0
 5          global hamperNumber += 1
 6          hamper = Unit[]
 7          value = 0
 8          canAdd = true
 9          while canAdd
10              u = [rand][7](0:(length(units)-1))
11              canAdd = false
12              for o = 0:(length(units)-1)
13                  uo = (u + o) % length(units) + 1
14                  unit = units[uo]
15                  if length(units) < 3 || findfirst(u -> u == unit,hamper) === nothing && (value + unit.price) < valueMax
16                      push!(hamper,unit)
17                      value += unit.price
18                      deleteat!(units,uo)
19                      canAdd = length(units) > 0
20                      break
21                  end
22              end
23          end
24          Printf.@[printf][8]("\nHamper %d value %d:\n",hamperNumber,value)
25          for unit in hamper
26              Printf.@[printf][8]("%-25s%-25s%7d\n",unit.item,unit.brand,unit.price)
27          end
28          Printf.@[printf][8]("Remaining units %d\n",length(units))
29      end
```
Some clarification, by line numbers:
* Lines 13: Set up the ideal and maximum values to be loaded into any given hamper and initialize Groovy's random number generator and the hamper number
* Lines 429: This `while` loop redistributes units into hampers, as long as there are more available
* Lines 57: Increment the (global) hamper number, get a new empty hamper (an array of `Unit` instances), and set its value to 0
* Line 8 and 923: As long as I can add units to the hamper…
* Line 10: Gets a random number between zero and the number of remaining units minus 1
* Line 11: Assumes I can't find more units to add
* Lines 1222: This `for` loop, starting at the randomly chosen index, will try to find a unit that can be added to the hamper
* Lines 1314: Figure out which unit to look at (remember arrays start at index 1) and get it
* Lines 1521: I can add this unit to the hamper if there are only a few left or if the value of the hamper isn't too high once the unit is added and if that unit isn't already in the hamper
* Lines 1618: Add the unit to the hamper, increment the hamper value by the unit price, and remove the unit from the available units list
* Lines 1920: As long as there are units left, I can add more, so break out of this loop to keep looking
* Line 22: On exit from this `for` loop, if I have inspected every remaining unit and could not find one to add to the hamper, the hamper is complete; otherwise, I found one and can continue looking for more
* Line 23: On exit from this `while` loop, the hamper is as full as I can make it, so…
* Lines 2428: Print out the contents of the hamper and the remaining units info
* Line 29: When I exit this loop, there are no more units left
The output of running this code looks quite similar to the output from the other programs:
```
Hamper 1 value 5020:
Tea                      Superior                     544
Sugar                    Good Price                   565
Soap                     Sunny Day                    299
Chickpeas                Southern Style              1300
Flour                    Neighbor Mills               520
Rice                     Best Family                  565
Spaghetti                Best Family                  327
Bleach                   Blanchite                    710
Tomato sauce             Best Family                  190
Remaining units 146
Hamper 2 value 5314:
Flour                    Neighbor Mills               520
Sugar                    Good Price                   565
Vegetable oil            Crafco                       835
Coffee                   Colombia Select             2090
UHT milk                 Atlantic                     760
Tea                      Superior                     544
Remaining units 140
Hamper 3 value 5298:
Tomato sauce             Best Family                  190
Tofu                     Gourmet Choice              1580
Sugar                    Good Price                   565
Bleach                   Blanchite                    710
Tea                      Superior                     544
Lentils                  Southern Style              1189
Flour                    Neighbor Mills               520
Remaining units 133
Hamper 23 value 4624:
Chickpeas                Southern Style              1300
Vegetable oil            Crafco                       835
Tofu                     Gourmet Choice              1580
Sardines                 Fresh Caught                 909
Remaining units 4
Hamper 24 value 5015:
Tofu                     Gourmet Choice              1580
Chickpeas                Southern Style              1300
Chickpeas                Southern Style              1300
Vegetable oil            Crafco                       835
Remaining units 0
```
The last hamper is abbreviated in contents and value.
### Closing thoughts
Once again, the random-number-driven list manipulation seems to make the "working code" portion of the program pretty similar to the Groovy, Python, and Java versions. To my delight, I found good functional programming support in Julia, at least with respect to the straightforward list processing required for this small problem.
Given that the main effort revolves around `for` and `while` loops, in Julia, I don't see any construct similar to:
```
`for (boolean canAdd = true; canAdd; ) { … }`
```
This means I have to declare the `canAdd` variable outside the `while` loop. Which is too bad—but not a terrible thing.
I do miss not being able to attach behavior directly to my data, but that's just my appreciation for object-oriented programming showing through. It's certainly not a huge impediment in this program; however, correspondence with a kind author about my Java version made me realize that I should have built a class to fully encapsulate the distribution function into something like a list of hampers, which the main program would just print out. This approach would not be feasible in a non-object-oriented language like Julia.
Good things: low ceremony, check; decent list-handling, check; compact and readable code, check. All in all, a pleasant experience, supporting the idea that Julia can be a decent choice to solve "ordinary problems" and as a scripting language.
Next time, I'll do this exercise in [Go][9].
--------------------------------------------------------------------------------
via: https://opensource.com/article/21/1/solve-problem-julia
作者:[Chris Hermansen][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/clhermansen
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/puzzle_computer_solve_fix_tool.png?itok=U0pH1uwj (Puzzle pieces coming together to form a computer screen)
[2]: https://opensource.com/article/20/9/groovy
[3]: https://opensource.com/article/20/9/solve-problem-python
[4]: https://opensource.com/article/20/9/problem-solving-java
[5]: https://julialang.org/
[6]: http://www.opengroup.org/onlinepubs/009695399/functions/div.html
[7]: http://www.opengroup.org/onlinepubs/009695399/functions/rand.html
[8]: http://www.opengroup.org/onlinepubs/009695399/functions/printf.html
[9]: https://golang.org/

View File

@ -0,0 +1,103 @@
[#]: collector: (lujun9972)
[#]: translator: (wxy)
[#]: reviewer: (wxy)
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Try GNU nano, a lightweight alternative to Vim)
[#]: via: (https://opensource.com/article/20/12/gnu-nano)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
试试 GNU nano一个轻量级的 Vim 替代品
======
> 轻巧而直接nano 提供了一个简单、直观的编辑器,没有额外的麻烦。
![粉色打字机][1]
许多 Linux 发行版都捆绑了 [Vim][2] 作为默认的文本编辑器。这吸引了很多长期使用 Linux 的用户,反正那些不喜欢它的用户也可以在安装后及时更换。不过 Vim 是一个很有趣的编辑器,因为它是少数几个打开时的模式不允许输入文字的编辑器之一。这对任何用户来说都是一个令人费解的选择,对一个新用户来说也是很困惑的。
多亏了 GNU nano才有了 Vim 之外的另一种轻量级终端文本编辑器,而且使用起来非常方便 —— 它的窗口底部列出了最重要的命令。
![Black nano terminal with white text][3]
### 安装
在 Linux 和 macOS 上,你可能已经安装了 GNU nano。你可以用 `which` 命令来验证:
```
$ which nano
/bin/nano
```
如果你没有安装它,你可以从你的软件库中安装,或者你可以自己[下载它的源代码并编译][4]。
在 Windows 上,你可以使用 [Chocolatey][6] 来 [安装 GNU nano][5]。
### 启动 nano
从终端启动 nano要么单独打开它
```
$ nano
```
或者你也可以在你的命令后面加上一个文件的路径来打开一个特定的文件。如果你命名的文件还不存在,它就会被创建:
```
$ nano example.txt
```
### 使用 nano
nano是个只要稍看一下就会发现它是一个非常自明的东西。当你启动它的时候nano 会打开一个空的缓冲区或者你要打开的文件。在屏幕下方,有一个功能列表和相应的键盘快捷键。更多的功能可以按 `Ctrl+G` 获取帮助。
以下是最重要的应用程序命令:
* `Ctrl+S` 保存你的工作
* `Ctrl+W` 另存为
* `Ctrl+R` 加载文件(读取)
* `Ctrl+X` 退出
* `Ctrl+G` 获得帮助
以下是最常用的编辑命令:
* `Alt+A` 选择(标记)一个区域
* `Ctrl+K` 剪切标记的文字
* `Ctrl+U` 粘贴(不剪切)
* `Alt+F` 撤销
* `Alt+E` 重做
### 可定制
nano 不像 Emacs 或 Vim 那样可扩展,但你可以在一个名为 `~/.nanorc` 的文件中进行一些重要的定制。在这个文件中,你可以设置全局的偏好,包括文字折行设置、颜色方案、行号等。你也可以创建你自己的键绑定,所以如果你想用 `Ctrl+V` 来代替 nano 默认的 `Ctrl+U` 来粘贴,你可以改变分配给 `paste` 函数的绑定。
```
bind ^V paste all
```
你可以在 [GNU nano 文档][7]中获得所有可用函数的列表。
### 简单而有效
GNU nano 是一款简单明了的文本编辑器。它易于使用,并提供了你所期望的所有文本编辑器的功能。试试吧,享受直观编辑的简单性。
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/12/gnu-nano
作者:[Seth Kenlon][a]
选题:[lujun9972][b]
译者:[wxy](https://github.com/wxy)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/seth
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc-docdish-typewriter-pink.png?itok=OXJBtyYf (A pink typewriter)
[2]: https://opensource.com/article/20/12/vi-text-editor
[3]: https://opensource.com/sites/default/files/uploads/nano-31_days-nano-opensource.png (Black nano terminal with white text)
[4]: http://nano-editor.org
[5]: https://opensource.com/article/20/12/%C2%A0https://chocolatey.org/packages/nano
[6]: https://opensource.com/article/20/3/chocolatey
[7]: https://www.nano-editor.org/dist/latest/nanorc.5.html

View File

@ -0,0 +1,166 @@
[#]: collector: (lujun9972)
[#]: translator: (wxy)
[#]: reviewer: (wxy)
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Bring an old MacBook back to life with Linux)
[#]: via: (https://opensource.com/article/20/12/linux-macbook)
[#]: author: (Eric D. Schabell https://opensource.com/users/eschabell)
用 Linux 让旧 MacBook 重获新生
======
> 花上一小时,用 Fedora 让一台过时的 Mac 重新有用。
![电脑桌面的数字图像][1]
最近,我偶然找到了一台 2011 年底的老款 13 英寸 MacBook Pro有 125GB SSD 和 8GB 内存。我曾带着这台机器去世界各地旅行,当年,我开了很多场会议、研讨会或演示,分享 JBoss 技术带来的各种 AppDev 优势。
在验证了它的电池能用,充了电,重新安装了一个新的 OS X 之后,我发现 Safari 浏览器的版本受限于旧的安全规范,这意味着它现在无法连接到很多 HTTPS 网站。这就使得这个解决方案失效了。
这个老伙计该怎么处理呢?
自从我作为开发人员专门在 Linux 工作站上工作以来已经有几年了。我只使用 Fedora所以我决定尝试在这台 MacBook Pro 上安装它的最新版本。
我只花了一个多小时就用下面的步骤让 [Fedora 33][2] 在这台笔记本上工作了。
### 下载 Fedora 33 并创建一个临场 USB
第一步是找到正确的安装 Fedora 的方法。这台机器有一个 CD 插槽,所以可以刻录一个 ISO 并从它启动,但我选择直接使用可启动的 USB 方式。
我登上了另一台 MacBook访问了 [Fedora Workstation 网站][3],它有 Fedora Media Writer 的链接。点击你的机器类型的图标(在我的例子中是苹果标志),你会得到一个安装包。
![Fedora Media Writer 下载界面][4]
开始安装可以看到一个引导你完成安装过程的图形用户界面GUI。选择 Fedora Workstation 33 选项。
![在 Fedora Media Writer 中下载 Fedora Workstation][6]
接下来选择右上角的“Create Live USB”选项。
![创建 Live USB 的按钮][7]
镜像将开始下载,你将看到一个下拉菜单来选择安装位置。
![下载 Fedora Workstation][8]
插入一个有足够空间的 U 盘,下载完成后,就可以选择它并在上面安装镜像。完成后,关闭 GUI取出 U 盘。
### 安装 Linux
将你创建的 U 盘插入 MacBook Pro 左侧的端口,并按住 `Cmd` 键左侧的 `Option`(或 `Alt`)键的同时重新启动。这将打开一个启动机器的选项菜单:使用 EFI 选项,因为那是 USB 镜像。
笔记本电脑将从 USB 设备启动,你可以按照[正常的 Fedora 安装][9]过程进行。如果你能将 MacBook Pro 插入网线连接,会有帮助,因为它的 Broadcom WiFi 设备无法开箱即用。
![MacBook Pro][10]
你现在也可以将 Fedora 安装到你的硬盘上,并将它永久地放在你的机器上。
![在 MacBook Pro 上安装 Fedora][11]
一旦安装程序完成重新启动机器Fedora 33 现在应该是启动选项。
![MacBook Pro 启动到 Fedora][12]
唯一缺少的就是 WiFi 驱动,所以要保持网线连接,安装你正在运行的内核的开发包,并为该内核构建 `broadcom-wl` 驱动。
验证你需要用于 WiFi 的卡。
```
$ lspci -vnn -d 14e4:
```
在输出中会有几项,包括如下内容:
```
Network controller [0280]: Broadcom Inc. and subsidiaries....
Subsystem: Apple Inc. AirPort Extreme...
```
安装一个仓库来拉取 Broadcom 相关的部分:
```
$ su -c 'dnf install -y http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm'
```
接下来的部分很有趣:如果你查看正在运行的内核时,你会看到 `v5.9.8-200.fc33`,但是你要使用开发内核包来构建你的 Broadcom 无线驱动。所以,你需要安装 `v5.8.15-301.fc33`(在写这篇文章的时候可用)。使用 `uname -r` 检查它们,并使用 `sudo dnf list kernel` 列出已安装的内核包:
```
$ sudo dnf list kernel
kernel.x86_64                     5.8.15-301.fc33
kernel.x86_64                     5.9.8-200.fc33
```
安装开发包:
```
$ sudo dnf install -y akmods kernel-devel-5.8.15-301.fc33
```
![安装开发包][13]
安装 Broadcom 无线软件包:
```
$ sudo dnf install -y broadcom-wl
```
构建内核模块:
```
$ sudo akmods
```
![构建内核模块][14]
重新启动你的机器,你应该可以看到无线驱动(`wl`)。
```
$ lsmod | grep wl
```
在 Fedora 中设置你的无线连接:
![设置无线连接][15]
这篇文章对我来说有些出乎意料,但我希望它能帮助别人在周末享受一些老硬件的乐趣!
> 现在要走不寻常路了……在 2011 年的 Macbook Pro 上安装 [#Fedora][16]。祝我好运! [pic.twitter.com/zlsESnq2Px][17]。
>
> - Eric D. Schabell (@ericschabell) [2020 年 11 月 22 日][18]
*此文原载于 [Schabell.org][19],经许可转载。*
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/12/linux-macbook
作者:[Eric D. Schabell][a]
选题:[lujun9972][b]
译者:[wxy](https://github.com/wxy)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/eschabell
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_desk_home_laptop_browser.png?itok=Y3UVpY0l (Digital images of a computer desktop)
[2]: https://getfedora.org/en/
[3]: https://getfedora.org/en/workstation/download/
[4]: https://opensource.com/sites/default/files/uploads/fedoramediawriter.png (Fedora Media Writer download screen)
[5]: https://creativecommons.org/licenses/by-sa/4.0/
[6]: https://opensource.com/sites/default/files/uploads/fedoraworkstation33-installation.png (Fedora Workstation download in Fedora Media Writer)
[7]: https://opensource.com/sites/default/files/uploads/create-live-usb.png (Create Live USB button)
[8]: https://opensource.com/sites/default/files/uploads/download_fedora-workstation.png (Downloading Fedora Workstation)
[9]: https://docs.fedoraproject.org/en-US/fedora/f33/install-guide/install/Booting_the_Installation/
[10]: https://opensource.com/sites/default/files/uploads/macbook.jpeg (MacBook Pro)
[11]: https://opensource.com/sites/default/files/uploads/macbook_install-fedora.jpeg (Installing Fedora on MacBook Pro)
[12]: https://opensource.com/sites/default/files/uploads/macbook_fedora-boot.jpeg (MacBook Pro booting into Fedora)
[13]: https://opensource.com/sites/default/files/uploads/install-development-packages.jpeg (Installing development packages)
[14]: https://opensource.com/sites/default/files/uploads/build-kernel-module.jpeg (Building the kernel module)
[15]: https://opensource.com/sites/default/files/uploads/wireless-setup.jpeg (Set up wireless connection)
[16]: https://twitter.com/hashtag/Fedora?src=hash&ref_src=twsrc%5Etfw
[17]: https://t.co/zlsESnq2Px
[18]: https://twitter.com/ericschabell/status/1330434517883121665?ref_src=twsrc%5Etfw
[19]: https://www.schabell.org/2020/11/installing-fedora33-on-macbook-pro-13inch-late-2011.html