code-rag-bench/online-tutorials huggingface dataset:
How to create a PUT request in Postman?

A Postman PUT request is used to pass data to the server for the creation or modification of a resource. The difference between POST and PUT is that POST request is not idempotent.
This means invoking the same PUT request numerous times will always yield the same output. But invoking the same POST request numerous times will create a similar resource more than one time.
Before creating a PUT request, we shall first send a GET request to the server on an endpoint:http://dummy.restapiexample.com/api/v1/employees.
On applying the GET method, the Response body obtained is −
Now, let us update the employee_salary and employee_age for id 21 with the help of the PUT request.
Step 1 − Click on the New menu from the Postman application. The Create New pop-up comes up. Then click on the Request link.
Step 2 − SAVE REQUEST pop-up comes up. Enter Request name then click on Save.
Step 3 − The Request name (Test1) gets reflected on the Request tab. We shall select the option PUT from the HTTP request dropdown. Then enter the URL -http://dummy.restapiexample.com/api/v1/update/21 (endpoint for updating the record of id 21) in the address bar.
It must be noted that in a PUT request, we have to mention the id of the resource in the server which we want to update in the URL. For example, in the above URL, we have added the id 21.
Step 4 − Move to the Body tab below the address bar and select the option raw.
Step 5 − Then choose JSON from the Text dropdown.
Step 6 − Copy and paste the below information in the Postman Body tab.
{ "name": "Jenette Caldwell","salary": "2000","age": "15"}
The overall parameters to be set for a PUT request is shown below −
Step 7 − Click on the Send button.
Once a request has been sent, we can see the response code 200 OK populated in the Response body. This signifies a successful request and the request we have sent has been accepted by the server.
Also, information on the time consumed to complete the request (673 ms) and payload size (705 B) are populated. The Response body shows the salary and age got updated to 2000 and 15 respectively for the employee having id 21.
Redis - Pipelining

