« first day (4001 days earlier)      last day (938 days later) » 

7:12 AM
I have asp.net core project where i download product images from a external system, and use the images on the website for the products. Where would be a good place to store these images?
 
Morning all
 
right now i store them in the public folder under ClientApp/public... but is does not seems like the best place?
 
7:24 AM
@Botler not necessarily
I dont have to deal with Java's inconveniences while still enjoying it's primary features
for me, casting null to a Boolean? and comparing it with true will simply result in false
 
7:37 AM
Hello friends!
[Squirrel in Training] GoOoOoOoOoOoOoOoOoOoOoOd Mornin' neglecterinos!
 
botler sleeps as well at night?
 
 
2 hours later…
9:18 AM
[Captain Obvious] Yeah that happens when the stack connection drops
[Captain Obvious] Chat must have gone down briefly, or the bot lost internet connection
 
10:08 AM
[Squirrel in Training] Cant it's in the microsoft claud
[Captain Obvious] Probably stack then
 
10:28 AM
still not fixed?
 
[Captain Obvious] It's not my fault the crappy library gives no indication that its lost connection
 
List<RecordModel> toReTest = new List<RecordModel>();

var records = await ChecksService.GetAllRecordsAsync();
var reTestsRecords = await ChecksService.GetAllReTestsAsync();

var invalidRecords = records.Where(x => x.IsValid == false).ToList();

