« first day (3411 days earlier)      last day (1520 days later) » 

mr5
3:00 PM
why is that?
 
because it is not disposable
you cannot do a using on it
 
mr5
oh
boi
wrong class I'm looking at
 
and HttpRequestHeaders?
 
Headers and Message
 
mr5
yep
wrong class. mi bad
 
3:02 PM
also, @mr5 did you notice that you use the Headers property of your message?
you might be in the wrong class there
 
mr5
yes. I'm actually referring to the Headers
I just looked at the wrong class
this syntax is odd though
I wish they exposed the ctor outside
 
So when referencing a "Hash" table, we are saying give me a row with "this unique hash" or value?
 
The key will be hashed when looking up value
 
@mr5 what do you mean?
 
it means you have an array way bigger than the number of items needed to hold it, most of which is empty
 
mr5
3:05 PM
if you reference a hash table, you're not utilizing the hash logic though?
@Wietlol better make up your mind, what do you mean?
 
> I wish they exposed the ctor outside
 
then you take the key hash, which is usually way bigger than the array itself, and you modulo with the size of the array making it jump to a specific spot in the array
 
0.o?
 
You don't provide hash as key when using HashTable
 
mr5
@Wietlol Warning!
seriously speaking, I need to create that syntax in order to create a new instance of HttpRequestHeaders
 
3:08 PM
why do you need a new instance of RequestHeaders?
http headers are just a multi-value dictionary
or hash table
or hash map
 
mr5
@Wietlol yeah hmm. I think I'm just being whimsical with my decision here
I could just used the HttpClient's default
 
The Community Team on February 17, 2020
In this post, we’d like to talk about some of the initiatives that are happening internally at Stack Overflow aimed at addressing and repairing our relationship with our community.
 
??= is my favorite new operator by far. How are y'all this morning?
 
ew
 
mr5
3:10 PM
@nyconing did you wrote the bot yourself? did you implement all of those features?
 
wait, are there any other new operators?
 
mr5
@JonathonChase it's legit helpful
 
not if you dont use nulls everywhere
 
I just remembered the book The Age of Spiritual Machines -- which gives a look at the future of tech from the perspective of 1999..I must read
 
@mr5 I definitely prefer it to something = something ?? newSomething
 
mr5
3:11 PM
it's useful for when you want a lazy loading too
 
but why would you re-assign a variable?
have we learned nothing?
:)
 
we cannot return an instance of nothing
 
Connecting your soul and enjoying spiritual moment with machines?
 
@Wietlol There are also the new range operators for indices.
 
mr5
AddSomething(value) => { internalList ??= new List<T>(); internalList.Add(value); }
@Wietlol as far as I understand, it's just a syntactic sugar for if (var == null) var = new T();
 
3:13 PM
wait, no, its not that bad
 
mr5
so there's no re-assignment
 
you could also create a new variable and assign it to var ?? new T(), but it's just more local variables
 
mr5
there we go
Wietlang will copy it
 
no
 
It can confuse junior devs
 
3:15 PM
why would wietlang need such a silly feature?
 
Anything can confuse junior devs
 
^
 
Junior devs confuse Junior devs
 
mr5
I wish C# will copy that one from Swift also
the nullable! instead of nullable.Value
and the .EnumValue, instead of EnumName.Value
 
I sure would like a native Maybe<T> implementation but oh well.
 
3:17 PM
Maybe<T> is like a nullable?
 
If you cannot convince your clients, then confuse them
 
while(wool.IsOverEyes()) {
    client.JazzHands();
}
 
@Neil Well, nothing is null in Maybe, it's either Some or None.
 
ok, how is None different from null?
 
@JonathonChase we do have nullable references now
but they are silly and weak
and dont work
and... C# in its entirety embraced null-implicitness
 
mr5
3:19 PM
 
it will take a decade before you have actual null awareness
 
I like how Kotlin does it. Every reference is a non-nullable reference unless otherwise specified
 
mr5
how can I ...
@Neil Swift does it too.
 
@Neil that is the idea of Nullable references in C# as well
but C# is just incapable of making that change now
 
I believe it. It's not a language thing that you can simply toggle with a switch without breaking a bunch of code
 
