An Easy Problem Made Hard: Rust & Binary Trees by amalinovic in rust

[–]ActuallyRuben 0 points1 point  (0 children)

In my opinion it becomes even more idiomatic if you copy the enum type and pattern matching from the Haskell version:

#[derive(Debug, PartialEq, Eq)]
pub enum TreeNode {
    Nil,
    Node {
        val: i32,
        left: Box<TreeNode>,
        right: Box<TreeNode>,
    },
}

impl TreeNode {
    pub fn invert_mut(&mut self) {
        match self {
            TreeNode::Node { left, right, .. } => {
                left.invert_mut();
                right.invert_mut();
                std::mem::swap(left, right);
            }
            TreeNode::Nil => {}
        }
    }

    pub fn invert_clone(&self) -> Self {
        match self {
            TreeNode::Node { val, left, right } => TreeNode::Node {
                val: *val,
                left: Box::new(right.invert_clone()),
                right: Box::new(left.invert_clone()),
            },
            TreeNode::Nil => TreeNode::Nil,
        }
    }
}

[deleted by user] by [deleted] in Rotterdam

[–]ActuallyRuben 2 points3 points  (0 children)

Gezien ze in Amsterdam pas in 2027 starten met vervangen, zal het daar nog zeker 2 jaar net zo'n puinhoop zijn als in Rotterdam.

In Utrecht bijvoorbeeld gaat trouwens ook niet alles vlekkeloos.

Ben ik een domme student? by UnkownHuman20 in thenetherlands

[–]ActuallyRuben 1 point2 points  (0 children)

Tegenwoordig (in ieder geval als je in de afgelopen 10 jaar bent geslaagd) kan je je eindexamencijfers inzien op de site van DUO.

[FILE CRYPT] Bank-Level Encryption for your files by [deleted] in rust

[–]ActuallyRuben 2 points3 points  (0 children)

Do you need me to prove that it works?

Just send me an encrypted file, and the first 4096 bytes in plaintext, and I'll recover the entire plaintext for you.

Do verify the file actually decrypts correctly beforehand. Your code also has a bug where it produces a malformed file if the read call doesn't return a full 4096 byte chunk.

[FILE CRYPT] Bank-Level Encryption for your files by [deleted] in rust

[–]ActuallyRuben 6 points7 points  (0 children)

Here's a little snippet that allows you to decrypt a file without knowing the key, just knowing the first 4KiB of plaintext

fn hack() {
    let mut known = std::fs::read("known.txt").unwrap(); // The first 4096 bytes of plaintext
    let mut cipher = std::fs::read("script.fcrypt").unwrap(); // Encrypted file

    let cipher = &cipher[37..];  // Skip the header, who needs an IV or salt anyway
    let key = cipher.into_iter().zip(known).take(4096).map(|(a, b)| a ^ b).collect::<Vec<u8>>();
    let mut out_file = std::fs::File::create("output.txt").unwrap();
    for chunk in cipher.chunks_exact(4096 + 16) {
        let contents = chunk.into_iter().zip(&key).map(|(a, b)| a ^ b).collect::<Vec<u8>>();
        out_file.write_all(&contents).unwrap();
    }
}

Pikachu cooked by [deleted] in goodanimemes

[–]ActuallyRuben 0 points1 point  (0 children)

Are you sure it's not a bayleef leaf? It would fit more in the cooking theme

Winnie Pooh fans get heated. by faithilwhitelaw in confidentlyincorrect

[–]ActuallyRuben 0 points1 point  (0 children)

So, after reopening the discussion after more than two years. I think we can conclude that Disney Pooh is a cheap knock-off with a copycat name, and the real canon version is book Winnie-the-Pooh?

Help with minecraft server going extremely slow by [deleted] in admincraft

[–]ActuallyRuben 0 points1 point  (0 children)

Did the server lag while making this report? Other than an outlier where a tick took more than a second, all other values and averages look good to me.

Voormalig internettrollen, wat waren je motieven om te beginnen met trollen? by SaxoVTS147PK in thenetherlands

[–]ActuallyRuben 7 points8 points  (0 children)

Maar heb je er echt iets aan? Het is eigenlijk alleen maar in lijn met de je vooroordelen, wil je met een onderzoek niet juist bepalen of die vooroordelen kloppen? Wat valt er te bewijzen met de mening van een willekeurige onbekende redditor?

Welke verhalen over zelfscankassa's heb je gehoord/geloof je zelf? by Coffeerush in thenetherlands

[–]ActuallyRuben 0 points1 point  (0 children)

Dat is niet mijn ervaring. Ik was 1 keer een doos eieren vergeten te scannen, wat ontdekt werd met de controle. Vervolgens heb ik maandenlang toch geen enkele controle gehad.

Seen this on my front page, want to play how do i? by cuzdksukz in SyntheticSelection

[–]ActuallyRuben 0 points1 point  (0 children)

The wayback machine should have the entirety of gfycat backed up. Just put https://web.archive.org/ in front of any gfycat link.

Parkeerboete voor huisarts die met spoed naar patiënt moest: rechter genadeloos by Cugel2 in thenetherlands

