« first day (3462 days earlier)      last day (1486 days later) » 

1:05 PM
8:18.4615
or
8:18:27.692
depending on which notation you prefer
 
yep, got it
 
also, TIL I have problems with m = 240 - m*12
took me 3 times before I could derive a better formula from it
which ofcourse was 240 = m*13
on a side note
yesterday, someone asked me "hey, you are kinda smart, right?"
and I am like "sure"
"ok, then, in a race, when you pass the 2nd in place, what place are you at?"
and I am like "dude, seriously?"
I guess these questions are a bit more on level
 
that does get some people
probably would have gotten me too
 
hi
say I get list of entries of an entity from db
I work on each item and call update on dbcontext
will that original data list automatically change? or do I need to make another call in db?
 
except I know the answer because I've heard that one
 
1:16 PM
I called save after the update
 
@Shad do a test and find out
I honestly don't know
 
ok
 
do what I do and write a junit test which does that
run it, check the results
 
I need to still get comfortable with unit testing
I know it is easy
but I am just lazy to setup as of now. xD
but will do
 
Got the thing solved
The final solution was to paste stuff together with custom column and row separators that could be processed afterwards as JSON
So to say, a small transformation from garbage to readable data, and then submit that
 
1:42 PM
> What 9-digit number has the following features:

It has all 9 digits from 1 to 9

It can be exactly divided by 6 and 7

Each time it is rounded (starting with units, then tens, hundreds, etc) it rounds in an alternate pattern (up, down, up ...), until after rounding 8 times the final number is 500000000

After rounding four times the sum of the digits is 24
 
sorry I am brain dead currently :p
by rounding you mean floor and ciel rounding right?
 
Wait is that supposed to be solvable by logic?
 
must be
 
I can do a program that solves it with a certain degree of swiftness
 
for(int i =1; i <= 999999999; i++)
lol
 
1:47 PM
XD
 
for(int i =100000000; i <= 999999999; i++)
 
that's an improvement, but still no
first of all, we know the number is between 5000... and 5999...
IDK how many zeroes are in there
I guess 8 zeroes
because rounded 8 times
 
nope, it could be 45..
it just has to round up to 500000000
also by that same logic it couldn't be 55 or higher
 
define round up.
 
1:49 PM
0.5 rounds up, 0.4999 rounds down
if at the 8th round, it arrives at 500000000, then it couldn't have started as 55...
 
right so a number with 9 digits, point 1
can't be 55
 
@Neil 42
 
@Wietlol it's the answer to life, the universe, and everything except this problem
 
42 rounds up to 42
that doesn't make any sense
 
dang it
 
1:50 PM
wait
 
let me think about this.. if it first rounds up (one's place), then as I understand it, then the first digit must be 5 or bigger
it also means that the last rounding, assuming it alternates, must be a round down
so it can't be less than 500000000
 
out of the blue, I would guess 546372819 or 564738291
 
haha
 
yes that seems like an easy approach, but the question is now... can those be divided by 6 and 7?
 
but neither are divisible by 6
 
1:52 PM
actually in hindsight, it just says it must alternate, not that it necessarily must start with a round up
so nevermind
 
neither are even, so that is quite easy to rule out
 
Wait you don't know the answer either?
 
I do
just don't want to give misinformation
 
so, it is a number between 4516273849 and 549382716
 
1:54 PM
@Wietlol I can confirm this statement
 
given 6 and 7, the least common multiple would be... 42
oh, is it 42?
 
you mean is the 9 digit answer 42? no
 
ah, dang it
 
but yeah, if it is divisible by 6 and 7, then it is divisible by 42
 
well, only 1/42 numbers in that range satisfy the division constraint
and out of those numbers, it should be rather easy to just filter programmatically for the numbers where the digits alternate between <5 and >5
oh, also filter out where each digit is unique
but I am not sure how to do it with maths
this would be an optimal brute force rather than a logical approach
 
1:57 PM
we're talking about permutations of digits 4 or lower and digits 5 or higher being alternated basically
starting with a 4 or a 5
 
do binary search ;)
 
