code-rag-bench/online-tutorials huggingface dataset:
Node.js Writable Stream pipe Event - GeeksforGeeks

12 Oct, 2021
The pipe event in a Writable Stream is emitted when the stream.pipe() method is being called on a readable stream by attaching this writable to its set of destinations.
Syntax:
Event: 'pipe'
Return Value: If the pipe() method is being called then this event is emitted else it is not emitted.
Below examples illustrate the use of ‘pipe’ event in Node.js:Example 1:
// Node.js program to demonstrate the     // pipe event   // Accessing fs modulevar fs = require("fs");  // Create a readable streamvar readable = fs.createReadStream('input.txt');  // Create a writable streamvar writable = fs.createWriteStream('output.txt');  // Handling pipe eventwritable.on("pipe", readable => {    console.log("Piped!");});  // Calling pipe methodreadable.pipe(writable);  console.log("Program Ended.");
Output:
Piped!
Program Ended.

Example 2:
// Node.js program to demonstrate the     // pipe event   // Accessing fs modulevar fs = require("fs");  // Create a readable streamvar readable = fs.createReadStream('input.txt');  // Create a writable streamvar writable = fs.createWriteStream('output.txt');  // Handling pipe eventwritable.on("pipe", readable => {    console.log("Piped!");});  console.log("Program Ended");
Output:
Program Ended

So, here pipe() function is not called so the pipe event is not emitted.
Reference: https://nodejs.org/api/stream.html#stream_event_pipe
Node.js-Stream-module
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Express.js express.Router() Function
Express.js req.params Property
JWT Authentication with Node.js
Difference between npm i and npm ci in Node.js
Mongoose Populate() Method
Roadmap to Become a Web Developer in 2022
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
Convert a string to an integer in JavaScript
talk - Unix, Linux Command

Options available:


When first called,
 talk
contacts the talk daemon on the other user’s machine, which sends the
message

Message from TalkDaemon@his_machine...
talk: connection requested by your_name@your_machine.
talk: respond with: talk your_name@your_machine


to that user. At this point, he then replies by typing



     talk  your_name@your_machine



It doesn’t matter from which machine the recipient replies, as
long as his login name is the same.  Once communication is established,
the two parties may type simultaneously; their output will appear
in separate windows.  Typing control-L (^L)
will cause the screen to
be reprinted. The erase, kill line, and word erase characters
(normally ^H, ^U, and ^W respectively)
will behave normally.  To exit, just type the interrupt character
(normally ^C);
 talk
then moves the cursor to the bottom of the screen and restores the
terminal to its previous state.


As of netkit-ntalk 0.15
 talk
supports scrollback; use esc-p and esc-n to scroll your window, and
ctrl-p and ctrl-n to scroll the other window. These keys are now
opposite from the way they were in 0.16; while this will probably be
confusing at first, the rationale is that the key combinations with
escape are harder to type and should therefore be used to scroll one’s
own screen, since one needs to do that much less often.


If you do not want to receive talk requests, you may block them using the
mesg(1)
command.  By default, talk requests are normally not blocked.
Certain commands, in particular
nroff(1),
pine(1),
and
pr(1),
may block messages temporarily in order to
prevent messy output.




Also, the version of
talk(1)
released with
BSD 4.2
uses a different and even more braindead protocol that is completely
incompatible. Some vendor Unixes (particularly those from Sun) have
been found to use this old protocol.


Old versions of
 talk
may have trouble running on machines with more than one IP address,
such as machines with dynamic SLIP or PPP connections. This problem is
fixed as of netkit-ntalk 0.11, but may affect people you are trying to
communicate with.


Advertisements


    129 Lectures 
     23 hours 

 Eduonix Learning Solutions

    5 Lectures 
     4.5 hours 

 Frahaan Hussain

    35 Lectures 
     2 hours 

 Pradeep D

    41 Lectures 
     2.5 hours 

 Musab Zayadneh

    46 Lectures 
     4 hours 

 GUHARAJANM

    6 Lectures 
     4 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
Ext.js - Style

Application Styling refers to user adjustment of the look and feel of the components. These adjustments may include: color, color gradients, font, margins/padding, etc. Ext JS 6 has a new way of styling the application.
It uses SCSS for styling. SCSS is a more dynamic way of writing the CSS code. We can write the variables in our stylesheet with the help of this. However, a browser cannot understand SCSS. It can only understand CSS, hence all SCSS files should get compiled into CSS to a production-ready code.
Thus, SCSS file is called preprocessor files. In Ext.js, compilation is done through Sencha CMD tool. Sencha CMD compiles it manually only once using the following command.
sencha app build [development]

