[-] UlrikHD@programming.dev 1 points 2 months ago

Seems like everything is up to date on lemmy.dbzer0 now, just minor federation quirks it seems like. Thanks for notifying about a potential issue.

[-] UlrikHD@programming.dev 1 points 3 months ago

I haven't hidden the community yet and the post is visible both on the standard frontend and the tesseract frontend. Not quite sure what's going on in OP's picture, checking the database, all the recent posts seem normal.

[-] UlrikHD@programming.dev 1 points 1 year ago

If you don't have anything positive or helpful to say, it would be better to just not reply. If you think the post shouldn't be posted here, use the report function instead.

[-] UlrikHD@programming.dev 1 points 2 years ago

This is your second warning to not break our CoC (3.2).

A third warning will result in a temporary ban from programming.dev.

[-] UlrikHD@programming.dev 1 points 2 years ago

I personally would prefer the if check and return 0 in most instances just because it's clearer and more readable. But the two previous functions were one-liners so it just looked better if get_winnings() also was.

[-] UlrikHD@programming.dev 1 points 2 years ago

Then I would suggest you to re-read the article and spend a minute to think about how that relates to how the technology can be abused. I'm not sure I can make it more obvious, and honestly if feels like you don't understand it in bad faith.

[-] UlrikHD@programming.dev 1 points 2 years ago

Please refrain from using the word "retard" as a slur on our instance in accordance to our user rules.

[-] UlrikHD@programming.dev 1 points 2 years ago* (last edited 2 years ago)

If you believe it's an bug with our instance, try making a post over at !meta@programming.dev . Posting here is unlikely to grab the attention of an admin unless the post gets reported (which it did). Before that though, look up if isn't just the more likely scenario of a general lemmy bug/quirk caused by mismatched lemmy versions, etc...

[-] UlrikHD@programming.dev 1 points 3 years ago

Interesting stuff, might give me an excuse to look into rust in the future. Thanks!

[-] UlrikHD@programming.dev 1 points 3 years ago* (last edited 3 years ago)

As others have suggested, ffmpeg is a great cli tool. If you aren't comfortable with the terminal you can do it via python like this:

import os
import sys
import subprocess


def crop_media(file_name: str, w: int, h: int, x: int, y: int, new_dir: str) -> None:
    try:
        subprocess.run(f'ffmpeg -i "{file_name}" -vf "crop={w}:{h}:{x}:{y}" temp.gif -y',
                           shell=True, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
        os.rename('temp.gif', os.path.join(new_dir, file_name))
    # Print the error and continue with other gifs, remove try block if you want a complete stop
    except subprocess.CalledProcessError as e:
        print(e)
    except KeyboardInterrupt:
        print('KeyboardInterrupt, cleaning up files...')
        os.remove('temp.gif')
        sys.exit(0)


def crop_directory(directory: str, w: int, h: int, x: int, y: int, new_dir: str) -> None:
    for root, _, files in directory:
        for file in files:
            if not file.endswith('.gif'):
                continue
            if os.path.isfile(os.path.join(new_dir, file)):
                print(f'{file} already exists in {new_dir}, skipping...')
                continue

            file_path = os.path.normpath(os.path.join(root, file))
            crop_media(file_path, w, h, x, y, new_dir)


if __name__ == '__main__':
    width = 0
    height = 0
    x_offset = 0
    y_offset = 0
    gif_directory = ''
    new_directory = ''
    crop_directory(gif_directory, width, height, x_offset, y_offset, new_directory)

This should go through every file in the directory and subdirectories and call the ffmpeg command on each .gif. With new_directory you can set a directory to store every cropped .gif. The ffmpeg command is based on johnpiers suggestion.

The script assumes unique filenames for each gif and should work with spaces in the filenames. If they aren't unique, you can just remove the new_directory part, but you will then lose the original gif that you cropped.

[-] UlrikHD@programming.dev 1 points 3 years ago

Could you elaborate on that point? Is it as smooth as using C?

[-] UlrikHD@programming.dev 1 points 3 years ago

Downloads and Documents starting with a capital letter is my biggest pet peeve with Ubuntu. It makes it a lot more annoying to navigate through them than if it was all lower case.

view more: ‹ prev next ›

UlrikHD

0 post score
0 comment score
joined 3 years ago
MODERATOR OF