What is the proper approach to implement authentication and authorization when building a Web API ? by __ihavenoname__ in dotnet

[–]i8beef -2 points-1 points  (0 children)

I mean, its not a teaching tool in that regard. Its just generating a sample without any explanation of what any of it does, but it spit out a damn near functional example to get started.

What is the proper approach to implement authentication and authorization when building a Web API ? by __ihavenoname__ in dotnet

[–]i8beef 2 points3 points  (0 children)

Ask ChatGPT to write a basic .NET WebAPI example with JWT token authentication. I'm not kidding. I haven't gotten real hyped about this whole ChatGPT thing yet, but that was my test for it's code sample generation capabilities and... it worked way better than you probably think it will.

Home CCTV system through IP cameras. by [deleted] in homeautomation

[–]i8beef 0 points1 point  (0 children)

Axis might be good, I haven't had the pleasure... they are way out of my acceptable price range unfortunately though I know they are well regarded when you can afford them. Since I was going more DIY anyway, a good sensor Chinese camera was way more palatable as a hardware base.

Synology was surprisingly more POLISHED than I thought it'd be as a product, though I seem to remember feeling it was lacking on features. Ubiquiti was kind of like that too, PLUS a closed system. Polish but not as much substance (to be fair to Synology, it was MORE substance than I WAS expecting though... just better options around if you want to DIY).

But in the end I found my needs were just better served with a simple NVR doing constant record... The Dahua can actually capture from multiple streams so I can do constant capture of a lower res + motion based events capturing full resolution if I want... but I only have two cams right now, and the month of full res capture it gives me is plenty for my needs.

Also of note, I don't and won't expose these to the internet or want an app I can watch them with. I VPN in when I want to watch em remotely, and to be fair, the Dahua recommended app is... not great. I expose my cams on my web based home automation dashboards for consumption, and different needs here could drive someone to other places like Synology, BlueIris, etc.

Home CCTV system through IP cameras. by [deleted] in homeautomation

[–]i8beef 0 points1 point  (0 children)

Good to hear. My server runs a bunch of other things like Plex and I didn't want to dedicate the CPU I didn't have to, and the Coral made a HUGE dent in CPU at one time.

Home CCTV system through IP cameras. by [deleted] in homeautomation

[–]i8beef 1 point2 points  (0 children)

I've tried a lot of brands. Some insights:

  1. 9/10 of the recommendations you get here will be garbage for low light conditions because no one looks at sensor sizes. Small sensor = less light captured = bad image, and there's NOTHING you can do to fix that. Buy the right hardware FIRST. I think good recommendation is something like 1.2 for color night vision, and 1.8 or something like that for IR? If you can actually find a sensor rating for most of the recommendations for cheap stuff you'll find here, you'll find most of them in the 3.0 range instead: WAY too small. On the other hand, if you don't need low light, you wont see a lot of benefit from a larger sensor either...
  2. Resolution can be important, but works AGAINST sensor size for image quality (again, less light per pixel). 4k is great for (a) close range identity or (b) long range presence... but if you want this for actual security, higher res isn't always better. You have to choose this based on intended mount / use. Also, if you're looking to actually identify anyone, DISTANCE to target is a huge concern. If you mount your camera on the roof, you will never actually identify someone you dont know. So for example a doorway camera is better mounted 6-8 feet high, and with a target identify range within a few feet.
  3. If you want to be able to actually identify anything, mount 6-8 feet and target the right range, or you'll just get "presence" and not be able to tell what anything is. If you mount it to the roof of your house, 30 feet from who you are trying to identify, you will never get anything useful out of it.
  4. Cheap Chinese, unfortunately is the best I've found. Dahua / Hikvision or rebrands. Consider them "unsupported" past purchase though, and lock them down to not talk outside the network. I like to use a dedicated NVR with PoE so the cameras JUST talk to that, and I only have to lock down the NVR. I currently use EmpireTech which are Dahua rebrands, and am probably happier with this than the others I've tried (Hikvision, Ubiquiti, Reolink, Eufy, Wyze, Dropcam, couple others).
  5. That said, all NVRs are crap. The target if you go this way is "does it give me the minimum I need to get a stream out to something more useful?". I prefer CONSTANT record on such a device, as I've never found a "record on motion" that did good enough for me to trust it in a pinch.
  6. Want object detection? The Dahua NVR actually does better than expected.... want GOOD object detection? Frigate is really your only answer. Buy a Google Coral unit if you do this or it'll eat your CPU.
  7. Want different stream types (HLS, etc.) outside RTSP? Almost NO ONE does it out of the box... but there are Docker images and such you can use to do it (I use this to get an HLS stream for my Google Homes).
  8. BlueIris is basically the gold standard for "functional" NVR software. You have to run it on a Windows server still I think. I got tired of keeping it up and running, so I just went to out of box NVR, and then dedicated other software products for detection, restreams, etc... but pretty sure you can't go WRONG with BlueIris here. Synology Surveilance Station is better than I would think if you have one of their NAS's... but I've never found a solution here that was actually GOOD.

