code-rag-bench/online-tutorials huggingface dataset:
How to add a box-shadow on one side of an element using CSS?

19 Feb, 2019
The box-shadow property is used to set the box shadow on one side of element.
Syntax:
box-shadow: h-offset v-offset blur spread color;
box-shadows values:
h-offset: It is required and used to set the position of the shadow horizontally. The positive value is used to set the shadow on right side of the box and a negative value is used to set the shadow on the left side of the box.
v-offset: It is required and used to set the position of shadow vertically. The positive value is used to set the shadow below to the box and negative value is used to set shadow above box.
blur: It is an optional attribute, the work of this attribute is to blur the shadow of the box.
spread: It is used to set the size of the shadow. The size of spread depends on the value of spread.
color: It is optional attribute and used to set the color of shadow.
Example 1: This example set the box shadow in the bottom of box.
<!DOCTYPE html> <html>   <head>     <title>         Box-shadow Property    </title>           <!-- style to set box-shadow property -->    <style>        h1 {            text-align: center;            background: green;            padding-top: 60px;            color: white;            width: 500px;            height: 130px;            box-shadow: 0 10px 10px blue;         }    </style></head>  <body>     <h1>GeeksForGeeks</h1> </body>   </html>                    
Output:
Example 2: This example set the box-shadow in the left side of box.
<!DOCTYPE html> <html>   <head>     <title>         Box-shadow Property    </title>           <!-- style to set box-shadow property -->    <style>        h1 {            text-align: center;            background: green;            padding-top: 60px;            color: white;            width: 500px;            height: 130px;            box-shadow: -10px 0px 10px blue;         }    </style></head>  <body>     <h1>GeeksForGeeks</h1> </body>   </html>                    
Output:
inset: By default the shadow generates outside the box but inset value can be used to create shadow inside the box.
Example 3: This example create shadow inside the box.
<!DOCTYPE html> <html>   <head>     <title>         Box-shadow Property    </title>           <!-- style to set box-shadow property -->    <style>        h1 {            text-align: center;            background: green;            padding-top: 60px;            color: white;            width: 500px;            height: 130px;            box-shadow: 0px 10px 20px blue inset;         }    </style></head>  <body>     <h1>GeeksForGeeks</h1> </body>   </html>                    
Output:
CSS-Misc
Picked
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Set Axis Breaks of ggplot2 Plot in R

23 Aug, 2021
In this article, we are going to see how to set axis break of ggplot2 plot in R Programming Language. 
To add axis breaks in ggplot2 plots in R, we use scale_x_break() and scale_y_break() functions. These functions take a vector as a parameter that has breakpoints.  If we need multiple breakpoints we can add those too.
Syntax:
scale_x_continuous(breaks = <break-vec>) 
scale_y_continuous(breaks = <break-vec>) 
Here is a ggplot2 scatter plot with x-axis break using scale_x_continuous() function. This function has a breaks parameter that takes a vector as input which has all the points of axis break as vector points. So, here we can set the axis breaks point to a plot manually.
Code:
R
# Create sample dataset.seed(5642)   sample_data <- data.frame(x = rnorm(1000),                            y = rnorm(1000))# Load ggplot2 and ggbreaklibrary("ggplot2") library("ggbreak")   # create plot with axis breakggplot(sample_data, aes(x = x, y = y)) + geom_point() + scale_x_continuous(breaks = c(-1,0, 1))
Output:
Here is a ggplot2 scatter plot with y-axis break using the scale_y_continuous() function. This function has a breaks parameter that takes a vector as input which has all the points of y-axis break as vector points. So, here we can set the axis breaks point to a plot manually.
R
# Create sample dataset.seed(5642)   sample_data <- data.frame(x = rnorm(1000),                            y = rnorm(1000))# Load ggplot2 and ggbreaklibrary("ggplot2") library("ggbreak")   # create plot with axis breakggplot(sample_data, aes(x = x, y = y)) + geom_point() + scale_y_continuous(breaks = c(-2, -1, 0, 1))
Output:
To specify the sequence of axis ticks we use the seq function as a parameter to breaks the property of scale_x_continuous / scale_y_continuous instead of vector. Here instead of giving input as a vector, we give input as a sequence that has three points, the first is starting break, the second is ending break and the third one is break period between starting and ending break.
Syntax: plot+ scale_x_continuous(breaks = <seq-vec>) / scale_y_continuous(breaks = <seq-vec>) 
Code:
R
# Create sample dataset.seed(5642)   sample_data <- data.frame(x = rnorm(1000),                            y = rnorm(1000))  # Load ggplot2 and ggbreaklibrary("ggplot2") library("ggbreak")   # create plot with axis breakggplot(sample_data, aes(x = x, y = y)) + geom_point() + scale_x_continuous(breaks = seq(-3, 4, 0.2))
Output:
Picked
R-ggplot
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Manipulating objects in array of objects in JavaScript

Suppose, we have two arrays of objects like this −
const arr1 = [
   {id:'124',name:'qqq'},
   {id:'589',name:'www'},
   {id:'45',name:'eee'},
   {id:'567',name:'rrr'}
];
const arr2 = [
   {id:'124',name:'ttt'},
   {id:'45',name:'yyy'}
];
We are required to write a JavaScript function that takes in two such objects. Our function should search the first array for objects with the same "id" property that is present in the second array.
Then our function should replace the "name" property of those objects with the corresponding "name" property of the second array's objects.
Therefore, for the above arrays, the output should look like −
const output = [
   {id:'124',name:'ttt'},
   {id:'589',name:'www'},
   {id:'45',name:'yyy'},
   {id:'567',name:'rrr'}
];
The code for this will be −
const arr1 = [
   {id:'124',name:'qqq'},
   {id:'589',name:'www'},
   {id:'45',name:'eee'},
   {id:'567',name:'rrr'}
];
const arr2 = [
   {id:'124',name:'ttt'},
   {id:'45',name:'yyy'}
];
const replaceByOther = (arr1, arr2) => {
   for(let i = 0; i < arr1.length; i++){
      const el = arr1[i];
      const index = arr2.findIndex(elm => el['id'] === elm['id']);
      if(index === -1){
         continue;
      };
      else['name'] = arr2[index]['name'];
   };
};
replaceByOther(arr1, arr2);
console.log(arr1);
And the output in the console will be −
[
   { id: '124', name: 'ttt' },
   { id: '589', name: 'www' },
   { id: '45', name: 'yyy' },
   { id: '567', name: 'rrr' }
]
SQL Query to Add Foreign Key Constraints Using ALTER Command

19 Apr, 2021
In this article, we will look into how you can add a foreign key constraint using the ALTER command in SQL. For this article, we will be using Microsoft SQL Server as our database.
But before we start let’s take a look at the below terminologies:
Primary key: It is used to uniquely identify the records in the table. It is mainly used in Relational Database. A Primary must be unique.
Foreign Key: It is used to link tables together. This is also called referencing. It is used for referring to a Primary Key of another table.
We can create a Database using the command:
Syntax: CREATE DATABASE DATABASE_NAME;
So let’s create a geeks database as shown below:
CREATE DATABASE geeks;
Use the below command to use the geeks database:
use geeks;
To add a table into the database we use the below command:
Syntax:- CREATE TABLE table_name (Attribute_name datatype...);
So, let’s create a geeks table within the geeks database as shown below:
CREATE TABLE geeks(id int , name varchar(20));
Here Table Added Successfully.
For inserting records into the table we can use the below command:
Syntax: INSERT INTO table_name(column1,
                column2,
                column 3,.....)
                 VALUES( value1,
                value2,
                value3,.....);
So let’s add some records in the geeks table:
 INSERT INTO geeks(id,name) VALUES (1,"teja");
To have a Foreign Key in a Table we must have a Primary Key. To create a Primary we use the below command:
Syntax: CREATE TABLE table_name (Attribute_name  datatype PRIMARY_KEY);
Now let’s create a primary key:
CREATE TABLE emp (id int NOT NULL PRIMARY KEY,name varchar(20))
Now to add a Foreign Key we have to create a new table by the following:
CREATE TABLE  student(
id int ,
name varchar(20),
Emp_id int REFERENCES emp(id));
So if you already created the table student, and now you wish to add Foreign Key you can use the below command to change that:
ALTER TABLE dbo.student 
add  constraint Fk_empid foreign key(emp_id)
references dbo.emp(id);
At this point, we have successfully achieved our goal.
Picked
SQL-Query
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Add Image in Text Background using HTML and CSS ?

11 May, 2020
In this article, we will use HTML and CSS to set the image in the text background. To set the image in the text background, some CSS property is used.
HTML Code: HTML code is used to create a basic structure of the body. In the following code, we will use paragraph tag to write text content.
<!DOCTYPE html><html>  <head>    <title>        How to Add Image in Text Background        using HTML and CSS ?    </title></head>  <body>    <p>GeeksforGeeks</p></body>  </html>
CSS Code: The CSS property is used to set the image as background in the text. The background-image property is used to set an image as background. The -webkit-text-fill-color property is used to give the text a transparent color, the background image will show through the text, thus completing the clipping effect.
<style>    p {        background-image: url(demo.jpg);        background-repeat: repeat;        -webkit-background-clip: text;        -webkit-text-fill-color: transparent;        margin-top: 200px;        font-size: 120px;        text-align: center;        font-weight: bold;        text-transform: uppercase;        font-family: 'Steelfish Rg', 'helvetica neue',                    helvetica, arial, sans-serif;        font-weight: 800;        -webkit-font-smoothing: antialiased;    }</style>
Complete Code: In this section, we will combine the above two sections to add an image as text background.
<!DOCTYPE html><html>  <head>    <title>        How to Add Image in Text Background        using HTML and CSS ?    </title>          <style>        p {            background-image: url(demo.jpg);            background-repeat: repeat;            -webkit-background-clip: text;            -webkit-text-fill-color: transparent;            margin-top: 200px;            font-size: 120px;            text-align: center;            font-weight: bold;            text-transform: uppercase;            font-family: 'Steelfish Rg', 'helvetica neue',                     helvetica, arial, sans-serif;            font-weight: 800;            -webkit-font-smoothing: antialiased;        }    </style></head>  <body>    <p>GeeksforGeeks</p></body>  </html>
Output:
CSS-Misc
HTML-Misc
CSS
HTML
Web Technologies
Web technologies Questions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
JavaScript | Function Apply

02 Dec, 2021
The apply() method is used to write methods, which can be used on different objects. It is different from the function call() because it takes arguments as an array.
Syntax:
apply()
Return Value: It returns the method values of a given function.
Example 1: This example illustrates the apply() function without arguments.
<!DOCTYPE html><html>  <head>    <title>        JavaScript apply() Method        without argument    </title></head>  <body>    <h1>GeeksforGeeks</h1>      <h2>        JavaScript apply() Method    </h2>          <h4>        It displays the details of second student    </h4>      <p id="GFG"></p>          <!-- Script to use apply() method -->    <script>        var student = {            details: function() {                return this.name + "<br>" + this.class;            }        }        var stud1 = {            name:"Dinesh",            class: "11th",        }        var stud2 = {            name:"Vaibhav",            class: "11th",        }                  var x = student.details.apply(stud2);         document.getElementById("GFG").innerHTML = x;     </script></body>  </html>                    
Output:
Example 2: This example illustrates the apply() function with arguments.
<!DOCTYPE html><html>  <head>    <title>        JavaScript apply() Method        with argument    </title></head>  <body>    <h1>GeeksforGeeks</h1>      <h2>        JavaScript apply() Method    </h2>          <h4>        It displays the details of second student    </h4>      <p id="GFG"></p>          <!-- Script to use apply() method -->    <script>        var student = {            details: function(section, rollnum) {                return this.name + "<br>" + this.class                    + " " + section + "<br>" + rollnum;            }        }        var stud1 = {            name:"Dinesh",            class: "11th",        }        var stud2 = {            name:"Vaibhav",            class: "11th",        }                  var x = student.details.apply(stud2, ["A", "24"]);         document.getElementById("GFG").innerHTML = x;     </script></body>  </html>                    
Output:
Supported Browser:
Chrome 1 and above
Edge 12 and above
Firefox 1 and above
Internet Explorer 5.5 and above
Opera 4 and above
Safari 1 and above
ysachin2314
Picked
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
How to append HTML code to a div using JavaScript ?
Difference Between PUT and PATCH Request
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
while Loop in C#

25 Aug, 2020
Looping in a programming language is a way to execute a statement or a set of statements multiple number of times depending on the result of the condition to be evaluated. while loop is an Entry Controlled Loop in C#.
The test condition is given in the beginning of the loop and all statements are executed till the given boolean condition satisfies, when the condition becomes false, the control will be out from the while loop.
Syntax:
while (boolean condition)
{
   loop statements...
}

Flowchart:
Example 1:
// C# program to illustrate while loopusing System;  class whileLoopDemo {    public static void Main()    {        int x = 1;          // Exit when x becomes greater than 4        while (x <= 4) {            Console.WriteLine("GeeksforGeeks");              // Increment the value of x for            // next iteration            x++;        }    }}
GeeksforGeeks
GeeksforGeeks
GeeksforGeeks
GeeksforGeeks

Example 2:
// C# program to illustrate while loopusing System;  class whileLoopDemo {    public static void Main()    {        int x = 10;          // Exit when x becomes less than 5        while (x > 4) {            Console.WriteLine("Value " + x);              // Decrement the value of x for            // next iteration            x--;        }    }}
Value 10
Value 9
Value 8
Value 7
Value 6
Value 5

CSharp-Basics
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Differences Between .NET Core and .NET Framework
C# | .NET Framework (Basic Architecture and Component Stack)
Lambda Expressions in C#
Extension Method in C#
C# | Abstraction
Top 50 C# Interview Questions & Answers
C# | Sealed Class
C# | Multiple inheritance using interfaces
C# | Boxing And Unboxing
Partial Classes in C#
How to generate a random number between 0 and 1 in Python ?

03 Jan, 2021
The use of randomness is an important part of the configuration and evaluation of modern algorithms.
Here, we will see the various approaches for generating random numbers between 0 ans 1.
Method 1:
Here, we will use uniform() method which returns the random number between the two specified numbers (both included).
Code:
Python3
import random  print(random.uniform(0, 1))
Output:
0.0023922878433915162
Method 2:
Here, we will use random() method which returns a random floating number between 0 and 1.
Code:
Python3
import random  print(random.random())
Output:
0.7769332461684861
Method 3:
Here, we will use the numpy to generate the array of the random numbers.
Code:
Python3
import numpy as np  x=np.random.random(1)[0]print(x)
Output:
0.03394418147881839
Method 4:
Here, we will see the custom approach for generating the random numbers.
randint() is the method which return the random integer between two specified values.
Code:
Python3
import random  print(random.randint(0, 10**5)/ 10**5)
Output:
0.59882
Picked
Python-random
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
Python | os.path.join() method
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 | Get unique values from a list
Python | datetime.timedelta() function
response.raise_for_status() – Python requests

07 Jul, 2022
response.raise_for_status() returns an HTTPError object if an error has occurred during the process. It is used for debugging the requests module and is an integral part of Python requests. Python requests are generally used to fetch the content from a particular resource URI. Whenever we make a request to a specified URI through Python, it returns a response object. Now, this response object would be used to access certain features such as content, headers, etc. This article revolves around how to check the response.raise_for_status() out of a response object.
How to use response.raise_for_status() using Python requests?
To illustrate the use of response.raise_for_status(), let’s ping github.com and geeksforgeeks.org. To run this script, you need to have Python and requests installed on your PC.
Prerequisites:
Download and Install Python 3 Latest Version
How to install requests in Python – For windows, linux, mac
Example code:
Python3
# import requests moduleimport requests # Making a get requestresponse = requests.get('https://api.github.com/') # print responseprint(response) # print check if an error has occurredprint(response.raise_for_status()) # ping an incorrect urlresponse = requests.get('https://geeksforgeeks.org/naveen/') # print check if an error has occurredprint(response.raise_for_status())
Example:
Save the above file as request.py and run using
Python request.py
Output:
Check that Traceback error, it shows that an error has occurred along with the error “Invalid URL” and status code 404.
Advanced Concepts: There are many libraries to make an HTTP request in Python, which are httplib, urllib, httplib2, treq, etc., but requests is the one of the best with cool features. If any attribute of requests shows NULL, check the status code using below attribute.
requests.status_code
If status_code doesn’t lie in the range of 200-29. You probably need to check the method to begin used for making a request + the url you are requesting for resources.
kamalcool007
Python-requests
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Iterate over a list in Python
Python Classes and Objects
Convert integer to string in Python
Format Calendar with String.format() in Java

Firstly, consider an object with date value.
Object arrObj[] = { "Date", Calendar.getInstance() };
After that, use the String.format() method to format Calendar and display the date.
The following is an example.
 Live Demo
import java.util.Calendar;
public class Demo {
   public static void main(String []args){
      Object arrObj[] = { "Date", Calendar.getInstance() };
      System.out.println("Formatting Date...");
      System.out.println(String.format("%1$s = %2$tY %2$tm %2$te", arrObj));
   }
}
Formatting Date...
Date = 2018 11 17
jQuery UI Autocomplete search() Method - GeeksforGeeks

22 Dec, 2021
jQuery UI consists of GUI widgets, visual effects, and themes implemented using HTML, CSS, and jQuery. jQuery UI is great for building UI interfaces for the webpages. The jQuery UI Autocomplete widget is used to perform autocomplete enables to quickly find and select from a pre-populated list of values as they type, leveraging searching and filtering.
The jQuery UI Autocomplete search() method is used to trigger a search event and invokes the data source if the event is not canceled. This method is called when search operation performed. 
Syntax:
$( ".selector" ).autocomplete( "search", "value" );
Parameters: This method accepts a single parameter value that holds a String type value.
 
CDN Links: First, add jQuery UI scripts needed for your project.
<link rel=”stylesheet” href=”//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css”><script src=”//code.jquery.com/jquery-1.12.4.js”></script><script src=”//code.jquery.com/ui/1.12.1/jquery-ui.js”></script>
Example: This example describes the uses of the jQuery UI Autocomplete search() method.
HTML
<!DOCTYPE html><html>  <head>    <meta charset="utf-8">    <meta name="viewport" content=        "width=device-width, initial-scale=1">    <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css">    <script src="//code.jquery.com/jquery-1.12.4.js"></script>    <script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script>      <script>        $(function () {            var subjects = [                "HTML",                "CSS",                "JavaScript",                "jQuery",                "PHP",                "React",                "Node.js"            ];            $("#GFG").autocomplete({                source: subjects            });              $("#btn").on('click', function() {                $("#GFG").autocomplete("search", "J");            })        });    </script></head>  <body>    <center>        <div class="ui-widget">            <h1 style="color: green;">                GeeksforGeeks            </h1>            <h3>jQuery UI Autocomplete search() Method</h3>              <label for="GFG">                Select Subject:            </label>              <input id="GFG">        </div>          <input type="button" id="btn"             style="padding: 5px 15px; margin-top: 40px;"             value="Search the Element">    </center></body>  </html>
Output:
Reference: https://api.jqueryui.com/autocomplete/#method-search
jQuery-UI
jQuery-UI-Autocomplete
JQuery
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to prevent Body from scrolling when a modal is opened using jQuery ?
jQuery | ajax() Method
Difference Between JavaScript and jQuery
How to get the value in an input text box using jQuery ?
QR Code Generator using HTML, CSS and jQuery
Top 10 Front End Developer Skills That You Need in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Node.js Bot.sendDocument() Method - GeeksforGeeks

13 Oct, 2020
The Bot.sendDocument() method is used in the Node.js Telegram Bot API. This Node.js module to interact with the official Telegram Bot API. This method is used to send Documents having extension like .pdf, .docx, .txt, etc.Syntax:  
TelegramBot.sendDocument(chatId, location)


Parameters: This method accepts two parameters as mentioned above and described below:  
chatId: A chatId is a unique identifier for a chat, that can be either private, group, supergroup or channel whereas userId is a unique identifier for a user or bot only. Every Client’s Message contains chatId.
Location: Location of the document which we want to send in String format.
Return Type: The return type of the function is void.Installing Module: Install the module using the following command:  
npm i telegram-bot-api


Steps to get the keys:  
First, get the GET BOT_TOKEN from BOTFATHER in telegram. Just search for BOTFATHER in Telegram and select the verified one as shown below:  
First, get the GET BOT_TOKEN from BOTFATHER in telegram. Just search for BOTFATHER in Telegram and select the verified one as shown below:  
Type /start and then click on /newbot as shown below:  
Type /start and then click on /newbot as shown below:  
 Now type the name of the bot and that must be unique.  
 