Global_CSS is the main CSS file, which has all SCSS variables associated with it in ExtJS that can be used in our application for customizing our theme by providing different value based on our need.
Following are some of the CSS variables available in the Global_CSS in Ext.js.
$base-color
$base-color: color (e.g. $base-color : #808080)
This base color is to be used throughout the theme.
$base-gradient
$base-gradient: string (e.g. $base-gradient : 'matte')
This base gradient is to be used throughout the theme.
$body-background-color
$body-background-color: color (e.g. $body-background-color : #808080)
Background color to apply to the body element. If set to transparent or 'none', no background-color style will be set on the body element.
$color
$color : color (e.g. $color : #808080)
This default text color is to be used throughout the theme.
$font-family
$font-family : string (e.g. $font-family : arial)
This default font-family is to be used throughout the theme.
$font-size
$font-size : number (e.g. $font-size : 9px )
This default font-size is to be used throughout the theme.
$font-weight
$font-weight : string/number (e.g. $font-weight : normal )
This default font-weight is to be used throughout the theme.
$font-weight-bold
$font-weight-bold : string/number (e.g. $font-weight-bold : bold )
This default font-weight for bold font is to be used throughout the theme.
$include-chrome
$include-chrome : boolean (e.g. $include-chrome : true)
True to include Chrome specific rules.
$include-ff
$include-ff : boolean (e.g. $include-ff : true)
True to include Firefox specific rules.
$include-ie
$include-ie : boolean (e.g. $include-ie : true)
True to include Internet Explorer specific rules for IE9 and lower.
$include-opera
$include-opera : boolean (e.g. $include-opera : true)
True to include Opera specific rules.
$include-safari
$include-safari : boolean (e.g. $include-safari : true)
True to include Opera specific rules.
$include-webkit
$include-webkit : boolean (e.g. $include-webkit : true)
True to include Webkit specific rules.
 Print
 Add Notes
 Bookmark this page
SimpleDateFormat(“Z”) in Java

The Z means "zero hour offset", also known as "Zulu time" (UTC) in the ISO 8601 time representation. However, ACP 121 standard defines the list of military time zones and derives the "Zulu time" from the Greenwich Mean Time (GMT).
TimeZone can be formatted in z, Z or zzzz formats.
The following is an example that displays how to implement SimpleDateFormat(“Z”) −
 Live Demo
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Calendar;
public class Demo {
   public static void main(String[] args) throws Exception {
      // displaying current date and time
      Calendar cal = Calendar.getInstance();
      SimpleDateFormat simpleformat = new SimpleDateFormat("dd/MMMM/yyyy hh:mm:s zzzz");
      System.out.println("Today's date = "+simpleformat.format(cal.getTime()));
      // displaying hour
      Format f = new SimpleDateFormat("H");
      String strHour = f.format(new Date());
      System.out.println("Current Hour = "+strHour);
      // displaying minutes
      f = new SimpleDateFormat("mm");
      String strMinute = f.format(new Date());
      System.out.println("Current Minutes = "+strMinute);
      // displaying seconds in two-digits
      f = new SimpleDateFormat("ss");
      String strSeconds = f.format(new Date());
      System.out.println("Current Seconds = "+strSeconds);
      f = new SimpleDateFormat("a");
      String strMarker = f.format(new Date());
      System.out.println("Current AM/PM Marker = "+strMarker);
      f = new SimpleDateFormat("Z");
      String strOffset = f.format(new Date());
      System.out.println("Offset = "+strOffset);
   }
}
Today's date = 26/November/2018 08:18:9 Coordinated Universal Time
Current Hour = 8
Current Minutes = 18
Current Seconds = 09
Current AM/PM Marker = AM
Offset = +0000
HTTP headers | Sec-WebSocket-Accept - GeeksforGeeks

22 Nov, 2019
The HTTP headers are used for passing additional information with an HTTP request or response between the client and the server. They are grouped as general-headers, request-headers, response-headers, entity-headers. The Sec-WebSocket-Accept header falls under the response-type headers category. It is used by the server to intimate the client that it understood. It was a WebSocket connection and it is ready to open connection. This comes handy for a reverse-proxy server as it can understand the WebSocket handshake and not to make a useless cache. The Sec-WebSocket-Accept header must not appear more than once in an HTTP response.
Note: The HTTP headers usually contain a case-insensitive name followed by a colon (:), then by its value. White-space before the value is ignored here.
Syntax:
Sec-WebSocket-Accept: <hashed key>
Directives: The HTTP Sec-WebSocket-Accept header accepts a single directive that mentioned above and described below:
<hashed key> The server takes the value of Sec-WebSocket-Key sent in handshake request and then appends Globally Unique Identifier (GUID, [RFC4122]) “258EAFA5-E914-47DA-95CA-C5AB0DC85B11” takes SHA-1 of the new value, and is then base64 encoded. This is unlikely to be used by network endpoints that do not understand the WebSocket Protocol.
Below example will illustrate the HTTP Sec-WebSocket-Accept header:
Example: In this example, the server sends 101 response codes if the incoming connection is a WebSocket connection to the client.
101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: MTMyNThFQUZBNS1FOTE0LTQ3REEtOTVDQS1DNUFCMERDODVCMTE=
Sec-WebSocket-Extensions: deflate-frame
Sec-WebSocket-Protocol: soap
Note: This header is not stable there are few research is going on right now on this header.
Supported Browsers: The browsers are compatible with HTTP Sec-WebSocket-Accept header are listed below:
Chrome
Internet Explorer
Firefox
Safari
Opera
HTTP-headers
Picked
Technical Scripter
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
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 ?
How to insert spaces/tabs in text using HTML/CSS?
Difference between var, let and const keywords in JavaScript
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to calculate the number of days between two dates in javascript?
Differences between Functional Components and Class Components in React
How to create footer to stay at the bottom of a Web page?
C Program to count the number of zeros from 0 to N - GeeksforGeeks

07 Aug, 2020
Given a number N, the task is to write C program to count the number of zeros from 0 to N.
Examples:
Input: N = 10Output: 2Explanation:The number with zeros are 0, 10 till 10. Hence the count of zeros is 2.
Input: N = 20Output: 3Explanation:The number with zeros are 0, 10, 20 till 20. Hence the count of zeros is 3.
Approach:
Iterate from 0 to N.For each number do the following:Store the above number in a variable temp.For each digit in temp, if the digit is zero then increment the zero count by 1.Print the count of zeros calculated in the above steps.
Iterate from 0 to N.
For each number do the following:Store the above number in a variable temp.For each digit in temp, if the digit is zero then increment the zero count by 1.
Store the above number in a variable temp.
For each digit in temp, if the digit is zero then increment the zero count by 1.
Print the count of zeros calculated in the above steps.
Below is the implementation of the above approach:
// C program for the above approach#include <stdio.h>  // Function to count zero in tempint countZero(int temp){    int cnt = 0;      // Iterate each digit in temp    while (temp) {          // If digit is zero, increment        // the count        if (temp % 10 == 0)            cnt++;          temp /= 10;    }      // Return the final count    return cnt;}  // Function that counts the number of// zeros from 0 to Nvoid countZerostillN(int N){   // To store the finalCount of zero    int finalCount = 1;      // Iterate from 0 to N    for (int i = 1; i <= N; i++) {          // Function call to count the        // zeros in variable i        finalCount += countZero(i);    }      // Print the final Count of zero    printf("%d", finalCount);}  // Driver Codeint main(){    // Given number    int N = 20;      // Function Call    countZerostillN(N);}
3

Time Complexity: O(N)Auxiliary Space: O(1)
number-digits
C Programs
School Programming
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
C Program to read contents of Whole File
Producer Consumer Problem in C
C program to find the length of a string
C / C++ Program for Dijkstra's shortest path algorithm | Greedy Algo-7
Regular expressions in C
Python Dictionary
Arrays in C/C++
Inheritance in C++
Reverse a string in Java
Interfaces in Java
Python - Frequency Distribution

Counting the frequency of occurrence of a word in a body of text is often needed during text processing. This can be achieved by applying the word_tokenize() function and appending the result to a list to keep count of the words as shown in the below program. 
from nltk.tokenize import word_tokenize
from nltk.corpus import gutenberg

sample = gutenberg.raw("blake-poems.txt")

token = word_tokenize(sample)
wlist = []

for i in range(50):
    wlist.append(token[i])

wordfreq = [wlist.count(w) for w in wlist]
print("Pairs\n" + str(zip(token, wordfreq)))
When we run the above program, we get the following output −
[([', 1), (Poems', 1), (by', 1), (William', 1), (Blake', 1), (1789', 1), (]', 1), (SONGS', 2), (OF', 3), (INNOCENCE', 2), (AND', 1), (OF', 3), (EXPERIENCE', 1), (and', 1), (THE', 1), (BOOK', 1), (of', 2), (THEL', 1), (SONGS', 2), (OF', 3), (INNOCENCE', 2), (INTRODUCTION', 1), (Piping', 2), (down', 1), (the', 1), (valleys', 1), (wild', 1), (,', 3), (Piping', 2), (songs', 1), (of', 2), (pleasant', 1), (glee', 1), (,', 3), (On', 1), (a', 2), (cloud', 1), (I', 1), (saw', 1), (a', 2), (child', 1), (,', 3), (And', 1), (he', 1), (laughing', 1), (said', 1), (to', 1), (me', 1), (:', 1), (``', 1)]

Conditional Frequency Distribution is used when we want to count words meeting specific crteria satisfying a set of text. 
import nltk
#from nltk.tokenize import word_tokenize
from nltk.corpus import brown

cfd = nltk.ConditionalFreqDist(
          (genre, word)
          for genre in brown.categories()
          for word in brown.words(categories=genre))
categories = ['hobbies', 'romance','humor']
searchwords = [ 'may', 'might', 'must', 'will']
cfd.tabulate(conditions=categories, samples=searchwords)
When we run the above program, we get the following output −
          may might  must  will 
hobbies   131    22    83   264 
romance    11    51    45    43 
  humor     8     8     9    13 


    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
Converting seconds into days, hours, minutes and seconds in C++

In this tutorial, we will be discussing a program to convert seconds into days, hours, minutes and seconds.
For this we will be provided with a random number of seconds. Our task is to convert it into proper number of days, hours, minutes and seconds respectively.
 Live Demo
#include <bits/stdc++.h>
using namespace std;
//converting into proper format
void convert_decimal(int n) {
   int day = n / (24 * 3600);
   n = n % (24 * 3600);
   int hour = n / 3600;
   n %= 3600;
   int minutes = n / 60 ;
   n %= 60;
   int seconds = n;
   cout << day << " " << "days " << hour
   << " " << "hours " << minutes << " "
   << "minutes " << seconds << " "
   << "seconds " << endl;
}
int main(){
   int n = 126700;
   convert_decimal(n);
   return 0;
}
1 days 11 hours 11 minutes 40 seconds
C++ program for the Array Index with same count of even or odd numbers on both sides?

Finding the array index with the same count of even or odd number is a number that has equal number of either numbers or odd number on both sides of it i.e. no.s at left = no.s right.
Here, we need a few definitions that are related to the concept,
Array − A container of elements of same data type.
Array Index − The position of an element is called its index. Index of array always start from 0.
Even number − A number that is divisible by 2.
Odd number − A number that is not divisible by 2.
A whole number can either be an even number or an odd number.
Now, lets see an example that will make the concept more clear.
Input: arr[] = {4, 3, 2, 1, 2}
Output : 2
At index 2, there is one odd number on its left and one odd on its right.
We have an array of n integers where to find the index of array element in such a way that it has even number even number of element on its left side and an even number of elements on its right side or we have to find frequency of odd number of element on its left side it is equal to the frequency of odd number of element in it there right side if there is no such condition so we have to who written ok print -1 if there is this type of condition then we have to print its index
To calculate the index of element with count of even or odd numbers on both sides, we need to find the number of elements on the left of and on the right of the given element.
Given array arr[] , n number of elements of array.
Step 1 : For i -> 0 to n, follow step 2 - 5:
Step 2: initialise e_l, o_l, e_r, o_r to 0.
Step 3: for j -> o to i
   Step 3.1 : count values for e_l and o_l.
Step 4: for j -> i+1 to n
   Step 4.1 : count values for e_r and o_r.
Step 5: if(e_l == e_r) or (o_l == e_r ) , print i.
 Live Demo
#include <iostream>
using namespace std;
int main() {
   int arr[] = {4, 3, 2, 1, 2};
   int n = 5;
   cout<<"The array is : ";
   for(int i = 0; i < n; i++) {
      cout<<arr[i]<<" ";
   }
   cout<<"\nThe index of the element with the same count of even or odd numbers on both sides = ";
   for (int i = 0; i < n; i++) {
      int o_l = 0, e_l = 0;
      int o_r = 0, e_r = 0;
   for (int j = 0; j < i; j++) {
      if (arr[j] % 2 == 0)
         e_l++;
      else
         o_l++;
   }
   for (int k = n - 1; k > i; k--) {
      if (arr[k] % 2 == 0)
         e_r++;
      else
         o_r++;
   }
   if (e_r == e_l || o_r == o_l)
      cout<<i<<endl;
   }
   return 0;
}
The array is : 4 3 2 1 2
The index of the element with the same count of even or odd numbers on both sides = 2
Bootstrap 4 - Clearfix Close Icon

Clearfix utility is used to clear the floated content in a container and close icon for dismissing the content such as alerts or modals.
For clearfix utility, use the .clearfix class to the parent element and close the content by adding close class on the element.
The following example shows the usage of clearfix and close icon −
<html lang = "en">
   <head>
      <!-- Meta tags -->
      <meta charset = "utf-8">
      <meta name = "viewport" content = "width = device-width, initial-scale = 1, shrink-to-fit = no">
      
      <!-- Bootstrap CSS -->
      <link rel = "stylesheet" 
         href = "https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
      <script src =  "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <title>Bootstrap 4 Example</title>
   </head>
   
   <body>
      <div class = "container-fluid">
         <h2>Clearfix</h2>
         <div class = "bg-secondary clearfix">
            <button type = "button" class = "btn btn-success float-left">Left Button</button>
            <button type = "button" class = "btn btn-success float-right">Right Button</button>
         </div>
         <br>
         
         <h2>Close</h2>
         <button type =" button" class = "close" aria-label = "Close">
            <span aria-hidden = "true">×</span>
         </button>
      </div>
      
      <!-- jQuery first, then Popper.js, then Bootstrap JS -->
      <script src = "https://code.jquery.com/jquery-3.2.1.slim.min.js" 
         integrity = "sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" 
         crossorigin = "anonymous">
      </script>
      
      <!-- Popper -->
      <script src = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" 
         integrity = "sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" 
         crossorigin = "anonymous">
      </script>
      
      <!-- Latest compiled and minified Bootstrap JavaScript -->
      <script src = "https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" 
         integrity = "sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" 
         crossorigin = "anonymous">
      </script>
      
   </body>
</html>
It will produce the following result −

    26 Lectures 
     2 hours 

 Anadi Sharma

    54 Lectures 
     4.5 hours 

 Frahaan Hussain

    161 Lectures 
     14.5 hours 

 Eduonix Learning Solutions

    20 Lectures 
     4 hours 

 Azaz Patel

    15 Lectures 
     1.5 hours 

 Muhammad Ismail

    62 Lectures 
     8 hours 

 Yossef Ayman Zedan
 Print
 Add Notes
 Bookmark this page
How to create a plot in base R with dates sequence on X-axis?

If we have a vector that contains dates as sequence that needs to be plotted on the X-axis and another vector for the response then the plot can be simply created by using the plot function. In the plot function, we would need to pass the dates as the first argument and the response vector as the second argument. Check ou the examples below to understand how it works.
 Live Demo
x<-rpois(10,5)
x
[1] 4 7 4 4 6 4 3 4 9 5
dates<-seq(as.Date("25/11/2020",format="%d/%m/%Y"),by="days",length=length(x))
dates
[1] "2020-11-25" "2020-11-26" "2020-11-27" "2020-11-28" "2020-11-29"
[6] "2020-11-30" "2020-12-01" "2020-12-02" "2020-12-03" "2020-12-04"
plot(dates,x)
y<-sample(0:9,10,replace=TRUE)
dates<-seq(as.Date("01/01/2020",format="%d/%m/%Y"),by="days",length=length(x))
plot(dates,y)
Python - Swap K suffix with prefix - GeeksforGeeks

11 Oct, 2020
Given a List, perform a swap of K prefix and suffix.
Examples:
Input : test_list = [5, 6, 3, 1, 0, 1, 3, 5, 7, 9], K = 2Output : [7, 9, 3, 1, 0, 1, 3, 5, 5, 6]Explanation : Rear 2 and Front 2 elements swapped.
Input : test_list = [5, 6, 3, 1, 0, 1, 3, 5, 7, 9], K = 1Output : [9, 6, 3, 1, 0, 1, 3, 5, 7, 5]Explanation : Rear 1 and Front 1 element swapped.
Method #1: Using slice and range swap 
In this, we perform the task of getting the required slice using list slicing and perform range swap to swap elements. This is inplace method to solve this problem.
Python3
# Python3 code to demonstrate working of# Swap K suffix with prefix# Using range swap + slice()  # initializing listtest_list = [5, 6, 3, 1, 0, 1, 3, 5, 7, 9]  # printing original listprint("The original list is : " + str(test_list))  # initializing KK = 3  # performing range swaptest_list[:K], test_list[len(    test_list) - K:] = test_list[len(test_list) - K:], test_list[:K]  # printing resultprint("After prefix suffix swap : " + str(test_list))
The original list is : [5, 6, 3, 1, 0, 1, 3, 5, 7, 9]
After prefix suffix swap : [5, 7, 9, 1, 0, 1, 3, 5, 6, 3]

Method #2 : Using slice notation
In this we perform reconstruction of list elements using slicing each list performing slice.
Python3
# Python3 code to demonstrate working of# Swap K suffix with prefix# Using slice notation  # initializing listtest_list = [5, 6, 3, 1, 0, 1, 3, 5, 7, 9]  # printing original listprint("The original list is : " + str(test_list))  # initializing KK = 3  # joining parts using sliceres = test_list[len(test_list) - K:] + \    test_list[K: len(test_list) - K] + test_list[:K]  # printing resultprint("After prefix suffix swap : " + str(res))
The original list is : [5, 6, 3, 1, 0, 1, 3, 5, 7, 9]
After prefix suffix swap : [5, 7, 9, 1, 0, 1, 3, 5, 6, 3]

Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Pandas dataframe.groupby()
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python program to check whether a number is Prime or not
Python | Convert a list to dictionary
Build index in the background with MongoDB

To create index in the background, use createIndex() method and set “background: true” as in the below syntax −
db.yourCollectionName.createIndex({"yourFieldName1":1,"yourFieldName2":1},{background: true} );
Let us implement the above syntax in order to create index and set background −
> db.indexCreationDemo.createIndex({"StudentName":1,"StudentAge":1},{background: true} );
{
   "createdCollectionAutomatically" : true,
   "numIndexesBefore" : 1,
   "numIndexesAfter" : 2,
   "ok" : 1
}
Let us display the indexes −
> db.indexCreationDemo.getIndexes();
This will produce the following output −
[
   {
      "v" : 2,
      "key" : {
         "_id" : 1
      },
      "name" : "_id_",
      "ns" : "web.indexCreationDemo"
   },
   {
      "v" : 2,
      "key" : {
         "StudentName" : 1,
         "StudentAge" : 1
      },
      "name" : "StudentName_1_StudentAge_1",
      "ns" : "web.indexCreationDemo",
      "background" : true
   }
]
HTML | DOM timeStamp Event Property - GeeksforGeeks

18 Jan, 2019
The timeStamp Event property is used to get the timestamp of when a particular event is created. It basically returns the difference in time (in milliseconds) between the time of event created by the browser and January 1, 1970.
It is a read-only property.
Syntax:
event.timeStamp
Return Value: : This event returns the number of milliseconds since January 1, 1970 and when the event is triggered.
Example:
<!DOCTYPE html><html>    <head>        <title>DOM timeStamp Event Property</title>    </head>      <body onwheel="Geeks(event)"           style="text-align:center">              <h1 style="color: green;">            GeeksforGeeks        </h1>                  <h2>DOM timeStamp Event Property</h2>                  <p onclick="Geeks(event)">            The click event occurred             <span id = "s" style="color:green">                unknown            </span>             milliseconds after January 1, 1970.        </p>                   <script>            function Geeks(event) {                var doc = event.timeStamp;                document.getElementById("s").innerHTML = doc;            }        </script>    </body></html>                    
Output:Before clicking the paragraph:After clicking the paragraph:Supported Browsers: The browser supported by timeStamp Event property are listed below:
Apple Safari
Google Chrome
Firefox
Opera
Internet Explorer 9.0
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-DOM
HTML-Property
HTML
Web Technologies
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
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 ?
How to insert spaces/tabs in text using HTML/CSS?
How to indent text in HTML by using CSS ? - GeeksforGeeks

12 Aug, 2021
In this article, we will discuss various methods to indent text in an HTML document. Text indentation is used to set the length of empty white space before lines of text in a block. It generally marks the beginning of a paragraph.
There are two common approaches for text indentation:
Approach 1: Using the margin-left property: This property is used to add margin to the left of an element. It can be used to add the required indent by specifying the space needed in suitable length units or percentage.
Example: This example uses the margin-left property to indent the whole block of text.
HTML
<!DOCTYPE html><html>  <head>    <style>        p {            margin-left: 40px;        }    </style></head>  <body>    <h2>Welcome To GFG</h2>      <p>        We provide a variety of services         for you to learn, thrive and also         have fun! Free Tutorials, Millions         of Articles, Live, Online and         Classroom Courses ,Frequent Coding         Competitions ,Webinars by Industry         Experts, Internship opportunities         and Job Opportunities.    </p></body>  </html>
Output:
Approach 2: Using the text-indent property: This property is used to set the amount of space before the first line of text in a paragraph. It can be specified in length units or a percentage as required. 
Example: In this example, the first line of the paragraph is indented using the text-indent property.
HTML
<!DOCTYPE html><html>  <head>    <style>        p {            text-indent: 40px;        }    </style></head>  <body>    <h2>Welcome To GFG</h2>      <p>        We provide a variety of services         for you to learn, thrive and also         have fun! Free Tutorials, Millions         of Articles, Live, Online and         Classroom Courses ,Frequent Coding         Competitions ,Webinars by Industry         Experts, Internship opportunities         and Job Opportunities.    </p></body>  </html>
Output:
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
CSS-Properties
CSS-Questions
HTML-Questions
Picked
CSS
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to set space between the flexbox ?
Design a web page using HTML and CSS
Form validation using jQuery
How to style a checkbox using CSS?
Search Bar using HTML, CSS and JavaScript
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)
HTML Cheat Sheet - A Basic Guide to HTML
Tryit Editor v3.7

HTML Input types
Tryit: input type = search
Program to find N-th term of series 1, 3, 12, 60, 360...in C++

In this problem, we are given a number N. Our task is to create a Program to find N-th term of series 1, 3, 12, 60, 360...in C++.
Given Series
1, 3, 12, 60, 360, 2520 ... N Terms
Let’s take an example to understand the problem,
Input − N = 6
Output − 2520
The general term formula for this one is a bit tricky. So, the increase in the series values is huge. So, there can be a few possibilities factorial or exponentials. So, we will first consider factorial, and on observing we can see the growth half as half of the factorial values. Also, the factorial of 2 is the first term here. So, the general formula would be,
TN = ((N+1)!)/ 2
#include <iostream>
using namespace std;
int calcFact(int n){
if(n == 1){
return 1;
}
return (n*calcFact(n-1));
}
int findNTerm(int N) {
int nthTerm = ( (calcFact(N+1)) /2 );
return nthTerm;
}
int main()
{
int N = 8;
cout<<N<<"th term of the series is "<<findNTerm(N);
return 0;
}
8th term of the series is 181440
SQLite - INSERT Query

SQLite INSERT INTO Statement is used to add new rows of data into a table in the database.
Following are the two basic syntaxes of INSERT INTO statement.
INSERT INTO TABLE_NAME [(column1, column2, column3,...columnN)]  
VALUES (value1, value2, value3,...valueN);

Here, column1, column2,...columnN are the names of the columns in the table into which you want to insert data.
You may not need to specify the column(s) name in the SQLite query if you are adding values for all the columns of the table. However, make sure the order of the values is in the same order as the columns in the table. The SQLite INSERT INTO syntax would be as follows −
INSERT INTO TABLE_NAME VALUES (value1,value2,value3,...valueN);

Consider you already have created COMPANY table in your testDB.db as follows −
sqlite> CREATE TABLE COMPANY(
   ID INT PRIMARY KEY     NOT NULL,
   NAME           TEXT    NOT NULL,
   AGE            INT     NOT NULL,
   ADDRESS        CHAR(50),
   SALARY         REAL
);
Now, the following statements would create six records in COMPANY table.
INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY)
VALUES (1, 'Paul', 32, 'California', 20000.00 );

INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY)
VALUES (2, 'Allen', 25, 'Texas', 15000.00 );

INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY)
VALUES (3, 'Teddy', 23, 'Norway', 20000.00 );

INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY)
VALUES (4, 'Mark', 25, 'Rich-Mond ', 65000.00 );

INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY)
VALUES (5, 'David', 27, 'Texas', 85000.00 );

INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY)
VALUES (6, 'Kim', 22, 'South-Hall', 45000.00 );
You can create a record in COMPANY table using the second syntax as follows −
INSERT INTO COMPANY VALUES (7, 'James', 24, 'Houston', 10000.00 );

All the above statements would create the following records in COMPANY table. In the next chapter, you will learn how to display all these records from a table.
ID          NAME        AGE         ADDRESS     SALARY
----------  ----------  ----------  ----------  ----------
1           Paul        32          California  20000.0
2           Allen       25          Texas       15000.0
3           Teddy       23          Norway      20000.0
4           Mark        25          Rich-Mond   65000.0
5           David       27          Texas       85000.0
6           Kim         22          South-Hall  45000.0
7           James       24          Houston     10000.0
You can populate data into a table through select statement over another table provided another table has a set of fields, which are required to populate the first table. Here is the syntax −
INSERT INTO first_table_name [(column1, column2, ... columnN)] 
   SELECT column1, column2, ...columnN 
   FROM second_table_name
   [WHERE condition];

