code-rag-bench/online-tutorials huggingface dataset:
How to Maximize window in chrome using webDriver (Python)?

We can maximize windows on Chrome with a webdriver. While working on any automated test cases, if the browser opens in maximized mode then the probability of the scripts getting failed lessens.
This is because if the element is visible, then the chances of its interaction increases. Also, if the window is maximized, then the testers or developers working on them gets a better visibility of the test steps.
Some of the applications open in maximized mode automatically. Applying maximizing techniques on them does not have any impact on them. Let us see the methods with which we can maximize window in chrome in python −
Using maximize_window() method.
Using maximize_window() method.
Using fullscreen_window() method.
Using fullscreen_window() method.
Code Implementation with maximize_window().
from selenium import webdriver
driver = webdriver.Chrome (executable_path="C:\\chromedriver.exe")
# maximize with maximize_window()
driver.maximize_window()
driver.get("https://www.tutorialspoint.com/index.htm")
driver.quit()
Code Implementation with fullscreen_window().
from selenium import webdriver
driver = webdriver.Chrome (executable_path="C:\\chromedriver.exe")
# maximize with maximize_window()
driver.fullscreen_window()
driver.get("https://www.tutorialspoint.com/index.htm")
driver.quit()
So in the above code implementations we have done the following steps −
Launched the Chrome browser.
Launched the Chrome browser.
Opened an URL.
Opened an URL.
Maximized the Chrome browser.
Maximized the Chrome browser.
Quitted the driver session.
Quitted the driver session.
Redis - Environment

In this chapter, you will learn about the environmental setup for Redis.
To install Redis on Ubuntu, go to the terminal and type the following commands −
$sudo apt-get update 
$sudo apt-get install redis-server

This will install Redis on your machine.
$redis-server

$redis-cli 

This will open a redis prompt.
redis 127.0.0.1:6379>

In the above prompt, 127.0.0.1 is your machine's IP address and 6379 is the port on which Redis server is running. Now type the following PING command.
redis 127.0.0.1:6379> ping 
PONG

This shows that Redis is successfully installed on your machine.
To install Redis desktop manager on Ubuntu, just download the package from https://redisdesktop.com/download
Open the downloaded package and install it.
Redis desktop manager will give you UI to manage your Redis keys and data.

    22 Lectures 
     40 mins

 Skillbakerystudios
 Print
 Add Notes
 Bookmark this page
Tryit Editor v3.7

CSS Image Reflection
Tryit: Image reflection below
JavaScript Date getUTCDate() Method - GeeksforGeeks

19 Oct, 2021
Below is the example of Date getUTCDate() method.  
Example:  
javascript
<script>    // If nothing is in parameter it takes    // the current date while creating Date object    var date = new Date();         // Date of the month from above date object    // is being extracted using getUTCDate().    var getUTC = date.getUTCDate();         //Printing on console    document.write(getUTC);</script>
Output:  
29
The date.getUTCDate() method is used to fetch the date of a month according to universal time from a given Date object.Syntax:  
DateObj.getUTCDate();
Parameter: This method does not accept any parameter. It is just used along with a Date Object from which we want to fetch the date of the month according to universal time.Return Values: It returns the date of the month for the given date object according to universal time. The date of the month is an integer value ranging from 1 to 31.More codes for the above method are as follows:Program 1: The date of the month should lie in between 1 to 31 because none of the months have a date greater than 31 that is why it returns NaN i.e, not a number because the date for the month does not exist.  
javascript
<script>   // Here a date has been assigned according   // to universal time while creating a Date object   var dateobj =   new Date('October 33, 1996 05:35:32 GMT-11:00');    // date of the month from above date object   // is being extracted using getUTCDate().   var B = dateobj.getUTCDate();    // Printing date of the month.   document.write(B);</script>
Output:  
NaN
Program 2: If date of the month is not given then by default getUTCDate() function returns 1 according to universal time.It is an exception case.  
javascript
<script>   // Here a date has been assigned according to   // universal time while creating Date object   var dateobj =   new Date('October 1996 05:35:32 GMT-11:00');    // date of the month from above date object is   // extracted using getUTCDate().   var B = dateobj.getUTCDate();    // Printing date of the month.   document.write(B);</script>
Output:  
1
Supported Browsers: The browsers supported by JavaScript Date getUTCDate() method are listed below:  
Google Chrome 1 and above
Edge 12 and above
Firefox 1 and above
Internet Explorer 4 and above
Opera 4 and above
Safari 1 and above
 
ysachin2314
javascript-date
JavaScript-Methods
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
How to calculate the number of days between two dates in javascript?
Differences between Functional Components and Class Components in React
How to append HTML code to a div using JavaScript ?
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
C# Access Modifiers

By now, you are quite familiar with the public keyword that appears 
in many of our examples:
public string color;

The public keyword is an access modifier, 
which is used to set the access level/visibility for classes, fields, methods and properties.
C# has the following access modifiers:
There's also two combinations: protected internal and private protected.
For now, lets focus on public and private modifiers.
If you declare a field with a private access modifier, it can only be 
accessed within the same class:
class Car
 
{
  private string model = "Mustang";

