« first day (3561 days earlier)      last day (1604 days later) » 
02:00 - 12:0012:00 - 19:00

02:35
sup all
yeah i was talking about initializers
i posted two questions here and over the board
@FrEeReY TrY AgAiN. JuSt hAd a nAp fOr a mOmEnT
funny i never go and really come back to it
im done with my tasks anyway.
sup patrick
 
1 hour later…
03:37
oh how can i cancel a task without throw exception and not run continuewith?
or how to handle cancel task correctly?
 
1 hour later…
04:52
return null and null checking at next action that continuewith?
mr5
mr5
05:07
@Squirrel.Downy if you are using TaskCompletionSource<T>, you can cancel it by invoking SetCancelled/TrySetCancelled. A more complex way is to check for every step of the Task if the CancellationToken passed to is has been cancelled - and invoke ThrowIfCancellationRequested() from the token.
To handle the cancellation properly if you await to it: just wrap with a try-catch and handle only the exception TaskCancelledException
If you're using .ContinueWith instead of awaiting to it, check if the Task is faulted - Task.IsFaulted or Task.IsCancelled
> A more complex way is to check for every step within the Task block if the CancellationToken passed to it has been cancelled - and invoke ThrowIfCancellationRequested() from the token.
git commit -m "Corrected grammar"
@Freerey am I using the hyphen/m-dash correct here?
mr5
mr5
05:23
Any OAuth expert here?
Why is one of the built-in scopes is named "offline_access" when what it actually does is to make the /connect/token to return a refresh_token? Wherein, refresh_token being used to request another access_token if it expires ...and it's not an offline thing?
GoOoOoOoOoOoOoOoOoOoOoOd Mornin' pleberinos!
@mr5 you've played the new gamemode?
mr5
mr5
05:39
@Squirrelintraining I haven't yet.
what's the new game mode?
Single Draft? Kek. That existed 3000 years ago.
05:56
is there a shortcut with which I could add a break point on all the methods of a class?
I want to know which method an api is calling
Morning Squirrel :)
Morning mr5
mr5
mr5
o/ shad! morning.
@Shad I don't know if that thing existed but you can also use Call Stack window to determine the stack trace. That way, you can also find which method an api is calling.
yeah okay :)
mr5
mr5
put the breakpoint on the API request (if possible) and start tracing the stack from there.
"put the breakpoint on the API request (if possible) "
what do you mean?
where in my code?
I have my controller...its constructor...
mr5
mr5
in the actual request?
ohh
06:05
I have the web api project code
yes
mr5
mr5
you're in ViewController.
there are many API controllers
mr5
mr5
so do you want to know the method from the client side or the server side?
nah its a dungeon clearer
serverside
mr5
mr5
06:07
@Squirrelintraining needs BP?
@Shad now I'm confused. How could you tell which method from the server invokes the API call if it's only triggered on network request?
Server = my api project that I am running
if I put the break point, say, on GetUser()
mr5
mr5
are you also invoking the APIs method from there?
if the network API calls it
it gets triggered
say I use postman curl request
I am not invoking
the api invokes
I am sorry if I am not able to explain
mr5
mr5
okay I think I get you now.
it looks like Call Stack window wouldn't help.
But you can also try, put breakpoint on the GetUser() then continue using Step Into
but I don't know before hand that it could be GetUser() or GetAdmin() or GetEmployee() etc
that's why I asked putting breakpoint before hand in all! :P
mr5
mr5
@Shad ohhhhh
then I'm sorry I failed you Shad :(
I only wasted your time :(
:)
it's okay :P
morning
hey! :)
mr5
mr5
If the source code for the actual routing is exposed, you can put the breakpoint there.
Is it possible to have a custom path router in ASP?
06:16
I see the API Route under the networks tab in developer tools
but still the mapping doesn't seem to be Perfect
mr5
mr5
all API request should pass from there.
hmm
mr5
mr5
sorry. 0 xp in asp :(
no I get what you mean
perhaps using the ActionFilters
I could check
7
Q: Is there any way to get request body in .NET Core FilterAttribute?

wtf512Sample of my request http://localhost:8065/api/note POST content-type:application/json request body: { "id" : "1234", "title" : "test", "status" : "draft"} and the response should be { "msg" : "ok", "code" : 1} The action public async Task<IActionResult> Post([FromBody]NoteModel model) ...

06:45
@mr5 oh thanks dude, praise the pinecone!
06:57
sup @mr5
hi room
mr5
mr5
o/ c0de
07:20
@Squirrel.Downy are you as amiable as the other squirrels?
will you be my C# buddy?
amiable? amiable? Squirrels are forest rodents!
3
They constitute the largest order of mammals. :p
I don't know, because I am just a downy squirrel.
@Squirrelintraining
https://stackoverflow.com/a/62889207/6859121
Look, what am I saying?
07:42
Your grammar was a bit off Downy
@mr5 the point is you can create the refresh token without logging in again
like I have one app that keeps getting the google access token for some user who isnt online
mr5
mr5
yeah I know that
I'm asking about the name
It says "offline_access" and you would still need to be online in the internet to refresh the access_token
well no the user isn't online
when my app does that
he isnt involved
so offline refers to whether the user is online or not
mr5
mr5
The name is quite confusing
indeed
mr5
mr5
07:49
and then somebody set the expiration to never and offline_access is useless now
is never really a thing or is it max int?
anyway thats not very cash security
@misha130 Hi
hello
I like your name
:P
its a combination
of your gfs name I think?
07:57
yes indeed
and your name
xD
I made it just for you
crush!
16 years ago
soon to be gf lmao
07:57
<3
mr5
mr5
miShad
lol
08:34
Hewwow.
hi hozu_r_i
mr5
mr5
@misha130 I have another good description of "offline_user" I think: "Let the application do something on behalf of user."
why couldn't they just write refresh_token
看板娘插件
mr5
mr5
@Squirrel.Downy das kool
Tokens are meant to expire, so no refresh possible
I do agree it is tedious to check for the expiration date of the tokens before using the API.
09:06
wait what
why dont you use a refresh token?
mr5
mr5
SSL of drive.live is expired. wtf
@mr5 probably related to this funny change
09:29
is it okay I use Try Catch just to handle to exception
I mean not do anything inside the Catch block?
just keep my code running
depends
it is called a "swallow"
gotcha :)
it is almost never a good idea... but yea... almost
thanks
I use one in my serializer, where it tries to serialize stuff and if it fails, then it should catch the error but not do anything with it
09:32
haha
I am using it for the result of an external api
(there is still a log call, but I dont really call that error handling)
I had used response.EnsureSuccessStatusCode();
which will throw exception if not successful
so just to catch that
and not do anything
That's a pokemon-exception handler. Gotta catch 'em all!
09:33
thanks haha
why do you throw an exception just for it to be caught?
seems..self defeating
maybe to log it in the future?
if not successful
is it actually an exception, or just a 'normal' case
98
Q: Usage of EnsureSuccessStatusCode and handling of HttpRequestException it throws