For now, you can skip the above statement. First, let's learn SELECT and WHERE clauses which will be covered in subsequent chapters.

    25 Lectures 
     4.5 hours 

 Sandip Bhattacharya

    17 Lectures 
     1 hours 

 Laurence Svekis

    5 Lectures 
     51 mins

 Vinay Kumar
 Print
 Add Notes
 Bookmark this page
LocalDate lengthOfMonth() method in Java

The length of the month in a particular LocalDate is obtained using the method lengthOfMonth() in the LocalDate class in Java. This method requires no parameters and it returns the length of the month in a particular LocalDate i.e. 28, 29, 30 or 31.
A program that demonstrates this is given as follows −
 Live Demo
import java.time.*;
public class Main {
   public static void main(String[] args) {
      LocalDate ld = LocalDate.parse("2019-02-15");
      System.out.println("The LocalDate is: " + ld);
      System.out.println("The length of the month is: " + ld.lengthOfMonth());
   }
}
The LocalDate is: 2019-02-15
The length of the month is: 28
Now let us understand the above program.
First the LocalDate is displayed. Then the length of the month in the LocalDate is obtained using the method lengthOfMonth() and displayed. A code snippet that demonstrates this is as follows −
LocalDate ld = LocalDate.parse("2019-02-15");
System.out.println("The LocalDate is: " + ld);
System.out.println("The length of the month is: " + ld.lengthOfMonth());
Foreach in C++ and C#

