« first day (3510 days earlier)      last day (1421 days later) » 

4:45 AM
Ben Popper on May 26, 2020
The software industry has become a kinder, more welcoming place. Has it finally left a certain kind of leadership behind?
 
mr5
5:26 AM
hey
so ugh, what happened here
hey @Wietlol how are you?
after reading Angelin's comment that he's not a software developer but an engineer of other discipline: selfEsteem -= 1; // now it's negative!
dota 2 has now "Guild" feature
 
 
1 hour later…
6:41 AM
Good moaning! AOOOOOOOAAAAAAAAAAAAAAAAAAAAAoaoaommmmmh.
 
6:56 AM
Buenos dias
@HéctorÁlvarez Are you ok?
Looking for a new job yet?
 
7:12 AM
@Squirrelkiller I am wonderfully great
yesterday I had to introduce myself to the rest of the training members and noticed I've been around for 8 months
 
Congrazt, you seem to have survived the big COVID wave!
Lol nice, I remember as if it was yesterday :D
 
Like seriously 8 months and I'm very happy
This never happened to me before
It was always "today I had this VB shit, and reports"
 
@mr5 ohai
 
mr5
within 4 hours after Battle Pass (DOTA2 thing) was released, Valve already earned 1 million USD
 
7:38 AM
Yeha but now you're working with some shit called Rhino
Is it really any better than VB
 
8:04 AM
good morning
 
 
2 hours later…
10:10 AM
Hi all,
what developer command prompt is used for other than running CSI?
 
like mono's?
Mono have csc.exe to compile the .cs. Than you can mono.exe <assembly> to run it
 
The one that shipped with Visual studio
 
oh. I misinterpreted the question
 
@CaptainObvious Good point, but this is usually not the case.
It's only the last resort when everything else fails
 
there are a lot of tools imported in it. certmgr for example
 
10:25 AM
Hmmm? Command line tool? CSI? I think this is what you're looking for
BTW if you didn't have time to watch it to the end, the killer's IP address was 192.168.1.33
 
-o
 
the killer is in da house
 
came back to kill more rodents
 
11:30 AM
I'm the only IT guy here today o-o
 
!~tell hans wat
 
;)
 
one of the guys was in close contact with a COVID patient, one is on vacation, and the other has a fever
 
I'm hearing a troubleshooting lecture, 10 minutes to explain how there's a combo to select between simple logging to truncate after 4k characters to save space, or extended (full length) for debugging.
 
11:54 AM
there's some job offer on SO for a dutch place....and all the details are in Dutch, soooo...
 
12:19 PM
Wow.
So there's a switch statement here.
It switches on a bool.
The cases are: true, false, default.
 
Brilliant.
 
@Squirrelkiller I have seen a code, where the default case run
great challange topic
 
@ntohl Not in C# you haven't. You can cheat typescript. You can't cheat C#.
 
it was C#
 
'twasn't a bool then
oh I forgot goto default;
 
12:28 PM
plain bool. Trick was in the setting of the plain old bool, not the type
 
But that's not cheating
 
no goto
7
A: Create bool value which is neither true or false

Marc GravellProbably a true with a value of 43 or similar. The point is: Boolean is a lie - it doesn't exist at the IL level. It is simply an integer with a value that is zero or non-zero. That works fine for the "brtrue" and "brfalse" opcodes for any boolean values (1,-1 or 42) - the problem comes when you ...

the StructLayout solution below that is scary also
 
I assume this is a good moment to nope out
 
Ok but those are explicitely not plain old bools
 
they are bools tho
if you do public void MyPerfectlyFineFunction(Boolean flag) you cannot guarantee that those booleans are sane
similar to how public void MyPerfectlyFineFunction(String? maybe, String definitely) where you cannot guarantee that definitely is actually not null
oh, how much I love C#
 
12:37 PM
Except string is a reference type and bool is not
 
but String? is explicitly nullable
that is the entire point of nullable reference types
 
Also the unsafe hack still results in a bool:
 
to assume that String (without the question mark) is actually not null
 
Nullable reference types aren't a compiler feature though, but an analyzer feature. They're a recommendation at this point.
 
@Squirrelkiller that depends on how that tool deals with > b
 
