code-rag-bench/online-tutorials huggingface dataset:
The system() Function in Perl

You can use system() Perl function to execute any Unix command, whose output will go to the output of the perl script. By default, it is the screen, i.e., STDOUT, but you can redirect it to any file by using redirection operator > −
#!/usr/bin/perl
system( "ls -l")
1;
When above code is executed, it lists down all the files and directories available in the current directory −
drwxr-xr-x 3 root root 4096 Sep 14 06:46 9-14
drwxr-xr-x 4 root root 4096 Sep 13 07:54 android
-rw-r--r-- 1 root root 574 Sep 17 15:16 index.htm
drwxr-xr-x 3 544 401 4096 Jul 6 16:49 MIME-Lite-3.01
-rw-r--r-- 1 root root 71 Sep 17 15:16 test.pl
drwx------ 2 root root 4096 Sep 17 15:11 vAtrJdy
Be careful when your command contains shell environmental variables like PATHorHOME. Try following three scenarios −
#!/usr/bin/perl
$PATH = "I am Perl Variable";
system('echo $PATH'); # Treats $PATH as shell variable
system("echo $PATH"); # Treats $PATH as Perl variable
system("echo \$PATH"); # Escaping $ works.
1;
When above code is executed, it produces the following result depending on what is set in shell variable $PATH.
/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin
I am Perl Variable
/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin
How do I create a java.sql.Date object in Java?

The java.sql.Date represents the date value in JDBC. The constructor of this class accepts a long value representing the desired date and creates respective Date object.
Date(long date)
You can create this object using this constructor.
Live Demo
import java.text.ParseException;
import java.text.SimpleDateFormat;
public class Demo {
   public static void main(String args[]) throws ParseException {  
      String str = "26-09-1989";
      SimpleDateFormat obj = new SimpleDateFormat("dd-MM-yyyy");      
      long epoch = obj.parse(str).getTime();      
      System.out.println("Date value: "+epoch);
      //Creating java.util.Date object
      java.util.Date date = new java.util.Date(epoch);
      System.out.println(date);
   }
}
Date value: 622751400000
Tue Sep 26 00:00:00 IST 1989
The valueOf() method of this class has two variants as shown below −
valueOf(LocalDate date);
valueOf(String s);
This method accepts a LocalDate object or a date string value (yyyy-[m]m-[d]d format) representing a desired date and creates/returns a java.sql.Date object.
Live Demo
import java.sql.Date;
import java.time.LocalDate;
public class Demo {
   public static void main(String args[]) {  
      LocalDate localDate = LocalDate.of(2014, 9, 11);
      Date date = Date.valueOf(localDate);
      System.out.println(date);
   }
}
Date Value: 2014-09-11
Live Demo
import java.sql.Date;
public class Demo {
   public static void main(String args[]) {  
      String str = "2017-12-03";
      Date date = Date.valueOf(str);
      System.out.println("Date Value: "+date);
   }
}
yyyy-[m]m-[d]d
Python - Element wise Matrix Difference - GeeksforGeeks

25 Oct, 2021
Given two Matrixes, the task is to write a Python program to perform element-wise difference.
Examples:
Input : test_list1 = [[2, 4, 5], [5, 4, 2], [1, 2, 3]], test_list2 = [[6, 4, 6], [9, 6, 3], [7, 5, 4]] Output : [[4, 0, 1], [4, 2, 1], [6, 3, 1]] Explanation : 6 – 2 = 4, 4 – 4 = 0, 6 – 5 = 1. And so on. 
Input : test_list1 = [[2, 4, 5], [1, 2, 3]], test_list2 = [[6, 4, 6], [7, 5, 4]] Output : [[4, 0, 1], [6, 3, 1]] Explanation : 6 – 2 = 4, 4 – 4 = 0, 6 – 5 = 1. And so on.  
Method #1 : Using loop + zip()
In this, we perform task of combining indices within rows and rows using zip and nested loop is used to iterate through all the elements of all the rows.
Python3
# Python3 code to demonstrate working of# Element-wise Matrix Difference# Using loop + zip() # initializing liststest_list1 = [[2, 4, 5], [5, 4, 2], [1, 2, 3]]test_list2 = [[6, 4, 6], [9, 6, 3], [7, 5, 4]] # printing original listsprint("The original list 1 is : " + str(test_list1))print("The original list 2 is : " + str(test_list2)) res = [] # iterating for rowsfor sub1, sub2 in zip(test_list1, test_list2):    temp = []     # iterate for elements    for ele1, ele2 in zip(sub1, sub2):        temp.append(ele2 - ele1)    res.append(temp) # printing resultprint("The Matrix Difference : " + str(res))
The original list 1 is : [[2, 4, 5], [5, 4, 2], [1, 2, 3]]
The original list 2 is : [[6, 4, 6], [9, 6, 3], [7, 5, 4]]
The Matrix Difference : [[4, 0, 1], [4, 2, 1], [6, 3, 1]]
Method #2 : Using list comprehension + zip()
In this, we perform task of zipping using zip() and list comprehension is used to solve this problem in one liner way.
Python3
# Python3 code to demonstrate working of# Element-wise Matrix Difference# Using loop + zip() # initializing liststest_list1 = [[2, 4, 5], [5, 4, 2], [1, 2, 3]]test_list2 = [[6, 4, 6], [9, 6, 3], [7, 5, 4]] # printing original listsprint("The original list 1 is : " + str(test_list1))print("The original list 2 is : " + str(test_list2)) # using list comprehension to perform task in one lineres = [[ele2 - ele1 for ele1, ele2 in zip(sub1, sub2)]       for sub1, sub2 in zip(test_list1, test_list2)] # printing resultprint("The Matrix Difference : " + str(res))
The original list 1 is : [[2, 4, 5], [5, 4, 2], [1, 2, 3]]
The original list 2 is : [[6, 4, 6], [9, 6, 3], [7, 5, 4]]
The Matrix Difference : [[4, 0, 1], [4, 2, 1], [6, 3, 1]]
anikaseth98
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 ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
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?
Port scanner using 'python-nmap' - GeeksforGeeks

