[-] Hammerheart@programming.dev 2 points 6 days ago* (last edited 6 days ago)

I just want you to know you weren't screaming into the void. Look at my new main.py:


from pathlib import PurePath


from Layout import Layout


DEFAULT_FOLDER = PurePath("/home", "mike", "bg")
WATERMARK_DIR = Path(Path(os.getcwd()).parent, "assets", "img")


def main() -> Layout:
    return Layout()

if __name__ == "__main__":
    main()

(I know I still need to change those folder defaults, but I am still riding the high of getting all that layout stuff into Layout.py and it working. I spent a couple hours today struggling, wondering why I was just getting a blank screen, when i realized i forgot to call .grid() on the frame that held all the widgets! So it was just rendering a blank window. )

[-] Hammerheart@programming.dev 7 points 1 week ago

Can you elaborate because this is not obvious to me. Maybe we sre thinking different things when we talk about "openness" in this context.

30

I started working through the 100 Days of Code course of Udemy last February, and I'm in the home stretch. I'm on the final lessons, which are really just prompts for projects. No hand holding, just a brief description of the goal. I recently finished a tkinter GUI program, the goal of which was to enable adding text watermarks.

I took a few liberties--mainly, I made it possible to layer a png on top of the background. It was a really fun project and quickly grew more complicated than I expected it to. I got some hands on experience with the Single Responsibility Principle, as I started off doing everything in my Layout class.

Eventually, I moved all the stuff that actually involved manipulating the Image objects to an ImageManager class. I feel like I could have gotten even more granular. That's one thing I would love to get some feedback on. How would a more experienced programmer have architected this program?

Anyway, I guess this preamble is long enough. I'm going to leave a link to the repository here. I would have so much appreciation for anyone who took the time to look at the code, or even clone the repo and see if my instructions for getting it to run on your machine work.

Watermark GUI Repo

[-] Hammerheart@programming.dev 6 points 2 weeks ago

What are some goos resources for learning jq? I really struggle when it comes to nested keys/values which obviously limits my ability to use it.

13

cross-posted from: https://programming.dev/post/14680192

I have a VPS, but no root access so I can't use apt, or even read a lot of the system files. I would like to get jellyfin (or any media server, really) running on it. Jellyfin has a portable installation option, so I followed the instructions in the docs to install it from the .tar.gz.

But it says I have to install ffmpeg-jellyfin, and I can't find a portable installation of that. My VPS already has ffmpeg installed on it. Will jellyfin work if I just point it to that instead? Or, how can I go about installing ffmpeg-jellyfin without root access?

21

I have a VPS, but no root access so I can't use apt, or even read a lot of the system files. I would like to get jellyfin (or any media server, really) running on it. Jellyfin has a portable installation option, so I followed the instructions in the docs to install it from the .tar.gz.

But it says I have to install ffmpeg-jellyfin, and I can't find a portable installation of that. My VPS already has ffmpeg installed on it. Will jellyfin work if I just point it to that instead? Or, how can I go about installing ffmpeg-jellyfin without root access?

[-] Hammerheart@programming.dev 18 points 1 month ago

Is this just referring to the firefox sync feature? I love being able to access tabs from my laptop on my phone and vice versa.

4
submitted 1 month ago* (last edited 1 month ago) by Hammerheart@programming.dev to c/linux4noobs@programming.dev

I have been using sway (basically i3 for Wayland) instead of a traditional desktop environment because it really makes a difference in my laptops performance.

But apparently sway ignores .desktop files which was how i was autostarting things on KDE.

Is the best way to handle this by going through the sway config? If not, how would you do it.

Bonus points if you can tell me how to get the autostart programs to also open in specific workspaces.

[-] Hammerheart@programming.dev 7 points 1 month ago

That was it! I moved the two lines above the .configure() call into the outermost scope, and it works now.

Should probably just bite the bullet and OOP it out. I was putting that off until I figured out how I wanted the whole thing to work, but it will probably be easier to just do it and change it as I go instead of trying to raw dog it for too long.

15
submitted 1 month ago* (last edited 1 month ago) by Hammerheart@programming.dev to c/learn_programming@programming.dev

I'm working on a little gui app that will eventually (hopefully) add a watermark to a photo. But right now I'm focused on just messing around with tkinter and trying to get some basic functionality down.

I've managed to display an image. Now I want to change the image to whatever is in the Entry widget (ideally, the user would put an absolute path to an image and nothing else). When I click the button, it makes the image disappear. I made it also create a plain text label to see if that would show up. It did.

Okay, time to break out the big guns. Add a breakpoint. py -m pdb main.py. it works. wtf?

def change_image():
    new_image = Image.open(image_path.get()).resize((480, 270))
    new_tk_image = ImageTk.PhotoImage(new_image)
    test_image_label.configure(image=new_tk_image)
    breakpoint()

with the breakpoint, the button that calls change_image works as expected. But without the breakpoint, it just makes the original image disappear. Please help me understand what is happening!