  static void Main(string[] args)
  {
    Car myObj = new Car();
    Console.WriteLine(myObj.model);
  }
}
The output will be:

Try it Yourself »

If you try to access it outside the class, an error will occur:
class Car
{
  private string model = "Mustang";
}

class Program
{
  static void Main(string[] args)
  {
    Car myObj = new Car();
    Console.WriteLine(myObj.model);
  }
}
 

The output will be:

Try it Yourself »

If you declare a field with a public access modifier, it is accessible for 
all classes:
class Car
{
  public string model = "Mustang";
}

class Program
{
  static void Main(string[] args)
  {
    Car myObj = new Car();
    Console.WriteLine(myObj.model);
  }
}
 

The output will be:

Try it Yourself »

To control the visibility of class members (the security level of 
each individual class and class member).
To achieve "Encapsulation" - which is the process of making sure that "sensitive" data is hidden from users. 
This is done by declaring fields as private. You will learn more about this in the next chapter.
Note: By default, all members of a class are private if you don't specify an access modifier:
class Car
{
  string model;  // private
  string year;   // private
}
 

We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
How to open PIL Image in Tkinter on Canvas?

Pillow package (or PIL) helps a lot to process and load images in Python projects. It is a free open-source library available in Python that adds support to load, process, and manipulate the images of different formats.
In order to open the Image in Tkinter canvas, we have to first import the library using from PIL import Image, ImageTk command. To display the image in our Tkinter application, we can use the Canvas widget by specifying the image file in the create_image(x,y,image) method.
#Import the required Libraries
from tkinter import *
from PIL import Image,ImageTk

#Create an instance of tkinter frame
win = Tk()

#Set the geometry of tkinter frame
win.geometry("750x270")

#Create a canvas
canvas= Canvas(win, width= 600, height= 400)
canvas.pack()

#Load an image in the script
img= ImageTk.PhotoImage(Image.open("download.png"))

#Add image to the Canvas Items
canvas.create_image(10,10,anchor=NW,image=img)

win.mainloop()
Running the above code will display a window with an image inside the canvas widget.
Converting Odd and Even-indexed characters in a string to uppercase/lowercase in JavaScript?

We need to write a function that reads a string and converts the odd indexed characters in the
string to upperCase and the even ones to lowerCase and returns a new string.
Full code for doing the same will be −
const text = 'Hello world, it is so nice to be alive.';
const changeCase = (str) => {
   const newStr = str
   .split("")
   .map((word, index) => {
      if(index % 2 === 0){
         return word.toLowerCase();
      }else{
         return word.toUpperCase();
      }
   })
   .join("");
   return newStr;
};
console.log(changeCase(text));
The code converts the string into an array, maps through each of its word and converts them to
uppercase or lowercase based on their index.
Lastly, it converts the array back into a string and returns it. The output in console will be −
hElLo wOrLd, It iS So nIcE To bE AlIvE.
java.time.Clock.tick() Method Example

The java.time.Clock.tick() method obtains a clock that returns instants from the specified clock truncated to the nearest occurrence of the specified duration.
Following is the declaration for java.time.Clock.tick() method.
public static Clock tick(Clock baseClock, Duration tickDuration)

baseClock − the base clock to add the duration to, not null.
baseClock − the base clock to add the duration to, not null.
tickDuration − the duration of each visible tick, not negative, not null.
tickDuration − the duration of each visible tick, not negative, not null.
a clock that ticks in whole units of the duration, not null.
IllegalArgumentException − if the duration is negative, or has a part smaller than a whole millisecond such that the whole duration is not divisible into one second.
IllegalArgumentException − if the duration is negative, or has a part smaller than a whole millisecond such that the whole duration is not divisible into one second.
ArithmeticException − if the duration is too large to be represented as nanos.
ArithmeticException − if the duration is too large to be represented as nanos.
The following example shows the usage of java.time.Clock.tick() method.
package com.tutorialspoint;

import java.time.Clock;
import java.time.Duration;

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

      Clock clock = Clock.systemUTC();  

      Duration tickDuration = Duration.ofNanos(250000);
      Clock clock1 = Clock.tick(clock, tickDuration);
      System.out.println("Clock : " + clock.instant());
      System.out.println("Clock1 : " + clock1.instant());
   }
}
Let us compile and run the above program, this will produce the following result −
Clock : 2017-03-07T06:53:24.870Z
Clock1 : 2017-03-07T06:53:24.951Z

 Print
 Add Notes
 Bookmark this page
Bootstrap 4 .justify-content-*-end class

To justify the flex items on the end, use the justify-content-end class.
To justify the flex items on the end, on different screen sizes, use the justify-content-*-end class. The flex items justified at the end would be visible like the following on different screen sizes −
Small Screen Size
<div class="d-flex justify-content-sm-end bg-danger mb-5">
  <div class="p-2 bg-primary">Alabama</div>
  <div class="p-2 bg-info">New York</div>
  <div class="p-2 bg-secondary">Texas</div>
</div>
Medium Screen Size
<div class="d-flex justify-content-md-end bg-danger mb-5">
  <div class="p-2 bg-primary">Alabama</div>
  <div class="p-2 bg-info">New York</div>
  <div class="p-2 bg-secondary">Texas</div>