21 Apr, 2020
In this article, we will learn how to program a port scanner using the ‘nmap‘ module in Python. The program will take a range of port numbers as input and print the state (open or closed) of all the ports in that range.
Nmap: Nmap is a free and open-source network scanning tool. To run the program discussed in this article, you will need to have ‘nmap’ tool installed in your system. If it is not installed, visit Nmap download page.
We will be using the ‘python-nmap‘ module to achieve this task. Install the package (if not already installed) by the following command –
pip install python-nmap

Note: Doing ‘nmap’ scans on a target without proper permission and authority is illegal. Use localhost (127.0.0.1) as your target
Example:
import nmap   # take the range of ports to # be scannedbegin = 75end = 80  # assign the target ip to be scanned to# a variabletarget = '127.0.0.1'   # instantiate a PortScanner objectscanner = nmap.PortScanner()   for i in range(begin,end+1):       # scan the target port    res = scanner.scan(target,str(i))       # the result is a dictionary containing     # several information we only need to    # check if the port is opened or closed    # so we will access only that information     # in the dictionary    res = res['scan'][target]['tcp'][i]['state']       print(f'port {i} is {res}.')
Output:
port 75 is closed.
port 76 is closed.
port 77 is closed.
port 78 is closed.
port 79 is closed.
port 80 is open.

Note: The output can vary depending on the present status of the ports.
python-modules
python-utility
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Python | Get unique values from a list
Defaultdict in Python
Python | os.path.join() method
Create a directory in Python
Python | Pandas dataframe.groupby()
Python - Convert Lists to Nested Dictionary - GeeksforGeeks

14 May, 2020
Sometimes, while working with Python dictionaries, we can have a problem in which we need to convert list to nestings, i.e each list values representing new nested level. This kind of problem can have application in many domains including web development. Lets discuss certain way in which this task can be performed.
Method : Using zip() + list comprehensionThe combination of above functions can be combined to perform this task. In this, we iterate for zipped list and render the nested dictionaries using list comprehension.
# Python3 code to demonstrate working of # Convert Lists to Nestings Dictionary# Using list comprehension + zip()  # initializing listtest_list1 = ["gfg", 'is', 'best']test_list2 = ['ratings', 'price', 'score']test_list3 = [5, 6, 7]  # printing original listprint("The original list 1 is : " + str(test_list1))print("The original list 2 is : " + str(test_list2))print("The original list 3 is : " + str(test_list3))  # Convert Lists to Nestings Dictionary# Using list comprehension + zip()res = [{a: {b: c}} for (a, b, c) in zip(test_list1, test_list2, test_list3)]  # printing result print("The constructed dictionary : " + str(res)) 
The original list 1 is : ['gfg', 'is', 'best']
The original list 2 is : ['ratings', 'price', 'score']
The original list 3 is : [5, 6, 7]
The constructed dictionary : [{'gfg': {'ratings': 5}}, {'is': {'price': 6}}, {'best': {'score': 7}}]

 
Python list-programs
Python-nested-dictionary
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python String | replace()
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
Convert integer to string in Python
What is NULL ? Give an example to illustrate testing for NULL in SQL. What is dangling tuple problem ? - GeeksforGeeks

03 Nov, 2021
What is NULL ?In Structured Query Language Null Or NULL is a special type of marker which is used to tell us about that a data value does not present in the database. In Structured Query Language (SQL) Null is a predefined word which is used to identity this marker. It is very important to understand that a NULL value is totally different than a zero value.
In other words we can say that a NULL attribute value is equivalent of nothing that means in database there is an attribute that has a value which indicates nothing or Null, An attributes does not exist or we can say that it is missing . In database a Null value in tables is that value in the fields that appears to be blank. It is a field that has no value.
An Example to illustrate testing for NULL in SQL :Suppose there is a table named as CUSTOMERS that having records as given below.
Now we can use IS NOT NULL operator and write a query which is as following.
SQL> SELECT * 
FROM CUSTOMERS 
WHERE SALARY IS NOT NULL;
After execution this query would produce the following result-
Here we can see that in CUSTOMERS table , ID no. 6 and 7 which is named as NAMAN and AYUSH and their salary column is empty and in other words it is Null . That’s why after query execution it would produce a table where these two names NAMAN and AYUSH not present because we use IS NOT NULL operator.
Now we can use IS NULL operator and write a query.
SQL> SELECT * 
FROM CUSTOMERS 
WHERE SALARY IS NULL;
After execution this query would produce the following results-
Here we can that in CUSTOMERS table , ID no. 6 and 7 which is named as NAMAN and AYUSH and their salary column is empty and in other words it is Null. That’s why after query execution it would produce a table where these two names NAMAN and AYUSH not present because we use IS NULL operator.
What is Dangling tuple problem?In DBMS if there is a tuple that does not participate in a natural join we called it as dangling tuple . It may gives indication consistency problem in the database.
Another definition  of dangling problem tuple is that a tuple with a foreign key value that not appear in the referenced relation is known as dangling tuple. In DBMS Referential integrity constraints specify us exactly when dangling tuples indicate problem. 
DBMS-SQL
DBMS
SQL
DBMS
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Deadlock in DBMS
Types of Functional dependencies in DBMS
KDD Process in Data Mining
Conflict Serializability in DBMS
Two Phase Locking Protocol
SQL | DDL, DQL, DML, DCL and TCL Commands
How to find Nth highest salary from a table
SQL | ALTER (RENAME)
How to Update Multiple Columns in Single Update Statement in SQL?
MySQL | Group_CONCAT() Function
DateTime.GetTypeCode() Method in C# - GeeksforGeeks

