« first day (2747 days earlier)      last day (2217 days later) » 
00:00 - 13:0013:00 - 00:00

12:10 AM
posted on April 24, 2018 by Scott Hanselman

Last week while upgrading my podcast site to ASP.NET Core 2.1 and .NET. Core 2.1 I moved my Http Client instances over to be created by the new HttpClientFactory. Now I have a single central place where my HttpClients are created and managed, and I can set policies as I like on each named client. It really can't be overstated how useful a resilience framework like Polly is. Take some code lik

 
 
2 hours later…
mr5
2:20 AM
o/
can we use git to track all queries from a database?
 
er...
 
mr5
not that I need it, I just want to know
we could add a hook to its input stream ya know
 
 
1 hour later…
3:32 AM
is it normal to have DTO classes that are separate from the classes they are meant to represent?
 
@cubesnyc depending the protection needed yes
 
so like current situation i ran into
have simple database records name/pw
but the actual user class is much more complicated and has other properties
 
mr5
3:49 AM
AFAIK, DTOs should be used for data transmission only. You would have another model which is called domain model that should cover at least the id field in that DTO model. So yeah, it doesn't need to cover all the properties and is usually dumb
 
 
3 hours later…
6:41 AM
If you had to teach delegates to students, how would you describe a delegate in 1 or 2 sentences?
 
6:54 AM
Delegate - a person sent or authorized to represent others, in particular an elected representative sent to a conference.
Kidding :)
 
mr5
if they know what a function is, tell them it's like that, but can be stored for a later use
 
@ErwinOkken Tell them it's a wildcard function that they can assign to whatever they want, provided it has the expected signature
 
I do have my own way of telling them what a delegate is and the internet is full of quotes aswell, but maybe someone can surprise me :d
 
mr5
I first learned delegate when I want to pass the entire function instead of a variable
 
I wish Java had something like delegates
The closest thing they have now is lambdas I suppose, but that doesn't really fit the bill
 
7:10 AM
good morning
 
@ntohl That's like just your opinion, man
 
(ugt)
what's wrong with lambda?
 
lambdas don't have a fixed signature
Unless you're explicitly declaring it a Function or something, but maybe that isn't the signature you wanted
 
7:37 AM
delegate will have specific signature too
 
that's my point
You need a signature accepting three booleans and a CaptainKirk instance, you can make one in C# no problems
In Java, at the very least you need to create an interface
 
goood morning sharperinos!
Of crouse lambdas have a specific signature
() => doStuff();
is void without parameters e.g.
 
@Squirrelkiller I meant an equivalent of delegates in Java
without the use of interfaces
 
oh ok
 
8:01 AM
going for lazy bastard achievement in factorio
I keep forgetting and making items by hand ;_;
there is some leverage, but I think it's like 6 items or so (everything else is absolutely necessary to be built by hand)
 
Hi guys
whats wrong in this below sql query :
select top 10 * from (Select [Id] As [LinkedColumn],[Amount] As [AmountDump] From HR.Product)
I am getting this error :
Incorrect syntax near ')'.
 
@Learning-Overthinker-Confused Well does the inner query work without errors?
 
Actually inner query contains 12 million records
hence i want to select only top 10 from it
and yes it runs without error
This indeed runs successfully
Select top 10 [Id] As [LinkedColumn],[Amount] As [AmountDump] From HR.Product
 
@Learning-Overthinker-Confused Ok, so logically the problem is the syntax of the outer query
It isn't that it doesn't like a column being used, in other words. It is that you cannot arrange your outer query that way.. Is this MS SQL?
 
Actually what i want to do is i have 1 page where user will write sql query and then i want to display top 10 records to user
I am using sql server
 
8:14 AM
I don't know if that's possible
everything I've seen involves using an inner query in the where clause
 
This works now :
SELECT TOP 10 *
FROM (
  SELECT [Id] As [LinkedColumn], [Amount] As [AmountDump]
  FROM HR.Product
) i
 
meaning it has to be relateable in some way to the outer query
oh, good for you :)
 
Actually this table contains 12 millions of records so does this means still database engine will load 12 millions records and from that it will select top 10?
 
@Learning-Overthinker-Confused maybe.. you'd have to check the execution plan to know for sure
probably not though
If you ordered the inner query, it would have to load all 12 million though
because top 10 of an ordered query means the records with the largest/smallest whatever
 
I think this outer query inujection wont work in case of CTE query
 
