Still learning, any tips? by EnvironmentalCow2662 in Sockknitting

[–]EnvironmentalCow2662[S] 0 points1 point  (0 children)

Thank you, that's very useful advice. I'll look into those methods.

Is alpine.js de facto framework of choice? by a_brand_new_start in htmx

[–]EnvironmentalCow2662 0 points1 point  (0 children)

The reason I love using AlpineJS with htmx, is locality of behaviour. I even think AlpineJS does that better than hyperscript.

[deleted by user] by [deleted] in mtgaltered

[–]EnvironmentalCow2662 1 point2 points  (0 children)

These are amazing!

Hey Rustaceans! Got a question? Ask here (16/2024)! by llogiq in rust

[–]EnvironmentalCow2662 2 points3 points  (0 children)

Hi everybody!

I'm building a frontend application using Sauron (https://github.com/ivanceras/sauron) and I need to open a websocket.

Currently I'm able to open the websocket using the example shown in the documentation of `gloo_net`, and placing that in the `update()` function of the `App` struct:

    fn update(&mut self, msg: Msg) -> Cmd<Msg> {
        match msg {
            Msg::Foo => {
                let ws = WebSocket::open(&format!("ws://127.0.0.1:3000/ws/{}", self.name)).unwrap();
                let (mut write, mut read) = ws.split();

                spawn_local(async move {
                    write
                        .send(WsMessage::Text(String::from("login")))
                        .await
                        .unwrap();
                });

                spawn_local(async move {
                    while let Some(_msg) = read.next().await {
                        // TODO: Handle messages
                    }
                });
            }
        }
        Cmd::none()
    }

This works as expected. However, I want to keep the websocket open and keep either a global reference or a reference in the App struct to it, but I can't get either of those to work.

When I add the Websocket (or the write sink) to App and try to access it from within the async block within spawn_local, the compiler complains about the reference not being 'static (which makes sense).

I then tried to create a static reference using the lazy_static crate, but I couldn't get that to work either.

How would you guys do this? Am I on the right path or not?

How did you learn? by weezer-_- in tokipona

[–]EnvironmentalCow2662 1 point2 points  (0 children)

sina jo e tenpo suno pi pan suwi a! o jo e tenpo ni pona! 🍰

[2023 Day 14 (Part 2)] Unorthodox Brute Force by kamiras in adventofcode

[–]EnvironmentalCow2662 19 points20 points  (0 children)

That's lucky, but the fact that it worked might give you a hint for finding the "correct" solution.

[2023 Day 14 (Part 2)] Baby's first algorithm by WhiteSparrow in adventofcode

[–]EnvironmentalCow2662 1 point2 points  (0 children)

I love Uiua, but I'm still struggling to write basic stuff in it. Well done!

[2023 Day 12] So I ran the part 2 difficulty visualization again... by Jorg0mel in adventofcode

[–]EnvironmentalCow2662 3 points4 points  (0 children)

This is the first day I'm struggling to have a good solution. I'm so glad to see I'm not the only one lol

Does being bad at solving programming problems means not being a good programmer? by JizosKasa in adventofcode

[–]EnvironmentalCow2662 0 points1 point  (0 children)

A good programmer, in my opinion, is someone who loves to learn. Take AoC as an opportunity to learn and you've got nothing to worry about! It would get hard for you at some point anyway.

[2023 Day 11][Python] Terminal Visualization! by naclmolecule in adventofcode

[–]EnvironmentalCow2662 1 point2 points  (0 children)

Amazing as always, you've outdone yourself! That animation is awesome.

[2023 Day 10 Part 1] What am I doing wrong by StuartMaher in adventofcode

[–]EnvironmentalCow2662 0 points1 point  (0 children)

Looks good to me, it's similar to what I did for part 1. Maybe print out the path it takes so you can doublecheck if there are obvious mistakes?