05 Feb, 2019
This method is used to return the TypeCode for value type DateTime.
Syntax: public TypeCode GetTypeCode ();
Return Value: This method returns the enumerated constant, DateTime.
Below programs illustrate the use of DateTime.GetTypeCode() Method
Example 1:
// C# program to demonstrate the// DateTime.GetTypeCode()// Methodusing System;  class GFG {      // Main Method    public static void Main()    {          // creating object of DateTime        DateTime date = new DateTime(2010, 1,                                1, 4, 0, 15);          // getting Typecode of date        // using GetTypeCode() method;        TypeCode value = date.GetTypeCode();          // Display the hashcode        Console.WriteLine("TypeCode is {0}", value);    }}
TypeCode is DateTime

Example 2:
// C# program to demonstrate the// DateTime.GetTypeCode()// Methodusing System;  class GFG {      // Main Method    public static void Main()    {        // calling check() method        check(new DateTime(2010, 1,                     3, 4, 0, 15));          check(new DateTime(2010, 1,                     5, 4, 0, 15));    }      public static void check(DateTime date)    {          // getting TypeCodeCode of date        // using GetTypeCode() method;        TypeCode value = date.GetTypeCode();          // Display the ShortTime        Console.WriteLine("TypeCode of {0} is {1}",                                      date, value);    }}
TypeCode of 01/03/2010 04:00:15 is DateTime
TypeCode of 01/05/2010 04:00:15 is DateTime

Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.datetime.gettypecode?view=netframework-4.7.2
CSharp DateTime Struct
CSharp-method
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 50 C# Interview Questions & Answers
Extension Method in C#
HashSet in C# with Examples
Partial Classes in C#
C# | Inheritance
Convert String to Character Array in C#
Linked List Implementation in C#
C# | How to insert an element in an Array?
C# | List Class
Difference between Hashtable and Dictionary in C#
How to align button to right side of text box in Bootstrap? - GeeksforGeeks

18 Aug, 2021
Bootstrap allows us to align elements by using the utility class float. As we want to align the button to the right side of the text box, we have to use the float-right class. Syntax:  
<button class="btn btn-success btn-lg float-right" type="submit">Submit</button>
Example:  
html
<!DOCTYPE html><html> <head>    <title>Bootstrap Button Alignment</title>    <meta charset="utf-8">    <meta name="viewport"          content="width=device-width, initial-scale=1">    <link rel="stylesheet"          href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">  </script>    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js">    </script>    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js">    </script></head> <body>    <div class="container">        <h1 style="text-align:center;color:green;">          GeeksforGeeks      </h1>        <form>            <div class="form-group">                <label for="">Enter Your Name:</label>                <input class="form-control"                       type="text"                       placeholder="Input Your Name Here">            </div>            <div class="form-group">                <button class="btn btn-success btn-lg float-right"                        type="submit">                     Submit                </button>            </div>        </form>    </div></body> </html>
Output:  
Note: Although by default, elements like buttons, are left-aligned still we can use float-left class to mention it specifically. We can also use the class float-none to remove any hierarchical floating. It is important to note that we are using Bootstrap 4 here, in Bootstrap 3 or Bootstrap 2 we can use the helper classes like pull-left, pull-right to align the elements to the left or right accordingly. 
kapoorsagar226
Bootstrap-4
Bootstrap-Misc
Picked
Bootstrap
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Show Images on Click using HTML ?
How to set Bootstrap Timepicker using datetimepicker library ?
Difference between Bootstrap 4 and Bootstrap 5
How to Use Bootstrap with React?
Tailwind CSS vs Bootstrap
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?
Java program to check for URL in a String

A program can be created to check if a string is a correct URL or not. An example of an URL is given as follows −
String = https://www.wikipedia.org/
The above string is a valid URL
A program that demonstrates this is given as follows.
 Live Demo
