« first day (4049 days earlier)      last day (884 days later) » 
01:00 - 14:0014:00 - 19:00

1:48 AM
@mr5 nope... just make backup and restore test
The I/O bottleneck of HDD is very annoying, which causes the database to become slower and slower.
I tested it on SSD and there were hardly any problem.
HDD: 01:08->02:13->02:46->05:32
SSD: 00:17->00:21->00:17->00:22
WTH
mysql
 
 
4 hours later…
 
1 hour later…
6:47 AM
@Mr.Squirrel.Downy Increase cache enough it should same like SSD
 
posted on November 11, 2021 by Scott Hanselman

.NET 6 is released and it's a LTS release which means it'll be fully and actively supported for the next 3 years. If you've been paused waiting for the right time to upgrade to .NET 6, it's a good time to make the move! The .NET Upgrade Assistant can take Windows Forms, WPF, ASP.NET MVC, Console Apps, and Libraries and help you - interactively - upgrade them to .NET 6. Why bother? Massive

 
mr5
@Mr.Squirrel.Downy you should still find out why it generates 1 million character.
 
7:05 AM
Hi ppl
 
@mr5 --max-allowed-packet=1K fixed it
1 million = 1000^2 = 1,000,000B ~= 1MB
the default max-allowed-packet is 1MB, so mysqldump output the statement size max to 1MB
so --max-allowed-packet=1K limit the statement size to 1KB
 
mr5
7:24 AM
oh I misunderstood the problem. nvm
 
8:10 AM
Where exactly do we apply validations? ViewModels or Models (MVC)?
 
controllers?
 
It's probably a matter of opinion
 
Um... I am trying to use the RegularExpression attribute
[RegularExpression("[a-zA-Z0-9]*@gmail.com")] // must only allow gmail
Although, I am guessing that should be +
 
If you don't need to validate that it's a legal email address, just that it ends with gmail.com, then that would probably work.
 
@LasseV.Karlsen Ah! That's what I was looking for! It will not accept stuff like kesarlingisdumb@gmail.com@gmail.com, will it?
 
8:17 AM
Well, you haven't anchored your expression so I think it would.
 
oh?
Um... what do I do then?
 
Yes, it can find dumb@gmail.com in the middle there
add $ at the end to anchor the expression to the end of the string
then anchor the start with ^
so it would be "^...@gmail.com$"
 
you mean, something like:
 
this means it will match the whole string, and then it wouldn't match that example
 
[RegularExpression("[a-zA-Z0-9]+^@pict.edu$")]?
 
8:18 AM
no, add the ^ all the way at the start
 
RegularExpression("^[a-zA-Z0-9]+@gmail.com$")
 
[Squirrel in Training] GoOoOoOoOoOoOoOoOoOoOoOd Mornin' pleberinos!
 
[RegularExpression("^[a-zA-Z0-9]+@pict.edu$")]?
 
but this will flag valid email address as well, just be aware of this
 
8:19 AM
@LasseV.Karlsen Ah! Great
 
this is a legal email address: lasse.vkarlsen@gmail.com
 
@LasseV.Karlsen like?
 
as is this: lassevk+xyz@gmail.com
 
Um... its kind of like this. The Email will be technically provided by the client and will be of the form <firstname'sfirstletter><middlename'sfirstletter><lastname>@<clientdomain>.<edu>
For example:
 
mr5
how about two steps:
1. Validate if it's an email.
2. Split the string by '@' and check the last element if it's equal to 'gmail.com'
 
8:21 AM
My full name is Uchchay Vinayak Dugal, so my email would be uvdugal@<domainname>.<edu>
@mr5 Hmm... that's another way (and probably a great one), but I want to try out using this Regex attribute thingy
 
mr5
I thought the initial spec was only allow gmail.com, no?
 
@mr5 gmail.com is an example
it won't be gmail.com when the system is deployed. It will be <client's domain>.edu
 
mr5
@kesarlingHe-Him here is the full regular expression. It came from thousand upvotes in SO: github.com/mr5z/PropertyValidator#setup
I just forgot to add the source in my documentation.
 