Now type the name of the bot and that must be unique.  
 Now just copy the token From the BotFather. And for deleting the token simply search /delete token in BotFather.  
 
Now just copy the token From the BotFather. And for deleting the token simply search /delete token in BotFather.  
Project structure:  
Filename: bot.js  
javascript
var token = 'Enter the token'; const TelegramBot = require('node-telegram-bot-api'); const bot = new TelegramBot(token, {polling: true}); // Matches "/echo [whatever]"bot.onText(/\/echo(.+)/, (msg, match) => {  // The 'msg' is the received Message from Telegram // and 'match' is the result of executing the regexp // above on the text content of the message  const chatId = msg.chat.id;  // The captured "whatever" const resp = match[1];  // Reply to the Bot bot.sendMessage(chatId, "Your Document is")    // Sending the document bot.sendDocument(chatId, "document.pdf");});
Run bot.js file using the following command:  
node bot.js


Output:  
 
zack_aayush
Node.js-Methods
Node.js
Web Technologies
Write From Home
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Node.js fs.writeFile() Method
Node.js fs.readFile() Method
How to install the previous version of node.js and npm ?
Difference between promise and async await in Node.js
How to use an ES6 import in Node.js?
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to Create a Password Protected ZIP File in Linux? - GeeksforGeeks

23 Feb, 2021
Linux provides Zip command to work with a file like compressing the file and decompressing with a password. It’s not come with built-in you need to install from an external source. The Zip command has two different utility(zip and unzip). zip is used for compressing the file and unzip is used for decompressing the file.
Use this command in Ubuntu, Debian, and Linux mint.
sudo apt install zip unzip
For Arch Linux:
sudo pacman -S zip unzip
For Red Hat, Fedora, and CentOS.
sudo dnf install zip unzip
Zip the file with the following commands.
zip -re OUTPUT_FILE.zip FOLDER
While running this command it will ask the password for a zip file.
Example:
zip -re output_data.zip gfg
Check your file(output_data.zip) is created with password protected.
ls
You can easily unzip the file with these commands.
unzip YOUR_FILE.zip
While running this command it will ask the password for a decompressing zip file.
Example:
unzip output_data.zip
We can use our GUI window to create a zip file and unzip too. Here are the following steps:
Step 1: Go to the file location and right-click on the file.
Step 2: Then click on the compress option.
Step 3: Then click on the other option and set your password and click on Create option.
Your Password-Protected ZIP File is created.
Picked
How To
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install FFmpeg on Windows?
How to Add External JAR File to an IntelliJ IDEA Project?
How to Set Git Username and Password in GitBash?
How to Install Jupyter Notebook on MacOS?
How to Create and Setup Spring Boot Project in Eclipse IDE?
Sed Command in Linux/Unix with examples
AWK command in Unix/Linux with examples
grep command in Unix/Linux
cut command in Linux with examples
cp command in Linux with examples
Groovy - contains()

Checks if a range contains a specific value.
boolean contains(Object obj)

Obj − The value to check in the range list.
Returns true if this Range contains the specified element.
Following is an example of the usage of this method −
class Example { 
   static void main(String[] args) { 
      // Example of an Integer using def 
      def rint = 1..10; 
		
      println(rint.contains(2)); 
      println(rint.contains(11)); 
   } 
}
When we run the above program, we will get the following result −
true 
false


    52 Lectures 
     8 hours 

 Krishna Sakinala

    49 Lectures 
     2.5 hours 

 Packt Publishing
 Print
 Add Notes
 Bookmark this page
HTML - <dialog> tag

The HTML <dialog> tag is used for defining a dialog box.
<!Doctype html>
<html>

   <head>
      <title>HTML dialog Tag</title>
   </head>

   <body>
      <dialog open>this will be shown in a dialog</dialog>
   </body>

</html>
This will produce the following result −
This tag supports all the global attributes described in HTML Attribute Reference
The HTML <dialog> tag also supports the following  additional attributes −
This tag supports all the event attributes described in HTML Events Reference

    19 Lectures 
     2 hours 

 Anadi Sharma

    16 Lectures 
     1.5 hours 

 Anadi Sharma

    18 Lectures 
     1.5 hours 

 Frahaan Hussain

    57 Lectures 
     5.5 hours 

 DigiFisk (Programming Is Fun)

    54 Lectures 
     6 hours 

 DigiFisk (Programming Is Fun)

    45 Lectures 
     5.5 hours 

 DigiFisk (Programming Is Fun)
 Print
 Add Notes
 Bookmark this page
Unicode Character Class \p{IsLatin}

The character class \p{IsLatin} matches any latin script character.
The following example shows the usage of Unicode character class matching.
package com.tutorialspoint;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class UnicodeCharacterClassDemo {
   private static final String REGEX = "\\p{IsLatin}";
   private static final String INPUT = "Bb12 \tc!";

   public static void main(String[] args) {
      // create a pattern
      Pattern  pattern = Pattern.compile(REGEX);
      
      // get a matcher object
      Matcher matcher = pattern.matcher(INPUT); 

      while(matcher.find()) {
         //Prints the start index of the match.
         System.out.println("Match String start(): "+matcher.start());
      }
   }
}
Let us compile and run the above program, this will produce the following result −
Match String start(): 0
Match String start(): 1
Match String start(): 6

 Print
 Add Notes
 Bookmark this page
