code-rag-bench/online-tutorials huggingface dataset:
VBScript WeekDay Function

The WeekDay function returns an integer from 1 to 7 that represents the day of the week for the specified date.
Weekday(date[,firstdayofweek])  

Date, a Required Parameter. The Week day would be returns for this specified date.
Date, a Required Parameter. The Week day would be returns for this specified date.
firstdayofweek, an Optional Parameter. Specifies the first day of the week..

0 = vbUseSystemDayOfWeek - Use National Language Support (NLS) API setting
1 = vbSunday - Sunday
2 = vbMonday - Monday
3 = vbTuesday - Tuesday
4 = vbWednesday - Wednesday
5 = vbThursday - Thursday
6 = vbFriday - Friday
7 = vbSaturday - Saturday


firstdayofweek, an Optional Parameter. Specifies the first day of the week..
0 = vbUseSystemDayOfWeek - Use National Language Support (NLS) API setting
0 = vbUseSystemDayOfWeek - Use National Language Support (NLS) API setting
1 = vbSunday - Sunday
1 = vbSunday - Sunday
2 = vbMonday - Monday
2 = vbMonday - Monday
3 = vbTuesday - Tuesday
3 = vbTuesday - Tuesday
4 = vbWednesday - Wednesday
4 = vbWednesday - Wednesday
5 = vbThursday - Thursday
5 = vbThursday - Thursday
6 = vbFriday - Friday
6 = vbFriday - Friday
7 = vbSaturday - Saturday
7 = vbSaturday - Saturday
<!DOCTYPE html>
<html>
   <body>
      <script language = "vbscript" type = "text/vbscript">
         document.write("Line 1: " & Weekday("2013-05-16",1) & "<br />")
         document.write("Line 2: " & Weekday("2013-05-16",2) & "<br />")
         document.write("Line 3: " & Weekday("2013-05-16",2) & "<br />")
         document.write("Line 4: " & Weekday("2010-02-16") & "<br />")
         document.write("Line 5: " & Weekday("2010-02-17") & "<br />")
         document.write("Line 6: " & Weekday("2010-02-18") & "<br />")

      </script>
   </body>
</html>
When you save it as .html and execute it in Internet Explorer, then the above script will produce the following result −
Line 1: 5
Line 2: 4
Line 3: 4
Line 4: 3
Line 5: 4
Line 6: 5


    63 Lectures 
     4 hours 

 Frahaan Hussain
 Print
 Add Notes
 Bookmark this page
How to Import and Export Datasets in Google Colab | by Mohammad Masum, PhD | Towards Data Science

Google Colaboratory, known as Colab, is a free Jupyter Notebook environment with many pre-installed libraries like Tensorflow, Pytorch, Keras, OpenCV, and many more. It is one of the cloud services that support GPU and TPU for free. Importing a dataset and training models on the data in the Colab facilitate the coding experience. We can apply different ways to import and download data in Colab. In this tutorial, I will discuss my experience in:
Importing data from Google DriveImporting and downloading data into the local system
Importing data from Google Drive
Importing and downloading data into the local system
Mounting Google Drive
We can access files in the drive using mounting Google Drive. Mounting Drive into the Colab meaning that setting up the google drive account as a virtual drive so that we can access the resources of the drive just like a local hard drive.
Step 1 To connect Google Drive (GDrive) with Colab, execute the following two lines of code in Colab:
from google.colab import drivedrive.mount("/content/gdrive")
Running the shell will return a URL link and ask for an authorization code:
Step 2 Follow to the mentioned link, sign in Google account, and copy the authorization code by clicking at highlighted spot:
Step 3 Paste the authorization code in the shell and finally, Google Drive will be mounted at /content/gdrive. Note that, files in the drive are under the folder /content/gdrive/My Drive/. Now, we can import files in GDrive using a library like Pandas.
Step 4 For instance, we have a dataset (sample.csv) in /My Drive/sample data folder in GDrive.
Executing the following two lines of code will import the data into Colab:
import pandas as pdpd.read_csv('/content/gdrive/My Drive/sample data/sample.csv')
Importing Data from Local System
Step1 Run the following two lines of code to import data from the local system.
from google.colab import filesuploaded = files.upload()
Executing the shell will invoke a browse button:
Step 2 Browsing directories in the local system, we can upload data into Colab:
Finally, we can read the data using a library like Pandas:
pd.read_csv("sample.csv")
Downloading Data into Google Drive and Local System
We can easily download data into local directories by executing the following two lines of codes given the dataset is already in CSV format:
from google.colab import filesfiles.download('sample.csv')
A pandas dataframe can be downloaded by executing the following code. Given that the name of the dataframe is “sample”, then save the file in Google Drive using one line code:
sample.to_csv('sample.csv')
Finally, to download in the local drive execute the following single line code:
files.download('sample.csv')
As an additional source, you can also read this blog to understand more about how to deal with files in Colab.
Your membership fee will directly support and inspire Mohammad Masumand and thousands of other writers you read. You’ll also get full access to every story on Medium — https://masum-math8065.medium.com/membership
Find Circles in an Image using OpenCV in Python