This one?
oops, too long
 
8:25 AM
Ours is a subset. So I think I'll be able to shorten that a little
@LasseV.Karlsen Um... will you please clarify? do you mean it won't allow lassevk+xyz?
 
mr5
 
+ is not allowed in this: [a-zA-Z0-9]
 
oh! right. But that's frankly how I need it to be. In fact, it should not even allow numbers
 
just use the regular expression "@gmail.com$", ignore whatever else (yes, with the right domain)
 
So, you mean just [Regex("^@gmail.com$")] ?
 
mr5
8:28 AM
why are you keep changing on requirements
 
Um.. I am actually going from simple to hard😅
7 mins ago, by kesarling He-Him
My full name is Uchchay Vinayak Dugal, so my email would be uvdugal@<domainname>.<edu>
This is the exact requirement
How does this sound?: [RegularExpression("^[a-z][a-z][a-z]+@<domain>.edu$")]
 
[Captain Obvious] whoa it's been busy this morning
 
horribly wrong?
 
oh dear!
 
> [a-z][a-z][a-z]
 
8:39 AM
[Captain Obvious] ahhhh people are parsing emails but wrong
 
not people, me :D
 
[Captain Obvious] I agree with wiet
 
um... compulsorily 3 character start?
 
[Captain Obvious] (for once)
[Captain Obvious] I mean sure, but you could just do [a-z]{3,}
 
8:41 AM
oh?
 
[Captain Obvious] I think that's the right notation for "3 or more of the preceeding token"
 
I am really bad at regexes
 
{3,} only if it is "at least 3"
 
thanks for that :)
@Wietlol yes, it is
 
[Captain Obvious] I used to be really bad too
[Captain Obvious] Now I'm only sorta bad
 
8:42 AM
lol
 
I saw someone do a leetcode puzzle and wrote an application that could find the longest valid series of parens, like "()()()", "((()))" or "(()())()"
 
[Captain Obvious] I learned by basically going to regexr.com and entering a bunch of test cases (failures and successes) then randomly jabbing at the pattern box at the top until everything workds
 
the code ended up being about 100 lines long
 
[Captain Obvious] Over time you learn good
 
then I solved it with one simple regex
 
8:43 AM
@Wietlol lol
 
[Captain Obvious] Programmers HATE him!
 
unfortunately, almost no engine supports the regex
(?:\((?0)*\))+
 
[Captain Obvious] Why not, that doesn't look too offensive
[Captain Obvious] Unfortunately BrainParser isn't the best regex engine in the world and regularly fucks stuff up
 
mr5
@Wietlol how did you approach your previous dilemma where you need only one value from two nullable variables?
One value, same type, and identifiable but not necessarily the same domain.
 
[Captain Obvious] 415 Unsupported Language 😅
 
mr5
I'm confused
Is it the language that is not supported? The page does not exist? Media not supported? Or resource unavailable?
 
9:18 AM
[Captain Obvious] 415 is unsupported media typew
[Captain Obvious] But the MDN doesn't have an article explaining that in english
[Captain Obvious] *german, but it does in english
[Captain Obvious] So it's actually a 404 kinda but not really
 
Morning
 
@mr5 how did I do what?
@Botler "(?0)" recurses the 0th (entire) pattern
C#, Java (and thus Kotlin) and Javascript all dont support recursive patterns
I would've had to use PHP, so I said "no"
 