3:20 PM
a lot of language features have to be re-done
 
mr5
you'll get a compile error if you try not to initialize a non-nullable private fields
 
None is just nice for pattern matching.
 
default parameter values for example only allow null (or other compile time constants)
 
well, compile time constant values
 
class properties are often initialized after the construction
 
3:21 PM
If anything "null" needed to be an instance that can't be instantiated so you could still call Equals on it and whatnot
 
public String Text { get; set; }
new MyClass { Text = "", }
also will be horrific with nullability
 
- Create HttpRequestMessage
- Assign .Headers to a variable
- Dispose
- Return headers
 
getters and setters cannot have different types
 
special handling of anything in a language is usually a negative thing
 
(which other, more modern languages also lack, for example kotlin)
 
mr5
3:22 PM
@DKDhilip I am skeptical about this
It's like a dangling pointer
 
not to mention, since it is optional, if you write a library, your users might not even use it and therefor will not get any information about the nullability of your api
and the compiler or runtime do NOTHING to help you
 
I guess GC will do the job
 
mr5
oh well, I guess I better not to instantiate this HttpRequestHeaders
 
// with nullable reference types
public void DoTheThing(String nonNullString)
{
    if (nonNullString == null)
       throw new ArgumentNullException(nameof(nonNullString));
}
is still required
 
public void DoTheThing(string nonNullString?)
 
3:25 PM
it is non-null
so no question mark
but still nullable in the runtime
 
yeah, you still gotta add the guards, although having things marked as non-nullable can give you some compile time warnings and errors if you're consuming with the option on
which is nice
 
jon skeet made a blog post about it when he tried to change Nodatime to nullable references
if I say it must be non-null, I dont want guards
 
Adding null guards is so 2019.
 
Maybe someday, but for now this is definitely a weird compromise to not break backwards compat and interop
 
Make Guards great again
 
3:27 PM
declaring it as non-null and not adding checks is literally not doing anything different than what it does now
you can't know if it will be null at compile-time, so it's still a npe at runtime
the only backwards compatible way of doing this is by having Optionals
 
mr5
any recommended dark theme for SO chat?
I turned the lights off and now I realize I needed one for chat.SO
 
Best theme: document.body.style.backgroundColor = "black"
 
mr5
followed by $('.messages').css({ backgroundColor: '#aaa' }) and $('.content').css({ backgroundColor: 'gray' })
 
Another advanced theme: document.querySelectorAll("*").forEach(x => x.style.filter = "invert()")
 
mr5
the right panel just disappears
 
3:34 PM
@mr5 lol yeah, I tried it too.. same thing
wasn't expecting that to happen
 
Actually the right panel moved, scroll to top to see that
 
mr5
not bad but a lot of features got broken (including upload)
 
stack hi-contrast mode
 
is it possible to get a value from KeyValuePair?
 
mr5
Okay, this dark mode extension is better
 
3:46 PM
@hazmatsuit kvp.Value
 
mr5
 
what if i need a value corresponding to a specific key?
 
KeyValuePairs are just that.. keys and values
if you have the proper KeyValuePair pertaining to a specific key, then getting its value is always kvp.Value
 
mr5
Okay, I've found a winner
chrome://flags#enable-force-dark
 
Nice effects: document.getElementById("chat").querySelectorAll("*").forEach(x => x.style.filter = "grayscale() drop-shadow(1px 1px 25px rgba(0,0,0,.1))")
 
mr5
3:51 PM
 
why not use dark so chat extension
 
mr5
can't find one
the latest I've found was created 9 years ago
 
chrome or firefox? @mr5
For firefox, i believe @CaptainObvious has one
 
mr5
4:07 PM
@CaptainSquirrel noice but you're minutes late. I've already found the built-in dark mode
 
mr5
I think this one is using an HSLA-based inversion system
 
Watwat
 
@mr5 built-in dark mode?
 
^For a less garbage SO chat experience
 
mr5
4:19 PM
29 mins ago, by mr5
chrome://flags#enable-force-dark
 
Jack, learn dark-chat <>https://chat.stackoverflow.com/transcript/message/48582922#48582922
 
I've learned the command dark-chat
 
I use Stylus because it lets me customize my view
 
Jack, dark-chat
 