G. StoynevWhat's the usage pattern of HttpResponseMessage.EnsureSuccessStatusCode()? It disposes of the Content of the message and throws HttpRequestException, but I fail to see how to programmatically handle it any differently than a generic Exception. For example, it doesn't include the HttpStatusCode, w...

09:35
ceven if not common, can still be 'expected'..which is not* what exceptions are for
hmm
iidk im not going to read the link. just giving my 2cent comment..take for what its worth.
I get you
@mr5 hwat?
I would also go against the accepted answer
09:38
@nyconing put you waife on you blog site
try {
    DoSomething();
} catch (Exception ex) {
    HandleFailure(ex);
}
mr5
mr5
@Squirrel.Downy das kool = that's cool
is perfectly fine, depending on how the HandleFailure works
if HandleFailure throws an exception, you want as much information in that exception as possible
therefor, the exception raised by the EnsureSuccessStatusCode() should be the inner exception
the only exception is that the exception being thrown by said function is probably not that informative in the first place
but in almost every case, catching the exception for a throw of a new exception beats having a success check yourself
hence why I think stuff like Int32.TryParse are stupid
mr5
mr5
@Shad with this, you give no chance to other response code such as 400 (bad request) so that you can diagnose the error more
09:42
TryParse stupid..whaa
Knowledge
hugs
mr5
mr5
or 401 (Unauthorized) so that you can issue another auth request to refresh them tokens
!~shiba
mr5
mr5
tip of the iceberg: it's almost always bad idea to check for access token expiration time. issuing the request and let the server determine it for you would be bestest
09:46
^
mr5
mr5
^:>
><
@ABuckau simple example:
@Wietbot evalcsharp
const String text = "999999999999999";

try {
	Console.WriteLine(Int32.Parse(text));
} catch (Exception ex) {
	Console.WriteLine("Stuff went wrong because " + ex.Message);
}