import java.net.URL;
public class Example {
   public static boolean check_URL(String str) {
   try {
      new URL(str).toURI();
      return true;
   }catch (Exception e) {
      return false;
   }
}
public static void main(String[] args) {
   String str = "http://www.wikipedia.org/";
   System.out.println("String = " + str);
   if (check_URL(str))
      System.out.println("The above string is a URL");
   else
      System.out.println("The above string is not a URL");
   }
}
String = http://www.wikipedia.org/
The above string is a URL
Now let us understand the above program.
In the function check_URL(), a URL object is created. If there is no exception when the object is created, then true is returned. Otherwise, false is returned. The code snippet that demonstrates this is given as follows.
public static boolean check_URL(String str) {
   try {
      new URL(str).toURI();
      return true;
   }catch (Exception e) {
      return false;
   }
}
In the function main(), the string is printed. Then the function check_URL() is called with string str. If true is returned, then str is a URL and that is printed otherwise str is not a URL and that is printed. The code snippet that demonstrates this is given as follows.
public static void main(String[] args) {
   String str = "http://www.wikipedia.org/";
   System.out.println("String = " + str);
   if (check_URL(str))
      System.out.println("The above string is a URL");
   else
      System.out.println("The above string is not a URL");
}
io.popen() function in Lua Programming

Sometimes we want to execute the system's command and then make use of whatever was returned by them, and in order to do that we simply can either make use of the os.execute() function or io.popen() function.
The difference between the os.execute() function and the io.popen() function is that the output value of the os.execute() function is much harder to deal with, and that is the reason why it is recommended to use the io.popen() function, whose output value is much easier to handle and make use of.
io.popen() starts the program in a separate process and returns a file handle that you can use to read data from this program.
output = io.popen(command)
Now that we know what io.popen() function does, let’s use it in a Lua example.
Consider the example shown below −
local handle = io.popen("echo hello")
local result = handle:read("*a")
handle:close()
In the above code, we made use of io.popen that returns a file handle that we can use to read the output of the command.
hello
jQuery Effects - Sliding

The jQuery slide methods slide elements up and down.
Click to slide down/up the panel
Because time is valuable, we deliver quick and easy learning.
At W3Schools, you can study everything you need to learn, in an accessible and handy format.
jQuery slideDown()
Demonstrates the jQuery slideDown() method.
jQuery slideUp()
Demonstrates the jQuery slideUp() method.
jQuery slideToggle()
Demonstrates the jQuery slideToggle() method.
With jQuery you can create a sliding effect on elements.
jQuery has the following slide methods:
slideDown()
slideUp()
slideToggle()
The jQuery slideDown() method is used to slide down an element.
Syntax:
The optional speed parameter specifies the duration of the effect. It can take the following values: "slow", "fast", or 
milliseconds.
The optional callback parameter is a function to be executed after the sliding completes.
The following example demonstrates the slideDown() method:
The jQuery slideUp() method is used to slide up an element.
Syntax:
The optional speed parameter specifies the duration of the effect. It can take the following values: "slow", "fast", or 
milliseconds.
The optional callback parameter is a function to be executed after the sliding completes.
The following example demonstrates the slideUp() method:
The jQuery slideToggle() method toggles between the slideDown() and slideUp() 
methods.
If the elements have been slid down, slideToggle() will slide them up.
If the elements have been slid up, slideToggle() will slide them down. 
The optional speed parameter can take the following values: "slow", "fast", milliseconds.
The optional callback parameter is a function to be executed after the 
sliding completes.
The following example demonstrates the slideToggle() method:
Use a jQuery method to slide up a <div> element.
$("div").();

Start the Exercise
For a complete overview of all jQuery effects, please go to our 
jQuery Effect Reference.
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
Merge objects in array with similar key JavaScript

Let’s say, we have the following array of objects −
const arr = [
   {id: 1, h1: 'Daily tests'},
   {id: 2, h1: 'Details'},
   {id: 1, h2: 'Daily classes'},
   {id: 3, h2: 'Results'},
   {id: 2, h3: 'Admissions'},
   {id: 1, h4: 'Students'},
   {id: 2, h5: 'Alumni'},
   {id: 3, h3: 'Appreciations'},
   {id: 1, h5: 'Tiny Tots'},
   {id: 1, h6: 'Extras'},
];
We have to write a function that converts this array into an array where all the headings (h1, h2,
h3 ...) that have the same id get clubbed inside the same object. Therefore, let’s write the code
for this function −
const arr = [
   {id: 1, h1: 'Daily tests'},
   {id: 2, h1: 'Details'},
   {id: 1, h2: 'Daily classes'},
   {id: 3, h2: 'Results'},
   {id: 2, h3: 'Admissions'},
   {id: 1, h4: 'Students'},
   {id: 2, h5: 'Alumni'},
   {id: 3, h3: 'Appreciations'},
   {id: 1, h5: 'Tiny Tots'},
   {id: 1, h6: 'Extras'},
];
const clubArray = (arr) => {
   return arr.reduce((acc, val, ind) => {
      const index = acc.findIndex(el => el.id === val.id);
      if(index !== -1){
         const key = Object.keys(val)[1];
         acc[index][key] = val[key];
      } else {
         acc.push(val);
      };
      return acc;
   }, []);
};
console.log(clubArray(arr));
The output in the console will be −
[
   {
      id: 1,
      h1: 'Daily tests',
      h2: 'Daily classes',
      h4: 'Students',
      h5: 'Tiny Tots',
      h6: 'Extras'
   },
   { id: 2, h1: 'Details', h3: 'Admissions', h5: 'Alumni' },
   { id: 3, h2: 'Results', h3: 'Appreciations' }
]
How to make a HTML div responsive using CSS ?

