« first day (3751 days earlier)      last day (1180 days later) » 

mr5
2:53 AM
146 dependencies in a single ctor mmmmmmmm
 
3:35 AM
morning fellas!
!~Shiba
 
posted on January 22, 2021 by Scott Hanselman

Tailscale is a zero config mesh "VPN" that runs atop other networks and effectively "flattens" networks and allows users/services to more easily (and securely) communicate with each other. For example, I've written extensively on how to SSH into WSL2 on Windows 10 from another machine and you'll note that there is not only a ton of steps but there's more than one way to do it! I have talked

 
 
2 hours later…
 
1 hour later…
7:09 AM
[mr5] !shiba
[mr5] !shiba
[mr5] wut
[mr5] it didn't trigger the first time
 
8:00 AM
[Squirrel in Training] GoOoOoOoOoOoOoOoOoOoOoOd Mornin' pleberinos!
 
@mr5 you mean parameters?
"dependencies" is quite a broad term
 
 
1 hour later…
9:09 AM
!~youtube eeeaaaooo
 
mr5
@Wietlol yes
 
 
1 hour later…
10:26 AM
\[**[flixius](https://discord.gg/PNMq3pBSUe)**] I'm reading "what's new in C#9" in the MS Docu

Quote:
*One of the most common uses is a new syntax for a null check:*
**if (e is not null)**
[flixius] what's the difference to if(e != null)? Just for a better readability?
 
mr5
mm interesting.
public data class Person(string FirstName, string LastName);
@Wietlol they copied Kotlin
 
10:44 AM
If I have a Console Application project, is it possible to set a property on Program.cs and access it from other classes?
 
[flixius] yes, you can use a constructor or a parameter in a public method in your other class
 
@mr5 90% copied from F#
 
Wait are we all on discord now?
 
[mattthr] That's not going to work in this instance.
[mattthr] But thanks
 
mr5
11:06 AM
@ntohl source?
 
@mr5 why wouldnt they? :p
the question is... how well did they do it?
meh, it is trash
why do they keep holding on to this silly property based initialization?
 
Records> https://fsharpforfunandprofit.com/posts/records/ from 2012
With-expressions> same
Value-based equality> records implement comparable, iequitable by default, and they are immutable
Positional records> https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/records#records-and-members
Value-based equality and inheritance> why wouldn't it work?
Top-level programs> .fsx are scripts. Like in a script language.
Improved pattern matching> F# have it
ActivePatterns also lets you define what considered matching
> let (|Even|Odd|) input = if input % 2 = 0 then Even else Odd
You can use the active pattern in a pattern matching expression, as in the following example.

F#

Copy
let TestNumber input =
match input with
| Even -> printfn "%d is even" input
| Odd -> printfn "%d is odd" input
 
mr5
Is it weird to send email format in text message?
@ntohl oh then Kotlin is a copy cat.
 
> let (|Even|Odd|) input = if input % 2 = 0 then Even else Odd
is that a function?
 
an active pattern
 
11:37 AM
so it is special?
 
from now on if something matches Even, than you know running that thing through that code returns Even
yeah. Kinda
usual syntax in the place of "(|...|)" there would be the function name
 
I dont see why you would do it though
 
nothing exists outside your comfort zone
like do-notation...
 
I still am clueless
 
mr5
do-notation is like body declaration?
!friday
 
11:47 AM
query syntax is a do-notation also
 
[mr5] !friday
 
mr5
It's not forwarded properly :(
@Wietlol because C# is full of MVVM and MVVM depends a lot on properties.
 
Jack. funfriday
F for jack
 
12:05 PM
let err = 1.e-10

let isNearlyIntegral (x:float) = abs (x - round(x)) < err

let (|Square|_|) (x : int) =
  if isNearlyIntegral (sqrt (float x)) then Some(x)
  else None

let (|Cube|_|) (x : int) =
  if isNearlyIntegral ((float x) ** ( 1.0 / 3.0)) then Some(x)
  else None

let findSquareCubes x =
   match x with
       | Cube x & Square _ -> printfn "%d is a cube and a square" x
       | Cube x -> printfn "%d is a cube" x
       | _ -> ()


[ 1 .. 1000 ] |> List.iter (fun elem -> findSquareCubes elem)
@Wietlol possibilities are limitless
let parseDate str =
   match str with
     | ParseRegex "(\d{1,2})/(\d{1,2})/(\d{1,2})$" [Integer m; Integer d; Integer y]
          -> new System.DateTime(y + 2000, m, d)
     | ParseRegex "(\d{1,2})/(\d{1,2})/(\d{3,4})" [Integer m; Integer d; Integer y]
          -> new System.DateTime(y, m, d)
     | ParseRegex "(\d{1,4})-(\d{1,2})-(\d{1,2})" [Integer y; Integer m; Integer d]
          -> new System.DateTime(y, m, d)
     | _ -> new System.DateTime()
 
Can someone who is competent in JavaScript please help me trouble shoot this issue. I am trying to use JavaScript to toggle a button from the label "Connect" to "Forget" when clicked, and then toggle the button back to "Connect" when clicked again. This code does not toggle the button like I expect it to. The code is in a view template file in an ASP.NET Core MVC app:
<script>
    const $ = document.querySelector.bind(document);

        $(".buttonOne").addEventListener("click", (e) => {
            let clicked = false;
            if (clicked)
            {
                e.target.innerText = "Forget";
            } else {
                e.target.innerText = "Connect";

            }

            clicked = !clicked;
        });

        $(".buttonTwo").addEventListener("click", (e) =>
        {
            let clicked = false;
            if (clicked)
            {
 
mr5
@BlackPanther I am no JS competent but I think you should store the clicked variable in a scope where it don't get reset.
 
yeah. Every click defaults it to false.
 
mr5
Learned new DOM trick.
I don't need jQuery anymore.
const $ = document.querySelector.bind(document);
This line embodies the entire jQuery huh
 
12:31 PM
@mr5 Yes that binds the function to an identifier so that you can call the function document.querySelector(...) using the identifier $.
 
[Squirrel in Training] web feels deirty..
 
mr5
I thought '.' (dot) and '#' (hash) is specific to jQuery itself.
 
someone brought their labradoodle to work <3
 
@mr5 still doesnt need property based initialization
constructors work perfectly fine
 
12:46 PM
[Squirrel in Training] sounds unhyginic
 
@mr5 I wish I could answer your question, but I have very little experience with JavaScript.
 
instead, we have this weird thing where we just make objects, assume we fill all the required properties and then assume that the object is perfectly fine to be used in every situation
@ntohl what makes it different from having public bool IsCube(float x) {...} ?
 
mr5
@Hozuki yeah, I only use jQuery for easy querying of DOMs, other than that, it's all pure JS.
 
@BlackPanther Could it be because you are setting clicked to false before trying anything? It'll always be false. Also, take it to a higher scope.
 
12:53 PM
I dont use jquery at all :D
@mr5 get on my level :p
 
mr5
if you know this line before:
37 mins ago, by mr5
const $ = document.querySelector.bind(document);
Then, you don't need jQuery of course.
But jQuery is still has some nice features though
 
apart from identifying it is javascript, I have no clue what happens there
"bind" has always been this weird function that should solve all your problems, but I still am clueless how it works
iirc, it has something to do with this so I dont even want to know
 
mr5
yeah, that's it.
 
@ntohl no clue how the regex example works though
 
1:10 PM
In JS `this` is the object that the method was invoked on. So:

var handler = myObject.myMethod;
handler();

Passes undefined as `this`, because handler was not invoked on an object.
If you'd do myObject.myMethod() then this is myObject. Again, it's the invoker object.
Bind just overrules the part that gets the object from the invoker with the one you 'bind' to it.
So:


var handler = myObject.myMethod.bind(myObject);
handler();

Now `this` inside `myMethod` is `myObject`.
Really easy once you understand that's the invocation that matters.
 
and if you dont do bind?
var handler = myObject.myMethod;
how would you invoke that?
myObject.handler() ?
 
You can just call handler() but then inside myMethod this will be undefined, because the invoker didn't operate on an object.
 
so it is absolutely useless?
 
If you don't need this inside myMethod, it's fine to call it like that.
Otherwise, bind it.
 
hmm...
 
mr5
1:15 PM
f********
why is NodeJS so popular
 
class MyClass {
  myMethod() {
    console.log(this);
  }
}

var obj = new MyClass();
obj.myMethod(); // -> prints obj
var handler = obj.myMethod;
handler(); // -> prints undefined
var boundHandler = obj.myMethod.bind(obj);
boundHandler(); // -> prints obj
var oddHandler = obj.myMethod.bind(123);
oddHandler(); // -> prints 123
 
mr5
I'm kinda hesitating my career path.
I should really really switch to backend
 
I see very little use in that
 
It has use if you want to dynamically compose a prototype chain but who does that really.
 
Ryan Donovan on January 22, 2021
Welcome to ISSUE #57 of the Overflow! This newsletter is by developers, for developers, written and curated by the Stack Overflow team and Cassidy Williams at Netlify. This week, teach your kids coding basics with fun apps, draw straight lines by hand, and recreate Minecraft with React in about an hour. From the blog Want to teach your…
 
1:21 PM
<select asp-for="Location" asp-items="Model.Locations" class="btn btn-secondary"></select>
Works fine. Now I want it to get the Latitude and Longitude of the selected Location, and Zoom the map to the selected Latitude and Longitude. How would I go about this?
Again, razor pages MVVM
 
@mr5 I like both front-end and back-end in TypeScript :-3
Node runtime env is great.
 
mr5
@d4rk4ng31 JS ^^
 
@mr5 Umm, also, when I select an option from the dropdown list, how would I pass that option to OnGet?
 
mr5
@Hozuki you use nodejs at work?
@d4rk4ng31 enclose it in <form>
and put name on it
 
@mr5 umm, but I don't want a submit button. Will that work without one?
 
1:25 PM
@mr5 For front-end compile-chains, yes. Unfortunately not for back-end. NodeJS back-end I use for all my hobby projects.
 
mr5
@d4rk4ng31 yeah, you could use JS. You can also not enclose it in <form> and not put name on it.
 
@mr5 how would I do it with JS? The main question is how I would reload the map
 
mr5
AnimeAsync()
 
You see, the map is a different razor page
 
1:27 PM
@mr5 :-[
 
while the drop down is a partial that's being placed in _Layout.cshtml
 
mr5
@d4rk4ng31 instantiate a new instance? Beware that probably my recommendations to you are all hack. Better approach is still using C# but I have no knowledge of Razor/Blazor/BazingerZ
@Hozuki I want to write lengthy description of project too. You are very well-versed human.
 
@mr5 lol it takes less time than the code
 
!~shiba
 
1:33 PM
awww
 
[kesarling] Hey Hans
 
mr5
@Hozuki It took me weeks, probably months to write all the words here: github.com/mr5z/PropertyValidator
 
[Hans1984] hey @kesarling
[kesarling] Hiya man! How's ye?
 
mr5
The only reason it looks lengthy is because of the code examples.
 
[Hans1984] I'm aight
[Hans1984] what about you ?
[kesarling] Awesome and fat 😄
[Hans1984] haha
[Hans1984] its the coronafatness
[Hans1984] i know what you re talking about..
[kesarling] yep! True that 😄
 
1:35 PM
@mr5 That's good docs tho!
 
[Hans1984] 😄
 
mr5
Most of popular GH repo contains lengthy words also that articulately describes what their library does. Meanwhile, I merely describe what my simple lib does.
 
[kesarling] Although I play badminton with my friends in the evenings
[kesarling] That has kept me under 90kgs
 
@mr5 SO it is then!
 
mr5
@Hozuki how did you become so very articulate?
 
1:38 PM
I somehow want to praise anime here and tell you to watch more of it... but... I don't know? I just did shit?
 
[Hans1984] thats good @kesarling
[Hans1984] i trie to walk 5 times a week and do my workouts 3 times a week
[Hans1984] keeping myself in check somewhat
[Hans1984] theres always a life after corona so we have to be ready
[Hans1984] but i gained some pounds the last few months regardless
[Hans1984] and its not muscles..
[kesarling] That's fine. Just keep exercising enough
[Hans1984] I ve been working out for 18 years now but its never been as hard as the last 10months
[Hans1984] especially since the gyms are closed and I have to do everything at home..
[Hans1984] hope this madness ends soon..
[Hans1984] but this is the wrong chat
[kesarling] Yeah man. We have started vaccination here. But it's still exclusively for workers, doctors and janitors
[kesarling] Yeah right😅
 
2:00 PM
@ntohl it is interesting, I guess I found a case where kotlin's generic type inference fails
 
and F# works?
 
oh absolutely not
I just got curious because of the regex example
I am still not sure how it works
but I could guess...
 
[mr5] Is F# gooder than Kotlin?
 
although it works...
the type inference couldnt figure out the type information
 
\[**[mr5](https://discord.gg/PNMq3pBSUe)**] C# is to Java
As
F# is to Kotlin
 
2:06 PM
hence match<String, MatchResult, LocalDate>
*did I*
**forget that**
---so chat---
`sucks?`
oh ye, I did
@ntohl but what I dont understand is this
ParseRegex "(\d{1,2})/(\d{1,2})/(\d{1,2})$"
is that just parsing the regex, or applying the regex on the input?
or is class Regex : Func<String, MatchResult?> ?
sort of
ah, wait, the docs have more code
ah
this looks more like it
ah, even managed to refactor it a bit, now with type inference and with unsynchronized intermediate values
 
2:26 PM
Does it stop when a regex above then other found a match?
 
yep
fun <I, R : Any> match(input: I, vararg operators: Operator<I, R>, orElse: () -> R): R =
	match(input, *operators) ?: orElse()

fun <I, R : Any> match(input: I, vararg operators: Operator<I, R>): R? =
	operators
		.asSequence()
		.mapNotNull { it(input) }
		.firstOrNull()
match just takes in a sequence of operators, each operator... is just (I) -> R?
just Func<I, R?>
the operators are iterated over, each gets invoked, filtered if the result is null, and it terminates when we found our first result
the orElse is optional, but gets invoked if none are returning a non-null value
cant do that with a default parameter value because the result of the function changes from R? to R
changing the parseRegex a bit, to reflect the behavior of the example in Active Patterns, you get this:
fun parseRegex(pattern: String): (String) -> List<String>? = {
	Regex(pattern).matchEntire(it)
		?.groups
		?.filterNotNull()
		?.map { it.value }
}
(not sure why, but it appears interface MatchGroupCollection : Collection<MatchGroup?>
so, a MatchGroupCollection is a collection of nullables for some reason
obviously, you could also just do ?.groupValues instead
fun parseRegex(pattern: String): (String) -> List<String>? = {
	Regex(pattern).matchEntire(it)
		?.groupValues
}
the only thing I cant see is where the mapping from string to int happens
considering
let (|ParseRegex|_|) regex str =
   let m = Regex(regex).Match(str)
   if m.Success
   then Some (List.tail [ for x in m.Groups -> x.Value ])
   else None
ParseRegex returns an IList<String>?
but the deconstructor assumes integers:
[Integer m; Integer d; Integer y]
I can only assume that it is some weird magic that converts the strings to integers
which Kotlin wouldnt allow
which results in
with(parseRegex("(\\d{1,2})/(\\d{1,2})/(\\d{1,2})\$")) {
	map { it.toInt() }
		.let { (m, d, y) -> LocalDate.of(y + 2000, m, d) }
},
instead of
with(parseRegex("(\\d{1,2})/(\\d{1,2})/(\\d{1,2})\$")) { (m, d, y) ->
	LocalDate.of(y + 2000, m, d)
},
other than the syntax and implicit mapping, it looks equal
 
@Wietlol yes. It's string[]
 
active patterns look like union types as portrayed by the docs
where |X|_| is just Nullable<X> or X?
 
yeah, with a possible _. |X|_| is option X
Some X|None
union type
 
2:43 PM
Larry !
I mean Harry
anyone played the larry laffer games as a teen ?
 
the colors are quite simple though
RGB just becomes a function to map a Color to a Triple<Int, Int, Int>
and matching it is just invoking the function and deconstructing it into 3 variables (put into an also call to keep their scope small)
 
3:42 PM
Hello all, just wondering if I can get some help with running a method asynchronously.

I have read through lots of answers and I think I have confused myself.

I want a sort of fire and forget method, so I have written this line;
Task.Run(() => _client.MoveFile(sourcePath, targetPath, FtpRemoteExists.Overwrite)));

Is this the correct way to do it?
and, should I put 'await' in front of it?
 
This is the correct way to fire and forget
 
thanking you very much
 
await would fire and wait for it to complete
 
ok thank you, its the intellisense moaning that threw me off
 
Why do we run a task asynchonously if we're going to await it anyway?
 
3:51 PM
i think its so it doesnt block everything?
 
Just an academic question. I'm old school and the async stuff hasn't totally clicked for me.
 
The bit that confuses me about 'await' is the warning, 'This async method lacks 'await' operators and will run synchronously.'
 
Which always sounds backward to me.
 
@IROEGBU Yes, that was it. Thanks, I somehow missed that school boy error.
 
4:11 PM
@matty357 This warning is about the method you're in. If you don't await anything inside, you don't actually need the async keyword. So the method you're in is running synchronously - but not the Task it fires off.
 
@SeaCharp To free up the thread resources. Blocking calls, as you're used to, spend idle time waiting for I/O. For example when you're querying a database. It's just sitting there, doing nothing. Eating precious RAM. Making it asynchronous allows the thread to return to the pool to do other work. Imagine you have 300 concurrent requests, all idling while waiting for DB-work to complete. That's ~300-600MB of RAM wasted doing nothing.
(Not to mention the CPU cycles they waste sitting there)
 
4:27 PM
@SeaCharp afaik, we use async to hide the major errors in designs of frameworks and the runtime
 
Bold statement Cotton.
 
afaik, we use async to hide the major errors in designs of frameworks and the runtime
fixed it
 
I use async on my bot cause idfk what discord wants me to do
 
@SeaCharp if you always immediately await the async calls, the process still works as a chain
where each node in the chain is separated by the await keywords
as soon as the first node finishes (and returns a non-completed task), it falls back to the caller (often from a framework or the runtime) to deal with how to approach the chain's continuation
ui frameworks that rely on a ui thread to deal with the ui responsiveness can then continue with the ui being responsive and have the continuation happen when the task completes
this would prevent the common "(Application does not respond)" freezing ui
at least... for the duration that the task is waiting for the continuation event
after that, it continues with the next node in the chain
if the thread that started the task was from a thread pool, it can return to the thread pool to do other stuff while the task is still waiting
although it does solve the majority of the problems, it could be solved much better and much easier
a thread in C# does not necessarily have to be a thread from the OS
an application could easily request a fixed (optimal) amount of threads from the OS and handle the internal threads itself
to make sure that there are no idle OS level threads
this way, avoid wasting CPU cycles
and if UI frameworks simply keep the UI thread encapsulated, there is no need to do anything to avoid freezing UI
so, to me, async just introduces a massive amount of noise to partially solve problems for which we even have better solutions
needless to say, I am a huge fan of async /s
 
4:50 PM
A suitable explanation.
 
@Squirrelkiller Ok thank you, so the method i want to fire off asynchronously doesnt need the async keyword, only methods that have async calls within them need it.
 
Correct
 
Thanks very much for your help
 
Anyone know anything about JwtSecurityTokenHandler.InboundClaimTypeMap? I updated a few packages that do stuff with identity and now 1) the handler moved into .Jwt.JwtSecurityTokenHandler from where was before and 2) There is no more InboundClaimTypeMap on it.
 
anybody there?
 
5:05 PM
[kesarling] yep
[kesarling] always here 🙂
[kesarling] @galmeida
 
Do you know details about dependency management and binding? I'm having trouble with bindingRedirect in web.config, package in packages,cconfig and Reference in csproj with regard to versions os newtonsoft.json . If you know details on how this works I could make my question. I'm not making it directly into the 'main' stack area because it may have to do with some basic misunderstanding.. if its actually worth it and know the naswer I could make the quations and you re answer it tyhere
 
I have this problem in like 80% of releases lol
1) write down the version you need 2) write down the versions your dependencies need 3) check if one of your dependencies has an upper bound on it 4) go to your config and make the binding redirect target the highest version
Also when someone has an upper bound, kick their ass
 
[kesarling] lol
 
Also use .NET Core so you can get rid of the package.json, I feel it's so redundant
(And yet, I can't successfully migrate to PackageReference)
 
[kesarling] don't migrate then 😄
 
5:15 PM
Checking if I'm getting it correcty: packages.config is exclusively associated with nuget and contains the packages that will be restored once you build the app. bindingRedirect will tell at runtime a replacement rule for versions of a dependency, correct?
 
Correct, although I can't promise package.json is exclusively associated with NuGet.
I just use it at work, hoping it doesn't explode in my face
 
[kesarling] Loggin off 🙂 Good Night all of you
 
ok, so what about 'Reference' in csproj ?
 
Same lol
That one maybeprobably tells msbuild what to copy to output
 
5:38 PM
but there is a time difference between then, right? Also - the reference speciffies version 10.0 , but when the exception is thrown at runtime, it complains aobut verions 6.0 missing. Nowhere in the project version 6.0 os newtonsoft json is mentioned
Ive configured both package.config and the bindingRedirect to 11.0.2, on csproj it references 10.0, so I guess the redirect ir not worlking. And there is also this issue - it cmplains about 6.0, not 10.0
Web.config: <dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="11.0.2" />
</dependentAssembly>
 
The binding redirect only takes effect at runtime
Recommend oldVersion="0.0.0.0-11.0.2" newVersion="11.0.2"
Always use the version you're redirecting to as the upper bound for the range
And yes there's another level of "version" that I'm currently fighting too
 
6:44 PM
Ok, I think I have to do more research. Thanks! This kind of thing is really frustrating..
 
 
5 hours later…
mr5
11:17 PM
@Wietlol async per second?
 

« first day (3751 days earlier)      last day (1180 days later) »