RunAwayFrog

joined 1 year ago
[–] RunAwayFrog@sh.itjust.works -1 points 3 weeks ago* (last edited 3 weeks ago)

We already knew it was from mastoclowns, for mastoclowns.
The details and which "e-celebs" are involved is immaterial.
No one relevant (or merely sane) cared, cares, or will ever care about that scene's rage-circlejerk choice of the day.

[–] RunAwayFrog@sh.itjust.works 4 points 7 months ago

Regarding Cargo.lock, the recommendation always was to include it in version control for application/binary crates, but not library ones. But tendencies changed over time to include it even for libraries. If a rust-toolchain file is tracked by version control, and is pinned to a specific stable release, then Cargo.lock should definitely be tracked too [1][2].

It's strictly more information tracked, so there is no logical reason not to include it. There was this concern about people not being aware of --locked not being the default behaviour of cargo install, giving a false sense of security/reliability/reproducibility. But "false sense" is never a good technical argument in my book.

Anyway, your crate is an application/binary one. And if you were to not change the "*" dependency version requirement, then it is almost guaranteed that building your crate will break in the future without tracking Cargo.lock ;)

[–] RunAwayFrog@sh.itjust.works 9 points 7 months ago (3 children)
  • Don't use "*" dep version requirements.
  • Add Cargo.lock to version control.
  • Why read to string if you're going to base64-encode and use Vec<u8> later anyway?
[–] RunAwayFrog@sh.itjust.works 2 points 11 months ago* (last edited 11 months ago)

Here is an originally random list (using cargo tree --prefix=depth) with some very loose logical grouping. Wide-scoped and well-known crates removed (some remaining are probably still known by most).

mime data-encoding percent-encoding textwrap unescape unicode-width scraper
arrayvec bimap bstr enum-iterator os_str_bytes pretty_assertions paste
clap_complete console indicatif shlex
lz4_flex mpeg2ts roxmltree speedy
aes base64 hex cbc sha1 sha2 rsa
reverse_geocoder trust-dns-resolver
signal-hook signal-hook-tokio
blocking
fs2
semver
snmalloc-rs
[–] RunAwayFrog@sh.itjust.works 4 points 11 months ago (1 children)

My quick notes which are tailored to beginners:

Use Option::ok_or_else() and Result::map_err() instead of let .. else.

  • let .. else didn't always exist. And you might find that some old timers are slightly triggered by it.
  • Functional style is generally preferred, as long as it doesn't effectively become a code obfuscater, like over-using Options as iterators (yes Options are iterators).
  • Familiarize yourself with the ? operator and the Try trait

Type inference and generic params

let headers: HashMap = header_pairs
        .iter()
        .map(|line| line.split_once(":").unwrap())
        .map(|(k, v)| (k.trim().to_string(), v.trim().to_string()))
        .collect();

(Borken sanitization will probably butcher this code, good thing the problem will be gone in Lemmy 0.19)

Three tips here:

  1. You don't need to annotate the type here because it can be inferred since headers will be returned as a struct field, the type of which is already known.
  2. In this pattern, you should know that you can provide the collected type as a generic param to collect() itself. That may prove useful in other scenarios.
  3. You should know that you can collect to a Result/Option if the iterator items are Results/Options. So that .unwrap() is not an ergonomic necessity 😉

Minor point

  • Use .into() or .to_owned() for &amp;str => String conversions.
    • Again, some pre-specialization old timers may get slightly triggered by it.

make good use of the crate echo system

  • It's important to make good use of the crate echo system, and talking to people is important in doing that correctly and efficiently.
    • This post is a good start.
    • More specifically, the http crate is the compatibility layer used HTTP rust implementations. Check it out and maybe incorporate it into your experimental/educational code.

Alright, I will stop myself here.

[–] RunAwayFrog@sh.itjust.works 12 points 1 year ago (2 children)

Broken input sanitization probably.

Issue will thankfully no longer exist in the next lemmy release.

[–] RunAwayFrog@sh.itjust.works 4 points 1 year ago

lemmy deleted everything between the “less than” character and “>”.

Lemmy also escaped the ampersands in their comment's link 😉

Isn't broken sanitization great!

[–] RunAwayFrog@sh.itjust.works 4 points 1 year ago* (last edited 1 year ago)