C++ 11 introduced foreach loop to traverse over each element. Here is an example −
 Live Demo
#include <iostream>
using namespace std;

int main() {
   int myArr[] = { 99, 15, 67 };

   // foreach loop
   for (int ele : myArr)
   cout << ele << endl;
}
99
15
67
Let us see an example of foreach in C#. It traverses items in a collection −
 Live Demo
using System;

namespace ArrayApplication {
   class MyArray {
      static void Main(string[] args) {
         int [] n = new int[10]; /* n is an array of 10 integers */

         for ( int i = 0; i < 10; i++ ) {
            n[i] = i + 100;
         }
         /* output each array element's value */
         foreach (int j in n ) {
            int i = j-100;
            Console.WriteLine("Element[{0}] = {1}", i, j);
         }
         Console.ReadKey();
      }
   }
}
Element[0] = 100
Element[1] = 101
Element[2] = 102
Element[3] = 103
Element[4] = 104
Element[5] = 105
Element[6] = 106
Element[7] = 107
Element[8] = 108
Element[9] = 109
Java Program for n-th Fibonacci number

There are multiple ways in which the ‘n’thFibonacci number can be found. Here, we will use dynamic programming technique as well as optimizing the space.
Let us see an example −
 Live Demo
public class Demo{
   static int fibo(int num){
      int first = 0, second = 1, temp;
      if (num == 0)
      return first;
      if (num == 1)
      return second;
      for (int i = 2; i <= num; i++){
         temp = first + second;
         first = second;
         second = temp;
      }  
      return second;
   }
   public static void main(String args[]){
      int num = 7;
      System.out.print("The 7th fibonacci number is : ");
      System.out.println(fibo(num));
   }
}
The 7th fibonacci number is : 13
A class named Demo contains a function named ‘fibo’, that gives Fibonacci numbers upto a given
limit. It checks if the number is 0, and if yes, it returns 0, and if the number is 1, it returns 0,1 as output. Otherwise, it iterates from 0 to the range and then adds the previous number and current number and gives that as the ‘n’th Fibonacci number. In the main function, a value for the range (upto which Fiboncacci numbers need to be generated) is defined. The function ‘fibo’ is called by passing this value. The relevant message is displayed on the console.
C library function - ungetc()

