code-rag-bench/online-tutorials huggingface dataset:
Bootstrap 4 .card-columns class

Create a grid of cards with Bootstrap 4, using the card-columns class −
<div class="card-columns">
  <!—Add cards- ->
</div>
Set the card classes inside the card-columns class −
<div class="card-columns">
  <div class="card bg-primary">
    <div class="card-body">
      <p class="card-text">One</p>
    </div>
  </div>
</div>
Let us see an example stating the usage of card-columns class −
Live Demo
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Bootstrap Example</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.1.0/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
  </head>
<body>
  <div class="container">
    <h2>Demo</h2>
    <div class="card-columns">
      <div class="card bg-primary">
        <div class="card-body">
          <p class="card-text">One</p>
        </div>
      </div>
      <div class="card bg-warning">
        <div class="card-body">
          <p class="card-text">Two</p>
        </div>
      </div>
      <div class="card bg-light">
        <div class="card-body">
          <p class="card-text">Three</p>
        </div>
      </div>
    </div>
  </div>
</body>
</html>
Inheritance vs Composition in C#

With Inheritance, you can designate that the new class should inherit the members of an existing class. This existing class is called the baseclass, and the new class is referred to as the derived class. Inheritance implements the IS-A relationship. For example, mammal IS A animal, dog IS-A mammal hence dog IS-A animal as well, and so on.
For example, A base class Shape has a derived classes like Circle, Square, Rectangle, etc.
Under Composition, if the parent object is deleted, then the child object also loses its status. Composition is a special type of Aggregation and gives a part-of relationship.
For example, A Car has an engine. If the car is destroyed, the engine is destroyed as well.
public class Engine {
   . . .
}
public class Car {
   Engine eng = new Engine();
   .......
}
EnumerateFiles method in C#

EnumerateFile() method is used in C# to get all the files. Use AllDirectories property to recurse through directories −
Directory.EnumerateFiles(@"D:\NEW", "*.*", SearchOption.AllDirectories)
To get the list of files in a directory, use the SearchOptions.AllDirectories in C# as shown above.
Let us see how −
using System;
using System.IO;
namespace Demo {
   class Program {
      static void Main(string[] args) {
         foreach (string allFiles is Directory.EnumerateFiles(@"D:\NEW","*.*",SearchOption.AllDirectories)) {
            Console.WriteLine(allFiles);
         }
      }
   }
}
The following is the output −
D:\NEW\my.txt
D:\NEW\amit.html
D:\NEW\tutorials\java\a.java
Perform Binary Search in Java using Collections.binarySearch

Binary Search can be performed in Java using the method java.util.Collections.binarySearch(). This method requires two parameters i.e. the list in which binary search is to be performed and the element that is to be searched. It returns the index of the element if it is in the list and returns -1 if it is not in the list.
A program that demonstrates this is given as follows −
 Live Demo
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class Demo {
   public static void main(String args[]) {
      List aList = new ArrayList();
      aList.add("James");
      aList.add("George");
      aList.add("Bruce");
      aList.add("Susan");
      aList.add("Martha");
      Collections.sort(aList);
      System.out.println("The sorted ArrayList is: " + aList);
      int index = Collections.binarySearch(aList, "Martha");
      System.out.println("Element Martha is at index: " + index);
      index = Collections.binarySearch(aList, "Amy");
      System.out.println("Element Amy is at index: " + index);
   }
}
The output of the above program is as follows −
The sorted ArrayList is: [Bruce, George, James, Martha, Susan]
Element Martha is at index: 3
Element Amy is at index: -1
Now let us understand the above program.
The ArrayList aList is created. Then ArrayList.add() is used to add the elements to the ArrayList. The ArrayList elements are sorted using Collections.sort(). A code snippet which demonstrates this is as follows −
List aList = new ArrayList();
aList.add("James");
aList.add("George");
aList.add("Bruce");
aList.add("Susan");
aList.add("Martha");
Collections.sort(aList);
The sorted ArrayList is displayed and then Collections.binarySearch() is used to find if the elements “Martha” and “Amy” are available in the LinkedList or not. A code snippet which demonstrates this is as follows −
System.out.println("The sorted ArrayList is: " + aList);
int index = Collections.binarySearch(aList, "Martha");
System.out.println("Element Martha is at index: " + index);
index = Collections.binarySearch(aList, "Amy");
System.out.println("Element Amy is at index: " + index);
Selenium - Drag and Drop

As a tester, you might be in a situation to perform a 'Drag & drop' operation. We will perform a drag and drop operation by picking up a tree grid that is available for us on http://www.keenthemes.com/preview/metronic/templates/admin/ui_tree.html. In the example, we would like to drag an element 'Disable Node' from 'initially open' folder to 'Parent Node' Folder.
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.interactions.Action;

public class webdriverdemo {

