« first day (3898 days earlier)      last day (1033 days later) » 

5:30 AM
Good morning
 
 
2 hours later…
mr5
7:36 AM
C++ is shit
2
 
GM, why do I need to duplicate connectionString in the executable project (Web API), if it's already defined in the DAL project (class library) which contains the DbContext, it's ready confusing!
 
7:49 AM
Or it only needs to be in the executable? :/
 
mr5
8:03 AM
You only need it on the project where the DbContext is being instantiated.
 
I thought that also, but it turns out, it should be in the executable project (in the web.config)
I removed the connection string from the Class library that contains the DbContext, and kept it in the API web config, and it works fine
 
mr5
oh you are referring to the config file? then it must be on the executable project.
instantiate the DbContext on the executable project and just reference it on other.
 
when will .net have project level resources?
like Java
 
mr5
do you know what is causing not to read from the class library? is it because of the executable path?
 
8:23 AM
depends on how the resources work
when you build, the .dll (and .pdb) are placed in the bin folder
also, all resources are copied over to the bin folder as well
if multiple proojects define an "app.config", then it would have 2 files with a conflicting name
for configuration specifically, it has a workaround, using the project_name.config pattern (or something like that)
but even then it is still messy
 
8:40 AM
but it makes sense though; moving the DbContext to a class library that other projects may use, requires every consuming project to define its connection string
 
it only makes sense sometimes
obviously, the using project must have an option to overrule the default settings
public class DbContext
{
    private String ConnectionString { get; }

    public DbContext(String connectionString = null)
    {
        ConnectionString = connectionString ?? GetConfigValue("database.connectionString");
    }
}
like this, you always have a way to specify which connectionstring you use instead of letting it figure it out by itself
 
@mshwf The trick is to only have it in the executable project
My DAL has this:
1 message moved to friendly bin
The default connectionstring is technically not needed as I would always use the DAL form my webapi project which passes a connectionstring because I built it, but theoretically it is now usable without it too.
 
8:58 AM
I use the old way: passing the name of the connecton string to the DbContext constructor. I must look at the .NET core modularity way
 
Yeah if you're using netCore anyway, try using DI, it's very convenient.
 
hmm...
postman: 200 (OK)
C# HttpClient: Response status code does not indicate success: 302 (Found).
wadda heck?
it is even found, why would you not let me have my response?!
 
Isn't 302 redirect?
Postman automatically follows redirects by default
 
it is
 
Not sure whether or not HttpClient does that too, but it seems not
 
9:04 AM
gotta tell httpclient to follow redirect
 
new HttpClient(new HttpClientHandler
{
    AllowAutoRedirect = true,
}
shouldnt that follow redirects?
 
maybe
If you believe this guy, it should automatically follow redirects by default.
 
(X) Doubt
 
Give me some copypastable code to paste into my REPL?
Presuming it's a public API
You know, to make sure it's your fault
 
9:20 AM
heh, it is my fault for getting a 302 tho
IDE says "pls dont use http"
 
Nah it's something that should be handled
 
server says "ye, we redirect all https calls to http"
 
uh what
 
I changed it to https but the server wont accept that
 
Time to slap your server?
 
9:21 AM
stupid 3rd party server
 
seriously
 
although... it should still do redirecting correctly
 
Time for a formal slap to the 3rd party
 
var httpClient = new HttpClient(new HttpClientHandler
{
    AllowAutoRedirect = true,
});

Stream response = await httpClient.GetStreamAsync("https://www.digitaal.loket.afm.nl/nl-NL/Pages/MutatiebestandFDRegister.aspx?action=downloadfullnew");
 
Maybe it doesn't because no https
 
9:22 AM
perhaps...
but that would be silly
the logic of redirection should be to use the Location header in the response
and ignore the current protocol
 
302 for me too
 
I blame C# :D
as usual
 
10:00 AM
why do record classes not work in 3.1? :(
cant they just introduce compiler features in the compiler?
 
 
1 hour later…
11:07 AM
how would you do a parallel task process?
what I currently do is
await Task.WhenAll(stuff.Select(it => it.DoStuffAsync()))
which does the job quite well... except that I have to rate limit it
DoStuff in this case is sending a request to a server, but that server will not accept a DoS attack :)
 
Parellel.ForEach has simple rate limiting
Or try LINQ .AsParallel
stuff.AsParallel.Select(DoStuff).FIgureOutIfIT'sAsyncNow
 
11:22 AM
Parallel.ForEach does not support async
 
await Enumerable.Range(0, 10).AsParallel().WithDegreeOfParallelism(5).Select(Stuff).Aggregate((o,t) => Task.WhenAll(o,t))
 
AsParallel does not allow me to set the rate limiter
nvm
 
I'd say degree of parallelism counts
 
.WithDegreeOfParallelism(5) is what I needed
 
LINQ keeps getting better the more things I learn it can do.
 
11:24 AM
it is still a rookie on the basics tho
hmm... I also need that Aggregate instead of a direct Task.WhenAll...
 
Yeah that one would be nicer with valuetasks I think
 
so far, I only need to await it, not actually use the result
so it works
:)
 
Ah nice
I think this is the first time I used something from that udemy course last year
 