GATE | GATE-CS-2004 | Question 42 - GeeksforGeeks

28 Jun, 2021
What does the following algorithm approximate?
x = m;y = 1;while (x - y > e){    x = (x + y)/2;    y = m/x;}print(x);
(Assume m > 1, e > 0).
(A) log m(B) m2(C) m1/2(D) m1/3Answer: (C)Explanation: The given code is implementation of Babylonian method for square rootQuiz of this Question
GATE-CS-2004
GATE-GATE-CS-2004
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE-IT-2004 | Question 66
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE CS 2019 | Question 27
GATE | GATE-CS-2006 | Question 49
GATE | GATE-CS-2004 | Question 3
GATE | GATE CS 2011 | Question 65
GATE | GATE CS 2021 | Set 1 | Question 47
GATE | GATE-CS-2017 (Set 2) | Question 42
GATE | Gate IT 2007 | Question 30
GATE | GATE CS 2011 | Question 7
Format and Parse Date in Java

To format a date in Java, firstly import the following package.
import java.text.DateFormat;
Now, create DateFormat object.
DateFormat shortFormat = DateFormat.getDateInstance(DateFormat.SHORT);
DateFormat longFormat = DateFormat.getDateInstance(DateFormat.LONG);
Use the format() method to format the above dates.
System.out.println(shortFormat.format(new Date()));
System.out.println(longFormat.format(new Date()));
To parse the dates, use the parse() method.
 Live Demo
import java.text.DateFormat;
import java.text.ParseException;
import java.util.Date;
public class Demo {
   public static void main(String[] args) throws Exception {
      // format date
      DateFormat shortFormat = DateFormat.getDateInstance(DateFormat.SHORT);
      DateFormat longFormat = DateFormat.getDateInstance(DateFormat.LONG);
      System.out.println("Format Date...");
      System.out.println(shortFormat.format(new Date()));
      System.out.println(longFormat.format(new Date()));
      // parse date
      System.out.println("Parse Date...");
      Date d1 = shortFormat.parse("11/21/2018");
      System.out.println(d1);
   }
}
Format Date...
11/22/18
November 22, 2018
Parse Date...
Wed Nov 21 00:00:00 UTC 2018
Google Charts - Basic Candlestick Chart

Following is an example of a basic candlestick chart. A candlestick chart is generally used to show an opening and closing value which are overlaid on top of a total variance. Candlestick charts are often used to show stocks value behavior. In this chart, filled boxes are drawn for items where the opening value is less than the closing value (a gain) and , and hollow boxes are drawn where the opening value of item is more than the closing value (a loss). We've already seen the configuration used to draw this chart in Google Charts Configuration Syntax chapter. So, let's see the complete example.
We've used CandlestickChart class to show candlestick based chart.
//candlestick chart
var chart = new google.visualization.CandlestickChart
(document.getElementById('container'));

googlecharts_candlestick_basic.htm
<html>
   <head>
      <title>Google Charts Tutorial</title>
      <script type = "text/javascript" src = "https://www.gstatic.com/charts/loader.js">
      </script>
      <script type = "text/javascript">
         google.charts.load('current', {packages: ['corechart']});     
      </script>
   </head>
   
   <body>
      <div id = "container" style = "width: 550px; height: 400px; margin: 0 auto">
      </div>
      <script language = "JavaScript">
         function drawChart() {
            // Define the chart to be drawn.
            var data = google.visualization.arrayToDataTable([
               ['Mon', 20, 28, 38, 45],
               ['Tue', 31, 38, 55, 66],
               ['Wed', 50, 55, 77, 80],
               ['Thu', 77, 77, 66, 50],
               ['Fri', 68, 66, 22, 15]
               // Treat first row as data as well.
            ], true);
              
            // Set chart options
            var options = {legend: 'none'};

            // Instantiate and draw the chart.
            var chart = new google.visualization.CandlestickChart(document.getElementById('container'));
            chart.draw(data, options);
         }
         google.charts.setOnLoadCallback(drawChart);
      </script>
   </body>
</html>
Verify the result.
 Print
 Add Notes
 Bookmark this page
Python - Ways to merge strings into list

While developing an application, there come many scenarios when we need to operate on the string and convert it as some mutable data structure, say list.
# Importing ast library
import ast
# Initialization of strings
str1 ="'Python', 'for', 'fun'"
str2 ="'vishesh', 'ved'"
str3 ="'Programmer'"
# Initialization of list
list = []
# Extending into single list
for x in (str1, str2, str3):
   list.extend(ast.literal_eval(x))
# printing output
print(list)
# using eval
# Initialization of strings
str1 ="['python, 'for', ''fun']"
str2 ="['vishesh', 'ved']"
str3 ="['programmer']"
out = [str1, str2, str3]
out = eval('+'.join(out))
# printing output
print(out)
newSingleThreadExecutor Method

A single thread pool can be obtainted by calling the static newSingleThreadExecutor() method of Executors class.
ExecutorService executor = Executors.newSingleThreadExecutor();

Where newSingleThreadExecutor method creates an executor that executes a single task at a time.
The following TestThread program shows usage of newSingleThreadExecutor method in thread based environment.
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

public class TestThread {

