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

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?

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

Oh didn't see that one, thanks! Of all the advice there did anything stick with you and help in the end?

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

But to truly master Linux, you need to understand its internals, like how the system boots, how networking works, and what the kernel actually does. In this third edition of the bestselling How Linux Works, author Brian Ward peels back the layers of this well-loved operating system to make Linux internals accessible.

Isn't it too advanced? Seems like a good book but like the opposite of what I meant - I'm curious about beginner resources that will get people interested, knowledgeable and comfortable about using linux on a daily basis as much as they are with windows after decades of using it, not to turn them into a "superuser familiar with internals like kernel, networking, LVM".

63

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?

37

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?

[-] Cyno@programming.dev 3 points 1 month ago* (last edited 1 month 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 1 month 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 28 points 2 months ago

You can kinda see this in things like modding communities or anything piracy related too. Users just want easy solutions even if it's at the expense of creators, and creators are doing it more and more for money rather than any personal drive or satisfaction. I can't believe we've reached a point where even mods are being locked behind paywalls, need to be commissioned or sometimes have entire teams funded by patreon to work on them, it's just another business nowadays.

[-] Cyno@programming.dev 2 points 2 months ago

I have this instinct drilled into me for years that anything using reflection is bad, both in terms of performance or code clarity/ease of debugging. Your answer is correct though, I could make a generic method using reflection... now I'm just not sure if it's better to just manually hardcode the cases for all types anyway

5

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)

17

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?

9

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.

1
submitted 9 months ago* (last edited 9 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 2 points 10 months ago

I only have half as much experience as you, and none with Go specifically, so I can't give you any good answers but I can say I empathize - the company I work at is also stuck with a legacy monolith that's still on .net framework and everything is so coupled that it's impossible to even unit test, less alone deploy the projects separately. Some people aren't bothered even with the basic principles of code writing and the senior people are just overworked and can't keep tabs on it even if they wanted to.

The worst part is that the company is mostly either juniors just doing what they are told or older seniors that are stuck in their ways and are afraid of anything new - although as I got older I started to see why that might be the correct approach, not everyone wants to learn and adapt to new tech and it's a big ask of the upper management to risk it on that. Basically we're just repeating the same mistakes and wasting time fixing known errors that keep happening and any actual improvement or proper removal of tech debt never happens.

So yeah... I'm starting to believe that "clean good code" only happens either in hobby projects or new startups. Any larger, "stable" codebase of a larger company is going to be an inefficient mess however 🤷‍♂️

[-] Cyno@programming.dev 8 points 10 months ago

I agree completely. The discussion was what we replace English with however.

I'm not in favor of replacing English, I'm just saying if we want an alterantive I don't want it to be a nation-specific language again, so to speak.

[-] Cyno@programming.dev 3 points 10 months 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 10 months 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.

[-] Cyno@programming.dev 3 points 10 months 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.

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: next ›

Cyno

joined 11 months ago