The C library function int ungetc(int char, FILE *stream) pushes the character char (an unsigned char) onto the specified stream so that the this is available for the next read operation.
Following is the declaration for ungetc() function.
int ungetc(int char, FILE *stream)
char − This is the character to be put back. This is passed as its int promotion.
char − This is the character to be put back. This is passed as its int promotion.
stream − This is the pointer to a FILE object that identifies an input stream.
stream − This is the pointer to a FILE object that identifies an input stream.
If successful, it returns the character that was pushed back otherwise, EOF is returned and the stream remains unchanged.
The following example shows the usage of ungetc() function.
#include <stdio.h>

int main () {
   FILE *fp;
   int c;
   char buffer [256];

   fp = fopen("file.txt", "r");
   if( fp == NULL ) {
      perror("Error in opening file");
      return(-1);
   }
   while(!feof(fp)) {
      c = getc (fp);
      /* replace ! with + */
      if( c == '!' ) {
         ungetc ('+', fp);
      } else {
         ungetc(c, fp);
      }
      fgets(buffer, 255, fp);
      fputs(buffer, stdout);
   }
   return(0);
}
Let us assume, we have a text file file.txt, which contains the following data. This file will be used as an input for our example program −
this is tutorials point
!c standard library
!library functions and macros
Now, let us compile and run the above program that will produce the following result −
this is tutorials point
+c standard library
+library functions and macros


    12 Lectures 
     2 hours 

 Nishant Malik

    12 Lectures 
     2.5 hours 

 Nishant Malik

    48 Lectures 
     6.5 hours 

 Asif Hussain

    12 Lectures 
     2 hours 

 Richa Maheshwari

    20 Lectures 
     3.5 hours 

 Vandana Annavaram

    44 Lectures 
     1 hours 

 Amit Diwan
 Print
 Add Notes
 Bookmark this page