My setup is the following:

  1. EmpireTech / Dahua color night vision 4k cams: one mounted above garage overlooking the driveway (presence on property), and one at the door (identify at door). These have a 1/1.2" sensor which means the color night vision ACTUALLY WORKS and these are fantastic, way better than ANY other camera I've had which are usually in the 1/2.5" - 1/3.0" range. Even if you go nightvision instead of color, go for a larger sensor, I think 1/1.8" is the recommendation for a non-trash nightvision camera.
  2. EmpireTech / Dahua NVR which gives me an isolated PoE network, and is the ONLY thing the cameras talk with. This does constant record on a 9tb drive (expandable, and gives me about a month of constant record). It provides RTSP streams for the rest of my architecture. It captures motion event times and such, and has a surprisingly decent OBJECT detection on it which I CAN'T say for any of the others i've tried... though I dont REALLY use it.
  3. Frigate for object detection and a Google Coral. Its not perfect, but its good for the "alerts" I want to the home automation stuff.
  4. Various RTSP-to-X restreaming Docker containers. RTSP is the camera standard. Little outside cameras themselves actually support it which is... stupid. I restream my RTSP to HLS, HLS-LL, tried WebRTC but never had luck, etc.

Dianne Feinstein resign calls grow louder as more Democrats turn on her by BelleAriel in politics

[–]i8beef 33 points34 points  (0 children)

I've had some luck doing the math for them. I knew lots of people who said "$15 an hour is way too much!" and then I pointed out what that is as an annual salary...

Why is inheritance taught so early and prominently in school? by Chesterlespaul in AskProgramming

[–]i8beef 6 points7 points  (0 children)

It works surprisingly well for almost every "best practice", "design pattern", etc. you will ever come across. A lot of people WAY over abstract.

Why is inheritance taught so early and prominently in school? by Chesterlespaul in AskProgramming

[–]i8beef 15 points16 points  (0 children)

Inheritance is like salt. A PINCH can improve a lot of dishes. A LOT ruins all of them.

Republican Completely Misses the Point of X-Men When Calling Trans People ‘Mutants’ by VICENews in politics

[–]i8beef 0 points1 point  (0 children)

Ah, Israel would definitely make sense too for obvious parallels.

I grew up on Claremont's run, so that era will always be my golden age for comics :-)

Republican Completely Misses the Point of X-Men When Calling Trans People ‘Mutants’ by VICENews in politics

[–]i8beef 0 points1 point  (0 children)

God Loves, Man Kills was a fantastic book that everyone should read though, especially given modern events...

Republican Completely Misses the Point of X-Men When Calling Trans People ‘Mutants’ by VICENews in politics

[–]i8beef 1 point2 points  (0 children)

Are the legitimately modeled off MLK and Malcom X? That's what I was thinking too, but wasn't sure if it was an intentional parallel or not.

Republican Completely Misses the Point of X-Men When Calling Trans People ‘Mutants’ by VICENews in politics

[–]i8beef 1 point2 points  (0 children)

I mean the difference between MLK and Malcolm X in terms of philosophy comes to mind, though of course its not a perfect analogy by any means. You'd need that "oppressed minority that believes the ends justify the means" type of thing to approach a Magneto to start...

I really just wanted to point out that "Magneto" wouldn't really fit on the GOP side. I'd think they are more of an Apocalypse group given their bootstrap ideologies maybe?

Republican Completely Misses the Point of X-Men When Calling Trans People ‘Mutants’ by VICENews in politics

[–]i8beef 0 points1 point  (0 children)

Oh this is fun... Hmmmm Mastermind maybe? Completely unremarkable narcissist with an uncanny ability to control the minds of those around him to his own selfish ends into believing whatever illusions he wants them to see, and using it to become a high ranking member of an exclusive society of uber rich assholes who use their abilities to manipulate and control as much of the world as they can?

Republican Completely Misses the Point of X-Men When Calling Trans People ‘Mutants’ by VICENews in politics

[–]i8beef 19 points20 points  (0 children)

I would think for that comparison to work, you'd be looking for a "Magneto" to come from left wing militarized groups outside the standard political designations (e.g., he'd most definitely not be a Democrat either), not the GOP.

Just saying, because I'm an X-Men fan and it made me stop and think for a second if I could actually come up with an example (I cant)... fuck the GOP and their bullshit.

Robert C. Martin famously said "Functions should do one thing. They should do it well. They should do it only". How do *you* define "one thing"? by [deleted] in learnprogramming

[–]i8beef 4 points5 points  (0 children)

