fabiochiu/medium-articles huggingface dataset:
Amal Totkay Reflection
By: Ahmad Raza
Tags: Amal Fellowship, Amal Totkay

I found those 5 tips in myself through the Amal lesson part “knowing yourself” as it helped me a lot to know about myself. Before that, I never thought to write and mention my good or bad habits openly but I did and now I am working on my habits to make them suitable for me. To make them helpful in making my decisions.

As discussed their takeaways are :

I have to keep myself realizing what I am doing. I have to do self-talk as well as question-answer my own self to know inner “why”.I have to engage more and more people basically strange people to come out of my fear of talking.I have to create new habits in a sense which makes me add new little features in myself on daily basis. I have to ask people for help as I am cannot do everything all alone.

Getting out of my comfort zone and create new habits are my favorite ones as getting out of my comfort zone to realize about things I am afraid to do, so the basic task here is to do those things to make myself strong in front of the world. Creating new habits cover everything for me as to talk myself I should do it more to know my “whys”.To create the habit of asking people for help so I can develop an understanding of teamwork.

I am already working on coming out of my comfort zone as I felt speaking English is not necessary for me and I don’t see I need that too. So in past, I avoid speaking English but in the last many days I am doing work on that I am coming out of the hesitation of speaking English as well as in front of people.

For a growth mindset, I can create new habits as to if I want to learn something I have to work on it as soon as possible. Besides that I can keep asking for help on daily basis it will increase the trust level within my office colleagues.
Amal Totky
By: Rida Majeed
Tags: Amal Fellowship, Amal Academy, Self, Growth

Amal shared a list of totky for developing a growth mind set. These totky are very useful to develop a growth mind set. Following are the amal Totky…….

1.Self talk

2.Get out of your comfort zone

3.Creat new habits

4.Ask people help

5.Fake it till you make it

All of these are so helpful for mind growth. Like if I start talking to my self and recalling what I learnt today, what type of work I did today to come closer to my dream or goal.This therapy surly useful for mind growth…… My favourite totkysss are

1.Self talk

2.Get out of your comfort zone

3.ask people help

I will differentially try all of these totkasss specially self talk and ask people help.

I’m already practicing to getting out of my comfort zone… This is not easy at all for me but I know I have to do this at any cost because without getting out of it I can not grow and can not learn new skills. If you want to excel in your career you have to come out from your comfort zone. In every session of amal I push my self to come out of my zone and actively involved in classes.

Surly from now i will start talking to myself for mind growth.I will spare some time to recall that i did all day, what step I took today to come closer to my dream, what good things i did today and what new thing I learnt today. Positive self-talk can help you improve your outlook on life. It can also have lasting positive health benefits, including improved well-being and a better quality of life. However, self-talk is a habit made over a lifetime.

I’ll Ask people help. It is very good totka to grow your mind but I will make sure that is I am asking help to right people.

At the end I want to say that all of these totakaas are just amazing……. We should implement these Totky in our life for growth mind set.
Self-Realization: An important tool for success
By: Muhammad Rahim Usman
Tags: Amal Fellowship, Amal Academy

I am excited to write about the experience that I recently had with myself and it was about pondering the problem or gap I would want to work on as my Mega Project. In this blog, I will discuss briefly my problem statement, how I refined it and how was the experience. Let’s begin with my problem statement.

Problem Statement

“To develop a platform for inculcating the importance of “Knowing and recognizing yourself” in the young generation that will help them to select their career smartly by themselves.”

Pakistan is in dire need of a career awareness platform for our high school and college students. 64% of Pakistan’s population consists of youth and most of them are unaware of themselves that what they want to in their lives. So, it’s very important to have a clear understanding of yourself.

The career choice of more than 80% of our youth is based on the interests of parents, friends, and society but they neglect interest or they even don’t bother to think about what will be good for them. Having a clear understanding of their self will not only help them choose the right career, but it will also play a crucial role in the development of Pakistan.

You will say that we all know about it. Now what!

Take the example of a self-aware and career-oriented candidate. What benefit can we get from them?

Let’s count a few:

1. He will remarkably perform well in studies

2. He will definitely look for ways to apply what she learned by getting a job, starting a new business in that field

3. After marriage, He will let his children dream big and achieve big. This will break the chains and parents will be well aware of future needs. They will be able to properly guide and allow their child to go for interest rather than their wish.

4. Every house will have at least one child who wants to make his/her mark. It will give why to every child in Pakistan and it will drive us to Quid-e-Azam ka Pakistan.

If I consider my example, I have got the support of my family and got a good bunch of teachers but not every one of us gets the same opportunity. Its one of the biggest factor in our decline that we are not utilizing our young blood. Many talents could not come up just because they don’t have the necessary resources and are unaware of the modern world’s trends. There should be a platform which would lead our youth towards the pursuit of their dreams.

Final Remarks