The OpenCV platform provides cv2 library for python. This can be used for various shape analysis which is useful in computer vision. In this article we will identify the shape of a circle using Open CV. For that we will use the cv2.HoughCircles() function.Finds circles in a grayscale image using the Hough transform. In the below example we will take an image as input. Then make a copy of it and apply this transform function to identify the circle in the output.
cv2.HoughCircles(image, method, dp, minDist)
Where
Image is the image file converted to grey scale
Method is the algorithm used to detct the circles.
Dp is the inverse ratio of the accumulator resolution to the image resolution.
minDist is the Minimum distance between the center coordinates of detected circles.
In the below example we use the image below as our input image. Then run the below program to get the circles.
The below program detects the presence of circle in an image file. If circle is present then it highlights it.
import cv2
import numpy as np
image = cv2.imread('circle_ellipse_2.JPG')
output = image.copy()
img = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# Find circles
circles = cv2.HoughCircles(img, cv2.HOUGH_GRADIENT, 1.3, 100)
# If some circle is found
if circles is not None:
   # Get the (x, y, r) as integers
   circles = np.round(circles[0, :]).astype("int")
   print(circles)
   # loop over the circles
   for (x, y, r) in circles:
      cv2.circle(output, (x, y), r, (0, 255, 0), 2)
# show the output image
cv2.imshow("circle",output)
cv2.waitKey(0)
Running the above code gives us the following result −
[[93 98 84]]
And we get the below diagram showing the output.
PHP mysqli_prepare() Function

The mysqli_prepare() function prepares an SQL statement for execution, you can use parameter markers ("?") in this query, specify values for them, and execute it later.
mysqli_prepare($con, $str);

con(Mandatory)
This is an object representing a connection to MySQL Server.
str(Mandatory)
This is string value specifying the required query.
This function returns a statement object incase of success and false incase of failure.
This function was first introduced in PHP Version 5 and works works in all the later versions.
Following example demonstrates the usage of the mysqli_prepare() function (in procedural style) −
<?php
   $con = mysqli_connect("localhost", "root", "password", "mydb");

   $query = "CREATE TABLE Test(Name VARCHAR(255), AGE INT)"; 
   mysqli_query($con, $query);
   print("Table Created.....\n");

   $stmt = mysqli_prepare($con, "INSERT INTO Test values(?, ?)");
   mysqli_stmt_bind_param($stmt, "si", $Name, $Age);
   $Name = 'Raju';
   $Age = 25;
   print("Record Inserted.....");

   //Executing the statement
   mysqli_stmt_execute($stmt);

   //Closing the statement
   mysqli_stmt_close($stmt);

   //Closing the connection
   mysqli_close($con);
?>
This will produce following result −
Table Created.....
Record Inserted.....

If you verify the contents of the table as shown below $minus;
mysql> select * from test;
+------+------+
| Name | AGE  |
+------+------+
| Raju |   25 |
+------+------+
1 row in set (0.00 sec)
In object oriented style the syntax of this function is $con-> prepare(); Following is the example of this function in object oriented style $minus;
<?php
   //Creating a connection
   $con = new mysqli("localhost", "root", "password", "mydb");

   $query = "CREATE TABLE Test(Name VARCHAR(255), AGE INT)"; 
   $con -> query($query);
   print("Table Created.....\n");

   $stmt = $con -> prepare( "INSERT INTO Test values(?, ?)");
   $stmt -> bind_param("si", $Name, $Age);
   $Name = 'Raju';
   $Age = 25;
   print("Record Inserted.....");

   //Executing the statement
   $stmt->execute();

   //Closing the statement
   $stmt->close();

   //Closing the connection
   $con->close();
?>
This will produce following result −
Table Created.....
Record Inserted.....


    45 Lectures 
     9 hours 

 Malhar Lathkar

    34 Lectures 
     4 hours 

 Syed Raza

    84 Lectures 
     5.5 hours 

 Frahaan Hussain

    17 Lectures 
     1 hours 

 Nivedita Jain

    100 Lectures 
     34 hours 

 Azaz Patel

    43 Lectures 
     5.5 hours 

 Vijay Kumar Parvatha Reddy
 Print
 Add Notes
 Bookmark this page
Tryit Editor v3.7

Tryit: Individual border sides
RLIKE operator in MySQL - GeeksforGeeks

16 Dec, 2020
RLIKE :This operator in MySQL is used to performs a pattern match of a string expression against a pattern.
Syntax :
RLIKE pattern

Parameters :This method accepts one parameter as mentioned in syntax.
pattern –The pattern which we want to match against an expression. Various pattern and their usage are described below.
Example-1 :The following example finds the employees whose last name starts with the letter S.
CREATE TABLE Employee
(
Employee_id INT AUTO_INCREMENT,  
First_name VARCHAR(100) NOT NULL,
Last_name VARCHAR(100) NOT NULL,
Joining_Date DATE NOT NULL,
PRIMARY KEY(Employee_id )
);
Inserting some data to the Employee table :
INSERT INTO Employee
(First_name ,Last_name , Joining_Date )
VALUES
('Sayantan', 'Majumdar', '2000-01-11'),
('Anushka', 'Samanta', '2002-11-10' ),
('Sayan', 'Sharma', '2005-06-11' ),
('Shayari', 'Das', '2008-01-21' ),
('Sayani', 'Jain', '2008-02-01' ),
('Tapan', 'Samanta', '2010-01-11' ),
('Deepak', 'Sharma', '2014-12-01'  ),
('Ankana', 'Jana', '2018-08-17'),
('Shreya', 'Ghosh', '2020-09-10') ;
So, the Employee Table is as follows.
select * from Employee ;
Output :
Now, we are going to check those employees whose last name stats with ‘S’.
SELECT * FROM Employee   
WHERE Last_name RLIKE '^S' ;
Output :
Example-2 :The following example finds the employees whose first name ends with the letter ‘i’.
SELECT * FROM Employee   
WHERE First_name RLIKE 'i$' ;
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
How to Update Multiple Columns in Single Update Statement in SQL?
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
Composite Key in SQL
SQL using Python
SQL | DROP, TRUNCATE
SQL indexes
SQL | Date functions
What is Temporary Table in SQL?
Window functions in SQL
How to Concat Two Columns Into One With the Existing Column Name in MySQL?
Bootstrap nav-stacked class