   public static void main(final String[] arguments) throws InterruptedException {
      ExecutorService executor = Executors.newSingleThreadExecutor();

      try {
         executor.submit(new Task());
         System.out.println("Shutdown executor");
         executor.shutdown();
         executor.awaitTermination(5, TimeUnit.SECONDS);
      } catch (InterruptedException e) {
         System.err.println("tasks interrupted");
      } finally {

         if (!executor.isTerminated()) {
            System.err.println("cancel non-finished tasks");
         }
         executor.shutdownNow();
         System.out.println("shutdown finished");
      }
   }

   static class Task implements Runnable {
      
      public void run() {

         try {
            Long duration = (long) (Math.random() * 20);
            System.out.println("Running Task!");
            TimeUnit.SECONDS.sleep(duration);
         } catch (InterruptedException e) {
            e.printStackTrace();
         }
      }
   }
}
This will produce the following result.
Shutdown executor
Running Task!
shutdown finished
cancel non-finished tasks
java.lang.InterruptedException: sleep interrupted
	at java.lang.Thread.sleep(Native Method)
	at java.lang.Thread.sleep(Thread.java:302)
	at java.util.concurrent.TimeUnit.sleep(TimeUnit.java:328)
	at TestThread$Task.run(TestThread.java:39)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
	at java.util.concurrent.FutureTask.run(FutureTask.java:138)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
	at java.lang.Thread.run(Thread.java:662)


    16 Lectures 
     2 hours 

 Malhar Lathkar

    19 Lectures 
     5 hours 

 Malhar Lathkar

    25 Lectures 
     2.5 hours 

 Anadi Sharma

    126 Lectures 
     7 hours 

  Tushar Kale

    119 Lectures 
     17.5 hours 

 Monica Mittal

    76 Lectures 
     7 hours 

 Arnab Chakraborty
 Print
 Add Notes
 Bookmark this page
Rotation of a point about another point in C++

Rotation of a point X about origin is by an angle θ in anti-clockwise direction is done by −
 X by θ about origin anti-clRotateockwise: X*polar( 1.0,θ ).
Here, the function polar for complex numbers is defined under <complex> header file
and is used to find a complex number using phase angle and magnitude.
polar(mag,angle) returns a complex number.
Rotation of point X about a point Y
To rotate a point about another point, we will use translation in which movement of all coordinates occur in a particular direction.
Translate X to Y, so Y becomes the new origin. This can be done by subtracting Y from all points. X now becomes X-Y.
Translate X to Y, so Y becomes the new origin. This can be done by subtracting Y from all points. X now becomes X-Y.
Rotate (X-Y) about new origin using above formula: (X-Y)*polar( 1.0,θ )
Rotate (X-Y) about new origin using above formula: (X-Y)*polar( 1.0,θ )
Back-translation by adding Y to all points.
Back-translation by adding Y to all points.
Rotation of X about Y is : (X-Y)*polar( 1.0,θ ) + Y
Below is the code to demonstrate rotation of point about another point
 Live Demo
#include <iostream>
#include <complex>
using namespace std;
typedef complex<double> point;
#define x real()
#define y imag()
int main(){
   // Rotate P about Q
   point X(5.0, 3.0);
   point Y(2.0, 4.0);
   // Angle of rotation is 90 degrees
   double theta = 3.14/2;
   point Xnew=(X-Y) * polar(1.0, theta) + Y;
   cout << "rotating X 90 degrees anti-clockwise about Y becomes:";
   cout << "(" << Xnew.x << ", " << Xnew.y << ")" << endl;
   return 0;
}
rotating X 90 degrees anti-clockwise about Y becomes:(3.00239, 6.9992)
How to import classes from within another directory/package in Java?

In Java classes and interfaces related to each other are grouped under a package. The package is nothing but a directory storing classes and interfaces of a particular concept. For example, all the classes and interfaces related to input and output operations are stored in the java.io package.
There are two types of packages namely user-defined packages and built-in packages (pre-defined)
Whenever you need to use the classes from a particular package −
First of all, you need to set a classpath for the JAR file holding the required package.
First of all, you need to set a classpath for the JAR file holding the required package.
Import the required class from the package using the import keyword. While importing you need to specify the absolute name (including the packages and sub-packages) of the required class.
Import the required class from the package using the import keyword. While importing you need to specify the absolute name (including the packages and sub-packages) of the required class.
In the following example we are trying to read a string value representing the name of the user from key-board (System.in). For this, we are using the scanner class of Java. Util Package.
 Live Demo
public class ReadingdData {
   public static void main(String args[]) {
      System.out.println("Enter your name: ");
      Scanner sc = new Scanner(System.in);
      String name = sc.next();
      System.out.println("Hello "+name);
   }
}
Since we are using a class named Scanner in our program and haven’t imported it in our program. On executing, this program generates the following compile-time error −
ReadingdData.java:6: error: cannot find symbol
      Scanner sc = new Scanner(System.in);
      ^
   symbol: class Scanner
   location: class ReadingdData
ReadingdData.java:6: error: cannot find symbol
      Scanner sc = new Scanner(System.in);
      ^
   symbol: class Scanner
location: class ReadingdData
2 errors
To resolve this error, add the import statement importing the scanner class on the top of the program as −
 Live Demo