</div>
Let us see the complete code and learn how to work with justify-content-*-end class −
Live Demo
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Bootstrap Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
  </head>

<body>
  <div class="container mt-3">
      <h3>US</h3>
      <div class="d-flex justify-content-sm-end bg-danger mb-5">
        <div class="p-2 bg-primary">Alabama</div>
        <div class="p-2 bg-info">New York</div>
        <div class="p-2 bg-secondary">Texas</div>
      </div>
      <div class="d-flex justify-content-md-end bg-danger mb-5">
        <div class="p-2 bg-primary">Alabama</div>
        <div class="p-2 bg-info">New York</div>
        <div class="p-2 bg-secondary">Texas</div>
      </div>
      <div class="d-flex justify-content-lg-end bg-danger mb-5">
        <div class="p-2 bg-primary">Alabama</div>
        <div class="p-2 bg-info">New York</div>
        <div class="p-2 bg-secondary">Texas</div>
      </div>
  </div>
</body>
</html>
Get Day Number of Week in Java

To get the day of the week, use Calendar.DAY_OF_WEEK.
Firstly, declare a calendar object and get the current date and time.
Calendar calendar = Calendar.getInstance();
System.out.println(calendar.getTime().toString());
Now, fetch the day of the week in an integer variable.
int day = calendar.get(Calendar.DAY_OF_WEEK);
The following is the final example.
 Live Demo
import java.util.Calendar;
public class Demo {
   public static void main(String[] args) {
      Calendar calendar = Calendar.getInstance();
      System.out.println(calendar.getTime().toString());
      int day = calendar.get(Calendar.DAY_OF_WEEK);
      System.out.println("Day: " + day);
      int hour = calendar.get(Calendar.HOUR_OF_DAY);
      System.out.println("Hour: " + hour);
      int minute = calendar.get(Calendar.MINUTE);
      System.out.println("Minute: " + minute);
   }
}
Mon Nov 19 10:11:41 UTC 2018
Day: 2
Hour: 10
Minute: 11
Tryit Editor v3.7

Tryit: JavaScript in head
MariaDB - Drop Tables

In this chapter, we will learn to delete tables.
Table deletion is very easy, but remember all deleted tables are irrecoverable. The general syntax for table deletion is as follows −
DROP TABLE table_name ;

Two options exist for performing a table drop: use the command prompt or a PHP script.
At the command prompt, simply use the DROP TABLE SQL command −
root@host# mysql -u root -p
Enter password:*******
mysql> use PRODUCTS;
Database changed
mysql> DROP TABLE products_tbl

mysql> SELECT * from products_tbl
ERROR 1146 (42S02): Table 'products_tbl' doesn't exist

PHP provides mysql_query() for dropping tables. Simply pass its second argument the appropriate SQL command −
<html>
   <head>
      <title>Create a MariaDB Table</title>
   </head>

   <body>
      <?php
         $dbhost = 'localhost:3036';
         $dbuser = 'root';
         $dbpass = 'rootpassword';
         $conn = mysql_connect($dbhost, $dbuser, $dbpass);
         
         if(! $conn ) {
            die('Could not connect: ' . mysql_error());
         }
         echo 'Connected successfully<br />';
         
         $sql = "DROP TABLE products_tbl";
         mysql_select_db( 'PRODUCTS' );
         $retval = mysql_query( $sql, $conn );
      
         if(! $retval ) {
            die('Could not delete table: ' . mysql_error());
         }
         echo "Table deleted successfully\n";
         
         mysql_close($conn);
      ?>
   </body>
</html>
On successful table deletion, you will see the following output −
mysql> Table deleted successfully

 Print
 Add Notes
 Bookmark this page
Accessing nested JavaScript objects with string key

You can use lodash's get method to get properties at any level safely. Getting first-level properties is pretty straightforward. Nested property access is tricky and you should use a tested library like lodash for it.
You can access a deeply nested object in the following way −
let _ = require("lodash");
let obj = {
   a: {
      b: {
         foo: "test"
      },
      c: 2
   }
};
console.log(_.get(obj, "a.b.foo"));
console.log(_.get(obj, "a.c"));
console.log(_.get(obj, "a.test"));
console.log(_.get(obj, "a.test.x"));
This will give the output −
test
2
undefined
undefined
You can also write your own getProp function in the following way −
const getProp = (object, path) => {
   if (path.length === 1) return object[path[0]];
      else if (path.length === 0) throw error;
   else {
      if (object[path[0]]) return getProp(object[path[0]], path.slice(1));
      else {
         object[path[0]] = {};
         return getProp(object[path[0]], path.slice(1));
      }
   }
};
You can use it by passing an array to access the props.
var obj = {
   level1:{
      level2:{
         level3:{
            name: "Foo"
         }
      },
      anotherLevel2: "bar"
   }
};
console.log(getProp(obj, ["level1", "level2"]));
This will give the output −
{level3: {name: "Foo"}}
SVG - Path

<path>  element is used to draw a connected straight lines.
Following is the syntax declaration of <path> element. We've shown main attributes only.
<path
   d="data" >  