   public static void main(String[] args) throws InterruptedException {
   
      WebDriver driver = new FirefoxDriver();
      //Puts a Implicit wait, Will wait for 10 seconds before throwing exception
      driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
      
      // Launch website
      driver.navigate().to("http://www.keenthemes.com/preview/metronic/templates/admin/ui_tree.html");
      driver.manage().window().maximize();
      
      WebElement From = driver.findElement(By.xpath(".//*[@id='j3_7']/a"));
      WebElement To = driver.findElement(By.xpath(".//*[@id='j3_1']/a"));
      
      Actions builder = new Actions(driver);
      Action dragAndDrop = builder.clickAndHold(From).moveToElement(To).release(To).build();
      
      dragAndDrop.perform();
      driver.close();
   }
}
After performing the drag-drop operation, the output would be as shown below.

    46 Lectures 
     5.5 hours 

 Aditya Dua

    296 Lectures 
     146 hours 

 Arun Motoori

    411 Lectures 
     38.5 hours 

 In28Minutes Official

    22 Lectures 
     7 hours 

 Arun Motoori

    118 Lectures 
     17 hours 

 Arun Motoori

    278 Lectures 
     38.5 hours 

 Lets Kode It
 Print
 Add Notes
 Bookmark this page
Apache NiFi - Environment Setup

In this chapter, we will learn about the environment setup ofApache NiFi. The steps for installation of Apache NiFi are as follows −
Step 1 − Install the current version of Java in your computer. Please set theJAVA_HOME in your machine. You can check the version as shown below:
In Windows Operating System (OS) (using command prompt) −
> java -version

In UNIX OS (Using Terminal):
$ echo $JAVA_HOME




Step 2 − DownloadApache NiFi from https://nifi.apache.org/download.html
For windows OSdownload ZIP file.
For windows OSdownload ZIP file.
For UNIX OSdownload TAR file.
For UNIX OSdownload TAR file.
For docker images,go to the following link https://hub.docker.com/r/apache/nifi/.
For docker images,go to the following link https://hub.docker.com/r/apache/nifi/.
Step 3 − The installation process for Apache NiFi is very easy. The process differs with the OS −
Windows OS − Unzip the zip package and the Apache NiFi is installed.
Windows OS − Unzip the zip package and the Apache NiFi is installed.
UNIX OS − Extract tar file in any location and the Logstash is installed.
UNIX OS − Extract tar file in any location and the Logstash is installed.
$tar -xvf nifi-1.6.0-bin.tar.gz

Step 4 − Open command prompt, go to the bin directory of NiFi. For example, C:\nifi-1.7.1\bin, and execute run-nifi.bat file.
C:\nifi-1.7.1\bin>run-nifi.bat

Step 5 − It will take a few minutes to get the NiFi UI up. A user cancheck nifi-app.log, once NiFi UI is up then, a user can enter http://localhost:8080/nifi/ to access UI.

    46 Lectures 
     3.5 hours 

 Arnab Chakraborty

    23 Lectures 
     1.5 hours 

 Mukund Kumar Mishra

    16 Lectures 
     1 hours 

 Nilay Mehta

    52 Lectures 
     1.5 hours 

 Bigdata Engineer

    14 Lectures 
     1 hours 

 Bigdata Engineer

    23 Lectures 
     1 hours 

 Bigdata Engineer
 Print
 Add Notes
 Bookmark this page
Bootstrap Filter list

To create a filter list, use the .list-group class in Bootstrap.
You can try to run the following code to create a filter list −
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet">
      <script src = "/scripts/jquery.min.js"></script>
      <script src = "/bootstrap/js/bootstrap.min.js"></script>
   </head>
   <body>
      <div class = "container">
         <h2>Tutorials</h2>
         <input class="form-control" id="demo" type="text" placeholder="Search here...">
         <br>
         <ul class = "list-group" id = "newList">
            <li class = "list-group-item">Java</li>
            <li class = "list-group-item">jQuery</li>
            <li class = "list-group-item">PHP</li>
            <li class = "list-group-item">AngularJS</li>
            <li class = "list-group-item">Ruby</li>
            <li class = "list-group-item">C</li>
         </ul>
      </div>
      <script>
         $(document).ready(function(){
            $("#demo").on("keyup", function() {
               var value = $(this).val().toLowerCase();
               $("#newList li").filter(function() {
                  $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
               });
            });
         });
      </script>
    </body>
</html>
Find unique rows in a NumPy array - GeeksforGeeks

02 Sep, 2020
In this article we will discuss how to find unique rows in a NumPy array. To find unique rows in a NumPy array we are using numpy.unique() function of NumPy library.
Syntax : numpy.unique(ar, return_index=False, return_inverse=False, return_counts=False, axis=None)
Now, let’s see an example:
Example 1:
Python3
# import libraryimport numpy as np  # Create a 2D numpy arrayarr2D = np.array([[11, 11, 12, 11],                     [13, 11, 12, 11],                     [16, 11, 12, 11],                     [11, 11, 12, 11]])  print('Original Array :' ,      arr2D, sep = '\n')  # Get unique rows from# complete 2D-array by # passing axis = 0 in # unique function along# with 2D-arrayuniqueRows = np.unique(arr2D,                        axis = 0)  # print the output resultprint('Unique Rows:',      uniqueRows, sep = '\n')
Output:
Original Array :
[[11 11 12 11]
[13 11 12 11]
[16 11 12 11]
[11 11 12 11]]
Unique Rows:
[[11 11 12 11]
[13 11 12 11]
[16 11 12 11]]