11:53 AM
people stating Parallel lib is very efficient, but in my experience it's snail slow compared to an equivalent async version
also it very much depends on which computer. For example only on my cpu it's slow
 
it depends on the process and on how many cores you have
if your cpu is just trash, everything should run slow
if your cpu only has one core... then Parallel wouldnt really improve anything
 
async works on the same cpu, with same trash
 
if your process needs expensive locking, then doing parallel stuff is basically just having your machine wait all the time
 
it was an ok computer. i5 4 cores etc
 
async switches contexts when cpu is idle
you can do a million http requests at the same time because you can start all of them
as long as you can start them faster than the other end responds, you can spam the server
it could be faster but at some point, you need a rate limiter
which is what Parallel already does
 
11:58 AM
I had a rate limiter implementation with async and with Parallel. That was exactly the tested application. But I think the tasks were computations, not Web get
 
then why are they even async?
 
and Parallel was slower than run the tasks serially
it was a bug. It was not about the nature of the task
 
Tasks still prolly use the default thread pool, using up your entire cpu anyway
 
Parallel implementation missed something dependent code on my specific i5 architecture or something
but it was bugged as hell
 
I think this whole flat icon design trend is dying, if win11 is any indication
 
12:03 PM
flat icon?
 
yeah, you know like the meem
Mr. Incredible watching all the icons being simplified
 
@Wietlol Why don't load the connection string with Configuration that is injected by DI?
 
because I think you shouldnt
the rules are very simple: the database class needs a connectionstring, it does not need a configuration
so, you give it a property for connectionstring, not for configuration
at the DI, you can decide to load the value from the configuration
 
12
A: How to allow migration for a console application?

The Shortest Mustache TheoremImportant: Don't name your assembly ef (or eF or Ef or EF) to avoid this exception. After struggling several hours, I found the solution as follows: using EFCore.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Design; using Microsoft.Extensions.Configuration; usin...

 
12:21 PM
Maybe also don't call the namespace EFCore^^
 
meanwhile in Javaland: package: me.wietlol.wietbot.commands.evalkotlin.core.api.models
that better be unique
 
mr5
java or kotlin?
why is kotlin still using src/main/java/ folder convention
 
iDunno
but Kotlin is just a front end
when you write Kotlin/JVM, then I suppose it makes sense to use the JVM patterns
 
mr5
then it should be named jvm, not java?
 
@mr5 by default, it wanted to be /src/main/kotlin/ just to be hipster
but to be fair, there is no reason to have them in different folders
the compiler is smart enough to figure out what the files are
and src/main/java is the default of maven
 
mr5
12:29 PM
do you use gradle as your build system?
 
so that works out of the box
I havent used gradle that much, no
 
mr5
maven is another build system right?
 
even though there is a gradle.kts version so you can write your build stuff in kotlin as well instead of groovy...
yes
maven and gradle are just the same thing with a different front end
maven uses xml, gradle uses groovy or kotlin
 
mr5
oic
so kotlin is based on groovy language
 
both are just project management tools (providing identification, build processes, dependency lists, deploy scripts, etc)
kotlin is based on many languages
one of those is groovy, indeed
 
mr5
12:33 PM
gradle is supposed to be the defacto build system for any jvm based languages, why are you still sticking on maven
 
maven is bae
 
mr5
man, after being exposed to C++ again, I feel like a complete noob again. I can't understand the heavily templated C++
everything needs to be written verbosely
 
Ahh, the configuration nightmares!
Why is there *.dll.config file besides the app.config in the deployed folder?!
and I have to edit the configuration in the *.dll.config that was originally in the app.config, in development!
just why they generate another config file, despite the app.config is in the same project!!
 
1:30 PM
because .net
> 64-bit upgrade
finally... I guess
> .NET 6
I suppose you need at least some content...
> Best IntelliCode yet
well... it would be silly if you make it worse every release
gotta love MS_marketing.exe
 
mr5
lol
I hope they reduce the number of buttons on VS
 
mr5
1:52 PM
@Wietlol can I do Xamarin in Rider?
 
iDunno
probably
> currently JetBrains Rider does not provide a designer or a previewer for Xamarin forms
limited support
 
 
2:33 PM
what's the joke?? the humans are smarter than the aliens?!
 
mr5
there is none
 
Continuation of the previous one where they came back and wanted to show us how to build pyramids again
Except in on a larger scale very recent times, human technology advanced very quickly.
 
2:57 PM
 
3:10 PM
on the original (2477) at least I can grasp an unintended joke of Stonehenge's construction technology we lost
 
okay now it makes sense
 
I assumed the comic was just about humans being far more advanced in technology than aliens
basically looking down on building pyramids and stonehenges as if it were like breathing or drinking
so, (second comic), the aliens come back to try to impress the humans again... failing again
it is like C# trying to show new language features that I already use every day (in other languages)
C#: "look look! I made records! are you proud of me?"
Wietlol:
 
yeah. F# had async since 2007
 
3:45 PM
my employer has possibly lost hundreds of dollars because of a screwup in the first program I made for them, and this is after I was told "naw mann it's fineee"
 
4:12 PM
what is hundreds of dollars lol
come back after you lost a few millions
 

« first day (3898 days earlier)      last day (1033 days later) »