Profile pic

SinTan1729, sintan1729@programming.dev

Instance: programming.dev
Joined: 10 months ago
Posts: 8
Comments: 86

RSS feed

Posts and Comments by SinTan1729, sintan1729@programming.dev

I would highly recommend the Framework 13. I’ve had it for a bit more than a year now. The only problem I’ve faced was that the WiFi card was a bit unstable in EndeavourOS. But that was fixed by replacing wpa_supplicant with iwd. (I hear that it was only an issue for the AMD version, and that it’s fixed now.) Battery life is fine for me. I limit charging at 70%, and that usually lasts me the whole day.

I love how Linux friendly it is. On my last laptop (an HP), it was pretty much impossible to upgrade the BIOS from inside Linux. Now it’s trivial. There’s also good support available when you face issues. (Both from Framework, and community members.) The hardware is pretty nice. I actually like how it’s MacBook-like, because it just looks nice in most settings. It’s portable too, I really hope they don’t make it bulkier like some folks here seem to demand.




Slightly off topic, but man, I wish there was a nice way to track all changes in all settings. I don’t really wanna go immutable. I also know about software that tracks directories like /etc as a git repo, but that’ll only track the newer changes. I want something that can help me replicate my current setup easily.


It’s fine. I’m not a professional, but I’ve used it before. It was enough for what I wanted to achieve.


If this were a single screen device, I would’ve given it some serious thought. I’m reading one page at a time, so I don’t see the point of a dual screen e-reader. Single screen would be cheaper, and also lighter.

I guess I’ll stick with my Kobo for now.



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.


Chhoto URL - It’s a simple URL shortener written in Rust.

I’ve written more programs, some of which are more useful in my daily life than this (e.g. movie-rename) but this is one that many seem to find interesting, and that’s kinda cool I guess. Also, I’m proud of some of my Lean code, but that stuff’s not published.


Oh, definitely. Its syntax is so simple, you can basically learn the basics over an afternoon. Outside of applications where consistent low latency is critical, if I can spare some extra RAM and CPU, I prefer Go to Rust.


Also useful for scripts to be executed inside containers. Alpine doesn’t have Python installed by default.


Been there, done that lol. Nowadays, if I think that some script is getting too long, I just rewrite it in Go. It’s faster to write than Rust (in fact, I find it almost as easy as Python), and performant enough for replacing scripts.


I have no experience in sysadmin work, but have some understanding of the Linux tools used. Can you eli5 what exactly is it that AD does? (Feel free not to, I just couldn’t find a good article, so decided to ask.)



Ah that makes sense. To be fair tho, there’s a lot of unwarranted hate towards Rust so it can be hard to tell.


I hope you’re joking. If anything, Rust makes error handling easier by returning them as values using the Result monad. As someone else pointed out, they literally used unwrap in their code, which basically means “panic if this ever returns error”. You don’t do this unless it’s impossible to handle the error inside the program, or if panicking is the behavior you want due to e.g. security reasons.

Even as an absolute amateur, whenever I post any Rust to the public, the first thing I do is get rid of unwrap as much as possible, unless I intentionally want the application to crash. Even then, I use expect instead of unwrap to have some logging. This is definitely the work of some underpaid intern.

Also, Python is sloooowwww.


KDE is great but do give some “better” distros like Fedora, or EndeavourOS (basically Arch) a try. Canonical, the company in control of Ubuntu, is a little bit shady.


I have a Framework 13 with the super button instead of Windows button, but I’ve set it up similarly to how the Windows buttons works in Windows. Pressing it by itself opens the KDE app menu, super+D goes to desktop, super+L locks screen, super+[ or ] moves around virtual desktops, super+W shows overview, supe+T shows tiles config, super+arrows do snapping, super+PgUp/PgDn/X for maximize/minimize/close etc.


RSS feed

Posts by SinTan1729, sintan1729@programming.dev

Comments by SinTan1729, sintan1729@programming.dev

I would highly recommend the Framework 13. I’ve had it for a bit more than a year now. The only problem I’ve faced was that the WiFi card was a bit unstable in EndeavourOS. But that was fixed by replacing wpa_supplicant with iwd. (I hear that it was only an issue for the AMD version, and that it’s fixed now.) Battery life is fine for me. I limit charging at 70%, and that usually lasts me the whole day.

I love how Linux friendly it is. On my last laptop (an HP), it was pretty much impossible to upgrade the BIOS from inside Linux. Now it’s trivial. There’s also good support available when you face issues. (Both from Framework, and community members.) The hardware is pretty nice. I actually like how it’s MacBook-like, because it just looks nice in most settings. It’s portable too, I really hope they don’t make it bulkier like some folks here seem to demand.




Slightly off topic, but man, I wish there was a nice way to track all changes in all settings. I don’t really wanna go immutable. I also know about software that tracks directories like /etc as a git repo, but that’ll only track the newer changes. I want something that can help me replicate my current setup easily.


It’s fine. I’m not a professional, but I’ve used it before. It was enough for what I wanted to achieve.


If this were a single screen device, I would’ve given it some serious thought. I’m reading one page at a time, so I don’t see the point of a dual screen e-reader. Single screen would be cheaper, and also lighter.

I guess I’ll stick with my Kobo for now.



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.


Chhoto URL - It’s a simple URL shortener written in Rust.

I’ve written more programs, some of which are more useful in my daily life than this (e.g. movie-rename) but this is one that many seem to find interesting, and that’s kinda cool I guess. Also, I’m proud of some of my Lean code, but that stuff’s not published.


Oh, definitely. Its syntax is so simple, you can basically learn the basics over an afternoon. Outside of applications where consistent low latency is critical, if I can spare some extra RAM and CPU, I prefer Go to Rust.


Also useful for scripts to be executed inside containers. Alpine doesn’t have Python installed by default.


Been there, done that lol. Nowadays, if I think that some script is getting too long, I just rewrite it in Go. It’s faster to write than Rust (in fact, I find it almost as easy as Python), and performant enough for replacing scripts.


I have no experience in sysadmin work, but have some understanding of the Linux tools used. Can you eli5 what exactly is it that AD does? (Feel free not to, I just couldn’t find a good article, so decided to ask.)



Ah that makes sense. To be fair tho, there’s a lot of unwarranted hate towards Rust so it can be hard to tell.


I hope you’re joking. If anything, Rust makes error handling easier by returning them as values using the Result monad. As someone else pointed out, they literally used unwrap in their code, which basically means “panic if this ever returns error”. You don’t do this unless it’s impossible to handle the error inside the program, or if panicking is the behavior you want due to e.g. security reasons.

Even as an absolute amateur, whenever I post any Rust to the public, the first thing I do is get rid of unwrap as much as possible, unless I intentionally want the application to crash. Even then, I use expect instead of unwrap to have some logging. This is definitely the work of some underpaid intern.

Also, Python is sloooowwww.


KDE is great but do give some “better” distros like Fedora, or EndeavourOS (basically Arch) a try. Canonical, the company in control of Ubuntu, is a little bit shady.


I have a Framework 13 with the super button instead of Windows button, but I’ve set it up similarly to how the Windows buttons works in Windows. Pressing it by itself opens the KDE app menu, super+D goes to desktop, super+L locks screen, super+[ or ] moves around virtual desktops, super+W shows overview, supe+T shows tiles config, super+arrows do snapping, super+PgUp/PgDn/X for maximize/minimize/close etc.


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.