4:20 PM
Oh damn he didn't fuck it up
 
the template is handy to do 99% of the job, I fix the nitpicks
 
I know
im amazed
 
Jack, you are alive!
 
....Come Again?
 
that's what she said
 
mr5
4:21 PM
not granny again
 
@mr5 not sure if I like that
 
mr5
look up my screenshots
it's not so bad
works good on images with transparent backgrounds too
 
oh man this dark chat is dutty
 
Jack, oobidigah
 
4:30 PM
is it me or does that Crash Enhanced Trilogy control worse than the original?
he feels more sluggish
 
4:43 PM
Is a try finally recursive method generally better than a while (true)?
 
those are two entirely different things
 
I was gonna say....
 
but an infinite loop in general should not be recursive
 
try-finally is for catching errors, if that's what you wanna do
like...actual errors, not just something that will break a normal loop
 
I guess tomorrow I will continue my quest to center a html span vertically in the parent node
wish me luck, for I have not acquired the necessary equipment to go on such a dangerous and difficult quest
death probably awaits me with nasty, big, pointy teeth
 
4:51 PM
@Freerey incorrect
you can use try finally without catch
 
May the wind be at your back, Wietlol. It's a dangerous path you've undertaken.
@AshKetchum You don't have a garauntee the finally will execute if an exception is thrown in that case.
 
@AshKetchum I'm aware of that..
 
@JonathonChase no
the only guarantee that finally is not executed is because something killed your process
or... your machine
 
Sorry @Freerey I wasn't aware.
So I'll give you some context, how can I better write this method to not fry my CPU?
public async void ListenAsync()
{
    while (true)
    {
        var tcpClient = await _listener.AcceptTcpClientAsync();
        var networkClient = new NetworkClient(tcpClient);

        _clients.Add(networkClient);

        networkClient.StartReceiving();
    }
}
 
try-finally without catch will still run the finally block independent of whether an exception is thrown
 
4:54 PM
^
even if you return
 
@Wietlol > Within a handled exception, the associated finally block is guaranteed to be run. However, if the exception is unhandled, execution of the finally block is dependent on how the exception unwind operation is triggered. That, in turn, is dependent on how your computer is set up. For more information, see Unhandled Exception Processing in the CLR.
 
if you return inside the finally block tho, you need to be flogged
 
I mean't in the try block xD
 
@JonathonChase .net sucks
 
What, you don't like random behavior in your CLR?
 
4:55 PM
the entire point of a finally block is to always run
not running based on random conditions is worse than writing code in javascript or batch/bash
 
Well, it had better have a catch(Exception ex) {} and hope that exception isn't StackOverFlowException or ThreadAbortException
 
@Wietlol how can I improve upon a while true so it doesn't fry my CPU? (code snippet above)
 
StackOverflowException, OutOfMemoryException, etc should still be fine
 
StackOverflowException won't be caught.
 
stack nodes should be freed before entering the catch or finally
same with memory being freed before that
if you can enter the try, you can enter the finally
thread abort is something different tho
 
4:57 PM
void Main()
{
    try {
         Foo();
    }
    catch(Exception ex) {
        Console.WriteLine("Exception Caught");
    }
}

public void Foo() {
    Foo();
}
 
but it is still being caught
 
> Query ended because an uncatchable exception was thrown. (To debug, press Ctrl+U to enable breaking on exceptions.)
 
so, I assume also being part of the finally
 
maybe a Cancellation Token? although I've only seen them be used with Tasks
 
ThreadAbort is just always rethrown if it's thrown by the framework
So you can catch it but it's going to blow up throw then entire callstack
 
4:59 PM
hmm... Java is also weird
finally does at least run tho
catch doesnt tho
 
