Make Axios send cookies in its requests automatically.
You can use the withCredentials
property.
axios.get(BASE_URL + '/todos', { withCredentials: true });
Also it is possible to force credentials to every Axios requests
axios.defaults.withCredentials = true
Or using credentials for some of the Axios requests as the following code
const instance = axios.create({
withCredentials: true,
baseURL: BASE_URL
})
instance.get('/todos')
Source app settings from key vault
Complete reference:
@Microsoft.KeyVault(SecretUri=https://myvault.vault.azure.net/secrets/mysecret/)
Alternatively:
@Microsoft.KeyVault(VaultName=myvault;SecretName=mysecret)
Source: Use Key Vault references - Azure App Service | Microsoft Learn
Arrays are ordered collections of values, and they are perhaps the most commonly used data structure in JavaScript. Elements in an array can be accessed by their index, and arrays can hold values of different data types.
let myArray = [1, 2, 3, 4, 5];
console.log(myArray[0]); // Accessing the first element
Objects in JavaScript are collections of key-value pairs. They are versatile and can be used to represent a wide range of data structures. Objects are often used for creating dictionaries, maps, and records.
let person = {
name: "Maria",
age: 28,
city: "New York"
};
console.log(person.name); // Accessing a property
Keys are always strings (or Symbols, introduced in ES6). When you use non-string values as keys in an object, JavaScript implicitly converts them to strings.
Objects are generally used for a simple dictionary-like structure with string keys.
In this example, you can see how you can manually manage a transaction around your database operations, providing more fine-grained control when needed. However, for most scenarios, the default behavior of wrapping SaveChanges
in a transaction is sufficient.
using (var dbContext = new YourDbContext())
{
using (var transaction = dbContext.Database.BeginTransaction())
{
try
{
// Perform your database operations here
dbContext.SaveChanges();
// If everything is successful, commit the transaction
transaction.Commit();
}
catch (Exception ex)
{
// Handle exceptions and optionally roll back the transaction
transaction.Rollback();
}
}
}
In this example, you can see how you can manually manage a transaction around your database operations, providing more fine-grained control when needed. However, for most scenarios, the default behavior of wrapping SaveChanges
in a transaction is sufficient.
Need some mock data to test your app? Mockaroo lets you generate up to 1,000 rows of realistic test data in CSV, JSON, SQL, and Excel formats.
Mockaroo - Random Data Generator and API Mocking Tool | JSON / CSV / SQL / Excel
The definition of the CSS class
.rotate{
width:80px;
height:80px;
animation: rotation infinite 3s linear;
}
Here we added an animation property with a value rotation infinite 3s linear, which is.
rotation
: this is the name of the animation.infinite
: the animation should play infinitely.3s
: animation duration.linear
: play the animation at the same speed from start to end.Source: How to rotate an image continuously in CSS | Reactgo
Question: How do you convert a nullable bool? to a bool in C#?
Solution:
You can use the null-coalescing operator: x ?? something
, where something
is a boolean value you want to use if x
is null
.
Example:
bool? nullBool = null;
bool convertedBool = nullBool ?? false; // convertedBool will be false
The null-coalescing operator ?? returns the value of its left-hand operand if it isn't null; otherwise, it evaluates the right-hand operand and returns its result.
Question: How can I check if a string is empty?
Option 1: Check using ""
if (str === "") {
}
Note: to know if it's an empty string use === instead of ==. This is because === will only return true if the values on both sides are of the same type, in this case a string. for example: (false == ""
) will return true, and (false === ""
) will return false.
Option 2: Check length of string
if (!str || str.trim().length === 0) {
}
A callback is a function passed as an argument to another function. This technique allows a function to call another function. A callback function can run after another function has finished.
Example
Using a callback, you could call the calculator function (myCalculator) with a callback (myCallback), and let the calculator function run the callback after the calculation is finished:
function myDisplayer(some) {
document.getElementById("demo").innerHTML = some;
}
function myCalculator(num1, num2, myCallback) {
let sum = num1 + num2;
myCallback(sum);
}
myCalculator(5, 5, myDisplayer);
In the example above, myDisplayer is a called a callback function.
It is passed to myCalculator() as an argument.
Note
When you pass a function as an argument, remember not to use parenthesis.
Right: myCalculator(5, 5, myDisplayer);
Wrong: myCalculator(5, 5, myDisplayer());
To do a case-sensitive search in EF Core you can use an explicit collation in a query like
var customers = context.Customers
.Where(c => EF.Functions.Collate(c.Name, "SQL_Latin1_General_CP1_CS_AS") == "John")
.ToList();
Note: EF Core does not support operators on in-memory collections other than simple Contains with primitive values.
References
Resources
To align content like buttons to the right you can use CSS flexible box layout.
<div class='align-right'>
<button>Cancel</button>
<button type='submit'>Create</button>
</div>
The CSS to align the buttons on the right uses two properties.
.align-right {
display: flex;
justify-content: flex-end;
}
References
C# Lambda expression operator (=>) is a shorthand syntax for defining anonymous functions. It allows you to write compact and inline functions without the need to declare a separate method. Lambdas are commonly used in LINQ queries, event handlers, and functional programming. They improve code readability, enable concise operations on collections, and provide a flexible way to work with data and delegates.
In lambda expressions, the lambda operator =>
separates the input parameters on the left side from the lambda body on the right side.
Here's an example that calculates the square of each number in a list:
List<int> numbers = new List<int> { 1, 2, 3, 4, 5 };
List<int> squaredNumbers = numbers.Select(x => x * x).ToList();
// squaredNumbers will be [1, 4, 9, 16, 25]
In this code, we have a list of numbers. Using the Select
method and a Lambda expression x => x * x
, we square each number in the list. The Lambda expression takes an input x
and returns its square x * x
. Finally, we have a new list squaredNumbers
containing the squared values of the original numbers. Lambda expressions are versatile and enable concise operations on collections, making code more expressive and readable.
The spread (...) syntax allows an iterable, such as an array or string, to be expanded in places where zero or more arguments (for function calls) or elements (for array literals) are expected.
Spread operator doing concat
let arrayOne = [1, 2, 3];
let arraryTwo = [4, 5];
arrayCombined = [...arrayOne,...arrayTwo];
Add item using spread operator
let arrayOne = [1, 2, 3];
arrayNew = [...arrayOne, 3];
In the example below, we have a list of numbers. The ForEach method is called on the list and a lambda expression num => Console.WriteLine(num) is passed as the argument. This lambda expression takes each element num from the list and prints it using Console.WriteLine. The lambda acts as the action to be performed on each element in the list.
var numbers = new List<int> { 1, 2, 3, 4, 5 };
numbers.ForEach(num => Console.WriteLine(num));
Entity Framework Core 5 is the first EF version to support filtering in Include
.
Supported operations are Where
, OrderBy
(Descending)/ThenBy
(Descending), Skip
, Take
Some usage example
context.Customers
.Include(c => c.Orders.Where(o => o.Name != "Foo")).ThenInclude(o => o.OrderDetails)
.Include(c => c.Orders).ThenInclude(o => o.Customer)
Only one filter is allowed per navigation, so for cases where the same navigation needs to be included multiple times (e.g. multiple ThenInclude on the same navigation) apply the filter only once, or apply exactly the same filter for that navigation.
You can get private property like so:
Class class = new Class();
var privateProperty = class.GetType().GetProperty("privateProperty", BindingFlags.Instance | BindingFlags.NonPublic);
int propertyValue = (int) privateProperty.GetValue(class);
var privateField = class.GetType().GetField("privateField", BindingFlags.Instance | BindingFlags.NonPublic);
int fieldValue = (int) privateField.GetValue(class);
It is possible to use PUT without a body like
PUT /example HTTP/1.0
Content-Type: text/plain
Content-Length: 0
A sample would be the github starring API, which uses PUT with an empty body to turn on a star and DELETE to turn off a star.
Sometimes, we want to change an HTML5 input’s placeholder color with CSS.
To change an HTML5 input’s placeholder color with CSS, we use the ::placeholder
selector.
For instance, to set the input placeholder’s color to #909 we write:
::placeholder {
color: #909;
}
Here’s an example of how to invoke a private method using reflection in .NET:
MyClass myClass = new MyClass();
Type classType = myClass.GetType();
MethodInfo methodInfo = classType.GetMethod("MethodName",
BindingFlags.Instance | BindingFlags.NonPublic);
// Make an invocation:
var result = await (dynamic)methodInfo.Invoke(myClass, null);
Iqra Technology is an IT Solutions and Services Company. We are a salesforce and Microsoft partner company. We aim to provide cost-effective IT services within the customer’s budget range. We scrutinize, design, and develop solutions custom-made for the business necessities. We deliver services in various domains including CRM, ERP, e-commerce, CMS, business intelligence, web development, customized applications, portals, mobile apps, & RPA technologies. We provide IT services starting from $2100 per month and 2 weeks free trial. https://iqratechnology.com/
If you just switched to the new Windows version, here are some of the most interesting Windows 11 features that you should know about:
Who doesn't know this? You have something on your mind and want to tell the other person how you feel and what's on your mind. However, the other person, unfortunately, does not listen properly and you do not feel understood.
Unfortunately, most people are poor listeners. Good listeners have often undergone special training or have made listening to their profession. But what does good listening actually mean? How can you listen better and give your counterpart an appreciative feeling? In the following, I would like to show you three tips that will help you become a better listener.
A large proportion of German employees suffer from recurring chronic back pain, which, according to medical experts, is mainly caused by immobile sitting in everyday working life.
In the following, you will find out what a vital workday can do for your health. First, however, you should start at the basis of your every day (work) life.
Do you not know where to go with you because of the heat? Rescue is at hand! According to traditional Chinese medicine, these foods provide a large portion of cooling.
The fan has given up the ghost, your feet are boiling, and you don't know if that thing on your neck is a head or a hotplate? We feel you! We can't offer you a nice igloo in the Arctic at the moment, but at least the heat buildup in your body can be solved with smart decisions when eating.
Doesn’t it make sense then to try to save as much of your hard-earned money as possible? The less you spend, the more you have.
Here are some money tips you can use to save big on many of your expenses.
Vasily Alekseyev was tricked into lifting 500 pounds over his head.
Until 1970, many weightlifters had only come close to cracking that psychological barrier.
So when his trainers told him that the bar was loaded with slightly less than 500 pounds, a weight he’d lifted before, he threw it up like a matchstick.
Only they had lied—he’d actually lifted 500.5 pounds. Over the next seven years, he continued to smash records, topping out at 564 before retiring.
Because seeing is believing, many others started lifting 500+ soon after.
Remember Roger Bannister? Until 1954, everyone believed a human couldn't run a mile in under four minutes. Then Roger did it, and his record stood for only 46 days. In the next 50 years, more than a thousand runners beat the four-minute mile.
What changed? Only a belief in what’s possible.
A few everyday things make us look immediately unattractive to our counterpart - at least, that's what science says.
Do you get too little sleep and are often in a bad mood? Then watch out! These and other everyday things that seem supposedly "normal" to us have a negative impact on your attractiveness. Scientists have found out which behaviors don't go down well and cast a bad light on us:
Walking barefoot is the natural way for humans to walk why it's worthwhile to go barefoot more often.
For thousands of years, our ancestors stomped around barefoot. Only recently have people started to squeeze into socks and shoes with rubber soles, completely isolating themselves from the earth's surface - yet walking with bare feet brings so many health benefits. Because walking barefoot...
Too many tasks and too little time is a permanent condition for you? Do you feel stressed and are unproductive? Poor time management is often to blame. With these 5 tips, you'll finally get the hang of it.
Everyone has 24 hours in a day, yet some people seem to use them better than others. Those who cultivate poor time management struggle to complete their tasks. The consequences: Constant stress and declining productivity. These tips (from Focus Online) show you how good time management works and bring peace back into your workday.
Our society places great value on multitasking. So, too, are our work environments designed for multitasking: Now more than ever, we use computers and networks that offer instant messaging, email, and other "productive" tools. We are constantly jumping back and forth between them.
Multitasking includes three different types:
Performing two or more tasks simultaneously.
Switching back and forth between tasks.
Performing a series of tasks in rapid succession.
While this way of working seems normal to many people, multitasking is a disadvantage. If we use single-tasking instead and consciously approach each project "task-by-task," we can be very productive.
The fastest way to get many things done is to do one thing at a time.
At least two liters a day should be. You should definitely drink before sports ... There are plenty of myths about drinking. But which ones are really true?
Many of us find it difficult to follow through on all work tasks and figure out how to continue to be as productive as possible after an extended period of physical and social isolation. With a little mindfulness, planning ahead, and acknowledging what's actually going well, it's possible to jumpstart productivity with new strategies. These six simple methods will help you be more productive in your workday:
This is what happens when you drink water in the morning on an empty stomach.
These 7 things happen when you drink water after waking up on an empty stomach, from weight loss to visibly healthier hair.
We hear again and again that sufficient liquid is important for our body. But what happens when water is drunk directly after getting up? We'll tell you:
How would the world look like 5, 10, or 15 years from now? Well, indeed, no one can predict.
Monitoring the changing pattern of technological usage & growth can help understand how the professional world may change in the future.
A career you may want to pursue, or a career you already have may shape up to be quite a boom in years to come.
In this blog, we shall shed some light on in-demand careers which we believe shall grow in years to come.
In the job interview, it is important to score points with professional competence and personality. In recent years, soft skills have become increasingly important compared to pure hard skills. Companies are looking for a "team fit" rather than a pure "skill fit. The problem with personality traits is that, in comparison to hard skills, they cannot be proven with a certificate. Companies are therefore not only looking for personalities. They are looking for personalities that are as authentic as possible. Here I explain how you can present yourself as authentically as possible.