« first day (3670 days earlier)      last day (1293 days later) » 

user14200771
3:29 AM
hey guys
 
user14200771
Thought it would be c#
 
c# aint going good
 
mr5
as far as I'm aware, a lot of companies are investing on AI and two of the popular languages in that field: TensorFlow and Python are dependent on C++
and a lot are looking into optimizing their existing systems so they resort in native
C# is stable but most of techs built into it are websites.
 
Hey, @mr5, there's a new requirement in my project. The HomePage, instead of displaying a list of locations, should show a zoomable map (like Google Maps or Bing Maps) and should show an icon at every location. When that icon is clicked, it should show the related information. Like, consider that the app is programmed to show hotels, then the hotels should appear on a map, and when clicked, should pop-up a dialog box with the menu
 
mr5
3:38 AM
and the growing popularity of self-driving cars ;)
 
and most of accounting and pos related system are built using c#
 
How do I add maps in the project?
 
mr5
Choose a map control first.
 
<map>?
That's the only one I know
 
mr5
what framework are you using?
 
3:40 AM
.Net Core
 
use google map, one line only
var map = new google.maps.Map(mapelement, {
zoom: 17,
mapTypeId: google.maps.MapTypeId.ROADMAP,
fullscreenControl: false,
streetViewControl: false
});
 
mr5
^
 
Hmm... and where do I pass the locations?
guys?
 
mr5
the finding of landmark comes with a different API though
 
@nyconing Whoa
 
mr5
3:42 AM
retrieving the device's location is also a different topic.
 
what happened @nyconing?
@mr5 hmm...
 
mr5
are you going to do this in JS?
 
nope
razor
 
mr5
well, it's html
so you're going to use JS for that
 
Map will be added as a razor component
 
3:44 AM
sorry typo
        var map = new google.maps.Map(mapelement, {
            zoom: 17,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            fullscreenControl: false,
            streetViewControl: false,
            center: new google.maps.LatLng(3.567451, 100.800482)
        });
its js code
 
Ty
And how do I display it using HTML?
(No JS background sorry)
 
mr5
JS will handle the DOM for you
DOM = Document Object Model = HTML content
 
So just copy paste @nyconing's code?
 
mr5
you need the header script first
and an API key
hint: Google
 
I thought so!
It couldn't have been that easy
 
user14200771
3:46 AM
I'm a bit stuck on some integration tests I'm creating
 
user14200771
wait will fix formating
 
Will get back to you too after I try it out :)
Ty @mr5 @nyconing
@raul
 
user14200771
        [Fact]
        //pass inline data here for multiple users here
        public async Task Should_GetClaims_CurrentUser_Successful()
        {
            await AuthenticateAsync(); //Calls Method in base class which gets bearer token


			//not sure how to add claims onto current user (await AuthenticateAsync)
            //Mock Database with Claims for multiple users
            var user1Claim = new Claim
            {
                ClaimId = 1,
                RestaurantId = 55,
                //UserId= user1.Id, //not sure what to pass as userId
 
mr5
use the "fixed font" button
 
Again wrong
Wait
 
user14200771
3:47 AM
yup just did :)
 
Do this:
 
no its pretty easy actually
 
Remove the indentation for [Fact] based lines
i.e. decrease the indentation be 2 tabs for the code
 
user14200771
okay one sec
 
3:49 AM
@nyconing Ty :)))
 
mr5
you can edit your previous post by pressing the up arrow key
 
after you create an api key, you put the key inside your html script
<script async defer src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap"
  type="text/javascript"></script>
 
@nyconing, do I need to have a special plugin in Visual Studio?
 
and then the map is ready to use
 
oh!
 
mr5
3:49 AM
you don't. it's just a client side script
 
no, just put script into your html body/ header
 
why async?
 
