Cyno

joined 11 months ago
[–] Cyno@programming.dev 2 points 1 week ago* (last edited 1 week ago) (2 children)

I wonder what kind of support for development do you get? Honestly I've only had obstacles when I switched, for example the docker installation was much more complicated on linux than on windows+wsl. Even installing python was problematic because apparently 'upgrading it yourself can brick the system', at least if an older version comes with the OS?

And lastly it's the simple thing that pretty much all tools work on windows natively but on linux you have to find workarounds, which is definitely a problem when it comes to productivity.

So what are the benefits, what does linux have that windows doesn't in this context?

[–] Cyno@programming.dev 2 points 1 week ago (1 children)

Thank you very much for such a detailed answer! This is exactly the type of stuff I wanted to learn in advance from some generalist tutorial because honestly, I feel bad constantly asking such basic questions and there's no guarantee there will always be someone like you to answer them. In retrospect it's probably the smarter and simpler option to just google the command docs online, I just wanted to do it "right" since I heard all the praise about man command and you never know if you're working offline.

I'll check out nala, could be a good learning tool, thanks!

[–] Cyno@programming.dev 1 points 2 weeks ago* (last edited 2 weeks ago) (3 children)

That gives me a list of over 2000 rows inside of the terminal that i cant apparently search or sort -.-

Then I tried to be smart and do man dpkg -l to see if that has any options on how to use it better, and instead i got another huge text file that i cant search or navigate through properly

So then i googled how to open it in an editor and tried man dpkg -l | nano, which does open it for a second and then crashes, i just get "too many errors from stdin, buffer written to nano.12608.save" in the terminal

ofc something as simple as map dpkg -l | vscode doesnt work either

I'm just tired

[–] Cyno@programming.dev 1 points 2 weeks ago* (last edited 2 weeks ago) (1 children)

I dunno if I agree with this. Using windows and the office suite is taught in schools, at least in europe, and has been even when I was in school around 2 decades ago. Regardless of that, it is very user-friendly with intuitive simple UI and various wizards that guide you through every process step by step and generally speaking you dont have to do much, if any, manual configuration or tinkering if you dont want to.

I'm not saying linux should be the same and its obvious the priorities are different as you say, but I disagree that all OSes are about "detective work and figuring it out". I dont think bashing your head against the wall is a good way of learning anymore. I dont think even asking questions every time on various forums is a good solution since there is no guarantee you will get a correct answer, especially with linux - chances are much higher in my experience you will get an opinionated and possibly wrong or outdated answer.

[–] Cyno@programming.dev 1 points 2 weeks ago (1 children)

As mentioned in another post I'm more of a reading than video-watching person but I'll take any resource I can get. I saw in another thread that someone recommended this video but it is 6 hours long so i haven't really delved into it yet

[–] Cyno@programming.dev 1 points 2 weeks ago* (last edited 2 weeks ago) (5 children)

I want to use the terminal and I'd prefer the simplicity and reliability of a single command over various GUIs, but it doesn't feel like it's consistent or simple with the terminal either. For example with VSCode, it doesn't have apt-get install vscode command (at least not listed on its installation pages) - it recommends manually downloading the deb file and then apt installing it.

https://code.visualstudio.com/docs/setup/linux

I just don't know whats the proper / good way of doing it anymore. The popOS shop is horrible, you cant stop running installations cuz it freezes and stops giving any feedback, sometimes it breaks and doesn't open fully, the UX is bad, but i dont know what else to do. At least with the shop I have a clear list of installed apps and a place to uninstall them, if i do it with the terminal I have no idea where they end up living.

[–] Cyno@programming.dev 1 points 2 weeks ago

Haha no worries, that's also a common linux experience :P

[–] Cyno@programming.dev 2 points 2 weeks ago* (last edited 2 weeks ago) (9 children)

I'm trying out popOS and even the native package manager (popOS shop?) installs most applications as flatpaks afaik? I have no idea where they end up being compared to windows' program files or what kind of defaults they install with. I started putting my custom downloaded AppImages into the ~/Applications folder and then used AppImageLauncher to actually have them show up in search.

