« first day (3789 days earlier)      last day (1142 days later) » 

mr5
2:33 AM
holy. I'm this old to know how this thing works: playground ride
 
3:23 AM
Idk maybe some shortcut key can revert the selected text's up/lower case?
PUBLIC CLASS aDDuPDATEpRODUCT{}
4years of coding, almost everyday I had atlease once typo on capslck
 
 
4 hours later…
7:45 AM
Good morning
 
 
2 hours later…
9:31 AM
[Squirrel in Training] GoOoOoOoOoOoOoOoOoOoOoOd Mornin' neglecterinos!
 
 
2 hours later…
11:15 AM
Hey, I have a question about serviceLocator in webAPI project (.net core 3.1)
How do I do it?
 
Do what?
 
How do I get the instance of a registered service through service locator
 
No idea what a service locator is, I just know the service provider
 
Okay my bad it's serviceProvider
 
11:18 AM
sp.GetService<YourService>(); then
 
GetRequiredService
 
Or just inject it to the ctor
 
I'm trying out something like this ServiceProvider.GetService<DbContextFactory>() from using Microsoft.Extensions.DependencyInjection
I cannot use ctor because it's a static method, and it needs to be static
 
I hate static ctors
Are you absolutely definitely 100% sure you need a static ctor
 
The class is not static nut the method is static
 
11:19 AM
@Comraid and this does not work?
 
Can't inject the sp into a static ctor
Technically, the static context exists before DI is set up
 
it doesn't recognize GetService method I says there a method with (Type paramter) but no generic method
 
So it's possible to be called before the services are even registered
 
then you dont have a serviceprovider
you first need a service provider instance
 
@Wietlol is it something that needs to be written? or does Microsoft.Extensions.DependencyInjection provide it?
 
11:21 AM
@Comraid Does the method really have to be static tho?
It is provided by the framework
 
unfortunately yes
 
If it needs a service but still has to be static...this smells. Like, really smelly.
 
@Comraid you have to get it from somewhere
 
I know the code base is all messed up! but what are the options do I have ? @Squirrelkiller
@Wietlol Can you please elaborate?
 
you need a ServiceProvider instance
 
11:25 AM
How do I get one?
 
often times, there is one instance being passed around all the time, especially in frameworks
 
I know I'm stupid please tolerate with me a bit
 
I am not entirely sure where you get it from in a web service project
is there other code in the same project that already uses a service provider?
 
See the WPF application does have it, but I'm confused about the web service project itself
Nope
So let me tell you the whole scenario, there's a expression builder which is a static method, it creates expression based on the user selection and one of the specific type of expression needs a data to be pulled from database, hence the whole chain of static methods
 
your methods still probably dont need to be static though
 
11:31 AM
Now what options do I have? other than service locator? can i refactor it?
@Wietlol If I make something non static the chain of changes will be triggered
 
chain of changes?
 
Static A() => Static B() => Static C(), if I make C as non static then B needs to be non static right?
 
yes
 
thats what I was talking about chain of changes
 
in any case, you can pass the service provider through your chain
if C needs to load a service from the service provider, C needs the service provider as parameter
 
11:34 AM
the seriveProvider literally isn't working syntactically, else I would use the service provider at C
 
then B in turn, needs a service provider to invoke C
still a chain of changes
 
Yes
 
@Comraid that is because the syntax you use is resolved as a static method invoke, but GetService is not static
C# does an excellent job at being the most confusing in this regard
in the example you took the code from, you only copied "ServiceProvider.GetService<X>()"
 
But I tried to use it as a property too, that should work right?
 
but ServiceProvider from the example was probably a property, not a direct link to the type
also copying the property would indeed work
as long as that property is visible and accessible from your function
but then you have the problem of static properties...
 
11:39 AM
All I want right now is to make the ServiceProvider get detected and return the result for it
 
I understand, but next week, you want it to still work
 
Anyone know if there's an equivalent to the vscode remote development extension pack for visual studio proper?
 
so, I suggest adding a parameter for the service provider
 
Beyond just e.g. the remote debugger?
 
@Comraid since it's webApi, just add a parameter to the constructor of type IDbContextFactory. ofc you need .AddDbContext at the setup, but that will bind the IDbContextFactory to the correct DbContextFactory instance
 
11:45 AM
@ntohl But the constructor wont be invoked! since the method is being executed as A.method();
there no new keyword
 
how does A constructed?
 
@Comraid So when the application starts up, the services are registered into DI. What happens if your DI isn't fully registered yet and the static method is called?
There is technically a hack you could use
But it's a hack
It's not nice
It's not a good solution
 
Okay wait there will be no condition where the service needs to be invoked before or anything
 
It's a workaround in case you can really absolutely definitely not make your methods instance methods
So I will give this to you but you have to understand, it's like, a live or death scenario. You're not supposed to do this, because it sucks.
 