user14200771
[Fact]
//pass inline data here for multiple users here
public async Task Should_GetClaims_CurrentUser_Successful()
{
	await AuthenticateAsync(); //Calls Method in base class which gets bearer token


	//not sure how to add claims onto current user (await AuthenticateAsync)
	//Mock Database with Claims for multiple users
	var user1Claim = new Claim
	{
		ClaimId = 1,
		RestaurantId = 55,
		//UserId= user1.Id, //not sure what to pass as userId
		VoucherId=43,
		StoryId= 614,
		PaymentId= 283
	};

	var user2Claim = new Claim
 
user14200771
little better
 
good boi :)
 
mr5
3:52 AM
also put all the script tags near </body> (near the end of body) so it would not hinder the UI loading
 
user14200771
So I'm confused on how to add claim to my users. The response for the claim is pretty much shown in user1Claim
 
user14200771
but I'm just super confused how to attach it to a user. The AuthenticateAysnc method is in a class which creates a user and returns the bearer token of that user
 
@mr5 mhmm
 
user14200771
I feel like it needs more content so happy to answer more questions
 
mr5
I think Razor already handles this, though I'm not sure. There should already be a section in that framework where you put all the scripts so it gets bundled elegantly.
@raul sorry no idea what those are. The squirrels are still sleeping.
 
user14200771
3:57 AM
yeah damn its too tricky question to ask
 
user14200771
trying to think how to break it down
 
 
2 hours later…
6:23 AM
Gooood moorniiiiing CeeeeeShaaaaaarp!! From today, I am doing my bachelors, so I'm allowed to be dumb again, yay!
@raul Not 100% sure, it would definitely be helpful to know how exactly your bearer token is generated from the user. This answer shows how to do it for tests, if you're in normal asp.net, but like I said I can't see how your method finds its claims from here.
 
@Squirrelkiller Nice :)
Also, can anyone explain this? I am not able to wrap my head around that code properly
 
6:39 AM
The class SeedData puts initial data into a database.
In the program.cs the class SeedData is used to initialize the database.
I'm not sure about the code above that though, where they pull the dbcontexoptions without having added EF.
But the linked part just uses the class built previously.
 
@Squirrelkiller RE: I'm not sure about the code above that though, where they pull the dbcontexoptions without having added EF. I want someone to explain what each line of that code does. (Hope I ain't asking too much)
 
The code of the SeedData-class, or the code in the program.cs?
 
Program.cs
@Squirrelkiller SeedData class seems pretty straightforward
Although, in the seeddata class, what does the following line do?:
using (var context = new RazorPagesMovieContext(
                serviceProvider.GetRequiredService<
                    DbContextOptions<RazorPagesMovieContext>>()))
 
first the host gets built. The host is basically the app known from asp.net core.
@d4rk4ng31 That line constructs a new dbContext, using the options pulled from the registered services.
Options contain connection string and such
 
Oh!
I need to break that line down to understand it. We'll table it for later currently :)
@Squirrelkiller var host = CreateHostBuilder(args).Build(); this line?
 
6:44 AM
yup
In the backend you'd have an IAppBuilder or something in your configureservices method instead.
 
What is an IAppBuilder?
 
Have you worked with asp.net before? Gotta check where I'm gonna...base my explanation on.
 
Sorry, if I am being too nooby :(
@Squirrelkiller Well, I started working on it around a month ago
 
No problem, everyone has to start somewhere
 
Took a week to realise that I was using Web Forms, which has been outdated :(
So that means, I have been into it for not more than 13-14 days
@Squirrelkiller :)
 
6:47 AM
ouchy
So you started directly with Blazor?
(Or Razor Pages)
 
.NET Standard -> .NET Core (Took another week to realise they were different) -> Blazor -> .NET Core with Razor pages back again
 
Interesting lol
 
Yeah, I am pretty dumb like that 😅
 
Technically the framework is not called Razor Pages anymore but Blazor Server - Blazor can be used in two modes: Server and Client. Server is literally Razor Pages. Client uses WASM to send the whole code to the browser and execute everything there.
 
hmm...
but can we please get back to program.cs?😅
 
6:51 AM
Absolutely
 
Ty :)
 
The host (or in the backend AppBuilder) lets you register services for dependency injection and configure general settings like CORS for the whole application. This code gets executed exactly once, when the application is started.
 
@Squirrelkiller This is clear now :)
 
That is also where the connection to a database is initialized.
Every time something needs to access the database from now on, basically it just pulls a dbcontext from the service provider (or has it injected via DI), so from now on no other class needs to know how to actually connect to a database.
 
@Squirrelkiller DBContext is like an object of the database, I guess?
 
6:56 AM
DBContext is a class letting you access the database without having to write actual SQL. It's a DAL - Data Access Layer. In bigger applications this might be built by the developers themselves, but most of the time using the dbcontext works fine.
Basically you treat it as if it was the database itself.
 
@Squirrelkiller Oh!
 
It will translate your code calls to actual SQL and send it to the database.
 
So it acts like an interpreter for C# -> SQL?
 
A translator, yes. And also as a cache between you and the database.
 
Ah! So, Update-Database dumps this cache! right?
 
6:59 AM
You can build queries like context.MyTable.Where(id == 3).First(); and it will just build a query. It will only actually hit the db once you call an async method like .FirstAsync() or .ToListAsync().
Dumping the cache is done using .SaveChanges() on the context, after you did your transaction.
 
@Squirrelkiller mhmm
 
It might be easier to start building an application without using a database first.
Building a WebApp is hard enough as it is lol
 
@Squirrelkiller concur :)
It is, especially if its the first time
 
Exactly
 
If this were to be in C/C++, I would have done this in a trice
 
7:04 AM
What kind of work have you done in C/C++? Might be easier to start with a desktop application.
 
Umm.. no, the project has to be done in .NET
that's a requirement
@Squirrelkiller CLI Apps mostly
But great command on its concepts though!
 
.NET is also for desktop apps though - Blazor is a relatively new Framework.
 
@Squirrelkiller Umm... I am using .NET Core, at least that's what I selected when creating new project
 
If it doesn't have to specifically be a web app it's probably easier to build a WPF app
 
@Squirrelkiller No, it has to be a web-app
 
7:09 AM
Ah I see. Pretty awesome honestly.
 
But, getting back to program.cs
Lemme get this cleared
 
Yeah. You could see host as the application itself being configured.
 
This line, host.Services.CreateScope() creates a scoped instance of the all services crammed into one object right?
And what exactly is the scope of these services? I am guessing the project?
 
Right. Services can generally be registered in three lifetime-options: Scoped, Transient and Singleton.
 
mhmm, and...
wait
lemme guess
Transient is across many apps?
and singleton is once created, can't be created again?
 
7:13 AM
Transient means: Every time a service is requested, the caller gets a freshly built instance of that service.
Scoped means: There is one instance of a service for each web request.
Singleton is singleton.
So yeah transient is basically the opposite of intuitive lol
 
I didn't get the difference between Transient and Scoped
Please explain a little in detail
Oh! Wait
So if the service is scoped,
and I request it 100 times, the same object will be reused as long as the app is running
and if it is transient, it will be created 100 times and destroyed an equal number of times?
Or do I have it wrong again?
 
Yup you got it right
 
@Squirrelkiller MS needs to work on its nomenclature
 
Sorry I'm in the lecture now, not gonna be very attentive now^^
 
@Squirrelkiller Yay!!
@Squirrelkiller Same here
 
7:17 AM
lol
Nice
 
though, I have muted the lecturer
 
That...is not the point of a lecture lol
 
Its annoying when you have to sit for the lectures of the subjects you never wanna get into
Like, machine learning
Aww, its so boring
 
user14200771
anyone know how to add data to an inmemory database??
 
user14200771
for integration tests
 
7:18 AM
same way as any other db I'd've said
 