If you want Pakistan to be Pakistan of Quid-e-Azam, you have to urge your majority population to play a role in the country’s progress rather than wasting time in useless activities.

Let’s level the grounds for all the students by properly guiding them.
Thalassemia Affectees
By: Warda Nizam
Tags: Amal Fellowship, Thalassemia, Megaprojects

My idea for Mega Project was to help the Thalamessia patients. As we all know that thalassemia patients' lives depend on blood transfusion. Pandemic has already made many things difficult for the people, but these patients are also victims of the Covid-19 but indirectly. Due to lockdown and fear of transmission, the lockdown has been lifted worldwide without thinking that this has put thalassemia patients’ lives in danger because of a blood shortage.

When I talked with the President of Help International Welfare Trust (HIWT), she said many things can be done for these survivors. Because this covid has badly affected the patients and we don’t have many blood-banks facilities, especially for thalassemia patients.

Problem statement :
Developing a Growth Mindset AMAL TOTKAY
By: Abdul Rehman
Tags: Amal Fellowship, Amal Academy

Developing a Growth Mindset AMAL TOTKAY

Individuals who believe their talents can be developed (through hard work, good strategies, and input from others) have a growth mindset. They tend to achieve more than those with a more fixed mindset (those who believe their talents are innate gifts). This is because they worry less about looking smart and they put more energy into learning.

To develop a growth mindset I found some “Amal Totkay”

Self-Talk

So what is self talk? Self-talk is your internal dialogue. It’s influenced by your subconscious mind, and it reveals your thoughts, beliefs, questions, and ideas. It Could be positive as well negative Consider the following two inner statements:

“I’m going to speak up in the meeting today because I have something important to contribute.” This sounds like a positive plan and attitude.

“I don’t think I want to speak up in the meeting today because I’ll look foolish if I say the wrong thing.” Contrast this negative comment with the statement above.

2. Get Out of your Comfort Zone

It’s much easier to remain within the boundaries of where you feel comfortable than it is to face the fear of venturing beyond them. But by limiting yourself to what you already know, you’re likely missing out on professional opportunities, life experiences, and personal growth.

3. Ask People Help

Asking for help doesn’t mean you’re stupid or inadequate, it simply means you need help with something specific for a time. Instead of seeing that we are giving others an opportunity to contribute, we think that asking for help means we are a burden.

* My Favorite tip ……. (Fake It till You make it)

Chances are you’ve heard the old aphorism “fake it ‘till you make it,” meant to suggest that by imitating confidence, competence, and/or an optimistic point of view, you can imbue your life with those qualities for really real — usually in work, but also in relationships, or even with regard to your moods. Even if we don’t fully buy into the new mindset, we should try acting as if we were. It will eventually help us in developing our growth mindset.

What I have done is start implementing these things in my daily routine to get that growth required to achieve my dream.

“To get what you wanted in life, you must inspire trust — even if you intended to break it.”
Developing a Growth Mindset
By: Rabbia Mohsin
Tags: Amal Fellowship, Amal Academy

Developing a Growth Mindset

Growth Mindset: In a growth mindset, people believe that their most basic abilities can be developed through dedication and hard work. brains and talent are just the starting point.

Fixed Mindset: In a fixed mindset, people believe their basic qualities, like their intelligence or talent, are simply fixed traits. They spend their time documenting their intelligence or talent instead of developing them.

There are 5 tips of Growth Mindset are discussed in Amal totkays .These are very helpful for my personal and professional life .

These are :

1. Self Talk

2. Get out of your Comfort Zone

3. Create New habits

4. Ask people helps

5. Fake it till you make it

How did they find the 5 tips?

All the tips discussed in for developing a growth mindset(Amal totkay). These are very valuable tips for improving myself.

2. What are their takeaways?

These tips are very interesting and impressive for the development of growth mindset it helps self improvement, enhanced brain development, we can lower stress, anxiety and depression. Through them we can improves our work relationships and performance levels.

3. What were their fav tips?

All tips are helpful but my favorite is self talk because positive Self talk allows me performers to be more relaxed and focused. positive self talk creates happiness and excitement that lead to successful performance.
WASTAGE OF FOOD AND HUNGER
By: Kazim Abbas
Tags: Shortage, Amalkindness, Amal Fellowship, Food Waste, Amal Academy

Pakistan is a lower middle-income country and the sixth most populous in the world. While undernourishment has slightly declined over the last two decades, it remains “moderately high”. Strictly speaking, Pakistan is a food surplus country and a series of good harvests has meant that food availability is high. Despite that, 60 percent of the country faces food insecurity, with many of the country’s poorest people unable to afford an adequate diet.

Although food production has increased and Pakistan was able to export a record 1.4 million tonnes of wheat last year (total food exports increased by 1.08% in the same period), hunger and malnutrition remain alarmingly high. According to a 2016 report by the Food and Agriculture Organization, Pakistan’s performance in reducing the prevalence of undernourishment is the second-worst in the region