List remove(int index) method in Java with Examples - GeeksforGeeks

11 Dec, 2018
The remove(int index) method of List interface in Java is used to remove an element from the specified index from a List container and returns the element after removing it. It also shifts the elements after the removed element by 1 position to the left in the List.
Syntax:
E remove(int index)

Where, E is the type of element maintained
by this List collection

Parameters: It accepts a single parameter index of integer type which represents the index of the element needed to be removed from the List.
Return Value: It returns the element present at the given index after removing it.
Below program illustrate the remove(int index) method of List in Java:
Program 1:
// Program to illustrate the// remove(int index) method  import java.util.*;  public class GFG {    public static void main(String[] args)    {          // Declare an empty List of size 5        List<Integer> list = new ArrayList<Integer>(5);          // Add elements to the list        list.add(5);        list.add(10);        list.add(15);        list.add(20);        list.add(25);          // Index from which you want to remove element        int index = 2;          // Initial list        System.out.println("Initial List: " + list);          // remove element        list.remove(index);          // Final list        System.out.println("Final List: " + list);    }}
Initial List: [5, 10, 15, 20, 25]
Final List: [5, 10, 20, 25]

Program 2:
// Program to illustrate the// remove(int index) method  import java.util.*;  public class GFG {    public static void main(String[] args)    {          // Declare an empty List of size 5        List<String> list = new ArrayList<String>(5);          // Add elements to the list        list.add("Welcome");        list.add("to");        list.add("Geeks");        list.add("for");        list.add("Geeks");          // Index from which you want        // to remove element        int index = 2;          // Initial list        System.out.println("Initial List: " + list);          // remove element        list.remove(index);          // Final list        System.out.println("Final List: " + list);    }}
Initial List: [Welcome, to, Geeks, for, Geeks]
Final List: [Welcome, to, for, Geeks]