30 Sep, 2020
The CSS Media Query can be used to make an HTML “div” responsive. The media queries allow the users to change or customize the web pages for many devices like desktops, mobile phones, tablets, etc without changing the markups. Using the media query, the user can change the style of a particular element for different sizes of screen.
The CSS @media rule consists of a media type and it can have one or more expressions, which can result to values like “true” or “false”.
Syntax:
 
@media not|only mediatype and (expressions) {
    // Your CSS codes
}

The following meta viewport element has to included in the “head” section of the HTML file for the responsive web page to work.
<meta name=”viewport” content=”width=device-width, initial-scale=1.0”>
Example: In the following example, all three HTML “div” blocks are aligned horizontally. But whenever the screen size is reduced below “500px”, all the three blocks will automatically align vertically. The width property for the “div” element in the @media query for screen size is set to less than or equal to “500px”.
HTML
<!DOCTYPE html><html>  <head>    <meta name="viewport" content=        "width=device-width, initial-scale=1.0">    <style>        div {            margin: 10px;        }          .first {            width: 25%;            display: inline-block;            background-color: green;        }          .second {            width: 25%;            display: inline-block;            background-color: blue;        }          .third {            width: 25%;            display: inline-block;            background-color: yellow;        }          @media screen and (max-width: 500px) {              .first,            .second,            .third {                width: 70%;            }        }    </style></head>  <body>    <h1>Geeks for Geeks</h1>    <p>Responsive div using css.</p>    <div class="first">        <p>First block</p>    </div>    <div class="second">        <p>Second block</p>    </div>    <div class="third">        <p>Third block </p>    </div>    <p>        The media query will only apply         if the media type is screen        and the viewport is equal to         or less than 500px    </p></body>  </html>
Output:
In the original window size, all the three blocks are aligned horizontally.
In the original window size, all the three blocks are aligned horizontally.
When the screen size is reduced to “500px”, all the three blocks are placed vertically.
When the screen size is reduced to “500px”, all the three blocks are placed vertically.
Similarly, one can add or change various styles for a particular HTML element for different screen sizes by adding CSS code in @media query section as shown in the above example.
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.
C++ String Library - find

It searches the string for the first occurrence of the sequence specified by its arguments.
Following is the declaration for std::string::find.
size_t find (const string& str, size_t pos = 0) const;
size_t find (const string& str, size_t pos = 0) const noexcept;
size_t find (const string& str, size_t pos = 0) const noexcept;
str − It is a string object.
str − It is a string object.
len − It is used to copy the characters.
len − It is used to copy the characters.
pos − Position of the first character to be copied.
pos − Position of the first character to be copied.
none
if an exception is thrown, there are no changes in the string.
In below example for std::string::find.
#include <iostream>
#include <string>

int main () {
   std::string str ("sairamkrishna Mammahe is a tech person in tutorialspoint.com.");
   std::string str2 ("needle");

   std::size_t found = str.find(str2);
   if (found!=std::string::npos)
      std::cout << "first 'needle' found at: " << found << '\n';

   found=str.find("needles are small",found+1,6);
   if (found!=std::string::npos)
      std::cout << "second 'needle' found at: " << found << '\n';

   found=str.find("haystack");
   if (found!=std::string::npos)
      std::cout << "'haystack' also found at: " << found << '\n';

   found=str.find('.');
   if (found!=std::string::npos)
      std::cout << "Period found at: " << found << '\n';

   str.replace(str.find(str2),str2.length(),"preposition");
   std::cout << str << '\n';

   return 0;
}
The sample output should be like this −
Period found at: 56

 Print
 Add Notes
 Bookmark this page
What is the use of a double-click event in AngularJs? - GeeksforGeeks

25 Jul, 2019
The ng-dblclick event in the AngularJS is useful for the HTML elements for getting the double click event, defined. In case a user wishes to get the function fired or other events when the double click of the HTML elements is done, then this event will be going to be needed. All the elements of the HTML will be going to support it.
Basically, the directive of ng-dblclick will be telling the AngularJS what exactly the HTML or the HTML elements need to do when it is double-clicked. However, it is not going to be overriding the original ondblclick event of the element, as both of them are going to be executed.
Syntax:
<element ng-dblclick="expression"> </element>

Parameter Values:
expression: The execution of the expression, when double-click is done on any element.Example: (The example is going to increase the value of the “count” of the variable, every time a double-click is done on the header.)<!DOCTYPE html>  <html><script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>  <head>    <title>        AngularJS ng-dblclick Directive    </title></head>  <body style="text-align:center;" ng-app="">    <h1 style="color:green">      GeeksForGeeks  </h1>    <h2 style="color:purple">      ng-dblclick Directive  </h2>    <p>On the header given below,       Double-Click on it.</p>    <h1 style="color:#EA6964"         ng-dblclick="count = count + 1"        ng-init="count=0">Click</h1>        <p>Double-Click has been done {{count}} times.</p>    <p></p></body>  </html>Output:My Personal Notes
arrow_drop_upSave
Example: (The example is going to increase the value of the “count” of the variable, every time a double-click is done on the header.)
<!DOCTYPE html>  <html><script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>  <head>    <title>        AngularJS ng-dblclick Directive    </title></head>  <body style="text-align:center;" ng-app="">    <h1 style="color:green">      GeeksForGeeks  </h1>    <h2 style="color:purple">      ng-dblclick Directive  </h2>    <p>On the header given below,       Double-Click on it.</p>    <h1 style="color:#EA6964"         ng-dblclick="count = count + 1"        ng-init="count=0">Click</h1>        <p>Double-Click has been done {{count}} times.</p>    <p></p></body>  </html>
Output:
AngularJS-Misc
Picked
AngularJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Angular PrimeNG Dropdown Component
Angular PrimeNG Calendar Component
Angular PrimeNG Messages Component
Angular 10 (blur) Event
How to make a Bootstrap Modal Popup in Angular 9/8 ?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
How to create a responsive inline form with CSS?