</path>
<path> element is used to define any path. Path element uses Path data which comprises of number of commands. Commands behaves like a nip of pencil or a pointer is moving to draw a path.
As above commands are in Upper case, these represents absolute path. In case their lower case commands are used, then relative path is used.
<html>
   <title>SVG Path</title>
   <body>
   
      <h1>Sample SVG Path Image</h1>
      
      <svg width="570" height="320">
         <g>
            <text x="0" y="10" fill="black" >Path #1: Without opacity.</text>
            
            <path d="M 100 100 L 300 100 L 200 300 z" 
            stroke="black" stroke-width="3" fill="rgb(121,0,121)"> </path>
         </g> 
      </svg>
   
   </body>
</html>
In above example,in first shape, M 100 100 moves drawing pointer to (100,100), L 300 100 draws a line from (100,100) to (300,100), L 200 300 draws a line from (300,100) to (200,300) and z closes the path.
Open textSVG.htm in Chrome web browser. You can use Chrome/Firefox/Opera to view SVG image directly without any plugin. Internet Explorer 9  and higher also supports SVG image rendering.
<html>
   <title>SVG Path</title>
   <body>
      
      <h1>Sample SVG Path Image</h1>
      
      <svg width="800" height="800"> 
         <g>
            <text x="0" y="15" fill="black" >Path #2: With opacity </text>
            
            <path d="M 100 100 L 300 100 L 200 300 z"
            style="fill:rgb(121,0,121);stroke-width:3;
            stroke:rgb(0,0,0);stroke-opacity:0.5;"> </path>
         </g>
      </svg>
   
   </body>
</html>
Open textSVG.htm in Chrome web browser. You can use Chrome/Firefox/Opera to view SVG image directly without any plugin. Internet Explorer 9  and higher also supports SVG image rendering.

    45 Lectures 
     5.5 hours 

 DigiFisk (Programming Is Fun)
 Print
 Add Notes
 Bookmark this page
Create a Letter-Spacing Animation Effect using HTML and CSS - GeeksforGeeks

22 Oct, 2021
In this article, we are going to create a letter-spacing animation using CSS. Letter spacing is the available space between the letters in a particular word, we will walk through each step to achieve this animation effect for our web page.
Approach:
Initially, letter-spacing will be -15px.
At 20%, letter-spacing will be 10px.
Finally, at 100% letter-spacing will be at 2px.
Example: In this example, we will animate the letter-spacing of a word. We have used the animation property which is used for creating animation in CSS. We have set a duration of 3 seconds. We have to use @keyframes rules which are responsible for making an element to animate. We can use percentage values for creating animation for an element. In this case, we are using three percentage values for our text. In our case we will animate the values of letter-spacing which is a property for text in CSS.
HTML
<!DOCTYPE html><html lang="en">  <head>          <!-- CSS Code -->    <style>        * {            margin: 0;            padding: 0;        }          #text_container {            display: flex;            align-items: center;            justify-content: center;            text-align: center;            height: 100vh;        }          #text {            font-weight: 100;            opacity: 1;            animation: animate 3s ease-out forwards infinite;            animation-delay: 1s;        }          /* For animation */        @keyframes animate {            0% {                letter-spacing: -15px;            }              20% {                letter-spacing: 10px;            }              100% {                letter-spacing: 2px;            }        }    </style></head>  <body>    <div id="text_container">        <h1 id="text">Geeks for Geeks</h1>    </div></body>  </html>
Output:
Letter Spacing animation
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
CSS-Properties
CSS-Questions
HTML-Questions
Picked
CSS
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Design a web page using HTML and CSS
Form validation using jQuery
How to set space between the flexbox ?
Search Bar using HTML, CSS and JavaScript
How to style a checkbox using CSS?
How to set the default value for an HTML <select> element ?
How to set input type date in dd-mm-yyyy format using HTML ?
Hide or show elements in HTML using display property
How to Insert Form Data into Database using PHP ?
REST API (Introduction)
What is the difference between height and line-height?

Height is the vertical measurement of the container, for example, height of a div.
Line-height is a CSS property to specify the line height i.e. the distance from the top of the first line of text to the top of the second. It is the space between the lines of two paragraphs.
You can try to run the following code to learn the difference between height and line height:
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <style>
         .height {
            height: 20px;
         }

         .lheight {
            line-height: 15px;
         }

         .lheightbigger {
            line-height: 35px;
         }
      </style>
   </head>
   <body>
      <h2>Height</h2>
      <div class="height">
         This is demo text. This is demo text.
         This is demo text. This is demo text.
         This is demo text. This is demo text.
      </div>

      <h2>Line Height with less space</h2>
      <div class="lheight">
         This is demo text showing line height example. This is demo text showing line height example.
         This is demo text showing line height example. This is demo text showing line height example.
         This is demo text showing line height example.This is demo text showing line height example.
      </div>

      <h2>Normal Text</h2>
    <div>
      This is normal text.
      This is normal text.
      This is normal text.
    </div>

    <h2>Line Height with more space</h2>
    <div class="lheightbigger">
      This is normal text. This is normal text.This is normal text.
      This is normal text. This is normal text.This is normal text.
      This is normal text. This is normal text.This is normal text.
    </div>
</body>
</html>
HTML | <table> cellpadding Attribute - GeeksforGeeks