After everything is loaded the user request for it, by then the whole thing will be set up right?, I dont understand what do you mean by service needs to be invoked before
@Squirrelkiller
 
11:49 AM
You have a class that contains a static method, and the static method absolutely needs to be static, and absolutely needs the service.
@Comraid I didn't say invoked, I said registered.
 
Or can you guide me to do things in the right manner?
 
there are 2 ways:
1, refactor your static methods so they are not static
2, add a parameter to your static methods to pass the service provider
 
Like I can show you a small set up may be replicating my exsiting situation I dont understand if I can refactor it
 
1 is a very good solution and should be the general idea in any new project
2 requires less work given the current state of the project, yet wont result in horrendous issues unlike other "solutions"
 
If you think I can refactor then I will go for it, but I dont know if it can be.
 
11:52 AM
there is a place in Botler, where CommandFactory takes care of being ServiceLocator>
https://github.com/butler1233/stackoverflow-chatbot/blob/master/StackoverflowChatbot/CommandProcessors/CommandFactory.cs
there are some extra code to rebind some types, where the actual "singleton" changes
 
this just screams of scopes
 
The workaround: Make a static property that returns your service. Inject the service in the class and store it as an instance variable. Make a static variable that is a Func<YourService>, so it can be called as a factory. In the ctor, assign a factory method to that static property like myFactory = () => return this.TheService;. Make the static Property a getter that calls the factory and returns the result like YourService Service => myFactory(). In the static method use the property.
 
but you need to have the ServiceCollection set up prior
 
If you do that, I hope you have a good excuse to not get beheaded in the code review.
 
11:56 AM
How do I refactor bruh
I'm already in a bad position, I dont want to screw things up
 
yeah. The code I posted uses something like Inject the service in the class and store it as an instance variable... github.com/butler1233/stackoverflow-chatbot/blob/…
 
@Comraid then add the parameters
or better yet, add parameters of the actual services you want to use rather than the service provider
 
you mean the context?
 
the DbContextFactory in your case
 
you mean as new DbContextFactory?
 
12:00 PM
as parameter
 
It goes up by 4 levels
 
then so be it
 
arghhh
 
Start with the first static method, find out how to make it an instance method.
So if you have A => B() => C(), make A an instance method.
 
^ that is option 1... which is better, but considering you think adding a parameter to 4 functions is too much work, I doubt you will like the refactoring of static methods to instance methods
 
12:06 PM
I mean, it's usually not that much of refactoring
 
okay let me put it this way without this one particular exception the static methods are pretty solid solution, how about now?
like there's 10 methods only 2 of them use dBContext.
 
static methods are not a solid solution
in a well designed application, there is 1 static method... which is Main
 
That's the point though. They are a "pretty solid solution" until you need special stuff.
Static method are for functional programming, and that's it.
 
mr5
@Wietlol you mean, helpers/utilities are not solid solution?
 
indeed
 
mr5
12:08 PM
make everything service?
injectables
 
Many times, helpers/utilities are hacks done because the dev can't think of a better place to put that code right now
 
@mr5 pretty much
@mr5 not necessarily
I suppose logical constructors could be static functions
but then again, perhaps they should be a part of a dedicated factory
a solid solution is one that remains to be a good solution when the design changed
 
mr5
what's your take on JsonSerializer? that thing is a solid solution for me.
 
JsonSerializer is a fluke :)
 
@Wietlol so you want me to go with something like class A { static void A(dataService, obj1) }??
 
mr5
12:12 PM
although if it were written in obj-c, they will probably require you to make a class every time you use its methods.
 
any self respecting serializer would have to be an instance based one
 
mr5
like that from Gson?
new Gson().serialize()
meh
I prefer a static method
 
for C#'s JsonSerializer, the instance is mostly handled by the serialization options
instead of passing around a serializer, you pass around options
@Comraid that would be an improvement
 
mr5
I think you can also pass JsonSerializer instance.
would be good if it's the case.
 
in simple terms, you have a function, which needs a service object... so that function has to do one of the following:
1, let others tell it which service object it should use
2, ask for a new service object
 
mr5
12:15 PM
@Wietlol what you mean by fluke here?
 
considering you want to avoid the second, I wont cover that one
the first can be split up in two categories
 
mr5
> a parasitic flatworm which typically has suckers and hooks for attachment to the host. Some species are of veterinary or medical importance.
 
1, parameters
2, instance properties
considering you have a static method, option 2 is unavailable (because I wont recommend static properties)
so, adding them as parameters is the only directly available option
 
mr5
@mr5 nope.
 
@mr5 I like this definition more :D
 
12:18 PM
Static serialiser is a solid solution when you have 99% of the people not needing any special options though so you just use defaults for everything.
 
