17
submitted 1 week ago* (last edited 1 week ago) by Doods@infosec.pub to c/rust@programming.dev

It might be lack of sleep, but I can't figure this out.

I have a Label, and I want its text to be red when it represents an error, and I want it be green when it represent "good to go".

I found search result for C and maybe a solution for Python, but nothing for Rust.

I tried manually setting the css-classes property and running queue_draw(); it didn't work.

I can have a gtk::Box or a Frame that I place where the Label should go, then declare two Labels, and use set_child() to switch between them, but that seems like an ugly solution.

Do you have a solution?

SOLVED:

I have to add a "." before declaring a CSS "thing" for it to be considered a class.

Ex:

.overlay {
        background: rgba(60, 60, 60, 1);
        font-size: 25px;
}

instead of:

overlay {
        background: rgba(60, 60, 60, 1);
        font-size: 25px;)
}

Just use label.add_css_class(), label.remove_css_class() or label.set_css_classes() and make sure to properly load your CSS style sheets,

Source: the comment of d_k_bo@feddit.org

12
submitted 1 month ago by Doods@infosec.pub to c/rust@programming.dev

I was using Iced as a dependency, but wanted to tweak its source code for some reason, so I jumped into the folder where cargo downloads dependencies, and went into iced_wgpu 13.5 (I think that's the version).

I could make a change, then run

cargo clean -p iced_wgpu && cargo check

in my other project for instant feedback, yet it took rust_analyzer at least 5 whole minutes to stop hallucinating.

Can I disable some functionality of rust_analyzer? I only use it for jump-to-definition, linting and syntax highlighting; I don't even use autocomplete.

Setup:

  • Desktop that thermally throttles only when both the IGPU and the CPU are under full load, and is cool otherwise.

  • CPU: Intel I5-7500

  • RAM: 8 GiB DDR-4

  • Editor: NVIM v0.11.0-dev | Build type: RelWithDebInfo | LuaJIT 2.1.0-beta3 (I had the same issue with other versions as well).

TLDR

What can I disable in rust_analyzer to boost performance while maintaining jump-to-definition, linting and syntax-highlighting, or what can I do to boost rust_analyzer for big projects in general?

8
submitted 2 months ago by Doods@infosec.pub to c/rust@programming.dev

Another crazy idea I share with this website.

I was developing a game and an engine in Rust, so I was reading many articles, most of which criticize the 'borrow checker'.

I know that Rust is a big agenda language, and the extreme 'borrow checker' shows that, but if it weren't for the checker, Rust would be a straight-up better C++ for Game development, so I thought: "Why not just use unsafe?", but the truth is: unsafe is not ergonomic, and so is Refcell<T> so after thinking for a bit, I came up with this pattern:

let mut enemies = if cfg!(debug_assertions) {
    // We use `expect()` in debug mode as a layer of safety in order
    // to detect any possibility of undefined bahavior.
    enemies.expect("*message*");
    } else {
    // SAFETY: The `if` statement (if self.body.overlaps...) must
    // run only once, and it is the only thing that can make
    // `self.enemies == None`.
    unsafe { enemies.unwrap_unchecked() }
};

You can also use the same pattern to create a RefCell<T> clone that only does its checks in 'debug' mode, but I didn't test that; it's too much of an investment until I get feedback for the idea.

This has several benefits:

1 - No performance drawbacks, the compiler optimizes away the if statement if opt-level is 1 or more. (source: Compiler Explorer)

2 - It's as safe as expect() for all practical use cases, since you'll run the game in debug mode 1000s of times, and you'll know it doesn't produce Undefined Behavior If it doesn't crash.

You can also wrap it in a "safe" API for convenience:

// The 'U' stands for 'unsafe'.
pub trait UnwrapUExt {
    type Target;

    fn unwrap_u(self) -> Self::Target;
}

impl<T> UnwrapUExt for Option<T> {
    type Target = T;

    fn unwrap_u(self) -> Self::Target {
        if cfg!(debug_assertions) {
            self.unwrap()
        } else {
            unsafe { self.unwrap_unchecked() }
        }
    }
}

I imagine you can do many cool things with these probably-safe APIs, an example of which is macroquad's possibly unsound usage of get_context() to acquire a static mut variable.

Game development is a risky business, and while borrow-checking by default is nice, just like immutability-by-default, we shouldn't feel bad about disabling it, as forcing it upon ourselves is like forcing immutability, just like Haskell does, and while it has 100% side-effect safety, you don't use much software that's written in Haskell, do you?

Conclusion: we shouldn't fear unsafe even when it's probably unsafe, and we must remember that we're programming a computer, a machine built upon chaotic mutable state, and that our languages are but an abstraction around assembly.

13
OpenGL 1.5 support? (infosec.pub)
submitted 3 months ago* (last edited 3 months ago) by Doods@infosec.pub to c/bevy@programming.dev

I know the title looks insane, but hear me out.

I wanted to make a game, specifically an isometric 2.5D RPG game, nothing that fancy.

So I decided to write it in Rust because I... like Enums, or something, and I had already finished the concurrency chapter, so I should be able to hang on.

Bevy seemed like the most complete engine out there, if overkill for my use case, but it's presumably so modular I could de-bloat it adequately, But...

Someone I know has a laptop; it is old.

It is not super old, a Toshiba Portege R700 with a locked BIOS which took me 3 days to trick its Windows 10 boot loader into booting Debian, and accidentally, yet irresponsibly, broke Windows and installed Grub.

There is no reason the thing shouldn't be able to run my hypothetical game. I've personally seen it LANning Sven Co-Op (Half-Life Co-Op) not long ago; the beast could maintain 60FPS for a solid few minutes, before overheating and dropping to 5, but it should hold on better now that I installed GNU/Linux.

So I, just to make sure, ran the command that exposes the OpenGL version used by Mesa, and... Open GL (ES?) 1.5? I surely, need a plan.

I noticed this issue with many indies. Many would-run-on-a-2005-thinkpad games sacrifice this untapped market for features they never use, or worse, go against the artistic vision.

So, since Bevy is modular, can I, a humble would-be-intern, write a rendering backend for the 2003 specification, but not before learning what a rendering backend is?

Or can I, a seasoned searcher, find a premade solution solution for Bevy or any other Rust engine, made to use the 2003 spec, or even the 1992 1.0 spec?

Or would it be worthwhile, to construct an engine of mine?

Edit: Or can I, a man of determination, write an FFI for an existing C solution?

23
submitted 5 months ago* (last edited 5 months ago) by Doods@infosec.pub to c/pop_os@lemmy.world

I have written a calculator in Rust and libcosmic, the design is copied from gnome-calculator; I discovered 2 things:

  1. I don't like working on UIs.
  2. I have no idea how to transform

cosmic::widget::button::Builder

to

cosmic::widget::Button;

this code would be so much cleaner if I could return a button::standard() from a function.

The source code.

[-] Doods@infosec.pub 14 points 6 months ago* (last edited 6 months ago)

My emotions just stopped, so I can now think straight.

There are really only 2 changes that - in my eyes - should be made:

  • 8 space-long, hard tabs.
  • 80 character limit instead of 100.

I don't think a tool like rustfmt can affect most of the original guidelines, and it's generally compatible with the OG style by default.

Edit: I - surprisingly - never actually used rustfmt, so I will go now and test before I say something stupid.

Edit II: I just found this on their repo:

Rustfmt is designed to be very configurable.

Edit III: I tested rustfmt with:

hard_tabs = true

max_width = 80

It's great!

38
submitted 6 months ago* (last edited 6 months ago) by Doods@infosec.pub to c/linux@lemmy.ml

Tabs are 8 characters, and thus indentations are also 8 characters. There are heretic movements that try to make indentations 4 (or even 2!) characters deep, and that is akin to trying to define the value of PI to be 3.

I am in love with this awsome document; I love its guidelines, and coding conventions.

However, when Rust was introduced into the kernel, they butchered these beautiful guidelines, I know it's hard to look at such heretic actions, but you have to see this:

The default settings of rustfmt are used. This means the idiomatic Rust style is followed. For instance, 4 spaces are used for indentation rather than tabs.

How can this even relate to the ideology of the first document? I am deeply saddened by these new rules.

I know this is "The Rust experiment", but this must be fixed before it's too late! This has to reach someone.

A counter-argument might be:

The code should be formatted using rustfmt. In this way, a person contributing from time to time to the kernel does not need to learn and remember one more style guide. More importantly, reviewers and maintainers do not need to spend time pointing out style issues anymore, and thus less patch roundtrips may be needed to land a change.

And to that I say that rustfmt is configurable per project, and if it isn't, then it has to be. Doesn't something like .editorconfig exist?

Edit: I think I read enough comments to come up with a conclusion.

At first, forcing another language's code style upon another sounds backwards, but both styles are actually more similar than I originally though, the kernel's C style is just rustfmt’s default with:

  • 80 character line.
  • 8-space hard tabs.
  • Indentation limited to 3.
  • Short local-variable names.
  • Having function length scale negatively with complexity.

The part about switch statements doesn't apply as Rust replaced them with match.*

The part about function brackets on new lines doesn't apply because Rust does have nested functions.

The bad part about bracket-less if statements doesn't apply as Rust doesn't support such anti-features.

The part about editor cruft is probably solved in this day & age.

The rest are either forced by the borrow checker, made obsolete by the great type system, or are just C exclusive issues that are unique to C.

I left out some parts of the standard that I do not understand.

This all turned up to be an indentation and line-size argument. Embarrassing!

*: I experimented with not-indenting the arms of the root match expression, it's surprisingly very good for simple match expressions, and feels very much like a switch, though I am not confident in recommending to people. Example:

match x {
5 => foo(),
3 => bar(),
1 => match baz(x) {
	Ok(_) => foo2(),
	Err(e) => match maybe(e) {
		Ok(_) => bar2(),
		_ => panic!(),
		}
	}
_ => panic!(),
}

[-] Doods@infosec.pub 10 points 6 months ago

w-what... 2 days was a looong time of not watching news, apparently.

What happened?

[-] Doods@infosec.pub 12 points 7 months ago* (last edited 7 months ago)

Didn't eat it, have to wait for sunset.

Probably tastes the same as other cheap options, they rarely differ in taste.

Edit: I am really bad at tasting things, but I don't think it tasted different from what I expected.

387
submitted 7 months ago by Doods@infosec.pub to c/programmerhumor@lemmy.ml
[-] Doods@infosec.pub 16 points 7 months ago* (last edited 7 months ago)

These posts get tens of likes but no comments, because nobody knows what to say anymore. The situation is clear, the motives have been revealed and the details are trivial, and pointless.

Should we stop talking, the situation will only decline, but should we speak the declination will happen slower.

Edit: I wrote a comment that looks pretty cool & I am somewhat proud of it, actually

[-] Doods@infosec.pub 12 points 8 months ago

English people on their way to ruin the meaning of every word.

[-] Doods@infosec.pub 14 points 8 months ago

The KDE Plasma 6 open-source desktop environment

Makes me wonder, are there closed-source desktop environments for Linux?

[-] Doods@infosec.pub 13 points 9 months ago* (last edited 9 months ago)

Stop revealing our plans! Our police force can hardly arrest protestors fast enough!

-Most Governments

[-] Doods@infosec.pub 10 points 9 months ago* (last edited 9 months ago)

(I ~~didn't read~~ skimped through the article)

Just make games with older graphics; it's cheaper, reduces visual bloat, and encourages player imagination to fill in the gaps, and investing xxx million dollars in a video game is dumb.

[-] Doods@infosec.pub 39 points 9 months ago

Being an adult has nothing to do with age, I saw 30 year-old children and 13 year-old men.

[-] Doods@infosec.pub 9 points 10 months ago* (last edited 10 months ago)

So you're trying to tell me the governments of the west will honor their word when it's against their interests? when did that ever happen?

(The tldr is the last paragraph)

Edit : yes, they might send "supplies" and tell Isreal that what it's doing is "bad", but that's just talk, the real action is being committed against the only ones who took actions, the (organization in Yemen).

I don't fully agree with that group, but they're the only ones who took real action, unlike everyone else who just watched and told Isreal: "stop, please, it's not good".

When Russia invaded Ukraine*, every "Civilized" nation took immediate action, cut trade, sent weapons and sent financial support, even though Ukraine originally belonged to the Russian entity, trying to reclaim it was seen as tearing the flesh of all that's good and holy in this world.

*: A European, white, non-islamic nation.

But when it comes to Isreal, whom the US acknowledged as a sovereign state 5 minute after its conception, even though it's based in land it has no right to exist in, by genocing a population** undeserving of being killed. And not only that, Isreal was supported fully by the US and the EU in its every move, not necessarily in the methods, but in the goal, Giving the Jews what they want, a land from the Nile to that other river, and making the poor nations pay for it, as all others are "deserving of being slaves to them - Jews." as they say, ignoring the religious aspect of this conflict is ignorant.

** A middle-eastern, Arab, not so white, Islamic population.

A while back I heard something on lemmy about France supporting Isreal duo to its debt to the Jews for playing a role in the holocaust or something, while the holocaust is possibly the most over-exaggerated event in modern history, in death numbers and whatnot, it's still a horrible event, yet what that writer failed to say is that France, along with the US and many European nations, are guilty of many similar acts against the Muslim Middle Eastern population.

The west are currently controlling every Arab state by having important government members - literally the entire government in many cases - consist of puppets they control, by threatening them - the puppets - with their crimes against humanity, by which they can turn the world media on the at any moment and strip them of their power, and offering to point the attention of the world media away from them.

People on lemmy here like to complain about the 1%, the 0.01% and modern capitalism and billionaires, the leaders of the government ARE the 0.001% you morons, they don't have hearts, worship money, and don't mind doing anything to maintain their power, yes they are pretending to support Gaza even before the war to maintain public support, but the supplies they were sending before the war were just enough for the now-homeless (duo to the occupation) Palestinian population to just die slowly enough for it to not attract public attention. They were quick to blame Hamas for "stealing supplies meant to support the poor population" THAT'S how you support a homeless population, by giving them guns to fight for their rights and freedom.

(the last sentence reminded me of what someone told me about a Rambo movie, IDK anything a ku Rambo don't quote me on that)

1
submitted 10 months ago* (last edited 9 months ago) by Doods@infosec.pub to c/mineclone2@lemmy.world

This texture pack, called Minecraftclone, is the best MC texture pack for MCL out there, because the only competition is NS-textures and this one which doesn't have a download link.

All the textures are taken from Minecraft 1.20 except for:

  • Horses, taken from 1.12
  • Bells*
  • Any feature not present in vanilla MC*

*: They are taken from mods with varying levels of editing done by me.

This pack supports the following mods:

  • MineClone2 Emerald Stuff
  • More Ores*
  • Technic*

*: Partial support

This pack is a work-in-progress, and lacks:

  • Most trims.
  • Lectern.
  • Brewing Stand.
  • Sun & Moon

https://mega.nz/file/mcI1BIoI#jSB-T5RsZXzNpue4OEr_LQwZcEAbh-e_MOqbsFVT7SU

Keywords for search engines to increase visibilty:

  • Minecraft textures for Mineclone
  • MC textures for MCL
  • Minecraft texture pack for Mineclone

I am also planning promote the pack on r/Minetest if this post fails to attract search engine results.

6

I have a huge library of game EXEs on my computer, but they run at a 4:3 aspect ratio as they're old, Proton/Proton-GE/WINE-GE keep the aspect ratio and place black bars left and right, which is desireble, unlike wine who stocks them to the left side of the screen.

[-] Doods@infosec.pub 15 points 1 year ago

I didn't mean we should stop improving, what I meant is we should focus more on the efficiency and less on the raw power.

11
submitted 1 year ago* (last edited 1 year ago) by Doods@infosec.pub to c/diy@beehaw.org

I might clean under a non-functioning button after this.

I used an old charging cable with a broken micro USB port.

17
Is this fixable? (infosec.pub)
submitted 1 year ago* (last edited 1 year ago) by Doods@infosec.pub to c/diy@beehaw.org

My 9yr old sister felt something is preventing her leg from moving, so she used violence.

A joystick USB cable.

*Without buying - or ripping off - another USB head of course.

70
submitted 1 year ago by Doods@infosec.pub to c/gaming@beehaw.org

This might seem stupid, but hear me out.

Fallout 3 on Epic is 39 GiB, the reason for that huge size is you're forced to download all the language packs, same story for Tomb Raider and FFXIII.

As someone with a monthly data limit of 140 Gib, and who has to share it with a family, these - unnecessary - download sizes are unacceptable and make me want - and plan - to pirate the game -which even though I didn't play for I still legally own*- and only having to download 7 GiB.

I would've complained about disk space but you can just remove the extra languages conveniently located in saperate folders**.

This also applies to single player games with privacy-invasive DRM and usability-hurting DRM***, and for people who hate the idea of DRM in general.

*Own as a service and a using license.

**Unless you are tight on disk space and cannot fully download the game before removing the files.

**DOOM 2016 didn't work on Linux duo to the DRM being incompatible with proton.

view more: next ›

Doods

joined 1 year ago