12:40 PM
Roslyn
It's the C# interactive window
 
maybe it depends on their internal way of processing a bool to a string or how Boolean.ToString() works
public override string ToString()
{
  return !this ? "False" : "True";
}
 
Not a string comparison:
> GetMyWeirdBool() == true
true
 
considering this, it can only result in True or False
 
> Convert.ToByte(true)
1
> Convert.ToByte(false)
0
> Convert.ToByte(GetMyWeirdBool())
1
 
keeping in mind that brtrue and brfalse should not be used to get the weird result
 
12:43 PM
- yes, that's because of how brtrue is defined: msdn.microsoft.com/en-us/library/… - as a side note, this means that tests like if(expr == 0), if(expr != 0), if(i == null) and if(i != null) can all be done simply via brtrue and brfalse - it doesn't need a ldc.i4.0 + beq or ldnull + beq. Testing for zero is cheaper than an equality test.
 
and I assume a switch always does some form of beq?
sounds weird to me
hmm... Wietbot is ded
I cant seem to get it running any more
 
\o/
he was a nutcase
 
getting an exception of unexpected html returned from the login page
 
the third bool value made him ded
 
need to fix that
@Hans1984 why would you say that? what did Wietbot ever do to you?
 
12:50 PM
yesterday I dedded mongodb's profiling table
 
I mean... apart from ignoring you... and shouting at you... and trolling you... and... some other stuff that better remains unspoken of
 
it was "so hard" to do it. Running a select query with text Contains.
trying to fetch the rows from the profiling table than resulted in Error: SyntaxError: invalid regular expression flag s
 
@Wietlol i remembe rthat day when he lost it
and floded the room with some exceptions
we barely got him under control in sandbox
 
they werent exceptions... at first
were there exceptions later on?
 
dont you remember that day ?
it was one of the first days you brought him here
 
12:59 PM
You actually load the login page?
Why not post directly and then read cookies from the response?
 
the day in the sandbox, there were no exceptions
dec 3rd
@Squirrelkiller I do a web request to load the login page, then send the submit request with the appropriate data, similar to how caprica did it
 
4 mins ago, by Squirrelkiller
Why not post directly and then read cookies from the response?
 
I appear to read the fkey from the html
I know this repo is probably not up to date... but still
oh wait, the exception is not of wrong html... it is of a missing cookie
if (cookies.containsKey("uauth").not())
    throw UnexpectedSituationException("?????")
that one
 
...uauth?
I thought it's prov and acct
 
it worked a month ago
it doesnt work now
maybe it changed
 
1:14 PM
ugh it's always freezing in the office during summer
except I forget it's still May
@PatrickStar is back?
 
nope
 
I saw he was here when I was gone last week..wha happun?
 
iDunno
 
I wanna ask if this is the krusty krab
 
1:30 PM
indeed it is
 
 
1 hour later…
2:45 PM
Sara Chipps on May 26, 2020
We received a bunch of requests to share how we use our feedback framework on specific features. We got excited about this, and given that we just released Dark Mode (and “Ultra Dark Mode”), we thought this was a great opportunity to show how we arrived at our solution.
 
Is it time for a meta post asking for dark mode in chat that is gonna be ignored anyway yet?
 
I forgot dark mode was even a thing in chat
 
It's not, that's the reason it may be time for a meta post.
 
3:00 PM
*in stack, I meant
 
Ah I see. I have it always active now.
 
I can still have dark mode with stylish and Stackoverflow dark style.
 
I wish iMac G3s were cheaper on ebay
or that the ones in my favorite color were easier to come by
 
3:38 PM
posted on May 26, 2020 by ericlippert

