• 109 Posts
  • 181 Comments
Joined 2 years ago
cake
Cake day: June 15th, 2023

help-circle
  • I’d rather fix the problems incase it’s a weird config I have going.

    You have the perfect Linux user mindset. I am not saying this as an offense, rather a compliment. :-) I am also someone who investigates and searches the reason and solution of problems.

    Recently I had an issue for months, before its stable now (AMD on Linux, but with a specific game Marvel Rivals). The issue was so bad that I got multiple crashes per game session or match even. And either my method or the updates to the game, to the Linux core and drivers fixed it, or a combination of it. What I want to say is, maybe its an issue with the software or as you say, a configuration issue. So trying and finding a workaround might be worth it. Especially if you are happy with Nividia otherwise.


  • But this can lead to over engineering simple stuff. Which makes the code harder to read and maintain and more error prone. Especially if you don’t need all the other stuff for the class. Worse, if you define a class then you also tend to add more stuff you don’t use, just in case it might be useful.

    A simple variable name is sometimes the better solution. But it depends on the situation off course. Sometimes a new class make things more clear, as it abstracts some complexity away. Yeah, we need to find a balance and that is different for every program.


  • My rule of thumb is, use short names if the context makes it clear. But do not make names too long and complicated (especially with Python :D). For me having unique names is also important, so I don’t get confused. So not only too similar names are bad, especially if they all start like “path_aaa”, “path_bbb” and such, then the eye can’t distinguish them quickly and clearly. And searching (and maybe replace) without an IDE is easier with unique and descriptive names.

    Sometimes its better to come up with a new name, instead adding a modification and make the name longer. This could be in a for loop, where inner loops edit variables and create a variation of it. Instead adding something like “_modified”, try to find what the modification is and change from “date” to “now” instead “date_current”.









  • You don’t need to understand a command in order to copy paste an alias or Bash function. Especially newcomers could tend to do it, without knowing what the command actually does. We are also in a posting with helpful commands, so its double harmful. And you doubling down without adding any sort of disclaimer shows you don’t care.


  • Lemmy is a far better platform for discussions than Discourse in my opinion. The tree like sub-reply threads in each post (the Reddit concept) is preferable over a single thread of replies. You don’t need to cross quote and for readers no need to read the quote to see who and to what the reply is about. I don’t like Discourse discussion platforms at all.

    However, Discourse has a few features that fits well for a discussion platform. I like the tags and Trust system of it.





  • Here is on that I actually don’t use, but want to use it in scripts. It is meant to be used by piping it. It’s simple branch with user interaction. I don’t even know if there is a standard program doing exactly that already.

    # usage: yesno [prompt]
    # example:
    #   yesno && echo yes
    #   yesno Continue? && echo yes || echo no
    yesno() {
        local prompt
        local answer
        if [[ "${#}" -gt 0 ]]; then
            prompt="${*} "
        fi
        read -rp "${prompt}[y/n]: " answer
        case "${answer}" in
        [Yy0]*) return 0 ;;
        [Nn1]*) return 1 ;;
        *) return 2 ;;
        esac
    }
    

  • For the newer version of program, that’s why we have the $PATH. You put your program into one of the directories that is in your $PATH variable, then you can access your script or program from any of these like a regular program. Check the directories with echo "$PATH" | tr ':' '\n'

    My custom scripts and programs directory is “~/.local/bin”, but it has to be in the $PATH variable too. Every program and script i put there can be run like any other program. You don’t even need an alias for this specific program in example.


  • I’m not sure what you mean with the question. If you have any alias like alias rm='ls -l' in your .bashrc in example, then you cannot use the original command rm anymore, as it is aliased to something else. I’m speaking about the terminal, when you enter the command. However, if you put a backslash in front of it like \rm in the terminal, then the alias for it is ignored and the original command is executed instead.

    Edit: Made a more clear alias example.