Example 2:
Python3
# import libraryimport numpy as np  # create 2d numpy arrayarray = np.array([[1, 2, 3, 4],                  [3, 2, 4, 1],                  [6, 8, 1, 2]])  print("Original array: \n",      array)  # Get unique rows from# complete 2D-array by # passing axis = 0 in # unique function along# with 2D-arrayuniqueRows = np.unique(array,                        axis = 0)  # print the output resultprint('Unique Rows :',      uniqueRows,      sep = '\n')
Output:
Original array: 
 [[1 2 3 4]
 [3 2 4 1]
 [6 8 1 2]]
Unique Rows :
[[1 2 3 4]
 [3 2 4 1]
 [6 8 1 2]]

Python numpy-arrayManipulation
Python-numpy
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?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | os.path.join() method
Python | Get unique values from a list
Create a directory in Python
Defaultdict in Python
Python | Pandas dataframe.groupby()
Stack peek() Method in Java - GeeksforGeeks

02 Aug, 2018
The java.util.Stack.peek() method in Java is used to retrieve or fetch the first element of the Stack or the element present at the top of the Stack. The element retrieved does not get deleted or removed from the Stack.
Syntax:
STACK.peek()
Parameters: The method does not take any parameters.
Return Value: The method returns the element at the top of the Stack else returns NULL if the Stack is empty.
Exception: The method throws EmptyStackException if the stack is empty.
Below programs illustrate the java.util.Stack.peek() method:Program 1:
// Java code to illustrate peek() function  import java.util.*;  public class StackDemo {    public static void main(String args[])    {        // Creating an empty Stack        Stack<String> STACK = new Stack<String>();          // Use push() to add elements into the Stack        STACK.push("Welcome");        STACK.push("To");        STACK.push("Geeks");        STACK.push("For");        STACK.push("Geeks");          // Displaying the Stack        System.out.println("Initial Stack: " + STACK);          // Fetching the element at the head of the Stack        System.out.println("The element at the top of the"                           + " stack is: " + STACK.peek());          // Displaying the Stack after the Operation        System.out.println("Final Stack: " + STACK);    }}
Initial Stack: [Welcome, To, Geeks, For, Geeks]
The element at the top of the stack is: Geeks
Final Stack: [Welcome, To, Geeks, For, Geeks]

Program 2:
// Java code to illustrate peek() function  import java.util.*;  public class StackDemo {    public static void main(String args[])    {        // Creating an empty Stack        Stack<Integer> STACK = new Stack<Integer>();          // Use push() to add elements into the Stack        STACK.push(10);        STACK.push(15);        STACK.push(30);        STACK.push(20);        STACK.push(5);          // Displaying the Stack        System.out.println("Initial Stack: " + STACK);          // Fetching the element at the head of the Stack        System.out.println("The element at the top of the"                           + " stack is: " + STACK.peek());          // Displaying the Stack after the Operation        System.out.println("Final Stack: " + STACK);    }}
Initial Stack: [10, 15, 30, 20, 5]
The element at the top of the stack is: 5
Final Stack: [10, 15, 30, 20, 5]

Java - util package
Java-Collections
Java-Functions
Java-Stack
Java
Java
Java-Collections
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Arrays in Java
Split() String method in Java with examples
For-each loop in Java
Object Oriented Programming (OOPs) Concept in Java
Arrays.sort() in Java with examples
Reverse a string in Java
HashMap in Java with Examples
Stream In Java
Interfaces in Java
How to iterate any Map in Java
Print substring of a given string without using any string function and loop in C - GeeksforGeeks

14 Jul, 2017
Write a function mysubstr() in C that doesn’t use any string function, doesn’t use any loop and prints substring of a string. The function should not modify contents of string and should not use a temporary char array or string.
For example mysubstr(“geeksforgeeks”, 1, 3) should print “eek” i.e., the substring between indexes 1 and 3.
One solution is to use recursion. Thanks to Gopi and oggy for suggesting this solution.
#include<stdio.h>  // This function prints substring of str[] between low and// high indexes (both inclusive).  void mysubstr(char str[], int low, int high){    if (low<=high)    {        printf("%c", str[low]);        mysubstr(str, low+1, high);    }}  int main (){    char str[] = "geeksforgeeks";    mysubstr(str, 1, 3);    return 0;}
Output:
eek
How to do it if recursions is also not allowed?We can always use pointer arithmetic to change the beginning part. For example (str + i) gives us address of i’th character. To limit the ending, we can use width specifier in printf which can be passed as an argument when * is used in format string.
#include <stdio.h>  // This function prints substring of str[] between low and// high indexes (both inclusive).  void mysubstr(char str[], int low, int high){    printf("%.*s", high-low+1, (str+low));}  int main (){    char str[] = "geeksforgeeks";    mysubstr(str, 1, 3);    return 0;}
Output:
eek
This article is contributed by Rahul Jain. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
C-String
C Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
TCP Server-Client implementation in C
Exception Handling in C++
Multithreading in C
'this' pointer in C++
Arrow operator -> in C/C++ with Examples
Smart Pointers in C++ and How to Use Them
Understanding "extern" keyword in C
Multiple Inheritance in C++
Ways to copy a vector in C++
How to split a string in C/C++, Python and Java?
Java Program to Print the Elements of an Array Present on Even Position - GeeksforGeeks

