• 6 Posts
  • 25 Comments
Joined 10 months ago
cake
Cake day: March 28th, 2025

help-circle

  • SinTan1729@programming.devOPtoProgrammer Humor@programming.devRust bad Jai good
    link
    fedilink
    English
    arrow-up
    14
    arrow-down
    2
    ·
    29 days ago

    You’re spot on. The same people complain endlessly about Rust being used in the Linux kernel, even though the actual experts are happy with it. It’s just culture war bullshit.

    I didn’t know how much of a change Lunduke had had until recently, when I watched a video by Nicco. I used to watch his Linux Sucks videos 4-5 years ago, and he genuinely seemed like a chill dude.


  • Good work, but this can be done in a more efficient way by utilizing the qBittorrent API in more places. Also, you may wanna utilize gluetun’s VPN_PORT_FORWARDING_UP_COMMAND for calling the script.

    Here’s my script. I used bash since the gluetun container doesn’t have Python in it.

    Code
    #!/bin/sh
    
    # Adapted from https://github.com/claabs/qbittorrent-port-forward-file/blob/master/main.sh
    
    # set -e
    
    qbt_username="${QBT_USERNAME}"
    qbt_password="${QBT_PASSWORD}"
    qbt_addr="${QBT_ADDR:-http://localhost:8085/}"
    
    if [ -z ${qbt_username} ]; then
        echo "You need to provide a username by the QBT_USERNAME env variable"
        exit 1
    fi
    
    if [ -z ${qbt_password} ]; then
        echo "You need to provide a password by the QBT_PASSWORD env variable"
        exit 1
    fi
    
    port_number="$1"
    if [ -z "$port_number" ]; then
        port_number=$(cat /tmp/gluetun/forwarded_port)
    fi
    
    if [ -z "$port_number" ]; then
        echo "Could not figure out which port to set."
        exit 1
    fi
    
    wait_time=1
    tries=0
    while [ $tries -lt 10 ]; do
        wget --save-cookies=/tmp/cookies.txt --keep-session-cookies --header="Referer: $qbt_addr" --header="Content-Type: application/x-www-form-urlencoded" \
          --post-data="username=$qbt_username&password=$qbt_password" --output-document /dev/null --quiet "$qbt_addr/api/v2/auth/login"
    
        listen_port=$(wget --load-cookies=/tmp/cookies.txt --output-document - --quiet "$qbt_addr/api/v2/app/preferences" | grep -Eo '"listen_port":[0-9]+' | awk -F: '{print $2}')
    
        if [ ! "$listen_port" ]; then
            [ $wait_time -eq 1 ] && second_word="second" || second_word="seconds"
            echo "Could not get current listen port, trying again after $wait_time $second_word..."
            sleep $wait_time
            [ $wait_time -lt 32 ] && wait_time=$(( wait_time*2 )) # Set a max wait time of 32 secs
            tries=$(( tries+1 ))
            continue
        fi
    
        if [ "$port_number" = "$listen_port" ]; then
            echo "Port already set to $port_number, exiting..."
            exit 0
        fi
    
        echo "Updating port to $port_number"
    
        wget --load-cookies=/tmp/cookies.txt --header="Content-Type: application/x-www-form-urlencoded" --post-data='json={"listen_port": "'$port_number'"}' \
          --output-document /dev/null --quiet "$qbt_addr/api/v2/app/setPreferences"
    
        echo "Successfully updated port"
        exit 0
    done
    
    echo "Failed after 10 attempts!"
    exit 2
    

    For the auto-exit stuff, you may wanna check out docker’s healthcheck functionality.

    Not trying to put you down or anything here, it’s great to learn to do things by yourself. Just giving you some pointers.




  • Welcome to the club. Don’t worry too much about setting it up perfectly in your first attempt. You’re gonna rewrite your whole config every year-ish anyway. (Or is that just me? 😥) Also, try Neovim. It’ll be a drop-in replacement for your current config. But Lua is just a superior language compared to Vimscript, so you’ll have a much better performance in the future. You also get all the sweet LSP and treesitter features.








  • It’s like everything else, you need to actually do it to get better at it. The more you want and try to get better, the harder it’ll feel. The best way is to just enjoy doing it. But it’s easier said than done.

    For me personally, since it’s not my job, I don’t feel any pressure programming, and it’s kind of a stress reliever. I’m not very good at it anyway, but the improvements I’ve made were due to the fact that I didn’t feel any pressure in learning new things, and was able to do things at my own preferred pace. As an example, for the last few days I’ve been learning about the internal working of SQLite. It’s pretty complex, but I don’t feel like I need to know and remember everything, so it’s easier for me to actually get through it. (Btw, if anyone reading this has experience working with SQLite, let me know, I’d like to discuss some stuff. It’s about optimizing some queries, so you don’t need to know about the SQLite codebase, just a rough idea of how it works, and some experience with Rusqlite. Fwiw, happy to add you as a contributor in my project if any performance improvements come out of it.)

    But it’s a different story when it comes to learning stuff for my actual work. Even though the rewards are bigger, the process feels much worse. (Hating on Deligne-Serre representations right now. :( They’re beautiful objects, but the pressure to learn is just too much.)

    So, if you’re like me, try not to take it too seriously, and it’ll be easier to learn.