Use the nav-stacked class to set the pills vertically. Set the pills vertically using the class .nav-stacked along with the classes: .nav, .nav-pills.
You can try to run the following code to set vertical pills in Bootstrap −
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet">
      <script src = "/scripts/jquery.min.js"></script>
      <script src = "/bootstrap/js/bootstrap.min.js"></script>
   </head>
   <body style = "background: orange;">
      <h2>Subjects</h2>
      <ul class = "nav nav-pills nav-stacked">
         <li class = "active"><a href = "#">Java</a></li>
         <li><a href = "#">WordPress</a></li>
         <li><a href = "#">JavaScript</a></li>
      </ul>
   </body>
</html>
Function Overloading

When we have multiple functions with the same name but different parameters, then they are said to be overloaded. This technique is used to enhance the readability of the program.
There are two ways to overload a function, i.e. −
Having different number of arguments
Having different argument types
Function overloading is normally done when we have to perform one single operation with different number or types of arguments.
The following example shows how function overloading is done in C++, which is an object oriented programming language −
#include <iostream> 
using namespace std;  
void addnum(int,int); 
void addnum(int,int,int); 

int main() {     
   addnum (5,5); 
   addnum (5,2,8); 
   return 0; 
} 

void addnum (int x, int y) {     
   cout<<"Integer number: "<<x+y<<endl; 
} 

void addnum (int x, int y, int z) {     
   cout<<"Float number: "<<x+y+z<<endl; 
}
It will produce the following output −
Integer number: 10 
Float number: 15 

The following example shows how to perform function overloading in Erlang, which is a functional programming language −
-module(helloworld).  
-export([addnum/2,addnum/3,start/0]).   

addnum(X,Y) ->  
   Z = X+Y,  
   io:fwrite("~w~n",[Z]).  
    
addnum(X,Y,Z) ->  
   A = X+Y+Z,  
   io:fwrite("~w~n",[A]).  
  
start() ->
   addnum(5,5),     addnum(5,2,8). 
It will produce the following output −
10 
15 


    32 Lectures 
     3.5 hours 

 Pavan Lalwani

    11 Lectures 
     1 hours 

 Prof. Paul Cline, Ed.D

    72 Lectures 
     10.5 hours 

 Arun Ammasai

    51 Lectures 
     2 hours 

 Skillbakerystudios

    43 Lectures 
     4 hours 

 Mohammad Nauman

    8 Lectures 
     1 hours 

 Santharam Sivalenka
 Print
 Add Notes
 Bookmark this page
How to make a plot title partially bold using ggplot2 in R?

To make a plot title partially bold using ggplot2, we can use bquote function inside labs function and then changing the default font to bold using bold function as shown in the below examples. While using these functions we need to make sure that the title that we want to bold should be inside circular brackets appropriately.
Consider the below data frame −
Live Demo
> x<-rnorm(20)
> y<-rnorm(20)
> df<-data.frame(x,y)
> df
             x           y
1  -0.62160328  0.38477515
2   0.68287365 -1.56169067
3   0.75259774  1.28849990
4   0.56688920 -0.17014225
5   1.22351113 -0.32446764
6  -1.54210099  0.29001967
7   0.08800284  1.34342269
8   1.77498480 -0.75239348
9  -0.31916824  0.24433868
10  0.09802049 -0.91107863
11 -1.63060088  0.05336120
12  0.01328284 -2.36494891
13 -1.69921881 -1.29001305
14 -0.02819300 -0.06126524
15  0.77405426  0.25468262
16 -0.36423968  0.79130216
17  0.26224330  0.10437648
18  0.31894879 -0.50317250
19  0.37739488  0.62952910
20  0.26141716 -0.97143860
Loading ggplot2 package and creating scatterplot with plot title −
> library(ggplot2)
> ggplot(df,aes(x,y))+geom_point()+labs(title="Scatterplot between x and y")
Creating scatterplot with plot title partially in bold −
> ggplot(df,aes(x,y))+geom_point()+labs(title=bquote("Scatterplot between"~bold("x and y")))
How to create a plot in base R with tick marks of larger size?

To create a plot in base R with tick marks of larger size, we can make use of axis function tck argument. The tck argument value will decide the size of the tick mark but since the ticks lie below the plot area hence the value will have a negative associated with it. Therefore, it will be like -0.05. Check out the below examples to understand how it works.
plot(1:10,axes=FALSE,frame=TRUE)
axis(1,1:10,tck=-0.02)
axis(2,1:10,tck=-0.02)
plot(1:10,axes=FALSE,frame=TRUE)
axis(1,1:10,tck=-0.05)
axis(2,1:10,tck=-0.05)
Convert user input string into regular expression using JavaScript

04 Jun, 2020
Regular expressions (RegExp) are patterns used to match character combinations in strings. In JavaScript, regular expressions are also objects. There are two ways to construct a regular expression in JavaScript .
1. Using a regular expression literal, which consists of a pattern enclosed between slashes, as follows.
const reg = /ab+/;
2. Calling the constructor function of the RegExp object, as follows.
const reg = new RegExp('ab+', flag);
Using the constructor function provides run time compilation of the regular expression, hence we should use the second method here as the string is a dynamic input from the user. Both the above expressions correspond to the same RegExp.  
Example:  For the string we will take “Geeks For Geeks'”.
Input : '^Ge'
Output: ["Ge"]
        0: "Ge" 