21 Oct, 2021
The task is to print all the elements that are present in even position. Consider an example, we have an array of length 6, and we need to display all the elements that are present in 2,4 and 6 positions i.e; at indices 1, 3, 5. 
Example:
Input: [1,2,3,4,5,6]

Output: 2
        4
        6

Input: [1,2]

Output: 2 
Approach:1) First take a class with the name DisplayElementAtEvenPosition.2) Then inside the main function, declare and initialize an array with values mentioned in the above example.3) Now in -order to display the values at even position we need to iterate through the array.4) For this purpose take a for-loop and iterate through the array while incrementing the value with 2 as we need the values at even position.5) Once done with the approach, compile it to get the output.
Example:
Java
// Java Program to Print the Elements of an Array Present on// Even Position import java.io.*;import java.util.*; public class EvenPosition {    public static void main(String[] args)    {        // declaration and initialization of array.        int[] arr = new int[] { 1, 2, 3, 4, 5, 6 };         // iterating through the array using for loop        for (int i = 1; i < arr.length; i = i + 2) {             // print element to the console            System.out.println(arr[i]);        }    }}
2
4
6
Time Complexity: O(n) where n is the size of an array
Auxiliary Space: O(1)
adnanirshad158
Java-Array-Programs
Picked
Java
Java Programs
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Constructors in Java
Exceptions in Java
Functional Interfaces in Java
Generics in Java
Java Programming Examples
Convert Double to Integer in Java
Implementing a Linked List in Java using Class
How to Iterate HashMap in Java?
Iterate through List in Java
Python | shutil.disk_usage() method - GeeksforGeeks

07 Jun, 2019
Shutil module in Python provides many functions of high-level operations on files and collections of files. It comes under Python’s standard utility modules. This module helps in automating process of copying and removal of files and directories.
shutil.disk_usage() method in Python is to get disk usage statistics about the given path. This method returns a named tuple with attributes total, used and free. The total attribute represents the amount of total space, the used attribute represents the amount of used space and the free attribute represents the amount of available space, in bytes.
Note: On Windows, the given path must represent a directory but on Unix systems, it can be a file or directory.
Syntax: shutil.disk_usage(path)
Parameter:path: A path-like object representing a file system path. A path-like object is either a string or bytes object representing a path.
Return Type: This method returns a named tuple with attributed total, used and free.
# Python program to explain shutil.disk_usage() method     # importing shutil module import shutil  # Pathpath = "/home/User/Documents"  # Get the disk usage statistics# about the given pathstat = shutil.disk_usage(path)  # Print disk usage statisticsprint("Disk usage statistics:")print(stat)
Disk usage statistics:
usage(total=244934381568, used=13350301696, free=219070689280)

Reference: https://docs.python.org/3/library/shutil.html
python-utility
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Different ways to create Pandas Dataframe
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
Check if element exists in list in Python
How to generate a documentation using Python? - GeeksforGeeks

01 Oct, 2020
Documentation improves the readability of the code. There are many tools that help us to create documentations. One such tool is pdoc to write documentation for python projects. 
Installation: Run the following pip command on the terminal.
pip3 install pdoc3

Now navigate (through command line) to the folder where our Python program is kept. Let’s say the name of our program is Numbers.py. It is a simple class that has 2 functions, one to find the factorial of the number and another to check whether the number is a prime number or not.
Python3
class Numbers :           """        This class will be used to perform operations on numbers.        To find out their factorial, check whether the number is prime        """           def isPrime(self, number) :                   '''                A method to check whether a number is prime                '''                   i = 2                while(i <= number / 2) :                        if number % i == 0:                                return False                        i += 1                return True                  def factorial(self, number) :                              """                A function that finds out the factorial of numbers                """                result = 1                while(number >= 2) :                        result *= number                        number -= 1                return result
Adding docstrings in classes and methods provide a convenient way of associating documentation with Python modules, functions, classes, and methods. Docstrings are an important part of the documentation. 
After navigating to the folder(through command line) where our code (Numbers.py) is kept. We have to type this command in the terminal:
 pdoc --html Numbers.py

Directory structure
After firing the –html command shown above, an HTML folder will be created in the directory where Numbers.py is kept. Inside that HTML folder, a file called Numbers.html will be created. Navigate to HTML folder and open Numbers.html.
Numbers.html
Numbers.html should be looking like this. We just created proper documentation of our class Numbers. In the left column(Index) of Number.html, classes and it’s methods are seen. Remember the docstrings which we wrote, they are available below their respective classes and methods.
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()
How to find all files in a directory with extension .txt in Python?

You can use the os.listdir method to get all directories and files in a directory. Then filter the list to get only the files and check their extensions as well.
>>> import os
>>> file_list = [f for f in os.listdir('.') if os.path.isfile(os.path.join('.', f)) and f.endswith('.txt')]
>>> print file_list
['LICENSE.txt', 'NEWS.txt', 'README.txt']
The endswith method is a member of string class that checks if a string ends with a certain suffix.
You can also use the glob module to achieve the same:
>>> import glob, os
>>> file_list = [f for f in glob.glob("*.txt")]
>>> print file_list
['LICENSE.txt', 'NEWS.txt', 'README.txt']
Matplotlib.axis.Axis.set_ticklabels() function in Python