8:23 AM
You should implement a timeout if you wanted to ensure the database wasn't bogged down doing queries by the user
 
@Neil I tried it with hard settings with my friend. Retried 4-5 times, but the resources were so scarce, that we didn't get to the hard part neither.
 
Hence i have to fallback to bringing whole result set in memory and then selecting top 10 records form it
 
@ntohl afaik, you can get lazy bastard achievement in peaceful mode
 
@Neil yeah. But where is the challenge in that :D
 
@Learning-Overthinker-Confused well the database maybe is doing this, but not your program
your program just gets the 10 records
@ntohl I can't even imagine doing that in hard mode
You'd have to pick up and move often to get the resources you need
 
8:26 AM
Morning.
 
@Neil You can't get to find any new resources... We yoloed 30 times into the wilderness, without finding a single trace of iron
 
@ntohl well that's not even possible
 
btw You can hoard some ammo by constantly dying. Your mate picks up the remainding ammo
 
you can't win without iron
 
we kinda give up. It was late, and never tried it again next days
 
8:28 AM
surely they can't expect you to charge into alien bases with a pistol and 10 clips before you can even start to mine your first iron ore
 
at the start position there is always basic resources
just from there, You must expand. And You can't, because You can't find the next ore anywhere
 
is there enough to make some gun turrets and sufficient ammo?
because maybe you just need to push farther away
like uranium always tends to spawn farther away from the starting point
 
I run like hell with 21 bases of aliens in my back, 200 miles away, but never found a trace of iron. 30 times
 
any people here running VS with R#?
 
if I find something, than I would start to take into consideration what to do to clear the way
@Wietlol me
 
8:37 AM
if I paste a piece of text into my code into a string literal, the text isnt auto-escaped
i wondered if R# does the escaping automatically
 
@ntohl no way you can win without enough iron
 
@Neil yeah.
 
I wonder if anyone has done a calculation involving least amount of iron, copper, coal required to send a rocket into space (considering research and all)
 
@Wietlol what You said is contradiction. Isn't auto-escaped and done automatically?
@Neil scarce resources, high alien activity, low resources is enough to be impossible. lazy bastard is just icing on the cake
 
@ntohl I dont have R#
if R# does the escaping, that explains why it doesnt work for me
 
8:42 AM
but You have Rider
 
I do
 
I suspect rider have most of R# features inside it
 
it would mean that Rider doesnt use R# itself
 
R# doesn't do escaping neither
 
> Add a feature of autoescaping (like in ReSharper) when paste some text inside different string literals
I suspected R# did something similar then
 
8:43 AM
I mean i had a string "aaa" and I pasted "aa" inside it. And it got "aa"aa"a"
 
it should have been "aa\"aa\"a"
or @"aa""aa""a"
 
ain't happening
 
@ntohl lazy bastard just slows you down a bit
really just amounts to having to drop an assembly machine down whenever you need something you don't have
at least until you can get to the point where robots can construct it for you
 
@ntohl im quite surprised these differences exists between their IDE's
I know C# and Java have different string literals, but they should have similar functionality
 
@Wietlol ohh
I forgot I'm in F# code
 
8:55 AM
IntelliJ does have this feature
it pains me when I paste regular expressions
and verbatim doesnt solve everything
 
I have it
in C# code
only Rider have some F# code support
 
my colleague also has it, I must have been stupid enough to disable it somewhere
 
R# don't
 
"aa""aa""a" teacher, leave them kids alone
 
my teacher would probably mess that up
 
9:01 AM
s/"aa""aa""a"/hey/
 
all in all it's just a.. another brick in the firewall
 
did you see that already?
that is my teacher right there
 
