[-] Cyno@programming.dev 3 points 3 weeks ago

I'm hooked all over again, can't wait to get to new content

[-] Cyno@programming.dev 3 points 1 month ago

If I do all that then my feed is going to be even emptier than it is now

[-] Cyno@programming.dev 4 points 1 month ago

Similar experience here. I have a nicely curated list of people I follow on twitter, they often retweet other users that are similar and I have a nice feed of good content that slowly grows without ever running into toxic assholes. On mastodon I couldn't get anywhere close to that no matter how much I tried.

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

One more reason why Git-Fork is the GOAT - it does have separate subject and description fields. Don't lump all GUI tools in together and generalize

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

Is gnome 3 the one without a desktop? The only thing I can figure out with gnome-shell --version is that bazzite uses 46.4

There is a KDE variant of bazzite I might try but I dont know what can of worms is that going to open

[-] Cyno@programming.dev 3 points 3 months ago* (last edited 3 months ago)

I'm not that familiar with newer c# code and only recently started with result pattern but tbh, I can't tell what is this code supposed to do. Does opt resolve to true or false in this case? Why do you want TestStringFail to always execute, and what should it return? Why is opt.None true when it was initialized with a valid string value, what does None even mean in this context?

[-] Cyno@programming.dev 5 points 3 months ago

I was so excited about Mint, seemed like the perfect distro to try but then I had nothing but issues on an laptop with nvidia. PopOS worked better right out of the box though

[-] Cyno@programming.dev 3 points 11 months ago

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)
[-] Cyno@programming.dev 4 points 11 months ago

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

1
submitted 11 months ago* (last edited 11 months ago) by Cyno@programming.dev to c/csharp@programming.dev

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.

[-] Cyno@programming.dev 3 points 1 year ago

It's a neutral, easily accessible language. Having it in programming could incentivize more people to learn it as well.

[-] Cyno@programming.dev 6 points 1 year ago

I'm not disagreeing outright but... Why do we need more non English programming languages? Is there a specific practical reason?

The only language translation I'd maybe consider to accept in programming is Esperanto. Anything else just sounds like a terrible idea.

17

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.

[-] Cyno@programming.dev 3 points 1 year ago

I use the CLI for simple commands, especially if helping someone on another PC and I don't have access to my preferred tool, but I honestly don't get people who use it religiously and never even try tools with GUIs. The convenience of being able to easily see the commit history, scroll through it, have a right click context menu or ability to just click it and see file changes (and then right click those files for additional options), is just something I can't abandon. Nowadays even the aliasing can be replicated in those tools if they support creation of custom commands so even that is a moot point - with some setup you can be as fast as with a CLI.

2

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.

9

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?

view more: โ€น prev next โ€บ

Cyno

joined 1 year ago