Death by a thousand microservices
TehPers @ TehPers @beehaw.org Posts 0Comments 687Joined 2 yr. ago
Tauri is also a more recent option, which uses the native webview. Not sure if it's suitable for production yet though.
It's a bit of a shame that HTML went from describing documents to describing UIs. I do miss the days of simple websites, although I'm not old enough to remember the old old internet.
"Today in class we will be finding out whether or not triangles will blend. Please put on these safety goggles before sitting at your desks."
And this is how we reached the point where sleep is more common in a classroom than anything else.
I think this has more to do with sleep deprivation. I can probably count the number of days I got a full night's rest while in high school and college on one hand. Rather than making classes more interesting (though they could do this as well I guess), they should focus on not completely overwhelming the students with homework, although I'll admit that was more of a college thing.
Hey at least they give you some books to read if you're bored. They're heavy as hell, but you might learn something and get a well needed break from the phone.
I would also recommend one of its successors, Seed. It's like the TypeScript of Befunge.
Having tried to do this in Rust, the ActivityPub protocol is not very Rust-friendly. There's a lot of weirdness, like how objects can have multiple types at once (aka @type
is an array) and how JSON-LD allows for basically any format to be passed as long as an appropriate context is passed (and the json-ld
library has a lot of limitations from my experience including lack of serde
support and no framing). I've tried looking at how the ActivityPub implementation Lemmy uses works, but from what I can see it just ignores these problems entirely, which at least seems to be working out for them right now.
Thinking about it more, I'm convinced JSON-LD's completely dynamic format is what's making this so difficult.
Man there have been hot take after hot take in the programming communities over the past few days. Here, I'll give my hot take since nobody asked:
If I have to touch your code and I can't tell what inputs it's supposed to accept, what it should do with those inputs, and what outputs it should produce, I'm probably deleting your code and rewriting it from scratch. Same goes for if I can trivially produce inputs or states that break it. If your code is buggy, it's getting fixed, even if that takes a rewrite.
When working with others, write readable and maintainable code that someone with much less context than you can pick up and work on. It really doesn't matter if you need to use TypeScript, mypy, tabs, doc comments, or whatever to do it.
When doing your own project, it doesn't matter. It's your code, and if you can't understand it when you come back to it then you'll probably rewrite it into something better anyway.
It can with some glue code that you better be writing in TypeScript if you care about code quality.
(As far as I know, it can't manipulate the DOM directly. Maybe things changed in the past couple months since I checked, but I doubt it.)
I've played with some ideas, but turns out the ActivityPub protocol is extremely difficult to implement in strongly-typed languages, at least from my experience. Anyway, whoever picks this up, here's my sword!
One thing to keep in mind is that tracing
works on spans/events, so rather than the subscriber receiving a string log message, it's receiving some metadata and a collection of field/value pairs, where values can be a lot of different types. You may need to determine ahead of time which fields you want deduped (or which you don't want deduped).
As someone who has written some Python at work, whenever I need to work on some code without type hints, I spend way too much time trying to figure out what all the parameter types should be for functions. I can't be the only one doing this though, I've seen functions that assume their inputs are strings receiving pathlib.Path
on some uncommon branch that sure enough errors on some obscure user inputs.
I've been pushing mypy hard though. It's not perfect, but it works well enough that it's still worth using over not using. The biggest pushback has actually been from the amount of time we'd have to spend fixing type-related bugs instead of developing new features.
Ah, most laptops these days ship with an internal NVMe, so that's what I assumed you were comparing against. A USB 3.2 gen 2x2 enclosure will vastly outperform a SATA SSD I believe, again assuming it's the only device connected to your controller.
In this case, I don't think Sink
will let you selectively remove sources (although you can clear the sink if you want), but whenever you want to play a click you could clear the sink and append the clicking source to it. Alternatively, you could create a source that chains the clicking sound with something like Zero
and have it repeat indefinitely, but have the Zero
source play until you receive a new signal to play the click audio (and stop the source once you're done clicking).
I think how you should approach this depends on your architecture, so I'll give a couple approaches I would consider if I were trying to do this myself:
- For a blocking approach: I'd play the click sound once (using
.append
on the sink, for example), then useInstant::now() - last_instant
and pass whatever duration is left to wait off tothread::sleep
. This would look something like this (pseudo-ish code):rs
let mut audio_started = Instant::now(); for _click_idx in 0..num_clicks { sink.append(click_sound.clone()); // you can buffer the click_sound source and clone the buffer using .buffered() if needed let remaining = Instant::now() - audio_started; if remaining > Duration::ZERO { std::thread::sleep(remaining); } }
- For a non-blocking approach where you have a separate thread managing the audio, I'd use a channel or similar as a signal for when to play the click. Your thread could then wait until that signal is received and append the click sound to the sink. You'd basically have a thread dedicated to managing the audio in this case. If you want a more complicated version this as an example, here's a project where we used
rodio
withtauri
(like you) to queue up audio sources to be played on demand whenever the user clicks certain buttons in the UI. The general architecture is the same - just afor
loop listening for events from a channel, and then using those events to add sources to our output stream (though you can just use aSink
I believe to keep things simple).
Having been to quite a few countries in Europe, I've heard more about UK tourists than USA tourists, although the few UK tourists I met were friendly.
The USA is a massive country with hundreds of millions of people. There are rude people, but there are also friendly people. It just depends on where you are (and unfortunately in some places who you are). Having been to Seattle, people were generally friendly, but you can't blame the barista for wanting to get through the line that goes out the door and two blocks down the road.
Hurricane tip
So it's the perfect conversation starter, is what you're saying?
It means it made 100% sense.
If you want the source to repeat indefinitely, you can try calling repeat_infinite
on it. Combine that with pausable
/stoppable
, and use periodic_access
to occasionally check whether the audio source should be paused/stopped probably by using an Arc[AtomicBool]
(using square brackets because Lemmy hates angle ones).
It could look something like this:
rs
let src = ...; let stop = Arc::new(AtomicBool::default()); let stop2 = stop.clone(); let src = src .repeat_infinite() .stoppable() .periodic_access(Duration::from_millis(50), move |src| { if stop2.load(Ordering::Relaxed) { src.stop(); } }); // later on... stop.store(true, Ordering::Relaxed);
periodic_access
is also how Sink
controls the source when you want to pause/stop/etc it. You could probably use Sink
directly if you want more control over the source.
I wish languages were more willing to release breaking versions, like a C++ v2 or such. That's not to say languages don't already have breaking changes between versions (Python comes to mind), but it would allow people to start fresh and clean up obsolete designs and libraries.