beeb

joined 2 years ago
[–] [email protected] 22 points 6 days ago (6 children)

I prefer main simply because it faster to type. I propose main branches be renamed to "m"

[–] [email protected] 2 points 6 days ago

It's like vim but with lsp support out of the box and the keybindings make sense

[–] [email protected] 1 points 2 weeks ago

I'm afraid I can't recommend anything as I've never had issues with this, so I never really researched it. But if the banding frequency changes from print to print, then an issue with the Z axis is unlikely

[–] [email protected] 3 points 2 weeks ago (2 children)

What is driving the bed height? Lead screws? Check if they are straight and/or wobble around as they turn. Any imprecision in bed height due to mechanical issues with the Z axis would also translate into perimeter width variations.

[–] [email protected] 4 points 3 weeks ago* (last edited 3 weeks ago)

If you want polymorphism which looks more like what you're describing, you can put trait bounds on parameters instead of a type and it will accept any parameter that implement those traits. E.g. If you want to accept anything that can be turned into an owned string with ".into()" you type an argument with "impl Into". Another common one is "impl AsRef" to accept a path, path reference, PathBuf etc.

[–] [email protected] 1 points 4 weeks ago (1 children)

Note that there are many security concerns with this, notably the fact that there is no input validation on the id path segment which means you can get the content of any file (e.g. http://localhost:3000/src%2Fmain.rs). It's also very easy to scrape the content of all the files because the IDs are easy to predict. When the server reboots, you will overwrite previously written files because the counter starts back at zero. Using a UUID would probably mostly solve both these issues.

[–] [email protected] 1 points 4 weeks ago* (last edited 4 weeks ago) (2 children)

Here's a slightly more idiomatic version:

use std::{
    fs,
    sync::atomic::{AtomicUsize, Ordering},
};

use axum::{extract::Path, http::StatusCode, routing::get, routing::post, Router};

const MAX_FILE_SIZE: usize = 1024 * 1024 * 10;
static FILE_COUNT: AtomicUsize = AtomicUsize::new(0);

async fn handle(Path(id): Path<String>) -> (StatusCode, String) {
    match fs::read_to_string(id) {
        Ok(content) => (StatusCode::OK, content),
        Err(e) => (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()),
    }
}

async fn submit_handle(bytes: String) -> (StatusCode, String) {
    dbg!(&bytes);
    if bytes.len() > MAX_FILE_SIZE {
        // Don't store the file if it exceeds max size
        return (
            StatusCode::BAD_REQUEST,
            "ERROR: max size exceeded".to_string(),
        );
    }
    let path = FILE_COUNT.fetch_add(1, Ordering::SeqCst);
    if let Err(e) = fs::write(path.to_string(), bytes) {
        return (StatusCode::INTERNAL_SERVER_ERROR, e.to_string());
    }
    (StatusCode::CREATED, format!("http://localhost:3000/%7Bpath%7D"))
}

#[tokio::main]
async fn main() {
    let app = Router::new()
        .route("/", get(|| async { "Paste something in pastebin! use curl -X POST http://localhost:3000/submit -d 'this is some data'" }))
        .route("/{id}", get(handle))
        .route("/submit", post(submit_handle));

    let listener = tokio::net::TcpListener::bind("127.0.0.1:3000")
        .await
        .unwrap();
    axum::serve(listener, app).await.unwrap();
}

Note that there are no unwrap in the handlers which would absolutely want to avoid (it would crash your server). The endpoints now also return the correct HTTP code for each case. Some minor changes regarding creating the string values (use of format! and to_string() on string slices). Lemmy messes with the curly braces in the format! macro, there should be curly braces around the path variable name.

[–] [email protected] 1 points 4 weeks ago (2 children)

Fetch add will return the old value before updating it so you don't need the ".load" call above it!

[–] [email protected] 4 points 4 weeks ago* (last edited 4 weeks ago) (7 children)

I will probably post an improved version (if you like) but the main point is that you do not need the atomic to be mut, and so you don't need unsafe. Have a look at https://doc.rust-lang.org/std/sync/atomic/struct.AtomicUsize.html#method.fetch_add too

[–] [email protected] 7 points 1 month ago (1 children)

Did you check out the Examples ?

[–] [email protected] 3 points 1 month ago* (last edited 1 month ago)

I can only guess the print orientation but it looks like curling to me. Basically on that side, the part cooling fan (or lack thereof) is making the plastic of overhangs curl more than on the opposite side which gives you this bad surface finish. Otherwise maybe a retraction issue but that would probably show in other places too (oozing).

[–] [email protected] 1 points 3 months ago

That was my point exactly :) glad you got it

 

I have a lot of problems with stability using the linuxserver/transmission docker image in my *arr stack. I setup restarting on unhealthy status in docker compose (using the following test command curl --fail http://localhost:9091 || exit 1) but even then, sometimes I just find that my donwloads have stopped and find that the container is not running at all. Do you have an alternative to suggest, which could run in docker compose?

8
submitted 1 year ago* (last edited 1 year ago) by [email protected] to c/[email protected]
 

I'm trying to block the Lemmit.online bot but its profile doesn't load for me : lemm.ee/u/[email protected]

Is it loading for you?

Edit : I managed to block it from one of the community feeds UI, but its still weird that the profile doesn't load through lemm.ee

view more: next ›