code-rag-bench/online-tutorials huggingface dataset:
Kali Linux – Crunch Utility

04 Aug, 2021
In order to hack a password, we have to try a lot of passwords to get the right one. When an attacker uses thousands or millions of words or character combinations to crack a password there is no surety that any one of those millions of combinations will work or not. This collection of a different combination of characters is called a wordlist. And in order to crack a password or a hash, we need to have a good wordlist which could break the password. So to do so we have a tool in kali Linux called crunch 
crunch is a wordlist generating tool that comes pre-installed with Kali Linux. It is used to generate custom keywords based on wordlists. It generates a wordlist with permutation and combination. We could use some specific patterns and symbols to generate a wordlist. 
To install crunch tool use the following commands as per your Linux distribution. 
In case of Debian/Ubuntu  
$sudo apt-get install crunch
In case of CentOS/RedHat  
$sudo yum install crunch
In case of Fedora OS  
$sudo dnf install crunch
1. To check the installation. 
crunch
This command will display the initial page of crunch tool which verifies the tool installation. 
2. To create a word list of specific numbers.  
cruch 1 2 0123456789 
This command will generate a wordlist of 110 words having the one and 2 digit numbers with all combinations of digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. you could use alphabets 
3. To save the wordlist into a file  
crunch 1 2 0123456789 >wordlist.txt 
This command will generate a wordlist of 110 words having the one and 2 digit numbers with all combinations of digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 and will copy the same to a text file named as wordlist.txt. 
4. To save the wordlist to a file with -o option  
crunch  1 2 0123456789 -o wordlist.txt
This command will generate a wordlist of 110 words having the one and 2 digit numbers with all combinations of digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 and will copy the same to a text file named as wordlist.txt. 
5. To generate a file using rainbow charset file  
crunch 2 3 -f /usr/share/rainbowcrack/charset.txt 
This command will use the charset present in the /usr/share/rainbowcrack/charset.txt file in order to generate a wordlist. 
6. To generate a wordlist with a specific pattern.  
crunch 10 10 -t manav^%%%% 
Here we have 4 characters to represent some group of characters which are as follows:  
, for all uppercase letters
@ for all lowercase letters
% for all numeric characters
^ for all special characters
So the above command will output all the words starting with “manav” and then after that a special character and then 4 digit number. 
7. To generate a wordlist with a permutation of some strings or characters  
crunch 1 10 -p Hello Manav
In the case of -p, the minimum size and the maximum size values are ignored by the crunch and it displays all the possible permutations.  
The above command will give 2 permutations of “hello manav”. 
anikakapoor
Kali-Linux
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Lodash _.sortBy() Method

10 Sep, 2020
Lodash is a JavaScript library that works on the top of underscore.js. Lodash helps in working with arrays, collection, strings, objects, numbers etc.
The _.sortBy() method creates an array of elements which is sorted in ascending order by the results of running each element in a collection through each iteratee. And also this method performs a stable sort which means it preserves the original sort order of equal elements.
Syntax:
_.sortBy(collection, iteratees)
Parameters: This method accepts two parameters as mentioned above and described below:
collection: This parameter holds the collection to iterate over.
iteratees: This parameter holds the iteratees to sort by and are invoked with one argument(value).
Return Value: This method is used to return the new sorted array.
Example 1: Here, const _ = require(‘lodash’) is used to import the lodash library in the file.
javascript
// Requiring the lodash library const _ = require("lodash");        // Original array var object = [  { 'obj': 'moto', 'price': 19999 },  { 'obj': 'oppo', 'price': 18999 },  { 'obj': 'moto', 'price': 17999 },  { 'obj': 'oppo', 'price': 15999 } ];   // Use of _.sortBy() methodlet gfg = _.sortBy(object,     [function(o) { return o.obj; }]);  // Printing the output console.log(gfg);
Output:
[
  { 'obj': 'moto', 'price': 19999 },
  { 'obj': 'moto', 'price': 17999 },
  { 'obj': 'oppo', 'price': 18999 },
  { 'obj': 'oppo', 'price': 15999 }
]

Example 2:
javascript
// Requiring the lodash library const _ = require("lodash");        // Original array var object = [  { 'obj': 'moto', 'price': 19999 },  { 'obj': 'oppo', 'price': 18999 },  { 'obj': 'moto', 'price': 17999 },  { 'obj': 'oppo', 'price': 15999 } ];   // Use of _.sortBy() methodlet gfg = _.sortBy(object, ['obj', 'price']);  // Printing the output console.log(gfg);
Output:
[
  { 'obj': 'moto', 'price': 17999 },
  { 'obj': 'moto', 'price': 19999 },
  { 'obj': 'oppo', 'price': 15999 },
  { 'obj': 'oppo', 'price': 18999 } 
]

Note: This code will not work in normal JavaScript because it requires the library lodash to be installed.
JavaScript-Lodash
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Roadmap to Learn JavaScript For Beginners
Difference Between PUT and PATCH Request
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
GATE | GATE-CS-2014-(Set-3) | Question 65

