Hi, i’m into programming, sexual transmutation and psychedelics!

  • 25 Posts
  • 67 Comments
Joined 1 year ago
cake
Cake day: June 13th, 2023

help-circle



  • Hi! First of all thank you so much for the detailed explanation!

    What I’m trying to do is scraping some content.

    Yes I’m trying to return all links (maybe in a vector), I have a list of elements (Select, which actually is scraper::html::Select<'_, '_>) which contain essentially html nodes selections, and I would like to grab each of them, extract the actual link value (&str), convert it into an actual String and push it firstly into a vector containing all the links and then in an istance of a struct which will contain several datas about the scraped page later.

    I was trying to use a for loop because that was the first structure that came to my mind, I’m finding it hard to wrap my head around ownership and error handling with rust, using the if let construct can be a good idea, and I didn’t consider the use of break!

    I also managed to build the “match version” of what I was trying to achieve:

    fn get_links(link_nodes: scraper::html::Select<'_, '_>) -> Vec<String> {
            let mut links = vec![];
    
            for node in link_nodes {
                match node.value().attr("href") {
                    Some(link) => {
                        links.push(link.to_string());
                    }
                    None => (),
                }
            }
    
            dbg!(&links);
            links
        }
    

    I didn’t understand that I had to return the same type for each of the Option match arms, I thought enum variants could have different types, so if the Some match arm returns (), also None has to do the same…

    If I try with a simpler example I still cannot understand why I cannot do something like:

    enum OperativeSystem {
                Linux,
                Windows,
                Mac,
                Unrecognised,
            }
    
            let absent_os = OperativeSystem::Unrecognised;
            find_os(absent_os);
    
            fn find_os(os: OperativeSystem) -> String {
                match os {
                    debian => {
                        let answer = "This pc uses Linux";
                        answer.to_string()
                    }
                    windows10home => {
                        let answer = "This pc uses Windows, unlucky you!";
                        answer.to_string()
                    }
                    ios15 => {
                        let answer = "This pc uses Mac, I'm really sorry!";
                        answer.to_string()
                    }
                    _ => {
                        let is_unrecognised = true;
                        is_unrecognised
                    }
                }
            }
    

    match is much more intuitive for a beginner, there’s a lot of stuff which go under the hood with ?















  • I mean theoretically if you are hosting your own chat server, for example on Matrix, you can easily make all the chats unaccessible from the clients by issuing a command to shutdown your server or simply the chat server service if there’s no content cached locally.

    I think you can do this pretty easily with a raspberry pi by connecting via ssh…

    Just use a shell script that changes the static ip to something else after the command to shutdown the service/wipe out the data (depending on what your goal is) has been issued, or use a vpn or something like that if possible, because anyone issuing the command would need to know your server ip.

    And issuing a command by ssh to a remote server both from smartphone or pc should be as easy that you can actually build a very small app for that, or use some app that creates shortcuts that directly connects and issue custom commands.

    That way you are forced to give people your new ip every time chats become unaccessible/deleted and someone can’t connect back even if wanting to without talking to you, unless you decide you can use the older ip for whatever reason.

    Of course not using your real ip but using some service like a vpn or proxy (or tor?) would be much better here, but i don’t really know how.

    That can give you full power on the chat history and create the said “panic button” for every client involved.







  • I’m actually curious on Rust, i don’t like how dispersive can be JavaScript, i prefer to build smaller, maybe uglier things, but that work and are nicely stable, scalable and can be integrated on multiple different platforms. Also i love that almost everything runs on Cargo and i don’t have to choose between 100 things that essentially cover the same target. I also think the Discord idea is quite good, i just want to find someone who is on my same level to grow / build cool things toghether, or small projects on which i can actively partecipate, there’s also an association near me that promotes opensource projects and give free code lessons, i might give it a try as well and see if i meet someone there. I’m gonna give it another try before deciding of giving up, i think it is deserved.



  • Honestly when i first got into coding i liked the fact it could give me jobs i could do from every part of the world, that is still on demand and that gave a certain freedom on how you approach technology and customize it to make it your own, i always liked to tinker around with computer and i even have a small home server i use for several stuff. I loved how useful internet was to find informations otherwise unreachable and share stuff without censorship woth everyone, as i said i love the story of the cypherpunk movement, i see bitcoin as a real solution to our obsolete economy, and i thought i would have liked to have a role into changing this shitty system paradigms, my target was to work with lightining network or similar protocols maybe one day. However i feel like i’m changing lately and i’m lacking human interactions so much, there’s no point in building something toghether if there’s no emotions to share with others before, during and after the process. Maybe it’s just how i’m made, but i cannot stick to it, i just get super depressed and i see no point in doing it. Maybe i’m just lazy i don’t know, but it is like that.

    Adding the fact that sometimes i feel like technology controls me, and not the opposite despite all the efforts i make, feels just super wrong and not how i want to live.

    I’m studying webdevelopment so i’ve had the opportunity to work only on simple stuff so far, but it already feels super overwhelming, sometimes i get lost just in setting up my coding environment, just to realize it will only be one of many i’ll need to learn how to work with.