C# is just weird
anyway, im off
tomorrow im going to do something even more werid... html/css
:(
 
I'm in xamarin weirdness :(
 
Yikers :(
 
5:29 PM
@mshwf Wait what teh fuck
That's so dumb
Jesus christ xamarin is stupidf
Anyway good luck lads, I'm out#
 
bro I saw that in a poetry class
 
7:14 PM
What do I use if I want an object property to only be accessible from that object instance and not other instances of the same class?
 
private / static?
 
Static is only if you're not instantiating it at all.
 
you want private.
 
Neither private
private means "only within this class", so other instances of the same class can still access that field.
I don't think it's possible
This is something the class has to be smart enough to not do.
(And therefore the dev needs to be smart enough)
 
7:32 PM
Good past-midnight
4
A: Elegant way to validate values

SkizzHere's my version, it's a bit cleaner than Jon's version in some respects: interface IValidator <T> { bool Validate (T value); } class IntValidator : IValidator <int> { public bool Validate (int value) { return value > 10 && value < 15; } } class Int2Validator : IValidator<int> { ...

> struct Property<T, P> where P : IValidator<T>, new ()
This bit of syntaxis baffles me. I wonder where I can read about this more.
I know what "struct" is, and I've read a little about interfaces.
But I don't understand this particular line.
 
Hello
var colBasedCollection = ProcessedCells.Where(e=>e.PositionInTable.Item2 == colIndex).ToList();
rowIndex = colBasedCollection.Count > 0 ? colBasedCollection.Max(t => t.PositionInTable.Item1) + 1 : rowIndex;
 
heyo hows everyone doing today
 
how do i write this in one linq statement ?
 
@mr5 A beautiful video. And made by a Russian too. Great.
 
@TomCrosman Going great Tom, how are you ?
 
7:39 PM
not to bad yourself?
 
It's off for me, but i am at office just writing some code and having a coffee ! not bad right ?
 
nice, alright lets take a look at your linq statement
so currently the code you posted works right? and you want to combine it into one line?
 
It works, I want to have Max of a tuple item from tuple<int,int> with a where condition
 
what type is rowIndex
im assuming int?
 
int
yes
 
7:45 PM
did you try the obvious?

rowIndex = colBasedCollection.Count > 0 ? ProcessedCells.Where(e=>e.PositionInTable.Item2 == colIndex).ToList().Max(t => t.PositionInTable.Item1) + 1 : rowIndex;
woops meant
rowIndex = ProcessedCells.Where(e=>e.PositionInTable.Item2 == colIndex).ToList().Count > 0 ? ProcessedCells.Where(e=>e.PositionInTable.Item2 == colIndex).ToList().Max(t => t.PositionInTable.Item1) + 1 : rowIndex;
downside is having to run your query twice
 
hahaa i was wondering..whaaaa
 
@CopperKettle It's generic parameters, with constraints. Same as with a List<T>, just that you can say "this type parameter P has to implement IValidator<T> and has to have a constructor".
 
@TomCrosman Yes this is obvious solution, I was wondering if i could where and max together
@TomCrosman thanks though, appreciate the time !
 
i'll look more into when i have the bandwidth, juggling a few things this second
 
If you're going to ToList after the where, you may was well do it up front once.
 
8:00 PM
Just drop the ToList(), the Count (it wil then be Count()) enumerates everything anyways.
 
Hello guys
I am using ZwOpenKey in c++ so I can open the RUN path from registry as for later on i want my coffee program to run with the windows
But unfortunately, I keep receiving an error in the function Access violation writing location 0x00000000.
Anyone there?
 
Also more performant than "Count>0" is .Any(), as it only enumerates the first item in case of long enumerables
Oh no C++
hides
 
We may not be the best resource for C++ questions @Castiel.
 
Alrighty then, Chase. Thank you.
 
Is there any way to parse a string into an int inside a Linq-to-sql function? While still in lazy-loading?
The idiots who created this database decided to store the year as a string, and I need to do a < compare.
 
8:07 PM
I mean, just put the int.Parse in there I guess?
 
Doesn't work. It throws an error.
 
Yeah
 
Find out what you need to put in for it to convert it to a native sql comparison
I saw a table about equality, turns out '=' turns to value-equality in the generated sql.
Try Convert.ToInt32
 
8:46 PM
So yeah, I just found someone getting his ass beaten by Eric Lippert.
Also my not being able to serialize enums as string got instantly bumped into the next preview release for blazor
 
Moral of the Story - coding is still a science
 
9:01 PM
Of course - it's still R &D
 
@V.7 Leave that alone damnit!
 
V.7
10:11 PM
 

« first day (3411 days earlier)      last day (1520 days later) »