@Wietlol ask for new service object is what I have been doing until now, but it needs to get the one which is being registered
 
"ask" primarily translates into code as "new X()"
 
until now it was being used as using (Context context = new DbContextFactory().Context())
 
yes, so now you want to turn that "ask" into a "tell" by receiving the dbContextFactory from the parameters
 
mr5
@Wietlol other meaning is "accident"?
 
12:22 PM
to be honest I have never seen any methods take an context as an input
 
and neither will your method after your refactoring
context != contextFactory
 
You...need the state of a dbContext in your static method?
This gets smellier by hte minute
 
@mr5 luck
@Squirrelkiller it smells of yagni
 
It smells like somebody should have built that application the right way from the ground up but didn't know about DI
 
not just DI, the entire concept of separation of concerns is missing...
 
12:27 PM
probably
Who knows, maybe the static method C is in the persistence layer for some reason
 
@Comraid they should be in constructor
 
12:57 PM
Hi, a beginner here. I have a project which runs well on Linux. For my next task, I need to make use of a implementation which has been done on .NET.
Is there a way to use the .NET implementation in Ubuntu 20,04
 
? You asking how to setup dotnet on linux? What kind of project you have? C#?
 
yes. In windows its a C# code, the stack has the .sln files
Is it possible to replicate what I see on Windows, to linux?
 
1:21 PM
that depends on what you see on Windows
 
Using dotnet core, you can use the same code for both operating systems, you just have to figure out what GUI to use.
winforms/wpf aren't available on linux
Avalonia is a project providing a GUI similar to wpf cross platform
 
mr5
you have a bad request in your avatar
 
anyone play valheim?
 
@mr5 I generally assume it is my adblocker that blocks avatars
 
mr5
@RakshanPremsagarKapikad you can use Xamarin
why would an adblocker block an image from google
oh
yeah prolly an ad
 
1:29 PM
But isnt Xamarin for mobile applications?
 
mr5
it's for wearables, mobile, desktop, TV
 
@mr5 it blocks avatars from facebook...
 
One more question, which IDE is best for C# in linux?
 
because facebook has no authority on this web page
in this case, it is just an http error
@RakshanPremsagarKapikad probably Rider
 
mr5
or VS code
or a VM with VS
 
1:32 PM
oh ok thanks
 
@mr5 also... it isnt my ad blocker :D it is privacy badger
 
mr5
badger...
> a heavily built omnivorous nocturnal mammal of the weasel family, typically having a gray and black coat.
 
mr5
why are you always using new word I'm not familiar with :|
 
it blocks their avatar
because it is from graph.facebook.com
 
mr5
1:34 PM
I don't think so.
 
which is not part of SO
 
mr5
If you open the image on another tab, it will show the actual reason.
 
badger is just an animal...
 
mr5
Same thing for that google image he have
I'm confusion now
 
oh, that is reason 2
> Failed to load resource: net::ERR_BLOCKED_BY_CLIENT
but this is the primary reason
 
mr5
1:36 PM
this one's from fb
@Wietlol it's actually: "An access token is required to request this resource."
 
what's that from? wow?
 
mr5
now, I'm not gonna collapse that image
it's from diablo page
maybe D3
oh right. a demon hunter
 
1:50 PM
@mr5 not for me
 
mr5
it's blockception
 
privacy badger detected that it might be a tracker, so it either blocks cookies or the entire request
in the case of facebook, it just blocks the request
 
mr5
but can you see that one from fb I posted?
 
on this page, it also blocked cookies from ajax.googleapis.com
i can see your image though
it is from a domain that badger has not yet categorized as tracker
 
2:05 PM
is there a spot in visual studio where you enter the publickeytoken? without a web.config file?
 
Ryan Donovan on March 01, 2021
One of the tough decisions you and your team may face as you scale is deciding between keeping your current codebase and rebuilding on a new architecture.
 
2:39 PM
docs.microsoft.com/en-us/dotnet/api/… looks like this will help
 
3:18 PM
Hi all
In web apps that detect we're on a "new device" (such as banking apps), are they detecting the user's IP?
 
IP wouldn't work as it is usually dynamic
They probably use a cookie
 
mr5
prolly that with a combination of User-Agent
 
Trying to determine how web apps detect that and then force a 2FA for the new device
 
User-Agent could change with browser updates though
My bet is on a cookie
 
3:33 PM
A GUID stored in the cookie and tied to the user's account on db
 
Or maybe just the identifier (i.e. username) in the cookie
 
Makes sense
Is that a good security practice -- to detect the cookie and if absent, force 2FA?
 
Anyone using the new-er webp image format?
 
Downloaded some images in that format but never generated any
 
Always look for a cookie first
Got to know anything about the user before they use the system
old school asp, had to make choices about what View to show them depending on the cookie check
We use IP as an Identifier when they're using the system, and block most vpn ip subnets
 