29 May, 2019
The HTML <table> cellpadding Attribute is used to specify the space between the cell content and cell wall. The cellpadding attribute is set in terms of pixels.
Syntax:
<table cellpadding="pixels">
Attribute Values:
pixels: It holds the space between the cell content and cell wall in terms of pixels.
Note: The <table> cellpadding Attribute is not supported by HTML 5.
Example:
<!DOCTYPE html><html>  <head>    <title>        HTML table cellpadding Attribute    </title></head>  <body>    <h1>GeeksforGeeks</h1>      <h2>HTML table cellpadding Attribute</h2>      <table border="1"            cellpadding="15">        <caption>Author Details</caption>          <tr>            <th>NAME</th>            <th>AGE</th>            <th>BRANCH</th>        </tr>        <tr>            <td>BITTU</td>            <td>22</td>            <td>CSE</td>        </tr>        <tr>            <td>RAM</td>            <td>21</td>            <td>ECE</td>        </tr>    </table></body>  </html>
Output:
Supported Browsers: The browser supported by HTML <table> cellpadding Attribute are listed below:
Google Chrome
Internet Explorer
Firefox
Safari
Opera
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to update Node.js and NPM to next version ?
How to Insert Form Data into Database using PHP ?
CSS to put icon inside an input element in a form
REST API (Introduction)
Types of CSS (Cascading Style Sheet)
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
How to change the text color of font in the legend using Matplotlib?

To change the text color of font in the legend in matplotlib, we can take the following steps−
Create x and y data points using numpy.
Plot x and y using plot() method, where color of line is red and label is "y=exp(x)".
To place the legend, use legend() method with location of the legend and store the returned value to set the color of the text.
To set the color of the text, use set_color() method with green color.
To display the figure, use show() method.
import numpy as np
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
x = np.linspace(-2, 2, 100)
y = np.exp(x)
plt.plot(x, y, label="y=exp(x)", c='red')
leg = plt.legend(loc='upper left')
for text in leg.get_texts():
text.set_color("green")
plt.show()
Checking semiprime numbers - JavaScript

We are required to write a JavaScript function that takes in a number and the function establishes if the provided number is a semiprime or not.
A semiprime number is that number which is a special type of composite number that is a product of two prime numbers. For example: 6, 15, 10, 77 are all semiprime. The square of a prime number is also semiprime, like 4, 9, 25 etc.
Following is the code to check semi-prime numbers −
const num = 141;
const checkSemiprime = num => {
   let cnt = 0;
   for (let i = 2; cnt < 2 && i * i <= num; ++i){
      while (num % i == 0){
         num /= i, ++cnt;
      }
   }
   if (num > 1){
      ++cnt;
   }
   // Return '1' if count is equal to '2' else
   // return '0'
   return cnt === 2;
}
console.log(checkSemiprime(num));
Following is the output in the console −
true
SQL – SELECT SUM

21 Jul, 2021
SELECT SUM is used to calculate the total value of an expression in SQL. It is the same as using the AGGREGATE function SUM ( ) in SQL.
In this article, we are going to see how to use “SELECT SUM” in SQL using suitable examples.
Syntax :
SELECT SUM(expr)
FROM Table_Name
WHERE condition;

expr : Expression or column name
1. Creating a Database: 
Use the following syntax to create a database:
CREATE DATABASE database_name
2. Creating a Table:
Use the below syntax to create a table:
CREATE TABLE Table_name(
col_1 TYPE col_1_constraint,
col_2 TYPE col_2 constraint
.....
)

col: Column name
TYPE: Data type whether an integer, variable character, etc
col_constraint: Constraints in SQL like PRIMARY KEY, NOT NULL, UNIQUE, REFERENCES, etc
3. Inserting into a Table:
Use the below syntax to insert data to the table:
INSERT INTO Table_name
VALUES(val_1, val_2, val_3, ..........)

val: Values in particular column
4. View The Table:
Use the below syntax to view the contents of the table:
SELECT * FROM Table_name
Now let’s look into some example use cases of the SELECT SUM function in SQL:
Example 1: Consider the purchase details of mobile phones from an E-commerce site as shown below :
Purchase Information Table
Query : 
Find the sum of all the mobile phones sold on Big Billion Days whose price is less than 55,000 INR.
Example 2: Let’s see another example using the GROUP BY clause. Consider the employee details table of an organization shown below which consists of information about the salary, name, department in which employees are working.
Employee Details
Query : 
Find out the total expenditure the company has to provide to the employees of every department.
In the above result, we can see that the number of employees in HR is 3 and each employee gets a salary of 50,000 INR per month. So, the total salary the company has to provide in the HR department is 1,50,000 INR per month.
sagar0719kumar
Picked
SQL-Functions
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
wcstok() function in C++ with example

12 Dec, 2021
The wcstok() function is defined in cwchar.h header file. The wcstok() function returns the next token in a null terminated wide string. The pointer delim points to the separator characters i.e. the delimiter.
.Syntax:  
wchar_t* wcstok(wchar_t* str, 
                     const wchar_t* delim, 
                     wchar_t ** ptr);