if (Int32.TryParse(text, out Int32 number)) {
	Console.WriteLine(number);
} else {
	Console.WriteLine("Something went wrong. I don't know what went wrong or why, I just know the thing I wanted to happen, didn't happen.");
}
Result: null
Output:
Stuff went wrong because Input string was not in a correct format.
Something went wrong. I don't know what went wrong or why, I just know the thing I wanted to happen, didn't happen.
or...
09:49
Result: null
Output:
Stuff went wrong because Value cannot be null. (Parameter 's')
Something went wrong. I don't know what went wrong or why, I just know the thing I wanted to happen, didn't happen.
or...
Result: null
Output:
Stuff went wrong because Value was either too large or too small for an Int32.
Something went wrong. I don't know what went wrong or why, I just know the thing I wanted to happen, didn't happen.
ahhh
when you are checking result codes, especially "success" booleans, you are missing the important information
hence why TryParse is not really useful, except if you allow stuff to be invalid and do it very often, at which point, the exception performance issues will rise
the only exception is when the thrown exception is not useful at all
for example, if the message is "Http status code was not in 200-399 range."
because that is what you are already checking for to determine if it is correct or not
at that point, there is no advantage of using either methods
10:16
HI everyone,I have a question
When I using block to open a memory stream and occur exception in the inside block so is that steam has been dispose?
mr5
mr5
nope
ah
I mean, yes
it's a short hand for try-finally
yeah, I also see it in Microsoft document
but I have a problem about memory when running backgroundjob
@sha
@NguyễnĐồng The using does dispose the resource even when an exception is raised
@bradbury9 sure.
In c 8.0 they added a form that does not require braces, I didnt know. c# using statement
10:30
In my code, I only use "Using block" to open connection, steam.. and when I run background job I see memory hold forever so I just guess the problem is resource hasn't dispose.
@bradbury9 Did you mead upgrade to 8.0 can resolve? bro
mr5
mr5
@NguyễnĐồng GC doesn't immediately gets triggered when you dispose a resource. That's normal.
p3k mimi OOM "completely natural phenomenon"
mr5
mr5
If you want to see the memory drop, you can try GC.Collect(). I think it is still not guaranteed to free resource immediately.
guaranteed clear memory: Environment.Exit()
mr5
mr5
^
10:41
@mr5 thanks
@nyconing haha funy man :D
10:56
I'm back
Hello
Hello
mr5
mr5
hello back
Hi rodent
@mr5 I like
Hello hello
Why does firefox not allow custom "search engines"
10:59
BECASUE SCRE YOU
Also they don't?
Hello
Or you mean in the top corner
HELLO
!~shiba
10:59
You can't just create a search keyword to work on any site
look im hooman
is having N number of small functions better
@CaptainObvious Wat why u need dis
or should I also to reduce the number, making them more configurable
Because I'm lazy
11:00
Yes Shad, Yes.
?
2nd one?
103
A: How to add a custom search engine to Firefox?

DisgruntledGoat I'd like to provide a URL such as "http://blahblah.com?search=%s" where Firefox replaces the %s with the content of the search box. You can do this with Firefox! Add a bookmark with that URL, where %s is the search query, then simply set a keyword for the bookmark. You can then search using <...

I can take parameters to determine and use if else in the function
And isntead of going to an application and then typing the search term in the native search box
instead of one function for if and another function for else
11:00
I want to just type om 6458445 and it take me where I want
?
which is better?
lol why does it need bookmarks
@Shad can you give a concrete example?
CreateEmployee(int empId)
CreateStudent(int studentId)....
can be turned into
CreateUser(int empId, Enum UserType)
right?
the idea is to have several small methods or use a common one like that
??
which is a better approach
in this case, I would probably go for CreateEmployee and CreateStudent
11:06
Why?
and make a 3rd function CreateUser which switches between the two types and then calls the other functions
CreateEmployee, CreateStudent, CreateManager, CreateWietlol, CreateMe.....N
remember,
all these methods are doing the same thing
are they?
11:08
@CaptainObvious Or a plugin/extension some random dude coded. But yeah "firefox rules!"
if the user type is just passed to the database or whatever, then sure one function is fine
well almost
I mean
Firefox is vastly superior in most instances
4
AHU
FIREFOX IS MASTARACE
Search engines can be added manually, with no fuss
just checked it
11:10
hmm
bow down to your master firefox
fox eat squirrels?
Just get into a seach page -> click the three dots in the far right of the address bar -> Add search engine
11:12
Squirrels around here have weapons
@mr5 you don't need that dash
haha
hehe
is it necessary for me to register a class in the dependency injection container?
can't I just use the old school, adding the reference and it's methods?
11:30
Use DI on those components that you want to abstract/decouple. Not everything must be an interface
I see code like
AddScoped<classX,classX>();
If you think it might become necesary, create the interface and use it. So later you can do the DI easily
AddScoped<classX,classX>();
> npm Teams
Share code and collaborate with the tools that make JavaScript the world's best software ecosystem
why this has been written?
11:32
> that make JavaScript the world's best software ecosystem
JavaScript the world's best software
ha thats a good one
JAVASCRIPT
WAT THE ACTUAL FRIRIRIRIRIRIIGGG
...
@Shad Maybe it was designed to work with DI but later was not used?
Sorry, had to bring ephesis to that
11:33
no it's funny haha
@bradbury9
my class isn't implementing an interface
Makes no sense to me... it should have been
AddScoped<IClassX,classX>();
should I still register it?
Ikr!
Lazy ass developer that didnt want to code an interface?
I am asking a different and basic question
I have a class X
I should use AddSingleton?
On DI interfaces should be used, otherwise there is no point. You are not decoupling the implementation
11:36
if I want it to be available to all the classes in my project
in adding to my services
okay
1720
A: AddTransient, AddScoped and AddSingleton Services Differences