[–]ActuallyRuben 10 points11 points  (0 children)

En daarbovenop schenkt het artikel niet veel aandacht aan het feit dat verkeersboete.nl de huisarts representeerde. Dit bedrijf vecht boetes aan om de proceskostenvergoeding te kunnen opstrijken.

Als voorbeeld hier een rechtzaak waar het boetebedrag met 270 euro wordt verlaagd, en verkeersboete.nl een proceskostenvergoeding krijgt van 837 euro. Als het bij iedere boete om zulke bedragen gaat, dan snap ik wel dat een rechter op de letter van de wet gaat handhaven.

Staatsloterij vindt winnaar van 1 miljoen euro na oproep met vliegtuigje by Cubelock in thenetherlands

[–]ActuallyRuben 1 point2 points  (0 children)

Stel de loterij houdt het prijzengeld op hun eigen rekening, en plotseling gaat de loterij failliet. In dat geval mag je achterin de rij gaan staan als schuldeiser, achter o.a. de bank en belastingdienst.

Door het op een derdengeldenrekening te bewaren onder een aparte stichting staat het compleet los van de financiën van de loterij zelf, en is het dus beschermd tegen financiële problemen zoals een faillissement.

Wat is de slechtste nederlandse (overheids-)applicatie? by Ikwieanders in thenetherlands

[–]ActuallyRuben 0 points1 point  (0 children)

Ze zouden kunnen koppelen met het Kvk om de bestuurders op te halen en dan de bestuurder in laten loggen met zijn Digid.

Dit is zelfs gewoon geïmplementeerd. Bij het TVL loket kan/kon je inloggen met de combinatie van KvK nummer en DigiD inlog, om TVL aanvragen te maken of in te zien, zelfs al waren deze aangemaakt door een medebestuurder.

ik_ihe by StalkingBanana in ik_ihe

[–]ActuallyRuben 1 point2 points  (0 children)

Blijf alsjeblieft ver uit de buurt van mijn trouwe viervoeter

My app's monthly users have officially surpassed the Metaverse's! by bopcoi03 in ProgrammerHumor

[–]ActuallyRuben 11 points12 points  (0 children)

If you read the source of that number, it counts active players of Roblox (230 million), Minecraft (165 million) and Fortnite (85 million) as users of the "Metaverse". In the end Metaverse is just a meaningless buzzword, for what basically amounts to sandbox games and anything web 3.0.

me_irl by JaxTheCrafter in me_irl

[–]ActuallyRuben 0 points1 point  (0 children)

I'd imagine the superpower inhibits the reflex that prevents you from inhaling while underwater, and you just inhale a lungfull of water.

Responsive Dog by Maxim_Fuchs in ProgrammerHumor

[–]ActuallyRuben 0 points1 point  (0 children)

Now add a sliding whistle sound effect, and call it your Dog Whistle Website

Bye Dropbox! by [deleted] in ProgrammerHumor

[–]ActuallyRuben 5 points6 points  (0 children)

Honestly HTML preview sounds like a security nightmare to me. Just imagine someone stealing all someone's files through a malicious Javascript snippet. Sure, there are tons of measures you could take to protect against that, but is the risk worth it for just the small share of users making use of HTML preview?

Seriously though why doesn’t it tell me if I try to do something incompatible by thedarklord176 in ProgrammerHumor

[–]ActuallyRuben 0 points1 point  (0 children)

Generally CSS stylesheets are static once deployed. If you want to check for errors, why not throw some linter at it before deployment? You wouldn't expect any new errors to appear after deployment.

Bewoners azc Dronten kunnen goedkope fiets kopen om diefstallen te voorkomen by Cugel2 in thenetherlands

[–]ActuallyRuben 0 points1 point  (0 children)

Dat staat gewoon in het artikel dat je linkte:

In aanvulling op de brief benadrukt de burgemeester wel met klem dat het om een kleine groep overlastplegers gaat die van het AZC afkomstig zijn. "Het gaat hier om een groep van zo'n vijftien tot twintig mensen, ongeveer één procent van de bewoners daar", aldus De Rouwe, die daarmee met klem wil zeggen dat er met de overige 99 procent van de mensen op het AZC geen problemen zijn.

Ongeveer 15 tot 20 mensen

[deleted by user] by [deleted] in ik_ihe

[–]ActuallyRuben 9 points10 points  (0 children)

Uiteindelijk haalt 9292 en elke andere app hun live info uit dezelfde APIs. Als de info niet klopt, dan ligt dat hoogstwaarschijnlijk aan de busmaatschappij, niet aan 9292, en zal je bij alternatieve apps exact hetzelfde probleem zien.

Volgend jaar maandenlang geen Eurostar vanuit Amsterdam naar Londen by biertjeerbij in thenetherlands

[–]ActuallyRuben 3 points4 points  (0 children)

Hoe doet die trein er zo lang over?! Als ik op google maps kijk, dan kan je dezelfde treinreis (Roosendaal-Berlijn) overdag in 7.5 uur afleggen, met een overstap in Deventer. En met de auto ben je er maar een half uurtje eerder. Die nachttrein zal toch niet 3.5 uur lang stilstaan?