Then I will run into something like docker which is not in the shop and has a ton of commands you have to run in order to get it to work, like uninstalling conflicting packages, installing some certificates and keyrings and i dont even know what - it was supposed to work better than on windows but it is nowhere near as neat as there!

Then I install samba (again, not available in the popOS shop) and I have it running but i have no idea whether it's set to automatically run or not. Searching for it with GUI tools doesn't show it as installed anywhere so in this case i have to rely on the terminal. The popOS store does have a list of installed apps but the search field gets disabled when you go into this screen because it's only used for browsing the shop, not through your installed apps?

I’d say that the best learning resource you can have is a spare computer specifically dedicated to exploring Linux, with which you can install and break and configure and break again without worry. Learning Linux can be like playing a roguelite, and I mean that also in the sense that it can be fun.

This is what I do but the issue is that I have no feedback on whether Im doing the right thing or if im making the life unnecessarily difficult for me. Games will slap you and make you redo something if you fuck it up, linux just makes you live in agony until sometimes breaks and you dont know why.

[–] Cyno@programming.dev 2 points 2 weeks ago* (last edited 2 weeks ago) (12 children)

Isn't there a lot of overlap though, at least between OSes that are of the same type (like debian/ubuntu)? How to set up users, knowing that you need to manually configure automatic mounting of your drives, knowing how/when to use flatpak or apt or .deb, where to install apps... These are not really intuitive things, especially for someone coming from windows, and most "how to install linux" guides don't really go into these in any meaningful way.

For instance at first I thought I could just keep a list of apt commands and make an "easy to reinstall" linux script at one time, and that lasted for whole of 10 minutes before I realized every app needs manual intervention in one or another way, or has a different way of installing. Also, as many people I just prefix everything with sudo to get it to install, but who knows if that is the correct thing to do? not me at least

[–] Cyno@programming.dev 1 points 2 weeks ago (1 children)

I've only gone through the reddit thread and tbh most people seem to be bashing this method and pointing out flaws? It doesn't seem like a magic bullet solution and dual boot seems like the better option, at least for now.

[–] Cyno@programming.dev 2 points 2 weeks ago

Yeah I'm the same way, there is a 6h video linked in your post but i can't imagine myself actually going through it like that lol. I'm also in the process of trying to move data and media off my main PC but haven't figured out the best way yet, I have an older laptop that I was considering setting up as a mini pc/home server but then there's also the option of buying a NAS... it gets complicated and more expensive fast either way.

[–] Cyno@programming.dev 1 points 2 weeks ago (3 children)

Can you elaborate? Googling linux vfio just gives me text heavy documents I dont understand. How does that replace dual booting and how would I use it?

 

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

I've always approached learning Linux by just diving into it and bashing my head against problems as they come until I either solve them or give up, the latter being the more common outcome.

I wouldn't take this approach with other pieces of software though - I'd read guides, best practices, have someone recommend me good utility tools or extensions to install, which shortcuts to use or what kind of file hierarchy to use, etc.
For example, for python I'd always recommend the "Automate the boring stuff with Python", I remember learning most Java with that "Head first Java" book back in the days, c# has really good official guides for all concepts, libraries, patterns, etc.

So... lemme try that with Linux then! Are there any good resources, youtube videos, bloggers or any content creators, books that go explain everything important about linux to get it running in an optimal and efficient way that are fun and interesting to read? From things like how the file hierarchy works, what is /etc, how to install new programs with proper permissions, when to use sudo, what is a flatpak and why use it over something else, how to backup your system so you can easily reconstruct your setup in case you need to do an OS refresh, etc? All those things that people take for granted but are actually a huge obstacle course + minefield for beginners?

And more importantly, that it's up to date with actually good advice?

 

I've always approached learning Linux by just diving into it and bashing my head against problems as they come until I either solve them or give up, the latter being the more common outcome.