Following is the code to create a responsive inline form with CSS −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
body {
   font-family: Arial, Helvetica, sans-serif;
}
* {
   box-sizing: border-box;
}
form {
   display: flex;
   flex-flow: row wrap;
   align-items: center;
}
form label {
   margin: 5px 10px 5px 0;
}
form input {
   margin: 5px 10px 5px 0;
   padding: 10px;
}
form button {
   padding: 10px 20px;
   font-size: 20px;
   background-color: rgb(39, 22, 141);
   border: 1px solid #ddd;
   color: white;
   cursor: pointer;
   font-weight: bolder;
   border-radius: 4px;
}
form button:hover {
   background-color: rgb(113, 65, 225);
}
@media (max-width: 800px) {
   form input {
      margin: 10px 0;
   }
   form {
      flex-direction: column;
      align-items: stretch;
   }
}
</style>
</head>
<body>
<h1>Responsive Inline Form Example</h1>
<form>
<label for="email">Email:</label>
<input type="email" id="email" placeholder="Enter email" name="email" />
<label for="pass">Password:</label>
<input type="password" id="pass" placeholder="Enter password" name="pass"/>
<button type="submit">Submit</button>
</form>
</body>
</html>
The above code will produce the following output −
On resizing the browser window the elements will reflow as follows −
Python | Check if all the values in a list that are greater than a given value

21 Nov, 2018
Given a list, print all the values in a list that are greater than the given valueExamples:
Input : list = [10, 20, 30, 40, 50] 
        given value = 20 
Output : No

Input : list = [10, 20, 30, 40, 50] 
        given value = 5 
Output : Yes

Method 1: Traversal of list
By traversing in the list, we can compare every element and check if all the elements in the given list are greater than the given value or not.
# python program to check if all # values in the list are greater # than val using traversal  def check(list1, val):          # traverse in the list    for x in list1:          # compare with all the values        # with val        if val>= x:            return False     return True            # driver code list1 =[10, 20, 30, 40, 50, 60]val = 5if(check(list1, val)):    print"Yes"else:    print"No"  val = 20 if(check(list1, val)):    print"Yes"else:    print"No"
Output:
Yes
No

Method 2: Using all() function:
Using all() function we can check if all values are greater than any given value in a single line. It returns true if the given condition inside the all() function is true for all values, else it returns false.
# python program to check if all # values in the list are greater# than val using all() function  def check(list1, val):    return(all(x > val for x in list1))            # driver code list1 =[10, 20, 30, 40, 50, 60]val = 5if(check(list1, val)):    print"Yes"else:    print"No"  val = 20 if (check(list1, val)):    print"Yes"else:    print"No"
Output:
Yes
No

Python list-programs
python-list
Arrays
Python
python-list
Arrays
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Pandas Series.argmax()

27 Feb, 2019
Pandas series is a One-dimensional ndarray with axis labels. The labels need not be unique but must be a hashable type. The object supports both integer- and label-based indexing and provides a host of methods for performing operations involving the index.
Pandas Series.argmax() function returns the row label of the maximum value in the given series object.
Syntax: Series.argmax(axis=0, skipna=True, *args, **kwargs)
Parameter :skipna : Exclude NA/null values. If the entire Series is NA, the result will be NA.axis : For compatibility with DataFrame.idxmax. Redundant for application on Series.*args, **kwargs : Additional keywords have no effect but might be accepted for compatibility with NumPy.
Returns : idxmax : Index of maximum of values.
Example #1: Use Series.argmax() function to return the row label of the maximum value in the given series object
# importing pandas as pdimport pandas as pd  # Creating the Seriessr = pd.Series([34, 5, 13, 32, 4, 15])  # Create the Indexindex_ = ['Coca Cola', 'Sprite', 'Coke', 'Fanta', 'Dew', 'ThumbsUp']  # set the indexsr.index = index_  # Print the seriesprint(sr)
Output :
Coca Cola    34
Sprite        5
Coke         13
Fanta        32
Dew           4
ThumbsUp     15
dtype: int64
Now we will use Series.argmax() function to return the row label of the maximum value in the given series object.
# return the row label for# the maximum valueresult = sr.argmax()  # Print the resultprint(result)
Output :
Coca Cola
As we can see in the output, the Series.argmax() function has successfully returned the row label of the maximum value in the given series object. Example #2 : Use Series.argmax() function to return the row label of the maximum value in the given series object.
# importing pandas as pdimport pandas as pd  # Creating the Seriessr = pd.Series([11, 21, 8, 18, 65, 18, 32, 10, 5, 32, None])  # Create the Index# apply yearly frequencyindex_ = pd.date_range('2010-10-09 08:45', periods = 11, freq ='Y')  # set the indexsr.index = index_  # Print the seriesprint(sr)
Output :
2010-12-31 08:45:00    11.0
2011-12-31 08:45:00    21.0
2012-12-31 08:45:00     8.0
2013-12-31 08:45:00    18.0
2014-12-31 08:45:00    65.0
2015-12-31 08:45:00    18.0
2016-12-31 08:45:00    32.0
2017-12-31 08:45:00    10.0
2018-12-31 08:45:00     5.0
2019-12-31 08:45:00    32.0
2020-12-31 08:45:00     NaN
Freq: A-DEC, dtype: float64
Now we will use Series.argmax() function to return the row label of the maximum value in the given series object.
# return the row label for# the maximum valueresult = sr.argmax()  # Print the resultprint(result)
Output :
2014-12-31 08:45:00
As we can see in the output, the Series.argmax() function has successfully returned the row label of the maximum value in the given series object.
Python pandas-series
Python pandas-series-methods
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python – Character coordinates in Matrix

