nous

joined 2 years ago
[–] nous@programming.dev 7 points 7 months ago

Structs are the AND data type in rust (ie it contains all the fields defined). As opposed to Enums which are the OR type (which can only be one of the variants defined). You also have ananomous data types like tuples or arrays.

The point about methods applies to any type in rust, structs are not unique or special there. Rust does not revolve around the struct type like other languages revolve around the class type.

[–] nous@programming.dev 2 points 7 months ago

Well, can only read the first line:

SUHL, Germany—Ten years ago, this town in central Germany was aging, rapidly depopulating and almost universally white. Today, its population has stabilized, is younger and includes people from 92 countries.

But that sounds like a good thing? Well for everyone but the racists. I am going to guess the rest of the article is not worth reading.

[–] nous@programming.dev 3 points 7 months ago* (last edited 7 months ago)

Pipewire can talk to both pulseaudio and jack applications - it basically provides both APIs. It does not create a new one that things nee to implement. You may need to install a plugin to get it to talk with jack applications though - never needed to do that side of things myself.

[–] nous@programming.dev 36 points 7 months ago* (last edited 7 months ago) (6 children)

Give pipewire a go. It is basically replacing pulseaudio and jack as a combined thing and is meant to not have the latency issues that pulseaudio does.

[–] nous@programming.dev 2 points 7 months ago

If you are willing to install this, why not configure the system to block an IP if it starts connecting to multiple closed ports? Something like crowdsec or fail2ban can do this. Then the attacker gets far less info - looks like all ports are closed and can be done for more then 8 hours.

[–] nous@programming.dev 5 points 7 months ago

And every extra step adds more losses and reduces the efficiency. So it is worst then just using the fossil fuels directly.

[–] nous@programming.dev 7 points 7 months ago (2 children)

SIGINT is sent when you press Ctrl+C. SIGTERM is sent in just about every other situation - basically when the system wants the program to end. For instance when systemd wants to stop the service or the default signal with programs like kill pkill htop etc. You should catch both of these signals.

[–] nous@programming.dev 2 points 7 months ago (1 children)

🤔 I think the vt100 protocols (where the escape code come from) predate windows and I think all modern terminals still use those as the base. So I think they are cross platform. From a quick search it looks like they are the same codes on windows. So I dont think the libraries are doing anything special for cross platform support.

[–] nous@programming.dev 2 points 7 months ago

It intentionally doesn't support JavaScript to make things faster and much less resource intensive. Instead it contains an updated set of scripts that fix and improve various w

So won't work for most popular websites nowadays.

[–] nous@programming.dev 3 points 7 months ago (3 children)

Coloured text does not require a dep. It is just about printing the right colour codes like:

const BLACK: &'static str = "\u{001b}[30m";
const RED: &'static str = "\u{001b}[31m";
const GREEN: &'static str = "\u{001b}[32m";
const YELLOW: &'static str = "\u{001b}[33m";
const BLUE: &'static str = "\u{001b}[34m";
const MAGENTA: &'static str = "\u{001b}[35m";
const CYAN: &'static str = "\u{001b}[36m";
const WHITE: &'static str = "\u{001b}[37m";
const CLEAR: &'static str = "\u{001b}[0m";

fn main() {
    println!("{RED}red! {BLUE}blue!{CLEAR}");
}

The libraries just make it easier so you don't need to remember or know what those codes mean.

[–] nous@programming.dev 2 points 7 months ago (1 children)

Declare input in the loop. That limits scope which is basically always a good idea.

There is good reason to not do this. Though in this case it won't make much difference as performance is not an issue. But by having it outside the loop it allows the allocation of the string to be reused and in more complex programs is typically what you would want to do - allocate once outside the loop and reuse that inside.

In this case waiting on user input is going to outweigh any performance benefit I would not call it out as bad practice either.

[–] nous@programming.dev 7 points 7 months ago (1 children)

That beaker does not look half full to me. Many like 1/3rd full, or at least somewhere between that and half full.

view more: ‹ prev next ›