Code for this episode can be found here. Exciting news for the client; I have added a play/pause button. I suppose I could have added that single line of code earlier, but hey, better now than later. Last time on … Continue reading →

 
3:55 PM
anyone used an apicontroller with a canvas?
Because I'm the only guy in my workplace who uses JS on occasion, I'm only now finding that WebMethod() isn't the best way to go these days
 
 
2 hours later…
5:57 PM
If I have a byte array [100, 0, 0, 0] named byteArray and I want to convert the bytes to a 32 bit unsigned integer, what is the best way to do it? Is it to use Encoding.UTF32.GetString(byteArray); to return the string representation of a 32 bit unsigned integer and then use UInt32.parse() to convert the number string representing a 32 bit integer to a 32 bit unsigned integer?
 
 
1 hour later…
7:16 PM
something like
Int32 num = (arr[0] << 24) | (arr[1] << 16) | (arr[2] << 8) | (arr[3]);
there's no sense in messing around with strings, you just need to join the bytes together
The indices might be backwards, (that is, you might want to start with arr[3] << 24 and count down), but this is what you want
 
7:30 PM
@Grace what is going on here?
 
Basically, you take each byte and shift it over to the proper place in a 32 bit int, then bitwise or them together.
 
@Grace I'm trying to process this.
@Grace what is the << operator?
@Grace and the | operator?
 
x << y means "take the value x and shift it to the right y bits".
x | y means "for each bit in x and y, if either bit is 1, return 1, otherwise return 0"
So, for the first byte, you want that to be in the highest eight bits of your integer, right?
So you shift it over, going from
000000000000000000000000XXXXXXXX
to
XXXXXXXX000000000000000000000000
(the leading zeroes aren't there in the byte, since that's only eight bits wide, but they help make my point)
And then you do this for the other three bytes, shifting them less each time.
So you have something like this:
XXXXXXXX000000000000000000000000
00000000YYYYYYYYY000000000000000
0000000000000000ZZZZZZZZ00000000
000000000000000000000000WWWWWWWW
And then you use the bitwise or to combine them all together into
XXXXXXXXYYYYYYYYZZZZZZZZWWWWWWWW
Which is your 32-bit integer.
 
@Grace Okay thanks. I see, so x and y are binary digits, and x | y returns 1 if either operand is 1, 0 if none of the operands is 1. Kinda like the || (OR) operator, but for bits instead of boolean.
 