08 Jun, 2020
Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. It is an amazing visualization library in Python for 2D plots of arrays and used for working with the broader SciPy stack.
The Axis.set_ticklabels() function in axis module of matplotlib library is used to set the text values of the tick labels.  
Syntax: Axis.set_ticklabels(self, ticklabels, \*args, minor=False, \*\*kwargs)  
Parameters: This method accepts the following parameters. 
ticklabels : This parameter is the List of texts for tick labels.
minor : This parameter contains the bool value.
Return value: This method returns the list of Texts. 
Below examples illustrate the matplotlib.axis.Axis.set_ticklabels() function in matplotlib.axis: 
Example 1:
Python3
# Implementation of matplotlib functionfrom matplotlib.axis import Axisimport matplotlib.pyplot as pltimport numpy as np    fig = plt.figure()   x = np.linspace(0,2*np.pi,100)y = 2*np.sin(x)   ax = fig.add_subplot()ax.plot(x,y)  ax.yaxis.set_ticklabels(['','a','b','c','d',                         'e','f','g','h','i',                         ''])  ax.xaxis.set_ticklabels(['','A','B','C','D',                         'E','F','G',''])  ax.grid()   fig.suptitle("""matplotlib.axis.Axis.set_ticklabels()function Example\n""", fontweight ="bold")      plt.show()
Output:  
Example 2:
Python3
# Implementation of matplotlib functionfrom matplotlib.axis import Axisimport matplotlib.pyplot as pltimport numpy as np     fig = plt.figure()x = np.linspace(-np.pi, np.pi, 100)y = 2 * np.sin(x)  ax = fig.add_subplot()ax.set_title('centered spines')ax.plot(x, y)  ax.spines['left'].set_position('center')ax.spines['right'].set_color('none')ax.spines['bottom'].set_position('center')ax.spines['top'].set_color('none')  ax.xaxis.set_ticks_position('bottom')ax.yaxis.set_ticks_position('left')ax.xaxis.set_ticklabels(['','A','B','C','D',                         'E','F','G',''])  ax.grid()   fig.suptitle("""matplotlib.axis.Axis.set_ticklabels()function Example\n""", fontweight ="bold")      plt.show()
Output:  
 
Matplotlib-Axis 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
Create a directory in Python
Teradata - Macros

Macro is a set of SQL statements which are stored and executed by calling the Macro name. The definition of Macros is stored in Data Dictionary. Users only need EXEC privilege to execute the Macro. Users don't need separate privileges on the database objects used inside the Macro. Macro statements are executed as a single transaction. If one of the SQL statements in Macro fails, then all the statements are rolled back. Macros can accept parameters. Macros can contain DDL statements, but that should be the last statement in Macro.
Macros are created using CREATE MACRO statement.
Following is the generic syntax of CREATE MACRO command.
CREATE MACRO <macroname> [(parameter1, parameter2,...)] ( 
   <sql statements> 
);

Consider the following Employee table.
The following example creates a Macro called Get_Emp. It contains a select statement to retrieve records from employee table.
CREATE MACRO Get_Emp AS ( 
   SELECT 
   EmployeeNo, 
   FirstName, 
   LastName 
   FROM  
   employee 
   ORDER BY EmployeeNo; 
);
Macros are executed using EXEC command.
Following is the syntax of EXECUTE MACRO command.
EXEC <macroname>; 

The following example executes the Macro names Get_Emp; When the following command is executed, it retrieves all records from employee table.
EXEC Get_Emp; 
*** Query completed. 5 rows found. 3 columns returned. 
*** Total elapsed time was 1 second.  
EmployeeNo             FirstName                      LastName 
-----------  ------------------------------  --------------------------- 
   101                  Mike                          James 
   102                  Robert                        Williams 
   103                  Peter                         Paul 
   104                  Alex                          Stuart 
   105                  Robert                        James 
Teradata Macros can accept parameters. Within a Macro, these parameters are referenced with ; (semicolon).
Following is an example of a Macro that accepts parameters.
CREATE MACRO Get_Emp_Salary(EmployeeNo INTEGER) AS ( 
   SELECT 
   EmployeeNo, 
   NetPay 
   FROM  
   Salary 
   WHERE EmployeeNo = :EmployeeNo; 
);
Macros are executed using EXEC command. You need EXEC privilege to execute the Macros.
Following is the syntax of EXECUTE MACRO statement.
EXEC <macroname>(value);

The following example executes the Macro names Get_Emp; It accepts employee no as parameter and extracts records from employee table for that employee.
EXEC Get_Emp_Salary(101); 
*** Query completed. One row found. 2 columns returned. 
*** Total elapsed time was 1 second.
std::hash class in C++ STL