Input : '[A-z]+'
Output: (3) ["Geeks", "For", "Geeks"]
        0: "Geeks"
        1: "For"
        2: "Geeks" 
Javascript
<script>    const str = "Geeks for Geeks";      // Input from User    const regex = prompt("Enter RegExp");      // Conversion from string to RegExp    const reg = new RegExp(regex, "g");      // The match fn returns the array of strings     // That match to RegExp    const result = str.match(reg);      if (result) console.log(result);    else console.log("Not Found");</script>
Output:
javascript-string
Picked
regular-expression
JavaScript
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
What is the best way in C to convert a number to a string?

02 Jun, 2017
#include<stdio.h>int main(){    char result[50];    float num = 23.34;    sprintf(result, "%f", num);    printf("\n The string for the num is %s", result);    getchar();}
You can also write your own function using ASCII values of numbers.
C-Data Types
c-puzzle
C Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Check if a column starts with given string in Pandas DataFrame? - GeeksforGeeks

01 Aug, 2020
In this program, we are trying to check whether the specified column in the given data frame starts with specified string or not. Let us try to understand this using an example suppose we have a dataset named student_id, date_of_joining, branch. Example:
Python3
#importing library pandas as pdimport pandas as pd    #creating data frame for studentdf = pd.DataFrame({    'Student_id': ['TCS101','TCS103', 'PCS671',                    'ECS881', 'MCS961'],          'date_of_joining': ['12/12/2016','07/12/2015',                        '11/11/2011','09/12/2014',                        '01/01/2017'],          'Branch': ['Computer Science','Computer Science',               'Petroleum','Electrical','Mechanical']})  # printing the given data framedf
Output:
Now we want to know whether student_id starts with  TCS or not. Now let us try to implement this using Python
Python3
#importing library pandas as pdimport pandas as pd    #creating data frame for studentdf = pd.DataFrame({    'Student_id': ['TCS101','TCS103', 'PCS671',                    'ECS881', 'MCS961'],          'date_of_joining': ['12/12/2016','07/12/2015',                        '11/11/2011','09/12/2014',                        '01/01/2017'],          'Branch': ['Computer Science','Computer Science',               'Petroleum','Electrical','Mechanical']})  # joining new column in dataframe # .startswith function used to checkdf['student_id_starts_with_TCS'] = list(    map(lambda x: x.startswith('TCS'), df['Student_id']))   # printing new data framedf
Output:
In the above code, we used .startswith() function to check whether the values in the column starts with the given string. The .startswith() method in Python returns True if the string starts with the specified value, if not it returns False.
Python pandas-dataFrame
Python Pandas-exercise
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
Enumerate() in Python
How to Install PIP on Windows ?
Different ways to create Pandas Dataframe
Reading and Writing to text files in Python
sum() function in Python
Create a Pandas DataFrame from Lists
How to drop one or multiple columns in Pandas Dataframe
*args and **kwargs in Python
Graph Plotting in Python | Set 1
Data Structure and Algorithms Selection Sort

Selection sort is a simple sorting algorithm. This sorting algorithm is an in-place comparison-based algorithm in which the list is divided into two parts, the sorted part at the left end and the unsorted part at the right end. Initially, the sorted part is empty and the unsorted part is the entire list.
The smallest element is selected from the unsorted array and swapped with the leftmost element, and that element becomes a part of the sorted array. This process continues moving unsorted array boundary by one element to the right.
This algorithm is not suitable for large data sets as its average and worst case complexities are of Ο(n2), where n is the number of items.
Consider the following depicted array as an example.
For the first position in the sorted list, the whole list is scanned sequentially. The first position where 14 is stored presently, we search the whole list and find that 10 is the lowest value.
So we replace 14 with 10. After one iteration 10, which happens to be the minimum value in the list, appears in the first position of the sorted list.
For the second position, where 33 is residing, we start scanning the rest of the list in a linear manner.
We find that 14 is the second lowest value in the list and it should appear at the second place. We swap these values.
After two iterations, two least values are positioned at the beginning in a sorted manner.
The same process is applied to the rest of the items in the array.
Following is a pictorial depiction of the entire sorting process −
Now, let us learn some programming aspects of selection sort.
Step 1 − Set MIN to location 0
Step 2 − Search the minimum element in the list
Step 3 − Swap with value at location MIN
Step 4 − Increment MIN to point to next element
Step 5 − Repeat until list is sorted

procedure selection sort 
   list  : array of items
   n     : size of list

   for i = 1 to n - 1
   /* set current element as minimum*/
      min = i    
  
      /* check the element to be minimum */

      for j = i+1 to n 
         if list[j] < list[min] then
            min = j;
         end if
      end for

      /* swap the minimum element with the current element*/
      if indexMin != i  then
         swap list[min] and list[i]
      end if
   end for
	
end procedure
To know about selection sort implementation in C programming language, please click here.

    42 Lectures 
     1.5 hours 

 Ravi Kiran

    141 Lectures 
     13 hours 

 Arnab Chakraborty

    26 Lectures 
     8.5 hours 

 Parth Panjabi

    65 Lectures 
     6 hours 

 Arnab Chakraborty

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    64 Lectures 
     10.5 hours 

 Eduonix Learning Solutions
 Print
 Add Notes
 Bookmark this page
How to calculate Years between Dates in R ? - GeeksforGeeks