Anyways, I guess I should get back to the tutorial
Thanks tons @Squirrelkiller :)
@Squirrelkiller Yep, the point is maintaining 75% attendance, which is necessary to be qualified for final exams :D
 
user14200771
any tutorials I could follow? This is what I've currenlty got in my base context
 
user14200771
 public class IntegrationTest : IAsyncDisposable
    {
        //new database name created for each test method
        private readonly string _dbName = Guid.NewGuid().ToString();
        private readonly IServiceProvider _serviceProvider;
        protected readonly HttpClient TestClient;

        public IntegrationTest()
        {
            var appFactory = new WebApplicationFactory<Startup>()
                .WithWebHostBuilder(builder =>
                {
                    builder.ConfigureServices(services =>
 
7:45 AM
GoOoOoOoOoOoOoOoOoOoOoOd Mornin' neglecterinos!
 
8:07 AM
@Squirrelkiller, what attribute can I use for a public string Name {get; set;} to validate "only alphabet" input?
 
What kind of attributes are you using? The DataAnnotations stuff?
 
@Squirrelkiller User class
 
I'm more confused than before
 
Err...
 
8:09 AM
Start from the beginning: Where does the idea come from that you could validate a string using attributes?
I don't have the spare mental capacity for more now sorry
 
That...doesn't have attributes?
A Regex for validating "alphabet only" is simple though: [a-zA-Z]
 
No, it doesn't. Well I just want to validate the name
So that the user does not enter Hey, The creator of this app is dumb as f*ck
 
mr5
When is the validation going to take place?
 
During creation of the user
 
8:15 AM
private string name;
public string Name
{
  get => name;
  set
  {
    if(Regex.Match(value, "[a-zA-Z]").Succes) name = value;
    else name = "invalid"; // for example. Or throw an exception or something.
  }
}
Might be a valid declaration of your validated name.
 
mr5
@Squirrelkiller did you go back to school? Are you taking masters or PhD?
 
Bachelors
 
@mr5 Whoa
 
mr5
@Squirrelkiller eww.
@Squirrelkiller how old are you? Also, did you quit your job just to go back to school?
 
I got 30 in July, and I'm now a working student in the same team as before.
 
mr5
8:17 AM
@d4rk4ng31 are you using MVVM pattern?
 
He's building his first .NET app, immediately starting with Blazor. Give them a minute lol.
 
mr5
@Squirrelkiller 4 year course?
 
3 year. Profs in orientation said it's normal to need 3,5years though. I hope I can do it in 3.
 
mr5
Whoa, why do you need the degree, you already have the experience
 
For one, I want wider knowledge. Currently I have very much vertical knowledge, which gives me quite an advantage in my field, but many times I realized horizontal knowledge can be extremely helpful to understand new things.
 
8:21 AM
morning
 
mr5
\•
@Squirrelkiller the vertical and horizontal is software and hardware right?
 
No it's a concept of kind of knowledge. Has nothing to do with software or a specific field. Gimme a moment...
Basically if you do a training about a specific framework, like angular, you gain vertical knowledge: You stay narrowly in the field, software>highlevel>application>angular.
If you attend a university course about computer science, that will give you horiztontal knowledge: About the basics of CS, how computers are built, possibly transistors, what gates are, how memory is managed, how RAM and registers work, what an ACU is.
Many basics that wont immediately let you make a program but explains many things that come later in life.
 
mr5
@d4rk4ng31 if you are using MVVM, this library might be helpful to your validation needs: github.com/mr5z/PropertyValidator
 
ffs I can't actually find an image to explain vertical/horizontal knowledge. Interesting, I thought it's like, a common concept.
 
mr5
8:32 AM
@Squirrelkiller oic. That should always be the case.
One can get lost with that topic. I didn't finish the book I'm reading about transistors when I was 1st yr college because I get excited too quickly.
 
tbf there is extremely much to learn about transistors, even if you learned about just trigger transistors as used in computer chips.
 
mr5
I remember I stopped when the topic is about schmitt triggers and multiplexing, and now it's haunting me.
 
Morning children
 
morning lee
 
mr5
Is there a term to refer with "common mind" among people in the same field but are physically distant?
Or a group of people realized something even without obvious communications?
 
8:58 AM
uh
Hivemind, sort of fits, but not well
 
mr5
Hmm
 
common knowledge I'd say
 
Maybe, but the way he said it sounds like lots of people suddenly realised it together, as opposed to generally knowing it nayway
 
mr5
9:16 AM
Yeah, it's a sudden realization of something. Like a lot of developers realized they needed to code in C++ thus gaining its popularity again.
 
@CaptainObvious
Ill spam u in telegrem wait a sec
 
ahoy o/
 
heyho scrub
 
9:35 AM
Ahoy Captain o7
 
capacitors more interesting because it can explode
3
 
9:47 AM
Definitely
 
@nyconing quote of the day right there.
 
mr5
Samsung: you look back where you came from
 
10:32 AM
Good morning all o/
 
10:49 AM
Yo
 
11:31 AM
blk, hello again lol
bk*
 
What does bk mean? Burger king?
 
back
 
mr5
og*
 
I can't believe you shortened a 4 letter word
 
11:35 AM
yeh had to shoort, the MD came in to my office for a chat about the new lockdown coming
shoot*
bk? used it for years lol
 
I've literally never seen it
Lockdown 2: Electric Boogaloo 🎉
Last time we basically drowned in orders, will be interesting to see if that happens again
 
I got into a disagreement last time with my bosses about whether code refactoring was a job that could be done remotely...
In a team of 1
xD
I basically finished up the task i had that morning and walked out, dodnt come back in for 6 months lmao
 
mr5
 
Umm... hey @mr5.
A lil help
You see, I integrated bing maps API into my project
 
mr5
no I didn't see it
 
11:42 AM
now I want help in adding a search functionality to the maps
Gimme your GitHub usernmae
username
I'll add you as a contributor
Then you'll be able to see it :)
 
mr5
you claim I saw something which I didn't
=P
with that thing
 
duh
 
mr5
you can use Google ughh
I forgot the API name.
Google Place.
hmm wait
 
Umm with Bing maps?
 
mr5
yeah. You can integrate it with any other maps
since it's just an API
It returns JSON as response: developers.google.com/places/web-service/…
 
11:47 AM
Also, do you have a little time to explain what these guys have done here? I simply copy-pasted it, but I still don't understand it
 
Which part don't you understand?
The first JS bit uses the Bing Maps JS to stick a map on the page in a div called map. The second bit loads the Bing Maps JS so the first bit will do something. The last bit tells the first bit to actually run when the page has finished rendering
 
mr5
1st code snippet: add pin to an existing map control in DOM
2nd: load the script and trigger the callback once loaded.
3rd: looks like it basically implements the callback to take place.
 
@CaptainObvious Well, you see, I don't yet know much of JS
 
The ordering is very odd and there's not much explation, but Syncfusion's documentation is absolute ass
 
mr5
yeah why would you look at syncfusion.
 
11:53 AM
@mr5 Cause I am a newbie?😅
 
Syncfusion is hard to use
 
But it worked :(
 
Partly because their documentation is absolute crap and partly because they're very complex controls which while very powerful, are an absolute nightmare to set up
It worked because you copied something without knowing what it does
 
Okay, then how do I do it?
 
Maybe don't start with blazor
 
11:56 AM
Well, blazor
That's compulsory
 
Why
I thought you said you were new to C#
 
Yes
I am!
We are doing this for our BE Project
 
Final Year
of Engineering
 
Blazor Enterprise?
 
11:58 AM
You see
I've been doing this (professionally) for over 5 years, and for a while before that
And I make glaringly stupid mistakes at times like just now
And I'm not using fancy new shit like Blazor
 

« first day (3670 days earlier)      last day (1293 days later) »