import java.util.Scanner;
public class ReadingdData {
   public static void main(String args[]) {
      System.out.println("Enter your name: ");
      Scanner sc = new Scanner(System.in);
      String name = sc.next();
      System.out.println("Hello "+name);
   }
}
Enter your name:
krishna
Hello krishna
Python - Corpora Access

Corpora is a group presenting multiple collections of text documents. A single collection is called corpus. One such famous corpus is the Gutenberg Corpus which contains some 25,000 free electronic books, hosted at http://www.gutenberg.org/. In the below example we access the names of only those files from the corpus which are plain text with filename ending as .txt.  
 
from nltk.corpus import gutenberg
fields = gutenberg.fileids()

print(fields)
When we run the above program, we get the following output −
[austen-emma.txt', austen-persuasion.txt', austen-sense.txt', bible-kjv.txt', 
blake-poems.txt', bryant-stories.txt', burgess-busterbrown.txt',
carroll-alice.txt', chesterton-ball.txt', chesterton-brown.txt', 
chesterton-thursday.txt', edgeworth-parents.txt', melville-moby_dick.txt',
milton-paradise.txt', shakespeare-caesar.txt', shakespeare-hamlet.txt',
shakespeare-macbeth.txt', whitman-leaves.txt']

We can access the raw text from these files using sent_tokenize function which is also available in nltk. In the below example we retrieve the first two paragraphs of 
the blake poen text.
from nltk.tokenize import sent_tokenize
from nltk.corpus import gutenberg

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

token = sent_tokenize(sample)

for para in range(2):
    print(token[para])
When we run the above program we get the following output −
[Poems by William Blake 1789]

 
SONGS OF INNOCENCE AND OF EXPERIENCE
and THE BOOK of THEL


 SONGS OF INNOCENCE
 
 
 INTRODUCTION
 
 Piping down the valleys wild,
   Piping songs of pleasant glee,
 On a cloud I saw a child,
   And he laughing said to me:
 
 "Pipe a song about a Lamb!"
So I piped with merry cheer.


    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
How to use nested while loop in JavaScript?

The purpose of a while loop is to execute a statement or code block repeatedly as long as an expression is true. Once the expression becomes false, the loop terminates.
You can try to run the following code to learn how to use nested while loop
Live Demo
<html>
   <body>
      <script>
         var height = 2;
         var width = 8;

         var col = 0;
         var row = 0;
         document.write("Starting Loop<br> ");

         while (row < height) {
            col = 0;

            while(col < width) {
               document.write("#");
               col++;
            }
            document.write("<br>");
            row++;
         }
         document.write("Loop stopped!");
      </script>
   </body>
</html>
Sorted() function in Python

In this tutorial, we are going to learn about the sorted() function in Python.
The function sorted() is used to sort an iterable in ascending or descending order. We can even sort the list of dictionaries based on different keys and values. Let's get most out of the sorted() function.
The sorted() function is not an in-place algorithm like sort method.
The function sorted() will sort an iterable in ascending order by default. Let's see an example.
 Live Demo
# initializing a list
numbers = [4, 3, 5, 1, 2]
# sorting the numbers
sorted_numbers = sorted(numbers)
# printing the sorted_numbers
print(sorted_numbers)
If you run the above code, then you will get the following result.
[1, 2, 3, 4, 5]
We can set a parameter reverse as True to sort the iterable in descending order. Let's see an example.
 Live Demo
# initializing a list
numbers = [4, 3, 5, 1, 2]
# sorting the numbers
sorted_numbers = sorted(numbers, reverse=True)
# printing the sorted_numbers
print(sorted_numbers)
If you run the above code, then you will get the following result.
[5, 4, 3, 2, 1]
The function sorted() will take another optional parameter called key. The parameter key is to tell the sorted() on which value it has to sort the list.
Let's say we have a list of dictionaries. We have to sort the list of dictionaries based on a certain value. In this case, we pass key as a parameter with a function that returns a specific value on which we have to sort the list of dictionaries.
 Live Demo
# initializing a list
numbers = [{'a': 5}, {'b': 1, 'a': 1}, {'c': 3, 'a': 3}, {'d': 4, 'a': 4}, {'e'
'a': 2}]
# sorting the list of dict based on values
sorted_dictionaries = sorted(numbers, key= lambda dictionary: dictionary['a'])
# printing the numbers
print(sorted_dictionaries)
If you run the above code, then you will get the following result.
[{'b': 1, 'a': 1}, {'e': 2, 'a': 2}, {'c': 3, 'a': 3}, {'d': 4, 'a': 4}, {'a':
If you have any doubts in the tutorial, mention them in the comment section.
c# Put spaces between words starting with capital letters

To place spaces in between words starting with capital letters, try the following example −
Firstly, set the string.
var str = "WelcomeToMyWebsite";
As you can see above, our string isn’t having spaces before capital letter. To add it, use LINQ as we have done below −
str = string.Concat(str.Select(x => Char.IsUpper(x) ? " " + x : x.ToString())).TrimStart(' ');
The following is the complete code to place spaces between words beginning with capital letters −
using System;
using System.Linq;

class Demo {

   static void Main() {
      var str = "WelcomeToMyWebsite";

      Console.WriteLine("Original String: "+str);
      str = string.Concat(str.Select(x => Char.IsUpper(x) ? " " + x : x.ToString())).TrimStart(' ');

      Console.WriteLine("New String: "+str);
      Console.ReadLine();
   }
}