« first day (3464 days earlier)      last day (1471 days later) » 

4:19 AM
Meanwhile in japan, they again found new infection group, put confirmed cases into accelerating, declared state of emergency on 7 districts
 
 
1 hour later…
mr5
5:44 AM
 
 
4 hours later…
9:20 AM
Hey guys.... I'm having a nooby question. If I have an API service, which gets injected into a controller, but also store some of the pulled data in the database, so I have a separate DAL class that gets that data... should I inject this Dal class in the controller too, or should I only inject it in the service and only use the service from the controller level?
it would then look something like this:
    public async GoogleImageMetadata GetImageAsync(string id)
    {
        return await _dal.GetImageAsync(id);
    }
in the service class
please let me know if I'm not being clear with the question
 
mr5
9:52 AM
WTF is happening from the code above?
 
this is a service class. by calling _service.GetImageAsync(123) from the controller, you're querying the database
avoiding injecting DAL class in the controller itself
oh crap, sorry. didn't see the link.
 
10:08 AM
quaaack
sup
long time no see
 
mr5
@PawelFlajszer is GoogleImageMetadata a type alias of Task<T>?
 
10:43 AM
@mr5 yeah, just wrote it quickly,typo. Imagine it's Task<GoogleImageMetadata>, but that shouldn't make a difference for the question asked though
 
11:08 AM
> System.Exception: WTF!?
@mr5 wtf is certainly happening in that code
can confirm
 
mr5
yeah ikr
this captures are evil
 
what happens as well is closures, mutation on captured variables and general C#
especially that last one is biting you
although, it is not the source of the "unexpected" behavior
(where it is only unexpected to you and expected by everyone else)
thank you Rider for being a meme IDE frigging awesome
 
mr5
is your main named Main2()?
 
yes, yes it is
for obvious reasons
at some point, I was like "ye, I will put this in my main"
and then... "ye, perhaps not"
although, I have to admit, my white box analyzing would probably not have spotted the issue
 
mr5
so you have two starting entry point?
@Wietlol why do you like collapsing image so much
 
11:28 AM
!~shiba
 
aha!
so im supposed to drink today
I see
 
@mr5 but do you understand why the exception is thrown and why the numbers are doing weird shit?
@PawelFlajszer not sure about anyone else, but in our stuff, the DAL is a service by itself
 
mr5
@Wietlol nope. I have the slightest idea. All I know is that the compiler wraps this int into a reference object.
Maybe posting it in SO would be a good choice?
 
var limit = 20;
IEnumerable<Int32> stuff = Iterate(0, it => it + 1)
    .TakeWhile(it => it < limit);

limit = 40;

stuff.ForAll(Console.WriteLine);
do you understand what is going on here?
 
mr5
11:47 AM
nope
why?
 
what do you expect will happen with the above code?
 
mr5
it will print "hello world"?
 
almost
 
mr5
prints 0 - 39?
 
yep
the filter, limiting the sequence is just an instruction
 
mr5
11:50 AM
cuz it's an expression that's why it's deferred?
 
the instruction, in this case, is invoked by the ForAll function
because of how IEnumerable functions like TakeWhile work
at that time, one of the dependencies of that filter instruction has already changed
namely, the limit variable
with async, it becomes less obvious when the code is executed
but it is somewhere between Task.Run(() => Wtf(i)); and await Task.WhenAll(taskList);
and within that range, the variable i will be changed
this is one of the reasons why you shouldnt do mutation
Java's compiler will even just reject code like that
 
Java code won't even allow the use of variables in lambdas unless they have final keyword
 
not true
as the error says "final or effectively final"
 
in what version?
effectively final?
 
it doesnt have to be final, but if you dont mutate it... it is effectively final
I think this has been like that since Java 8
 
11:58 AM
so the compiler adds an implicit final keyword if it isn't reassigned?
 
sort of
keep in mind, final in theory is just a compiler feature
at runtime, it is just a flag without much meaning
only to be used by reflection and shit
 
makes sense
lets say then "treats it like it has final" if it isn't reassigned
maybe it wouldn't add the flag though
 
ye
 