@Wietlol Oh dear :(
 
this is not the first time he is an idiot
 
well you know what they say.. if you can't do, teach
why would you check inside Car if it is Buyable or Rentable?
when would that ever be false?
 
9:08 AM
this was the week before that
(whoops, editted it)
 
Are the examples incorrect?
 
@Default yes, they are horrible
 
i don't know java though - enlighten me please :)
 
and the worst part is that some of the students have never programmed before, they would gladly believe the teacher
 
are they incorrect?
 
9:10 AM
@Default just assume that it is C#, Java and C# are equal in these concepts
they are incorrect yea
 
is it because process would print all 3 outputs?
 
yep
those if statements are never false
 
have you told him?
 
hell yea
 
well, you can use explicit interface implementation in C# to get different results based on if you cast the instance - maybe that was something he was trying to show but failed
 
9:12 AM
explicit interface implementation?
care to give me an example?
 
sure, give me a sec
 
ow yea
but no, he could not have meant that
since its java, which doesnt have it that way
 
why are you attending those classes?
 
i need a piece of paper
unfortunately, you only get the task which rewards you with that specific piece of paper at the end of the study
i simply ignore the teacher and have someone pay attention that also has some experience
he notifies me whenever he doubt something
after the interfaces bullshit, he then tried to explain why Java doesnt support MI (multiple inheritance)
after which, I lost faith in mankind
 
but it seems to be one base class and multiple contracts, similar to C#?
so I guess he's correct on that point
 
9:25 AM
it is correct, Java and C# dont support multiple inheritance
but ONLY because of the inheritance of fields
and also because of the dual invocation of the grandparent methods
Java (since Java 8) and C# (since C# 8 as well) support MI in form of methods
where interfaces can have concrete methods
(non-abstract)
his explanation was removed, evaporated, nullified because Java DOES support what he claimed impossible
soon, Java and C# will have MI though
its just a matter of time
 
I doubt it
 
if (b instanceof A) // is false
System.out.println("a is B");
What is this crap!?
 
check link again
I messed up first time, then i editted
i edit for no reason you know
 
Ah
I guess I could see that as an example
But the Car thing was horrid
 
Perfect example for temporary fixes being permanent:

// Function can be deleted, when Centura bug is fixed:
bool IsEqual (DateTime left, DateTime right)
{
  // checks if second, minute, hour, month and year of left equals the one from right
}
 
9:37 AM
the instanceof was just a messup of the order of the parameters
the car was just idiotic
 
Literally "temporary" fucntion from 20 years ago
 
similar to comments called "This should never happen"
then why is there code handling it?
 
if (userProvidedWrongInput) {
    // this should never happen
}
that's why
 
If I have catches that // should never happen, I send an error message to the user "Tell squirrelkiller he fucked up please"
 
incorrect input is definitely a thing that will happen
 
9:41 AM
if something should never happen, the programmers just use a stupid language or have made a stupid assumption
 
I literally have "Tell Marlon he fucked up" somewhere in my code.
 
haha
 
@Squirrelkiller if I were doing that, the entire place would be filled with comments
not really useful ones actually
 
@Squirrelkiller I guess that's a // TODO?
 
@Squirrelkiller Point and shame, good old technique to force code plebs outside your magnificent kingdom of code.
 
9:43 AM
@Squirrelkiller Which is why all my temporary solutions doesn't use the word "temporary" in the comments :)
 
@Default Nope, that's an actual messagebox somewhere that can never happen
 
clever!
 
Therefore people will never know I fucked up :D
It's in some method I'm calling from my own other method where I already parse input and construct the parameters
 
Something I have a hard time understanding is how true it is when you choose a language over the rest in terms of performance.
 
@HéctorÁlvarez because performance is an umbrella term for a very complicated topic
 
9:51 AM
depends on your usage of your language
and your definition of performance
 
So measuring performance isn't just a number score
 
performance isnt even equal to performance
 
that means a language might be better in some respects and worse in others, making it both more performant and less performant than other languages
 
@Wietlol What?
 
"performance" == "performance"
 
9:54 AM
!!> "performance" == "performance"
even cap has trouble doing it
@HéctorÁlvarez what falls under "performance"?
like efficiency?
 
Yeah well I take some languages are better at floating point operations while others are better at big numbers, but I've researched a bit, and half the time the differences are pretty small.
 
yes and no
It gets translated into machine code, all of it
 
take for example, runtime efficiency
 
@Wietlol I think performance refers to the time it takes to get from start to end, for whatever task you require it.
 
or maintenance efficiency
 
9:56 AM
if the machine code is the same between code written in two different languages, it is technically not more or less performant
 
or development efficiency
 
some languages have considerations which are more costly than other languages, like garbage collection and leaning on a more efficient C-based library
 
one programming language may be much more performant for runtime (like C++ over C#)
but since I can write C#, but am not so good with C++, it is much more efficient to use C#
 
the C-based library is only more efficient because it's written with very close detail to performance
otherwise it could be written equally bad as any other language
but traditionally you'd only program in C for the level of attention you can dedicate towards optimization at a low level
therefore things programmed in C are generally faster
 
Exactly, that's where I wanted to get. At what point do you start considering development effort over application performance? In other words, how do you consider if the complexity of learning the optimizations for a particular instruction set is worth it over doing it with simpler approach that yields worse results in the end?
 
9:59 AM
but it's not a forgone conclusion either
 
Not talking about some performance-specific scenario here, just as a general rule of thumb.
Some examples are like "It went down from 40 minutes to 5 seconds!" and it obviously was worth it, but when it's down to something like:
- Await user input
- 5-second operation
- Await user input
- 3-second operation
- Await user input
Would it really be worth improving it by, like, 1 second on each operation?
 
@HéctorÁlvarez It's subjective
The person who decides whether it's worthwhile to optimize further is ultimately the one paying for the program
and the one who decides whether it would be an expensive optimization or not is you, the programmer
 
That's true.
 
10:18 AM
Though a general rule of thumb I've heard used is, 100ms or less, and users won't even notice a delay
under a second, and users won't be bothered by the delay
under 10 seconds, users won't switch to another task while waiting
in other words, aim as low as possible, but specifically under the 100ms, 1 second, 10 seconds "thresholds"
 
That's a nice rule.
 
I have similar thresholds but mine are about half because people here are incredibly impatient
 
10:45 AM
Hi Guys, I'm trying to port a .Net framework app to Core. It's mostly some plugins that get loaded at runtime based on the entries in the config.
Each plugin can have multiple implementation (let's say the first coming from Azure and another coming from AWS)
So what I noticed is that if the DLL and the dependencies (Azure.SDK.dll for example) are in the same path, both are loaded in .net framework
 
11:07 AM
But in core only the base dll loads, the dependency throws AssemblyNotFound exception
 
If it worked in FX, why are you porting it to core
Porting FullFX to core is a terrible idea unless you explicitly need features of core
 
11:33 AM
wow, did we really just now discover a new type of DNA?
really? didn't we have like a splicer or something? How is this possible without even knowing about the existence of a second DNA all this time?
 
@Neil The article says 1993. That's hardly breaking news.
 
it also says it was dismissed in 1993 as not natural
so still kind of breaking news
 
Ah yes, iflscience, a reliable source of news
 
@Butler1233 touchè
 
@Butler1233 there are more news sites reporting this
 
11:42 AM
I just figured that that would have been known by now
 
https://www.nature.com/articles/s41557-018-0046-3
it was received (whatever that means) 29 june last year
 
It'd be like finding out all CPUs really accepted the same machine code all this time, and we were just unaware of it
 
Can someone provide a layman explanation about dependency injection, or IoC as a broader concept? I think I'm missing the main point here... I know it was designed for code reusability and lets low-level components decide the dependencies that higher-level ones should use.
I understand it's forbidden to use my own instances whether they are static or new if I use dependency injection.
That's where I get lost, how does it help me decouple my model at all?
E.g. I have this:
private Foo foo => new Foo();
On the other hand I have this:
[Dependency]
private Foo foo => new Foo();
 
My understanding, in an easy example for mvvm:

without IoC:

public MyWindow()
{
  this.DataContext = new MyViewmodel();
}

With IoC:

public MyWindow(INotifyPropertyChanged context)
{
  this.DataCOntext = context;
}
 
it's easier to test if you can inject dependencies
 
11:55 AM
I can use my view with any viewmodel
 
public void Foo(){
    var service = new Service();
    service.MethodCall();
}
how would you assert that MethodCall has been called?
 
...I called it myself, so I know it was called?
 
in a unit test*
 
By checking whatever MethodCall() should do. Although yeah, here I'd probably just inject service to have Foo call my mock service
 
@HéctorÁlvarez not sure where you're lost tbh
 
11:59 AM
@Default I think this is a huge problem for me, I've never used unit tests beyond codewars examples.
I basically don't know how unit tests work, I've never been asked to use them.
But it looks interesting, I might do a little dummy test for stuff.
 
@Hector easy unit testing: Make a pure method, stage input and output and check whether the output from your input mathces the desired output
 
@Squirrelkiller I have a few of those, like Assert(4, Add(2+2)) and int Add(int x, int y) => return x+y;
But never really tried anything more complex than ints or strings.
 
usually you'd go with a triple-A pattern:

// Arrange
// init vars and stuff here

// Act
// execute method here

// Assert
// check output and actual output here
 
Let me build an MCVE, I don't know if I follow you.
damn, meeting.
I'll come back with something.
 
@HéctorÁlvarez You'll get the hang of it quickly
Just write the unit test that has to pass for your implementation to work, and then write the code
It seems backwards at first, but it is useful to helping you organize inputs/outputs
 
12:09 PM
@HéctorÁlvarez Here's an example test for testing the RankUp() method, which should elevate the players rank by one:

// Arrange

var oldRank = Rank.Legend;
Player sut = new Player("Name", oldRank)
var newRank = Rank.Ancient;

// Act
sut.RankUp();

// Assert
Assert.AreEqual(sut.Rank, newRank);
sut = system under test
(There should probably also be a unit test that tests the constructor&Properties)
 
12:26 PM
is it better to show valid password message based on conditions or showing one full message on a single error?
 
@Breathing For example?
 
what you were saying yesterday
 
Usually on a valid password the screen changes to wherever the user wants to go
 
I don't remember what I had for breakfast this morning, much less what we talked about yesterday
 
based on if else conditions that user is doing wrong rathern than one complete message
 
12:29 PM
What?
 
What?
 
If you're making user pick out a new password, best to be explicit and write out everything "Must have upper case, must have digit, etc."
 
The user always gets a complete message, and that is "Your credentials aren't valid, please try again" or something like that.
 
Otherwise, just write "Username or password incorrect."
don't even reveal if the username was correct and password was wrong
 
Login: incorrect / incorrect
> Login Successful. Welcome, incorrect!
 
12:30 PM
@Neil The entered password is incorrect, it already belongs to the user "Wietlol", please provide a different password.
2
 
@Wietlol "The entered password was what you used last month. Please enter this month's password"
 
Different passwords for each month? What is this, an Enigma machine?
 
"How aobut just change the number at the end by +1?"
 
hunter2+1
hunter2+1+1
 
All I see is *******+1
 
12:32 PM
hunter2+1+1+1
I can have this
@Squirrelkiller ofc it is
it is my password
if your password is inside the text you have written, it is replaced by stars
you can safely enter your password here in plain text
give it a try
 
It's funny the amount of password restrictions some websites have, then just go 'fuck it' and hash it in like, md5 with no salt
 
you mean store as plain text?
 
That too
Nothing like emailing the client their passwords :x
 
My colleague made a "Lost my password" recovery system where you'd put in the e-mail address and it'd reset your password and send you a new one via mail
 
In fact I'm pretty sure some major Microsoft service actually told you if you missed your password off by one character or not
 
12:36 PM
"Password reset"
"We send you a mail!"
"You reset oyur passwor. Your new password is FHueioFHneUI"
 
Which was sort of funny considering you could do this without being authenticated
So you could just reset anyone's password
 
Hello. In my MVC app, I'm writing a display template for a custom type, User. I created a razor file, Views/User/DisplayTemplates/User.cshtml, which right now contains just @model Support.Models.User and <label>@Model.Name</label>. I'm trying to render this template inside my Widget Index page, using @Html.DisplayFor(model => item.Owner). The page loads, but instead of displaying user name, it displays every attribute of the user object.
 
See that's why we need biometric passwords... "Please insert pee-sample into disc slot"
 
I'm guessing the framework doesn't recognize User.cshtml as a valid Display Template for the User class. Is there anything else I need to do to register it? Do I need a controller? I don't have a controller.
exceptionnotfound.net/… says "the name of the view (by default) should be the name of the object you want to use it as the template for." So I wasn't entirely sure what to name the razor file. Do I need to name it Owner.cshtml, because the widget's user property is named Owner? I thought that couldn't possibly be right, because then I'd need a new template for every user object that had a different name.
 
@AlphaDelta Please pee into the usb port
 
12:44 PM
@AlphaDelta I was registered on an IT companies CV database and had forgotten my password. They sent it in plain text in an email. I emailed them back and said that they should probably update some routines in password storing. Then I stopped using that site to search for jobs.
 
Do you reckon forums for psychics have a 'Forgot my password' option?
 
Oh, it works if I move User.cshtml into Views/Shared/DisplayTemplates. I don't know why the tutorial said "you can also put it in Views/ControllerName/DisplayTemplates" when that clearly did not work
 
how so?
 
Maybe it has to be in Shared if I want the template to be usable anywhere other than in the User views.
 
@Squirrelkiller I'm at the example, but why doesn't this work?
class Player
    {
        string _name;
        Rank _rank;

        Player(String name, Rank rank) => (_name, _rank) = (name, rank);
    }
Error on name and rank. System.Valuetuple 2 is not defined or imported...
Oh wait I'm missing a package.
 
00:00 - 13:0013:00 - 00:00

« first day (2747 days earlier)      last day (2217 days later) »