Extreme Deprivation:

The issues, experts say, are socioeconomic — that is, just because food is available, does not mean people can access it.

“There are four key pillars of food security in Pakistan: The first is availability, then accessibility, utilization and stability,” says Dr Ambreen Fatima, senior research economist at the Applied Economic Research Center of the Karachi University.

In Tharparkar, where Mithi Civil Hospital is, all four are lacking, she explains, adding that in other parts of the country they are present only to varying degrees.

In our surveys we came across the kids who had never eaten an apple, and when we offered him an apple he was reluctant to take the bite wondering whether it was an edible thing or not. DR Kaiser (A veteran economist)

Pakistan is quite well off in wheat production,” comments Dr Kaiser Bengali, a veteran economist, who has done field research on poverty and hunger in the country, but adds that much of it is sold for export.

This means ordinary people in the country may not have access to it, and if they do they may not have the resources to pay for it.

“Affordability is the biggest challenge here in Pakistan,” he says.

“In our surveys we came across the kids who had never eaten an apple, and when we offered him an apple he was reluctant to take the bite wondering whether it was an edible thing or not, In another case a family had never had eggs in their whole lives, he adds.” (DR Kaiser)

Here our main concern is that, to provide food to the people who have no enough money to buy and for homeless people. Almost 40% of total food in Pakistan are total in wastage. Sindh’s high number of child deaths are the result of a vicious poverty cycle that begins with malnourished. We will build a team that collect all the extra food from restaurants, homes, halls and give this food to them who can’t afford it and to who have nothing to eat. So that we can be able to overcome this shortage and wastage of the food.
Don’t Fake it till you Make it. Fake it till you become it.
By: Muhammad Faizan Mirza
Tags: Amal Fellowship, Amal Totkay, Amal Academy, Self Talk, Fake It Till You Make It

Don’t fake it till you make it. Face it till you make it.

Get up. Work hard. Fail. Stand back up.

Face it again. Do a little better. Fail again. Get up back.

Repeat.

Amal Totkay made it further simple for developing a growth mindset. These totkay includes five helpful tips.

1- Self Talk

The very first tip is as simple as telling yourself that yes you can do it. A growth mindset person always talks to themselves as they are talking with someone they love.

Self talk is dialogue between you and your subconscious mind. a positive self talk reveals your ideas, questions, beliefs, and your thoughts.

Self talk is a very powerful tool for building confidence and reducing negative thoughts. A growth mindset who master themselves in positive self-talk are more productive, confident, proactive and motivated.

2- Get out of your comfort Zone

Accepting new challenges and facing new problems makes you get out of your comfort zone. People living in their comfort zone always keep moving into a circle. For making some out of box progress, we need to get out of our comfort zone.

The ability to take risks by getting out of your comfort zone circle is the key for making success and grow in life. comfort zones are where we jailed ourselves due to fear.

3- Create New Habits.

For a growth mindset we should keep learning all life. We should keep making new and positive habits and eliminating bad habits from our lives. We should never stop building up positive and new habits. We should daily adopt something new, something unique, something different.

“We are what we repeatedly do. Success is not an action but a habit”

Aristotle.

4- Ask People help

Be strong enough to stand alone.

Smart enough to know when you need help. and brave enough to ask for help.

Most of us face a very hard time asking for help in time of need.

5- Fake it till you make it.

The most important step is to fake success till you make success in your life. This totka can be implemented in every aspect of life.

If you want to be happy, just do what happy people do.

If you want to be a millionaire one day, just adopt the habits of successful persons.
AMAL TOTKAY
By: Hafiz Awais Rasool
Tags: Amal Fellowship, Amal Academy

Flexible mindset source of happiness

We should always be ready to learn something new in our life. If we really want to learn something new ,we want to enjoy every moment all the time ,then we have to make our mindset flexible.

It would not be wrong to say at all, i found these five tips mixture of happiness. Development a growth mindset always tries to make you learn from your mistakes.

Just as Apaa Zubaida’s Totkay were good for your health similarly Amal Totkay are essential for your growth mindset.

There are following amal totky,

1.Talk to yourself

2.Get out of your comfort zone

3.Create new habits

4.Ask people help

5.Fake it till to make it

Reflection on Amal Totkay:

How did they find the tips?

They find these tips by knowing yourself, getting rid of negativity, and also by working on amal principle of progress like KAM KAM KAM.

2. What are their takeaway?

Always try to give their best whatever circumstances, prefer to work with growth mindset. They try to act like a leader.

3. What were your fav tips?

My fav tips is “self talk” whenever we do not try to knowing ourselves till that time we are not able to do something better .

4. What have you started implementing already?

yes, but always faced problem. After joining Amal academy i get a chance to know myself and try to get out comfort zone.

5. What can you do to develop a growth mindset beginning from today?