edit: all the code

import io
import tkinter as tk
from pathlib import Path
from tkinter import ttk

from PIL import ImageTk
from PIL import Image

from LocalImage import Localimage
from Layout import Layout

class State:
    def __init__(self) -> None:
        self.chosen_image_path = ""

    def update_image_path(self):
        self.chosen_image_path = image_path.get()



def change_image():
    new_image = Image.open(image_path.get()).resize((480, 270))
    new_tk_image = ImageTk.PhotoImage(new_image)
    test_image_label.configure(image=new_tk_image)
    breakpoint()

TEST_PHOTO_PATH = "/home/me/bg/space.png"
PIL_TEST_PHOTO_PATH = "/home/me/bg/cyberpunkcity.jpg"
pil_test_img = Image.open(PIL_TEST_PHOTO_PATH).resize((480,270))
# why does the resize method call behave differently when i inline it
# instead of doing pil_test_img.resize() on a separate line?


root = tk.Tk()

root.title("Watermark Me")
mainframe = ttk.Frame(root, padding="3 3 12 12")
mainframe.grid(column=0, row=0, sticky="NWES")

layout = Layout(mainframe)

image_path = tk.StringVar()
tk_image = ImageTk.PhotoImage(pil_test_img)
test_image_label = ttk.Label(image=tk_image)

entry_label = ttk.Label(mainframe, text="Choose an image to watermark:")
image_path_entry = ttk.Entry(mainframe, textvariable=image_path)
select_button = ttk.Button(mainframe, text="Select",
                           command=change_image)
hide_button = ttk.Button(mainframe, text="Hide", command= lambda x=test_image_label:
                  layout.hide_image(x))
test_text_label = ttk.Label(mainframe, text="here i am")
empty_label = ttk.Label(mainframe, text="")

for child in mainframe.winfo_children():
    child.grid_configure(padx=5, pady=5)

entry_label.grid(column=0, row=0)
image_path_entry.grid(column=1, row=0)
hide_button.grid(column=0, row=3)
select_button.grid(column=0, row=4)
test_image_label.grid(column=0, row=5)
empty_label.grid(column=0, row=6)


image_path_entry.insert(0,TEST_PHOTO_PATH)
image_path_entry.focus()
breakpoint()



root.mainloop()
[-] Hammerheart@programming.dev 22 points 3 months ago

Hacker news isnt an appropriate forum for most questions tho, that one is valid

[-] Hammerheart@programming.dev 12 points 3 months ago

One of my favorite things about vinyl is having to flip the record over. I think it demands more active and respectful listening.

[-] Hammerheart@programming.dev 10 points 3 months ago

I hate to sound like an elitist asshole, but i really dont want to read posts or comments from people who only used threads prior to discovering this community. I am in one Facebook programming group with good posters, but the overwhelming majority of them are low effort crap.

14
submitted 5 months ago by Hammerheart@programming.dev to c/linux@lemmy.ml

Sometimes my CMUS will randomly stop playing a track or it won't play the next track until I manually go in and hit c (for resume) or otherwise initiate playback. I would like to be able to see what happened before these instances so i could either fix my config or, if its a problem beyond the scope of my local environment, get info to write up a proper bug report with. Where can I find such logs? Would they be in the systemd journal or somewhere in /var ?

[-] Hammerheart@programming.dev 14 points 5 months ago

It bothers me when OO doesnt stand for "object oriented"

[-] Hammerheart@programming.dev 6 points 5 months ago* (last edited 5 months ago)

I started learning to program in February, which reinvigorated my love of computers. I discovered awesome new software like syncthing, and just recently started daily driving linix (debian 12) and its been great. Just little things like customizing my wall paper which i havent done for years. 2023 was a great year for me and tech.

Oh and i switched from chrome to Firefox, looks like that's been a common theme for the year!

11

So I just had an issue where my shebang lines weren't parsing properly for a python script I was attempting to execute. A quick google revealed that it was probably because I wrote the scripts on windows and now I was trying to run them on Linux (so happy i finally made the switch btw. using the computer is fun again!). So i took the advice I found and tried to run :%s/^M/ (using C-v, C-m to insert the escape character), and it failed to find any matches. I tried the same command in vanilla vi and it worked.

Is there some setting I don't have configured properly? I would prefer to be able to do this sort of thing within neovim.

[-] Hammerheart@programming.dev 8 points 6 months ago

I never got into Spotify. Soulseek is all I need.

19
submitted 6 months ago by Hammerheart@programming.dev to c/linux@lemmy.ml

If anyone could help me out with this, I'd greatly appreciate it. Basically, I can't ctrl + v to paste anything I pipe into the clipboard selection in xclip, and i can't xclip -o anything I copied with ctrl-c or ctrl-shift-c.

Maybe I want to paste a path into a neovim file. echo $(pwd) | xclip -i -sel c Now the path is in my clipboard, right? It sure shows up if i xclip -o -sel c!