mr5
9:53 AM
var thatThing = var1 ?? var2`
thatThing == var1?
thatThing == var2?
thatThing != null
yikes!
so I installed the new w11
it looks like I'm on Android
pre Lollipop
 
In this scenario: on the app, 2 separate questions are displayed one after the other.

Is it best to save the data into the database after each question? or store each question in memory and send it all at once into the `DB` at the end?
 
@mr5 just do var thatThing = var1 ?? var2 ?? throw new NullReferenceException();
 
mr5
@Wietlol but I still have to identify if it's var1 or var2 that has been assigned.
Some UIs they don't even dare to touch
win11 with winXPsh
on the left side, I was playing a YT video on Chrome
on the right, it's Edge.
 
10:14 AM
[Squirrel in Training] el wono kek
 
mr5
Tried switching focus but still ends up like that
yeah. izz the new dotawtf
anyway, win11 is shit. it's deliberately doing the blurr on Chrome so that people would say "hey look, Edge izz not doing the blurr so izz much better?"
 
10:39 AM
use firefox
firefox is best
 
lol
 
[Squirrel in Training] lunch is right you know
 
mr5
oh I'm wrong.
it will always blurr the window on the left
 
weird
why
 
mr5
10:54 AM
when you anchored the window left-right and you want to adjust the size of both window by clicking on the edge of both window on the middle, it will do that blur
 
overall, satisfied or nah with the update?
 
mr5
it's nothing so special. you will feel more like you're in mobile OS
 
> how did you approach your previous dilemma where you need only one value from two nullable variables?
 
mr5
and MS is just copying the steps of Apple
 
I didnt
I dont know what weird program you have, but you should probably refactor dat shit
 
10:57 AM
yeah someone mentioned it's heading towards Apple's route.. maybe it's a good thing.
Because Microsoft store sucks.
 
mr5
If you want to install Android apps on Windows, you have to go through MS Store > Amazon Store
it's shite
@Wietlol it's part of the migration process unfortunately. Some user have an incomplete data. Old apps only have "url" while the new format both have "url" and "code". On the new format, it's much preferred to use the "code" instead of the "url", so I have to get the "url" first for the migration.
 
then you use code ?? url
 
mr5
if (code != null)
   processCode(code)
else if (url != null)
   processUrl(url)
 
unless the code would never be a valid url replacement
@mr5 this sounds right
 
mr5
processCode and processUrl almost do the same thing but it needs to know if it's code or url.
 
11:02 AM
so?
 
mr5
so my problem is how do I make this a little bit elegant in one liner or two liner fashion
if-else-if seems to be I'm missing some condition but there really isn't
code == null && url == null shouldn't really happen
another interesting problem:
I want to seek backwards on a file and find this particular sentinel value. Obviously, I would seek end so it would be efficient, but, how do I seek efficiently backwards?
while (pos > 0)
   if (lseek(--pos).char(pos) == sentinelValue)
       break
lyk dat?
 
`var action = code != null : processCode(code) ? (url != null : processUrl(url) ? null)
action();`

just an idea
 
@mr5 else throw new Exception();
you could use a switch expression for clarity... oh no you cant because C# succ
the one thing they should've copied from Java, but didn't
 
mr5
@EdGzi hmm that could work, but I'm confused on what the action() is supposed to perform?
@Wietlol hmmmmmmmmmmmmmmmmmmmmmm
 
action will do either processCode or processUrl
 
mr5
11:13 AM
_ = (code != null) ? processCode(code) : (url != null) ? processUrl(url) : null
 
but the actual code would be
 
Just trying to do that now..
 
var action = code != null ? () => ProcessCode(code) : (url != null ? () => ProcessUrl(url) : null);
action?.Invoke();
assuming that C# understands this without adding a ton of parens
 
Whatever this means
 
you cant just do ProcessCode(code)
 
mr5
11:15 AM
cuz you can't assign a void type
 
you either need higher order functions, where ProcessCode(code) actually returns the function that processes it, or you need to wrap it in a lambda
but in that case, a switch expression would be much... oh yea, not allowed because C# is stoopid
 
mr5
what does "higher order function" means?
confusion of the highest orda!
 
> Higher order function is a function that takes one or more functions as arguments, or returns a function, or both.
- https://functionalprogrammingcsharp.com/higher-order-functions
 
mr5
in C++, I think it's just called "functor"
enough with these fancy naming
 
in your case, it would be public Action ProcessCode(String code)
in C++, they messed something up then
 
mr5
11:18 AM
func-tor = function pointer
 
a functor is an unflattenable monoid
 
mr5
but should be functer
wtf is monoid?
it's basically a function pointer on low level
then it became "confusion of the higher order function"
 
> The Functor typeclass represents the mathematical functor: a mapping between categories in the context of category theory. In practice a functor represents a type that can be mapped over.
such as a Nullable<T> or IEnumerable<T> or a Task<T>
luckily for C#, consistency is so high, all of the above use a completely different syntax
 
mr5
@Wietlol do I need to know category theory first?
 
do you use IEnumerable?
 
mr5
11:20 AM
no.
I'm using this on a different language though
Kotlin & Swift
 
Sequence<T>, Iterable<T> or Stream<T> then?
they are all functors
 
mr5
no, they are generic class
 
val powers: List<Int> = numbers.map { 2.pow(it) }
 
mr5
stop messing with my toasted brain
 
a List is a "box" where the containing value can be mapped over
(although int is probably the wrong type)
so, List is a functor
but not a function
and () -> Unit is a function, but not a functor
 
mr5
11:23 AM
of course, it doesn't have a parenthesis. duh
 
function and functor are totally different
 
mr5
> In practice a functor represents a type that can be mapped over.
Is it true for all generic class?
 
nope
 
mr5
Why are you talking about Math here btw
izz supposed to be easy
until you brought Math
 
a Comparer<T> cannot be mapped over because it doesnt have state that can be mapped
Comparer<T> is an abstraction of behavior
while Collection<T> is an abstraction of state
 
mr5
11:30 AM
Hmm, so in practical sense, if a generic class only contains a set of behaviors, it's not considered as functor?
 
most developer convo I seen
 
it is generally considered a functor when it has the following method
public Self<R> Map<R>(Func<T, R> mapper)
the problem is, C# doesnt like any common sense, so they just name it whatever
for IEnumerable, it is called Select
for Task, it is called ContinueWith
 
mr5
@Wietlol or "mappable"? Is that it?
 
for Nullable, it is written in the compiler by the syntax t?.map()
 
mr5
what if the class doesn't have any fields? What will it map?
 
11:34 AM
functor is basically an IMappable<T> (if such an interface existed)
if it doesnt have fields, then it maps nothing?
for example, in my utility library, I have IOptional<T>, which is mappable
one implementation is EmptyOptional<T> which is when there is no value
 
mr5
@Wietlol they should improve the definition of functor. I think this is targeted to Mathematicians rather than programmers.
 
it doesnt have a field, but it does have the Map function
 
mr5
watchu think about this format?
seeking starts at EOF & EOL
 
looks like jsonl format
 
mr5
yep
My task is to stream this file
so I thought about streaming it line by line but still wants to use JSON format
 
11:43 AM
so?
do it?
 
mr5
while (pos > 0) {
    line += file.seek(pos--)
    if (json.parse(line, out var obj)) {
        array.push(obj)
        line.clear()
    }
}
 
12:11 PM
what is this heresy?
why not just Path("myfile.jsonl").useLines { list.add(json.parse(it)) }
@mr5 what is this combination of Java, C# and Javascript in one snippet?
is this swift?
 
mr5
idunno what language is dat. kek
 
mr5
1:05 PM
I'm trying to write JSON in C
59
A: What are C++ functors and their uses?

docName "functor" has been traditionaly used in category theory long before C++ appeared on the scene. This has nothing to do with C++ concept of functor. It's better to use name function object instead of what we call "functor" in C++. This is how other programming languages call similar constructs...

 
1:24 PM
what are you even trying to do?
 
mr5
1:53 PM
So I'm not sure why +1 is necessary here.
if I don't add +1, it says buffer is too short.
 
[Captain Obvious] Wait what the fuck is going on here
[Captain Obvious] That looks like c blunt
[Captain Obvious] (because it's not sharp)
 
null character at the end?
 
[Captain Obvious] If it is C then yeah the strings will be null terminated
 
mr5
yeah
I got another sideline
 
01:00 - 14:0014:00 - 19:00

« first day (4049 days earlier)      last day (884 days later) »