I wouldn't take this approach with other pieces of software though - I'd read guides, best practices, have someone recommend me good utility tools or extensions to install, which shortcuts to use or what kind of file hierarchy to use, etc.
For example, for python I'd always recommend the "Automate the boring stuff with Python", I remember learning most Java with that "Head first Java" book back in the days, c# has really good official guides for all concepts, libraries, patterns, etc.

So... lemme try that with Linux then! Are there any good resources, youtube videos, bloggers or any content creators, books that go explain everything important about linux to get it running in an optimal and efficient way that are fun and interesting to read? From things like how the file hierarchy works, what is /etc, how to install new programs with proper permissions, when to use sudo, what is a flatpak and why use it over something else, how to backup your system so you can easily reconstruct your setup in case you need to do an OS refresh, etc? All those things that people take for granted but are actually a huge obstacle course + minefield for beginners?

And more importantly, that it's up to date with actually good advice?

 

I understand the basic principle but I have trouble determining what is the hard line separating responsibilities of a Repository or a Service. I'm mostly thinking in terms of c# .NET in the following example but I think the design pattern is kinda universal.

Let's say I have tables "Movie" and "Genre". A movie might have multiple genres associated with it. I have a MovieController with the usual CRUD operations. The controller talks to a MovieService and calls the CreateMovie method for example.

The MovieService should do the basic business checks like verifying that the movie doesn't already exist in the database before creating, if all the mandatory fields are properly filled in and create it with the given Genres associated to it. The Repository should provide access to the database to the service.

It all sounds simple so far, but I am not sure about the following:

  • which layer should be responsible for column filtering? if my Dto return object only returns 3 out of 10 Movie fields, should the mapping into the return Dto be done on the repository or service layer?

  • if I need to create a new Genre entity while creating a new movie, and I want it to all happen in a single transaction, how do I do that if I have to go through MovieRepository and GenreRepository instead of doing it in the MovieService in which i don't have direct access to the dbcontext (and therefore can't make a transaction)?

  • let's say I want to filter entries specifically to the currently logged in user (every user makes his own movie and genre lists) - should I filter by user ID in the MovieService or should I implement this condition in the repository itself?

  • is the EF DbContext a repository already and maybe i shouldn't make wrappers around it in the first place?

Any help is appreciated. I know I can get it working one way or another but I'd like to improve my understanding of modern coding practices and use these patterns properly and efficiently rather than feeling like I'm just creating arbitrary abstraction layers for no purpose.

Alternatively if you can point me to a good open source projects that's easy to read and has examples of a complex app with these layers that are well organized, I can take a look at it too.

 

Let's say I am making an app that has table Category and table User. Each user has their own set of categories they created for themselves. Category has its own Id identity that is auto-incremented in an sqlite db.

Now I was thinking, since this is the ID that users will be seeing in their url when editing a category for example, shouldn't it be an ID specific only to them? If the user makes 5 categories they should see IDs from 1 to 5, not start with 14223 or whichever was the next internal ID in the database. After all when querying the data I will only be showing them their own categories so I will always be filtering on UserId anyway.

So let's say I add a new column called "UserSpecificCategoryId" or something like that - how do I make sure it is autogenerated in a safe way and stays unique per user? Do I have to do it manually in the code (which sounds annoying), use some sort of db trigger (we hate triggers, right?) or is this something I shouldn't even be bothering with in the first place?

 

Let's say I have a method that I want to make generic, and so far it had a big switch case of types.

For an simplified example,

switch (field.GetType()) {
case Type.Int: Method((int)x)...
case Type.NullInt: Method((int?)x)...
case Type.Long: Method((long)x)...

I'd like to be able to just call my GenericMethod(field) instead and I'm wondering if this is possible and how would I go around doing it.

GenericMethod(field)

public void GenericMethod<T>(T field)

Can I use reflection to get a type and the pass it into the generic method somehow, is it possible to transform Type into ?

Can I have a method on the field object that will somehow give me a type for use in my generic method?

Sorry for a confusing question, I'm not really sure how to phrase it correctly, but basically I want to get rid of switch cases and lots of manual coding when all I need is just the type (but that type can't be passed as generic from parent class)

 

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.

 

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.

view more: next ›