mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-25 23:11:02 +08:00
Merge remote-tracking branch 'upstream/master' into Transit
This commit is contained in:
commit
266e451439
@ -3,55 +3,48 @@
|
||||
[#]: author: (Ray Paik https://opensource.com/users/rpaik)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13517-1.html)
|
||||
|
||||
试试这个新的数据分析开源工具吧
|
||||
Cube.js:试试这个新的数据分析开源工具
|
||||
======
|
||||
Cube.js 是一个开源的分析平台,作为数据源和应用之间的一层。
|
||||
![metrics and data shown on a computer screen][1]
|
||||
|
||||
数据分析是一个时髦的领域,有许多解决方案可供选择。其中之一是 [Cube.js][2],一个开源的分析平台。你可以把 Cube.js 看作是你的数据源和应用之间的一个层。
|
||||
> Cube.js 是一个开源的分析平台,可以作为数据源和应用之间的中间层。
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/202106/24/114907z53fpzv6szv936vj.jpg)
|
||||
|
||||
数据分析是一个时髦的领域,有许多解决方案可供选择。其中之一是 [Cube.js][2],这是一个开源的分析平台。你可以把 Cube.js 看作是你的数据源和应用之间的一个中间层。
|
||||
|
||||
如下图所示,Cube.js 支持无服务器数据仓库和大多数现代关系型数据库管理系统 (RDBMS)。你可以使用任何用于数据可视化的 JavaScript 前端库,而 Cube.js 将负责其他工作,包括访问控制、性能、并发性等。
|
||||
|
||||
![Cube.js architecture][3]
|
||||
|
||||
(©2021, [Cube Dev, Inc.][2])
|
||||
|
||||
### 主要优点
|
||||
|
||||
当我向我们的社区成员询问 Cube.js 的主要优点时,他们经常提到:
|
||||
|
||||
* **它的抽象层**:配置 Cube.js 后,人们说他们不再需要担心性能优化、资源管理、SQL 专业知识等问题。许多人把 Cube.js 称为 “黑盒”,因为它的抽象层帮助他们专注于理解数据,而不是实施细节。
|
||||
* **易于定制**:由于 Cube.js 是可视化的,它很容易与前端框架集成,建立看起来像用户自己平台的解决方案。大多数商业平台(如 Looker、Tableau 等)需要更多的定制工作来与他们的基础设施整合。许多用户说,定制的便利性与抽象层相结合,使他们能够减少数据分析平台的开发时间。
|
||||
* **社区支持**:在开始使用 Cube.js 时,人们通常会从社区成员那里得到帮助(特别是在我们的 [Slack][4]),许多人提到社区支持是一个关键的入门资源。
|
||||
|
||||
**它的抽象层:**配置 Cube.js 后,人们说他们不再需要担心性能优化、资源管理、SQL 专业知识等问题。许多人把 Cube.js 称为 “黑盒”,因为它的抽象层帮助他们专注于理解数据,而不是实施细节。
|
||||
**易于定制:**由于 Cube.js 是可视化的,它很容易与前端框架集成,建立看起来像用户自己平台的解决方案。大多数商业平台(如 Looker、Tableau 等)需要更多的定制工作来与他们的基础设施整合。许多用户说,定制的便利性与抽象层相结合,使他们能够减少数据分析平台的开发时间。
|
||||
**社区支持:**在开始使用 Cube.js 时,人们通常会从社区成员那里得到帮助(特别是在我们的 [Slack][4]),许多人提到社区支持是一个关键的入门资源。
|
||||
|
||||
|
||||
|
||||
访问[用户故事页面][5],阅读更多关于人们使用 Cube.js 的经验以及他们如何使用它。
|
||||
访问 [用户故事页面][5],阅读更多关于人们使用 Cube.js 的经验以及他们如何使用它。
|
||||
|
||||
### 开始使用
|
||||
|
||||
如果你想了解 Cube.js:
|
||||
|
||||
* 进入我们的[文档页面][6],点击**开始**,并按照指示在你的笔记本电脑或工作站上启动和运行 Cube.js。
|
||||
* 进入我们的 [文档页面][6],点击**开始**,并按照指示在你的笔记本电脑或工作站上启动和运行 Cube.js。
|
||||
* 当你进入 [Developer Playground][7],你将能够生成数据模式,执行查询,并建立仪表盘,以看到 Cube.js 的运行。
|
||||
|
||||
|
||||
|
||||
在你启动和运行 Cube.js 之后,这里有一些有用的资源:
|
||||
|
||||
* [文档][6]:我们把大量的精力放在我们的文档上,因为它是开源社区的重要资源。我们还在我们的文档页面和 YouTube 频道的[入门播放列表][8]中添加了视频剪辑。
|
||||
* [文档][6]:我们把大量的精力放在我们的文档上,因为它是开源社区的重要资源。我们还在我们的文档页面和 YouTube 频道的 [入门播放列表][8] 中添加了视频剪辑。
|
||||
* [Discourse][9]:Cube.js 论坛是最近增加的,社区成员可以在这里分享他们的使用案例、技巧和窍门等,这样我们就可以建立一个社区知识库。
|
||||
* [GitHub][10]: 你可以在这里找到 Cube.js 的代码,社区成员可以通过[问题页面][11]提交错误或功能请求。我们还在 GitHub 上发布了我们的[季度路线图][12],以便每个人都能看到我们正在进行的工作。
|
||||
* [每月社区电话会议][13]:我们在每个月的第二个星期三举行电话会议,讨论社区更新,展示功能演示,并邀请社区成员分享他们的使用案例。你可以在[社区电话会议页面][13]上找到电话会议的日程,你也可以在我们 YouTube 频道的[社区电话会议播放列表][14]上找到过去的电话会议录音。
|
||||
* [GitHub][10]: 你可以在这里找到 Cube.js 的代码,社区成员可以通过 [问题页面][11] 提交错误或功能请求。我们还在 GitHub 上发布了我们的 [季度路线图][12],以便每个人都能看到我们正在进行的工作。
|
||||
* [每月社区电话会议][13]:我们在每个月的第二个星期三举行电话会议,讨论社区更新,展示功能演示,并邀请社区成员分享他们的使用案例。你可以在 [社区电话会议页面][13] 上找到电话会议的日程,你也可以在我们 YouTube 频道的 [社区电话会议播放列表][14] 上找到过去的电话会议录音。
|
||||
|
||||
|
||||
|
||||
就像任何好的开源项目一样,Cube.js 有许多软件贡献者。如果你想查看社区的拉取请求 (PR),请搜索带有 `pr:community` 标签的 PR。如果你想寻找你可以回答的问题,请搜索带有 `good first issue` 或者 `help wanted` 标签的问题。
|
||||
就像任何好的开源项目一样,Cube.js 有许多软件贡献者。如果你想查看社区的拉取请求(PR),请搜索带有 `pr:community` 标签的 PR。如果你想寻找你可以回答的问题,请搜索带有 `good first issue` 或者 `help wanted` 标签的问题。
|
||||
|
||||
我希望你试试 Cube.js。如果你有任何问题,请随时在下面留言或在 [Cube.js Slack][4] 上找我!
|
||||
|
||||
@ -62,7 +55,7 @@ via: https://opensource.com/article/21/6/cubejs
|
||||
作者:[Ray Paik][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
137
published/20210623 Replace find with fd on Linux.md
Normal file
137
published/20210623 Replace find with fd on Linux.md
Normal file
@ -0,0 +1,137 @@
|
||||
[#]: subject: (Replace find with fd on Linux)
|
||||
[#]: via: (https://opensource.com/article/21/6/fd-linux)
|
||||
[#]: author: (Sudeshna Sur https://opensource.com/users/sudeshna-sur)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (wxy)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-13516-1.html)
|
||||
|
||||
在 Linux 上用 fd 代替 find
|
||||
======
|
||||
|
||||
> fd 命令是一个流行的、用户友好的 find 命令的替代品。
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/202106/24/110546npqmttwobtqpo4qk.jpg)
|
||||
|
||||
许多 Linux 程序员在其工作中每天都在使用 `find` 命令。但是 `find` 给出的文件系统条目是有限的,如果你要进行大量的 `find` 操作,它甚至不是很快速。因此,我更喜欢使用 Rust 编写的 `fd` 命令,因为它提供了合理的默认值,适用于大多数使用情况。
|
||||
|
||||
正如它的 [README][2] 所说,“`fd` 是一个在文件系统中寻找条目的程序。它是一个简单、快速和用户友好的 `find` 的替代品。”它的特点是目录的并行遍历,可以一次搜索多个目录。它支持正则表达式(regex)和基于通配符的模式。
|
||||
|
||||
### 安装 fd
|
||||
|
||||
在 Linux 上,你可以从你的软件库中安装 `fd`(可用的软件包列表可以在 [Repology 上的 fd 页面][3] 找到)。 例如,在 Fedora 上:
|
||||
|
||||
```
|
||||
$ sudo dnf install fd-find
|
||||
```
|
||||
|
||||
在 macOS 上,可以使用 [MacPorts][4] 或 [Homebrew][5]。
|
||||
|
||||
另外,你也可以使用 Rust 的 Cargo 软件包管理器:
|
||||
|
||||
```
|
||||
$ cargo install fd-find
|
||||
```
|
||||
|
||||
### 使用 fd
|
||||
|
||||
要做一个简单的搜索,运行 `fd` 并在后面跟上要搜索的名字,例如:
|
||||
|
||||
```
|
||||
$ fd sh
|
||||
registry/src/github.com-1ecc6299db9ec823/cc-1.0.67/src/bin/gcc-shim.rs
|
||||
registry/src/github.com-1ecc6299db9ec823/exa-0.10.1/completions/completions.bash
|
||||
registry/src/github.com-1ecc6299db9ec823/exa-0.10.1/completions/completions.fish
|
||||
registry/src/github.com-1ecc6299db9ec823/exa-0.10.1/completions/completions.zsh
|
||||
registry/src/github.com-1ecc6299db9ec823/exa-0.10.1/xtests/run.sh
|
||||
registry/src/github.com-1ecc6299db9ec823/git2-0.13.18/src/stash.rs
|
||||
registry/src/github.com-1ecc6299db9ec823/libc-0.2.94/src/unix/solarish
|
||||
registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.12.19+1.1.0/libgit2/cmake/SelectHashes.cmake
|
||||
registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.12.19+1.1.0/libgit2/include/git2/stash.h
|
||||
registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.12.19+1.1.0/libgit2/include/git2/sys/hashsig.h
|
||||
registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.12.19+1.1.0/libgit2/script/backport.sh
|
||||
registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.12.19+1.1.0/libgit2/script/leaks.sh
|
||||
registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.12.19+1.1.0/libgit2/script/valgrind.sh
|
||||
registry/src/github.com-1ecc6299db9ec823/libgit2-sys-0.12.19+1.1.0/libgit2/src/config_snapshot.c
|
||||
[...]
|
||||
```
|
||||
|
||||
如果你想搜索一个特定的目录,可以将目录路径作为 `fd` 的第二个参数,例如:
|
||||
|
||||
```
|
||||
$ fd passwd /etc
|
||||
/etc/pam.d/passwd
|
||||
/etc/passwd
|
||||
/etc/passwd-
|
||||
/etc/security/opasswd
|
||||
```
|
||||
|
||||
要搜索一个特定的文件扩展名,使用 `-e` 作为选项。例如:
|
||||
|
||||
```
|
||||
$ fd . '/home/ssur/exa' -e md
|
||||
/home/ssur/exa/README.md
|
||||
/home/ssur/exa/devtools/README.md
|
||||
/home/ssur/exa/man/exa.1.md
|
||||
/home/ssur/exa/man/exa_colors.5.md
|
||||
/home/ssur/exa/xtests/README.md
|
||||
$
|
||||
```
|
||||
|
||||
你也可以通过提供 `-x` 或 `-X` 来执行一个命令。
|
||||
|
||||
* `-x`/`--exec`:选项为每个搜索结果(并行)运行一个外部命令。
|
||||
* `-X`/`--exec-batch`:选项将所有搜索结果作为参数启动一次外部命令。
|
||||
|
||||
例如,要递归地找到所有的 ZIP 档案并解压:
|
||||
|
||||
```
|
||||
$ fd -e zip -x unzip
|
||||
```
|
||||
|
||||
或者,要列出某个特定目录下在过去 _n_ 天内改变的所有文件,使用`--changed-within` 选项:
|
||||
|
||||
```
|
||||
$ fd . '/home/ssur/Work/' --changed-within 10d
|
||||
/home/ssur/Work/wildfly/connector/src/main/java/org/jboss/as/connector/subsystems/data_sources/JdbcDriverAdd.java
|
||||
/home/ssur/Work/wildfly/connector/src/main/java/org/jboss/as/connector/subsystems/data_sources/JdbcExample.java
|
||||
[...]
|
||||
```
|
||||
|
||||
而要搜索所有在特定天数之前被修改的文件,请使用 `--changed-before` _n_ 选项:
|
||||
|
||||
```
|
||||
$ fd . '/home/ssur/Work/' --changed-before 365d
|
||||
```
|
||||
|
||||
这里,`.` 作为一个(正则)通配符,指示 `fd` 返回所有文件。
|
||||
|
||||
要了解更多关于 `fd` 的功能,请查阅 GitHub 上的 [文档][2]。
|
||||
|
||||
### 总结
|
||||
|
||||
我特别喜欢 `fd` 的一点是,搜索模式默认是不区分大小写的,这使得它更容易找到东西,即使你对你要找的东西没有精确的认识。更好的是,如果模式包含一个大写的字符,它就会*自动*切换到大小写敏感。
|
||||
|
||||
另一个好处是,它使用颜色编码来突出不同的文件类型。
|
||||
|
||||
如果你已经在使用这个神奇的 Rust 工具,请在评论中告诉我们你的想法。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/6/fd-linux
|
||||
|
||||
作者:[Sudeshna Sur][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/sudeshna-sur
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/find-file-linux-code_magnifying_glass_zero.png?itok=E2HoPDg0 (Magnifying glass on code)
|
||||
[2]: https://github.com/sharkdp/fd
|
||||
[3]: https://repology.org/project/fd-find/versions
|
||||
[4]: https://opensource.com/article/20/11/macports
|
||||
[5]: https://opensource.com/article/20/6/homebrew-mac
|
231
sources/tech/20210623 Parsing config files with Lua.md
Normal file
231
sources/tech/20210623 Parsing config files with Lua.md
Normal file
@ -0,0 +1,231 @@
|
||||
[#]: subject: (Parsing config files with Lua)
|
||||
[#]: via: (https://opensource.com/article/21/6/parsing-config-files-lua)
|
||||
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
Parsing config files with Lua
|
||||
======
|
||||
Configure persistent application settings with the Lua programming
|
||||
language.
|
||||
![Woman sitting in front of her computer][1]
|
||||
|
||||
Not all applications need configuration files; many applications benefit from starting fresh each time they are launched. Simple utilities, for instance, rarely require preferences or settings that persist across uses. However, when you write a complex application, it's nice for users to be able to configure how they interact with it and how it interacts with their system. That's what configuration files are for, and this article discusses some of the ways you can implement persistent settings with the Lua programming language.
|
||||
|
||||
### Choose a format
|
||||
|
||||
The important thing about configuration files is that they are consistent and predictable. You do not want to dump information into a file under the auspices of saving user preferences and then spend days writing code to reverse-engineer the random bits of information that have ended up in the file.
|
||||
|
||||
There are several popular [formats for configuration files][2]. Lua has libraries for most of the common configuration formats; in this article, I'll use the INI format.
|
||||
|
||||
### Installing the library
|
||||
|
||||
The central hub for Lua libraries is [Luarocks.org][3]. You can search for libraries on the website, or you can install and use the `luarocks` terminal command.
|
||||
|
||||
On Linux, you can install it from your distribution's software repository. For example:
|
||||
|
||||
|
||||
```
|
||||
`$ sudo dnf install luarocks`
|
||||
```
|
||||
|
||||
On macOS, use [MacPorts][4] or [Homebrew][5]. On Windows, use [Chocolatey][6].
|
||||
|
||||
Once `luarocks` is installed, you can use the `search` subcommand to search for an appropriate library. If you don't know the name of a library, you can search for a keyword, like `ini` or `xml` or `json`, depending on what's relevant to what you're trying to do. In this case, you can just search for `inifile`, which is the library I use to parse text files in the INI format:
|
||||
|
||||
|
||||
```
|
||||
$ luarocks search inifile
|
||||
Search results:
|
||||
inifile
|
||||
1.0-2 (rockspec) - <https://luarocks.org>
|
||||
1.0-2 (src) - <https://luarocks.org>
|
||||
1.0-1 (rockspec) - <https://luarocks.org>
|
||||
[...]
|
||||
```
|
||||
|
||||
A common trap programmers fall into is installing a library on their system and forgetting to bundle it with their application. This can create problems for users who don't have the library installed. To avoid this, use the `--tree` option to install the library to a local folder within your project directory. If you don't have a project directory, create one first, and then install:
|
||||
|
||||
|
||||
```
|
||||
$ mkdir demo
|
||||
$ cd demo
|
||||
$ luarocks install --tree=local inifile
|
||||
```
|
||||
|
||||
The `--tree` option tells `luarocks` to create a new directory, called `local` in this case, and install your library into it. With this simple trick, you can install all the dependency code your project uses directly into the project directory.
|
||||
|
||||
### Code setup
|
||||
|
||||
First, create some INI data in a file called `myconfig.ini`:
|
||||
|
||||
|
||||
```
|
||||
[example]
|
||||
name=Tux
|
||||
species=penguin
|
||||
enabled=false
|
||||
|
||||
[demo]
|
||||
name=Beastie
|
||||
species=demon
|
||||
enabled=false
|
||||
```
|
||||
|
||||
Save the file as `myconfig.ini` into your home directory, _not_ into your project directory. You usually want configuration files to exist outside your application so that even when a user uninstalls your application, the data they generate while using the application remains on their system. Users might remove unnecessary config files manually, but many don't. As a result, if they reinstall an application, it will retain all of their preferences.
|
||||
|
||||
Config file locations are technically unimportant, but each operating system (OS) has a specification or a tradition of where they ought to be placed. On Linux, this is defined by the [Freedesktop specification][7]. It dictates that configuration files are to be saved in a hidden folder named `~/.config`. For clarity during this exercise, just save the file in your home directory so that it's easy to find and use.
|
||||
|
||||
Create a second file named `main.lua` and open it in your favorite text editor.
|
||||
|
||||
First, you must tell Lua where you've placed the additional library you want it to use. The `package.path` variable determines where Lua looks for libraries. You can view Lua's default package path in a terminal:
|
||||
|
||||
|
||||
```
|
||||
$ Lua
|
||||
> print(package.path)
|
||||
./?.lua;/usr/share/lua/5.3/?.lua;/usr/share/lua/5.3/?/init.lua;/usr/lib64/lua/5.3/?.lua;/usr/lib64/lua/5.3/?/init.lua
|
||||
```
|
||||
|
||||
In your Lua code, append your local library location to `package.path`:
|
||||
|
||||
|
||||
```
|
||||
`package.path = package.path .. ';local/share/lua/5.3/?.lua`
|
||||
```
|
||||
|
||||
### Parsing INI files with Lua
|
||||
|
||||
With the package location established, the next thing to do is to require the `inifile` library and then handle some OS logistics. Even though this is a simple example application, the code needs to get the user's home directory location from the OS and establish how to communicate filesystem paths back to the OS when necessary:
|
||||
|
||||
|
||||
```
|
||||
package.path = package.path .. ';local/share/lua/5.3/?.lua
|
||||
inifile = require('inifile')
|
||||
|
||||
\-- find home directory
|
||||
home = os.getenv('HOME')
|
||||
|
||||
\-- detect path separator
|
||||
\-- returns '/' for Linux and Mac
|
||||
\-- and '\' for Windows
|
||||
d = package.config:sub(1,1)
|
||||
```
|
||||
|
||||
Now you can use `inifile` to parse data from the config file into a Lua table. Once the data has been placed into a table, you can query the table as you would any other Lua table:
|
||||
|
||||
|
||||
```
|
||||
\-- parse the INI file and
|
||||
\-- put values into a table called conf
|
||||
conf = inifile.parse(home .. d .. 'myconfig.ini')
|
||||
|
||||
\-- print the data for review
|
||||
print(conf['example']['name'])
|
||||
print(conf['example']['species'])
|
||||
print(conf['example']['enabled'])
|
||||
```
|
||||
|
||||
Run the code in a terminal to see the results:
|
||||
|
||||
|
||||
```
|
||||
$ lua ./main.lua
|
||||
Tux
|
||||
penguin
|
||||
false
|
||||
```
|
||||
|
||||
That looks correct. Try doing the same for the `demo` block.
|
||||
|
||||
### Saving data in the INI format
|
||||
|
||||
Not all parser libraries read and write data (often called _encoding_ and _decoding_), but the `inifile` library does. That means you can use it to make changes to a configuration file.
|
||||
|
||||
To change a value in a configuration file, you set the variable representing the value in the parsed table, and then you write the table back to the configuration file:
|
||||
|
||||
|
||||
```
|
||||
\-- set enabled to true
|
||||
conf['example']['enabled'] = true
|
||||
conf['demo']['enabled'] = true
|
||||
|
||||
\-- save the change
|
||||
inifile.save(home .. d .. 'myconfig.ini', conf)
|
||||
```
|
||||
|
||||
Take a look at the configuration file now:
|
||||
|
||||
|
||||
```
|
||||
$ cat ~/myconfig.ini
|
||||
[example]
|
||||
name=Tux
|
||||
species=penguin
|
||||
enabled=true
|
||||
|
||||
[demo]
|
||||
name=Beastie
|
||||
species=demon
|
||||
enabled=true
|
||||
```
|
||||
|
||||
### Config files
|
||||
|
||||
The ability to save data about how a user wants to use an application is an important part of programming. Fortunately, it's a common task for programmers, so much of the work has probably already been done. Find a good library for encoding and decoding into an open format, and you can provide a persistent and consistent user experience.
|
||||
|
||||
Here's the entire demo code for reference:
|
||||
|
||||
|
||||
```
|
||||
package.path = package.path .. ';local/share/lua/5.3/?.lua'
|
||||
inifile = require('inifile')
|
||||
|
||||
\-- find home directory
|
||||
home = os.[getenv][8]('HOME')
|
||||
|
||||
\-- detect path separator
|
||||
\-- returns '/' for Linux and Mac
|
||||
\-- and '\' for Windows
|
||||
d = package.config:sub(1,1)
|
||||
|
||||
\-- parse the INI file and
|
||||
\-- put values into a table called conf
|
||||
conf = inifile.parse(home .. d .. 'myconfig.ini')
|
||||
|
||||
\-- print the data for review
|
||||
print(conf['example']['name'])
|
||||
print(conf['example']['species'])
|
||||
print(conf['example']['enabled'])
|
||||
|
||||
\-- enable Tux
|
||||
conf['example']['enabled'] = true
|
||||
|
||||
\-- save the change
|
||||
inifile.save(home .. d .. 'myconfig.ini', conf)
|
||||
```
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/6/parsing-config-files-lua
|
||||
|
||||
作者:[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_women_computing_2.png?itok=JPlR5aCA (Woman sitting in front of her computer)
|
||||
[2]: https://opensource.com/article/21/6/config-files-and-their-formats
|
||||
[3]: https://opensource.com/article/19/11/getting-started-luarocks
|
||||
[4]: https://opensource.com/article/20/11/macports
|
||||
[5]: https://opensource.com/article/20/6/homebrew-mac
|
||||
[6]: https://opensource.com/article/20/3/chocolatey
|
||||
[7]: https://www.freedesktop.org/wiki/Specifications
|
||||
[8]: http://www.opengroup.org/onlinepubs/009695399/functions/getenv.html
|
@ -0,0 +1,83 @@
|
||||
[#]: subject: (Program on FreeDOS with Bywater BASIC)
|
||||
[#]: via: (https://opensource.com/article/21/6/freedos-bywater-basic)
|
||||
[#]: author: (Jim Hall https://opensource.com/users/jim-hall)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
Program on FreeDOS with Bywater BASIC
|
||||
======
|
||||
Install Bywater BASIC on your FreeDOS system and start experimenting
|
||||
with BASIC programming.
|
||||
![woman on laptop sitting at the window][1]
|
||||
|
||||
In the early days of personal computing—from the late 1970s and through the 1980s—many people got their start with BASIC programming. BASIC was a universal programming language that came built into most personal computers, from Apple to IBM PCs.
|
||||
|
||||
When we started the FreeDOS Project in June 1994, it seemed natural that we should include an open source BASIC environment. I was excited to discover one already existed in Bywater BASIC.
|
||||
|
||||
The [Bywater BASIC website][2] reminds us that “Bywater BASIC implements a large superset of the ANSI Standard for Minimal BASIC (X3.60-1978) and a significant subset of the ANSI Standard for Full BASIC (X3.113-1987).” It's also distributed under the GNU General Public License version 2, which means it's open source software. We only want to include open source programs in FreeDOS, so Bywater BASIC was a great addition to FreeDOS in our early days.
|
||||
|
||||
We've included Bywater BASIC since at least FreeDOS Alpha 5, in 1997. You can find Bywater BASIC in FreeDOS 1.3 RC4 in the "Development" package group on the Bonus CD. Load this:
|
||||
|
||||
![Bywater BASIC][3]
|
||||
|
||||
Installing Bywater BASIC on FreeDOS 1.3 RC4
|
||||
(Jim Hall, [CC-BY SA 4.0][4])
|
||||
|
||||
FreeDOS installs the Bywater BASIC package in the `\DEVEL\BWBASIC` directory. Change to this directory with `CD \DEVEL\BWBASIC` and type `BWBASIC` to run the Bywater BASIC interpreter.
|
||||
|
||||
![Bywater BASIC][5]
|
||||
|
||||
The Bywater BASIC intepreter
|
||||
(Jim Hall, [CC-BY SA 4.0][4])
|
||||
|
||||
### Writing a sample program
|
||||
|
||||
Let me demonstrate Bywater BASIC by writing a test program. We'll keep this simple—print five random numbers. This requires only a few constructs—a loop to iterate over five values and a random number generator. BASIC uses the `RND(1)` statement to generate a random value between 0 and 1. We can use `PRINT` to display the random number.
|
||||
|
||||
One feature I like in Bywater BASIC is the integrated "help" system. There's nothing more frustrating than forgetting the syntax for a BASIC statement. For example, I always forget how to create BASIC loops. Do I use `FOR I IN 1 TO 10` or `FOR I = 1 TO 10`? Just type `help FOR` at the Bywater BASIC prompt and the interpreter displays the usage and a brief description.
|
||||
|
||||
![Bywater BASIC][6]
|
||||
|
||||
Use the "help" system as a quick-reference guide
|
||||
(Jim Hall, [CC-BY SA 4.0][4])
|
||||
|
||||
Another neat feature in Bywater BASIC is how it reformats your BASIC instructions, so they are easier to read. After typing my brief program, I can type `list` to see the full source listing. Bywater BASIC automatically adds the `CALL` keyword to my `RANDOMIZE` statement on line 10 and indents the `PRINT` statement inside my loop. These small changes help me to see loops and other features in my program, which can aid in debugging.
|
||||
|
||||
![Bywater BASIC][7]
|
||||
|
||||
Bywater BASIC automatically reformats your code
|
||||
(Jim Hall, [CC-BY SA 4.0][4])
|
||||
|
||||
If everything looks okay, then type `RUN` to execute the program. Because I used the `RANDOMIZE` statement at the start of my BASIC program, Bywater _seeds_ the random number generator with a random starting point. This ensures that my numbers are actually random values and don't repeat when I re-run my program.
|
||||
|
||||
![Bywater BASIC][8]
|
||||
|
||||
Generating lists of random numbers
|
||||
(Jim Hall, [CC-BY SA 4.0][4])
|
||||
|
||||
Install Bywater BASIC on your FreeDOS system and start experimenting with BASIC programming. BASIC can be a great first programming language, especially if you are interested in getting back to the "roots" of personal computing. You can find more information about Bywater BASIC in the manual, installed in the `\DEVEL\BWBASIC` directory as `BWBASIC.DOC`. You can also explore the online "help" system by typing `HELP` at the Bywater BASIC prompt.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/6/freedos-bywater-basic
|
||||
|
||||
作者:[Jim Hall][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/jim-hall
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/lenovo-thinkpad-laptop-window-focus.png?itok=g0xPm2kD (young woman working on a laptop)
|
||||
[2]: https://sourceforge.net/projects/bwbasic/
|
||||
[3]: https://opensource.com/sites/default/files/uploads/bwbasic1.png (Installing Bywater BASIC on FreeDOS 1.3 RC4)
|
||||
[4]: https://creativecommons.org/licenses/by-sa/4.0/
|
||||
[5]: https://opensource.com/sites/default/files/uploads/bwbasic3.png (The Bywater BASIC intepreter)
|
||||
[6]: https://opensource.com/sites/default/files/uploads/randnum1.png (Use the "help" system as a quick-reference guide)
|
||||
[7]: https://opensource.com/sites/default/files/uploads/randnum2.png (Bywater BASIC automatically reformats your code)
|
||||
[8]: https://opensource.com/sites/default/files/uploads/randnum3.png (Generating lists of random numbers)
|
115
sources/tech/20210623 Python 3.10 beta in Fedora Linux.md
Normal file
115
sources/tech/20210623 Python 3.10 beta in Fedora Linux.md
Normal file
@ -0,0 +1,115 @@
|
||||
[#]: subject: (Python 3.10 beta in Fedora Linux)
|
||||
[#]: via: (https://fedoramagazine.org/python-3-10-beta-in-fedora-linux/)
|
||||
[#]: author: (Miro Hrončok https://fedoramagazine.org/author/churchyard/)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
Python 3.10 beta in Fedora Linux
|
||||
======
|
||||
|
||||
![][1]
|
||||
|
||||
The Python developers have already released three beta versions of Python 3.10.0. You can try the latest one in Fedora Linux today! Test your Python code with 3.10 early to be ready for the final 3.10.0 release in October.
|
||||
|
||||
### Install Python 3.10 on Fedora Linux
|
||||
|
||||
If you run Fedora Linux, you can install Python 3.10 from the official software repository with _dnf_:
|
||||
|
||||
```
|
||||
$ sudo dnf install python3.10
|
||||
```
|
||||
|
||||
You might need to enable the _updates-testing_ repository to get the very latest pre-release:
|
||||
|
||||
```
|
||||
$ sudo dnf install --enablerepo=updates-testing python3.10
|
||||
```
|
||||
|
||||
As more betas and release candidates [will be released][2], the Fedora package will receive updates. No need to compile your own development version of Python, just install it and have it up to date. The Python developers will add no new features starting with the first beta; you can already enjoy all the new things.
|
||||
|
||||
### Test your projects with Python 3.10
|
||||
|
||||
Run the _python3.10_ command to use Python 3.10 or create virtual environments with the [builtin _venv_ module, tox][3] or with [pipenv][4] and [poetry][5]. Here’s an example using _tox_:
|
||||
|
||||
```
|
||||
$ git clone https://github.com/benjaminp/six.git
|
||||
Cloning into 'six'...
|
||||
$ cd six/
|
||||
$ tox -e py310
|
||||
py310 run-test: commands[0] | python -m pytest -rfsxX
|
||||
================== test session starts ===================
|
||||
platform linux -- Python 3.10.0b3, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
|
||||
collected 200 items
|
||||
|
||||
test_six.py ...................................... [ 19%]
|
||||
.................................................. [ 44%]
|
||||
.................................................. [ 69%]
|
||||
.................................................. [ 94%]
|
||||
............ [100%]
|
||||
|
||||
================== 200 passed in 0.43s ===================
|
||||
________________________ summary _________________________
|
||||
py310: commands succeeded
|
||||
congratulations :)
|
||||
```
|
||||
|
||||
If you find a problem with Python 3.10 on Fedora Linux, please do [file bug reports at Fedora’s bugzilla][6] or in the [Python’s issue tracker][7]. If you aren’t sure if it is a problem in Python, you can [contact the Fedora’s Python maintainers][8] directly via email or IRC.
|
||||
|
||||
### What’s new in Python 3.10
|
||||
|
||||
See the [full list of news in Python 3.10][9]. You can, for example, try out [structural pattern matching][10]:
|
||||
|
||||
```
|
||||
$ python3.10
|
||||
Python 3.10.0b3 (default, Jun 17 2021, 00:00:00)
|
||||
[GCC 10.3.1 20210422 (Red Hat 10.3.1-1)] on linux
|
||||
Type "help", "copyright", "credits" or "license" for more information.
|
||||
>>> point = (3, 10)
|
||||
>>> match point:
|
||||
... case (0, 0):
|
||||
... print("Origin")
|
||||
... case (0, y):
|
||||
... print(f"Y={y}")
|
||||
... case (x, 0):
|
||||
... print(f"X={x}")
|
||||
... case (x, y):
|
||||
... print(f"X={x}, Y={y}")
|
||||
... case _:
|
||||
... raise ValueError("Not a point")
|
||||
...
|
||||
X=3, Y=10
|
||||
>>> x
|
||||
3
|
||||
>>> y
|
||||
10
|
||||
```
|
||||
|
||||
And stay tuned for [Python 3.10 as _python3_ in Fedora Linux 35][11]!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://fedoramagazine.org/python-3-10-beta-in-fedora-linux/
|
||||
|
||||
作者:[Miro Hrončok][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://fedoramagazine.org/author/churchyard/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://fedoramagazine.org/wp-content/uploads/2021/06/python310-beta-816x345.jpg
|
||||
[2]: https://www.python.org/dev/peps/pep-0619/
|
||||
[3]: https://developer.fedoraproject.org/tech/languages/python/multiple-pythons.html
|
||||
[4]: https://fedoramagazine.org/install-pipenv-fedora/
|
||||
[5]: https://python-poetry.org/
|
||||
[6]: https://bugzilla.redhat.com/buglist.cgi?component=python3.10&product=Fedora
|
||||
[7]: https://bugs.python.org/
|
||||
[8]: https://fedoraproject.org/wiki/SIGs/Python#Communicate
|
||||
[9]: https://docs.python.org/3.10/whatsnew/3.10.html
|
||||
[10]: https://www.python.org/dev/peps/pep-0634/
|
||||
[11]: https://fedoraproject.org/wiki/Changes/Python3.10
|
Loading…
Reference in New Issue
Block a user