But when I go into neovim and paste from the unnamedplus register, instead it pastes the last thing I copied in my browser.

if I want to copy the output of something from my terminal and google it, ctrl+v in the browser completely ignores my xclip selection.

i am forced to use the mouse and ctrl+shift+c in order to paste it into a search engine, like a caveman.

I hope I've done a decent enough job explaining the problem. It was most apparent earlier, as I was making a cronjob and I had to be explicit about file paths because i couldn't assume the working directory would be the directory of the script I was calling. I really wish I could have just echo $(pwd) | xclip -sel c; open neovim; hit p; see the path appear in my file.

I have a little clipboard icon in my system tray with my copy history, except none of the things I put in the clipboard selection with xclip -sel c or xsel -b appear there. I think that program is klipper, but I'm not sure.

I know there's a number of work arounds but still this kind of frustrates me. I think it has something to do with wayland and xclipboard not talking to each other. I am running wayland, KDE Plasma 5.27.5, and Debian 12.

Is there a simple configuration setting I can tweak, or do I need to find something to replace klipper or xclip? I have tried toggling the keep selection and clipboard the same and always save text selection in history settings in the plasma clipboard, no change. I tried two terminal emulators to no avail.

I will happily provide any more information if it would be helpful.

111
submitted 6 months ago* (last edited 6 months ago) by Hammerheart@programming.dev to c/linux@lemmy.ml

Lately ive noticed that i was wanting to do certain things on Windows that just seemed much easier and more intuitive on Linux, based in the OS specific solutions i would see to problems i encountered. And i was more frequently using software where Windows support seemed like an after thought.

A couple days ago i finally sat down and tried to install Mint. The installer didnt recognize my windows partition so it didnt offer any assistance. And a stroke of fate saw my internet connection dieing at the exact same time. Yes, i cant believe it either.

So i decided to live dangerously and just try to wing the installation with no outside help. It seems like creating a second EFI partition was not the right call. The install failed, and I couldn't get back onto windows.

I wound up just using a live ubuntu image for a few days while i wrestled with repairing the boot loader. I didnt succeed. Eventually i just made a windows recovery disk from my Desktop with an intact copy of windows, and had to reinstall windows.

Then i did manage to successfully install Debian, and ive been having such a great time with it so far. I feel like i probably didnt even need to keep a windows partition, especially since i could have just used my desktop if i REALLY needed windows. I havent had this much fun just using the computer since i was a kid.

7

I'm new to vim and getting the hang of the configuration. I've gone through a couple of youtube videos giving a tutorial of setting it up with lazy.nvim. Now I am following ThePrimeagen's config, and UndoTree doesn't work.

The plugin is loaded and my config is properly sourced, but when I run run :UndoTreeToggle, I get this lovely error:

(E5108: Error executing lua: function undotree#UndotreeToggle[11]..<SNR>37_new[2]..41, line 6: Vim(echoerr):"diff" is not executable. stack traceback: [C]: at 0x7ff77ae89570)

I am running windows (currenty in the process of backing up my personal data so I can try out Linux without feeling too disconnected from my daily computer user). I did a little bit of google searching and checked the issues on github, unfortunately I couldn't find anything related to my problem. Any help would be much appreciated.

[-] Hammerheart@programming.dev 13 points 6 months ago* (last edited 6 months ago)

this response is based on the few paragraphs available to non medium members

The second paragraph mirrors my experience with coding to a tee. I may have forgotten to turn off the oven while i was absorbed in Pycharm at least once, and ive certainly given a triumphany "fuck yea" with a raised fist worthy of a freeze frame ending to an '80s film upon succesfully accomplishing a task.

During a recent difficult time in my life, learning to code was the only activity i found that gave me substantial relief from the stress.

10

I am working on user authentication in Flask. I have my User class, which inherits from db.Model (SQLAlchemy) and UserMixins (flask-login):

class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(100), unique=True)
    password = db.Column(db.String(100))
    name = db.Column(db.String(1000))

and I create a new User object during registration:

        new_user = User(
            name=request.form["name"],
            password=generate_password_hash(password=request.form.get("password"),
                                            salt_length=8,
                                            method="pbkdf2:sha256"),
            email=request.form["email"])

Since I inherited from UserMixins, I started to get an "unexpected arguments" warning from pycharm when I create new_user. can someone explain to me why that is? If I don't inherit from UserMixins, the warning goes away.

3

So, it used to work just fine. Then jerboa became basically unusable due to some bug. That was a few weeks ago. I saw an update was available, so I thought to give it another try. It's much more stable after the update, and my lemmy.one account works just fine. But when I try to log in with this account on jerboa, I get an incorrect login error. I set the instance to "programming.dev" and I know I used the right credentials because my password manager filled them in, just like it does in the browser.

Any ideas on a cause or fix? It might be a jerboa issue but I don't get why it seems to only impact this instance.

view more: next ›

Hammerheart

joined 1 year ago