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/)CY
Cyno @programming.dev
Posts 7
Comments 34
What's your preferred code generation tool in 2024?
  • The most common usecase is generating data models based on the database, mostly using t4 files so far. We have a non-standard way of defining some parts of it so the default MS tools don't quite cut it (like ef dbcontext scaffold). I've been looking into roslyn but it seems like it might be more trouble than its worth, but default t4 doesn't even have a proper editor and syntax highlighting so its a low bar atm.

  • What's your preferred code generation tool in 2024?

    To clarify, I mean writing scripts that generate or modify classes for you instead of manually writing them every time, for example if you want to replace reflection with a ton of verbose repetitive code for performance reasons I guess?

    My only experience with this is just plain old manual txt generation with something like python, and maintaining legacy t4/tt VS files but those are kind of a nightmare.

    What's a good modern way of accomplishing this, have there been any improvements in this area?

    14
    Threads Federation Poll
  • If our content gets federated to threads then it just means that google results will point to it first rather than to us, they will probably have better indexing and search features than the fediverse. People will also probably think the content originated on threads too (since that's where they see it and threads could easily obfuscate info like that) instead of who actually made it.

    It could increase the short term engagement but in the long run, it will just serve to make threads better.

  • Need help understanding how to get around port-forwarding with tailscale
  • I was really hoping there was something like hamachi/xfire/garena from the old days but modernized and more stable 😅 I just assumed it'd be a solved problem by now.

    I'm not giving up on tailscale yet, I'll try the funnel feature but yeah... seems a bit troublesome for sure

  • Need help understanding how to get around port-forwarding with tailscale
  • Thanks for linking that, seems like a great resource! Seems like there's a few that support UDP although I'm not sure if they will work with a CGNAT setup, also their setup seems a bit more complicated and technical than expected but I need to look more into it tomorrow. If everyone else needs to have this installed then that might be an issue

  • Need help understanding how to get around port-forwarding with tailscale

    I don't have access to my router and my ISP charges for port forwarding (I think they might have a CGNAT setup?).

    I'm trying to work around that since I want to start hosting some apps and game servers from my PC. I'm seeing a lot of talk about tailscale as a possible solution to this but honestly I'm a bit confused with all the options and whether this is actually the proper tool for the job.

    Assuming it is, do I go the route of setting up a "tailscale funnel" or a "subnet"? Will other people have to install tailscale too if they want to join my servers? People also mention Netmaker or Cloudflared Tunnel, although it also seems like cloudflare doesn't want their tunnels used for game and media traffic?

    The more expensive option I guess would be just paying for protonvp premium since it offers port forwarding in that case, but I'm not sure about performance and whether it's worth it, at that point I might just rent a server instead.

    Hoping you folks at self-hosted have more ideas on how can I, well... self host instead of throwing money at the problem.

    13
    Should we block zerobytes.monster?
  • That's not really a good solution although it is a temporary workaround.

    • Many users won't know this is a feature they can use, or how to set it up
    • Some users use alternative instances that federate with lemmy which might not have this feature
    • Content still gets copied and hosted on this instance which might not be desireable

    Besides, at the end of the day, shouldn't the admins and mods here curate the content according to the community's guidelines and spirit? If someone started spamming undesired content on a forum you're administrating, the answer wouldn't be "all the users can just block it if it's an issue". I don't think it should be the answer here either

  • [2023 Day 3] Motivation time!
  • I went with a matrix approach and was just planning to handle it through indexes but kinda gave up halfway implementing the finding of numbers, their start/end positions... I'm guessing a regex but that might have issues if we have identical numbers later, so not sure. Will surely go back to it eventually though :P

  • [2023 Day #1] Massive Difficulty Increase
  • Thanks, I managed to find the culprit in the end however - I was using a forward-look of 5 characters for finding if it matches a word so in a string of a3two for example, it would register the two before the 3. It was an easy fix once i found the issue.

  • [Help] [2023 Day #1 (Part 2)] Attempted solution - answer not accepted
  • Thanks, I managed to find the culprit in the end however - I was using a forward-look of 5 characters for finding if it matches a word so in a string of a3two for example, it would register the two before the 3. It was an easy fix once i found the issue.

  • 🦌 - 2023 DAY 2 SOLUTIONS -🦌
  • Was pretty simple in Python with a regex to get the game number, and then the count of color. for part 2 instead of returning true/false whether the game is valid, you just max the count per color. No traps like in the first one, that I've seen, so it was surprisingly easy

    def process_game(line: str):
        game_id = int(re.findall(r'game (\d+)*', line)[0])
    
        colon_idx = line.index(":")
        draws = line[colon_idx+1:].split(";")
        # print(draws)
        
        if is_game_valid(draws):
            # print("Game %d is possible"%game_id)
            return game_id
        return 0
    
                
    def is_game_valid(draws: list):
        for draw in draws:
            red = get_nr_of_in_draw(draw, 'red')
            if red > MAX_RED:
                return False
            
            green = get_nr_of_in_draw(draw, 'green')
            if green > MAX_GREEN:
                return False
            
            blue = get_nr_of_in_draw(draw, 'blue')
            if blue > MAX_BLUE:
                return False    
        return True
            
                
    def get_nr_of_in_draw(draw: str, color: str):
        if color in draw:
            nr = re.findall(r'(\d+) '+color, draw)
            return int(nr[0])
        return 0
    
    
    # f = open("input.txt", "r")
    f = open("input_real.txt", "r")
    lines = f.readlines()
    sum = 0
    for line in lines:
        sum += process_game(line.strip().lower())
    print("Answer: %d"%sum)
    
  • [2023 Day #1] Massive Difficulty Increase
  • Oh god, sorry to hear that 😅i'm feeling desperate enough to try that, i just wrote a different implementation and i get the same (wrong) result. At this point I just want to know what i misunderstood or mistyped cuz its driving me crazy

  • 🎄 - 2023 DAY 1 SOLUTIONS -🎄
  • Part 2 is tricky, I keep succeeding with all the examples but the final count is still wrong every time😅 Anyone got some tricky inputs that I can check against? I'm not sure what I'm missing. Here's some that bugged me for a while

    spoiler

    eighthree - 83
    oneight - 18
    eightwothree - 83
    two1two - 22
    twoneight - 28

  • Is preloading/caching data before the actual method call an (anti)pattern?

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

    > Short explanation of the title: imagine you have a legacy mudball codebase in which most service methods are usually querying the database (through EF), modifying some data and then saving it in at the end of the method. > > This code is hard to debug, impossible to write unit tests for and generally performs badly because developers often make unoptimized or redundant db hits in these methods. > > What I've started doing is to often make all the data loads before the method call, put it in a generic cache class (it's mostly dictionaries internally), and then use that as a parameter or a member variable for the method - everything in the method then gets or saves the data to that cache, its not allowed to do db hits on its own anymore. > > I can now also unit test this code as long as I manually fill the cache with test data beforehand. I just need to make sure that i actually preload everything in advance (which is not always possible) so I have it ready when I need it in the method. > > Is this good practice? Is there a name for it, whether it's a pattern or an anti-pattern? I'm tempted to say that this is just a janky repository pattern but it seems different since it's more about how you time and cache data loads for that method individually, rather than overall implementation of data access across the app. > > In either case, I'd like to learn either how to improve it, or how to replace it.

    9

    Is preloading/caching data before the actual method call an (anti)pattern?

    Short explanation of the title: imagine you have a legacy mudball codebase in which most service methods are usually querying the database (through EF), modifying some data and then saving it in at the end of the method.

    This code is hard to debug, impossible to write unit tests for and generally performs badly because developers often make unoptimized or redundant db hits in these methods.

    What I've started doing is to often make all the data loads before the method call, put it in a generic cache class (it's mostly dictionaries internally), and then use that as a parameter or a member variable for the method - everything in the method then gets or saves the data to that cache, its not allowed to do db hits on its own anymore.

    I can now also unit test this code as long as I manually fill the cache with test data beforehand. I just need to make sure that i actually preload everything in advance (which is not always possible) so I have it ready when I need it in the method.

    Is this good practice? Is there a name for it, whether it's a pattern or an anti-pattern? I'm tempted to say that this is just a janky repository pattern but it seems different since it's more about how you time and cache data loads for that method individually, rather than overall implementation of data access across the app.

    In either case, I'd like to learn either how to improve it, or how to replace it.

    6

    What's your favorite DB editor software?

    Was just wondering what's popular nowadays, maybe I find something new and better - what kind of tools are you using to access and manage databases?

    I'm personally using Dbeaver a lot but honestly it feels increasingly more buggy and unreliable as time passes, every installation and update has had (unique) issues so far and there's little support. However the ease of use and some powerful, convenient, utilities in it make it preferable to others.

    13

    So what is actually the issue with (npm) dependency management?

    It is a common sentiment that managing dependencies is always a big issue in software development and the reason why so many apps come pre-bundled with all the requirements so it reliably works on every machine.

    However, I don't actually understand why is that an issue and why people generally bash npm and the way it's done there. Isn't it the simplest and most practical solution to a problem - you have a file which defines which other libraries you need, which version, and then with one command you can install them and run the program?

    Furthermore, those libraries and their specific versions can be stored elsewhere and shared across all apps on a system so you can easily reuse them instead of having to redownload for each program individually.

    I must be missing something since if it were that easy, people would have solved it years ago and agreed on a standardized best way, so I'm wondering what is the actual issue and a cause of so many headaches.

    3

    How do you improve your "pattern application" knowledge?

    I see this often with both new and old developers, they have one way of doing a thing and when presented with a new problem they will fall back to what they are used to even if it's not the optimal solution. It will probably work if you bruteforce it into your usual patterns but sometimes, a different approach is much easier to implement and maintain as long as you are willing to learn it, and more importantly - know it exists in the first place.

    On a less abstract level, I guess my question is - how would I go around learning about different design patterns and approaches to problem solving if I don't know about their existence in the first place? Is it just a matter of proactive learning and I should know all of them in advance, as well as their uses?

    Let's for example say I need to create a system for inserting a large amount of data from files into the db, or you need to create some service with many scheduled tasks, or an user authentication system. Before you sit down and start developing those the way you usually do, what kind of steps could you take to learn a potentially better way of doing it?

    9