我正在尝试使用“entr”命令自动编译 Groff 文档。
我希望运行以下行:
refer references.bib $1 | groff -ms $1 -T pdf > $2
Run Code Online (Sandbox Code Playgroud)
遗憾的是,如果我尝试这样做,它只会编译一次:
echo $1 | entr refer references.bib $1 | groff -ms $1 -T pdf > $2
Run Code Online (Sandbox Code Playgroud)
我也尝试过以下操作,但它创建了一个无法用Ctrl+退出的无限循环C:
compile(){
refer references.bib $1 | groff -ms $1 -T pdf > $2
}
while true; do
compile $1 $2
echo $1 | entr -pd -s 'kill $PPID'
done
Run Code Online (Sandbox Code Playgroud)
这样做的正确方法是什么?
在工作线程之间共享线性任务以提高性能的最佳方式是什么?
以下面的基本 Deno Web 服务器为例:
主线程
// Create an array of four worker threads
const workers = new Array<Worker>(4).fill(
new Worker(new URL("./worker.ts", import.meta.url).href, {
type: "module",
})
);
for await (const req of server) {
// Pass this request to worker a worker thread
}
Run Code Online (Sandbox Code Playgroud)
工人.ts
self.onmessage = async (req) => {
//Peform some linear task on the request and make a response
};
Run Code Online (Sandbox Code Playgroud)
分配任务的最佳方式是否与此类似?
function* generator(): Generator<number> {
let i = 0;
while (true) {
i == 3 ? …Run Code Online (Sandbox Code Playgroud) 我是R的新手,正在尝试使用Hansard库。
有什么办法可以将任何查询的结果导出为Json而不是小标题?
library(hansard)
library(tibble)
#example query
z <- mp_vote_record(172, "aye", start_date = "2017-01-01", end_date = "2017-05-03")
print(z)
Run Code Online (Sandbox Code Playgroud)
提供输出:
# A tibble: 38 x 5
about title uin date_value date_datatype
<chr> <chr> <chr> <dttm> <chr>
1 722300 Early Parl~ CD:20~ 2017-04-19 00:00:00 POSIXct
2 714865 Pension Sc~ CD:20~ 2017-03-29 00:00:00 POSIXct
3 714866 Pension Sc~ CD:20~ 2017-03-29 00:00:00 POSIXct
4 714868 Pension Sc~ CD:20~ 2017-03-29 00:00:00 POSIXct
5 713962 Bus Servic~ CD:20~ 2017-03-27 00:00:00 POSIXct
6 713963 Bus Servic~ CD:20~ 2017-03-27 …Run Code Online (Sandbox Code Playgroud) bash ×1
deno ×1
groff ×1
javascript ×1
json ×1
node.js ×1
r ×1
shell ×1
tibble ×1
typescript ×1