30 Dec, 2020
Sometimes, while working with Python data, we can have a problem in which we need to extract all the coordinates in Matrix, which are characters. This kind of problem can have potential application in domains such as web development and day-day programming. Let’s discuss certain ways in which this task can be performed.
Input : test_list = [‘1G’, ’12F’, ‘231G’]Output : [(0, 1), (1, 2), (2, 3)]
Input : test_list = [‘G’, ‘F’, ‘G’]Output : [(0, 0), (1, 0), (2, 0)]
Method #1 : Using enumerate() + list comprehension + isalpha()The combination of above functions can be used to solve this problem. In this, we perform the task of working with indices using enumerate and characters filtering is done using isalpha().
# Python3 code to demonstrate working of # Character coordinates in Matrix# Using enumerate() + list comprehension + isalpha()          # initializing listtest_list = ['23f45.;4d', '5678d56d', '789', '5678g']  # printing original listprint("The original list is : " + str(test_list))  # Character coordinates in Matrix# Using enumerate() + list comprehension + isalpha()res = [(x, y) for x, val in enumerate(test_list)         for y, chr in enumerate(val) if chr.isalpha()]    # printing result print("Character indices : " + str(res)) 
The original list is : ['23f45.;4d', '5678d56d', '789', '5678g']
Character indices : [(0, 2), (0, 8), (1, 4), (1, 7), (3, 4)]

 
Method #2 : Using regex() + loopThe combination of above functions can be used to solve this problem. In this, we perform task of filtering alphabets using regex expressions. Just returns the first occurrence of character in each string.
# Python3 code to demonstrate working of # Character coordinates in Matrix# Using regex() + loopimport re          # initializing listtest_list = ['23f45.;4d', '5678d56d', '789', '5678g']  # printing original listprint("The original list is : " + str(test_list))  # Character coordinates in Matrix# Using regex() + loopres = []for key, val in enumerate(test_list):    temp = re.search('([a-zA-Z]+)', val)    if temp :        res.append((key, temp.start()))          # printing result print("Character indices : " + str(res)) 
The original list is : ['23f45.;4d', '5678d56d', '789', '5678g']
Character indices : [(0, 2), (1, 4), (3, 4)]

Python list-programs
Python matrix-program
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Matplotlib.figure.Figure.get_axes() in Python

30 Apr, 2020
Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. The figure module provides the top-level Artist, the Figure, which contains all the plot elements. This module is used to control the default spacing of the subplots and top level container for all plot elements.
The get_axes() method figure module of matplotlib library is used to get the list of axes in the Figure.
Syntax: get_axes(self)
Parameters: This method does not accept any parameters.
Returns: This method returns a list of axes in the Figure.
Below examples illustrate the matplotlib.figure.Figure.get_axes() function in matplotlib.figure:
Example 1:
# Implementation of matplotlib functionimport matplotlib.pyplot as pltfrom matplotlib.tri import Triangulationfrom matplotlib.patches import Polygonimport numpy as np    xs = list([ 1, 2, 3, 4, 5, 6, 7, 8, 9])ys = list([9, 8, 7, 6, 5, 4, 3, 2, 1])          fig = plt.figure()  ax = fig.add_subplot(111)ax.plot(ys, xs)  fig.get_axes()[0].set_ylabel("Y label")fig.get_axes()[0].set_xlabel("X label")    fig.suptitle('matplotlib.figure.Figure.get_axes()\function Example\n\n', fontweight ="bold")  plt.show()
Output:
Example 2:
# Implementation of matplotlib functionimport matplotlib.pyplot as pltfrom matplotlib.tri import Triangulationfrom matplotlib.patches import Polygonimport numpy as np    xs = list([ 1, 2, 3, 4, 5, 6, 7, 8, 9])ys = list([9, 8, 7, 6, 5, 4, 3, 2, 1])          fig = plt.figure()  ax = fig.add_subplot(111)ax.bar(ys, xs, width = 0.5, align ="center")  fig.get_axes()[0].set_ylabel("Number")fig.get_axes()[0].set_xlabel("Values")    fig.suptitle('matplotlib.figure.Figure.get_axes()\ function Example\n\n', fontweight ="bold")  plt.show()
Output:
Matplotlib figure-class
Python-matplotlib
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
kinit - Unix, Linux Command