14 May, 2021
In this article, we will discuss how to calculate the number of years or difference of years between two dates in R programming language.
Example:
Input: 
Date_1 = 2020/02/21
Date_2 = 2023/03/21
Output:
3
Explanation: 
In Date_1 and Date_2 have three years difference in year.
Here we will use seq() function to get the result. This function is used to create a sequence of elements in a Vector.
Syntax: 
length(seq(from=date_1, to=date_2, by=’year’)) -1  
Example 1: 
R
# creating date_1 variable and# storing date in it.date_1<-as.Date("2020-08-10")  # creating date_2 variable and #storing date in it.date_2<-as.Date("2023-10-10")  # Here first date will start from# 2020-08-10 and end by 2023-10-10.# Here increment is done by year.# This three dates will be generated# as we used eq and this dates will# be stored in a.a = seq(from = date_1, to = date_2, by = 'year')  # Here we are finding length of a and# we are subtracting 1 because we dont# need to include current year.length(a)-1
Output:
3
Example 2:
R
# creating date_1 variable and# storing date in it.date_1<-as.Date("2020-08-10") # creating date_2 variable and# storing date in it.date_2<-as.Date("2100-08-10") # Here first date will start from# 2020-08-10 and end by 2100-08-10.# Here increment is done by year.# This three dates will be generated# as we used seq and this dates will# be stored in a.a = seq(from = date_1, to = date_2, by = 'year') # Here we are finding length of a and# we are subtracting 1 because we dont# need to include current year.length(a)-1
 Output:
80
 
simmytarika5
Picked
R-DateTime
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
Group by function in R using Dplyr
How to Change Axis Scales in R Plots?
How to Split Column Into Multiple Columns in R DataFrame?
Replace Specific Characters in String in R
How to filter R DataFrame by values in a column?
R - if statement
How to filter R dataframe by multiple conditions?
Plot mean and standard deviation using ggplot2 in R
Time Series Analysis in R
Python | os.times() method - GeeksforGeeks

18 Jun, 2019
OS module in Python provides functions for interacting with the operating system. OS comes under Python’s standard utility modules. This module provides a portable way of using operating system dependent functionality.
os.times() method in Python is used to get the current global process times.
Syntax: os.times()
Parameter: No parameter is required.
Return Type: This method returns a tuple-like object with five named attributes which represents the current global process times. The five attributes are as follows:
user: It represents the user time.
system: It represents the system time
children_user: It represents the user time of all child processes.
children_system: It represents the system time of all child processes.
elapsed: It represents the elapsed real time since a fixed point in the past.
Note: On Windows, only user and system attributes are known and other attributes have value 0.
Code: Use of os.times() method to get the current global process times.
# Python program to explain os.times() method     # importing os module import os  # Get the current global# process times# using os.times() methodcurr_gp_times = os.times()  # Print the current global# process timesprint(curr_gp_times)
posix.times_result(user=0.03, system=0.01, children_user=0.0, children_system=0.0, elapsed=17370844.95)

Reference: https://docs.python.org/3/library/os.path.html
python-os-module
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?
Check if element exists in list in Python
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | os.path.join() method
Create a directory in Python
Defaultdict in Python
Python | Get unique values from a list
Python | Pandas dataframe.groupby()
WebAssembly - Convert WAT to WASM

In the previous chapter, we have seen how to write code in .wat i.e., WebAssembly text format. The WebAssembly text format will not directly work inside the browser and you need to convert it into binary format i.e., WASM to work inside browser.
Let us convert .WAT to .WASM.
The code we are going to use is as follows −
(module 
   (func $add (param $a i32) (param $b i32) (result i32) 
      get_local $a 
      get_local $b 
      i32.add
   ) 
   (export "add" (func $add)) 
)
Now, go to WebAssembly Studio, which is available at https://webassembly.studio/.
You should see something like this, when you hit the link −
Click on Empty Wat project and click on Create button at the bottom.
It will take you to an empty project as shown below −
Click on main.wat and replace the existing code with yours and click on the save button.
Once saved, click on the build to convert to .wasm −
If the build is successful you should see .wasm file created as shown below −
Down the main.wasm file and use it inside your .html file to see the output as shown below.
For Example − add.html
<!doctype html>
<html>
   <head>
      <meta charset="utf-8">
      <title>WebAssembly Add Function</title>
   </head>
   <body>
      <script> 
         let sum; 
         fetch("main.wasm")
            .then(bytes => bytes.arrayBuffer()) 
            .then(mod => WebAssembly.compile(mod)) .then(module => {
            
            return new WebAssembly.Instance(module) 
         })
         .then(instance => {
            sum = instance.exports.add(10,40); 
            console.log("The sum of 10 and 40 = " +sum); 
         }); 
      </script>
   </body>
</html>
The function add is exported as shown in the code. The params passed are 2 integer values 10 and 40 and it returns the sum of it.
The output is displayed in the browser.
 Print
 Add Notes
 Bookmark this page
How do I return multiple results in a MySQL subquery with IN()?

