Set Cookies in ReactJS

Rahul Bansal
Updated on 10-Sep-2023 08:24:17

34K+ Views

In this chapter, we are going to see how to set, remove and retrieve cookies in a React application.Cookies are the data stored in the form of key-value pairs that are used to store information about the user on their computer by the websites that the users browse and use it to verify them.To set or remove the cookies, we are going to use a third-party dependency of react-cookie.Installing the modulenpm install react-cookieOr, yarn add react-cookieNpm is the node package manager which manages our React package but yarn is the more secure, faster and lightweight package manager.Setting up cookiesIn this ... Read More

Reverse a String in C Without Using Library Function

Bhanu Priya
Updated on 10-Sep-2023 08:20:38

67K+ Views

Using strrev() functionThe function is used for reversing a string.The reversed string will be stored in the same string.Syntaxstrrev (string)Before working on reversing the string without using function, let’s have a look on how to reverse a string using string function strrev(), so that we can easily find the difference and gets clarity on the concept −Example#include main (){    char a[50] ;    clrscr();    printf (“enter a string”);    gets (a);    strrev (a);    printf(“reversed string = %s”, a)    getch (); }Outputenter a string Hello reversed string = olleHWithout using strrev() functionNow let’s see the program ... Read More

Convert Torch Tensor to PIL Image

Shahid Akhtar Khan
Updated on 10-Sep-2023 08:19:41

47K+ Views

The ToPILImage() transform converts a torch tensor to PIL image. The torchvision.transforms module provides many important transforms that can be used to perform different types of manipulations on the image data. ToPILImage() accepts torch tensors of shape [C, H, W] where C, H, and W are the number of channels, image height, and width of the corresponding PIL images, respectively.StepsWe could use the following steps to convert a torch tensor to a PIL image −Import the required libraries. In all the following examples, the required Python libraries are torch, Pillow, and torchvision. Make sure you have already installed them.import torch ... Read More

Find the First Character of a String in C#

George John
Updated on 10-Sep-2023 08:18:07

44K+ Views

To get the first character, use the substring() method.Let’s say the following is our string −string str = "Welcome to the Planet!";Now to get the first character, set the value 1 in the substring() method.string res = str.Substring(0, 1);Let us see the complete code −Example Live Demousing System; public class Demo {    public static void Main() {       string str = "Welcome to the Planet!";       string res = str.Substring(0, 1);       Console.WriteLine(res);    } }OutputW

Perform String Comparison in TypeScript

Shubham Vora
Updated on 10-Sep-2023 08:16:41

48K+ Views

In this TypeScript tutorial, users will learn to make string comparisons. The string comparison is the basic operation required while working with any programming language. Suppose we are developing a web or Android application and need to compare string data such as user id, user name, password, etc. In such cases, string comparison becomes very useful. Using the strict equality (===) operator The best way to compare the strings in TypeScript is to use the strict equality operator. The strict equality operator first checks the types of the left and right operands, and if it matches, it compares the value ... Read More

Check If a Number Is Prime in C#

karthikeya Boyini
Updated on 10-Sep-2023 08:06:41

64K+ Views

To calculate whether a number is prime or not, we have used a for loop. Within that on every iteration, we use an if statement to find that the remainder is equal to 0, between the number itself.for (int i = 1; i

Call a Function That Returns Another Function in JavaScript

AmitDiwan
Updated on 10-Sep-2023 08:04:26

39K+ Views

We will call a function by referencing its name and adding parentheses after it. If the function we are calling returns another function (it does in our case), we will need to assign it to a variable or call it immediately. In the future, we will need to make sure that we understand the behavior of the returned function and how it can be utilized in our code. This is call Function Currying. Function Currying Function currying is a technique in functional programming where a function is transformed into a sequence of functions, each taking a single ... Read More

Set Cell Width and Height in HTML

Lokesh Badavath
Updated on 10-Sep-2023 08:02:31

42K+ Views

We use the inline CSS style, to set the cell width and height. The HTML style element contains width and height attributes. To set cell width and height we should place these attributes with specified values with pixels inside the tag. Syntax Following is the syntax to set cell width and height in HTML. content Example Following is the example program to set cell width and height in HTML. DOCTYPE html> table, tr, th, td { border:1px solid ... Read More

Redirect from an HTML Page

Yaswanth Varma
Updated on 10-Sep-2023 08:00:03

32K+ Views

Page redirection is a situation where you clicked a URL to reach a page X but internally you were directed to another page Y. It happens due to page redirection. Website designers rely on redirection when there is a need to change the layout of a particular website or the location of a specific page. To redirect from an HTML page, we use the META Tag. Along with this, we also use the http-equiv attribute to provide an HTTP header for the value of the content attribute. The value in the content is the number of seconds; you want ... Read More

Search in Array of Object in MongoDB

Anvi Jain
Updated on 10-Sep-2023 07:55:51

32K+ Views

To search the array of object in MongoDB, you can use $elemMatch operator. This operator allows us to search for more than one component from an array object.To understand the above concept, let us create a collection with the document. The query to create a collection with a document is as follows −> db.searchArrayDemo.insertOne({"EmployeeFirstName":"Adam", "EmployeeLastName":"Smith", "EmployeeDateOfBirth":new ISODate("1992-01-31 13:45:10"),    ... "EmployeeSkills":["Spring and Hibernate Framework", "Machine Learning"],    ... "EmployeeDetails":[       ... {          ... "EmployeePerformanceArea":"Java",          ... "Year":2001       ... },       ... {       ... ... Read More

Advertisements