akazemisTL;DR Transient objects are always different; a new instance is provided to every controller and every service. Scoped objects are the same within a request, but different across different requests. Singleton objects are the same for every object and every request. For more cl...

p3k speak Jabasukuriputo wa tawagotodesu
and the answer to my question is?
1- Use interfaces
2- If you want all DI calls to share the same object, AddSingleton
11:40
p3k speak わたし わ ねこ です
@bradbury9 you might not decouple the implementation, but you are decoupling the responsibility of instantiation
for example, HttpClient doesnt have interfaces it implements, but in the constructor, you can pass some listeners and converters to change the implementation
Yeah, but isnt the best thing of DI the ability to decouple the implementation?
passing it via DI enables you to change those listeners and converters
and the properties of that HttpClient class are part of that implementation
it would be better if it also implemented an interface which contained the important methods, but not having an interface doesnt necessarily mean that DI is meaningless
@bradbury9 thank you
@bradbury9 why Should I use Interface when there is absolutely no need
my question isn't about interfaces
it was about storing adding a class I created in services or not
why not just have reference in the class file and use the methods of the class
11:49
p3k speak 哎喲喵喵喵喵喵
because if you just use the method, then your class is less reusable
don't get you
using classX;


class Y{
X.A();
}
mr5
mr5
JAVASCRIPT
IS
DA
FUTURE!
should I add classX in services.AddSingleton()?
and then use it like
class Y{
Y(X x)
{
x.A();
}
}
??
11:53
Look
to da future
shape
da future
@Wietlol
public class UserCache : IUserProvider
{
	private IUserProvider UserProvider { get; } = new DatabaseUserProvider();
	private IDictionary<String, User> CacheMap { get; } = new Dictionary<String, User>();

	public User GetUser(String name)
	{
		if (CacheMap.ContainsKey(name))
			return CacheMap[name];

		var user = UserProvider.GetUser();
		CacheMap[name] = user;
		return user;
	}
}
am I being stupid?
for example this
mr5
mr5
@CaptainObvious I just tried FF again yesterday. Most of the sites I visited are lagging.
11:53
no not your example
look at mine
it is a cache for loading user objects
sorry
mr5
mr5
WebKit rendering is still far superior compared to FF
it loads the user objects from a database (new DatabaseUserProvider) and caches them in a dictionary
mr5
mr5
@Freerey why? what's wrong with my hyphens?
11:54
now, I cannot use this cache for something other than the database users
@mr5 I can tell you're using them to give pauses where no pause is necessary
so, if someone has a web service doing the loading, I have to write another UserCache class that uses the WebServiceUserProvider
yes
but what if the DatabaseUserProvider is determined by configuration like sometimes its a file sometimes a database depending on the server
then you still need to extract out that instantiation
(keep in mind, the code above is BAD)
11:57
alright
specifically this line:
private IUserProvider UserProvider { get; } = new DatabaseUserProvider();
mr5
mr5
@Freerey okay. I still need to learn to determine the correct pauses in a sentence.
probably can put some async to it but thats nitpicking
everything else is probably fine
don't mean to sound rude, but how much do you read?
11:58
oh yea, async...
mr5
mr5
@Freerey everyday 25 hrs a day!
as long as I am awake, I am reading everything I can :D
oh yea? name every article ever written
mr5
mr5
:D
02:00 - 12:0012:00 - 19:00

« first day (3561 days earlier)      last day (1604 days later) »