In MySQL, you can easily return multiple results, but also achieve this with subquery using IN(). Let us first create a table −
mysql> create table DemoTable1317
-> (
-> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
-> Name varchar(20)
-> );
Query OK, 0 rows affected (0.49 sec)
Insert some records in the table using insert command
mysql> insert into DemoTable1317(Name) values('Chris Brown');
Query OK, 1 row affected (0.18 sec)
mysql> insert into DemoTable1317(Name) values('John Doe');
Query OK, 1 row affected (0.12 sec)
mysql> insert into DemoTable1317(Name) values('Adam Smith');
Query OK, 1 row affected (0.12 sec)
mysql> insert into DemoTable1317(Name) values('John Smith');
Query OK, 1 row affected (0.18 sec)
mysql> insert into DemoTable1317(Name) values('David Miller');
Query OK, 1 row affected (0.10 sec)
mysql> insert into DemoTable1317(Name) values('Carol Taylor');
Query OK, 1 row affected (0.14 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable1317;
+----+--------------+
| Id | Name         |
+----+--------------+
|  1 | Chris Brown  |
|  2 | John Doe     |
|  3 | Adam Smith   |
|  4 | John Smith   |
|  5 | David Miller |
|  6 | Carol Taylor |
+----+--------------+
6 rows in set (0.00 sec)
Following is the query to return multiple results in a MySQL subquery −
mysql> select Name from DemoTable1317
-> where Id IN ( select Id from DemoTable1317);
+--------------+
| Name         |
+--------------+
| Chris Brown  |
| John Doe     |
| Adam Smith   |
| John Smith   |
| David Miller |
| Carol Taylor |
+--------------+
6 rows in set (0.00 sec)
What is constructor overloading in Java?

Similar to methods you can also overload constructors i.e. you can write more than constructor with different parameters.
And, based on the parameters we pass at the time of instantiation, respective constructor will be invoked.
 Live Demo
public class Sample {
   public Sample() {
      System.out.println("Hello how are you");
   }

   public Sample(String data) {
      System.out.println(data);
   }
   public static void main(String args[]){
      Sample obj = new Sample("Tutorialspoint");
   }
}
Tutorialspoint
Count distinct value in MongoDB?

Use the concept of length to count distinct value. Following is the syntax −
db.yourCollectionName.distinct("yourFieldName").length;
Let us create a collection with documents −
> db.countDistinctDemo.insertOne({"StudentName":"John"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5cbd6166de8cc557214c0dfa")
}
> db.countDistinctDemo.insertOne({"StudentName":"Chris"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5cbd616ade8cc557214c0dfb")
}
> db.countDistinctDemo.insertOne({"StudentName":"Chris"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5cbd616cde8cc557214c0dfc")
}
> db.countDistinctDemo.insertOne({"StudentName":"Carol"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5cbd6170de8cc557214c0dfd")
}
> db.countDistinctDemo.insertOne({"StudentName":"David"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5cbd6175de8cc557214c0dfe")
}
> db.countDistinctDemo.insertOne({"StudentName":"Carol"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5cbd6181de8cc557214c0dff")
}
Display all documents from a collection with the help of find() method −
> db.countDistinctDemo.find().pretty();
This will produce the following output −
{ "_id" : ObjectId("5cbd6166de8cc557214c0dfa"), "StudentName" : "John" }
{ "_id" : ObjectId("5cbd616ade8cc557214c0dfb"), "StudentName" : "Chris" }
{ "_id" : ObjectId("5cbd616cde8cc557214c0dfc"), "StudentName" : "Chris" }
{ "_id" : ObjectId("5cbd6170de8cc557214c0dfd"), "StudentName" : "Carol" }
{ "_id" : ObjectId("5cbd6175de8cc557214c0dfe"), "StudentName" : "David" }
{ "_id" : ObjectId("5cbd6181de8cc557214c0dff"), "StudentName" : "Carol" }
Following is the query to count distinct value −
> db.countDistinctDemo.distinct("StudentName").length;
This will produce the following output −
4
Display Timestamp before the current date in MySQL

Let us first create a table −
mysql> create table DemoTable(
   ArrivalDate timestamp
);
Query OK, 0 rows affected (1.96 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('2019-09-14 17:25:00');
Query OK, 1 row affected (0.26 sec)
mysql> insert into DemoTable values('2019-09-13 17:25:00');
Query OK, 1 row affected (0.11 sec)
mysql> insert into DemoTable values('2016-09-01 17:20:10');
Query OK, 1 row affected (0.38 sec)
mysql> insert into DemoTable values('2019-09-11 12:00:00');
Query OK, 1 row affected (0.16 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+---------------------+
| ArrivalDate         |
+---------------------+
| 2019-09-14 17:25:00 |
| 2019-09-13 17:25:00 |
| 2016-09-01 17:20:10 |
| 2019-09-11 12:00:00 |
+---------------------+
4 rows in set (0.04 sec)
Following is the query to display timestamp before the current date −
mysql> select *from DemoTable where ArrivalDate < now();
This will produce the following output −
+---------------------+
| ArrivalDate         |
+---------------------+
| 2019-09-13 17:25:00 |
| 2016-09-01 17:20:10 |
| 2019-09-11 12:00:00 |
+---------------------+
3 rows in set (0.07 sec)
Union and Union All in MS SQL Server - GeeksforGeeks

14 Aug, 2020
1. Union :Union means joining two or more data sets into a single set. In SQL Server, Union is used to combine two queries into a single result set using the select statements. Union extracts all the rows that are described in the query.
Syntax –
query1 UNION query2
Union holds a few conditions before being used in a query. One such condition is that the rows to be extracted must come from the same columns from the tables.
Example –
select name, rollnumber 
from student 
UNION 
select name, rollnumber 
from marks
Output –
Two different tables are being used here for extraction of rows yet the column specified for extraction is the same for both. An error occurs if different columns are being used. The data type specified also must be the same for both the queries.
2. Union All :A union is used for extracting rows using the conditions specified in the query while Union All is used for extracting all the rows from a set of two tables.
Syntax –
query1 UNION ALL query2
The same conditions are applicable to Union All. The only difference between Union and Union All is that Union extracts the rows that are being specified in the query while Union All extracts all the rows including the duplicates (repeated values) from both the queries.
DBMS-SQL
DBMS
SQL
DBMS
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Introduction of B-Tree
Difference between Clustered and Non-clustered index
Introduction of DBMS (Database Management System) | Set 1
Introduction of ER Model
SQL | Views
How to find Nth highest salary from a table
SQL | ALTER (RENAME)
SQL | Views
CTE in SQL
Difference between DELETE, DROP and TRUNCATE
SAP ABAP - Macros

If we want to reuse the same set of statements more than once in a program, we need to include them in a macro. For example, a macro can be useful for long calculations or for writing complex WRITE statements. We can only use a macro within a program in which it is defined. Macro definition should occur before the macro is used in the program.
Macros are designed based on placeholders. Placeholder works like pointers in C language. You can define a macro within the DEFINE...END-OF-DEFINITION statement.
Following is the basic syntax of a macro definition −
DEFINE <macro_name>. <statements> 
END-OF-DEFINITION. 
   ...... 
  
   <macro_name> [<param1> <param2>....].

It is necessary to define a macro first before invoking it. The <param1>.... replaces the placeholders &1...in the ABAP statements contained in the macro definition.
The maximum number of placeholders in a macro definition is nine. That is, when a program is executed, the SAP system replaces the macro by appropriate statements and the placeholders &1, &2,....&9 are replaced by the parameters param1, param2,....param9. We may invoke a macro within another macro, but not the same macro.
Go to transaction SE38. Create a new program ZMACRO_TEST along with the description in the short text field, and also with appropriate attributes such as Type and Status as shown in the following screenshot −
Following is the code −
REPORT ZMACRO_TEST. 
DEFINE mac_test. 
WRITE: 'This is Macro &1'. 
END-OF-DEFINITION. 

PARAMETERS: s1 type C as checkbox. 
PARAMETERS: s2 type C as checkbox. 
PARAMETERS: s3 type C as checkbox default 'X'. 

START-OF-SELECTION. 
IF s1 = 'X'. 
   mac_test 1. ENDIF. 
IF s2 = 'X'. 
   mac_test 2. 
ENDIF.
 
IF s3 = 'X'. 
   mac_test 3. 
ENDIF.
We have 3 checkboxes. While executing the program, let’s select the S2 checkbox.
The above code produces the following output −
A Macro Program 
 
This is Macro 2

If all checkboxes are selected, the code produces the following output −
A Macro Program 
 
This is Macro 1 This is Macro 2 This is Macro 3


    25 Lectures 
     6 hours 

 Sanjo Thomas

    26 Lectures 
     2 hours 

 Neha Gupta

    30 Lectures 
     2.5 hours 

 Sumit Agarwal

    30 Lectures 
     4 hours 

 Sumit Agarwal

    14 Lectures 
     1.5 hours 

 Neha Malik

    13 Lectures 
     1.5 hours 

 Neha Malik
 Print
 Add Notes
 Bookmark this page
MySQL Stored Procedure to update records with certain condition?

For this, you can use the UPDATE command along with the WHERE clause in a PROCEDURE. Let us first create a table −
mysql> create table DemoTable
   -> (
   -> Id int,
   -> FirstName varchar(20),
   -> LastName varchar(20)
   -> );
Query OK, 0 rows affected (0.56 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(101,'David','Brown');
Query OK, 1 row affected (0.15 sec)
mysql> insert into DemoTable values(102,'Chris','Brown');
Query OK, 1 row affected (0.08 sec)
mysql> insert into DemoTable values(103,'John','Doe');
Query OK, 1 row affected (0.07 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+------+-----------+----------+
| Id   | FirstName | LastName |
+------+-----------+----------+
|  101 | David     | Brown    |
|  102 | Chris     | Brown    |
|  103 | John      | Doe      |
+------+-----------+----------+
3 rows in set (0.00 sec)
Here is the query to create a stored procedure−
mysql> delimiter //
mysql> create procedure update_sp(fName varchar(20),lName varchar(20))
   -> begin
   -> update DemoTable
   -> set FirstName=fName,
   -> LastName=lName
   -> where Id=101;
   -> end
   -> //
Query OK, 0 rows affected (0.12 sec)
mysql> delimiter ;
Now you can call a stored procedure using call command −
mysql> call update_sp('Adam','Smith');
Query OK, 1 row affected, 2 warnings (0.08 sec)
Let us check the table records once again −
mysql> select *from DemoTable;
This will produce the following output −
+------+-----------+----------+
| Id   | FirstName | LastName |
+------+-----------+----------+
|  101 | Adam      | Smith    |
|  102 | Chris     | Brown    |
|  103 | John      | Doe      |
+------+-----------+----------+
3 rows in set (0.00 sec)
XQuery - replace function

The replace function replaces the matched input string with a given string.
replace($input, $regex, $string)
$input − input string.
$input − input string.
$regex − regular expression. 
$regex − regular expression. 
$string - string to replace original string.
$string - string to replace original string.
let $input := 'Chapter 1 ... Chapter 2'
return ( replace($input, "Chapter (\d)", "Section $1.0"))
Section 1.0 ... Section 2.0

In order to test the above-mentioned functionality, replace the contents of books.xqy (mentioned in Environment Setup chapter) with the above XQuery expression and execute the XQueryTester java program to verify the result.
 Print
 Add Notes
 Bookmark this page
Python | Split a list into sublists of given lengths - GeeksforGeeks

03 Apr, 2019
The problem of splitting a list into sublists is quite generic but to split in sublist of given length is not so common. Given a list of lists and list of length, the task is to split the list into sublists of given length.
Example:
Input : Input = [1, 2, 3, 4, 5, 6, 7]
        length_to_split = [2, 1, 3, 1]

Output: [[1, 2], [3], [4, 5, 6], [7]]

 
Method #1: Using islice to split a list into sublists of given length, is the most elegant way.
# Python code to split a list# into sublists of given length.  from itertools import islice  # Input list initializationInput = [1, 2, 3, 4, 5, 6, 7]  # list of length in which we have to splitlength_to_split = [2, 1, 3, 1]  # Using isliceInputt = iter(Input)Output = [list(islice(Inputt, elem))          for elem in length_to_split]  # Printing Outputprint("Initial list is:", Input)print("Split length list: ", length_to_split)print("List after splitting", Output)
Initial list is: [1, 2, 3, 4, 5, 6, 7]
Split length list:  [2, 1, 3, 1]
List after splitting [[1, 2], [3], [4, 5, 6], [7]]

 Method #2: Using zip is another way to split a list into sublists of given length.
# Python code to split a list into# sublists of given length.from itertools import accumulate  # Input list initializationInput = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]  # list of length in which we have to splitlength_to_split = [2, 2, 3, 3]  # Using isliceOutput = [Input[x - y: x] for x, y in zip(          accumulate(length_to_split), length_to_split)]  # Printing Outputprint("Initial list is:", Input)print("Split length list: ", length_to_split)print("List after splitting", Output)
Initial list is: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Split length list:  [2, 2, 3, 3]
List after splitting [[1, 2], [3, 4], [5, 6, 7], [8, 9, 10]]

Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Python String | replace()
*args and **kwargs in Python
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
How to print without newline in Python?
Pattern Drawing in R - GeeksforGeeks

03 Mar, 2021
Everyone found an easy way for pattern printing in other programming languages. But its a tough task using R language . This article focuses on drawing various patterns using R language and its constructs.
Approach
Start first loop for number of lines
Start second loop for item to be displayed
Print item
Increment second loop until a condition is reached
Increment first loop until condition is true
Continue in this fashion
Program 1: Drawing a Triangle with numbers
R
stars = c()  for(i in 1:5){  for(j in 1:i+1){     stars = c(stars, i)  }      print(stars)  stars = c()}
Output:
[1] 1
[1] 2 2
[1] 3 3 3
[1] 4 4 4 4
[1] 5 5 5 5 5
Program 2: Drawing a triangle with *
R
#creating a empty list to storestars = c()  for(i in 1:5){   for(j in 1:i+1){      stars = c(stars, "*")   }  # line by line printing  print(stars)  stars = c()}
Output:
[1] "*"
[1] "*" "*"
[1] "*" "*" "*"
[1] "*" "*" "*" "*"
[1] "*" "*" "*" "*" "*"
Program 3: Draw inverted triangle
R
starsrev = c()i=1j=5  while(i<=5){  for(j in 1:j){     starsrev = c(starsrev, "*")   }      print(starsrev)      starsrev = c()    i=i+1  j=j-1}
Output:
[1] "*" "*" "*" "*" "*"
[1] "*" "*" "*" "*"
[1] "*" "*" "*"
[1] "*" "*"
[1] "*"
Program 4: Drawing inverted as well as normal triangle pattern
R
i=1stars = c()  while(i<=5){  for(j in 1:i+1){     stars = c(stars, "*")  }    print(stars)  stars = c()  i=i+1}  starsrev = c()i=1j=5  while(i<=5){  for(j in 1:j){    starsrev = c(starsrev, "*")  }      print(starsrev)  starsrev = c()  i=i+1  j=j-1}
Output:
[1] "*"
[1] "*" "*"
[1] "*" "*" "*"
[1] "*" "*" "*" "*"
[1] "*" "*" "*" "*" "*"
[1] "*" "*" "*" "*" "*"
[1] "*" "*" "*" "*"
[1] "*" "*" "*"
[1] "*" "*"
[1] "*"
school-programming
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
Group by function in R using Dplyr
How to Change Axis Scales in R Plots?
How to Split Column Into Multiple Columns in R DataFrame?
Replace Specific Characters in String in R
How to filter R DataFrame by values in a column?
R - if statement
How to import an Excel File into R ?
Plot mean and standard deviation using ggplot2 in R
How to filter R dataframe by multiple conditions?
How to Force User to Change Password at Next Login in Linux - GeeksforGeeks

23 Aug, 2021
For security reasons, you must frequently change the password of accounts on the system. In this article, we are going to see how can we force the user to change the password on the next login in Linux. We can do that by two methods one is using passwd command and the other is by using chage command.
To force a user to change the user account password, the current password must have expired. We can expire the password of the user using passwd command.passwd command provides -e or –expire option to expire the password of the user. Use the following command to expire the password of user
sudo passwd --expire username
After executing this command, the password will get expired. We can check the password expired or not using the chage command with -l option. Use the following command to verify password expired or not.
chag -l username
Next time when a user tries to log in to the system the user is prompted to change the current password.
chage is a command-line tool that is used to update the user account ageing information. We can use the chage command to expire the password of an account.chage command provides -d or –lastday option, with this option mention the number of number day after January 1st, 1970 password should expire. So to expire password now we can use the 0 option. When we use 0 this means that the password is expired on January 1st, 1970, and it must be changed.
chage --lastday 0 username
We can verify the password is expired or not by using change command with the -l option.
On the next login, the system will ask the user to  reset the password.
linux-command
Linux-system-commands
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
scp command in Linux with Examples
Docker - COPY Instruction
mv command in Linux with examples
SED command in Linux | Set 2
chown command in Linux with Examples
nohup Command in Linux with Examples
Named Pipe or FIFO with example C program
Thread functions in C/C++
uniq Command in LINUX with examples
Start/Stop/Restart Services Using Systemctl in Linux