28 Jun, 2021
Consider the following rooted tree with the vertex P labeled as root
The order in which the nodes are visited during in-order traversal is(A) SQPTRWUV(B) SQPTURWV(C) SQPTWUVR(D) SQPTRUWVAnswer: (A)Explanation:
Algorithm Inorder(tree) - Use of Recursion
Steps:
1. Traverse the left subtree, 
   i.e., call Inorder(left-subtree)
2. Visit the root.
3. Traverse the right subtree, 
   i.e., call Inorder(right-subtree)

Understanding this algorithm requires the basic 
understanding of Recursion

Therefore, We begin in the above tree with root as
the starting point, which is P.

# Step 1( for node P) :
Traverse the left subtree of node or root P.
So we have node Q on left of P.

-> Step 1( for node Q)
Traverse the left subtree of node Q.
So we have node S on left of Q.

* Step 1 (for node S)
Now again traverse the left subtree of node S which is 
NULL here.

* Step 2(for node S)
Visit the node S, i.e print node S as the 1st element of 
inorder traversal.

* Step 3(for node S)
Traverse the right subtree of node S.
Which is NULL here.

Now move up in the tree to Q which is parent
of S.( Recursion, function of Q called for function of S).
Hence we go back to Q.

-> Step 2( for node Q):
Visit the node Q, i.e print node Q as the 2nd
element of inorder traversal.

-> Step 3 (for node Q)
Traverse the right subtree of node Q.
Which is NULL here.

Now move up in the tree to P which is parent
of Q.( Recursion, function of P called for function of Q).
Hence we go back to P.

# Step 2(for node P)
Visit the node P, i.e print node S as the 3rd
element of inorder traversal.

# Step 3 (for node P)
Traverse the right subtree of node P.
Node R is at the right of P.

Till now we have printed SQP as the inorder of the tree. 
Similarly other elements can be obtained by traversing 
the right subtree of P.

The final correct order of Inorder traversal would 
be SQPTRWUV. 
Quiz of this Question
GATE-CS-2014-(Set-3)
GATE-GATE-CS-2014-(Set-3)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE-CS-2014-(Set-2) | Question 65
GATE | Sudo GATE 2020 Mock I (27 December 2019) | Question 33
GATE | GATE-CS-2014-(Set-3) | Question 20
GATE | GATE CS 2008 | Question 40
GATE | GATE CS 2008 | Question 46
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE CS 2011 | Question 49
GATE | GATE CS 1996 | Question 38
GATE | GATE-CS-2004 | Question 31
PHP | imagecreatefromjpeg() Function

30 Jan, 2020
The imagecreatefromjpeg() function is an inbuilt function in PHP which is used to create a new image from JPEG file or URL. This image can be further worked upon in the program.
Syntax:
resource imagecreatefromjpeg( string $filename )
Parameters: This function accepts a single parameter, $filename which holds the name of imageReturn Value: This function returns an image resource identifier on success, FALSE on errors.
Below examples illustrate the imagecreatefromjpeg() function in PHP:
Example 1:
<?php    // Load an image from jpeg URL$im = imagecreatefromjpeg('https://media.geeksforgeeks.org/wp-content/uploads/20200123100652/geeksforgeeks12.jpg');  // View the loaded image in browserheader('Content-type: image/jpg');  imagejpeg($im);imagedestroy($im);?>
Output:
Example 2:
<?php    // Load an image from jpeg URL$im = imagecreatefromjpeg('https://media.geeksforgeeks.org/wp-content/uploads/20200123100652/geeksforgeeks12.jpg');  // Flip the imageimageflip($im, 1);  // View the loaded image in browserheader('Content-type: image/jpg');  imagejpeg($im);imagedestroy($im);?>
Output:Reference: https://www.php.net/manual/en/function.imagecreatefromjpeg.php
PHP-function
PHP-Imagick
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to fetch data from localserver database and display on HTML table using PHP ?
Difference between HTTP GET and POST Methods
Different ways for passing data to view in Laravel
PHP | file_exists( ) Function
How to create admin login page using PHP?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
C# | How to change the visibility of the Cursor of Console

28 Jan, 2019
Given the normal Console in C#, the task is to change the visibility of the Cursor of the Console.
Approach: This can be done using the CursorVisible property in the Console class of the System package in C#. It gets or sets a value indicating whether the cursor is visible.
Program 1: Getting the value of CursorVisible
// C# program to illustrate the// Console.CursorVisible Propertyusing System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;  namespace GFG {  class Program {      static void Main(string[] args)    {          // Get the default CursorVisible        Console.WriteLine("Current Cursor Visible: {0}",                                 Console.CursorVisible);    }}}
Output:
Program 2: Setting the value of CursorVisible
// C# program to illustrate the// Console.CursorVisible Propertyusing System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;  namespace GFG {  class Program {      static void Main(string[] args)    {          // Get the CursorVisible        Console.WriteLine("Current Cursor Visible: {0}",                                 Console.CursorVisible);          // Set the CursorVisible        Console.CursorVisible = false;          // Get the CursorVisible        Console.Write("Current Cursor Visible: {0}",                             Console.CursorVisible);    }}}
Output:
CSharp-Console-Class
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Introduction to .NET Framework
C# | Delegates
C# | Multiple inheritance using interfaces
Differences Between .NET Core and .NET Framework
C# | Method Overriding
C# | Data Types
C# | Constructors
C# | String.IndexOf( ) Method | Set - 1
C# | Class and Object
Extension Method in C#
How to Enable Copy and Paste in Oracle VirtualBox?

19 Feb, 2020
In this article, we will see how to enable copy and paste from a Windows host to a VirtualBox and vice-versa. We’ve taken the VirtualBox guest additions which gives us various additional tooling, specifically giving us the ability to copy and paste. It also enables bi-directional copy and pastes.
Step 1: Start the Virtual Box and go to Settings as shown in the below screenshot
Step 2: Now click on Advanced as marked below
Step 3: Now, click
Share Clipboard --< Bidirectional 
Drag & Drop --< bidirectional.

Technical Scripter 2019
Technical Scripter
TechTips
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Scala List distinct() method with example

26 Jul, 2019
The distinct() method is utilized to delete the duplicate elements from the stated list.
Method Definition: def distinct: List[A]
Return Type: It returns a new list of elements without any duplicates.
Example #1:
// Scala program of distinct()// method  // Creating objectobject GfG{       // Main method    def main(args:Array[String])    {              // Creating a list        val m1 = List(1, 1, 3, 3, 5, 2)                  // Applying distinct method        val res = m1.distinct                  // Displays output        println(res)          }}
List(1, 3, 5, 2)

Example #2:
// Scala program of distinct()// method  // Creating objectobject GfG{       // Main method    def main(args:Array[String])    {              // Creating a list        val m1 = List(1, 1, 3, 3, 3, 5, 4, 5, 2)                  // Applying distinct method        val res = m1.distinct                  // Displays output        println(res)          }}
List(1, 3, 5, 4, 2)

Scala
Scala-list
Scala-Method
Scala
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
CSS | 8 Digit Hex Color

21 Aug, 2019
The Eight Digit Hex color is as simple as Six Digit Hex color it contains 8 digits rather than six, it is used to define the color of your elements with the CSS. It has a prefixed hash(#) value before the digits like six-digit hex code.The difference between 6 and 8 digit hex codes is, that 2 extra characters define the alpha channel as the name suggests in the 8 digit hex color. The last two digits will define that the color will how much transparent or opaque. If the last two digit is 00 then that will be fully transparent and if that is FF then it will be fully opaque.
Syntax:
#RRGGBBAA
Note: The first six character represent the RGB color as Six digit hex color code. Last two represent the alpha channel.
Example 1:
<!DOCTYPE html><html>  <head>    <title>CSS 8 Digit Hex Color</title>    <style>        body {            background-color: #666600;        }                  h1 {            color: green;        }                  article {            background-color: #FFFFFF44;            border: 5px solid green;            margin: 15px;            text-align: center;        }    </style></head>  <body>    <article>        <h1>GeeksforGeeks</h1>    </article></body>  </html>
Output:
Example 2:
<!DOCTYPE html><html>  <head>    <title>CSS 8 Digit Hex Color</title>      <style>        body {            background-image: url('https://media.geeksforgeeks.org/wp-content/uploads/20190808143838/logsm.png');            background-attachment: fixed;            background-size: cover;        }                  h2 {            color: white;        }                  article {            background-color: #FFFFFF22;            border: 2px solid green;            background-position: center center;            text-align: center;        }    </style></head>  <body>    <article>        <h2>GeeksforGeeks</h2>    </article></body>  </html>
Output:
CSS-Properties
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Types of CSS (Cascading Style Sheet)
Design a Tribute Page using HTML & CSS
How to set space between the flexbox ?
How to position a div at the bottom of its container using CSS?
How to Upload Image into Database and Display it using PHP ?
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to fetch data from an API in ReactJS ?
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Time Series - Moving Average

For a stationary time series, a moving average model sees the value of a variable at time ‘t’ as a linear function of residual errors from ‘q’ time steps preceding it. The residual error is calculated by comparing the value at the time ‘t’ to moving average of the values preceding.
Mathematically it can be written as −
yt=c+εt+θ1εt−1+θ2εt−2+...+:θqεt−q
Where‘q’ is the moving-average trend parameter
εt is white noise, and
εt−1,εt−2...εt−q are the error terms at previous time periods.
Value of ‘q’ can be calibrated using various methods. One way of finding the apt value of ‘q’ is plotting the partial auto-correlation plot.
A partial auto-correlation plot shows the relation of a variable with itself at prior time steps with indirect correlations removed, unlike auto-correlation plot which shows direct as well as indirect correlations, let’s see how it looks like for ‘temperature’ variable of our data.
Showing PACP
In [143]:
from statsmodels.graphics.tsaplots import plot_pacf

plot_pacf(train, lags = 100)
plt.show()


A partial auto-correlation is read in the same way as a correlogram.

 Previous Page
 Print Page
Next Page  


Advertisements






Where‘q’ is the moving-average trend parameter
εt is white noise, and
εt−1,εt−2...εt−q are the error terms at previous time periods.
Value of ‘q’ can be calibrated using various methods. One way of finding the apt value of ‘q’ is plotting the partial auto-correlation plot.
A partial auto-correlation plot shows the relation of a variable with itself at prior time steps with indirect correlations removed, unlike auto-correlation plot which shows direct as well as indirect correlations, let’s see how it looks like for ‘temperature’ variable of our data.
In [143]:
from statsmodels.graphics.tsaplots import plot_pacf

plot_pacf(train, lags = 100)
plt.show()

A partial auto-correlation is read in the same way as a correlogram.
How to vertically center text with CSS ?

30 Jun, 2022
In this article, we will learn how to align the text vertically using CSS & Although CSS2 doesn’t support Vertical aligning. But, we can align the center blocks vertically, by combining a few properties. The trick is to specify the outer block to be formatted as a table cell because the contents of a table cell can be centered vertically. We will use the vertical-align property that specifies the vertical alignment of the table-box or inline element.
Syntax:
DIV.container {
    min-height: 10em;
    display: table-cell;
    vertical-align: middle }
...
DIV {
  GeeksforGeeks
}
Example: This example describes the use of the vertical-align property along with the display property as table-cell.
HTML
<!DOCTYPE html><html>  <head>    <title>Horizontal and Vertical alignment</title>    <style>    div {        height: 200px;        width: 400px;        border: 2px dashed #4b2869;    }          .container {        min-height: 10em;        display: table-cell;        vertical-align: middle;    }    </style></head>  <body>    <div class="container">GeeksforGeeks</div></body>  </html>
Output:
There is a more versatile approach to align text vertically.It will work for a single line as well as multiple lines of text, but it will still require a fixed height container.
Syntax:
div {
  height: 200px;
  line-height: 200px;
  text-align: center;
  border: 2px dashed #f69c55;
}
span {
  display: inline-block;
  vertical-align: middle;
  line-height: normal;
}
The CSS just sizes the div, vertically center aligns the span by setting the div’s line-height equal to its height, and makes the span an inline-block with vertical-align: middle. Then it sets the line-height back to normal for the span, so its contents will flow naturally inside the block.
Example: This example describes aligning the content vertically with a fixed height of the container.
HTML
<!DOCTYPE html><html>  <head>    <title> Horizontal and Vertical alignment </title>    <style>    div {        height: 200px;        line-height: 200px;        text-align: center;        border: 2px dashed #f69c55;    }          span {        display: inline-block;        vertical-align: middle;        line-height: normal;    }    </style></head>  <body>    <div>      <span>GeeksforGeeks</span>       </div></body>  </html>
Output:
CSS is the foundation of web pages, is used for webpage development by styling websites and web apps. You can learn CSS from the ground up by following this CSS Tutorial and CSS Examples.
bhaskargeeksforgeeks
CSS-Misc
Picked
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to shuffle an array in Java?

Declare a string array and add elements in the form of letters −
String[] letters = { "P", "Q", "R", "S", "T", "U","V", "W", "X", "Y", "Z" };
Convert the above array to list −
List<String>list = Arrays.asList(letters);
Now, create a shuffled array using the Random class object and generate the random letters with nextInt() −
int len = list.size();
System.out.println("Shuffled array...");
for (int i = 0; i < letters.length; i++) {
   int index = new Random().nextInt(len);
   String shuffle = list.get(index);
   System.out.println(shuffle);
}
 Live Demo
import java.util.Arrays;
import java.util.List;
import java.util.Random;
public class Demo {
   public static void main(String[] args) {
      String[] letters = { "P", "Q", "R", "S", "T", "U","V", "W", "X", "Y", "Z" };
      System.out.println("Initial array = "+Arrays.toString(letters));
      List<String>list = Arrays.asList(letters);
      int len = list.size();
      System.out.println("Shuffled array...");
      for (int i = 0; i < letters.length; i++) {
         int index = new Random().nextInt(len);
         String shuffle = list.get(index);
         System.out.println(shuffle);
      }
   }
}
Initial array = [P, Q, R, S, T, U, V, W, X, Y, Z]
Shuffled array...
P
X
S
X
W
S
V
R
Y
Q
R
Remove Axis Labels and Ticks in ggplot2 Plot in R

24 Oct, 2021
In this article, we will discuss how to remove axis labels and ticks in ggplot2 in R Programming Language.
The axes labels and ticks can be removed in ggplot using the theme() method. This method is basically used to modify the non-data components of the made plot. It gives the plot a good graphical customized look. The theme() method is used to work with the labels, ticks, and text of the plot made. The labels and ticks are aligned to the element_blank() method in order to remove them.
Syntax : 
theme(axis.text.x = , axis.ticks.x = , axis.text.y = , axis.ticks.y = )
Arguments : 
axis.text.x , axis.text.y =  tick labels along axes
axis.ticks.x, axis.ticks.y  = tick labels along axes
R
# creating data framecol1 = c(1: 10)col2 = c(11: 20)  print("X coordinates")print(col1)  print("Y coordinates")print(col2)  # plotting the data framegraph < - ggplot(df, aes(x=col1, y=col2)) +geom_point()  # removing axes labels and ticksgraph +theme(axis.text.x=element_blank(),      axis.ticks.x=element_blank(),      axis.text.y=element_blank(),      axis.ticks.y=element_blank())  # printing the graphprint(graph)
Output
[1] "X coordinates"
[1]  1  2  3  4  5  6  7  8  9 10
[1] "Y coordinates"
[1] 11 12 13 14 15 16 17 18 19 20
Explanation: The x and y axes markings and tick marks have been removed from the graph by setting them to the element_blank() method. 
Picked
R-ggplot
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
JavaScript | Replace() Method

02 Jun, 2022
The replace() method in JavaScript is used to replace the current page with another page. The Replace Method replaces the URL of the current window by the URL mention in the Replace method. 
Syntax:
location.replace(URL)
Parameter: This method accepts single parameter URL. The URL is the reference of other page which need to replace with older page. 
Return Value: This method returns or open the new page in window. 
Example: 
javascript
<!DOCTYPE html><html>     <head>          <title>Redirect to Webpage</title>          <style>            body{                text-align:center;            }            .gfg {                font-size:40px;                font-weight:bold;                color:green;            }          </style>     </head>     <body>     <div class = "gfg">GeeksforGeeks</div>     <h2>Replace Method</h2>     <button onclick = "Replace()" >Replace with Gfg</button>          <script>                //Replace function that replace the current page.               function Replace() {                    location.replace("https://www.geeksforgeeks.org/")               }           </script>     </body></html>
Output: Before clicking on the button:  After clicking on the button: 
 
kumargaurav97520
javascript-functions
Web technologies
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python VLC – Instance

29 Aug, 2020
In this article we will see how we can create a Instance class instance in the python vlc module. VLC media player is a free and open-source portable cross-platform media player software and streaming media server developed by the VideoLAN project. Instance act as a main object of the VLC library with the Instance object we can create media player, list player or any other player available in VLC. Instance class the base classed used in VLC to create various objects.
In order to do this we will use vlc.Instance method
Syntax : vlc.Instance()
Argument : It takes no argument
Return : It returns Instance object
Below is the implementation
# importing vlc moduleimport vlc  # importing time moduleimport time  # creating Instance class objectplayer = vlc.Instance()  # creating a new mediamedia = player.media_new("death_note.mkv")  # creating a media player objectmedia_player = player.media_player_new()  media_player.set_media(media)  # setting video scalemedia_player.video_set_scale(0.6)  # start playing videomedia_player.play()    # wait so the video can be played for 5 seconds# irrespective for length of videotime.sleep(5)
Output :
Another exampleBelow is the implementation
# importing vlc moduleimport vlc  # importing time moduleimport time  # creating Instance class objectplayer = vlc.Instance()  # creating a new mediamedia = player.media_new("1.mp4")  # creating a media player objectmedia_player = player.media_player_new()  media_player.set_media(media)  # setting video scalemedia_player.video_set_scale(0.6)  # start playing videomedia_player.play()    # wait so the video can be played for 5 seconds# irrespective for length of videotime.sleep(5)
Output :
Python vlc-library
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
MoviePy – Setting Duration of the Clip

30 Aug, 2020
In this article we will see how we can set duration of the video file clip in MoviePy. MoviePy is a Python module for video editing, which can be used for basic operations on videos and GIF’s. Duration is the time for which the clip get played increasing the duration make it repeat itself and decreasing duration will close the clip when duration is completed.
In order to do this we will use set_duration method with the VideoFileClip object
Syntax : clip.set_duration(n)
Argument : It takes float value as argument
Return : It returns VideoFileClip object
Below is the implementation
# Import everything needed to edit video clips from moviepy.editor import *    # loading video dsa gfg intro video clip = VideoFileClip("dsa_geek.mp4")      # getting only first 5 secondsclip = clip.subclip(0, 5)  # new clip with new durationnew_clip = clip.set_duration(10)    # new clip with new durationnew_clip.ipython_display(width = 360)
Output :
Moviepy - Building video __temp__.mp4.
Moviepy - Writing video __temp__.mp4

                                                                                                                       
Moviepy - Done !
Moviepy - video ready __temp__.mp4

# Import everything needed to edit video clipsfrom moviepy.editor import *  # loading video gfgclip = VideoFileClip("geeks.mp4")  # getting only first 2 secondsclip = clip.subclip(0, 2)  # new clip with new durationnew_clip = clip.set_duration(6)  # showing  clip new_clip.ipython_display(width = 360) 
Output :
Moviepy - Building video __temp__.mp4.
MoviePy - Writing audio in __temp__TEMP_MPY_wvf_snd.mp3
                                                                                                                       
MoviePy - Done.
Moviepy - Writing video __temp__.mp4

                                                                                                                       
Moviepy - Done !
Moviepy - video ready __temp__.mp4

Python-MoviePy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
AngularJS | ng-maxlength Directive - GeeksforGeeks

26 Mar, 2019
The ng-maxlength Directive in AngularJS is used to set the maximum length for an input field i.e it adds the restriction for an input field. It is different from maxlength attribute in HTML because the former prevent users from exceeding the limit whereas the later doesn’t do that. It will make the form invalid if the input limit exceeds.
Syntax:
 <element ng-maxlength="expression"> Contents... </element> 
Where expression is a number denoting the maximum limit upto which the input is valid.
Example: This example uses ng-maxlength Directive to check the maximum length of string.
<!DOCTYPE html><html>  <head>    <title>ng-maxlength Directive</title>          <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js">    </script></head>  <body style="text-align: center">          <h1 style="color:green">GeeksforGeeks</h1>          <h2>ng-maxlength Directive</h2>          <div ng-app="app" ng-controller="geek">          <form name="maxlen" novalidate ng-submit=                        "maxlen.$valid &&maxlength()">              <pre>Atmax 5 characters required</pre>                              Input: <input type="text" name="code" ng-model="txt"                        ng-maxlength="5" required />             <br><br>                            <button type="submit">Click it</button>                            <br><br>                            <span>{{msg}}</span>         </form>    </div>          <script>        var app = angular.module('app', []);        app.controller('geek', function ($scope) {            $scope.maxlength = function () {                $scope.msg = "Input is valid";            };        });    </script></body>  </html>
Output:Before clicking the button:After clicking the button:
AngularJS-Directives
AngularJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Top 10 Angular Libraries For Web Developers
Auth Guards in Angular 9/10/11
What is AOT and JIT Compiler in Angular ?
How to set focus on input field automatically on page load in AngularJS ?
Angular PrimeNG Dropdown Component
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
Convert a string to an integer in JavaScript
React Native - TouchableHighlight

We already mentioned touchable components in one of our previous chapters. This chapter will show you how to use TouchableHighlight component.
We already done this in our previous chapters. We will create src/components/home/TouchableHighlight.js file.
This is container component. We are passing buttonPressed function as a prop.
src/components/home/HomeContainer.js
import React, { Component } from 'react'
import TouchableHighlightExample from './TouchableHighlightExample'

export default class HomeContainer extends Component {

   constructor() {
      super();
   }
   buttonPressed = () => {
      console.log('TouchableHighlight pressed...');
   }
   render() {
      return (
         <TouchableHighlightExample buttonPressed = {this.buttonPressed}/>
      );
   }
}
This component is our button. underlayColor will be visible when button is pressed.
src/components/home/TouchableHighlightExample.js
import React, { Component } from 'react'
import {
   View,
   TouchableHighlight,
   Text,
   StyleSheet
} from 'react-native'

export default TouchableHighlightExample = (props) => {
   return (
      <View style = {styles.container}>
         <TouchableHighlight underlayColor = {'red'} onPress = {props.buttonPressed}>
            <Text style = {styles.button}>
               Button
            </Text>
         </TouchableHighlight>
      </View>
   )
}

const styles = StyleSheet.create ({
   container: {
      flex: 1,
      justifyContent: 'center',
      alignItems: 'center',
  },
  button: {
      borderWidth: 1,
      padding: 25,
      borderColor: 'black'
  }
})
You can press the button to see red color.

    20 Lectures 
     1.5 hours 

 Anadi Sharma

    61 Lectures 
     6.5 hours 

 A To Z Mentor

    40 Lectures 
     4.5 hours 

 Eduonix Learning Solutions

    56 Lectures 
     12.5 hours 

 Eduonix Learning Solutions

    62 Lectures 
     4.5 hours 

 Senol Atac

    67 Lectures 
     4.5 hours 

 Senol Atac
 Print
 Add Notes
 Bookmark this page
Python String maketrans() Method - GeeksforGeeks

05 Oct, 2021
Python String maketrans() function is used to construct the transition table i.e specify the list of characters that need to be replaced in the whole string or the characters that need to be deleted from the string.
Syntax:
maketrans(str1, str2, str3)
Parameters:
str1: Specifies the list of characters that need to be replaced.
str2: Specifies the list of characters with which the characters need to be replaced.
str3: Specifies the list of characters that need to be deleted.
Returns: 
Returns the translation table which specifies the conversions that can be used by translate()
To translate the characters in the string translate() is used to make the translations. This function uses the translation mapping specified using the maketrans().
Syntax:
translate(table, delstr)
Parameters:
table: Translate mapping specified to perform translations.
delstr: The delete string can be specified as optional argument is not mentioned in table.
Returns: Returns the argument string after performing the translations using the translation table.
Python3
# Python3 code to demonstrate# translations using# maketrans() and translate()  # specify to translate charsstr1 = "wy"  # specify to replace withstr2 = "gf"  # delete charsstr3 = "u"  # target stringtrg = "weeksyourweeks"  # using maketrans() to# construct translate# tabletable = trg.maketrans(str1, str2, str3)  # Printing original stringprint ("The string before translating is : ", end ="")print (trg)  # using translate() to make translations.print ("The string after translating is : ", end ="")print (trg.translate(table))
Output:
The string before translating is : weeksyourweeks
The string after translating is : geeksforgeeks
Python-Built-in-functions
python-string
Python-string-functions
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
Selecting rows in pandas DataFrame based on conditions
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | os.path.join() method
Python | Get unique values from a list
Defaultdict in Python
Create a directory in Python
Python | Pandas dataframe.groupby()
Python - Reading RSS feed

RSS (Rich Site Summary) is a format for delivering regularly changing web content. Many news-related sites, weblogs and other online publishers syndicate their content as an RSS Feed to whoever wants it. In python we take help of the below package to read and process these feeds. 
pip install feedparser
In the below example we get the structure of the feed so that we can analyse further about which parts of the feed we want to process.
import feedparser
NewsFeed = feedparser.parse("https://timesofindia.indiatimes.com/rssfeedstopstories.cms")
entry = NewsFeed.entries[1]

print entry.keys()
When we run the above program, we get the following output −
['summary_detail', 'published_parsed', 'links', 'title', 'summary', 'guidislink', 'title_detail', 'link', 'published', 'id']

 In the below example we read the title and head of the rss feed.
import feedparser

NewsFeed = feedparser.parse("https://timesofindia.indiatimes.com/rssfeedstopstories.cms")

print 'Number of RSS posts :', len(NewsFeed.entries)

entry = NewsFeed.entries[1]
print 'Post Title :',entry.title
When we run the above program we get the following output −
Number of RSS posts : 5
Post Title : Cong-JD(S) in SC over choice of pro tem speaker

Based on above entry structure we can derive the necessary details from the feed using python program as shown below. As entry is a dictionary we utilise its keys to produce the values needed.  
import feedparser

NewsFeed = feedparser.parse("https://timesofindia.indiatimes.com/rssfeedstopstories.cms")

entry = NewsFeed.entries[1]

print entry.published
print "******"
print entry.summary
print "------News Link--------"
print entry.link
When we run the above program we get the following output −
Fri, 18 May 2018 20:13:13 GMT
******
Controversy erupted on Friday over the appointment of BJP MLA K G Bopaiah as pro tem speaker for the assembly, with Congress and JD(S) claiming the move went against convention that the post should go to the most senior member of the House. The combine approached the SC to challenge the appointment. Hearing is scheduled for 10:30 am today.
------News Link--------
https://timesofindia.indiatimes.com/india/congress-jds-in-sc-over-bjp-mla-made-pro-tem-speaker-hearing-at-1030-am/articleshow/64228740.cms


    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
How can we take a backup of a particular table from a database by using mysqldump client program?

By using mysql dump client program we can take the backup of a particular table from the databases into a file having the extension ‘.sql’. It can be understood with the help of the following example −
In this example, with the help of mysql dump client program, we are taking the backup of a table named ‘student_info’ from ‘query’ database in a file named ‘student_info.sql’. The following command will do this:
C:\mysql\bin>mysqldump -u root query student_info > student_info.sql
The above command will create a file named student_info.sql which has the dump information of a file named ‘student_info’ from database named ‘query’.
Extract word from a String at specified position in R Programming – word() Function

03 Jun, 2020
word() Function in R Language is used to extract words from a string from the position specified as argument.
Syntax: word(string, position)
Parameter:string: From which word needs to be extractedposition: Specified Index value
Example 1:
# R Program to illustrate # the use of word function  # Loading Librarylibrary(stringr)  # Creating a stringx <- "Geeks for Geeks"  # Extracting wordword(x, 2)
Output:
[1] "for"

Example 2:
# R Program to illustrate # the use of word function  # Loading Librarylibrary(stringr)  # Creating a stringx <- "abc bcd 100 efg"  # Extracting wordsword(x, 2, 4)
Output:
[1] "bcd 100 efg"

R String-Functions
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
fsetpos() (Set File Position) in C

30 Jun, 2021
The fsetpos() function moves the file position indicator to the location specified by the object pointed to by position. When fsetpos() is executed ,the end-of-file indicator is reset.Declaration  
 
Parameters –  
stream – This is the pointer to a FILE object that identifies the stream.
position – This is the pointer to a fpos_t object containing a position previously obtained with fgetpos.
Return – If it successful, it return zero otherwise returns nonzero value. 
C
// c code to demonstrate fsetpos() function.#include <stdio.h>int main () {   FILE *fp;   fpos_t position;    /*write your own file name.    My file name is "myfile.txt"*/   fp = fopen("myfile.txt","w+");   fgetpos(fp, &position);   fputs("HelloWorld!", fp);      fsetpos(fp, &position);    // previous function is override   fputs("geeksforgeeks", fp);   fclose(fp);       return(0);}
Output –  
geeksforgeeks
This article is contributed by Shivani Ghughtyal. 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. 
dpatwal8
C-File Handling
C Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
response.url – Python requests

01 Mar, 2020
response.url returns the URL of the response. It will show the main url which has returned the content, after all redirections, if done. Python requests are generally used to fetch the content from a particular resource URI. Whenever we make a request to a specified URI through Python, it returns a response object. Now, this response object would be used to access certain features such as content, headers, etc. This article revolves around how to check the response.url out of a response object.
To illustrate use of response.url, let’s ping api.github.com. To run this script, you need to have Python and requests installed on your PC.
Download and Install Python 3 Latest Version
How to install requests in Python – For windows, linux, mac
# import requests moduleimport requests  # Making a get requestresponse = requests.get('http://api.github.com')  # print responseprint(response)  # print urlprint(response.url)
Save above file as request.py and run using
Python request.py

Check that https://api.github.com/, it shows the url that returned the response.
There are many libraries to make an HTTP request in Python, which are httplib, urllib, httplib2, treq, etc., but requests is the one of the best with cool features. If any attribute of requests shows NULL, check the status code using below attribute.
requests.status_code
If status_code doesn’t lie in range of 200-29. You probably need to check method begin used for making a request + the url you are requesting for resources.
Python-requests
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Enumerate() in Python
Different ways to create Pandas Dataframe
How to Install PIP on Windows ?
Python String | replace()
Python OOPs Concepts
Python Classes and Objects
*args and **kwargs in Python
Introduction To PYTHON
Create a Pandas DataFrame from Lists
How to Iterate over months between two dates in Python?

18 Feb, 2022
In this article, we will discuss how to iterate over months between two dates using Python. 
We can iterate over months between two dates using timedelta and rrule methods.
timedelta() is used for calculating differences in dates and also can be used for date manipulations in Python
Example:
But using timedelta we can’t iterate over months between dates perfectly because here we are adding 31 days for each month. But every month won’t have exact 31 days. Some months have 30 and even 28, 29. In order to solve the problem rrule comes into the act that helps to iterate between dates by a specific period of time.
Python3
# import necessary packagesfrom datetime import datetime, timedelta # date initialisationstartDate = datetime(2020, 1, 10)endDate = datetime(2020, 4, 20) # stores 31 days that can be addedaddDays = timedelta(days=31) while startDate <= endDate:    print(startDate)    # add a month    startDate += addDays
2020-01-10 00:00:00
2020-02-10 00:00:00
2020-03-12 00:00:00
2020-04-12 00:00:00
rrule is a package present in dateutil library and this package consists of a method also rrule which takes dtstart, until and specific time period as parameters which are start date, end date, and time period based on iteration respectively. Specific time periods are WEEKLY, MONTHLY, YEARLY, etc.
Note: Use MONTHLY when you want to iterate over months between dates.
Syntax:
rrule(rrule.MONTHLY, dtstart=start_date, until=end_date)
Example:
Iterate over months between dates using rrule.
Python3
# import necessary packagesfrom datetime import datetimefrom dateutil import rrule # datesstart_date = datetime(2021, 1, 1)end_date = datetime(2022, 1, 1) for dt in rrule.rrule(rrule.MONTHLY, dtstart=start_date, until=end_date):    print(dt)
2021-01-01 00:00:00
2021-02-01 00:00:00
2021-03-01 00:00:00
2021-04-01 00:00:00
2021-05-01 00:00:00
2021-06-01 00:00:00
2021-07-01 00:00:00
2021-08-01 00:00:00
2021-09-01 00:00:00
2021-10-01 00:00:00
2021-11-01 00:00:00
2021-12-01 00:00:00
2022-01-01 00:00:00
Example:
Iterate over years in between dates using rrule.
Python3
# import necessary packagesfrom datetime import datetimefrom dateutil import rrule # datesstart_date = datetime(2021, 1, 1)end_date = datetime(2022, 1, 1) for dt in rrule.rrule(rrule.YEARLY, dtstart=start_date, until=end_date):    print(dt)
2021-01-01 00:00:00
2022-01-01 00:00:00
kk773572498
Picked
Python-datetime
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.