Parameters: This method takes following parameters:  
str: It represents pointer to the null-terminated wide string to tokenize.
delim: It represents pointer to the null terminated wide string that contains the separators.
ptr: It represents pointer to an object of type wchar_t*, which is used by wcstok to store its internal state.
Return Value: The wcstok() function returns the pointer to the beginning of next token if there is any. Otherwise it returns zero.Below program illustrate the above function:Example 1: 
cpp
// c++ program to demonstrate// example of wcstok() function. #include <bits/stdc++.h>using namespace std; int main(){     // Get the string    wchar_t str[] = L"A computer science portal for geeks";     // Creating the parameters of wcstok() method     // Create the pointer of which    // the next token is required    wchar_t* ptr;     // Define the delimiter of the string    wchar_t delim[] = L" ";     // Call the wcstok() method    wchar_t* token = wcstok(str, delim, &ptr);     // Print all tokens with the help of it    while (token) {        wcout << token << endl;        token = wcstok(NULL, delim, &ptr);    }     return 0;}
A
computer
science
portal
for
geeks
 
anikaseth98
akshaysingh98088
CPP-Functions
CPP-Library
Picked
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Java Program for Find largest prime factor of a number

17 Feb, 2018
Given a positive integer \’n\'( 1 <= n <= 1015). Find the largest prime factor of a number.
Input: 6
Output: 3
Explanation
Prime factor of 6 are- 2, 3
Largest of them is \'3\'

Input: 15
Output: 5

Java
// Java Program to find largest// prime factor of numberimport java.io.*;import java.util.*;  class GFG {  // function to find largest prime factorstatic long maxPrimeFactors( long n){    // Initialize the maximum prime    // factor variable with the     // lowest one    long maxPrime = -1;      // Print the number of 2s    // that divide n    while (n % 2 == 0) {        maxPrime = 2;                  // equivalent to n /= 2        n >>= 1;     }      // n must be odd at this point,    // thus skip the even numbers     // and iterate only for odd    // integers    for (int i = 3; i <= Math.sqrt(n); i += 2) {        while (n % i == 0) {            maxPrime = i;            n = n / i;        }    }      // This condition is to handle     // the case when n is a prime     // number greater than 2    if (n > 2)        maxPrime = n;      return maxPrime;}  // Driver codepublic static void main(String[] args){    Long n = 15l;    System.out.println(maxPrimeFactors(n));      n = 25698751364526l;    System.out.println(maxPrimeFactors(n));}}  // This code is contributed by Gitanjali
5
328513

Time complexity: Auxiliary space: 
Please refer complete article on Find largest prime factor of a number for more details!
Java Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
HTML vs XML

25 May, 2022
HTML: HTML (Hyper Text Markup Language) is used to create web pages and web applications. It is a markup language. By HTML we can create our own static page. It is used for displaying the data not to transport the data. HTML is the combination of Hypertext and Markup language. Hypertext defines the link between the web pages. A markup language is used to define the text document within tag which defines the structure of web pages. This language is used to annotate (make notes for the computer) text so that a machine can understand it and manipulate text accordingly. 
Example: 
html
<!DOCTYPE html><html><head>    <title>GeeksforGeeks</title></head><body>    <h1>GeeksforGeeks</h1>      <p>A Computer Science portal for geeks</p>   </body></html>
Output:  
XML: XML (eXtensible Markup Language) is also used to create web pages and web applications. It is dynamic because it is used to transport the data not for displaying the data. The design goals of XML focus on simplicity, generality, and usability across the Internet. It is a textual data format with strong support via Unicode for different human languages. Although the design of XML focuses on documents, the language is widely used for the representation of arbitrary data structures such as those used in web services.Example: 
html
<?xml version = "1.0"?><contactinfo>    <address category = "college">        <name>G4G</name>        <College>Geeksforgeeks</College>        <mobile>2345456767</mobile>    </address></contactinfo>
Output: 
G4G
Geeksforgeeks
2345456767
Difference between HTML and XML: There are many differences between HTML and XML. These important differences are given below: 
XML document size is relatively large as the approach of formatting
and the codes both are lengthy.
Additional application is not required for parsing of
JavaScript code into the HTML document.
DOM(Document Object Model) is required for parsing JavaScript
codes and mapping of text.
anshitaagarwal
shalinipriya1011
siddharthredhu01
HTML and XML
Difference Between
HTML
Web Technologies
HTML
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
Difference Between Method Overloading and Method Overriding in Java
Difference between Process and Thread
Difference between Clustered and Non-clustered index
Differences between IPv4 and IPv6
How to update Node.js and NPM to next version ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
REST API (Introduction)
Hide or show elements in HTML using display property
Node.js v8.serialize() Method

28 Jul, 2020
The v8.serialize() method is an inbuilt application programming interface of the v8 module which is used to serialize any type of data into a buffer using default serializer.
Syntax:
v8.serialize(value);
Parameters: This method one parameter as described below and mentioned above.
value: This is a required parameter, refers to any type of data to be serialized by default serializer
Return Value: This method returns a buffer containing serialized data of the passed value.
Below examples illustrate the use of v8.serialize() method in Node.js.
Example 1: Filename: index.js
// Accessing v8 moduleconst v8 = require('v8');  // Calling v8.serialize() console.log(v8.serialize("geeksforgeeks"));
Run index.js file using the following command:
node index.js
Output:
<Buffer ff 0d 22 0d 67 65 65 6b 73 66 6f 72 67 65 65 6b 73>