good point...
not sure how I missed that in my range check
 
for(int i =4516273849 ; i <= 549382716; i++)
 
4516273849 is obviously wrong
as it has 10 digits
 
for(int i =4516273849 + 1 ; i <= 549382716; i++)
 
1:59 PM
if starting with a 4, then alternation wont work
 
oh you threw in a 4 there
 
except if alternation is allowed to be broken on the last rounding
I did full alternation of a closed set from top down and from bottom up
bottom up however doesnt work
the range is 516273849 to 549382716
which is quite a small range
 
no, it must alternate up to the last
 
oh, I missed the 24 check
 
if it's divisible by 42, it's also divisible by 2
so you can also avoid checks where last digit is odd
 
2:08 PM
517294638
518372946
519273846
527194836
536192748
oh wait... that is wrong
I did the 24 check wrong
doing the 24 check correct still gives me the same answers
is there one unambiguous answer?
 
hell, I started trying to find it on a simple program and now I'm struggling between adding an extension method to a struct, and performing a quick hash conversion of the number.
 
@Neil ?
if so, why are 4/5 of the above answers wrong? if not, then are they all correct?
 
wait, they're all divisible by 6 and 7?
 
yep
 
seems right to me
you didn't get the answer I'm looking for though
are these the only ones you found?
 
2:19 PM
those are the only ones in the range starting at 516273849
which retains the rounding alternation
starting at 45 would be...
 
the only answer given is 473816952
which also works
 
no, it doesnt
 
sure it does
how is that wrong?
 
how does the rounding work?
695
all round up
 
first round would be 473816950
second would be 473817000
 
2:22 PM
ah, so it is an iterative rounding
 
third would be 473817000
 
in that case, I should just do the range between 444444445 and 5499999
and update the rounding filter
 
maybe I'm just not understanding the meaning behind the rounding
 
2:37 PM
!~>Math.Round(0.5)
 
!=>0.0
 
that's a problem with my program
are you sure 0.5 rounds up?
 
doing the different rounding alternation check and lowering the range results in 473816952
which is the only result at that point
@HéctorÁlvarez 0.5 rounding is always special
and there are various approaches to it
 
yeah i changed to away from zero
 
Javascript rounts towards evens
 
2:41 PM
but by default it goes to even numbers
ye
 
so, 0.5 -> 0, 1.5 -> 2
 
accounting bullshit I heard...
 
other approaches are away from 0, towards 0, towards positive infinity, towards negative infinity
 
anyway I got a few numbers @Neil, can you tell me if the correct answer is one of these?
 
@HéctorÁlvarez there's bank rounding which alternates between rounding up and rounding down in the case of x.5
which is what C# does I think
 
2:42 PM
iirc, Java and C# use a different approach
 
you can specify several rounding approaches in java
 
ye, but just the Math.round()
 
Just CTRL F the solution
 
@HéctorÁlvarez 450738162
0 is not a digit in 1-9
 
2:43 PM
@HéctorÁlvarez the first one doesn't work with the "after the fourth round, the sum of the digits should equal 24" rule
 
@Wietbot evalcsharp
Console.WriteLine(Math.Round(0.5));
Console.WriteLine(Math.Round(1.5));
Console.WriteLine(Math.Round(-0.5));
Console.WriteLine(Math.Round(-1.5));
 
Result: null
Output:
0
2
0
-2
 
@Wietbot evaljs
console.log(java.lang.Math.round(0.5));
console.log(java.lang.Math.round(1.5));
console.log(java.lang.Math.round(-0.5));
console.log(java.lang.Math.round(-1.5));
dang it
 
-1
null
 
you wot? I forgot logging?
 
2:46 PM
found a bug XD
 
javax.script.ScriptException(ReferenceError: "console" is not defined in <eval> at line number 1)
 
hmm...
I think I forgot logging
in any way, -1.5 is -1
so, yes, it uses a different approach if nothing is specified
it appears it would round to positive infinity then?
at least not away from 0
 
@Neil I know, but was the right answer among those?
I am still working on it.
 
@HéctorÁlvarez nope :P
 
What.
Okay I narrowed down:
Potential Matches:
517284936
518372946
519273846
536192748
Is it one of those?
 
2:56 PM
nope
 
in any case, your condition about rounding up and down all the time doesn't make much sense as-is
 
if you round the one's place of a number like 15, then it rounds up to 20
 
because as soon as you hit the 4, which is preceded by a number higher than 5, it will become 5, and thus not pass the requirements
 
if it were 14, then it rounds down to 10
 
the only option would be to have the 4 as last number
 
2:57 PM
After rounding four times the number 517284936, you get 517280000
 
but then, the 9 will also round down
 
the sum of 5 + 1 + 7 + 2 + 8 isn't 24
anything at the x5 point or higher gets rounded up
if it's lower, it's rounded down, regardless of the less significant digits
 
@Neil Wrong, you get 517290000
and that is 24
 
@HéctorÁlvarez if the number were 51728.4936, how would you round this?
 
I am sure differently from performing 4 consecutive rounds
> fter rounding four times the sum of the digits is 24
 
3:02 PM
Teresa Dietrich on April 08, 2020
Back in February, we shared our Q1 Community Roadmap with you. In that post, we described our four roadmap themes which will continue throughout the year. In our commitment to provide transparency, we will continue to share our roadmaps each quarter. So without further ado, here is our Q2 Community Roadmap:  Understand community This month,…
 
Not "after rounding 4 numbers"
 
well if you're considering previous rounds, you'll have 51728.5000 right?
but then you'd be rounding up and then rounding up again, wouldn't you?
 
517284936
517284940 up
517284900 down
517285000 up
517290000 up (must be down)
 
you'd still be in violation of a rule
 
@Neil That's what I just said, it's impossible to fit that rule
number 4 has to be last
 
3:07 PM
i don't think you should consider consecutive roundings
damn this gets hella confusing
 
iterative rounding is what you need to do
 
you have to tell us the rounding rule
 
aka, rounding the result of the previous rounding
at least... that gives me an unambiguous answer
 
if this was default C# rounding it would be a different result
 
and the answer neil was looking for
 
3:08 PM
nah doesn't make sense...
 
@HéctorÁlvarez I think the question was about math tho
 
Doesn't match the definition
I mean, if you always do zigzag rounding, you are not rounding according to any rules I know about
 
well how about a light problem to end the ambiguous hard problem
 
you dont do zig zag rounding
 
> When asked about his birthday, a man said:

"The day before yesterday I was only 25 and next year I will turn 28."

This is true only one day in a year - when was he born?
 
3:11 PM
zig zag rounding should be the result, not the approach
@Neil how about it was already 2020 on dec 30 2019?
calendars are weird
 
eh?
 
@Neil 29th of Feb?
 
nope, not a leap year thing
 
probably jan 1st
 
daylight saving?
 
3:12 PM
birthday on dec 31
 
anyone born on this date can say this "The day before yesterday I was only x and next year I will turn x + 3"
there you go
 
Wietlol's got it I think
 
well that's appalling, too brief
 
the day before yesterday (2019-12-30), I was 25
 
3:13 PM
I didn't have time to rub my hands.
 
it's the 1st of january. the day before yesterday was the 30th of december and he was 25
 
the day after that (2019-12-31), I turned 26
 
birthday on the 31st of december, so he turns 26
this year (on the 31st) he turns 27 and next year he will turn 28
 
today, it is (2020-1-1), which means this year, I will turn 27
and next year, 28
but Niel, you dont know about the iso calendar?
 
Fun race.
 
3:15 PM
guys is there a way to convert a generic type parameter that is an enum into an int?
 
> The ISO Week Date for 30 December 2019 is: 2020-W01-1
 
class Test<TEnum>
{
    private int _val;
    public Test(TEnum eval)
    {
        _val = (int) eval;
    }
}
 
@user2296177 considering not all enums are ints... no
 
tf
 
I would ensure the backing type is Int
 
3:17 PM
so iso calendar considers the first week the one that includes days of 2020?
that screws up royally the whole 52 weeks a year thing
 
it does not
because the ISO week calendar is based on weeks
I mean... it does mean that there are 52 or 53 weeks per year
but always full weeks
which, in some situations is really useful
 
screw the week calendar
the week calendar is weak amirite?!
 
twitter loves it
also... his newest video has quite a bit more views than his others
clickbait title?
I dont think so
 
I am out for holidays
see you on MondaAaAaAaAay
 
3:52 PM
@Wietlol i am still trying to get that DateTime thing working, having my custom TimeProvider class and thinking of how can I set it from tests so, it would behave like DateTime.Now only with offset: hastebin.com/colicibovi.cs
 
make it an interface instead of a class
make it a method instead of a property
make an implementation which always returns DateTime.Now
make another implementation which you give a datetime via the constructor and store it as a property
 
ISO says the first week of a year is the first one with a thursday in it.
To Microsoft this translates as "The first 4-day-week".
 
ah, democratically
the year with the most votes wins
 
4:07 PM
> "This must be Thursday,' said Arthur to himself, sinking low over his beer. 'I never could get the hang of Thursdays." ― Douglas Adams, The Hitchhiker's Guide to the Galaxy
 
4:22 PM
@Wietlol something along these lines? hastebin.com/faraziqoba.cs
 
@Neil This is wednesday
 
@Hypersapien I was referencing Squirrelkiller's remark
 
 
1 hour later…
5:33 PM
@Wietlol you can do it like this
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static unsafe TTo Reinterpret<TFrom, TTo>(TFrom value) where TFrom: struct
    {
        var reference = __makeref(value);

        var ptr = (IntPtr*)&reference;

        return Marshal.PtrToStructure<TTo>(*ptr);
    }
the generic class example is:

class MyGeneric<TEnum> where TEnum: struct, IConvertible
    {
        TEnum _value;

        public MyGeneric(TEnum value)
        {
            _value = value;
        }

        public void Print()
        {
            Console.WriteLine($"int value of enum: {Cast.Reinterpret<TEnum, int>(_value)}");
        }
    }
normally, even thought you know the generic param TEnum will 100% be an Enum with a backing type that is integral
You cannot do int converted = (int) value;
You'll get: error CS0030: Cannot convert type 'TEnum' to 'int'
If you call the Print() function as shown above, it will in fact print the correct enum integral value for the generic enum class generic parameter.
 
mr5
5:54 PM
Our local celebrities are showing off how bright they are. Concluding a news just by reading the headlines. This are the target audience of this woke journalist.
 
I'm limited to .NET Framework 4.5.2, so I don't know if 4.7.3's new Enum constraint helps at all
 
mr5
are you limited also by C# language version?
if not, then you code already make an enum constraint like this where T : System.Enum
 
Yes, that's what I meant by being limited to 4.5.2, I cannot use T: System.Enum
 
mr5
I thought those two are independent with each other
There's an IL workaround if you're interested: stackoverflow.com/a/8086788/2304737
 
