aloso

joined 2 years ago
[–] aloso 1 points 2 years ago* (last edited 2 years ago) (2 children)

The majority of aircraft pilot fatalities occur in crashes of privately owned planes and helicopters rather than on regularly scheduled commercial jet aircraft.

https://www.ishn.com/articles/112748-top-25-most-dangerous-jobs-in-the-united-states

By the way, most deaths aren't reported on the news.

[–] aloso 11 points 2 years ago (2 children)

It is so frustrating when a conspiracy narrative is mixed with valid criticism, which ultimately only taints the criticism by association with the "conspiracy."

[–] aloso 3 points 2 years ago

Is that Professor McGonagall

[–] aloso 1 points 2 years ago (1 children)

That doesn't solve the issue that there are too few contributors. Requiring a review doesn't ensure that someone reviews the code.

[–] aloso 9 points 2 years ago

I guess it cannot be done if their IT infrastructure was not designed with that use case in mind. Although I'm not familiar with human resource management software, I don't find this hard to believe at all.

Also, you'll understand what Biron Tchaikovsky meant with "Please believe me" when you look at their email address. They already tried to do it, and probably complained many times before giving up.

[–] aloso 91 points 2 years ago (3 children)

Oh, didn't the domain somesoftwarecorp.com give it away?

[–] aloso 1 points 2 years ago (3 children)

On GitHub, everybody has the ability to review pull requests, even you. But there still aren't enough volunteers who review PRs.

[–] aloso 2 points 2 years ago (7 children)

Discriminant is irrelevant and you’re not supposed to fuck with it

It matters because the conversion between i32 and the Result is only "free" if they have the same layout (which they do not, because of the discriminant). So a more costly conversion method is required.

And there is zero reason to use unsafe/transmute for this.

You are right, because the compiler is able to optimize your code quite well. However, if that optimization were to break at some point (as there is no guarantee that an optimization will continue to work in the future), it would become less efficient.

[–] aloso 2 points 2 years ago* (last edited 2 years ago) (10 children)

This is not possible, because Rust still stores a discriminant even when the enum values don't overlap.

As far as I can tell, the only situation where Rust doesn't store a discriminant is when either the Ok or Err variant is zero-sized, and the other variant has a niche. So, Result<(), ErrorEnum> can be represented as an integer, but Result can not.

You can still use enums, and implement simple conversions like this:

#[repr(i8)]
pub enum Error {
    E1 = -1,
    E2 = -2,
    E3 = -3,
    E4 = -4,
}

#[repr(i8)]
pub enum Success {
    S0 = 0,
    S1 = 1,
    S2 = 2,
    S3 = 3,
}

pub type LibResult = Result;

pub fn number_to_result(value: i32) -> Option {
    match value {
        -4 ..= -1 => Some(Err(unsafe { std::mem::transmute(value as i8) })),
        0 ..= 3 => Some(Err(unsafe { std::mem::transmute(value as i8) })),
        _ => return None,
    }
}

pub fn result_to_number(res: LibResult) -> i32 {
    match res {
        Ok(value) => value as i32,
        Err(error) => error as i32,
    }
}

P.S. Sorry that the generics aren't displayed due to Lemmy's bad santiziation.

[–] aloso 6 points 2 years ago (1 children)

Lemmy is like Reddit, which is used a lot to ask questions and get help. But StackOverflow fills a different niche, it's meant to be useful to as many people as possible and stay up to date. This is why

  • there's a distinction between "comments" and "answers" (comments can be used to request additional information, and for meta discussion)
  • both questions and answers can be modified by other users, for example to
    • add more information, or remove unnecessary details
    • correct outdated information
    • fix typos and formatting
    • rephrase sentences that are confusing
  • a question can be closed as duplicate, so people always find the oldest thread of the question with the best/most detailed answers
  • before submitting a question, you get a list of related questions to avoid creating a duplicate question
  • questions have tags, making them easier to search for
[–] aloso 12 points 2 years ago* (last edited 2 years ago)

Iframes cannot access the main frame's DOM if the iframe is from a different origin than the main frame, and they never share the same JavaScript execution context, so an iframe can't access the main frame's variables etc.

It's not required that iframes run in a different process, but I think they do at least in Chrome and Firefox if they're from a different origin. Also, iframes with the sandbox attribute have a number of additional restrictions, which can be individually disabled when needed.

[–] aloso 13 points 2 years ago (2 children)

They still have their place; for example to embed Google Maps or a YouTube video. Generally, whenever you want to embed something from a different website you have no control over, that shouldn't inherit your style sheets, and should be sandboxed to prevent cross site scripting attacks.

view more: ‹ prev next ›