foreach (var record in invalidRecords)
{
    var matchedRecord = reTestsRecords.Where(x => x.RecordId.Id == record.Id).ToList();
    // If count is 0, this record has not yet been re-tested.
    if (matchedRecord.Count == 0)
    {
        if (!toReTest.Contains(record))
Thought on this code?
 
11:12 AM
looks like code
 
11:30 AM
[Squirrel in Training] would look better in discrod
 
imma back
 
@Squirrel.98 Why .ToList()?
Why even have the variable invalidRecords
foreach(var record in records.Where(r => r.IsValid == false))
 
@Squirrelkiller var invalidRecords does not need .ToList(), in this case I'll remove it and just take the recods.Where... and place it in the foreach.
But countOfValid needs the .ToList()
never used so much Linq - weird at first.
 
11:48 AM
@Squirrel.98 matchedRecord.Where(x => x.IsValid == true).Count()?
Or like
matchedRecord.Count(x => x.IsValid == true)
The Where functionality is basically included in most other LINQ functions.
.Single/First/Any/All(x => x.HasStuff)
 
@Squirrelkiller I meant matchedRecord not countOfValid. Not sure where I messed that up lol
 
Still applies :)
int countOfValid = matchedRecord.Count(x => x.IsValid == true);
Also if you make toReTest a HashSet you don't have to check whether or not it contains the record every time
Also that if/else about matchedRecords.Count feels redundant I just have too much other stuff on my mind right now to figure out why^^
Fine lets see
 
12:05 PM
phahaha
@Squirrelkiller That's a nice approach btw.. didn't know this before.
 
12:21 PM
If there are no matched records, you add your record
If there is one matched record but exactly 1 valid record, you do not add it. Because that record then matches the matched record and you are done anyway?
Let's pretend there is no if/else
You start, without matched records
valid records are zero, because there are no matched records
therefore valid records are not 1
So you add the record
Therefore, you don't need the if/else
I fell like you could do this whole thing in one LINQ expression with like, two functions. But I don't know the actual use case so...good luck.
 
If there are 0 records from `matchedRecord`: This record has not yet been retested. But it's still `Invalid`, therefore it needs to be re-tested.

If there is 1 or more records. This means retests have been done.. but need to know if any of these retests contains a `Valid` record. If it does not, then re-test needs to be done.
 
I found following code on microsoft docs

public struct Point3D
{
public Point3D(double x, double y, double z)
{
_x = x;
_y = y;
_z = z;
}

private double _x;
public double X
{
readonly get => _x;
set => _x = value;
}

private double _y;
public double Y
{
readonly get => _y;
set => _y = value;
}

private double _z;
public double Z
{
readonly get => _z;
set => _z = value;
}

public readonly double Distance => Math.Sqrt(X * X + Y * Y + Z * Z);

public readonly override string ToString() => $"{X}, {Y}, {Z}";
 
@Ravi Please format this code.
 
:53129326
public struct Point3D
{
    public Point3D(double x, double y, double z)
    {
        _x = x;
        _y = y;
        _z = z;
    }

    private double _x;
    public double X
    {
        readonly get => _x;
        set => _x = value;
    }

    private double _y;
    public double Y
    {
        readonly get => _y;
        set => _y = value;
    }

    private double _z;
    public double Z
    {
        readonly get => _z;
        set => _z = value;
    }

    public readonly double Distance => Math.Sqrt(X * X + Y * Y + Z * Z);
 
12:56 PM
@Ravi No idea. Do tell us when you find out.
Because I agree it's weird, to make it readonly you'd just remove the setter.
@Squirrel.98 Well since, with 0 records there are no valid records, the algorithm will still add the record. Have you tried removing the if part and see how it works?
 
1:16 PM
[DAustin] hey your sample ends at if (!toReTest.Contains(record)) on discord, I feel like im missing a chunk of code
[DAustin] looks like a fun one, i loooove linq so im happy to take a stab at it
[DAustin] can you let me know if im missing any code over here? ive already got a couple of minor changes for readability
[DAustin] such as var invalidRecords = records.Where(x => x.IsValid == false).ToList(); can be var invalidRecords = records.Where(x => !x.IsValid).ToList();
 
2
A: What's the benefit of a property with readonly getter?

Konrad RudolphThe readonly get syntax is a new addition to C# 8. It signifies that the getter may not modify instance members. Regular getters may modify the instance: public double X { get { _x = 1; return _x; } } That code is entirely valid; more usefully, a getter could for instance update a cached val...

it basically ensures that it is a pure getter... although I can probably make an impure readonly getter...
 
[DAustin] also int countOfValid = matchedRecord.Where(x => x.IsValid == true).ToList().Count; could be int countOfValid = matchedRecord.Count(x => x.IsValid);
[DAustin] I reeeeeeeally wanna fix up that linq, there's a whole bunch of improvements we can do lol
 
1:34 PM
@Squirrelkiller I'll take a look
 
\[**[Squirrel.98](https://discord.gg/PNMq3pBSUe)**] @DAustin Here is the full code:

`List<RecordModel> toReTest = new List<RecordModel>();

var records = await ChecksService.GetAllRecordsAsync();
var reTestsRecords = await ChecksService.GetAllReTestsAsync();

var invalidRecords = records.Where(x => x.IsValid == false).ToList();

foreach (var record in invalidRecords)
{
var matchedRecord = reTestsRecords.Where(x => x.RecordId.Id == record.Id).ToList();
// If count is 0, this record has not yet been re-tested.
[DAustin] Yeh i hopped across to take a look
[DAustin] ok here's my cleaned up version (not tested obv)
\[**[DAustin](https://discord.gg/PNMq3pBSUe)**] `List<RecordModel> toReTest = new List<RecordModel>();

var records = await ChecksService.GetAllRecordsAsync();
var reTestsRecords = await ChecksService.GetAllReTestsAsync();

foreach (var record in records.Where(x => !x.IsValid))
{
if (!reTestsRecords.Any(x => x.RecordId.Id == record.Id))
{
if (!toReTest.Contains(record))
toReTest.Add(record);
}
else
{
//Why are we checking for exactly 1 record? If 1 or more then .Any() can replace .Count()
if (reTestsRecords.Count(x => x.RecordId.Id == record.Id && x.IsValid) != 1)
 
that's like 3x shorter :D
 
[DAustin] euph formatting is off there
[DAustin] let me try again
[DAustin] ah screw it discord is being fucky
[Squirrel.98] foreach (var record in records.Where(x => !x.IsValid)) that's neat
[DAustin] give that code a try and see if it does the same
[DAustin] yeah if you can avoid extracting subsets out into new lists then I find it's a bit easier to follow
[DAustin] you can always extract the expression into a var/IEnumerable
[Squirrel.98] Yeah - does the same.
[DAustin] so var invalidRecords = records.Where(x => x.IsValid == false).ToList(); could be var invalidRecords = records.Where(x => !x.IsValid); and that reference can be reused instead of the linq query like your original code, but if I find I dont need to refer to the same var again, I'll just put the expression in the foreach loop and move up, saves muddying it up
[DAustin] Sweeeeet
[DAustin] move up = move on lol
[Squirrel.98] Regarding your comment Why are we checking for exactly 1 record? If 1 or more then .Any() can replace .Count()
[DAustin] yeah?
[DAustin] i dont know if its a requirement so i didnt swap it out
[Squirrel.98] I should of done 1 or more.. or any() because if 1 valid record found in retest means the record does not need to be re-tested.
\[**[DAustin](https://discord.gg/PNMq3pBSUe)**] but it basically would be
`if (!reTestsRecords.Any(x => x.RecordId.Id == record.Id && x.IsValid))`
if you were testing for 1 or more in that
[Squirrel.98] If you're interested - this is my schema: stackoverflow.com/questions/69372771/…
[DAustin] will have a look in a minute
[DAustin] yeh swap the != 1 line for the line I wrote above
[DAustin] if (!reTestsRecords.Any(x => x.RecordId.Id == record.Id && x.IsValid))
[Squirrel.98] Correct 🙂
[DAustin] cool
[DAustin] so i didnt actually change much in the way it operates
[DAustin] just removed some of the extra lists
[DAustin] and then cleaned up the linq
[Squirrel.98] It's shorter and easier to read !
[DAustin] so the logic is pretty much identical to what you wrote
[Squirrel.98] So thank you 🙂
[DAustin] no worries, like i said I love this shit lol
[DAustin] its the majority of my day job atm
[DAustin] glad to help 🙂
[Squirrel.98] Linq is really like data - like SQL, but it's more readable and can add if statements 😄
[DAustin] yeah i barely use raw sql anymore for that reason
[DAustin] when i first started to use lambda expressions my brain struggled, but now I find it so much easier to write than SQL
[Squirrel.98] I originally was going to add queries into my service - rather than use Linq and figure out the logic there. But SQL is too messy for my project.
 
1:55 PM
it also makes everything else easier
primarily monads are very interesting to work with
 
[DAustin] sometimes the only way to get something performant is to do it in raw sql though, I have a couple of calls that just pass a raw query over because its too mad for EF and Linq to handle properly
 
the tiny problem with it is that C# is doing all of them wrong
 
[Squirrel.98] What's a monads
 
a monad is basically a wrapper type
it's api mostly consists of functions to apply logic on the underlying values
common examples are IEnumerable<T> Nullable<T> and Task<T>
the first problem is that none of the C# monads share how you interact with them, they all have different syntax for the same functions
 
[DAustin] ill have a read up on monads at some point, sounds like big brain stuff
[Squirrel.98] It definitely does
[Squirrel.98] I'll need to start writing a ToDo list of what to learn
[Squirrel.98] Monad is noted
[DAustin] gonna go grab a coffee, but feel free to throw any more linq queries my way, i find them strangely pleasing to write
[Squirrel.98] Shweet ! 😄
[DAustin] 👍
[Squirrel.98] @Wietlol Where did you learn about these sort of things? Such as; Monad?
 
2:04 PM
interwebz
 
[Squirrel.98] Is that CSGO
 
    public class ClassOne
    {
        public int Property { get; set; }
    }

    public class ClassTwo : ClassOne
    {
        public ClassTwo()
        {
            int variable = this.Property;
        }
    }
I need the ClassOne.Property to be public
So it can be accessed via XAML.
Out of curiosity, is it possible to not allow ClassTwo to touch that property?
 
3:16 PM
 
3:27 PM
[DAustin] I think if you make it sealed that stops classes that derive from it being able to access it
 
you'd make it private
sealed will stop the deriving class from overriding it
if you need public, you have a broken system to start with
also, if you need inheritance, you have a broken system to start with
inheritance should be very rarely used as it is a type of composition that only works once and will drag a lot of side effects with it
it is probably a lot better to compose using other means of composition
 
3:58 PM
[DAustin] I used inheritance pretty effectively in a Builder pattern project
[DAustin] but that was a bit of an exception rather than the norm
 
 
2 hours later…
5:49 PM
[Hypersapien] I have a WPF project with a Setup project for it. I have the Setup project including an extra .exe to run during installation. That part is working, but I need the Setup to send a command line parameter to that .exe when it's called. It looks like there's a couple places in the properties where they could be added (Arguments and CustomActionData), but neither of them work. I currently have it being called in Custom Actions -> Install.
 
6:36 PM
[Hypersapien] This is really weird. I have a self-extracting installer (winzip 2.2). When I call it from the command line with /auto it automatically runs the installer without any user input. But when I incorporate it into the installer of another program and give it the same parameter, it gives a very user friendly prompt rather than the generic Setup/Cancel/About prompt.
 

« first day (4001 days earlier)      last day (938 days later) »