I have started when i took first session of amal academy. I hope i will learn more by working on these tips.
On the mission to end plastic pollution
By: Urooj Fatima
Tags: Amal Fellowship, Amal Academy, Plastic Pollution, Endplasticpollution

Being a human-being and especially a Muslim, it is our responsibility to work for our environment and for the welfare of mankind. We use plastics for our daily life uses like we use shampoo, packed food, hair-brushes, tooth-brushes. Cutlery, crockery, pens, electronics, bags, containers, bottles and the list is so long, all in single use plastic packaging.

How horrible!

For our benefits, we are destroying our environment. We are losing our natural beauty. We are depleting the resources. We are causing trouble to the other species living in the same environment as we do.

not only humans, but other species also get badly effected by the pollution we are causing on the Earth

This is not what we should be doing right now!

Rather we should work for the betterment. For the good endings. For the ideal life having no destructions and problems.

mountains of trash every where

So, I also decided to work for my environment, for my motherland and for my place which I love the most n the world. I decided to end the plastic pollution over here by working as a volunteer.

I came up with an idea which was really beneficial. Cost-effective and needed no as such high resources. I thought to make my community aware of the plastic pollution, its causes and its consequences. Also where does it end to!

I observed my surroundings and found out that how terrible the situation was. The mountains of the plastic trash were getting higher and higher every day.

this is where all the single use plastics end up into!

I raised awareness amongst my people.

They were so appreciative.

They volunteered themselves too and said that from now on, they will recycle thee plastic and reuse them as much as possible.

It really made me happy. I have seen the results. People don’t trash now. They save their area and guide their children to not litter anywhere.

Just a little effort made the whole community aware and clean!

This is the beauty of the volunteer work and team work!
Chapter 4 | Variables
By: Kumar Anurag
Tags: C Sharp, Variables

In this chapter we will learn about variables in C#.

The following code (wait for it to load) will explain the same.

I hope you enjoyed learning this chapter. See you in the next one. Bbye!
Chapter 11 | Type Casting
By: Kumar Anurag
Tags: C Sharp, Type Casting

In this chapter, we will learn how to do type casting and what are the various types of type casting in C#.

The following code (wait for it to load) will explain the same.

I hope you enjoyed this lesson. See you in the next one. Bbye!
Chapter 10 | Operators
By: Kumar Anurag
Tags: C Sharp, Operators

In this chapter we will learn about the operators and how to use them in C#.

The following code (wait for it to load) will explain the same.

I hope you enjoyed this lesson. See you in the next one. Bbye!
Chapter 7 | For Loop
By: Kumar Anurag
Tags: C Sharp, For Loop

In this chapter, we will learn how to write for loop statement in C#.

The following code (wait for it to load) will explain the same.

In hope you enjoyed this lesson. See you in the next one. Bbye!
Chapter 6 | Switch Case
By: Kumar Anurag
Tags: C Sharp, Switch Case

In this chapter, we will learn how to write switch cases in C#.

The following code (wait for it to load) will explain the same.

I hope you enjoyed this chapter. See you in the next one. Bbye!
Chapter 5 | Conditions
By: Kumar Anurag
Tags: C Sharp, Conditions

In this chapter we will learn how to write conditional statements in C#.

The following code (wait for it to load) will explain the same.

I hope you enjoyed this chapter. See you in the next one. Bbye!
Chapter 8 | While Loop
By: Kumar Anurag
Tags: C Sharp, While Loop

In this chapter, we will learn how to write while loop in C#.

The following code (wait for it to load) will explain the same.

I hope you enjoyed this lesson. See you in the next one. Bbye!
Async Lambda in Task.Factory.StartNew
By: Rico 技術農場
Tags: Net Core, Async, Csharp

Learn more. Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Make Medium yours. Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore
Integrate IdentityServer 4.1 With ASP.NET Core 3.1 (Part 2-Securing web API with IdentityServer)
By: Suvethan Nantha
Tags: Identityserver4, Net Core 3, API, Csharp

In Part 1 of this series, we learnt how to build Identity Server 4.1 for various authentication and authorization. Now let’s look at how we can secure our web APIs with the IdentityServer. Let’s move to the implementation.😃

Create a API ASP.NET Core Web application

Provide name for the API project

Select API project template and click on “Create” button

2. Install following nuget packages

Install-Package IdentityModel -Version 4.5.0

Install-Package IdentityServer4.AccessTokenValidation -Version 3.0.1

Install-Package Microsoft.Extensions.Platform.Abstractions -Version 3.0.1

3. Add following codes inside ConfigureServices section and resolve all the references

//enabled to see auth identity server related error

IdentityModelEventSource.ShowPII = true;

.AddIdentityServerAuthentication(options =>

{

options.Authority ="

options.RequireHttpsMetadata = false;

options.ApiName ="webAPI";

options.SaveToken = true;

}); services.AddAuthentication("Bearer").AddIdentityServerAuthentication(options =>options.Authority =" https://localhost:44304 ";options.RequireHttpsMetadata = false;options.ApiName ="webAPI";options.SaveToken = true;}); // Add Cross Domain Policies

