Skip Navigation

InitialsDiceBearhttps://github.com/dicebear/dicebearhttps://creativecommons.org/publicdomain/zero/1.0/„Initials” (https://github.com/dicebear/dicebear) by „DiceBear”, licensed under „CC0 1.0” (https://creativecommons.org/publicdomain/zero/1.0/)H
帖子
20
评论
603
加入于
2 yr. ago

  • Thank you for the pointers! Didn't take it as a put down at all. I appreciate the feedback, and your bash script.

    I didn't realize that gluetun had added this functionality, so I'll likely implement that as the more efficient way to keep the port updated.

  • Thank you! I'm gonna take a look at flaresolvarr too.

  • Love this song

  •  
        
    find /path/to/starting/dir -type f -regextype egrep -regex 'some[[:space:]]*regex[[:space:]]*(goes|here)' -exec mv {} /path/to/new/directory/ \;
    
      

    I routinely have to find a bunch of files that match a particular pattern and then do something with those files, and as a result, find with -exec is one of my top commands.

    If you're someone who doesn't know wtf that above command does, here's a breakdown piece by piece:

    • find - cli tool to find files based on lots of different parameters
    • /path/to/starting/dir - the directory at which find will start looking for files recursively moving down the file tree
    • -type f - specifies I only want find to find files.
    • -regextype egrep - In this example I'm using regex to pattern match filenames, and this tells find what flavor of regex to use
    • -regex 'regex.here' - The regex to be used to pattern match against the filenames
    • -exec - exec is a way to redirect output in bash and use that output as a parameter in the subsequent command.
    • mv {} /path/to/new/directory/ - mv is just an example, you can use almost any command here. The important bit is {}, which is the placeholder for the parameter coming from find, in this case, a full file path. So this would read when expanded, mv /full/path/of/file/that/matches/the/regex.file /path/to/new/directory/
    • \; - This terminates the command. The semi-colon is the actual termination, but it must be escaped so that the current shell doesn't see it and try to use it as a command separator.
  • I used duckdns for years without any issues at all. Only reason I switched is because I'm using Pangolin and tunneling instead of exposing my IP directly.

  • That makes sense. I'll add the whitespace capture. The actual string only has one backslash, the second is to escape, though as I'm typing this, I'm thinking I can do a `fr"regex here" to eliminate the second backslash? I'll have to test this later when I have time.

    Thank you!

  • No apologies necessary! This is incredibly helpful! I found in the documentation how to format the message with the basicConfig, so I'm going to get rid of the logDateTime, move the logger out of main (didn't even think about how that would limit it to only main and not the other functions.), and test output to stdout vs the file defined in basicConfig.

    Gotta go to work, but will implement this later. Thank you!!

  • Can you explain your reasoning behind adding the whitespace regex? I'm guessing that's insurance in case the config file syntax changes with an app update. Thank you!

  • They started doing the thing that all shows are doing now. One, is dumbing down the plotlines in general, but the far more annoying thing is the trend of showing a flashback of a thing that literally happened five minutes ago in the show and here it is again to make it super obvious that this was the super sneaky thing that they did to advance the plan/heist/plot.

    I fucking hate that trend. I'm not a second screen watcher. When I watch something, I watch it and pay attention because I want to be engaged in it. I know I'm in the minority and no amount of removed will change that, but it has caused me to abandon a lot of shows. Most recently Matlock and High Potential.

  • I did run across the qbittorrent-natpmp when I was looking into how to change the port via the api, but wanted to work out the process myself (not because of NIH, but for the learning of figuring it all out).

    I had no idea about the up/down command in gluetun! That's very nice. I'm going to look into that for sure.

    Thank you!

  • Ooh, that's very nice. I will definitely use that instead of the with open... I'm using now. Thank you!!

  • So, if I understand what you mean correctly, with logger, drop the function, and in the main script body (which is now under an if __name__ == "__main__": check, call logger directly something like:

     
        
    if __name__ == "__main__":
        load_dotenv()
        
        logDateTime = datetime.today().strftime("%Y-%m-%d %H:%M:%S")
        logger = logging.getLogger(__name__)
    
        currentForwardedPort = get_current_forwarded_port()
        currentListeningPort = get_current_listening_port()
    
        if currentForwardedPort != currentListeningPort:
            update_qbittorrent_listen_port(currentPort)
            logger.info(f"[{logDateTime}] qbittorrent listen port set to {currentForwardedPort}")
        else:
            loger.info(f"[{logDateTime}] forwarded port and listen port are a match")
    
      

    And then in the crontab I can do:

    0 * * * * /path/stuff/python script.py > /path/to/log/file.txt

    Thanks!

  • That's a good idea. I will do that. Thank you!

  • I'm glad you mentioned the shebang. I was considering doing that (with the path to my venv python), but wasn't sure if that was a good idea.

    I will also add the if __name__ == "__main" to the main script. Thank you!

  • Programming @programming.dev

    Kinda proud of this python script I wrote

  • They've dumbed down shows like this waaaayyy too much. I get that a lot of tv is made now for second screen watching, which is fine, but I don't have to watch it. Leverage, and Leverage Redemption both fell victim to this. I stopped watching Leverage after the first season because they immediately dumbed it down after that and IMO ruined it.

  • That is a banger!

  • Music @lemmy.world

    VISIONS OF ATLANTIS - Hellfire

  • This sounds awesome. I'm going to read this tomorrow when I can give it my full attention.

  • And uses Arch BTW.

  • Can't fucking wait.

  • Linux @lemmy.ml

    Question About Bash Command Grouping Behavior in Script vs CLI

  • Linux @lemmy.ml

    Happy with my bash progress!

  • Linux @lemmy.ml

    Question: Can I use dd to clone my luks encrypted lvm os drive?

  • Linux @lemmy.ml

    In vim I can't type the ~ character

  • FoodPorn @lemmy.world

    I made Loukomedes (Greek donuts)

  • Linux @lemmy.ml

    Perl rename command works at cli but not in alias or bash script

  • Linux @lemmy.ml

    Edit: it's CentOS 7 (original: CentOS 3 on a self checkout?!?)

  • Linux @lemmy.ml

    Requesting Help with txg_sync Error I Can't Diagnose

  • Linux @lemmy.ml

    Kicked macOS to the Curb and Installed Asahi Fedora Gnome

  • FoodPorn @lemmy.world

    Spiced Lamb Taco on Fresh Naan

  • FoodPorn @lemmy.world

    Chicken Gyros

  • cats @lemmy.world

    My boy Brewster lounging

  • cats @lemmy.world

    Our very dramatic girl GG in her floofy bed.

  • FoodPorn @lemmy.world

    Made pita bread and then took the pita bread and made pita chips!

  • FoodPorn @lemmy.world

    Pineapple Coconut Curry and Fresh Naan

  • Linux @lemmy.ml

    What I Learned Using Linux This Week (05)

  • Linux @lemmy.ml

    What I Learned Using Linux This Week (04)