Next Day Edit: Sorry. Forgot to use my Canadian Aboriginal syllabics again. Because apparently it's too hard to admit HTML-sanitizing source markdown was wrong!

One thing that irks me in these articles is gauging the opinion of the "Rust community" through Reddit/HN/Lemmy😉/blogs... etc. I don't think I'd be way off the mark when I say that these platforms mostly collectively reflect the thoughts of junior Rustaceans, or non-Rustaceans experimenting with Rust, with the latter being the loudest, especially if they are struggling with it!

And I disagree with the argument that poor standard library support is the major issue, although I myself had that thought before. It's definitely current lack of language features that do introduce some annoyances. I do agree however that implicit coloring is not the answer (or an answer I want to ever see).

Take this simple code I was writing today. Ideally, I would have liked to write it in functional style:

    async fn some_fn(&self) -> OptionᐸMyResᐸVecᐸu8ᐳᐳᐳ {
        (bool_cond).then(|| async {
            // ...
            // res_op1().await?;
            // res_op2().await?;
            // ...
            Ok(bytes)
        })
    }

But this of course doesn't work because of the opaque type of the async block. Is that a serious hurdle? Obviously, it's not:

    async fn some_fn(&self) -> OptionᐸMyResᐸVecᐸu8ᐳᐳᐳ {
        if !bool_cond {
            return None;
        }

        let res = || async {
            // ...
            // res_op1()?;
            // res_op2()?;
            // ...
            Ok(bytes)
        };

        Some(res().await)
    }

And done. A productive Rustacean is hardly wasting time on this.

Okay, bool::then() is not the best example. I'm just show-casing that it's current language limitations, not stdlib ones, that are behind the odd async annoyance encountered. And the solution, I would argue, does not have to come in the form of implicit coloring.

[–] RunAwayFrog@sh.itjust.works 3 points 1 year ago* (last edited 1 year ago)

Practically speaking, you don't have to.

Your executor of choice should be doing tokio compat for you, one way or another, so you don't have to worry about it (e.g. async-global-executor with the tokio feature).

async-std is dead.

[–] RunAwayFrog@sh.itjust.works 3 points 1 year ago

I do, however, hold to the fact that any sudo implementation will be more complicated than doas. Sudo, as a project, has more options and usecases than doas so it also has more posibilities for bugs or misconfiguration for the user.

Fair.

I’m unable to tell what codebase your are refering to with you’re grep arguments, sorry.

sudo-rs

 

In a comment I wrote, I was surprised to see something I didn't write showing up, in the form of a third dot.

So, where did the third dot come from?

Well, markdown-it has an extension where "typographic replacements" are done. You can see them all in action here (tick typographer on and off).

So, wherever two or more dots are written, even if around quotes, three dots will be rendered ('..' => '..')

While it may seem nice, this is more trouble than good IMHO. Not to mention the fact that people using other apps, utilizing other markdown implementations, will not see what others see (which is why some of you probably had no idea what the hell I was talking about at the start of this post).

It is my opinion that use of non-standard markdown extensions should be kept to a minimum, or preferably not used at all. And since a new UI is going to be written (which may open the possibility to use a high-quality markdown Rust crate), this should be a deliberate implementation choice going forward.

 
{"msg":"Error in store"}

Or the longer version:

< HTTP/2 500
< server: nginx
< date: Sat, 15 Jul 2023 06:45:55 GMT
< content-type: application/json
< content-encoding: gzip
< access-control-expose-headers: content-encoding, vary, content-type, date, content-length
< vary: accept-encoding, Origin, Access-Control-Request-Method, Access-Control-Request-Headers
<
* Connection #0 to host sh.itjust.works left intact
{"msg":"Error in store"}
 

Using this with Stylus:

li .comment-node {
    padding: 0.5ex;
    border: 0.1ex solid #80808060 !important;
    border-radius: 1ex;
}

li li .comment-node {
    border-left: none !important;
    border-top: none !important;
    border-radius: 1ex 1ex 1ex 0 !important;
}

Or for a more lightweight change:

.comment-node {
    border-bottom: 0.1ex solid #80808060 !important;

It's the lack of clearly visible separation between comments that just doesn't look right to me.

view more: next ›