services.AddCors(opt => opt.AddPolicy("CorsPolicy", al =>

al

.AllowAnyHeader()

.AllowAnyMethod()

.AllowAnyOrigin()));

Identity Server can be started using Kestrel web server or IIS web server. Authority url will change depending on our selection.

Kestrel web server - https://localhost:5001

IIS web server - https://localhost:44304

We should provide the ApiName which will be used when authenticating with Identity Server. Further to that, we should set SaveToken to true to persist the token obtained from IdentityServer to Authentication properties ( we will need these tokens later)

4. Add following codes inside Configure section

app.UseCors("CorsPolicy");

app.UseAuthentication();

app.UseAuthorization();

5. Create Roles.cs class and add role constants as shown below.

public class Roles

{

public const string Admin = "Admin";

public const string Customer = "Customer";

public const string Maintenance = "Maintenance"; public const string AdminOrMaintenance = Admin + "," + Maintenance;

public const string AdminOrMaintenanceOrCustomer = Admin + "," + Maintenance+ "," + Customer;

public const string AdminOrCustomer = Admin + "," + Customer;

}

6. Adding the following lines in the controller methods to restrict API methods per Roles

[Authorize(Roles = Roles.AdminOrMaintenanceOrCustomer)]

Finally, we need to pass the access token we obtained from IdentityServer token endpoint as a Bearer token when requesting API. Please have a look at Part 1 section for more details about how to generate token.

That’s all 😅 We have successfully secured our web API using Identity Server.

Sample response after calling API

This concludes Part 2 “Securing web API with IdentityServer” 😊
Chapter 1 | Hello World
By: Kumar Anurag
Tags: C Sharp, Hello World

Okay, so let’s start C# programming with classic Hello World Program.

First of all, make sure that you have .NET SDK installed in your system. If not, then go install from official microsoft website. At the time of writing this chapter, it is available on the following website.

Now, we need to run some dotnet commads.

STEP-1 : In your working directory, create a new folder 01_HelloWorld and go into that folder and type this command dotnet new console .

and go into that folder and type this command . STEP-2 : Now, open the file Program.cs , you will find that code of Hello World is already written there.

, you will find that code of Hello World is already written there. STEP-3: Now, if you want to run this program, then open terminal inside 01_HelloWorld and type this commad dotnet run .

Here’s the source code (wait for it to load):

This is it for this chapter. See you in the next one. Bbye!😊
NDepend ile Statik Kod Analizi
By: Oktay Kır
Tags: Yazılım, Static Code Analysis, Software Engineering, Csharp, Programming