Redis is a TCP server and supports request/response protocol. In Redis, a request is accomplished with the following steps −
The client sends a query to the server, and reads from the socket, usually in a blocking way, for the server response.
The client sends a query to the server, and reads from the socket, usually in a blocking way, for the server response.
The server processes the command and sends the response back to the client.
The server processes the command and sends the response back to the client.
The basic meaning of pipelining is, the client can send multiple requests to the server without waiting for the replies at all, and finally reads the replies in a single step.
To check the Redis pipelining, just start the Redis instance and type the following command in the terminal.
$(echo -en "PING\r\n SET tutorial redis\r\nGET tutorial\r\nINCR 
visitor\r\nINCR visitor\r\nINCR visitor\r\n"; sleep 10) | nc localhost 6379  
+PONG 
+OK 
redis 
:1 
:2 
:3 

In the above example, we will check Redis connection by using PING command. We have set a string named tutorial with value redis. Later, we get that keys value and increment the visitor number three times. In the result, we can see that all commands are submitted to Redis once, and Redis provides the output of all commands in a single step.
The benefit of this technique is a drastically improved protocol performance. The speedup gained by pipelining ranges from a factor of five for connections to localhost up to a factor of at least one hundred over slower internet connections.

    22 Lectures 
     40 mins

 Skillbakerystudios
 Print
 Add Notes
 Bookmark this page
What is the difference between jQuery and JavaScript?

The following is the difference between jQuery and JavaScript:
jQuery is a fast and concise JavaScript library created by John Resig in 2006. jQuery simplifies HTML document traversing, event handling, animating, and Ajax interactions for Rapid Web Development.
JavaScript is a lightweight, interpreted programming language. It is designed for creating network-centric applications. It is complimentary to and integrated with Java. JavaScript is very easy to implement because it is integrated with HTML. It is open and cross-platform.
jQuery is automatically optimized to work with a lot of browsers. But, JavaScript is still dealing with some issues such as cross-browser compatibility. This can be due to poor JavaScript implementation practices by web browser developers.
jQuery needs less testing of code, and lesser code for the same goal, when compared with JavaScript. For example, to change font-size, background color, etc.
Let us see an example of jQuery and JavaScript to change the background color:
JavaScript
function changeColor(color) {
   document.body.style.background = color;
}
Onload=”changeColor('blue’);”
jQuery
$ (‘body’) .css (‘background’, ‘#0000FF’);
As shown above, both the code snippets are doing the same work of changing the background color. But jQuery takes less code and in this way you can work around other examples also, which shows that jQuery minimizes the code and is easier to use.
D3.js | d3.min() function - GeeksforGeeks

28 Jun, 2019
The d3.min() function in D3.js is used to returns the minimum value in the given array using natural order. If an array is empty then it returns undefined as output.
Syntax:
d3.min(Array)
Parameters: This function accepts a parameters Array which is an array of elements whose minimum value is to be calculated. Here elements might be integers or any strings.
Return Value: It returns the minimum value.
Below programs illustrate the d3.min() function in D3.js.
Example 1:
<html>  <head>    <title>Getting minimum value</title></head>  <body>    <script src='https://d3js.org/d3.v4.min.js'>  </script>      <script>        // initialising the array of elements        var Array1 = [10, 20, 30, 40, 50, 60];        var Array2 = [1, 2];        var Array3 = [0, 1.5, 6.8];        var Array4 = [.8, .08, .008];          // Calling to d3.min() function        A = d3.min(Array1);        B = d3.min(Array2);        C = d3.min(Array3);        D = d3.min(Array4);          // Getting minimum value        document.write(A + "<br>");        document.write(B + "<br>");        document.write(C + "<br>");        document.write(D + "<br>");    </script></body>  </html>
Output:
10
1
0
0.008
Example 2:
<html>  <head>    <title>Getting minimum value</title></head>  <body>    <script src='https://d3js.org/d3.v4.min.js'>  </script>      <script>        // initialising the array of elements        var Array1 = [];        var Array2 = ["a", "b", "c"];        var Array3 = ["A", "B", "C"];        var Array4 = ["Geek", "Geeks", "GeeksforGeeks"];          // Calling to d3.min() function        A = d3.min(Array1);        B = d3.min(Array2);        C = d3.min(Array3);        D = d3.min(Array4);          // Getting minimum value        document.write(A + "<br>");        document.write(B + "<br>");        document.write(C + "<br>");        document.write(D + "<br>");    </script></body>  </html>
Output:
undefined
a
A
Geek
D3.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
How to append HTML code to a div using JavaScript ?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
HTML <br> Tag - GeeksforGeeks

17 Mar, 2022
In this article, we will know how to add line-break using HTML <br> tag. The browser does not recognize new line and paragraph formatting in the text. If you want to start a new line, you need to insert a line break with the help of the <br>. The <br> tag inserts a single carriage return or breaks in the document. This element has no end tag.
Example: In this example, we use <br> tag in p tag to line break the content.
HTML
<!DOCTYPE html><html>  <body>    <h2>GeeksforGeeks</h2>        <!--br tag is used in below paragraph-->      <p>Hi Geeks! <br>Welcome to GeeksforGeeks</p>  </body>  </html>
Output:
HTML <br> tag
Let us consider an example. Type the following HTML code does not use the <BR> tag in notepad, save the document as an HTML file, and open it in a browser. You will notice that the text shows line breaks at four instances, the browser displays the entire text as a single paragraph.
Syntax:
<br>
Attributes: This tag accepts an attribute called clear
clear: Indicates where to begin the next line after the break.
Example: This example explains the use of the <br> tag to add the line-breake.
HTML
<!DOCTYPE html><html>  <body>    <h1>GeeksforGeeks</h1>    <h2>br Tag</h2>          <!-- br tag -->    <p>GeeksforGeeks:        <br> Computer science portal</p>  </body>  </html>
Output:
HTML <br> tag
Supported Browsers: 
Google Chrome 1 and above
Microsoft Edge 12 and above
Internet Explorer
Firefox 1 and above
Safari
Opera
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
shubhamyadav4
ysachin2314
bhaskargeeksforgeeks
HTML-Tags
Picked
HTML
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to update Node.js and NPM to next version ?
How to set the default value for an HTML <select> element ?
Hide or show elements in HTML using display property
How to set input type date in dd-mm-yyyy format using HTML ?
REST API (Introduction)
How to Insert Form Data into Database using PHP ?
CSS to put icon inside an input element in a form
Types of CSS (Cascading Style Sheet)
HTTP headers | expires - GeeksforGeeks

19 Nov, 2019
The HTTP Expires header is a response-type header, the fundamental way of controlling the caches present. The expire header contains the date and time which denotes the period where the object can stay alive. Once the period expires, the object becomes stale. Almost every client support expire headers. The expire headers are usually ignored if a cache-control header is present with a max-age directive. The users need not press the reload button in order to get a live object. Once the time expires the caches take control over the pages. Web servers allow clients to set the expire headers in multiple ways. The two most common ways may include:
Last access time: It sets the expire time-based on the final time the client accessed the object.
Last modification time: It denotes the last time the document was changed on the server.
Syntax:
Expires: <http-date>
Directives: The HTTP Expires header accepts a single directive mentioned above and described below:
<http-date>: This directive contains the date time information of the retirement.
Below example will illustrate the HTTP Expires header:
Example: In this example, the object is set with an expiry date and time. It will enable the caches to know when to get a fresh copy of the object. The users need not press the reload button in order to get a live object. Once the time expires the caches take control over the pages.
Expires: Mon,11 Nov 2019 08:36:00 GMT
To check this Expires in action go to Inspect Element -> Network check the response header for Expires like below, Expires is highlighted you can see.Note: The time denoted in HTTP date should always hold Greenwich Meridian Time(GMT) and not local time.
Supported Browsers: The browsers are compatible with HTTP Expires header are listed below:
Google Chrome
Internet Explorer
Firefox
Safari
Opera
HTTP-headers
Picked
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
How to create footer to stay at the bottom of a Web page?
Differences between Functional Components and Class Components in React
Node.js fs.readFileSync() Method
File uploading in React.js
How to apply style to parent if it has child with CSS?
How to Open URL in New Tab using JavaScript ?
p5.js | constrain() Function - GeeksforGeeks

25 Mar, 2020
The constrain() function in p5.js is used to constrain a number between a given minimum and maximum limit.
Syntax:
constrain( n, low, high )
Parameters: This function accept three parameters as mentioned above and described below:
n: It is a number which denotes the value that has to be constrained.
low: It is a number which denotes the minimum limit to which the number is constrained.
high: It is a number which denotes the maximum limit to which the number is constrained.
Return Value: It returns a number with the constrained value.
The example below illustrates the constrain() function in p5.js:
Example 1:
function setup() {  createCanvas(650, 200);  textSize(20);     inputElemA = createInput(10);  inputElemA.position(30, 40);     inputElemB = createInput(100);  inputElemB.position(30, 60);     sliderElem = createSlider(-100, 100, 50, 1);  sliderElem.position(30, 120);}   function draw() {  clear();  text("Enter two values between which the "    + "number would be constrained", 20, 20);  text("Move the slider to observe the effects"    + " of the constrain() function", 20, 100);     // Convert the string value to a number value  inputValA = Number(inputElemA.value());  inputValB = Number(inputElemB.value());  sliderVal = sliderElem.value();     text("The slider value is: " + sliderVal, 20, 160);     // Display the constrained value  text("The constrained value is: "        + constrain(sliderVal, inputValA,        inputValB), 20, 180);}
Output:
Example 2:
function setup() {  createCanvas(600, 350);  textSize(20);   }   function draw() {  clear();  text("Move the pointer to see the effect "        + "of constrain() in the square", 20, 30);  text("White circle represents unconstrained"        + " mouse", 20, 50);  text("Red circle represents mouse constrained"        + " to box dimensions", 20, 70);     noFill();  square(100, 100, 200);     circle(mouseX, mouseY, 40);     // Constrain the mouse x and y position  constrainedMouseX = constrain(mouseX, 100, 300);  constrainedMouseY = constrain(mouseY, 100, 300);     fill('red');  circle(constrainedMouseX, constrainedMouseY, 20);}
Output:
Online editor: https://editor.p5js.org/
Environment Setup: https://www.geeksforgeeks.org/p5-js-soundfile-object-installation-and-methods/
Reference: https://p5js.org/reference/#/p5/constrain
JavaScript-p5.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
How to calculate the number of days between two dates in javascript?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
Recursive program to check if number is palindrome or not in C++

We are given an integer as input. The goal is to find whether the input number Num is a palindrome or not using recursion.
To check if a number is palindrome, reverse that number and check if both numbers are the same or not. If the reversed number is equal to the original number, then it is palindrome.
Input − Num = 34212;
Output − 34212 is not a Palindrome!
Explanation − If we reverse 34212 then we get 21243. 34212 != 21243 hence the input number is not palindrome.
Input − Num = 32123;
Output − 32123 is Palindrome!
Explanation − If we reverse 32123 then we get 32132. 32123!= 32123 hence the input number is palindrome.
In this approach we are using the recursive function revrsNum(int num1, int num2) which takes input number num1 and temporary number num2.
For base cases-: if num1 is 0 return num2.
Else-: calculate reverse of num1 using recursion. Return calculated reverse.
If both are the same, then the input number is palindrome.
Take the input number Num.
Take the input number Num.
Take Num2 = revrsNum(Num,0)
Take Num2 = revrsNum(Num,0)
Function revrsNum(int num1, int num2) generates reverse of num1 recursively and returns the reversed number.
Function revrsNum(int num1, int num2) generates reverse of num1 recursively and returns the reversed number.
If num1 is 0 then return num2 as calculated reverse.
If num1 is 0 then return num2 as calculated reverse.
Else multiple num2 by 10 and add num1%10 to it.
Else multiple num2 by 10 and add num1%10 to it.
Reduce num1 by 10 using num1=num1/10.
Reduce num1 by 10 using num1=num1/10.
Recurse using revrsNum(num1, num2);
Recurse using revrsNum(num1, num2);
Return result.
Return result.
Print result obtained inside main.
Print result obtained inside main.
#include <bits/stdc++.h>
using namespace std;
int revrsNum(int num1, int num2){
   if (num1 == 0){
      return num2;
   }
   num2 *= 10;
   num2 += (num1 % 10);
   num1 = num1/10;
   return revrsNum(num1, num2);
}
int main(){
   int Num = 1345431;
   int Num2 = revrsNum(Num,0);
   if (Num == Num2){
      cout <<Num<<" is Palindrome!";
   }
   else{
      cout <<Num<<" is not a Palindrome!";
   }
   return 0;
}
If we run the above code it will generate the following Output
1345431 is Palindrome!
XPath - Relative Path

Location path specifies the location of node in XML document. This path can be absolute or relative. If location path starts with the node that we've selected then it is a relative path.
Following are few examples locating the elements using relative path.
firstname − select firstname related to student nodes.
<p><xsl:value-of select = "firstname"/></p>
In this example, we've created a sample XML document students.xml and its stylesheet document students.xsl which uses the XPath expressions.
Following is the sample XML used.
<?xml version = "1.0"?>
<?xml-stylesheet type = "text/xsl" href = "students.xsl"?>
<class>
   <student rollno = "393">
      <firstname>Dinkar</firstname>
      <lastname>Kad</lastname>
      <nickname>Dinkar</nickname>
      <marks>85</marks>
   </student>
   <student rollno = "493">
      <firstname>Vaneet</firstname>
      <lastname>Gupta</lastname>
      <nickname>Vinni</nickname>
      <marks>95</marks>
   </student>
   <student rollno = "593">
      <firstname>Jasvir</firstname>
      <lastname>Singh</lastname>
      <nickname>Jazz</nickname>
      <marks>90</marks>
   </student>
</class>
<?xml version = "1.0" encoding = "UTF-8"?>
<xsl:stylesheet version = "1.0"
   xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">
	
   <xsl:template match = "/" >
      <html>
         <body>
            <h3>Details of each Students. </h3>
            <table border = "1">
               <tr bgcolor = "#9acd32">
                  <th>Roll No</th>
                  <th>First Name</th>
                  <th>Last Name</th>
                  <th>Nick Name</th>
                  <th>Marks</th>		 
               </tr>		 
					
               <xsl:for-each select = "/class/student">
                  <tr>
                     <td><xsl:value-of select = "@rollno"/></td>
                     <td><xsl:value-of select = "firstname"/></td>
                     <td><xsl:value-of select = "lastname"/></td>
                     <td><xsl:value-of select = "nickname"/></td>
                     <td><xsl:value-of select = "marks"/></td>		 
                  </tr>
               </xsl:for-each>
            </table> 
         </body>
      </html>
   </xsl:template>
</xsl:stylesheet>

    90 Lectures 
     20 hours 

 Arun Motoori

    23 Lectures 
     8 hours 

 Sanjay Kumar

    13 Lectures 
     1.5 hours 

 Sanjay Kumar

    24 Lectures 
     1.5 hours 

 Sanjay Kumar

    47 Lectures 
     3 hours 

 Krishna Sakinala
 Print
 Add Notes
 Bookmark this page
Multithreaded using the Pthreads API

Pthreads refers to the POSIX standard (IEEE 1003.1c) defining an API for thread creation and synchronization, which is a specification for thread behavior, not an implementation. This specification may be implemented by Operating-system designers in any way they wish. The C program shown in below, demonstrates the basic Pthreads API for constructing a multithreaded program that calculates the summation of a nonnegative integer in a separate thread. Separate threads begin execution in a specified function, in a Pthreads program. In below program, this is the runner() function. When the program begins, a single thread of control begins in main(). main() creates a second thread that begins control in the runner() function, after some initialization. Both threads share the global data sum. the pthread.h header file must be included by all Pthreads programs. The identifier for the thread we will create. A set of attributes, including stack size and scheduling information are there in each thread. The attributes for the thread is represented by declaration of the pthread attr_t_attr. We set the attributes in the function call pthread attr init(&attr). Because we did not explicitly set any attributes, we use the default attributes provided. With the pthread create() function call, separate thread is created. To passing the thread identifier and the attributes for the thread, we also pass the runner() function, where the new thread will begin execution. At Last, we pass the integer parameter that was provided on the command line, argv[1]. At this point, the program has two threads: the initial (or parent) thread in main() and the summation (or child) thread performing the summation operation in the runner() function. This program follows the fork-join strategy: after creating the summation thread, the parent thread will wait for it to terminate by calling the pthread join() function. When it calls the function pthread exit(), when the summation thread will terminate .The parent thread will output the value of the shared data sum, once the summation thread has returned,
#include<pthread.h>
#include<stdio.h>
int sum;
/* This ‘sum’ is shared by the thread(s) */
void *runner(void *param);
/* threads call this function */
int main(int argc, char *argv[]){
   pthread t tid;
   /* the thread identifier */
   pthread attr t attr;
   /* set of thread attributes */
   if (argc != 2){
      fprintf(stderr,"usage: a.out \n");
      return -1;
   }
   if (atoi(argv[1]) < 0){
      fprintf(stderr,"%d must be >= 0\n",atoi(argv[1])); return -1;
   }
   /* get the default attributes */
   pthread attr init(&attr);
   /* create the thread */
   pthread create(&tid,&attr,runner,argv[1]);
   /* wait for the thread to exit */
   pthread join(tid,NULL);
   printf("sum = %d\n",sum);
}
/* The thread will begin handle in this function */
void *runner(void *param){
   int i, upper = atoi(param);
   sum = 0;
   for (i = 1; i <= upper; i++)
      sum += i;
   pthread exit(0);
}
Batch Script - ASSOC

This is a batch command that associates an extension with a file type (FTYPE), displays existing associations, or deletes an association.
assoc – Displays all the file extensions 
assoc | find “.ext” – Displays only those file extensions which have the extension ext.

@echo off 
assoc > C:\lists.txt 
assoc | find “.doc” > C:\listsdoc.txt
The list of file associations will be routed to the file lists.txt. The following output shows what is there in the listsdoc.txt file after the above batch file is run.
.doc=Word.Document.8 
.dochtml=wordhtmlfile 
.docm=Word.DocumentMacroEnabled.12 
.docmhtml=wordmhtmlfile 
.docx=Word.Document.12 
.docxml=wordxmlfile

 Print
 Add Notes
 Bookmark this page
How to add items/elements to an existing jagged array in C#?

To add an element to existing jagged array, just set the value of the element with a new value.
Let’s say you need to add an element at the following location −
a[3][1]
Just set the value −
a[3][1] = 500;
Above, we accessed the first element of the 3rd array in a jagged array.
Let us see the complete code −
using System;

namespace Demo {
   class Program {
      static void Main(string[] args) {

         int[][] x = new int[][]{new int[]{10,20},new int[]{30,40}, new int[]{50,60},new int[]{ 70, 80 }, new int[]{ 90, 100 } };
         int i, j;

         Console.WriteLine("Old Array...");
         for (i = 0; i < 5; i++) {
            for (j = 0; j < 2; j++) {
               Console.WriteLine("a[{0}][{1}] = {2}", i, j, x[i][j]);
            }
         }

         x[3][1] = 500;

         Console.WriteLine("New Array...");
         for (i = 0; i < 5; i++) {
            for (j = 0; j < 2; j++) {
               Console.WriteLine("a[{0}][{1}] = {2}", i, j, x[i][j]);
            }
         }
         Console.ReadKey();
      }
   }
}
Program to count number of palindromes of size k can be formed from the given string characters in Python

Suppose we have a string s that is representing alphabet characters and a number k. We have
to find the number of palindromes where we can construct of length k using only letters in s.
And we can use these letters more than once if we want.
So, if the input is like s = "xy", k = 4, then the output will be 4 as the palindromes are [xxxx, yyyy,
xyyx, yxxy].
To solve this, we will follow these steps −
n := quotient of k/2
x := number of unique characters in s
return x^(n + k mod 2)
Let us see the following implementation to get better understanding −
 Live Demo
class Solution:
   def solve(self, s, k):
      n=k//2
      return len(set(s))**(n+k%2)
s = "xy"
k = 4
ob = Solution()
print(ob.solve(s, k))
"xy",4
4
HTML | <hr> width Attribute

28 May, 2019
The HTML <hr> width attribute is used to specify the width of the horizontal line in terms of pixels or percent.
Syntax:
<hr width="pixels|%">
Attribute Values:
pixels: It sets the width of <hr> attribute in terms of pixels.
%: It sets the width of <hr> attribute in terms of percentage (%).
Note: The <hr> width attribute is not supported by HTML 5.
Example:
<!DOCTYPE html><html>  <head>    <title>        HTML hr width Attribute    </title></head>  <body style="text-align:center;">    <h1>GeeksforGeeks</h1>    <hr width="500px;">    <p>Computer science portal</p>    <hr width="70%"></body>  </html>
Output:
Supported Browsers: The browser supported by HTML <hr> width attribute are listed below:
Google Chrome
Internet Explorer
Firefox
Safari
Opera
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
time.Since() Function in Golang With Examples

21 Apr, 2020
In Go language, time packages supplies functionality for determining as well as viewing time. The Since() function in Go language holds time value and is used to evaluate the difference with the actual time. Moreover, this function is defined under the time package. Here, you need to import the “time” package in order to use these functions.
Syntax:
func Since(t Time) Duration

Here, t is the time value.
Note: This method is shortcut for time.Now().Sub(t).
Return value: It returns a duration value.
Example 1:
// Golang program to illustrate in Golang  // Including main packagepackage main  // Importing fmt and timeimport (    "fmt"    "time")  // Calling mainfunc main() {      // Defining time value    // of Since method    now := time.Now()      // Prints time elapse    fmt.Println("time elapse:",             time.Since(now))}
Output:
time elapse: 210ns // Can be different at different run times

Here, time elapse between now and the current time is printed. So, it can be different at different run times.
Example 2:
// Golang program to illustrate in Golang  // Including main packagepackage main  // Importing fmt and timeimport (    "fmt"    "time")  // Calling mainfunc main() {      // Defining time value     // of Since method    timevalue := time.Now()      // Calling Since method    // with its parameter    Duration := time.Since(timevalue)      // Prints time elapse in nanoseconds    fmt.Println("time elapse in nanoseconds:",                   Duration.Nanoseconds())}
Output:
time elapse in nanoseconds: 351 // Can be different at different run times

GoLang-time
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
What is chunk in Node.js ?

25 Apr, 2022
The data is a transfer from server to client for a particular request in the form of a stream. The stream contains chunks. A chunk is a fragment of the data that is sent by the client to server all chunks concepts to each other to make a buffer of the stream then the buffer is converted into meaningful data. In this article, we will discuss how to send chunks from the request body to the server. The request object is used for handling the chunks of data.
Syntax:
request.on('eventName',callback)
Parameters: This function accepts the following two parameters:
eventName: It is the name of the event that fired
callback: It is the Callback function i.e Event handler of the particular event.
Return type: The return type of this method is void.
Example: Create an index.js file with the following code.
index.js
// Importing http librariesconst http = require('http');  // Creating a serverconst server = http.createServer((req, res) => {    const url = req.url;    const method = req.method;      if (url === '/') {        // Sending the response        res.write('<html>');        res.write('<head><title>Enter Message</title><head>');        res.write(`<body><form action="/message" method="POST">    <input type="text" name="message"></input>    <button type="submit">Send</button></form></body></html>`);        res.write('</html>');        return res.end();    }      // Handling different routes for different type request    if (url === '/message' && method === 'POST') {        const body = [];          req.on('data', (chunk) => {              // Storing the chunk data            body.push(chunk);            console.log(body)        });          req.on('end', () => {              // Parsing the chunk data            const parsedBody = Buffer.concat(body).toString();            const message = parsedBody.split('=')[1];                          // Printing the data            console.log(message);        });          res.statusCode = 302;        res.setHeader('Location', '/');        return res.end();    }});  // Starting the serverserver.listen(3000);
Run index.js file using below command:
node index.js
Now open a browser and go to http://localhost:3000, you will see the following output.
Console Output:
rkbhola5
Node.js-Buffer-module
Node.js-Methods
NodeJS-Questions
Picked
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
JWT Authentication with Node.js
Installation of Node.js on Windows
Difference between dependencies, devDependencies and peerDependencies
Mongoose Populate() Method
Mongoose find() Function
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
Differences between Functional Components and Class Components in React
Group Factor Levels in R

14 Sep, 2021
In this article, we will be looking at the approach to group factor level using the base functions of the R Programming language.
In this approach to group factor levels, the user has to simply call the levels() functions with the required parameters as required by the user, and then it will be leading to the new factor level as specified by the user in other words we will be merging two-factor levels into one category in the R programming language.
Levels() function provides access to the levels attribute of a variable. The first form returns the value of the levels of its argument and the second sets the attribute.
Syntax:
levels(x)
levels(x) <- value
Parameters:
x: an object, for example, a factor.
value: A valid value for levels(x). For the default method, NULL or a character vector. For the factor method, a vector of character strings with length at least the number of levels of x, or a named list specifying how to rename the levels.
Example: In this example, we will be creating an initial factor of some elements in the string data type and with the help of the levels function, we will be grouping the initial factor levels in the R programming language.
R
gfg <- factor(c("a","b","c","d","c","a"))gfg  gfg1 <- gfg                                   levels(gfg1) <- c("a", "b", "b","b")        gfg1
Output:
> gfg
[1] a b c d c a
Levels: a b c d
> gfg1
[1] a b b b b a
Levels: a b
Example: In this example, we will be creating an initial factor of some elements in the integer data type and with the help of the levels function, we will be grouping the initial factor levels in the R programming language.
R
gfg <- factor(c(1,2,3,4,5,1,1,3,3,3,3))gfg  gfg1 <- gfg                                   levels(gfg1) <- c(1,5,5,5,5)        gfg1
Output:
> gfg
 [1] 1 2 3 4 5 1 1 3 3 3 3
Levels: 1 2 3 4 5     
> gfg1  
 [1] 1 5 5 5 5 1 1 5 5 5 5
Levels: 1 5
Picked
R-Factors
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Change Color of Bars in Barchart using ggplot2 in R
How to Split Column Into Multiple Columns in R DataFrame?
Group by function in R using Dplyr
How to Change Axis Scales in R Plots?
R - if statement
Logistic Regression in R Programming
How to filter R DataFrame by values in a column?
How to import an Excel File into R ?
Replace Specific Characters in String in R
Joining of Dataframes in R Programming
Running Docker Containers as Non-Root User

05 Nov, 2020
By default, Docker Containers run as Root Users. Now, if you are running applications inside Docker Containers, you have access to all the root privileges. This poses a great security threat when you deploy applications on large scale inside Docker Containers. Because if somehow your application gets hacked by external users, other applications running inside the Containers would also be a huge risk. Moreover, if your Docker Container is part of a network, then the whole network has the risk of getting hacked. To avoid this, you need to make sure that you run the Docker Containers as non-root users.
In this article, we will discuss two different ways using which you can create and add non-root users inside Docker Containers.
You can add users using the -u option along with useradd. You can then use the USER instruction to switch the user. Consider the Dockerfile below.
FROM ubuntu
RUN useradd -u 1234 my-user
USER my-user

The above Dockerfile pulls the Ubuntu base image and creates a user with ID 1234 and name my-user. It then switches to the new user using the USER instruction.
Now, to build the Image, use the Docker Build command.
sudo docker build -t nonroot-demo .

Use the Docker Run command to run the container.
sudo docker run -it nonroot-demo bash

You can see that the user has been changed to the non-root user that we created in the Dockerfile.
To create a Docker group, you can use the following command.
sudo groupadd docker

If there is already a docker group, you will get the following output – 
Now, to create a non-root user and add it to the docker group, you can use the following command.
sudo useradd -G docker <user-name>

After that, you can assign a password to the user using the following command.
sudo passwd user

To change a user’s primary group, use this command.
sudo usermod -aG docker <non-root user>

Restart the Docker service.
Docker Container
linux
Advanced Computer Subject
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Fuzzy Logic | Introduction
Game Playing in Artificial Intelligence
Artificial Intelligence - Temporal Logic
Difference between Backward and Forward Chaining.
Markov Decision Process
Getting Started with System Design
Basics of API Testing Using Postman
Web Mining
Python | Implementation of Polynomial Regression
ML | What is Machine Learning ?
How to place background image using ::before pseudo selectors in CSS ?

14 Dec, 2020
Given a web page and the task is to place the background image on web page using ::before pseudo selector.
The ::before pseudo selector is used to place something before the content of the selected items. 
Syntax:
.container::before{
    content: '';
    background: url(image file);
    position:absolute;
    top:0px;
    left:0px;
}
Approach: The ::before pseudo selector places the background image before the selected element and if the selected element has a background color associated with it, we can use the z-index property to make the background image visible.  
Example:
HTML
<!DOCTYPE html><html lang="en">  <head>    <meta charset="UTF-8">    <meta name="viewport" content=        "width=device-width, initial-scale=1.0">              <title>        How to place the background image         using ::before pseudo selectors ?    </title>      <style>        * {            margin: 0px;            padding: 0px;        }          body {            text-align: center;        }          h1 {            color: green;        }          .container {            width: 100vw;            height: 100vh;            display: flex;            justify-content: center;            align-items: center;            color: black;            font-weight: bold;            font-size: 2rem;        }          .container::before {            content: '';            background: url('bg.png')                 no-repeat center center/cover;            position: absolute;            opacity: 0.3;            top: 0px;            left: 0px;            width: 100vw;            height: 100vh;            z-index: -1;        }          span {            font-size: 2em;        }     </style></head>  <body>    <div class="container">        GeeksforGeeks<br><br>        How to place background image using        ::before pseudo selectors ?    </div></body>  </html>
Output:
Image Reference: https://media.geeksforgeeks.org/wp-content/cdn-uploads/20200212230557/How-To-Become-A-Web-Developer-in-2020-A-Complete-Guide.png
CSS-Misc
HTML-Misc
Technical Scripter 2020
CSS
HTML
Technical Scripter
Web Technologies
Web technologies Questions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Design a Tribute Page using HTML & CSS
How to set space between the flexbox ?
Build a Survey Form using HTML and CSS
Design a web page using HTML and CSS
Form validation using jQuery
REST API (Introduction)
Hide or show elements in HTML using display property
How to set the default value for an HTML <select> element ?
How to set input type date in dd-mm-yyyy format using HTML ?
Design a Tribute Page using HTML & CSS
Tensorflow.js tf.data.Dataset class .prefetch() Method

22 Apr, 2022
Tensorflow.js is an open-source library developed by Google for running machine learning models and deep learning neural networks in the browser or node environment.
The tf.data.Dataset class .prefetch() function is used to produce a dataset that prefetches the specified elements from this given dataset.
Syntax:
prefetch (bufferSize)
Parameters: This function accepts a parameter which is illustrated below:
bufferSize: It is an integer value that specifies the number of elements to be prefetched.
Return Value: It returns a dataset of elements.
Example 1:
Javascript
// Importing the tensorflow.js libraryimport * as tf from "@tensorflow/tfjs"  // Calling the .prefetch() function over// the specified dataset of some elementsconst a = tf.data.array([5, 10, 15, 20]).prefetch(4);  // Getting the dataset of prefetched elementsawait a.forEachAsync(a => console.log(a));
Output:
5
10
15
20
Example 2:
Javascript
// Importing the tensorflow.js libraryimport * as tf from "@tensorflow/tfjs"  // Specifying a dataset of some elementsconst a = tf.data.array(["a", "b", "c", "d", "e"]);  // Calling the .prefetch() function over// the above dataset along with the // batch of size 2const b = a.batch(2)const c = b.prefetch(2)  // Getting the dataset of prefetched elementsawait c.forEachAsync(c => console.log(c));
Output:
Tensor
    ['a', 'b']
Tensor
    ['c', 'd']
Tensor
    ['e']
Reference: https://js.tensorflow.org/api/latest/#tf.data.Dataset.prefetch
arorakashish0911
Picked
Tensorflow.js
TensorFlow.js-Classes
TensorFlow.js-Data
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Remove elements from a JavaScript Array
Roadmap to Learn JavaScript For Beginners
Difference Between PUT and PATCH Request
JavaScript | Promises
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
journalctl Command in Linux with Examples - GeeksforGeeks

10 Feb, 2022

journalctl command in Linux is used to view systemd, kernel and journal logs. The logs are presented in the following way:
-- Logs begin at [date_time_stamp], end at [dat_time_stamp]
[date_time_stamp] [host_name] kernel:

It displays the paginated output, hence it is a bit easy to navigate through a lot of logs. It prints the log in the chronological order with the oldest first.
1. To display all logs
$journalctl

It displays all the logs in the paginated view.
2. To reverse the order or to display the new entries first.
$journalctl -r

This will display the logs in the chronological order with the newest first.
3. To display only a few log entries
$journalctl -n 2

This will display just 2 log entries.
4. To get log entries containing a specific keyword.
$journalctl | grep Centaur

This will display all the entries containing the word Centaur in them.
5. To display priority specific log entries.
$journalctl -p warning

It displays all log entries with priority as a warning.
6. To print verbose customized output.
$journalctl -o verbose

This will display the formatted output in verbose mode.
7. To display the boots of the system.
$journalctl --list-boots

To display all the boots of the system.
8. To display journalctl help.
$journalctl --help

The above command will display the help section of the journalctl command.
rkbhola5

linux-command


Linux-system-commands


Linux-Unix

Writing code in comment? 
                                    Please use ide.geeksforgeeks.org, 
                                    generate link and share the link here.
                                
Thread functions in C/C++
nohup Command in Linux with Examples
mv command in Linux with examples
scp command in Linux with Examples
Docker - COPY Instruction
chown command in Linux with Examples
nslookup command in Linux with Examples
SED command in Linux | Set 2
Named Pipe or FIFO with example C program
uniq Command in LINUX with examples
Get first and last elements of a list in Python

There may be situation when you need to get the first and last element of the list. The tricky part here is you have to keep track of the length of the list while finding out these elements from the lists. Below are the approaches which we can use to achieve this. But of course all the approaches involve using the index of the elements in the list.
In any list the first element is assigned index value 0 and the last element can be considered as a value -1. So we apply these index values to the list directly and get the desired result.
 Live Demo
Alist = ['Sun','Mon','Tue','Wed','Thu']
print("The given list : ",Alist)

print("The first element of the list : ",Alist[0])
print("The last element of the list : ",Alist[-1])
Running the above code gives us the following result −
The given list : ['Sun', 'Mon', 'Tue', 'Wed', 'Thu']
The first element of the list : Sun
The last element of the list : Thu
List slicing is another method in which we directly refer to the positions of elements using the slicing technique using colons. The first element is accessed by using blank value before the first colon and the last element is accessed by specifying the len() with -1 as the input.
 Live Demo
Alist = ['Sun','Mon','Tue','Wed','Thu']
print("The given list : ",Alist)

first_last = Alist[::len(Alist)-1]
print(first_last)
Running the above code gives us the following result −
The given list : ['Sun', 'Mon', 'Tue', 'Wed', 'Thu']
['Sun', 'Thu']
We can also use a for loop with in operator giving the index values as 0 and -1.
 Live Demo
Alist = ['Sun','Mon','Tue','Wed','Thu']
print("The given list : ",Alist)

first_last = [Alist[n] for n in (0,-1)]
print(first_last)
Running the above code gives us the following result −
The given list : ['Sun', 'Mon', 'Tue', 'Wed', 'Thu']
['Sun', 'Thu']
AWK - User Defined Functions

Functions are basic building blocks of a program. AWK allows us to define our own functions. A large program can be divided into functions and each function can be written/tested independently. It provides re-usability of code.
Given below is the general format of a user-defined function −
function function_name(argument1, argument2, ...) { 
   function body
}

In this syntax, the function_name is the name of the user-defined function. Function name should begin with a letter and the rest of the characters can be any combination of numbers, alphabetic characters, or underscore. AWK's reserve words cannot be used as function names.
Functions can accept multiple arguments separated by comma. Arguments are not mandatory. You can also create a user-defined function without any argument.
function body consists of one or more AWK statements.
Let us write two functions that calculate the minimum and the maximum number and call these functions from another function called main. The functions.awk file contains −
# Returns minimum number
function find_min(num1, num2){
   if (num1 < num2)
   return num1
   return num2
}
# Returns maximum number
function find_max(num1, num2){
   if (num1 > num2)
   return num1
   return num2
}
# Main function
function main(num1, num2){
   # Find minimum number
   result = find_min(10, 20)
   print "Minimum =", result
  
   # Find maximum number
   result = find_max(10, 20)
   print "Maximum =", result
}
# Script execution starts here
BEGIN {
   main(10, 20)
}
On executing this code, you get the following result −
Minimum = 10
Maximum = 20

 Print
 Add Notes
 Bookmark this page
LCASE() or LOWER() Functions in MySQL - GeeksforGeeks

03 Sep, 2020
1. LCASE() :The LCASE() function used to convert a text to lower-case. This function is a similar to the LOWER() function.
Syntax :
SELECT LCASE(text)
Example :
SELECT LCASE("Reading on GEEKSFORGEEKS is FUN") AS LowerText; 
Output –
2. LOWER() :Syntax :
SELECT LOWER(text)
Example :
SELECT LOWER("Studying on GeeksForGeeks is FUN") AS LowerText; 
Output –
DBMS-SQL
mysql
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
SQL Trigger | Student Database
SQL | Views
CTE in SQL
Difference between DELETE, DROP and TRUNCATE
How to Update Multiple Columns in Single Update Statement in SQL?
SQL | GROUP BY
Difference between DDL and DML in DBMS
SQL Interview Questions
What is Temporary Table in SQL?
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter