code-rag-bench/online-tutorials huggingface dataset:
How to load window width value to SCSS variable ?

02 Mar, 2021
The task is to load the window width value to an SCSS variable and use it. Let us take a brief introduction to an SCSS.
SCSS Variables can store any kind of value color, font-family, font-size, clip-path values, etc, and are mainly used to maintain the reusability of code across the stylesheets.
Approach:
Step 1: Define a function in SCSS and generate the precise viewport width values to acquire the window width @function get-vw($target) { 
  $vw-context: (1000*.01) * 1px;
  @return ($target/$vw-context) * 1vw;
}
Step 1: Define a function in SCSS and generate the precise viewport width values to acquire the window width 
@function get-vw($target) { 
  $vw-context: (1000*.01) * 1px;
  @return ($target/$vw-context) * 1vw;
}
Step 2: Pass in a value in pixels to this function and store it in an SCSS variable.$window-width: get-vw(72px);Since viewport-width is 1% of the viewport we can scale the size in px as a ratio.
Step 2: Pass in a value in pixels to this function and store it in an SCSS variable.
$window-width: get-vw(72px);
Since viewport-width is 1% of the viewport we can scale the size in px as a ratio.
Step 3: Use the variable wherever needed.
main.scss
$window-width: get-vw(72px); /* Passing in a value in pixels */  /* Defining the function to generate the window width* /@function get-vw($target) {   $vw-context: (1000*.01) * 1px;  @return ($target/$vw-context) * 1vw;}  /* Setting the default values*/*{  padding : 0;  margin : 0;  box-sizing: border-box;}  /* Using the property*/.misc{  padding: 3rem 0;  color: #fff;  width: $window-width;  text-align: center;  font-size: 1.8rem;  background-color:green;}
Output: This would result in the following CSS.
main.css
/* Passing in a value in pixels *//* Defining the function to generate the window width*//* Setting the default values*/* {  padding: 0;  margin: 0;  box-sizing: border-box;}  /* Using the property */.misc {  padding: 3rem 0;  color: #fff;  width: get-vw(72px);  text-align: center;  font-size: 1.8rem;  background-color: green;}
Note: Here, mentioning box-sizing: border-box is really important here because this would render the DOM to remove any default margin or spaces.
index.html
<!DOCTYPE html>    <html>     <body>        <div class="misc">           GeeksforGeeks        </div>     </body></html>
Output: Here, our text is taking up the whole width of its current screen.
Note: Though there are javascript methods like window.outerWidth, we cannot possibly store those values in an SCSS variable since SCSS is just a pre-processor.
Picked
SASS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Database - DAVERAGE Function

The DAVERAGE function returns the average of the values in a column of a list or database that match the conditions specified.
DAVERAGE (database, field, criteria)

The range of cells that makes up the list or database.
A database is a list of related data in which rows of related information are records, and columns of data are fields.
The first row of the list contains labels for each column.
Indicates for which column the Average is calculated.
Enter the column label enclosed between double quotation marks, such as "Age" or "Yield," or a number (without quotation marks) that represents the position of the column within the list: 1 for the first column, 2 for the second column, and so on.
The range of cells that contains the conditions you specify.
You can use any range for the criteria argument, as long as it includes at least one column label and at least one cell below the column label in which you specify a condition for the column.
You can use any range for the criteria argument, as long as it includes at least one column label and at least one cell below the column label for specifying the condition.
You can use any range for the criteria argument, as long as it includes at least one column label and at least one cell below the column label for specifying the condition.
For example, if the range G1:G2 contains the column label Income in G1 and the amount 10,000 in G2, you could define the range as MatchIncome and use that name as the criteria argument in the database functions.
For example, if the range G1:G2 contains the column label Income in G1 and the amount 10,000 in G2, you could define the range as MatchIncome and use that name as the criteria argument in the database functions.
Although the criteria range can be located anywhere on the worksheet, do not place the criteria range below the list. If you add more information to the list, the new information is added to the first row below the list. If the row below the list is not blank, Excel cannot add the new information.
Although the criteria range can be located anywhere on the worksheet, do not place the criteria range below the list. If you add more information to the list, the new information is added to the first row below the list. If the row below the list is not blank, Excel cannot add the new information.
Make sure the criteria range does not overlap the list.
Make sure the criteria range does not overlap the list.
To perform an operation on an entire column in a database, enter a blank line below the column labels in the criteria range.
To perform an operation on an entire column in a database, enter a blank line below the column labels in the criteria range.
Excel 2007, Excel 2010, Excel 2013, Excel 2016

    296 Lectures 
     146 hours 

 Arun Motoori

    56 Lectures 
     5.5 hours 

 Pavan Lalwani

    120 Lectures 
     6.5 hours 

 Inf Sid

    134 Lectures 
     8.5 hours 

 Yoda Learning

    46 Lectures 
     7.5 hours 

 William Fiset

    25 Lectures 
     1.5 hours 

 Sasha Miller
 Print
 Add Notes
 Bookmark this page
Python 3 - List reverse() Method

The reverse() method reverses objects of list in place.
Following is the syntax for reverse() method −
list.reverse()

NA
This method does not return any value but reverse the given object from the list.
The following example shows the usage of reverse() method.
#!/usr/bin/python3

list1 = ['physics', 'Biology', 'chemistry', 'maths']
list1.reverse()
print ("list now : ", list1)
When we run above program, it produces the following result −
list now :  ['maths', 'chemistry', 'Biology', 'physics']


    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
java.time.Duration.between() Method Example

The java.time.Duration.between() method obtains a Duration representing the duration between two temporal objects.
Following is the declaration for java.time.Duration.between() method.
public static Duration between(Temporal startInclusive, Temporal endExclusive)

startInclusive − the start instant, inclusive, not null.
startInclusive − the start instant, inclusive, not null.
endExclusive − the end instant, exclusive, not null.
endExclusive − the end instant, exclusive, not null.
a Duration, not null.
DateTimeException − if the seconds between the temporals cannot be obtained.
DateTimeException − if the seconds between the temporals cannot be obtained.
ArithmeticException − if the calculation exceeds the capacity of Duration.
ArithmeticException − if the calculation exceeds the capacity of Duration.
The following example shows the usage of java.time.Duration.between() method.
package com.tutorialspoint;

import java.time.Duration;
import java.time.LocalDateTime;
import java.time.LocalTime;

public class DurationDemo {
   public static void main(String[] args) {

      Duration duration = Duration.between(LocalTime.NOON,LocalTime.MAX); 

      LocalDateTime date = LocalDateTime.now();
      System.out.println(date);  

      date = (LocalDateTime)duration.addTo(date);
      System.out.println(date);  
   }
}
Let us compile and run the above program, this will produce the following result −
std::find in C++

12 May, 2022
Finds the element in the given range of numbers. Returns an iterator to the first element in the range [first,last) that compares equal to val. If no such element is found, the function returns last. Function Template :
InputIterator find (InputIterator first, InputIterator last, const T& val)
first,last :Input iterators to the initial and final positions in a sequence. The rangesearched is [first,last), which contains all the elements between first andlast, including the element pointed by first but not the element pointed by last.
val :Value to be search in the range
Return Value :An iterator to the first element in the range that compares equal to val.If no elements match, the function returns last.
Examples:
Input : 10 20 30 40
Output : Element 30 found at position : 2 (counting from zero)  

Input : 8 5 9 2 7 1 3 10
Output : Element 4 not found.    
CPP
// CPP program to illustrate// std::find// CPP program to illustrate// std::find#include<bits/stdc++.h>  int main (){    std::vector<int> vec { 10, 20, 30, 40 };      // Iterator used to store the position    // of searched element    std::vector<int>::iterator it;      // Print Original Vector    std::cout << "Original vector :";    for (int i=0; i<vec.size(); i++)        std::cout << " " << vec[i];      std::cout << "\n";      // Element to be searched    int ser = 30;      // std::find function call    it = std::find (vec.begin(), vec.end(), ser);    if (it != vec.end())    {        std::cout << "Element " << ser <<" found at position : " ;        std::cout << it - vec.begin() << " (counting from zero) \n" ;    }    else        std::cout << "Element not found.\n\n";      return 0;}
Output:
Original vector : 10 20 30 40
Element 30 found at position : 2 (counting from zero)
Time Complexity: O(n)
Auxiliary Space: O(1)
Related Articles: 
std::search
std::find_if, std::find_if_not
std::nth_element
std::find_end
This article is contributed by Sachin Bisht. If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to review-team@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.
dietrichflo68
karthikjagadeeshponarkar
cpp-strings-library
STL
C++
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Bitwise Operators in C/C++
Set in C++ Standard Template Library (STL)
vector erase() and clear() in C++
unordered_map in C++ STL
Inheritance in C++
The C++ Standard Template Library (STL)
Priority Queue in C++ Standard Template Library (STL)
C++ Classes and Objects
Sorting a vector in C++
Object Oriented Programming in C++
EXPORT_SET() function in MySQL

30 Dec, 2020
EXPORT_SET() :This function helps to return a string which will show the bits in number. The function requires 5 arguments for its functioning. The function converts first argument i.e integer to binary digits, then returns “on” if binary digit is 1 and “off” if binary digit is 0.
Syntax :
EXPORT_SET
(bits, on, off, separator, number of bits)
Parameters :This function accepts 5 arguments.
bits –The integer number for which the result will be formatted.
on –If the binary digit is 1, then it will return.
off –If the binary digit is 0, then it will return.
separator –The separator which will be placed between returned values.
number of bits –The number of bits in which the result will come
Returns :This function will return a string that will show the bits in number.
Example-1 :General working of EXPORT_SET() function.
SELECT EXPORT_SET(10, 'On', 'Off', ':', 5) 
AS Export;
Output :
Example 2 :Working of EXPORT_SET() function by changing 2nd and 3rd arguments.
Using “Y” and “N” as second and third argument respectively –SELECT EXPORT_SET(11, 'Y', 'N', ', ', 4) 
AS Export;Output :ExportY, Y, N, Y
SELECT EXPORT_SET(11, 'Y', 'N', ', ', 4) 
AS Export;
Output :
Using “1” and “0” as second and third argument respectively –SELECT EXPORT_SET(11, 1, 0, ', ', 4) 
AS Export;Output :Export1, 1, 0, 1
SELECT EXPORT_SET(11, 1, 0, ', ', 4) 
AS Export;
Output :
Example-3 :Working of EXPORT_SET() function by changing 4th argument.
Using “-” as the fourth argument –SELECT EXPORT_SET(10, 1, 0, '-', 4) 
AS Export;Output :Export0-1-0-1
SELECT EXPORT_SET(10, 1, 0, '-', 4) 
AS Export;
Output :
Using “::” as the fourth argument –SELECT EXPORT_SET(10, 1, 0, '::', 4) 
AS Export;Output :Export0::1::0::1
SELECT EXPORT_SET(10, 1, 0, '::', 4) 
AS Export;
Output :
Example-4 :Working of EXPORT_SET() function by changing 5th argument.
Using 10 as the fifth argument –SELECT EXPORT_SET(9, 'Y', 'N', ' ', 10) 
AS Export;Output :ExportY N N Y N N N N N N
SELECT EXPORT_SET(9, 'Y', 'N', ' ', 10) 
AS Export;
Output :
Using 20 as the fifth argument –SELECT EXPORT_SET(9, 1, 0, ' ', 20) 
AS Export;Output :Export1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SELECT EXPORT_SET(9, 1, 0, ' ', 20) 
AS Export;
Output :
DBMS-SQL
mysql
Technical Scripter 2020
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Update Multiple Columns in Single Update Statement in SQL?
Window functions in SQL
SQL | Sub queries in From Clause
What is Temporary Table in SQL?
SQL using Python
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
RANK() Function in SQL Server
SQL Query to Convert VARCHAR to INT
SQL Query to Compare Two Dates
SQL Query to Insert Multiple Rows
Pizza cut problem (Or Circle Division by Lines)

16 Jun, 2022
Given number of cuts, find the maximum number of possible pieces.Examples:  
Input  : 2
Output : 4

Input  : 3
Output : 7
 
This problem is nothing but The Lazy Caterer’s Problem and has below formula.Maximum number of pieces = 1 + n*(n+1)/2Refer this for proof. 
C++
Java
Python3
C#
PHP
Javascript
// C++ program to find maximum no of pieces// by given number of cuts#include<bits/stdc++.h>using namespace std; // Function for finding maximum pieces// with n cuts.int findMaximumPieces(int n){   return 1 + n*(n+1)/2;   } // Driver codeint main(){   cout << findMaximumPieces(3);   return 0;}
// Java program to find maximum no of// pieces by given number of cutsclass GFG {         // Function for finding maximum pieces    // with n cuts.    static int findMaximumPieces(int n)    {        return 1 + n * (n + 1) / 2;    }         // Driver Program to test above function    public static void main(String arg[])    {                 System.out.print(findMaximumPieces(3));    }} // This code is contributed by Anant Agarwal.
# Python3 program to find maximum# no. of pieces by given# number of cuts # Function for finding maximum# pieces with n cuts.def findMaximumPieces(n):    return int(1 + n * (n + 1) / 2) # Driver codeprint(findMaximumPieces(3)) # This code is contributed 29AjayKumar
// C# program to find maximum no of// pieces by given number of cutsusing System; class GFG {          // Function for finding maximum pieces    // with n cuts.    static int findMaximumPieces(int n)    {        return 1 + n * (n + 1) / 2;    }          // Driver Program to test above function    public static void Main()    {                  Console.Write(findMaximumPieces(3));    }}  // This code is contributed by nitin mittal.
<?php// PHP program to find maximum// no. of pieces by given// number of cuts // Function for finding maximum// pieces with n cuts.function findMaximumPieces($n){    return 1 + $n * ($n + 1) / 2;} // Driver codeecho findMaximumPieces(3); // This code is contributed by nitin mittal.?>
<script> // Javascript program to find maximum no of pieces// by given number of cuts // Function for finding maximum pieces // with n cuts.    function findMaximumPieces(n)    {        return 1 + n * (n + 1) / 2;    } // Driver Code     document.write(findMaximumPieces(3)); </script>
Output: 
7
Time Complexity: O(1)
Auxiliary Space: O(1)
This article is contributed by DANISH_RAZA. If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to review-team@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. 
nitin mittal
29AjayKumar
code_hunt
ajaymakvana
Geometric
Geometric
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PostgreSQL – Rename Table

28 Aug, 2020
PostgreSQL has a RENAME clause that is used with the ALTER TABLE statement to rename the name of an existing table.
Syntax:
ALTER TABLE table_name
RENAME TO new_table_name; 
In the above syntax:
First, specify the name of the table which you want to rename after the ALTER TABLE clause.
Second, give the new table name after the RENAME TO clause.
Attempting to rename a table that doesn’t exist leads to PostgreSQL raising an error. To rename multiple tables, one has to execute multiple ALTER TABLE RENAME TO statements. It’s not possible to do it in a single statement.For the purpose of example let’s first create a table using the below statements and then we will attempt to rename it:
CREATE TABLE vendors (
    id serial PRIMARY KEY,
    name VARCHAR NOT NULL
);
Now check if the table has been successfully created using the below statement:
SELECT * FROM vendors;
Now that our table is ready, let’s jump into an example.
Example:In this we will rename the vendors table to suppliers, using the following ALTER TABLE RENAME TO statement:
ALTER TABLE vendors RENAME TO suppliers;
Now we can verify if the name has been changed using the below statement:
SELECT * FROM suppliers;
Output:
postgreSQL-managing-table
PostgreSQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
SoapUI Assertion - XQuery Match

XQuery uses an XQuery expression to select content from the target property. It compares the result of an XQuery expression to an expected value.
Step 1 − After clicking Add Assertion, select Assertion Category – Property Content.
Step 2 − Select Assertion Type – XQuery Match.
Step 3 − Click Add.
Step 4 − Similar to XPath, click ‘Declare’ to declare the namespace automatically or enter it manually.
Following XQuery structure needs to be defined −
for $x in //ns1:<XPath>  
//It declares iteration and XPath is where similar nodes are present 
return {data ($x/ns1:<attribute>)} //it will return all values of the attribute 

Step 5 − Click Save.
Step 6 − Select from current tab will display all the values present currently in response.
Note − Since this WSDL is not enough to use XQuery assertion, kindly use a WSDL having more and same attributes in response XML.
Align an element with the bottom of the parent element's font in Bootstrap 4

Use align-text-bottom class to align an element with the bottom of the parent element's font.
You need to set the align-text-bottom class as shown below −
<span class="align-text-bottom">
  Bottom Text
</span>
You can try to run the following code to implement the align-text-bottom class in Bootstrap 4 −
Live Demo
<!DOCTYPE html>
<html>
<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>Example</h2>
  <p>This is demo text<p>
  <span class="align-baseline">Demo Baseline</span>
  <span class="align-top">Top Alignment</span>
  <span class="align-text-top">Top Text</span>
  <span class="align-text-bottom">Bottom Text</span>
</div>

</body>
</html>
Tk - Events

Events in its simplest form is handled with the help of commands. A simple example for event handling is event handling with button and is shown below −
#!/usr/bin/wish

proc myEvent { } {
   puts "Event triggered"
}
pack [button .myButton1  -text "Button 1"   -command myEvent]
When we run the above program, we will get the following output −
A simple program to show delay text animation event is shown below −
#!/usr/bin/wish

proc delay {} {
   for {set j 0} {$j < 100000} {incr j} {} 
}

label .myLabel -text "Hello................" -width 25
pack .myLabel
set str "Hello................"
for {set i [string length $str]} {$i > -2} {set i [expr $i-1]} {
   .myLabel configure -text [string range $str 0 $i]
   update
   delay
}
When we run the program, we will get the following output in animated way −
The syntax for event after delay is shown below −
after milliseconds number command

A simple program to show after delay event is shown below −
#!/usr/bin/wish

proc addText {} {
   label .myLabel -text "Hello................" -width 25
   pack .myLabel
}
after 1000 addText
When we run the program, we will get the following output after one second −
You can cancel an event using the after cancel command as shown below −
#!/usr/bin/wish

proc addText {} {
   label .myLabel -text "Hello................" -width 25
   pack .myLabel
}
after 1000 addText
after cancel addText
The syntax for event binding is as shown below −
bind arguments 

#!/usr/bin/wish

bind .  {puts "Key Pressed: %K "}
When we run the program and press a letter X, we will get the following output −
Key Pressed: X 

#!/usr/bin/wish

bind .  {puts "Button %b Pressed : %x %y "}
When we run the program and press the left mouse button, we will get an output similar to the following −
Button 1 Pressed : 89 90 

#!/usr/bin/wish

proc myEvent { } {
   puts "Event triggered"
}
pack [button .myButton1  -text "Button 1"   -command myEvent]
bind .  ".myButton1 invoke"
When we run the program and press enter, we will get the following output −
Event triggered

 Print
 Add Notes
 Bookmark this page
C# - Passing Parameters by Output

A return statement can be used for returning only one value from a function. However, using output parameters, you can return two values from a function. Output parameters are similar to reference parameters, except that they transfer data out of the method rather than into it.
The following example illustrates this −
using System;

namespace CalculatorApplication {
   class NumberManipulator {
      public void getValue(out int x ) {
         int temp = 5;
         x = temp;
      }
      static void Main(string[] args) {
         NumberManipulator n = new NumberManipulator();
         
         /* local variable definition */
         int a = 100;
         
         Console.WriteLine("Before method call, value of a : {0}", a);
         
         /* calling a function to get the value */
         n.getValue(out a);

         Console.WriteLine("After method call, value of a : {0}", a);
         Console.ReadLine();
      }
   }
}
When the above code is compiled and executed, it produces the following result −
Before method call, value of a : 100
After method call, value of a : 5

The variable supplied for the output parameter need not be assigned a value. Output parameters are particularly useful when you need to return values from a method through the parameters without assigning an initial value to the parameter. Go through the following example, to understand this −
using System;

namespace CalculatorApplication {
   class NumberManipulator {
      public void getValues(out int x, out int y ) {
          Console.WriteLine("Enter the first value: ");
          x = Convert.ToInt32(Console.ReadLine());
          
          Console.WriteLine("Enter the second value: ");
          y = Convert.ToInt32(Console.ReadLine());
      }
      static void Main(string[] args) {
         NumberManipulator n = new NumberManipulator();
         
         /* local variable definition */
         int a , b;
         
         /* calling a function to get the values */
         n.getValues(out a, out b);
         
         Console.WriteLine("After method call, value of a : {0}", a);
         Console.WriteLine("After method call, value of b : {0}", b);
         Console.ReadLine();
      }
   }
}
When the above code is compiled and executed, it produces the following result −
Enter the first value:
7
Enter the second value:
8
After method call, value of a : 7
After method call, value of b : 8


    119 Lectures 
     23.5 hours 

 Raja Biswas

    37 Lectures 
     13 hours 

 Trevoir Williams

    16 Lectures 
     1 hours 

 Peter Jepson

    159 Lectures 
     21.5 hours 

 Ebenezer Ogbu

    193 Lectures 
     17 hours 

 Arnold Higuit

    24 Lectures 
     2.5 hours 

 Eric Frick
 Print
 Add Notes
 Bookmark this page
CSS Class Selector - GeeksforGeeks

11 Oct, 2021
The .class selector is used to select all elements which belong to a particular class attribute. In order to select the elements with a particular class, use the period (.) character specifying the class name ie., it will match the HTML element based on the contents of their class attribute. The class name is mostly used to set the CSS property to a given class.
Syntax: 
.class {
    // CSS property
} 
Example 1: This example demonstrates the class Selector for the specific HTML element.
HTML
<!DOCTYPE html><html><head>    <style>    .geeks {        color: green;    }          .gfg {        background-color: yellow;        font-style: italic;        color: green;    }    </style></head>  <body style="text-align:center">    <h1 class="geeks">            GeeksforGeeks    </h1>    <h2>.class Selector</h2>    <div class="gfg">        <p>GeeksforGeeks: A computer science portal</p>    </div></body></html>
Output:
Example 2: This example describes the space-separated class name.
HTML
<!DOCTYPE html><html><head>    <title>class selector</title>    <style>        .geeks {        color: green;    }          .gfg {        background-color: yellow;    </style></head>  <body style="text-align:center">    <h1 class="geeks">            GeeksforGeeks    </h1>    <h2 class="gfg">.class Selector</h2>    <p class="geeks gfg">       GeeksforGeeks: A computer science portal       </p>  </body></html>
Output:
Supported Browsers: The browser supported by the .class selector are listed below: 
Google Chrome 1.0
Firefox 1.0
Microsoft Edge 12.0
Opera 3.5
Internet Explorer 3.0
Safari 1.0
bhaskargeeksforgeeks
CSS-Selectors
Picked
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to update Node.js and NPM to next version ?
How to create footer to stay at the bottom of a Web page?
CSS to put icon inside an input element in a form
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
JavaScript | array.toLocaleString() function - GeeksforGeeks

18 Nov, 2021
The array.toLocaleString() is an inbuilt function in JavaScript which is basically used to convert the element of the given array to string. Syntax:  
arr.toLocaleString();
Return values: It return a string representing the elements of the array. JavaScript Version: ECMAScript 1 Examples:  
Input: 
var name = "gfg";
var number = 123;
var A = [ name, number ];
Output:
> "gfg, 123"
Here as we see that in input there are two variables containing elements but in output these are converted into a string. Let’s see JavaScript program on array.toLocaleString() function: 
JavaScript
// taking inputs.var name = "geeksforgeeks";var number = 567; // It will give current date and time.var date = new Date(); // Here A is an array containing elements of above variables.var A = [ name, number, date ]; // applying array.toLocaleString function.var string = A.toLocaleString(); // printing string.console.log(string);
Output:  
> "geeksforgeeks, 567, 2/18/2018, 10:41:20 AM"
Application: The array.toLocaleString() function in JavaScript is used whenever we need to convert the element of the given array to a string. Let’s see JavaScript program on array.toLocaleString() function: 
JavaScript
// taking inputs.var name = [ "Ram", "Sheeta", "Geeta" ];var number1 = 3.45;var number2 = [ 23, 34, 54 ]; // Here A is an array containing elements of above variables.var A = [ name, number1, number2 ]; // applying array.toLocaleString function.var string = A.toLocaleString(); // printing string.console.log(string);
Output:  
> "Ram, Sheeta, Geeta, 3.45, 23, 34, 54"
 Supported Browser:
Google Chrome 1 and above
Internet Explorer 5.5 and above
Firefox 1 and above
Opera 4  and above
Safari 1 and above
rajeev0719singh
ysachin2314
javascript-array
JavaScript
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Difference between var, let and const keywords in JavaScript
Difference Between PUT and PATCH Request
Angular File Upload
How to get selected value in dropdown list using JavaScript ?
How to remove duplicate elements from JavaScript Array ?
How to filter object array based on attributes?
Remove elements from a JavaScript Array
Introduction to Object Oriented Programming in JavaScript
JavaScript | Promises
How to convert JSON data to a html table using JavaScript/jQuery ?
arp command in Linux with examples - GeeksforGeeks

22 Oct, 2021
arp command manipulates the System’s ARP cache. It also allows a complete dump of the ARP cache. ARP stands for Address Resolution Protocol. The primary function of this protocol is to resolve the IP address of a system to its mac address, and hence it works between level 2(Data link layer) and level 3(Network layer). 
Syntax:  
arp [-v] [-i if] [-H type] -a [hostname]
Example: Here we created two machines with name machine1 and machine2 with IP address 10.0.2.4 and 10.0.2.5 
Screenshot of hosts before adding 
Addition of host 
Hosts file after adding machines 
Now checking arp for all 
Options: 
-v, –verbose: This option shows the verbose information.
-n, –numeric: This option shows numerical addresses instead of symbolic host, port or usernames. 
-H type, –hw-type type, -t type: This tells arp which class of entries it should check for. Default value is ether. List of possible hardware types(which support ARP) are ash(Ash), ether(Ethernet), ax25(AMPR AX.25), netrom (AMPR NET/ROM), rose (AMPR ROSE), arcnet (ARCnet), dlci (Frame Relay DLCI), fddi (Fiber Distributed Data Interface), hippi (HIPPI), irda (IrLAP), x25 (generic X.25), eui64 (Generic EUI-64). 
-a [hostname] –all: This option is used for showing entries of the specified host. If nothing is passed all entries will be displayed. 
-d hostname, –delete hostname: Removes any entry for the specified host. If any host is down, there is no need of keeping its entry in arp cache so this command is used to delete those entries explicitly by the user. 
-D, –use-device: Use the given interface’s hardware address. 
-e: Shows the entries in default(Linux) Style.
-i If, –device If: Select an interface. When dumping the ARP cache, only entries matching the specified interface will be printed. Note: This has to be different from the interface to which the IP datagrams will be routed.
Note: This has to be different from the interface to which the IP datagrams will be routed.
-s hostename hw_address: Manually create an ARP address mapping entry for the host hostname with its mac address as hw_address. 
-f filename: Works same as -s but instead of giving the entries manually, it takes entry from the file given as parameter. 
Some useful flags are:  
-C: Complete entry.
-M: Permanent entry.
-P: Published entry.
Some useful file related to these data are: 
/proc/net/arp
/etc/networks
/etc/hosts/
/etc/ethers
simmytarika5
linux-command
Linux-networking-commands
Picked
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ZIP command in Linux with examples
TCP Server-Client implementation in C
SORT command in Linux/Unix with examples
tar command in Linux with examples
curl command in Linux with Examples
Conditional Statements | Shell Script
Tail command in Linux with examples
diff command in Linux with examples
UDP Server-Client implementation in C
echo command in Linux with Examples
Using Set() in Python Pangram Checking

23 Nov, 2020
Given a string check if it is Pangram or not. A pangram is a sentence containing every letter in the English Alphabet. Lowercase and Uppercase are considered the same.
Examples:
Input : str = 'The quick brown fox jumps over 
               the lazy dog'
Output : Yes
// Contains all the characters from ‘a’ to ‘z’

Input : str='The quick brown fox jumps over the dog'
Output : No
// Doesn’t contains all the characters from ‘a’
// to ‘z’, as ‘l’, ‘z’, ‘y’ are missing

This problem has existing solution please refer Pangram Checking link. We will solve this in Python using Set() data structure and List() comprehension. Approach is very simple,
Convert complete sentence in lower case using lower() method of string data type in python.Now pass this sentence into Set(str) so that we could have list of all unique characters present in given string.Now separate out list of all alphabets (a-z), if length of list is 26 that means all characters are present and sentence is Pangram otherwise not.
Convert complete sentence in lower case using lower() method of string data type in python.
Now pass this sentence into Set(str) so that we could have list of all unique characters present in given string.
Now separate out list of all alphabets (a-z), if length of list is 26 that means all characters are present and sentence is Pangram otherwise not.
# function to check pangram  def pangram(input):          # convert input string into lower case    input = input.lower()          # convert input string into Set() so that we will    # list of all unique characters present in sentence    input = set(input)      # separate out all alphabets    # ord(ch) returns ascii value of character    alpha = [ ch for ch in input if ord(ch) in range(ord('a'), ord('z')+1)]      if len(alpha) == 26:        return 'true'    else:        return 'false'  # Driver programif __name__ == "__main__":    input = 'The quick brown fox jumps over the lazy dog'    print (pangram(input))
Output:
true

sjoshi
Akanksha_Rai
nidhi_biet
python-set
Python
Strings
python-set
Strings
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Iterate over a list in Python
Rotate axis tick labels in Seaborn and Matplotlib
Enumerate() in Python
Deque in Python
Stack in Python
Reverse a string in Java
Write a program to reverse an array or string
C++ Data Types
KMP Algorithm for Pattern Searching
Write a program to print all permutations of a given string
Filtering rows based on column values in PySpark dataframe

29 Jun, 2021
In this article, we are going to filter the rows based on column values in PySpark dataframe.
Python3
# importing moduleimport spark  # importing sparksession from pyspark.sql modulefrom pyspark.sql import SparkSession  # creating sparksession and giving an app namespark = SparkSession.builder.appName('sparkdf').getOrCreate()  # list  of employee datadata = [["1", "sravan", "company 1"],        ["2", "ojaswi", "company 1"],        ["3", "rohith", "company 2"],        ["4", "sridevi", "company 1"],        ["1", "sravan", "company 1"],        ["4", "sridevi", "company 1"]]  # specify column namescolumns = ['ID', 'NAME', 'Company']  # creating a dataframe from the lists of datadataframe = spark.createDataFrame(data, columns)  dataframe.show()
Output:
Method 1: Using where() function
This function is used to check the condition and give the results
Syntax: dataframe.where(condition)
We are going to filter the rows by using column values through the condition, where the condition is the dataframe condition
Example 1: filter rows in dataframe where ID =1
Python3
# get the data where ID=1dataframe.where(dataframe.ID=='1').show()
Output:
Example 2:
Python3
# get the data where name not 'sravan'dataframe.where(dataframe.NAME != 'sravan').show()
Output:
Example 3: Where clause multiple column values filtering.
Python program to filter rows where ID greater than 2 and college is vvit
Python3
# filter rows where ID greater than 2# and college is vvitdataframe.where((dataframe.ID>'2') & (dataframe.college=='vvit')).show()
Output:
Method 2: Using filter() function
This function is used to check the condition and give the results.
Syntax: dataframe.filter(condition)
Example 1: Python code to get column value = vvit college
Python3
# get the data where college is  'vvit'dataframe.filter(dataframe.college=='vvit').show()
Output:
Example 2: filter the data where id > 3.
Python3
# get the data where id > 3dataframe.filter(dataframe.ID>'3').show()
Output:
Example 3: Multiple column value filtering.
Python program to filter rows where ID greater than 2 and college is vignan
Python3
# filter rows where ID greater# than 2 and college is vignandataframe.filter((dataframe.ID>'2') &                 (dataframe.college=='vignan')).show()
Output:
Picked
Python-Pyspark
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
JavaScript to keep only first N characters in a string

31 May, 2019
Given a string and the task is to keep only first n characters of the string. There are various methods to solve this problem in JavaScript, some of them are discussed below:
Method 1: Using substring() Method: The string.substring() method is an inbuilt function in JavaScript which is used to return the part of the given string from start index to end index. Indexing starts from zero (0).
Syntax:
string.substring(Startindex, Endindex)
Below program demonstrates the above approach.
Example:
<script>    // JavaScript to keep only first    // 'n' characters of String          // Original string    var str = "GeeksforGeeks";          // Keep first 5 letters    var n = 5;          document.write("Original String = \""                    + str + "\"<br>");    document.write("n = " + n + "<br>");          // Using substring() method    str = str.substring(0, n);          document.write("Keep first " + n +         " characters of original String = \""        + str + "\"<br>");</script>                                     
Output:
Original String = "GeeksforGeeks"
n = 5
Keep first 5 characters of original String = "Geeks"

Method 2: Using slice() Method: The string.slice() is an inbuilt function in javascript which is used to return a part or slice of the given input string.
Syntax:
string.slice(startingindex, endingindex)
Below program demonstrates the above approach.
Example:
<script>    // JavaScript script to keep only    // first 'n' characters of String          // Original string    var str = "Data Structure";          // Keep first 11 letters    var n = 11;          document.write("Original String = \""                    + str + "\"<br>");    document.write("n = " + n + "<br>");          // Using slice() method    str = str.slice(0, n);          document.write("Keep first " + n +         " characters of original String = \""        + str + "\"<br>");</script>                    
Output:
Original String = "Data Structure"
n = 11
Keep first 11 characters of original String = "Data Struct"

javascript-string
Picked
JavaScript
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python program to Replace all Characters of a List Except the given character

05 Sep, 2020
Given a List. The task is to replace all the characters of the list with N except the given character.
Input : test_list = [‘G’, ‘F’, ‘G’, ‘I’, ‘S’, ‘B’, ‘E’, ‘S’, ‘T’], repl_chr = ‘*’, ret_chr = ‘G’ Output : [‘G’, ‘*’, ‘G’, ‘*’, ‘*’, ‘*’, ‘*’, ‘*’, ‘*’] Explanation : All characters except G replaced by *
Input : test_list = [‘G’, ‘F’, ‘G’, ‘B’, ‘E’, ‘S’, ‘T’], repl_chr = ‘*’, ret_chr = ‘G’ Output : [‘G’, ‘*’, ‘G’, ‘*’, ‘*’, ‘*’, ‘*’] Explanation : All characters except G replaced by * 
Method #1 : Using list comprehension + conditional expressions
In this, we perform the task of iteration using list comprehension, and replacements are taken care of using conditional operators.
Python3
# Python3 code to demonstrate working of# Replace all Characters Except K# Using list comprehension and conditional expressions  # initializing liststest_list = ['G', 'F', 'G', 'I', 'S', 'B', 'E', 'S', 'T']  # printing original listprint("The original list : " + str(test_list))  # initializing repl_chrrepl_chr = '$'  # initializing retain chararterret_chr = 'G'  # list comprehension to remake list after replacementres = [ele if ele == ret_chr else repl_chr for ele in test_list]  # printing resultprint("List after replacement : " + str(res))
The original list : ['G', 'F', 'G', 'I', 'S', 'B', 'E', 'S', 'T']
List after replacement : ['G', '$', 'G', '$', '$', '$', '$', '$', '$']

Method #2 : Using map() + lambda
In this, we use map() and lambda function to extend the logic to each element of the list.
Python3
# Python3 code to demonstrate working of# Replace all Characters Except K# Using map() + lambda  # initializing liststest_list = ['G', 'F', 'G', 'I', 'S', 'B', 'E', 'S', 'T']  # printing original listprint("The original list : " + str(test_list))  # initializing repl_chrrepl_chr = '$'  # initializing retain chararterret_chr = 'G'  # using map() to extend logic to each element of listres = list(map(lambda ele: ret_chr if ele == ret_chr else repl_chr, test_list))  # printing resultprint("List after replacement : " + str(res))
The original list : ['G', 'F', 'G', 'I', 'S', 'B', 'E', 'S', 'T']
List after replacement : ['G', '$', 'G', '$', '$', '$', '$', '$', '$']

Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | frexp() Function

21 Sep, 2018
frexp() function is one of the Standard math Library function in Python.
It returns mantissa and exponent as a pair (m, e) of a given value x, where mantissa m is a floating point number and e exponent is an integer value. m is a float and e is an integer such that x == m * 2**e exactly.
If x is zero, returns (0.0, 0), otherwise 0.5 <= abs(m) < 1. This is used to “pick apart” the internal representation of a float in a portable way.
Syntax: math.frexp( x )
Parameters: Any valid number (positive or negative).
Returns: Returns mantissa and exponent as a pair (m, e) value of a given number x.
Exception: If x is not a number, function will return TypeError.
Code #1:
# Python3 code demonstrate frexp() function  # importing math libraryimport math    # calculating mantissa and# exponent of given integerprint(math.frexp(3))print(math.frexp(15.7))print(math.frexp(-15))
Output:
(0.75, 2)
(0.98125, 4)
(-0.9375, 4)

 
Code #2:
# Python3 code demonstrate frexp() function  # importing math libraryimport math  # creating a listlst = [15, 13.76, 17.5, 21]  # creating a tupletpl = (-15.85, -41.24, -11.2, 54)  # calculating mantissa and exponent# of 1st, 3rd elements in list print(math.frexp(lst[0]))print(math.frexp(lst[2]))  # calculating mantissa and exponent# of 2nd, 3rd and 4th elements in tuple print(math.frexp(tpl[1]))print(math.frexp(tpl[2]))print(math.frexp(tpl[3]))
Output:
(0.9375, 4)
(0.546875, 5)
(-0.644375, 6)
(-0.7, 4)
(0.84375, 6)
 Code #3: If the x parameter is not a number, frexp() function will return a TypeError.
# Python3 code demonstrates when error occursimport math  print(math.frexp('25')) 
Output:
TypeError: a float is required
Python math-library
Python math-library-functions
Python-Built-in-functions
Python-Library
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
C# program to convert decimal to Octal number

Set the decimal number −
int decVal = 40;
Now take a variable and set the decVal in it. Find the remainder with 8 since octal has base-8 number system and evaluate it in a loop like the following code snippet.
while (quot != 0) {
   octalVal[i++] = quot % 8;
   quot = quot / 8;
}
You can try to run the following code to convert decimal to octal number.
Live Demo
using System;
class Demo {
   public static void Main() {
      int decVal, quot, i = 1, j;
      int[] octalVal = new int[80];
      decVal = 40;
      quot = decVal;
      Console.WriteLine("Decimal Number:{0}",decVal);
      while (quot!= 0) {
         octalVal[i++] = quot % 8;
         quot = quot / 8;
      }
      Console.Write("Octal Number: ");
      for (j = i - 1; j > 0; j--)
         Console.Write(octalVal[j]);
         Console.Read();
   }
}
Decimal Number:40
Octal Number: 50
Difference between out and ref keyword in C#

out keyword is used to pass arguments to method as a reference type and is primary used when a method has to return multiple values. ref keyword is also used to pass arguments to method as reference type and is used when existing variable is to be modified in a method. Following is the valid usage of ref and out keywords in C#.
 Live Demo
using System.IO;
using System;
public class Program {
   public static void update(out int a){
      a = 10;
   }
   public static void change(ref int d){
      d = 11;
   }
   public static void Main() {
      int b;
      int c = 9;
      Program p1 = new Program();
      update(out b);
      change(ref c);
      Console.WriteLine("Updated value is: {0}", b);
      Console.WriteLine("Changed value is: {0}", c);
   }
}
Updated value is: 10
Changed value is: 11
Following are some of the important differences between ref and out keywords.
Java Examples - Remove Pages from PDF

How to remove pages from a PDF document using Java.
Following is an example program to remove pages from a PDF document using Java.
import java.io.File; 
import java.io.IOException; 
import org.apache.pdfbox.pdmodel.PDDocument;  

public class RemovingPagesFromPdf { 
   public static void main(String args[]) throws IOException {  
      
      //Loading an existing document 
      File file = new File("C:/pdfBox/RemovePages_IP.pdf"); 
      PDDocument doc = PDDocument.load(file); 
       
      //Listing the number of existing pages       
      System.out.print(doc.getNumberOfPages()); 
       
      for(int i = 0; i<5; i++){
         
         //removing the pages 
         doc.removePage(i); 
      } 
      System.out.println("page removed");       
      
      //Saving the document 
      doc.save("C:/pdfBox/RemovePages_OP.pdf");     
      
      //Closing the document  
      doc.close(); 
   }  
} 
 Print
 Add Notes
 Bookmark this page