• 1 Post
  • 26 Comments
Joined 2 years ago
cake
Cake day: July 17th, 2024

help-circle

    • When does 4 become 5?

    4.5 >=? Lots of programming languages define casting as the largest integer value, not the the rounded value. Outside of programming, there are scenarios where 4 cannot be rounded to 5 either… Like a height requirement for a ride at an amusement park. Though, it might seem natural to round it to humans.

    • When does green become black in a gradient?

    With computer languages, we define colors with red, blue, and green. The above is a gradient on horizontal x-axis, with

    (r = 0, g = x, b = 0) 
    

    This is more complicated. If we surveyed 1 million people, maybe we’d get a plot that defined the start of green as something like the following.

    And then maybe we could take the the average and state that as green.

    Though, is that really good enough description of green to serve as a legal definition of green? Maybe lawyers would select significantly different results than the general population when surveyed for the value of green. Maybe the results should be restricted to lawyers?

    • And when does 2 become 7?

    If we restricted it pixels to a 3x5 grid…

    We could possibly define 2 and 7.

    But then is this a 2 or a 7?




  • It’s easy to build most flatpaks on flathub into bundles from source.

    An example building KDE's weather application from source
    # Setup for building bundles
    sudo apt install flatpak flatpak-builder git
    flatpak remote-add --if-not-exists --user flathub https://dl.flathub.org/repo/flathub.flatpakrepo
    flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
    
    # Building flatpak bundles from source code
    git clone https://github.com/flathub/org.kde.kweather 
    cd org.kde.kweather
    flatpak-builder --force-clean --user --install-deps-from=flathub --repo=repo builddir org.kde.kweather.json
    flatpak build-bundle repo org.kde.kweather.flatpak org.kde.kweather
    
    # Installing the build on any device that has completed setup
    flatpak install -y --user ./org.kde.kweather.flatpak
    
    # Running the installed flatpak
    flatpak run org.kde.kweather
    

    The flathub organization account contains everything needed for most applications on flathhub

    https://github.com/flathub

    edit: I write code sometimes, and building projects from source is often a painful process that can feel overwhelming and hopeless at times. I was really impressed when I realized this was possible, and went and built some of my favorite applications from source afterwards.







  • Sometimes it’s specific to the application. As an example, yt-dlp is redistributed by Canonical, and they usually maintain stable packages, but their versions seem to lag like 6 months. This might be related to their desire for stability, or maybe just align to their release cycle. I don’t know.

    The issue is that yt-dlp needs to be updated more frequently because websites break their methods of downloading, so the version that follows the latest version seems to work better.

    I don’t think using PPA’s is usually recommended, (like in the photo) so I think I would recommend flatpaks first if the developer of the application maintains one themselves. (and you want to follow later releases.) Though, the first time I had to use flatseal to fix an application, I felt like flathub was a failed platform.








  • I just use autossh for it.

    I run an ssh connection to a VPS I pay like $5, which forwards a port there. The screen in the following command isn’t required, but I have it so I don’t have to keep the terminal window open.

    screen -d -m -S autossh.eastusa.keepalive autossh -M 33333 -R VPS_IP_HERE:5555:localhost:22 root@VPS_IP_HERE
    

    Then from other computers, to connect back

    ssh -L 5555:localhost:5555 root@VPS_IP_HERE
    ssh root@localhost -p 5555
    

    For remote computers connecting back, the first ssh connects to the VPS and forwards a port to the remote computer. Then the 2nd ssh connection uses the forwarded port to complete the ssh connection to the computer behind the IP that can’t port forward.


  • I like this solution more too, what about something like?

    code examples
    {
        spawn(async move {
            do_something_else_with(
                ^{ self.some_a.clone() },
                ^{ self.some_a.clone() },
                ^{ self.some_a.clone() },
            )
        });
    }
    

    Which desugars to

    {
        let (a, b, c) = (self.some_a.clone(), self.some_a.clone(), self.some_a.clone());
        
        spawn(async move {
            do_something_else_with(a, b, c)
        });
    }
    

    Then have like

    'super1: {
        'super2: {
            spawn(async move {
                do_something_else_with(
                    ^super1: { self.some_a.clone() },
                    ^super1: { self.some_a.clone() },
                    ^super1: { self.some_a.clone() },
                )
            });
        }
    }
    

    Which desugars to

    'super1: {
        let (a, b, c) = (self.some_a.clone(), self.some_a.clone(), self.some_a.clone());
    
        'super2: {
            spawn(async move {
                do_something_else_with(a, b, c)
            });
        }
    }
    

    And finally, the harder to read

    'super1: {
        'super2: {
            spawn(async move {
                do_something_else_with(
                    ^^{ self.some_a.clone() },
                    ^^{ self.some_a.clone() },
                    ^^{ self.some_a.clone() },
                )
            });
        }
    }
    

    Which desugars to

    'super1: {
        let (a, b, c) = (self.some_a.clone(), self.some_a.clone(), self.some_a.clone());
    
        'super2: {
            spawn(async move {
                do_something_else_with(a, b, c)
            });
        }
    }