24 Oct, 2021
The hash class is default constructible, which means that one can construct this object without any arguments or initialization values. It is used to get the hash value of the argument that is being passed to it. If the argument doesn’t change, the value doesn’t change either.Syntax:  
template <class T> struct hash;
Syntax to create object:  
hash<class template> object-name
Member functions: This Hash class only has one member function:  
operator(): It returns hashed value for given argument.
Below is the implementation of the hash class:Example:  
CPP
#include <bitset> // functional header// for hash<class template> class#include <functional> #include <iostream>#include <string>#include <vector> using namespace std; // To demonstrate String Hashingvoid stringHashing(){     // Get the string    // to get its hash value    string hashing1 = "Geeks";     // Instantiation of Object    hash<string> mystdhash;     // Using operator() to get hash value    cout << "String hash values: "         << mystdhash(hashing1)         << endl;} // To demonstrate BITSET Hashingvoid bitsetHashing(){     // Get the BITSET    // to get its hash value    bitset<5> h_bitset("10101");     // Instantiation of Object    hash<bitset<5> > hash_bitset;     // Using operator() to get hash value    cout << "\nBitset 10101 hash value: "         << hash_bitset(h_bitset) << endl;} // To demonstrate Vector<bool> Hashingvoid vectorHashing(){     // Get the Vector<bool>    // to get its hash value    vector<bool>        h_vecbool{ true, false,                   true, false };     // Instantiation of Object    hash<vector<bool> > hash_vector_bool;     // Using operator() to get hash value    cout << "\nVector<bool> hash value: "         << hash_vector_bool(h_vecbool)         << endl;} // To demonstrate Char Hashingvoid charHashing(){     // Get the char    // to get its hash value    char ch = 'a';     // Instantiation of Object    hash<char> hash_char;     // Using operator() to get hash value    cout << "\nChar hash values: "         << hash_char(ch)         << endl;} // Driver Codeint main(){     stringHashing();    bitsetHashing();    vectorHashing();    charHashing();}
String hash values: 4457761756728957899

Bitset 10101 hash value: 17123654466142159564

Vector hash value: 16935082123893034051

Char hash values: 97
 
Reference: http://www.cplusplus.com/reference/functional/hash/ 
anikaseth98
cpp-class
STL
C++
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
MATLAB - The break Statement

The break statement terminates execution of for or while loop. Statements in the loop that appear after the break statement are not executed.
In nested loops, break exits only from the loop in which it occurs. Control passes to the statement following the end of that loop.
Create a script file and type the following code −
a = 10;
% while loop execution 
while (a < 20 )
   fprintf('value of a: %d\n', a);
   a = a + 1;
      if( a > 15)
         % terminate the loop using break statement 
         break;
      end 
end
When you run the file, it displays the following result −
value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 15
Loop Unrolling

19 Feb, 2018
Loop unrolling is a loop transformation technique that helps to optimize the execution time of a program. We basically remove or reduce iterations. Loop unrolling increases the program’s speed by eliminating loop control instruction and loop test instructions.
Program 1:
// This program does not uses loop unrolling.#include<stdio.h>  int main(void){    for (int i=0; i<5; i++)        printf("Hello\n"); //print hello 5 times      return 0;} 
Program 2:
// This program uses loop unrolling.#include<stdio.h>  int main(void){    // unrolled the for loop in program 1    printf("Hello\n");    printf("Hello\n");    printf("Hello\n");    printf("Hello\n");    printf("Hello\n");      return 0;} 
Output:
Hello
Hello
Hello
Hello
Hello

Illustration:Program 2 is more efficient than program 1 because in program 1 there is a need to check the value of i and increment the value of i every time round the loop. So small loops like this or loops where there is fixed number of iterations are involved can be unrolled completely to reduce the loop overhead.
Advantages:
Increases program efficiency.
Reduces loop overhead.
If statements in loop are not dependent on each other, they can be executed in parallel.
Disadvantages:
Increased program code size, which can be undesirable.
Possible increased usage of register in a single iteration to store temporary variables which may reduce performance.
Apart from very small and simple codes, unrolled loops that contain branches are even slower than recursions.
Reference:https://en.wikipedia.org/wiki/Loop_unrolling
This article is contributed by Harsh Agarwal. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Algorithms
Algorithms
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
What is Hashing | A Complete Tutorial
Find if there is a path between two vertices in an undirected graph
How to Start Learning DSA?
Complete Roadmap To Learn DSA From Scratch
Types of Complexity Classes | P, NP, CoNP, NP hard and NP complete
Difference between NP hard and NP complete problem
What Should I Learn First: Data Structures or Algorithms?
Ternary Search
K means Clustering - Introduction
Hash Functions and list/types of Hash functions
What is connection pooling in C# and how to achieve it?

