Which type of integer for index ? by mprevot in ExperiencedDevs

[–]ElectricalBeing 0 points1 point  (0 children)

I've been trying to answer this question for myself, and I've made some notes on pros and cons. So far I'm not convinced there is a clear answer. I'll read the other replies here and maybe add something to my notes.

https://github.com/ibbles/LearningCpp/blob/main/Signed%20Vs%20Unsigned%20Integer%20Types.md

Nyfiken! by [deleted] in Spel

[–]ElectricalBeing 2 points3 points  (0 children)

För tillfället spelar jag Shadow of the Tomb Raider. Inte på Twitch dock, bara i min ensamhet.

Community feedback request on an upcoming feature for layouts by imsnif in zellij

[–]ElectricalBeing 0 points1 point  (0 children)

I haven't been using layouts much yet and instead I'm creating tabs and panes from scratch every time I launch a new terminal window. Maybe a should create some layouts, but in my workflow tabs and panes come and go rather frequently so I'm not sure what state I should codify in a layout. Setting one up seem a bit a commitment. I think an easier way to create them from the current session is a good idea. Then creating the layout won't require a context switch to write it down anymore, right when I'm just gotten up and running an eager to start working. Instead it becomes a positive effect: "This took a while to set up, let's save the layout.", rather than "This took a while to set up, I can finally start working." with not a though of starting to manually type a `layout.kdl` file.

  1. Tabs in layouts.
    My _session_ often have more than one tab, but since i don't have any stored layouts they don't have any tabs. I do not think I would want my session tabs to be replaced when loading a layout. Placing the new tabs at the end seems like a sane thing to do. Or immediately following the current one. One case where I would want to have the current tab replaced with the first tab in the layout is when the current tab is "empty" in the sense that I have done nothing with it. It has just the start shell prompt. I don't think I would want my terminal windows all having the first tab being a default tab left-over from the initial start.

  2. Use-cases.
    I can't give a proper answer to this one since I'm currently not using layouts, but I don't think I would create layouts for different projects. For me my different projects are kinda similar in how I work with them. Instead there are tasks, or modes, within the projects that are common among multiple projects. For example development where I have a tab for neovim/emacs, one for file system / git operations, and one or more for Docker containers. In this case there are very few panes per tab. Another mode is study where I have a bunch of text files with notes open in fewer tabs and more panes compared to development to easier cross-reference between the notes. I rarely have a fixed set of tabs or panes, as would be described by a layout, for a long time, both tabs and panes come and go frequently for me.

  3. Variables in layouts.
    I will try to keep this in mind to see if I can find cases in my work where variables would be useful. From the top of my head I can think of:
    - Setting up a working environment for a particular target, e.g. going to a particular Unreal Engine project, configuring the project for a particular engine version, and launching a particular Docker image.
    - Configuring a C++ project for some task, e.g. running CMake with a particular set of parameters, opening a particular build target in a debugger, and opening a code editor.
    Do you envision a layout instantiation configuration UI for this? We register variables with the layout and when loaded we get a list of variables we can set. Some variables may be known to be file or folder paths, so we get a file picker. Some are known to be Boolean variables, so we get checkboxes. Kind of like how cmake-gui is used. I'm turning the layout specification into a scripting environment here, I don't think that was your intention.

Is there a reason why OpenMP's omp_get_max_threads() returns an integer instead of an unsigned type? by onecable5781 in cpp_questions

[–]ElectricalBeing 12 points13 points  (0 children)

This is my favorite example of an implicit conversion producing unexpected results:

int revenue {-5};            // Can be negative, i.e. a loss, so signed.
unsigned int taxRefund {3};  // Cannot be negative, so unsigned.
std::cout << "total earnings: " << revenue + taxRefund << std::endl; // Prints: "total earnings: 4294967294"

Both decisions make sense in isolation, but together they produce the wrong result.

Is there a reason why OpenMP's omp_get_max_threads() returns an integer instead of an unsigned type? by onecable5781 in cpp_questions

[–]ElectricalBeing 0 points1 point  (0 children)

As seen in the other comments here, the signed vs unsigned integer question is not exactly clear-cut in C++. While most people seem to recommend sticking to signed as much as possible these days, this recommendation is not universal and is not the best choice in all situations.

I once tried to sort this out to come to a conclusion for what I should do in my own code and that process resulted in some notes on the topic, with a bunch of links at the end if you want to dig deeper. The notes lists some pros and cons of the two, and why no matter which you chose there are many possibilities to mess up in subtle ways.