3:39 PM
IP/MAC can be spoofed so have to approach that carefully
 
Also a device only sees the MAC of the device next to it
 
Ahh, okay. Didn't know that
It's like the universe can be spoofed
 
Bascially they have a table "MAC xy is connected to ethernet port 3, so when a package for MAC xy comes, send it through ethernet port 3"
The internet as we know it is not built with security in mind, but with "it only works if everybody does the right thing". Basically if one node fucks up, traffic through that node is unusable.
A nice example of that is DNS: If you plug your home router into a company network, the whole network will start to collapse, as your router goes "you need an IP? Here you go.", devices in the network will go "oh nice there an IP for me I'll take it", but the domain controller of the network goes "what do you mean IP XY I didn't create that who are you?".
 
Well, it started as Arpanet back in the days of the Cold War. It was meant to be distributed, able to have other parts continue functioning if sections failed
 
Yes, failed
But if a node doesn't use the protocols correctly, things break
 
3:47 PM
Yup
 
Or if you connect a switch without STP to itself, the whole network will die from the storm too, because that's not how it's supposed to be used
 
4:02 PM
@Alex not many sites have data other's could use to make their own 'branded' site.
 
4:15 PM
True
 
5:07 PM
Ben Popper on March 01, 2021
Comparing summary statistics like the mean and median can help us understand how these variables are related, but we can learn even more by using visualizations.
 
6:02 PM
hey uhh how many of you left your first job outside college after a few months?
 
6:34 PM
For me, it was a year of contract work and then switched to full-time
 
hmm..I've been working full-time for almost two years, but I've heard how a lot of graduates only stay at their first job for 6 months at most
 
It depends. One job was so bad, I counted the days until I left: 340
 
o dam
 
I'd not leave in middle of a project, just to be fair to the employer. I left another contract position after 6 months. Not an issue, as long as you're moving to something and can say "I left to look for new opportunities"
Bouncing around too much can raise red flags w/ employers though
In IT, at least in smaller/govt orgs, you have to move to get better pay and learn more
Very unusual for someone to stay at the same org for entire career
Maybe at MSFT/Google/APPL
 
7:19 PM
Hi all
 
7:40 PM
hi
 
@Freerey I left my first job within a week.
 
oh boy
that bad?
 
I never went to college lol
work as fullstack though
 
8:47 PM
@Freerey Yeah. I got hired with false promises, essentially.
So... I left. It was an awful place filled with bad practice. Had to get out of there.
 
I remember warning one of my friends about a place that tried hiring me, but I looked into their glassdoor and heard horror stories....then later found out my friend went to work there anyway and was like "not sure what the negativity was about"
 
my colleague left today. He was an intern while learn in college. His task would require him knowing F#, WebSharper, Fable...
He was here for 1-2 month
@Freerey I was kinda in same shoes. I didn't know german, but the hierarchy there was very flat. Lots of time the german CEO ordered what task to do. I had not much problem there, but the level above me worked like an umbrella for me. Ppl left or fired all over the place. In half year 30 colleague left/fired.
I was the third oldest at the company after 1 year
I quit for some stability and went to a multi
 
9:08 PM
hot dayum
 
posted on February 25, 2021 by Scott Hanselman

Late last year I blogged about the Elecrow CrowPi2 Raspberry Pi Laptop. The folks at Elecrow are great and I've used their original CrowPi many times with the kids at and talks. None of these links are affiliate links and I am getting no kickbacks from the company - I'm just a fan and own two of their products. As such I was excited to see their new Kickstarter called CrowBits. These are magn

 
considering we have a website that stores login tokens (guids) in cookies on the browser's side
with which, the user is considered logged on until said token expires (expiry is handled server side)
would it make sense to also store the sender ip address with said token to ensure that the cookie has not been copied to some other device?
 
@Wietlol No. Token hijacking is a valid concern, but IP should not be one of the things you bind on. IP can change for numerous of reasons.
You can store other information and associate that, like user agent, plugins, etc.
 
i remember some services which use ip security
and when I log in on the website from a different ip address, I need to authorize said ip address
except for one case, I never had problems with it
so I am not sure what part of the ip address they used to validate the request, but it certainly sounds like a feasible option
 
9:25 PM
Dutch ISPs give home connections static IPs, yes, but that doesn't apply to the whole world. Germany is notorious for having dynamic IPs. But here, in the Netherlands, mobile networks don't have static IPs either. Sign on with your mobile device, drive to another city, and you likely get a different IP.
Depending on your use case and target audience, it can be very annoyng.
 
hmm... I suppose that makes sense
 
I would just use user-agent, accept, encoding and language to bind on. Copying a token then would most likely become invalid.
 

« first day (3789 days earlier)      last day (1142 days later) »