Yep! That's why we call | the "bitwise OR" operator.
so x | y will do that for each bit in X and Y and return the result
(There's also &, the bitwise AND, and ^, the bitwise XOR)
 
7:44 PM
@Grace So x << y shifts the whole byte (i.e. 8 binary digits) to the left by y binary digits?
 
Yep!
 
@Grace Thanks, this is very clever. Why are we shifting bytes in the first place?
 
Because you want to interpret some bytes as a 32-bit integer, right?
So you have to shift them into their proper places in that integer.
 
@Grace Yes, all I know is that a 32 bit integer is 4 bytes. I don't know anything about the proper places/order for the bytes.
@Grace Can you explain why we arrange the bytes in this order?
 
So, depending on your processor hardware and where these bits came from, you might put the most significant bit first or the least significant bit first. Most processors these days are "little-endian", which means that the least significant bit is in the leftmost position. I assumed that the first byte in your array should go in the least significant place, but it could just as easily be the other way around.
Hence my note about "The indices might be backwards, (that is, you might want to start with arr[3] << 24 and count down)"
The right way to stitch these bytes together into an int depends on the problem you're trying to solve. I can't help you without more information.
For example, if these bytes represent a stream coming in from over the network, they're probably big endian, and you'd want to stitch them together in reverse order so that they're correct on your little endian processor.
 
8:00 PM
@Grace excellent explanation. But the array I'm using as an example is [100, 0, 0, 0], the largest byte is 100, so didn't you just put the most significant bit in the leftmost position?
 
"most significant" means "the bit with the highest place value".
That is, if you look at the decimal number 612387, the most significant digit is 6, because it represents six hundred thousands.
 
Yes, I'm following.
 
So even if your array was something like [0, 255, 0, 0], you'd stitch the bytes together in the same order.
 
So I'd like to check if I'm being stupid here before making an aspnetcore github issue
 
@Grace I want to get something straight. Are we putting the least significant bit first or the least significant byte first? Which one please?
 
8:06 PM
I got Microsoft.AspNetCore.Components.DataAnnotations.Validation 3.2.0-rc1 in my project.
Blazor is now in production - version 3.2.0.
Except I can't find Microsoft.AspNetCore.Components.DataAnnotations.Validation 3.2.0 anywhere.
Steve Sanderson's CarChecker example on github references Microsoft.AspNetCore.Components.DataAnnotations.Validation 3.2.0 though.
How?!
 
@Grace I'm reading a binary file (list of bytes) and converting specific sequences into specific data types.
 
Like I said, I don't know which one is correct for your situation. The code I gave you assumes that the most significant byte is first.
Alternatively, you can sidestep the whole mess with BitConverter.ToInt32, which will (hopefully) handle all this for you.
 
@Grace Thanks for providing more than one way to do it. I like working at a low level so I will try to use the bitwise operator and << operator.
 
For what it's worth, Int32 num = (arr[3] << 24) | (arr[2] << 16) | (arr[1] << 8) | (arr[0]); does the same thing as BitConverter on my machine.
(if you want my two cents, you should use the named function that does what you want instead of rolling your own- it's easier on whoever has to maintain your code in the future)
 
@Grace Thanks, that helps.
@Grace But to use a ready-made function it's best to understand how it works, isn't it?
 
8:14 PM
It is! You now know a little more about what bitconverter is doing behind the scenes, and that'll serve you well in the future.
 
@Grace can you confirm whether all the Xs are 1s, all the Ys 1s, all the Zs are 1s, and all the Ws are 1s?
 
So the Ws, Xs, Ys, and Zs are "whatever pattern of bits were in that byte"
They could be all zeroes, all ones, a mix of zeroes and ones, it doesn't matter.
 
@Grace You put the most significant byte (i.e. 100 which is more significant than 0 when counting in binary) first right?
@Grace Wouldn't that make it Big Endian?
@Grace Or is Little Endian when the most significant byte is first?
 
Little Endian is LSB first
 
Squirrel is right
 
8:23 PM
Easy to remember: little endian could theoretically take less space to save, since a 1 is only one bit.
Of course practically not at all helpful, but makes it easier to remember
 
I think you're still thinking of "most significant byte" as "the one with the greatest value"
consider the bytes [ 5, 100, 2, 70 ]
The most significant byte will be either 5 (if we're big endian) or 70 (if we're little endian)
 
@Grace Jesus, that was my problem. Thanks, I see it now.
@Grace my processor is most likely little endian and the bytes are from a file stream so they are likely little endian too. So 5 is the first byte and as the least significant byte 5 should be shifted to the leftmost position, yes?
 
You'd think so! Though, programming languages like this are tricky. Even if your hardware is little endian, the bit shift operators work in a big endian way.
(It's really weird, I know, I'm sorry)
Which is why you probably want to do
Int32 num = (arr[3] << 24) | (arr[2] << 16) | (arr[1] << 8) | (arr[0]);
And, in fact, this is what BitConverter.ToInt32 will do for you.
 
@Grace No reason to apologize, you're explanations are worth a million upvotes!
@Grace But then we're shifting the most significant (i.e. rightmost) byte to the leftmost position?
@Grace So Big Endian?
@Squirrelkiller thanks.
 
8:38 PM
Correct. You kinda want to think in big endian.
Because that's the abstraction that C# presents to you.
The endianness discussion comes up more if the thing you're reading is the opposite endianness.
 
@Grace Are you saying that by default C# uses big endian?
@Grace How do you know if what you are reading is the opposite endianness?
 
To quote Wikipedia, "Similarly, programming languages use big-endian digit ordering for numeric literals as well as big-endian language (“left” and “right”) for bit-shift operations, regardless of the endianness of the target architecture. This can lead to confusion when interacting with little-endian numbers."
You have to know something about the data to know its endianness.
For example, the "network byte order" is big endian, so if you're getting raw bytes from a socket, they might be in big endian.
 
@Grace would that mean that the most significant byte is already the left most byte, so there is no need to shift the most significant byte to the left most position?
 
Well, you'd have to tell your computer to swap the bytes around at some point, right?
 
@Grace Sorry, what do you mean?
 
8:51 PM
Because you want to read the big endian value and swap it around so it makes sense to your little endian processor.
Maybe the easier way to think about this is that c# uses "left" and "right" backwards compared to the underlying hardware.
And usually, this doesn't matter.
 
@Grace Oh right, I see. For our array example we do not need to arrange it into little endian because it is not intended for the processor?
@Grace It's only for C Sharp?
 
The fact that it's C# doesn't matter. Any other language that offers bit shift operators (C, C++, Java, etc.) will do the same thing.
In your array example, we're assuming your array is already in little endian order.
 
@Grace Yes, since it is from a file.
 
Someone could have written that file with big endian integers, too, but we might as well assume it's little endian.
It seems more likely to me that [100, 0, 0, 0] represents the number 100 instead of 1677721600, but that really depends on what you're doing.
 
@Grace where did you get 1677721600 from?
 
8:56 PM
1677721600 is what you get if you interpret those four bytes as a big endian integer.
 
"Heidelberg data is stored in a single binary, little endian file..."
There's your answer.
 
@Grace I'm trying to get the third entry u32 version ("0x64")
@Grace Thanks.
 
Which is why both of these give you the right answer:
BitConverter.ToInt32(arr, 0)
Int32 num = (arr[3] << 24) | (arr[2] << 16) | (arr[1] << 8) | (arr[0]);
 
@Grace Yes the answer is 100. Is that what you got on your machine?
 
9:00 PM
Yep!
 
Your like an expert at binary.
 
I wouldn't say that, I've just had a little more experience than most.
 
Fair enough, at least I know you are not cybernetic organism, hehe.
 
Yeah, I'm more like a living computer virus.
 
Oh no, virus has taken a whole different meaning nowadays.
But for some reason I just remembered the movie "The Matrix" when you said that.
@Grace So, to rephrase my previous question, Most programming languages use big endian so a program should interpret bytes as big endian unless the program is feeding those bytes to the processor, or something like that?
 
9:07 PM
Every byte you do anything with goes through the processor.
I would say something like "Most programming languages pretend that everything is big endian."
 
@Grace so why is it that sometimes we swap byte values to little endian for the processor?
 
Imagine you're getting four bytes from the network that you want to interpret as an integer.
And those bytes are [ 5, 100, 2, 70 ]
Because those bytes are in the network byte order (big endian), you have to convert them so that your little endian processor does the right thing with them
So you would do Int32 num = (arr[0] << 24) | (arr[1] << 16) | (arr[2] << 8) | (arr[3]);, putting the most significant byte (5) first.
 
@Grace But putting the most significant byte first just gives big endian, does it not?
 
Yes, but remember that C# is kinda tricking you here.
 
@Grace go on, please.
 
9:20 PM
So, C#, in an effort to make things easier for the programmer, treats integers as big endian, regardless of the underlying hardware. Shifting a number "left" one is the same as multiplying it by two, and shifting it "right" is halving it.
 
@Grace I want to confirm whether the bitwise OR operator (i.e. x | y) compares only the XXXXXXXX and YYYYYYYY and not XXXXXXXX000000000000000000000000 and 00000000YYYYYYYYY000000000000000?
 
The bitwise OR operator works on the entire integer.
But note that the XXXXXXXX and YYYYYYYY don't overlap.
You're effectively computing XXXXXXXX | 00000000
 
You mean XXXXXXXX000000000000000000000000?
 
Which, of course, is XXXXXXXX
Notice that the bytes don't overlap
You're not comparing the bytes at all, really
What do you think you get when you compute:
XXXXXXXX000000000000000000000000 | 00000000YYYYYYYYY000000000000000
 
@Grace Yes, so that's what you mean by the bitwise operator works on the entire integer?
 
9:25 PM
Yeah. It might help to think of the integers as arrays of bits for this.
 
@Grace great I will.
 
think of the bitwise or as something like:
bool[32] result, x, y;
for (int i = 0; i < 32; i++)
{
   result[i] = x[i] || y[i];
}
The bitwise or operator works much faster, of course
 
@Grace you get XXXXXXXXYYYYYYYY0000000000000000?
 
Yep!
 
@Grace awesome!
 
9:29 PM
If you want to learn more about the tricks people do with these bitwise operators, you can look up "bit masking".
 
@Grace sorry I still don't get why you shift the most significant byte to the left most position even though you are trying to convert the bytes to little endian so that your processor does the right thing with them?
@Grace Thanks, I'll have to now.
 
The bytes are already little endian in your case.
When you write this:

Int32 num = (arr[0] << 24) | (arr[1] << 16) | (arr[2] << 8) | (arr[3]);

You're telling the computer "Put the zeroth byte in the most significant place, the first byte in the second most significant place, and so on"
 
@Grace yes, but I mean this example which you said are network bytes.
 
Then you'd do it the other way around.
Wait, other way
Int32 num = (arr[0] << 24) | (arr[1] << 16) | (arr[2] << 8) | (arr[3]); is for big endian, because you put the first byte in the most significiant place.
Int32 num = (arr[3] << 24) | (arr[2] << 16) | (arr[1] << 8) | (arr[0]); is for little endian, because you put the last byte in the most significant place.
I should say "is for reading big endian/little endian data"
BitConverter assumes that the incoming data is the same endianness as your processor.
 
@Grace I guess what I mean is, when reading big endian the most significant byte is already the rightmost byte, so why shift the most significant byte to the most significant place, after all the most significant byte is already in the most significant (i.e. leftmost) place?
@Grace it's really useful to know that BitConverter assumes that the incoming data is little endian.
 
9:44 PM
Because you have four bytes, and you need to tell the computer to take that byte and put it in the most significant place in your integer.
When you start, you have four bytes, WWWWWWWW, XXXXXXXX, YYYYYYYY, and ZZZZZZZZ.
If you want to put WWWWWWWW in the most significant place, you have to turn it into WWWWWWWW000000000000000000000000
(In C, you would probably simply cast your array to an integer if the endiannesses match, because the bit patterns are the same, but I don't think C# lets you do that)
 
@Grace Oh thank you. I was thinking of WWWWWWWW as being the left most byte in WWWWWWWW, XXXXXXXX, YYYYYYYY, and ZZZZZZZZ, forgetting that WWWWWWWW has to be the most significant byte in the array of binary digits WWWWWWWW000000000000000000000000.
 
Yep! There you go.
 
@Grace thanks :)
@Grace what do you do that got you such a deep understanding of the binary system?
I'm curious.
 
I took an assembly language course in college, and also experience.
 
@Grace Aah, I see. Assembly must be just 1s and 0s.
 
9:50 PM
I mean, not really
 
I think that's a conversation for another day, hehe.
 
Assembly programs tend to look like a series of instructions like

MOV r0, r1
ADD r1, r2
and so on.
I remember one assignment was something like "multiply a number by a hundred using only shifts and adds".
 
I keep hearing a lot of people say that a computer science degree is useless for a career in software development. I guess you're the perfect example of why that's not true.
Congrats.
@Grace Can you still solve that problem, even now?
 
I have a lot of opinions on whether school actually prepares you for this sort of thing, but a decent school at least teaches you what to google and gives you some experience with real-worldish problems.
 
@Grace agreed.
 
9:55 PM
But you still have to be a lifelong learner and be willing to seek out information beyond what you learn in class.
 
Yeah, you know what they say. Successful people are always learning!
 
I can! I just solved it again to prove that I can.
> int x = 1234;
> int timesten = (x << 6) + (x << 5) + (x << 2);
> timesten
123400
 
Wow, you can still remember things from college. That's better than most.
 
I had to figure it out from what I knew and do a little algebra, but the principles stuck.
 
I've found a lot of people hit their peek in college, it's always good to delay that till you're much older.
@Grace that means you understood the fundamentals of whatever you were taught.
 
9:59 PM
I did! I can't say the same for a lot of my classmates.
 
@Grace Were you like Richard Feynmann that took longer than his class mates to learn a topic but mastered it to a deep level, or like Von Neumann that just understood things straight away?
I'm guessing Von Neumann?
@Grace oh yeah, what do you call the << operator in C Sharp?
 
Some things were easier to grasp than others, but I suspect I had an easier time understanding than my classmates.
<< and >> are the bit shift operators.
 
@Grace haha, knew it. Von Neumann it is.
@Grace thanks.
 
Happy to help!
 
@Grace it's really late over here in the UK, and I have to be up early tomorrow. Thank you for the chat, it was great!
 
10:05 PM
Rest well!
 
Thanks you too. See ya!
 

« first day (3510 days earlier)      last day (1421 days later) »