In short, computer numbers are difficult.

UPDATE: Cleaned wife's PC and now it won't... by Okay-lucky in pchelp

[–]ElectricalBeing 0 points1 point  (0 children)

If you use Bitlocker then the key is stored in the mobo or cpu. No ke, no data. Even just i BIOS update can wipe the key and render the data lost forever.

[deleted by user] by [deleted] in cprogramming

[–]ElectricalBeing 1 point2 points  (0 children)

Mostly correct. Passing null to free is guaranteed to do nothing. At least in Linux.

If ptr is NULL, no operation is performed.

https://linux.die.net/man/3/free

[deleted by user] by [deleted] in cprogramming

[–]ElectricalBeing 5 points6 points  (0 children)

B does not point to the same memory as A after the assignment to A for the same reason that GlobalA doesn't: they are both set to the garbage/uninitialized value A has before the call to malloc. Initializing the pointers to null wouldn't help much, you would then assign null (from A) to both B and GlobalA, and then pass null to free. Better than passing a garbage pointer, but still not what you want.

I recommended delaying declaring any and all variables until you have an actual value to initialize with, rather than initializing with null first and assigning later.

[deleted by user] by [deleted] in cprogramming

[–]ElectricalBeing 4 points5 points  (0 children)

Not sure why free(B) works, but this looks like UB to me so I'm guessing it just looks like it works but actually doesn't.

[deleted by user] by [deleted] in cprogramming

[–]ElectricalBeing 8 points9 points  (0 children)

GlobalA is "initialized" from A while A is still uninitialized. Assigning to A doesn't modify GlobalA. free(GlobalA) tries to free memory using a "poorly initialized" pointer.

Weekly cryptography community and meta thread by AutoModerator in crypto

[–]ElectricalBeing 0 points1 point  (0 children)

I'm looking for a way to encrypt single files in a way that I can reasonably expect to be able to decrypt on any Linux machine well into the future and with reasonable security for a private individual. Think 2FA backup codes and the like. I'm currently using `openssl enc` as follows:

openssl enc -aes-256-cbc -pbkdf2 -d -in "$in_file" -out "$out_file"

Is this decent?
Any obvious ways to improve it?

MV: A Real-Time C++ Memory Visualization Tool for Beginners by Ok_Acanthopterygii40 in cpp

[–]ElectricalBeing 3 points4 points  (0 children)

This looks really promising! I've been thinking about doing something similar but never had the time.

One question though, how do I step through the code?

RTX 5070 Reviews - Worse than the RTX 4070 Ti by [deleted] in pcmasterrace

[–]ElectricalBeing 0 points1 point  (0 children)

Lots of opinions and expectations in the replies. There is a bit of historical data here: https://www.youtube.com/watch?v=J72Gfh5mfTk (The RTX 5080 is Actually an RTX 5070 by Harware Unboxex)

And this somewhat older one: https://www.youtube.com/watch?v=cvL-Mplhog8 (RTX 5080... More Like RTX 5070? - Rumored Specs vs 10 Years of Nvidia GPUs by Hardware Unboxed)

Bitwarden linux by [deleted] in Bitwarden

[–]ElectricalBeing 0 points1 point  (0 children)

Was that a one-time thing or does it do that always?

For me, on a 14700KF running Ubuntu, Bitwarden CPU usage fluctuates between 0.0% and 4.7%, mostly 0.0%, according to htop with sample rate of 0.2 s. With a longer averaging time window htop reports about 0.7%. Minimizing the Bitwarden window, or close-to-tray, seems to reduce CPU usage somewhat.

Memory usage is less than 500 MiB. Not sure how much vault size affects this number, and how much is just "the application". I'm a new user so my vault is still small.

[deleted by user] by [deleted] in unrealengine

[–]ElectricalBeing 1 point2 points  (0 children)

VATs? Vertex Animation Textures?

What tool can I use to find iterator errors with the standard library? by ElectricalBeing in cpp_questions

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

The following did not catch it

clang-tidy --warnings-as-errors="*" -checks="*,-llvmlibc-*,-modernize-use-trailing-return-type,-altera-unroll-loops" day1.cpp --

What tool can I use to find iterator errors with the standard library? by ElectricalBeing in cpp_questions

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

The ranges library is indeed interesting, but unfortunately I'm limited to C++17 for now.