By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information about our privacy practices.
Slack Logging (Webhook) with Worker Service in .Net Core (C#)
By: Kemal Akçıl
Tags: Net Core, Csharp, Slack, Webhooks, Slackbot

In this article, I’ll try to instill the idea of using Worker Service and Slack together, where you can perform scheduled and repetitive operations in .Net Core. You can simply create your Worker Service in .Net Core 3.0 with a command line or from the “Create a new Project” section. However, this is not mandatory! You can also use Worker Service in your MVC or API project etc.

with a command line

with creating new project

In this walkthrough, I will create a Worker Service, include a Logger for Slack and run it. But I won’t publish it. By the way, It is also possible to publish for Linux Daemon or Windows Service.

After installation, we will see a background class named Worker.cs by default.

Worker.cs

Now let’s examine the contents of our Worker.cs file. The contents of our file are given below. Worker.cs is inherited from an abstract class named BackgroundService. There are crushable methods called StartAsync, StopAsync and ExecuteAsync in this class.

BackgroundService

It is not mandatory to use the StartAsync and StopAsync methods. When these methods are not used, the service will call the ExecuteAsync method to start running. We will not use these two non-mandatory methods as we will briefly mention it here. We will not use it, but if you want to install it as a Service, we need to install extra packages (it will depend on the broadcast environment) so that we can run it. All of these are in the picture below. You can install it using the NuGet.

necessary packages

In the next section, we will touch on the Slack side to perform logging. We will do logging using two methods. You don’t need to install a package for this. A Post request is sufficient.
Code refactoring tools like Resharper help a lot in getting familiar with the new features of C#…
By: Bart Van Den Abbeel
Tags: Resharper, Refactoring, Csharp

Code refactoring tools like Resharper help a lot in getting familiar with the new features of C# every new release.
Is console app fun?
By: Muhammet Kandemir
Tags: Console, Fun, Learning, Csharp, Improvement

Let’s start how you can improve on programming with the console app. Firstly, you need to understand console app is not just for junior developer. I am a senior developer and I’m still using console app for some scenarios. To make it clear, many services which works on background like e-mail sender, notification sender, calculating some things at specific moments is written by using console app on Linux. Also, your logs is saved with a basic command you know. It is “Console.WriteLine” in C# or “printf” in C or anything else according to the programming language. You don’t need to force yourself to fix a problem on a genius way to show you’re a professional developer. Actually, it mentions that you still should improve yourself with more project. Secondly, you can do as many examples as possible to be senior developer easily. I’ll explain that on giving example about C#. Most of us know that C# essentially is used with Visual Studio. But its size too much and your pc is not enough to run it unless your pc has powerful hardwares like Intel I3 CPU, 8GB RAM. There is one way to solve this problem which is Visual Studio Code. I can’t say that it is better than Visual Studio but it’s requirements less as hardware. So we can create a console app on Visual Studio Code and start to write our code. However, don’t forget you must know how to use terminal. Visual Studio provides us many things on an easier way which doesn’t include terminal but it causes more size and performance problem. If we want to write a program without Visual Studio, we must learn terminal. It’s very simple and it is not hard to learn. There is already one command to create a console app that “dotnet new console”. Let’s examine this on a screen shot;

I knew we could do it! Now, we have a console app. We can do anything we want! Wait Ellon, we’re coming!
UniLecs #Task. Plus one to Linked List
By: Albert Davletov
Tags: Unilecs, Algorithms, Linked Lists, Csharp, Programming

Learn more. Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Make Medium yours. Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore
Ref structs in async methods
By: Stefan Daniel Schranz
Tags: Asyncawait, Csharp

Today, I had the chance to review a pull request of a colleague at work, containing code along these lines:

private async Task<CustomType> DoStuff(byte[] src)

{

var data = Task.WaitSafe(() =>

{

var utf8Reader = new Utf8JsonReader(src);

return Task.FromResult(JsonSerializer.Deserialize<CustomType>(ref utf8Reader));

}); // Some proper tasks to await here, just use some imagination :)

await Task.CompletedTask; return data;

}

(Note that Task.WaitSafe is a custom method we use, containing some Task.Run(…).Result, as well as exception handling.You get the point 😉)

I thought that this looks kind of weird. Given that this part of the JsonSerializer API is synchronous, why wouldn’t you just run it as such?

So I went ahead and tried something I thought was quite obvious before proposing a solution:

private async Task<CustomType> DoStuff(byte[] src)

{

var utf8Reader = new Utf8JsonReader(src);

var data = JsonSerializer.Deserialize<CustomType>(ref utf8Reader); // Some proper tasks to await here, just use some imagination :)

await Task.CompletedTask; return data;

}

Well, here is what Visual Studio has to say about this:

I thought, huh, I do remember this. in, out and ref are not allowed in an async context. So here is my proposed solution with a local function:

private async Task<CustomType> DoStuff(byte[] src)

{

CustomType Deserialize(byte[] source)

{

var utf8Reader = new Utf8JsonReader(source);

return JsonSerializer.Deserialize<CustomType>(ref utf8Reader);

}

var data = Deserialize(src);

// Some proper tasks to await here, just use some imagination :)

await Task.CompletedTask;

return data;

}

Cool, this works. However, on my way back to the parking lot after work, I couldn’t find peace thinking about the why.

So I spent my evening reading up and experimenting around a bit with sharplab, until I figured it out.

The problem lies in the Utf8JsonReader type, which is a ref struct. The problem with ref structs can be found here: MSDN Article.

Essentially, a ref struct is not allowed to be a field of a class. Why does this matter in an async context? Because the compiler converts an async method to a class, and all local variables are turned into a field, essentially. Here’s a short example:

static async Task Main(string[] args)

{

var myVariable = 5;

await Task.CompletedTask;

Console.WriteLine(myVariable);

}

Turns into:

And there we have it. Given that the compiler turns local variables into fields, and we just learned that ref structs cannot be fields, this is not possible.

Feel free to check it out yourself over at Sharplab
Implement bubble sort in C# the value of array given by the users
Tags: C, Program, Computer Science, Csharp, Codin

Implement bubble sort in C# the value of array given by the users codeboks ·Dec 17, 2020

Object: Implement bubble sort in C# the value of array given by the users. C# Projects with Source Code.

Code:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace code

{

class sort

{………continue code for click here…
Dangerous self-compiling malware. Antivirus programs work by comparing…
By: Sam Berry
Tags: Programming, Hacking, Malware, Csharp

Antivirus programs work by comparing files that you download or run to known malicious software. When you run an executable, your antivirus will scan it before it is executed.

This is effective — for most viruses.

Runtime compilation is a method that allows text to be compiled and executed as code at runtime.

If you are familiar with Python you might have seen the eval function, which allows you to send a string to the Python interpreter. This is not entirely the same because Python is interpreted rather than compiled, but it is a good example to explain the concept.

Example of eval in python

C#, on the other hand, is an example of a compiled programming language. The average virus is a program, possibly written in a language like C#, compiled into an assembly that contains lines of code that will ultimately put the victim at risk or steal something from the victim’s machine, and can be easily scanned and compared to other malicious programs, and therefore detected and removed.

But what if I told you that you could make a virus that contained no malicious code?

That’s right — well, sort of.

This article by black wasp demonstrates runtime compilation with C# (in summary it’s pretty easy to do)

If you had a program that downloaded encrypted text from a server, decrypted it and compiled the code into the memory at runtime, the executable wouldn’t contain any malicious code and therefore would not be seen as a threat. The code it downloads, however, would be a different story. It could be highly malicious but wouldn’t be detected if the program uses secure encryption like AES to cipher the text.

In 2018 a cryptovirus much like the notorious wannacry ransomware was observed that encrypted the victim’s files and demanded 0.14 bitcoin for decryption, which would have been worth about £700.

Ransom note, courtesy of bleeping computer

Normally, the cryptovirus code would have been recognized and the threat would have been neutralized, however because of the use of runtime compilation, the virus went undetected.

While there are not many documented cases of the use of this technique in malware, I’m interested to see whether this technique is seen in future malware analyses.
C#, XUnit, Moq Typing lines of code to mock dependencies of a class under test is one of those things no software developer enjoys. Having to rearrange these mocks…
By: Tuba Kaya
Tags: Open Source, Moq, Xunit, Unit Testing, Csharp

Generate mocks with AutoSetup - C#, XUnit, Moq

Typing lines of code to mock dependencies of a class under test is one of those things no software developer enjoys. Having to rearrange these mocks after changes in the implementation makes it even more time consuming. Thanks to Roslyn and Visual Studio analyzers, this can be automated.

AutoSetup generates the mocks and an instance of a class under test automatically. It finds the class under test based on the naming convention.

For an example class under test such as this one:

It would generates mocks as shown here:

If you are using XUnit with Moq and still typing those lines to mock each dependency for a class under test, just add AutoSetup nuget package to your unit test project and generate mocks automatically.
Write a C# program of throwing an exception when dividing by zero condition occurs
Tags: Coding, Code, C Sharp Programming, Csharp, Assignment

Write a C# program of throwing an exception when dividing by zero condition occurs codeboks ·Dec 13, 2020

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace code

{

class Program

{

static void Main(string[] args)

{……..continue code for click here…
Sorting Users In The Sitefinity Backend
By: Daniel Plomp
Tags: Sitefinity, Aspnet, Telerik, Csharp, Sitefinity Development

Dilemma

Sitefinity has a friendly user interface for all kinds of activities. One of them is maintaining the backend users that have access to the CMS. Since version 8.x and higher, there is a bug that when users are sorted by name in the backend both in ascending or descending order, they are not sorted correctly.

Progress confirms this bug, and you can read more information about it here:

Bug 230852 see http://feedback.telerik.com/Project/153/Feedback/Details/230852

Solution

We can work around this issue by writing some custom code in our Sitefinity Web application.

Step 1. Create a custom class in your project

First, we are going to add a custom class in our project that implements the IUser interface. This way, we can adjust some of the methods that Sitefinity needs for showing and sorting users in the backend.

I’ve named my custom class SortableUsers.

Step 2. Write the implementation

When you have your class ready and implement the IUser interface, it is time to implement each method needed by the IUser interface.

Almost every method is making use of the BaseService property defined on top of the class. The GetUser() and the SearchUsers() methods need a custom implementation to get the sorting function to work correctly.

Step 3. Register our SortableUsers service

To let Sitefinity use our custom service instead of its own service, we need to register our custom service and map it to the default one. We will do this when the Sitefinity bootstrapper is initialized.

Step 4. Build your project and sort that users

When all the code is in place, you may want to build your project and check out the working solution!
Tutorial 1:- Get Going to F# from C# and Vb.net
By: Barath Kumar Basker Rangareddy
Tags: Net Core, Microsoft, Fsharp, Csharp, Netframework

Requirement:- Be aware of .Net and also know the basics of C sharp

F# is a functional language. In F#, functions work like data types. You can declare and use a function in the same way like any other variable. In general, an F# application does not have any specific entry point. The compiler executes all top-level statements in the file from top to bottom.

However, to follow procedural programming style, many applications keep a single top level statement that calls the main loop.

Making your Hello World Program:-

printfn “Hello World”

Actually some of the differences include it is not at all similiar to c sharp directly in rules such as semi colon and paranthese.

Comments in F#

It has similiar style as in most programming language

// For single line comment

(* For Starting of multiline comment and *) for ending multiline comment

Other Helpful Resources
The single best tip for running Asp.Net Core microservices
By: Morten Ricki Rasmussen
Tags: Web Development, Programming, Csharp

Lets make a massive reduction in your Memory Usage

TLDR;

Add this line to your .csproj file

<ServerGarbageCollection>false</ServerGarbageCollection>

as a part of the property group holding your target framework, like so

<PropertyGroup>

<TargetFramework>netcoreapp3.1</TargetFramework>

<ServerGarbageCollection>false</ServerGarbageCollection>

</PropertyGroup>

Can you tell me a bit more?

So, one of the things behind running microservices, or any service at all, is the constant use of memory.

Somewhere out there, you might be running a service or two, and depending on the environment and the programming language behind that service, it might require more or less memory just to stay alive, and running an Asp.Net Core service is no different.

Just spinning up a small service in Asp.Net Core requires up to 150MB of memory, so picture you’re running a microservice setup containing just a couple of services will quickly require atleast 1GB of memory.

As you might already be thinking, this will quickly add up, so how ca we fix this?

Well, Microsoft themselves has a nice post about Garbage Collection in .Net — Here they explain that there are two different types of Garbage Collection in .Net WorkStation GC and Server GC.

To tell it short, WorkStation GC is more aggressive than Server GC and therefore collects more often.

Testing WorkStation GC we took a simple Asp.Net Core Crud Api and moved from Server to Workstation GC. This Api is serving around 500 requests a minute and swallowed around 230MB of memory.

After moving to Workstation GC the api fell to around 85MB of memory, with no noticeable performance degrading or increased CPU usage on the machines.

But

This is not a miracle cure, you might have different needs, throughput and so on, that could mean that moving from Server to WorkStation GC could have a performance impact on your service

Do you already run WorkStation GC? If not, try it out — And please share your results
Native Android text sharing to Whatsapp contact in Unity
By: Suneet Agrawal
Tags: Unity Game Development, Unity3d, Csharp, Unity, Android

In the previous blogs, we learnt about how can we trigger native Android text, image or any other format file sharing in Unity App. A lot of you have asked me about how can we share some text directly to a WhatsApp contact.

If you have not read the previous medium posts, I would strongly recommend to read them first. You can read them on the links below.

This post was originally posted at https://agrawalsuneet.github.io/blogs/native-android-text-sharing-to-whatsapp-contact-in-unity/ and reposted on Medium on 3rd Dec 2020.

Whatsapp is something which doesn’t require any introduction. It’s a conversation app used by millions of users across the world. These million users make it unique for developers also to give special attention when it comes to sharing some message through Whatsapp.

During recent times, I was asked multiple times in the comments section or even emails, if there is any possible way where we can send the text message directly to a WhatsApp contact?

Please continue reading at https://agrawalsuneet.github.io/blogs/native-android-text-sharing-to-whatsapp-contact-in-unity/
A Journey from PHP to .Net Core. A software engineer who works in PHP…
Tags: Net Core, Csharp, Travelportgds, Travelportaldevelopment, Gds Integration

ASP.Net Core

A software engineer who works in PHP but now switching toward .Net core. Mostly working on the data layer of an application so as a back-end developer I am developing web services, writing libraries, and do third-party web service/API integrations.

I have worked on different projects but for the last few years, I am working specifically on web services related to the travel industry. I have gained a very deep understanding of a web service/API belongs to one of the most popular giants of the travel industry called Travelport GDS.

So during my integration of Travelport universal API in PHP which is SOAP-based, I learned that the request sends to Travelport via SOAP library can be of two types OOP based or an Array, which is actually mapping internally by SOAP library and construct the desired XML request and send to Travelport and received a response in XML and converted back into object notation rather than return us a raw XML.

I always prefer the OOP way over the Array approach to construct requests as it gives me more flexibility and control over my request construction and off course data encapsulation and prevents me from reinventing the wheel for other requests as some parts of the requests are repeating in other requests.

So for me, the journey from PHP into .Net is not quite difficult despite the fact that C# is a strongly typed language and follows pure OOP concepts, I easily adjust in the .net environment. Before jumping into the .Net world I take a basic course from the plural site C# Fundamentals thanks to David and Uri who make this possible for me.

In this new journey, I decided to share my experience with you guys during development the issues that I faced and their solutions, so I am going to start with my first issue that faced during my request construction and the solution.

Problem 1:

The first problem that I faced in the Travelport UAPI search response is that Travelport returns search response data as a separate entity I mean an isolated object in the same response. You will need to apply logic and combine isolated portions and link them together in order to construct a list of complete flight objects.

So the problem that I faced during the construction of a flight object is a type casting issue. I have to cast the parent object into a child object.

Solution:

In order to cast a parent into a child (down-casting), first of all, I tried a simple solution straight away casting but that did not work. Then I found that we can do down-casting via JSON serialization/de-serialization. So below is the solution that I successfully applied in order to downcast the parent into the child.

using Newtonsoft.Json

var serializedParent = JsonConvert.SerializeObject(parentInstance);

Child c = JsonConvert.DeserializeObject<Child>(serializedParent);