The use must be registered as a principal with the Key Distribution Center
(KDC) prior to running kinit.


<USER_HOME> is obtained from the
java.lang.System property
user.home. <USER_NAME> is obtained from
java.lang.System property
user.name. If <USER_HOME>
is null, the cache file would be stored in
the current directory that
the program is running from.
<USER_NAME> is the operating system’s login
username. This username could be different than
the user’s principal name. For
example on Solaris, it could be
/home/duke/krb5cc_duke,
in which duke is the <USER_NAME>
and  /home/duke is the
<USER_HOME>.


By default, the keytab name is retrieved from
the Kerberos configuration file. If
the keytab name is not specifed in the Kerberos
configuration file, the name is
assumed to be <USER_HOME>/krb5.keytab


If you do not specify the password using
the password option on the command
line, kinit will prompt you for the password.


Note: password is provided only for testing purposes. Do not place
your password in a script or provide your password on the command
line. Doing so will compromise your password.


For more information see the man pages for kinit.



kinit duke@JAVA.SUN.COM


Requesting proxiable credentials for a different
principal and storing these credentials in a
specified file cache:



kinit -p -c FILE:/home/duke/credentials/krb5cc_cafebeef
cafebeef@JAVA.SUN.COM


Requesting proxiable and forwardable credentials
for a different principal and
storing these credentials in a specified file cache:



kinit -f -p -c
FILE:/home/duke/credentials/krb5cc_cafebeef
cafebeef@JAVA.SUN.COM


Displaying the help menu for kinit:



kinit -help















Advertisements


    129 Lectures 
     23 hours 

 Eduonix Learning Solutions

    5 Lectures 
     4.5 hours 

 Frahaan Hussain

    35 Lectures 
     2 hours 

 Pradeep D

    41 Lectures 
     2.5 hours 

 Musab Zayadneh

    46 Lectures 
     4 hours 

 GUHARAJANM

    6 Lectures 
     4 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
How to convert an integer to a unicode character in Python?

Python library’s chr() function converts Unicode character associated to any interger which is between 0 an 0x10ffff.
>>> chr(36)
'$'
>>> chr(97)
'a'
>>> chr(81)
'Q'
Create scatterplot for two dependent variables and one independent variable in R.

To create scatterplot for two dependent variables and one independent variable, we can use geom_point function and geom_smooth function of ggplot2 package. Both of these functions will be used twice, where we can define the aesthetics of the plot for each dependent variable as shown in the Example below.
Following snippet creates a sample data frame −
x<-rnorm(20)
y1<-rnorm(20,5)
y2<-rnorm(20,10)
df<-data.frame(x,y1,y2)
df
The following dataframe is created −
            x       y1       y2
 1  2.4995751 5.515944 11.055437
 2 -0.6271148 6.234058 9.847844
 3  1.5572278 4.363662 10.305286
 4  0.7544594 4.660968 9.709750
 5 -0.3531405 5.896566 8.300061
 6  0.3516249 6.714057 10.735020
 7  0.4605740 4.955006 8.975519
 8  0.2999492 4.671082 10.373543
 9  1.0682999 4.590270 11.436856
10  0.2140709 5.163876 9.100128
11 -0.3508677 4.798086 9.221152
12  0.6303074 4.879782 10.123158
13 -1.0964767 4.678353 9.703888
14 -1.0814789 4.701568 10.983667
15  0.3777337 4.694484 11.089179
16  0.9787944 5.577403 8.935059
17 -0.2456083 6.365431 9.195587
18 -1.1495510 3.654495 7.648289
19  0.1903006 7.930433 11.254847
20  0.6788355 4.661313 11.421257
To load the ggplot2 package and to create a scatterplot for dependent variables y1 and y2 that has only one independent variable x on the above created data frame, add the following code to the above snippet −
x<-rnorm(20)
y1<-rnorm(20,5)
y2<-rnorm(20,10)
df<-data.frame(x,y1,y2)
library(ggplot2)

ggplot(df,aes(x,y1))+geom_point()+geom_smooth(method="lm")+geom_point(aes(x,y2)
)+geom_smooth(aes(x,y2),method="lm")
`geom_smooth()` using formula 'y ~ x'
`geom_smooth()` using formula 'y ~ x'
If you execute all the above given snippets as a single program, it generates the following Output −
C++ Queue Library - empty() Function

The C++ function std::queue::empty() tests whether queue is empty or not. Queue of zero size is considered as empty queue.
Following is the declaration for std::queue::empty() function form std::queue header.
bool empty() const;

None
Returns true if queue is empty otherwise false.
Constant i.e. O(1)
The following example shows the usage of std::queue::empty() function.
#include <iostream>
#include <queue>

using namespace std;

int main(void) {
   queue<int> q;

   if (q.empty())
      cout << "Queue is empty." << endl;

   q.push(10);

   if (!q.empty())
      cout << "Queue is not empty." << endl;

   return 0;
}
Let us compile and run the above program, this will produce the following result −
Queue is empty.
Queue is not empty.

 Print
 Add Notes
 Bookmark this page