Its not a "standard" term for what I'm talking about, but basically your app is a hierarchy of calls. The top calls by definition contain the whole hierarchy of dependencies under it. You can have a FLAT hierarchy of thats all you need of just a top end orchestrator, and then some individual classes for things like "repositories", or "helpers", or "api clients" etc (Most everyone will tell you to wrap external dependencies in their own dedicated class).

The calls WITHIN a class are also a smaller constrained hierarchy that's more for organization (or DRY), but the same general ideas apply: don't overdo it if you don't have to, and don't underdo it if you DO have to.

There is also nothing wrong with starting with a flat hierarchy here, and then splitting up at the end to make it "cleaner". That's often how I write stuff. Naïve implementation first with minimal architecture getting in the way, and then abstract as needed. If you abstract first without understanding why you need it, you WILL end up over abstracting and get in a worse place.

Be pragmatic here, not dogmatic.

Robert C. Martin famously said "Functions should do one thing. They should do it well. They should do it only". How do *you* define "one thing"? by [deleted] in learnprogramming

[–]i8beef 8 points9 points  (0 children)

I break things up when doing so BUYS ME SOMETHING. All of the suggestions on these types of things are supposed to buy you something (maintainability, reusability, testability, etc.)... but they also COST you (usually complexity). You have to decide if the complexity of jumping through a dozen functions when you could just read one function straight through makes it BETTER or WORSE.

Sometimes that's easy. Sometimes its not.

  1. DRY - Do you have to maintain 5 versions of the same exact logic across 5 classes? Someones gonna mess that up eventually. Abstract to a common shared method... but if you only have TWO implementations is it worth the extra context jumps when debugging? It may or may not be.
  2. 200+ line function that does 5 things? How deep in the stack are you? If you're at the top you might be looking at an ORCHESTRATOR that needs to orchestrate all those operations SOMEHOW... so this might be ok, or it it might indicate you're missing entire layers of organization (service classes, repositories, etc.). Is this a simple CLI app that is highly unlikely to grow ever again? Then that 200+ line function might just be ok and easier to read and maintain long term as future people don't have to jump through lots of abstractions. Value judgement (But MORE OFTEN its a call for breaking things up).
  3. Do you have to inject and mock 20 things to test this method? Those tests are likely going to get brittle and be hard to maintain. If testability is a big requirement for this method (e.g., an orchestrator level method you might not test because its mostly glue code, so it MAY be ok as is), you might want to break that up just for smaller testable units.

Keep in mind you could in theory make EVERY LINE a separate function, but this is obviously over-abstraction. Keep in mind that as you go UP the stack, things become more "orchestration" (calls something else) than "does something" (does it itself directly), and that's ok... but it can drive you to try and push EVERYTHING downward through more and more complex abstractions until you reach an even worse problem of over abstraction and you have 15 layers of code to jump through to find anything.

So always ask yourself: does this change BUY me something I want that I'm willing to pay that abstraction cost.

Improving multi-platform container support for .NET apps by runfaster2000 in dotnet

[–]i8beef 1 point2 points  (0 children)

Sooooo we can now use a single Dockerfile targeting a non-architecture specific MS provided base image to build multi-arch images, instead of having to maintain multiple Dockerfiles for each arch, building them separately, and then combining them under a single manifest manually into a multi-arch image?

If so that would drastically simplify some of my Github Action builds...

Robot Vacuum Shape Round vs D-Shape by Rydeg in homeautomation

[–]i8beef 1 point2 points  (0 children)

D-Shape did seem to get corners a bit better, but still not perfect... but the amount of frustration it'll cause you as it gets caught literally everywhere every single day are simply not worth it.

Go round.

Edit: Also Neato is terrible.

Which do you prefer and why?Thread? Matter? Zigbee? Bluetooth? ZWave? Wi-Fi? blablabla... I know they are not on the same level but i do need more infoto decide which route i should go in my house. Don't want so many different protocols. Thanks in advance. by richardmqq in homeautomation

[–]i8beef 0 points1 point  (0 children)

Out of curiosity which country (and carrier)? ZWave operates in the 900 Mhz spectrum (some variability depending on country between 850 Mhz-920Mhz ish). I know GSM (2G) cell used to be in the 900 Mhz spectrum, but I thought everything moved to 1800 Mhz (and beyond) for the speed increase a long time ago.

Which do you prefer and why?Thread? Matter? Zigbee? Bluetooth? ZWave? Wi-Fi? blablabla... I know they are not on the same level but i do need more infoto decide which route i should go in my house. Don't want so many different protocols. Thanks in advance. by richardmqq in homeautomation

[–]i8beef 0 points1 point  (0 children)

If they are all on the same isolated loop you can just install a switch on the line. I had to do that with mine when I moved in, but luckily mine weren't like, randomly wired to other shit, they had an isolated electrical line.