These are used to import namespaces (or create aliases for namespaces or types).
These go at the top of the file, before any declarations.
using System;
using System.IO;
using WinForms = global::System.Windows.Forms;
using WinButton = WinForms::Button;
The using statement ensures that Dispose() is called even if an exception occurs when you are creating objects and calling methods, properties and so on. Dispose() is a method that is present in the IDisposable interface that helps to implement custom Garbage Collection. In other words, if we are doing some database operation (Insert, Update, Delete) but somehow an exception occurs, then here the using statement closes the connection automatically.here's no need to call the connection Close() method explicitly.
Another important factor is that it helps in Connection Pooling. Connection Pooling in .NET helps to eliminate the closing of a database connection multiple times. It sends the connection object to a pool for future use (next database call). The next time a database connection is called from your application the connection pool fetches the objects available in the pool. So it helps to improve the performance of the application. So when we use the using statement the controller sends the object to the connection pool automatically, and there is no need to call the Close() and Dispose() methods explicitly.
using (Stream input = File.OpenRead(filename)) {
   ...
}
string connString = "Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind;";
using (SqlConnection conn = new SqlConnection(connString)) {
   SqlCommand cmd = conn.CreateCommand();
   cmd.CommandText = "SELECT CustomerId, CompanyName FROM Customers";
   conn.Open();

   using (SqlDataReader dr = cmd.ExecuteReader()) {
      while (dr.Read())
      Console.WriteLine("{0}\t{1}", dr.GetString(0), dr.GetString(1));
   }
}
In the above code we are not closing any connection, it will close automatically. The using statement will call conn.Close() automatically due to the using statement
(using (SqlConnection conn = new SqlConnection(connString)) and the same for a SqlDataReader object.And also if any exception occurs it will close the connection automatically.
Convert an Object to List in R Programming – as.list() Function

27 Oct, 2021
as.list() function in R Programming Language is used to convert an object to a list. These objects can be Vectors, Matrices, Factors, and dataframes.
Syntax: as.list(object)
Parameters: 
object: Vector, Matrix, factor, or data frame 
R
# R program to convert object to list # Creating vectorx < - c(1, 2, 3, 4, 5) # Calling as.list() Functionas.list(x)
Output: 
[[1]]
[1] 1

[[2]]
[1] 2

[[3]]
[1] 3

[[4]]
[1] 4

[[5]]
[1] 5
R
# R program to convert object to list # Calling pre-defined data setBOD # Calling as.list() Functionas.list(BOD)
Output: 
  Time demand
1    1    8.3
2    2   10.3
3    3   19.0
4    4   16.0
5    5   15.6
6    7   19.8
$Time
[1] 1 2 3 4 5 7

$demand
[1]  8.3 10.3 19.0 16.0 15.6 19.8

attr(, "reference")
[1] "A1.4, p. 270"
R
# R program to create a matrix# and then convert into list A = matrix(     # Taking sequence of elementsc(1, 2, 3, 4, 5, 6, 7, 8, 9), # No of rowsnrow = 3, # No of columnsncol = 3,        # By default matrices are in column-wise order# So this parameter decides how to arrange the matrixbyrow = TRUE       ) # Naming rowsrownames(A) = c("a", "b", "c") # Naming columnscolnames(A) = c("c", "d", "e") cat("The 3x3 matrix:\n")print(A)  lst = as.list(A)lst
Output:
The 3x3 matrix:
  c d e
a 1 2 3
b 4 5 6
c 7 8 9
[[1]]
[1] 1

[[2]]
[1] 4

[[3]]
[1] 7

[[4]]
[1] 2

[[5]]
[1] 5

[[6]]
[1] 8

[[7]]
[1] 3

[[8]]
[1] 6

[[9]]
[1] 9
 
kumar_satyam
R List-Function
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Filter data by multiple conditions in R using Dplyr
Change Color of Bars in Barchart using ggplot2 in R
How to Split Column Into Multiple Columns in R DataFrame?
Loops in R (for, while, repeat)
Group by function in R using Dplyr
How to change Row Names of DataFrame in R ?
How to Change Axis Scales in R Plots?
R - if statement
Logistic Regression in R Programming
How to filter R DataFrame by values in a column?
Hide axis values but keep axis tick labels in matplotlib

To hide the axis value but to keep the axis tick labels, we can perform the following steps −
Plot a line using the plot( ) method.
Plot a line using the plot( ) method.
Set X and Y labels using x label and y label methods.
Set X and Y labels using x label and y label methods.
Using plt.gca(), get the current axis, creating one if necessary.
Using plt.gca(), get the current axis, creating one if necessary.
Use xaxis.set_ticklabels() with an empty list.
Use xaxis.set_ticklabels() with an empty list.
Use yaxis.set_ticklabels() with an empty list.
Use yaxis.set_ticklabels() with an empty list.
To show the diagram, use the plt.show() method.
To show the diagram, use the plt.show() method.
import matplotlib.pyplot as plt

plt.plot([0, 5], [0, 5])

plt.ylabel("Y-axis ")
plt.xlabel("X-axis ")

ax = plt.gca()
ax.axes.xaxis.set_ticklabels([])
ax.axes.yaxis.set_ticklabels([])
plt.show()
GATE | GATE-CS-2016 (Set 1) | Question 46 - GeeksforGeeks

28 Jun, 2021
What will be the output of the following pseudo-code when parameters are passed by reference and dynamic scoping is assumed?
a=3;
void n(x) {x = x * a; print(x);}
void m(y) {a = 1; a = y - a; n(a); print(a);}
void main() {m(a);} 
(A) 6, 2(B) 6, 6(C) 4, 2(D) 4, 4Answer: (D)Explanation:
a = 3;

void main() 
{  
   // Calls m with 'a' being passed by reference
   // Since there is no local 'a', global 'a' is passed. 
   m(a);
} 


// y refers to global 'a' as main calls "m(a)"
void m(y) 
{
   // A local 'a' is created with value 1.
   a = 1; 

   // a = 3 - 1 = 2
   a = y - a; 

   // Local 'a' with value 2 is passed by 
   // reference to n()
   n(a); 

   // Modified local 'a' is printed
   print(a);
}

// Local 'a' of m is passed here
void n(x) 
{
  // x = 2 * 2 [Note : again local 'a' is referred
  //                   because of dynamic scoping]  
  x = x * a; 

  // 4 is printed and local 'a' of m() is also
  // changed to 4.
  print(x);
}

Quiz of this Question
GATE-CS-2016 (Set 1)
GATE-GATE-CS-2016 (Set 1)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | Gate IT 2007 | Question 25
GATE | GATE-CS-2000 | Question 41
GATE | GATE-CS-2001 | Question 39
GATE | GATE-CS-2005 | Question 6
GATE | GATE MOCK 2017 | Question 21
GATE | GATE-CS-2006 | Question 47
GATE | GATE MOCK 2017 | Question 24
GATE | Gate IT 2008 | Question 43
GATE | GATE-CS-2009 | Question 38
GATE | GATE-CS-2003 | Question 90
matplotlib.pyplot.angle_spectrum() in Python - GeeksforGeeks

12 Apr, 2020
Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. Pyplot is a state-based interface to a Matplotlib module which provides a MATLAB-like interface.
The angle_spectrum() function in pyplot module of matplotlib library is used to plot the angle spectrum. Generally, it computes the angle spectrum of sequence and plotting is done.
Syntax: angle_spectrum(x, Fs=2, Fc=0, window=mlab.window_hanning, pad_to=None, sides=’default’, **kwargs)
Parameters: This method accept the following parameters that are described below:
x: This parameter is a sequence of data.
Fs : This parameter is a scalar. Its default value is 2.
window: This parameter take a data segment as an argument and return the windowed version of the segment. Its default value is window_hanning()
sides: This parameter specifies which sides of the spectrum to return. This can have following values : ‘default’, ‘onesided’ and ‘twosided’.
pad_to : This parameter contains the integer value to which the data segment is padded.
Fc: This parameter is also contains the integer value to offsets the x extents of the plot to reflect the frequency range. Its default value is 0
Returns: This returns the following:
spectrum :This returns the angle spectrum in radians.
freqs :This returns the frequencies corresponding to the elements in spectrum.
line : This returns the line created by this function.
The resultant is (spectrum, freqs, line)
Below examples illustrate the matplotlib.pyplot.angle_spectrum() function in matplotlib.pyplot:
Example #1:
# Implementation of matplotlib.pyplot.angle_spectrum()# function  import matplotlib.pyplot as pltimport numpy as np  np.random.seed(10**5)  dt = 0.0001Fs = 1 / dtgeeks = np.array([24.40, 110.25, 20.05,                   22.00, 61.90, 7.80,                   15.00, 22.80, 34.90,                   57.30])  nse = np.random.randn(len(geeks))r = np.exp(-geeks / 0.05)  s = 0.1 * np.sin(2 * np.pi * geeks) + nse  # plot angle_spectrumplt.angle_spectrum(s, Fs = Fs)  # Display the simple spectrum and # angle_spectrum plotplt.show()
Output:
Example #2:
# Implementation of matplotlib.pyplot.angle_spectrum()# function  import matplotlib.pyplot as pltimport numpy as np  np.random.seed(0)  dt = 0.01Fs = 1 / dtt = np.arange(0, 10, dt)nse = np.random.randn(len(t))r = np.exp(-t / 0.05)  cnse = np.convolve(nse, r)*dtcnse = cnse[:len(t)]s = 0.1 * np.sin(2 * np.pi * t) + cnse  # plot simple spectrumplt.subplot(2, 1, 1)plt.plot(t, s)  # plot angle_spectrumplt.subplot(2, 1, 2)plt.angle_spectrum(s, Fs = Fs)  # Display the simple spectrum and # angle_spectrum plotplt.show()
Output:
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
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()
Reading and Writing to text files in Python
*args and **kwargs in Python
Create a Pandas DataFrame from Lists
Requests - Handling Sessions

To maintain the data between requests you need sessions. So, if the same host is called again and again, you can reuse the TCP connection which in turn will improve the performance. Let us now see, how to maintain cookies across requests made using sessions.
import requests
req = requests.Session()
cookies = dict(test='test123')
getdata = req.get('https://httpbin.org/cookies',cookies=cookies)
print(getdata.text)    
E:\prequests>python makeRequest.py
{
   "cookies": {
      "test": "test123"
   }
}

Using session, you can preserve the cookies data across requests. It is also possible to pass headers data using the session as shown below −
import requests
req = requests.Session()
req.headers.update({'x-user1': 'ABC'})
headers = {'x-user2': 'XYZ'}
getdata = req.get('https://httpbin.org/headers', headers=headers)    
print(getdata.headers)
 Print
 Add Notes
 Bookmark this page