Example 2: Filename: index.js
// Accessing v8 moduleconst v8 = require('v8');  // Calling v8.serialize() serialized_data = v8.serialize("abcdefg");console.log("\nSerialized data is ");console.log(serialized_data);  serialized_data = v8.serialize(58375693);console.log("\nSerialized data is ");console.log(serialized_data);  serialized_data = v8.serialize(73847.0234);console.log("\nSerialized data is ");console.log(serialized_data);  serialized_data = v8.serialize('\n');console.log("\nSerialized data is ");console.log(serialized_data);
Run index.js file using the following command:
node index.js
Output:
Serialized data is
<Buffer ff 0d 22 07 61 62 63 64 65 66 67>

Serialized data is
<Buffer ff 0d 49 9a f8 d5 37>

Serialized data is
<Buffer ff 0d 4e ac ad d8 5f 70 07 f2 40>

Serialized data is
<Buffer ff 0d 22 01 0a>

Reference: https://nodejs.org/api/v8.html#v8_v8_serialize_value
Node.js-V8-Module
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
What happens if we does not initialize variables of an interface in java?

In Java final is the access modifier which can be used with a filed class and a method.
When a method if final it cannot be overridden.
When a variable is final its value cannot be modified further.
When a class is finale it cannot be extended.
If you declare a variable as final, it is mandatory to initialize it before the end of the constructor. If you don’t you will get a compilation error.
In the following java program, we a have an interface with a public, static, final variable with name num and, a public, abstract method with name demo.
public interface MyInterface {
   public static final int num;
   public abstract void demo();
}
On compiling, the above program generates the following error.
MyInterface.java:2: error: = expected
   public static final int num;
^
1 error
MFC - Progress Bars

Besides the Progress control, Visual C++ provides two other progress-oriented controls −
The Microsoft Progress Control Version 5.0
The Microsoft Progress Control Version 6.0
The main difference is in their ability to assume one or two orientations.
Let us look into a simple example.
Step 1 − Right-click on the dialog in the designer window.
Step 2 − Select Insert ActiveX Control.
Step 3 − Select the Microsoft ProgressBar Control 6.0 and click OK
Step 4 −  Select the progress bar and set its Orientation in the Properties Window to 1 – ccOrientationVertical
Step 5 − Add control variable for Progress bar.
Step 6 − Add the following code in the OnInitDialog()
m_progBarCtrl.SetScrollRange(0,100,TRUE); 
m_progBarCtrl.put_Value(53); 
Step 7 − Run this application again and you will see the progress bar in Vertical direction as well.
 Print
 Add Notes
 Bookmark this page
Redis - Set Srandmember Command

Redis SRANDMEMBER command is used to get a random member from set stored at specified key. If called with the additional count argument, return an array of count distinct elements if count is positive. If called with a negative count the behavior changes and the command is allowed to return the same element multiple times. In this case the numer of returned elements is the absolute value of the specified count.
String reply, without the additional count argument. The command returns a Bulk Reply with the randomly selected element, or nil when the key does not exist. Array reply, when the additional count argument is passed the command returns an array of elements, or an empty array when the key does not exist.
Following is the basic syntax of Redis SRANDMEMBER command.
redis 127.0.0.1:6379> SRANDMEMBER KEY [count] 

redis 127.0.0.1:6379> SADD myset1 "hello" 
(integer) 1 
redis 127.0.0.1:6379> SADD myset1 "world" 
(integer) 1 
redis 127.0.0.1:6379> SADD myset1 "bar" 
(integer) 1 
redis 127.0.0.1:6379> SRANDMEMBER myset1 
"bar" 
redis 127.0.0.1:6379> SRANDMEMBER myset1 2 
1) "Hello" 
2) "world"


    22 Lectures 
     40 mins

 Skillbakerystudios
 Print
 Add Notes
 Bookmark this page
Python 3 - Tkinter tkMessageBox

The tkMessageBox module is used to display message boxes in your applications. This module provides a number of functions that you can use to display an appropriate message.
Some of these functions are showinfo, showwarning, showerror, askquestion, askokcancel, askyesno, and askretryignore.
Here is the simple syntax to create this widget −
tkMessageBox.FunctionName(title, message [, options])

FunctionName − This is the name of the appropriate message box function.
FunctionName − This is the name of the appropriate message box function.
title − This is the text to be displayed in the title bar of a message box.
title − This is the text to be displayed in the title bar of a message box.
message − This is the text to be displayed as a message.
message − This is the text to be displayed as a message.
options − options are alternative choices that you may use to tailor a standard message box. Some of the options that you can use are default and parent. The default option is used to specify the default button, such as ABORT, RETRY, or IGNORE in the message box. The parent option is used to specify the window on top of which the message box is to be displayed.
options − options are alternative choices that you may use to tailor a standard message box. Some of the options that you can use are default and parent. The default option is used to specify the default button, such as ABORT, RETRY, or IGNORE in the message box. The parent option is used to specify the window on top of which the message box is to be displayed.
You could use one of the following functions with dialogue box −
showinfo()
showinfo()
showwarning()
showwarning()
showerror ()
showerror ()
askquestion()
askquestion()
askokcancel()
askokcancel()
askyesno ()
askyesno ()
askretrycancel ()
askretrycancel ()
Try the following example yourself −
# !/usr/bin/python3
from tkinter import *

