小编mep*_*erp的帖子

便携式Windows Mosh?

我想知道是否有办法在没有Cygwin的Windows 上使用Mosh
我需要能够将它放在我的USB驱动器上并将其复制到Windows计算机上并能够将Mosh插入我的一台服务器中.否则,有没有办法使用Cygwin并让它可移植?我确实通过Cygwin在Windows下工作,但这意味着我必须为Windows计算机添加一个环境路径,在我正在处理的Windows计算机上,不允许你更改它,因为我不知道有管理员权限.

windows ssh portability mosh

28
推荐指数
4
解决办法
2万
查看次数

Rust Axum 获取完整 URI 请求

尝试获取完整的请求 URI(方案 + 权限 + 路径)

我找到了讨论:https://github.com/tokio-rs/axum/discussions/1149其中说 Request.uri() 应该有它。所以我尝试了以下方法:

use axum::body::Body;
use axum::http::Request;
use axum::routing::get;
use axum::Router;

async fn handler(req: Request<Body>) -> &'static str {
    println!("The request is: {}", req.uri());
    println!("The request is: {}", req.uri().scheme_str().unwrap());
    println!("The request is: {}", req.uri().authority().unwrap());

    "Hello world"
}

#[tokio::main]
async fn main() {
    let app = Router::new().route("/test", get(handler));

    axum::Server::bind(&"0.0.0.0:8080".parse().unwrap())
        .serve(app.into_make_service())
        .await
        .unwrap();
}
Run Code Online (Sandbox Code Playgroud)

运行curl -v "http://localhost:8080/test"但我得到:

The request is: /test
thread 'tokio-runtime-worker' panicked at 'called `Option::unwrap()` on a `None` value', src/main.rs:8:59 …
Run Code Online (Sandbox Code Playgroud)

rust rust-axum

5
推荐指数
1
解决办法
3213
查看次数

GNU如何为不在同一目录中的文件制定静态模式规则?

我想使用make并创建一个静态模式规则,该规则的目标位于output目录中,并且前提文件位于先前的目录中,并且必须递归工作。

我这里有一个最小的例子:

.
??? anotherdir
?   ??? output
?   ?   ??? source3.md
?   ?   ??? source4.md
?   ??? source3.json
?   ??? source4.json
??? output
?   ??? source1.md
?   ??? source2.md
??? source1.json
??? source2.json
Run Code Online (Sandbox Code Playgroud)

我要生成output的目录,如果它们不存在,我想生成*.md从文件中*.json使用make,如果它们不存在,或*.json将被更新。

到目前为止,我有以下内容Makefile

SOURCE_FILES := $(shell find ./ -name "*.json")
OUTPUT_FILES := $(join $(addsuffix output/,$(dir $(SOURCE_FILES))), $(addsuffix .md,$(basename $(notdir $(SOURCE_FILES)))))

.PHONY: all
all: $(OUTPUT_FILES)

$(OUTPUT_FILES): %.md: %.json
    mkdir -p $(dir $@) …
Run Code Online (Sandbox Code Playgroud)

bash shell makefile

4
推荐指数
2
解决办法
78
查看次数

OpenGL Assimp导入的模型无法渲染

我正在尝试使用assimp加载模型.我正在尝试使用索引,但我的模型不起作用.我的代码没有错误(只是由于某种原因解析不能正常工作),这就是它:

void loadOBJ(const char *path,
    int &numOfVertices,
    int &numOfFaces,
    int &numOfIndices,
    std::vector<unsigned int> &outIndices,
    std::vector<float> &outVertices,
    std::vector<float> &outUVs,
    std::vector<float> &outNormals) {

    Assimp::Importer importer;
    const aiScene* scene = importer.ReadFile(path, aiProcessPreset_TargetRealtime_Fast);
    aiMesh* mesh = scene->mMeshes[0];

    numOfFaces = mesh->mNumFaces;
    numOfIndices = numOfFaces * 3;
    outIndices.resize(numOfIndices);

    for (unsigned int i = 0; i < mesh->mNumFaces; ++i) {
        const aiFace &face = mesh->mFaces[i];
        assert(face.mNumIndices == 3);
        outIndices[i * 3 + 0] = face.mIndices[0];
        outIndices[i * 3 + 1] = face.mIndices[1];
        outIndices[i * 3 + 2] …
Run Code Online (Sandbox Code Playgroud)

c++ opengl import assimp

3
推荐指数
1
解决办法
3657
查看次数

有序打印的Python多处理子流程?

我正在尝试并行运行一些Python函数,该函数在整个函数中都有打印命令。我想要的是让每个子进程运行相同的功能,以分组的方式输出到主标准输出。我的意思是,我希望每个子流程的输出仅在完成其任务后才打印。但是,如果在此过程中发生某种错误,我仍要输出子过程中所做的任何事情。

一个小例子:

from time import sleep
import multiprocessing as mp


def foo(x):
    print('foo')
    for i in range(5):
        print('Process {}: in foo {}'.format(x, i))
        sleep(0.5)


if __name__ == '__main__':
    pool = mp.Pool()

    jobs = []
    for i in range(4):
        job = pool.apply_async(foo, args=[i])
        jobs.append(job)

    for job in jobs:
        job.wait()
Run Code Online (Sandbox Code Playgroud)

这是并行运行的,但是输出的是:

foo
Process 0: in foo 0
foo
Process 1: in foo 0
foo
Process 2: in foo 0
foo
Process 3: in foo 0
Process 1: in foo 1
Process 0: …
Run Code Online (Sandbox Code Playgroud)

python stdout multiprocessing

1
推荐指数
1
解决办法
2290
查看次数