voila:另类处理文件的方式
Voila 是一种通过 CLI 工具启动的特定领域语言,用于以快速可靠的方式处理大量文件和目录。
安装需要切换到 nightly 版本:
$ rustup default nightly
$ cargo install voila
一些使用实例:
# 删除创建日期在 2020年1月1日 之后的所有文件
$ voila ./backup "@creation=date >= 2020-01-01 { print(@name has been deleted) delete(@path) }"
# 删除文件名以 2020 结束的文件
$ voila ./backup "@name ~= #(.*)-2020# { print(@name has been deleted) delete(@path) }"
语法如下:
$ voila DIRECTORY "<@VARIABLE | STRING | /REGEXP/> OPERATOR <@VARIABLE | STRING | #REGEXP#> [|| | && ANOTHER_CONDITIONAL ...] {OPERATION1-CYCLE-1(ARG1 ARG1, ARG2) OPERATION2-CYCLE-1(ARG1 ARG2) ...; OPERATION1-CYCLE-2(ARG1, ARG2 ARG2, ARG3)...}"
GitHub:Alonely0/Voila: Voila is a domain-specific language launched through CLI tool for operating with files and directories in massive amounts in a fast & reliable way.
peekread:使 Read 流变得可窥视
获取任意 Read 流并在不消耗原始流的情况下 “窥视” 到流中:
use peekread::{PeekRead, SeekPeekReader};
let mut f = SeekPeekReader::new(File::open("ambiguous")?);
// HTML is so permissive its parser never fails, so check for signature.
if f.starts_with("<!DOCTYPE") {
Ok(ParseResult::Html(parse_as_html(f)))
} else {
// Can pass PeekCursor to functions accepting T: Read without them
// having to be aware of peekread.
parse_as_jpg(f.peek()).map(ParseResult::Jpg)
.or_else(|_| parse_as_png(f.peek()).map(ParseResult::Png))
.or_else(|_| parse_as_gif(f.peek()).map(ParseResult::Gif))
.or_else(|_| parse_as_javascript(f.peek()).map(ParseResult::Js))
}
GitHub 地址:orlp/peekread: Rust crate for making Read streams peekable.
onnxruntime-rs:ONNX 的 Rust 皮(V1.7)
来自维基百科的解释:ONNX(英语:Open Neural Network Exchange )是一种针对机器学习所设计的开放式的文件格式,用于存储训练好的模型。它使得不同的人工智能框架(如 Pytorch、MXNet)可以采用相同格式存储模型数据并交互。ONNX 的规范及代码主要由微软,亚马逊, Facebook 和 IBM 等公司共同开发,以开放源代码的方式托管在 Github 上。目前官方支持加载 ONNX 模型并进行推理的深度学习框架有:Caffe2, PyTorch, MXNet,ML.NET,TensorRT 和 Microsoft CNTK,并且 TensorFlow 也非官方的支持 ONNX。
GitHub:haixuanTao/onnxruntime-rs: Rust wrapper for Microsoft's ONNX Runtime (version 1.7)
sql-rs:内存数据库
一个为学习 ptest 解析器而构建的内存 SQL 数据库。一些例子:
$ cargo run --bin sql-rs -- -s test-files/seed.sql
...
> select * from users;
> select u.email, a.* from users as u join addresses as a on u.id = a.user_id where u.age > 22 and a.type = 'mail';
> select * from users as u left join addresses as a on false;
> select * from users as u right join addresses as a on false;
> select * from users order by age desc;
> select * from addresses order by street1 limit 2;
> select count(*) from addresses;
> update users set age = 22 where id = '1';
看样子是有一本书要写,不过还没开始。
GitHub:andrewhalle/byo-sql: An in-memory SQL database in Rust.
bustd:轻量进程杀手守护进程
相比 earlyoom 有更少的内存占用(注意是 Linux 系统的,不是跨平台的噢):
$ ps -F -C bustd
UID PID PPID C SZ RSS PSR STIME TTY TIME CMD
vrmiguel 353609 187407 5 151 8 2 01:20 pts/2 00:00:00 target/x86_64-unknown-linux-musl/release/bustd -V -n
$ ps -F -C earlyoom
UID PID PPID C SZ RSS PSR STIME TTY TIME CMD
vrmiguel 350497 9498 0 597 688 6 01:12 pts/1 00:00:00 ./earlyoom/
nut-client-rs:NUT Rust 客户端
一个 NUT(Network UPS Tools)的 Rust 客户端。
确认 UPS 已经连接:
upsc username@localhost ups.status
GitHub: aramperes/nut-client-rs: A Network UPS Tools (NUT) client library for Rust.
Prettier-Print
嗯,这个打出来的效果真的是这样的:
// 支持的 print
Type { a: "a", b: [0, 1], c: {"So": "pretty"} }
// 骚气的 print