from tkinter import messagebox

top = Tk()
top.geometry("100x100")
def hello():
   messagebox.showinfo("Say Hello", "Hello World")

B1 = Button(top, text = "Say Hello", command = hello)
B1.place(x = 35,y = 50)

top.mainloop()
When the above code is executed, it produces the following result −

    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
Using Python to Connect to a GraphQL API | by Melvynn Fernandez | Towards Data Science

Let’s automate and remove the margin for error, trying to get rid of the front end one step at a time.
What exactly is GraphQL?GraphQL in its simplest terms a query language used for the front end. We send a request and retrieve certain data back. GraphQL is also advanced enough to make changes in the data called mutations. But that requires a whole new article to explain.
So the main reason I wanted to connect to GraphQL directly is because we have a web application where we must manually fill in fields one by one. Not the most effective use of my time if we know it’s repetitive.
The old method I used was thru Selenium, which also caused room for error whenever front end engineers made some changes. So I did some research and decided why not just send the data directly thru GraphQL. I still grab data from SalesForce, I have an article showing you how to do that here. I would then process all that data and send to the GraphQL endpoint.
But I am getting sidetracked, let’s connect to GraphQL using Python and get some data back!
Getting StartedAssuming you already have Python installed the main modules you need are:1. requests (used to connect to GraphQL)2. json (used to parse GraphQL data)3. pandas (used for visibility of our data)
Let’s import these modules into a new Python script.
import requestsimport jsonimport pandas as pd
For tutorial purposes, we will connect to a GraphQL endpoint that does not require authentication. We will connect to a Rick and Morty GraphQL API!
Let’s start with something simple, a dataset of characters will do. The information I want from each of them is the name, status, species, type and gender. We can set this GraphQL query as a string and set it as a variable like this:
query = """query {    characters {    results {      name      status      species      type      gender    }  }}"""
The people who made this made it really easy for us to connect. We get a limit of 10000 requests per day, so use them sparingly. The next few lines of code we set the URL, send the request to them aka the query. If successful we should get a status_code of 200 and text in the format of a string.
url = 'https://rickandmortyapi.com/graphql/'r = requests.post(url, json={'query': query})print(r.status_code)print(r.text)
The r.text is in the format of a string. This is where the module json comes in. Let’s transform this string to a JSON format so we can move it to a DataFrame.
json_data = json.loads(r.text)
We only want name, status, species, type, and gender. So before we push it to a DataFrame, since it is a nested JSON we want to move further into the nest. Now we can send it to be translated to a DataFrame. We can do that with the following code:
df_data = json_data[‘data’][‘characters’][‘results’]df = pd.DataFrame(df_data)
Our DataFrame should now look like this.
Now that is has been transferred to a pandas DataFrame the possibilities are endless!
Access to my code here!
I also have tutoring and career guidance available here!
Don’t forget to connect with me on LinkedIn if you guys have any questions, comments or concerns!
How to remove all non-printable characters in a string in PHP? - GeeksforGeeks

07 May, 2019
Given a string which contains printable and not-printable characters. The task is to remove all non-printable characters from the string. Space ( ) is first printable char and tilde (~) is last printable ASCII characters. So the task is to replace all characters which do fall in that range means to take only those char which occur in range(32-127). This task is done by only differents type regex expression.
Example:
Input: str = "\n\nGeeks \n\n\n\tfor Geeks\n\t"
Output: Geeks for Geeks

Note: Newline (\n) and tab (\t) are commands not printable character.
Method 1: Using general regular expression: There are many regex available. The best solution is to strip all non-ASCII characters from the input string, that can be done with this preg_replace.
Example:
<?PHP// PHP program to remove all non-printable// character from string  // String with non printable characters$str = "Geeks šžfor ÂGee\tks\n";  // Using preg_replace method to remove all // non-printable character from string$str = preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $str);  // Display the modify stringecho($str);  ?>
Geeks for Geeks

Method 2: Use the ‘print’ regex: Other possible solution is to use the print regular expression. The [:print:] regular expression stands for “any printable character”.
Example:
   <?PHP// PHP program to remove all non-printable// character from string  // String with non printable char$str = "Geeks šžfor ÂGee\tks\n";  // Using preg_replace method to remove all // non-printable character from string$str = preg_replace('/[[:^print:]]/', '', $str);  // Display modify stringecho($str);  ?>
Geeks for Geeks

Picked
PHP
PHP Programs
Web Technologies
Web technologies Questions
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Insert Form Data into Database using PHP ?
How to convert array to string in PHP ?
How to check whether an array is empty using PHP?
Comparing two dates in PHP
How to receive JSON POST with PHP ?
How to Insert Form Data into Database using PHP ?
How to convert array to string in PHP ?
How to call PHP function on the click of a Button ?
How to check whether an array is empty using PHP?
Comparing two dates in PHP