6:12 PM
unit tests exposed a flaw where a normal string can be passed to Authenticate. How best to handle this?
        public void Authenticate(string token)
        {
            IsSecure = (Base64Decode(token) == _options.Value.Secret);
        }

        private static string Base64Decode(string base64EncodedData)
        {
            if (String.IsNullOrEmpty(base64EncodedData))
            {
                return base64EncodedData;
            }

            var base64EncodedBytes = Convert.FromBase64String(base64EncodedData);
blows up here: var base64EncodedBytes = Convert.FromBase64String(base64EncodedData);
 
185
Q: How to check whether a string is Base64 encoded or not

loganathanI want to decode a Base64 encoded string, then store it in my database. If the input is not Base64 encoded, I need to throw an error. How can I check if a string is Base64 encoded?

 
@user2296177 thank you. I suppose this is why I feel TDD causes code bloat. Will take a look.
near the bottom:
It is impossible to check if a string is base64 encoded or not. It is only possible to validate if that string is of a base64 encoded string format, which would mean that it could be a string produced by base64 encoding (to check that, string could be validated against a regexp or a library could be used, many other answers to this question provide good ways to check this, so I won't go into details)."
Would a try / catch be acceptable?
 
6:47 PM
That's up to you.
And the user of your code.
Do you expect clients to be sending non-base64 strings?
 
quick threading question. i have a thread with a concurrent dictionary. producer threads add a thing, wait for a signal on that thing to be set, and then return. the main thread is responsible for setting the signal. my question is: is ManualResetEventSlim the right thing to be using for my completion signal?
 
mr5
> Tom: "So if 2019 was a rough year for you, and you want to leave it behind,"


WatchMojo: "Top Ten Statements That Have Aged Poorly"
quoted from YT's comment
 
mr5
7:25 PM
I was this close to becoming a PS expert. (image created circa 2014)
 
mr5
8:21 PM
7 attempts
Elon's Raptors
 
9:06 PM
Probably bit of a noob question, but if I remove a tabPage from a tabControl, will any of the attached Controls automaticly be removed (collected by the garbage collector) as well? I mean removing like this.tabControl1.TabPages.RemoveAt(i);
 
mr5
I suppose
as long as there's no other references to it
 
No there aren't. I'd also prefer that to happen, just needed to be sure that I wouldn't have to do it manually
 
9:58 PM
@Gintas exactly
now, when testing, you can use the CustomTimeProvider, in which, you can explicitly state which moment it would return
while on the servers, you would use the SystemTimeProvider
each implementation is only responsible for its own behavior
there is one kind of problem tho... which is liskov
but in simple terms, you should make the ITimeProvider's behavior "it gives a datetime", in which case, there is no problem
but yes, DateTime.Now is a special kind of trap
I have seen great programmers literally spending days to understand what they are dealing with (not even writing any code to solve the problems, just understanding what is going on)
and yes, they are not the noob level programmers... possibly higher levels than me... definitely back when they were dealing with the problem
https://stackoverflow.com/questions/2425721/unit-testing-datetime-now
https://medium.com/@tonerdo/unit-testing-datetime-now-in-c-without-using-interfaces-978d372478e8
https://dzone.com/articles/inject-datetimenow-to-aid-unit-tests
https://dvoituron.com/2020/01/22/UnitTest-DateTime/
https://codopia.wordpress.com/2017/04/24/how-to-mock-up-datetime-now-in-unit-tests-using-ambient-context-pattern/
https://www.limilabs.com/blog/testing-datetime-now
https://stackoverflow.com/questions/9878676/tell-dont-ask-principle-and-password-expiration
and there are so many questions and blog posts about this particular situation
and in different usages, different solutions apply
also... perhaps you should use UtcNow
there is no reason to use a local time for your logging service
especially considering DST and such black magic
@user2296177 hence why I said it is impossible
I dont even know what is going on in that code
and I dont even want to know
on top of which, I dont use enums or structs
their designs are very flawed and completely replacable by classes, which work a lot better with a lot more features from C#
 
10:44 PM
 
10:57 PM
Ive just got into bed and had a thought. How fast is /dev/null?
 
run pv /dev/zero > /dev/null and find out
 
According to this guy at least, quite fast
19
A: Can I get a faster output pipe than /dev/null?

Steven SchlanskerI'm able (via dd) to dump 20 gigabytes of data per second down /dev/null. This is not your bottleneck :-p Pretty much the only way to make it faster is to not generate the data in the first place - remove the logging statements entirely. The cost of producing all the log messages likely exceed...

 
@CaptainObvious at least... it is web scale
 
And mongodb runs shit fast when tou write the data to /dev/null
 
mr5
@CaptainObvious why is it special?
 

« first day (3462 days earlier)      last day (1486 days later) »