mr5
I still can't get my head around how does it become 20 though since I only loop from 0 - 19 inclusively.
 
does it tho?
> for (var i = 0; i < clientCount; ++i)
this loops from 0, going up, as long as the i < clientCount
at some point, i < clientCount must return false in order to exit the loop
 
mr5
12:06 PM
oh yeah right
it triggers the invocation while the i is almost 20
it should probably be 20 at the end.
 
as soon as i == 20, i < clientCount yields false, breaking the loop
there is no room for "probably"
 
mr5
probably because I wouldn't know for certain when it will read the i?
 
as for the exact result of "Id: 2" being printed twice and then the exception of "WTF!?", that is just a race condition
maybe it would start at the exception, maybe it would even just print 0 through 19... if you are really lucky
 
mr5
This can easily be solved if I use the Task.Factory.StartNew(Wtf, i) and change the callback signature to Wtf(object)
 
but yea, if you just change it to an iterator/enumerator loop, it would be fine
hmm... you could pass the index as input object to the task, sure
but I would first of all remove the primitive for loop
 
12:55 PM
 
@Hans1984 the girl in the back tho with the full white balaclava
 
;)
 
@Wietlol Thank you. Do you make your DAL into a separate project and divide into small pieces like FooDAL, BarDAL etc?
 
I do make the data repository into a separate project, yes, but in my case, Foo and Bar are already separate solutions
 
1:11 PM
Ben Popper on April 10, 2020
In this episode of the podcast, we talk about the history of COBOL, a “common business-oriented language”, which is suddenly missions critical to government systems, like unemployment, overwhelmed by the pandemic. After that, we chat about the supply chain in China, which pivoted within weeks from pitching Ben electronic components to offering critical medical supplies.…
 
1:25 PM
@Wietlol Are you talking about the mannequin?
 
:)
 
1:44 PM
            var assets = GetAssetsByKitId(customerContent);
            foreach(var content in customerContent)
            {
                content.Assets = assets.Where(a => a.Key = content.ContentId);
            }
assets is type Dictionary<int, string>
content is a content model
a.Key is not valid syntax, how do I fix it?
 
= assets[content.ContentId]
 
I meant to say assets is type Dictionary<int, IList<string>>
so one to many where I need to append the string array to the content model where contentId ==
 
so your syntax invalid issue is solved. this is another question.
 
true, I see where that fixes the syntax
 
but the new question is unclear, do you want to string.Join() a IList<string>?
 
1:51 PM
I want content.Assets = the IList<string> portion of the assets Dictionary<int, IList<string>> value. matching on content.ContentID
so content.ContentId == the int portion of the assets Dictionary
 
no, the Dictionary, only have one unique key
you cant have duplicated key inside dictionary
 
true, contentId
it doesn't Dictionary<int, IList<string>>
I just need to assign that list of strings by content id
 
@JoJo you are using assingment instead of equals
also, Where does not return a List
it returns an IEnumerable
 
ok
 
on top of that, using this, it would remove all items scrap that
 
2:00 PM
your right. i see the assignment in the linq
 
= assets[content.ContentId] (as mentioned by nyconing) would work better than the foreach loop
but you have to keep in mind that it may not have any values for the given key
in which case, you would probably want to use an empty list or remove the item from the customer content
 
okay
 
perhaps, simply re-assigning customerContent is a better idea
 
the problem is customerContent is a List<CustomerContent> that is why the for loop. a nested array
 
Ryan Donovan on April 10, 2020
This week, we’re going deep on dark mode, balancing code quality with deadlines, and rolling your own chat apps.
 
2:05 PM
AllContent > Content > Assets (filenames
 
do you need to retain values from the old customerContent?
 
not on the Assets property
 
does it have other properties?
 
yes a ton
 
hmm...
 
2:08 PM
            // assets = IDictionary<int, IList<string>>
            // customerContent = List<CustomerContent>
            var assets = GetAssetsByKitId(customerContent);

            foreach(var content in customerContent)
            {
                content.Assets = assets[content.ContentId];
            }
            return customerContent;
Unless it would be better to pass the customerContent into here:
        internal IDictionary<int, IList<String>> GetAssetsByKitId(List<CustomerContent> customerContent)
        {
            var assetsDictionary = new Dictionary<int, IList<String>>();
            foreach (var content in customerContent)
            {
                assetsDictionary.Add(content.ContentId, GetAssetsByContentId(content.ContentId));
            }
            return assetsDictionary;
        }
reducing my dictionary's by 1
.... hmmm
okay that works>>
            // assets = IDictionary<int, IList<string>>
            // customerContent = List<CustomerContent>
            customerContent = GetAssetsForContent(customerContent);

            return customerContent;
        }

        internal List<CustomerContent> GetAssetsForContent(List<CustomerContent> customerContent)
        {
            var assetsDictionary = new Dictionary<int, IList<String>>();
            foreach (var content in customerContent)
            {
                content.Assets = GetAssetsByContentId(content.ContentId);
 
mr5
@Wietlol from the WTF code I have earlier, it will only occur when I pass a closure in an async code. Nothing to worry if its sync, right?
 
my example was not async
and still suffers
 
mr5
so deferred execution?
lambda with deferred execution?
 
just execution
 
mr5
closures?
I was thinking it would be a good SO question but I'm an inarticulate man.
 
2:22 PM
it is based on when they are executed, how often they are executed and under what shared model they are executed
if any of them wants to bite your ass, you get errors that you cant explain
 
export class anotherThing {
    thing1: 'hello';
    thing2: 'world';
}

sampleObje = {
    something: 'here',
    something2: anotherThing
}

// prints out like this

{
    something: 'here',
    something2: anotherThing {
        thing1: 'hello',
        thing2: 'world'
    }
}
why is that anotherThing there lol
i don't want it there why is it there
 
mr5
@Wietlol do you have a good title in mind if I want it to make a question?
 
Asking Bob out! [GONE SEXUAL]
2
 
mr5
ayt
I'mma reference your message id in my post
 
Can i use WebRTC to share just the contents of an iframe?
 
2:27 PM
@ChristianMatthew first of all, that doesnt look like C#, secondly, you dont show how you are printing... perhaps ask again in JS channel with more context?
 
Looks a lot like typescript
 
mr5
when was the last time you guys posted a SO question?
 
And if you print sampleObje, anotherThing is there because you put it into smapleObje
 
lol ahhh i thought this was the JS room damn it
 
mr5
@Squirrelkiller why would you need wrtc for that?
 
2:29 PM
hope you guys are well
 
SO probably a few months at least
serverfault like a week ago
@mr5 Well how would I do it without wrtc?
 
mr5
http?
you pull the iframe from somewhere using http?
 
I actually want to stream the content of the iframe in my browser to another browser
 
mr5
continuous update?
@Wietlol here, introducing a local variable fixes the closure issue: dotnetfiddle.net/xc74Iu
 
ye... just remove the primitive for loop
use an internal enumerator or external enumerator if an internal one is not possible
 
mr5
2:39 PM
me to C#: why are you the way you are? stares mdrfly
 
var clientCount = 20;
await Iterate(0, it => it + 1)
    .TakeWhile(it => it < clientCount)
    .Select(index => Task.Run(() => Wtf(index)))
    .Let(Task.WhenAll);
or just RangeOf(0, 20) instead of Iterate().TakeWhile()
 
mr5
is index a copy of it + 1?
 
index is the input
Iterate is a function which generates an IEnumerable, starting at the initial value (0) and each following value is the result of the mapper function (it + 1)
 
should I be using Path Combine here instead of concatenating?
            var contentSharePath = @"\\" + asset.ServerName + @"\" + asset.ShareName + @"\" + asset.FolderPath + @"\";

            var urls = new List<string>();

            if (Directory.Exists(contentSharePath))
            {
                // GetFiles contains full paths docs.microsoft.com/en-us/dotnet/api/…
                var assetFiles = Directory.GetFiles(contentSharePath);
 
so, it generates an infinite* sequence of integers from 0 counting up to positive infinity*
infinite technically being limited by Int32.MaxValue, as is positive infinity
 
mr5
2:46 PM
somewhere in the internal code, it passes that result to another method.
the result being it + 1
 
yep
 
mr5
so it's not a copy?
 
var value = initial; // 0
yield value;
value = value + 1;
yield value;
value = value + 1;
yield value;
...
copy?
 
mr5
it doesn't get assigned to a new var?
 
@mr5 Yes, continuously. Basically screen sharing, but for jsut this iframe.
Let's call it...frame sharing.
 
2:48 PM
it does
it wont have the problem you have
because in my user code, I have no mutating variable
 
mr5
@Squirrelkiller what's the streaming for when you just need to load it once?
 
I load a webapp into the iframe.
I use this webapp.
The person in the other browser should see what I do in the webapp.
I can't even get it to stream the screen to a video in the same browser at the moment :/
 
mr5
is the host also allowed to interact to the iframe?
 
The host? I'm the host, I'm the one with the iframe on my site.
 
mr5
I think I don't have the courage anymore to post questions in SO
 
2:54 PM
Maybe the user can take control, but for now just sharing.
 
mr5
> The person in the other browser should see what I do in the webapp.
isn't this person the host?
 
That person is the client. I send htem an email with a link, so htey connect to me.
They just watch.
Well and maybe I put a canvas over the webapp in my iframe and try to let them paint on it.
 
mr5
But from their tab, they are hosting your iframe
 
They just have a video of my iframe
I jsut want to share part of my screen with a viewer
 
mr5
I mean by host is the one who have an iframe in their html. You didn't say you can view them, but that's just nitpicking and does not actually help your problem.
 
2:57 PM
I have an iframe in my html
The client jsut gets a <video> or something
 
mr5
if it's a readonly mode, you can try to address this problem using a video streaming.
so you can also view their tab?
 
No, the sharing is one-way
That's what I'm trying to build - video streaming
but just for a part of screen
 
mr5
or you can stream the current html content of yours and draw it in a canvas in their end.
probably the easiest route imo
 
How would i do that? And can i confine that to the iframe?
 
mr5
a long polling should work but if you still have time, sure look for wrtc, or TCP/UDP implementation.
You don't need an iframe for that
just a dedicated canvas region
 
3:03 PM
But I need controls on the left and the webapp on the right
and only the webapp is supposed to get shared
 
mr5
that approach would not restrict you from doing those
 
But how?
I'm trying to get the stream of the iframe...but I don't know how.
 
mr5
layout your html into two parts?
 
Right now I have two parts - left side with controls, right side with one iframe
 
mr5
well, if you still like the idea of iframe, my idea is to stream the input from your side and simulate it in their side which I think is more complicated.
 
3:05 PM
I mean, if I can od it without iframe, sure - I just don't understand how
 
mr5
okay
 
The WebApp I want to stream already exists, it's not something I build new.
 
mr5
say, your html is like this <div><div id="left" /><div id="right" /></div>
which part is the web app again? left or right?
 
right
So I wanna stream #right
 
mr5
okay, from the right div, you make a canvas.
 
3:07 PM
@mr5 how do you call viewmodel from your view
i use prism
 
mr5
then you need to create a script that polls the updated html content in your web app
 
So I jsut <canvas><div id="right">{content}</div></canvas> ?
 
mr5
the web app should send this to a single row of a database (probably there's a better way)
@c0dem0nkey NICE!!
@c0dem0nkey you don't
MVVM is made just so you don't reference those two things.
 
@mr5 Nah no database inbetween. P2P - directly to the other browser.
That's what wrtc is for
 
mr5
@Squirrelkiller no. the canvas should be empty.
 
3:09 PM
So...how do i place hte canvas?
 
mr5
since this is where you want to have exact copy of your web app
 
Ah the canvas is on the clients screen
 
so..p2p huh
im listening
 
mr5
@Squirrelkiller yes.
hmm wait. I thought there was a canvas.innerHTML
oh well. it doesn't seem so
then just went to iframe and access the innerHTML. replace it with the html text you get from the long polling
@Squirrelkiller unfortunately, I have no experience in wrtc but basically, the concept is the same. just you have a better throughput using wrtc.
 
@mr5 i got this method returning nearby places in the service.
mind dumbing me down on how ill be calling it
 
mr5
3:15 PM
@c0dem0nkey you put the logic the in ViewModel
services provides the data
views are just displays.
 
kinda got that but then, how am i suppose to call method in service
 
mr5
which method?
 
the one in the service. i plan to call the service from the viewmodel on init of view
 
mr5
Service.GetNearbyPlaces()
ViewModel.NearbyPlaces
<View DataSource="{Binding NearbyPlaces}" />
Prism comes with a built-in dependency injection
install the Prism.DryIoc
 
i still need <View Datasource="{Binding Nearb....
to bind it?
even with prism around
 
mr5
3:20 PM
no, just so you could do something like this: ViewModel(IService)
it will automatically inject the necessary service
@c0dem0nkey yeah. Prism is not a magic library
it doesn't offer binding features
it's library for navigations and ioc
there is this thing called containers in dependency injection
you put the instance/type of an abstract model in that container
in order for a ViewModel and a Page to communicate, you need to call IContainerRegistry.RegisterForNavigation<PageName, ViewModelType>()
 
got to that.
 
mr5
so that, every time you make a navigation navigationService.NavigateAsync("YourPageName"), it will instantiate the ViewModel counter part.
 
but then my case is: when the view loads, i have to GetNearbyPlaces so i was thinking to call the viewmodel from the view so i can call the service from the viewmodel
theres still a part in MVVM i dont quite understand lol
 
mr5
and it will automatically invoke the page lifecycle events like OnInitialize, OnNavigatedTo, ...etc
again, you should not put any logic in your View
let the ViewModel handle it
now, for the service part
well, you can directly instantiate the Service from your ViewModel but it's not cool
you put the abstract model of your service in the ViewModel constructor. That's how the cool kids does it.
so now that you have the service instance, you need to know which part of the page events you need to invoke the service call
is it during initalization? is it whenever the page appears? is it when I tap a certain button?
after self-reflecting and you made your mind, here comes the artistic part. you need to layout your XAML so that the data you get from your ViewModel will be displayed beautifully.
let's say, you want to display a text you get from the service: <Label Text="{Binding TheText"} />
ViewModel(ITextService textService, INavigationService navigationService)
OnInitailize(INavigationParameter parameter) => TheText = textService.GetText()
that's it.
 
@mr5 ultra helpful man
 
mr5
3:35 PM
@c0dem0nkey
sure
let me know if you made it.
try a basic one first before you map that nearby places.
 
@mr5 will do.
 
mr5
I forgot the registration of the service part. Here's an example: container.Register<ITextService, TextService>() (basically, the same on how you associate Page to a ViewModel)
 
i got the services regustered too
 
mr5
you also need to consider service lifetimes but that goes for another WhatIf
 
i guess i should learn about life cycle
 
4:25 PM
does Path.Combine automatically add the back-slashes?
                var contentSharePath = Path.Combine(@"\\", asset.ServerName, @"\", asset.ShareName, @"\", asset.FolderPath, @"\");
 
 
2 hours later…
6:28 PM
posted on April 10, 2020 by ericlippert

Welcome to yet another working-from-home pandemic episode of Fun For Friday Fabulous Adventures. Over the past while I’ve gradually been looking for music, movies and games I enjoyed as a teenager and seeing how they hold up. So I am … Continue reading →

 
6:41 PM
Heyho guys

Room's dead as always 'eh :P
 
yep
 
Ofcourse, wietlol must be here
 
there needs to be someone guarding this room
just imagine if Jack returned, someone must save the room then
 
I thought that's whats Jack's there for
For guarding this room.
Also how come you immediately saw my message lionboi?
@Neil was this ever answered?
 
7:02 PM
I see
because I had my eyes open
@Squirrelintraining got answered multiple times
turns out, I read the description wrong multiple times (-1)
 
Was it answered correct?
 
the last time, it was
 
Then I won't spoiler miself
 
7:21 PM
Not as dead as it could be
 
 
2 hours later…
mr5
9:35 PM
Wildfires in the following: South Jersey, Thailand, Chernobyl, Antipolo
 
9:49 PM
hi
 
 

« first day (3464 days earlier)      last day (1471 days later) »