Reference: https://docs.oracle.com/javase/8/docs/api/java/util/List.html#remove-int-
Java-Collections
Java-Functions
java-list
Java
Java
Java-Collections
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Functional Interfaces in Java
Stream In Java
Constructors in Java
Different ways of Reading a text file in Java
Exceptions in Java
Generics in Java
Comparator Interface in Java with Examples
Strings in Java
Difference between Abstract Class and Interface in Java
How to remove an element from ArrayList in Java?
Connecting to a Jupyter Notebook on a remote Linux machine with an SSH tunnel | by Shah Newaz Khan | Towards Data Science

In this post I will go over how I connect to my work machine and run Jupyter Notebook workloads when I am working remotely.
Step 1 is to ssh into your remote machine and launch Jupyter Notebook to a local port with the --no-browser option.
user@local_machine$ ssh user@remote_machine user@remote_machine$ jupyter notebook --no-browser --port=8889
Step 2 is to set up an SSH tunnel from your local machine to port 8889 on the remote machine where the Jupyter Notebook is being served.
user@local_machine$ ssh -N -L localhost:8888:localhost:8889 user@remote_mahcine
Here is a break down of the ssh options
-N Do not execute a remote command. This is useful for just forwarding ports
-L local_socket:remote_socketSpecifies that connections to the given TCP port or Unix socket on the local (client) host are to be forwarded to the given host and port, or Unix socket, on the remote side. This works by allocating a socket to listen to either a TCP port on the local side, optionally bound to the specified bind_address, or to a Unix socket. Whenever a connection is made to the local port or socket, the connection is forwarded over the secure channel, and a connection is made to either host port hostport, or the Unix socket remote_socket, from the remote machine.
Port forwardings can also be specified in the configuration file. Only the superuser can forward privileged ports. IPv6 addresses can be specified by enclosing the address in square brackets.
By default, the local port is bound in accordance with the GatewayPorts setting. However, an explicit bind_address may be used to bind the connection to a specific address. The bind_address of “localhost” indicates that the listening port be bound for local use only, while an empty address or ‘*’ indicates that the port should be available from all interfaces.
Note that running the SSH tunnel with -N will not log any outputs, as long as you do not get an error this means you have established a tunnel.
On the local machine browser load localhost:8888 and the Jupyter Notebook from your remote machine will load out as expected.
Python | Pandas dataframe.add_suffix() - GeeksforGeeks

16 Nov, 2018
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.Dataframe.add_suffix() function can be used with both series as well as dataframes. add_suffix() function Concatenate suffix string with panel items names.
For Series, the row labels are suffixed.
For DataFrame, the column labels are suffixed.
Syntax: DataFrame.add_suffix(suffix)

Parameters:
suffix : string

Returns:  with_suffix: type of caller

For link to CSV file Used in Code, click here
Example #1: Suffix _col in each columns in the dataframe.
# importing pandas as pdimport pandas as pd  # Making data frame from the csv filedf = pd.read_csv("nba.csv")  # Printing the first 10 rows of# the data frame for visualizationdf[:10]
# Using add_suffix() function to # add '_col' in each column labeldf = df.add_suffix('_col')  # Print the dataframedf 
Output:
 
Example #2: Using add_suffix() with Series in pandas
add_suffix() alters the row index labels in the case of series.
# importing pandas as pdimport pandas as pd  # Creating a Series df = pd.Series([1, 2, 3, 4, 5, 10, 11, 21, 4])  # This will suffix '_Row' in# each row of the seriesdf = df.add_suffix('_Row')  # Print the Seriesdf
Output:
Python pandas-dataFrame
Python pandas-dataFrame-methods
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Selecting rows in pandas DataFrame based on conditions
Check if element exists in list in Python
Python | os.path.join() method
Defaultdict in Python
Python | Get unique values from a list
Create a directory in Python
Python | Pandas dataframe.groupby()