code-rag-bench/online-tutorials huggingface dataset:
How to select record from last 6 months in a news table using MySQL?

To select the last 6 months records from news table, use the date_sub() function from MySQL since news records are arranged according to date.
The syntax is as follows −
select *from yourTableName where yourDateTimeColumnName >= date_sub(now(),interval 6 month);
To understand the above concept, let us first create a NEWS table with only NEWS ID and the date on which it published −
mysql> create table Newstable
   -> (
   -> NewsId int,
   -> NewsDatetime datetime
   -> );
Query OK, 0 rows affected (0.66 sec)
Insert records in the table using insert command. The query is as follows −
mysql> insert into Newstable values(101,'2018-2-10');
Query OK, 1 row affected (0.18 sec)

mysql> insert into Newstable values(102,'2018-12-10');
Query OK, 1 row affected (0.19 sec)

mysql> insert into Newstable values(103,'2018-3-14');
Query OK, 1 row affected (0.14 sec)

mysql> insert into Newstable values(104,'2018-12-12');
Query OK, 1 row affected (0.29 sec)

mysql> insert into Newstable values(105,'2018-4-21');
Query OK, 1 row affected (0.09 sec)

mysql> insert into Newstable values(106,'2018-6-30');
Query OK, 1 row affected (0.22 sec)
Display all records from the table using select statement. The query is as follows −
mysql> select *from Newstable;
+--------+---------------------+
| NewsId | NewsDatetime        |
+--------+---------------------+
|    101 | 2018-02-10 00:00:00 |
|    102 | 2018-12-10 00:00:00 |
|    103 | 2018-03-14 00:00:00 |
|    104 | 2018-12-12 00:00:00 |
|    105 | 2018-04-21 00:00:00 |
|    106 | 2018-06-30 00:00:00 |
+--------+---------------------+
6 rows in set (0.00 sec)
The following is the query to select last 6 months from the new table. The query is as follows −
mysql> select *from Newstable where NewsDatetime > date_sub(now(),Interval 6 month);
+--------+---------------------+
| NewsId | NewsDatetime        |
+--------+---------------------+
|    102 | 2018-12-10 00:00:00 |
|    104 | 2018-12-12 00:00:00 |
|    106 | 2018-06-30 00:00:00 |
+--------+---------------------+
3 rows in set (0.00 sec)
Design and Analysis Quick Sort

It is used on the principle of divide-and-conquer. Quick sort is an algorithm of choice in many situations as it is not difficult to implement. It is a good general purpose sort and it consumes relatively fewer resources during execution.
It is in-place since it uses only a small auxiliary stack.
It is in-place since it uses only a small auxiliary stack.
It requires only n (log n) time to sort n items.
It requires only n (log n) time to sort n items.
It has an extremely short inner loop.
It has an extremely short inner loop.
This algorithm has been subjected to a thorough mathematical analysis, a very precise statement can be made about performance issues.
This algorithm has been subjected to a thorough mathematical analysis, a very precise statement can be made about performance issues.
It is recursive. Especially, if recursion is not available, the implementation is extremely complicated.
It is recursive. Especially, if recursion is not available, the implementation is extremely complicated.
It requires quadratic (i.e., n2) time in the worst-case.
It requires quadratic (i.e., n2) time in the worst-case.
It is fragile, i.e. a simple mistake in the implementation can go unnoticed and cause it to perform badly.
It is fragile, i.e. a simple mistake in the implementation can go unnoticed and cause it to perform badly.
Quick sort works by partitioning a given array A[p ... r] into two non-empty sub array A[p ... q] and A[q+1 ... r] such that every key in A[p ... q] is less than or equal to every key in A[q+1 ... r].
Then, the two sub-arrays are sorted by recursive calls to Quick sort. The exact position of the partition depends on the given array and index q is computed as a part of the partitioning procedure.
Algorithm: Quick-Sort (A, p, r) 
if p < r then 
   q Partition (A, p, r) 
   Quick-Sort (A, p, q) 
   Quick-Sort (A, q + r, r) 

Note that to sort the entire array, the initial call should be Quick-Sort (A, 1, length[A])
As a first step, Quick Sort chooses one of the items in the array to be sorted as pivot. Then, the array is partitioned on either side of the pivot. Elements that are less than or equal to pivot will move towards the left, while the elements that are greater than or equal to pivot will move towards the right.
Partitioning procedure rearranges the sub-arrays in-place.
Function: Partition (A, p, r) 
x ← A[p] 
i ← p-1 
j ← r+1 
while TRUE do 
   Repeat j ← j - 1 
   until A[j] ≤ x  
   Repeat i← i+1 
   until A[i] ≥ x  
   if i < j then  
      exchange A[i] ↔ A[j] 
   else  
      return j 

The worst case complexity of Quick-Sort algorithm is O(n2). However using this technique, in average cases generally we get the output in O(n log n) time.

    102 Lectures 
     10 hours 

 Arnab Chakraborty

    30 Lectures 
     3 hours 

 Arnab Chakraborty

    31 Lectures 
     4 hours 

 Arnab Chakraborty

    43 Lectures 
     1.5 hours 

 Manoj Kumar

    7 Lectures 
     1 hours 

 Zach Miller

    54 Lectures 
     4 hours 

 Sasha Miller
 Print
 Add Notes
 Bookmark this page
HTML Computer Code Elements

To display computer codes on the web page, some elements are provided in HTML. Let us see those elements one by one −
<kbd>
<pre>
<code>
<var>
<samp>
The <kbd> tag is used to define the keyboard input. Use this when you want the user to type on their keyboard, for example, shortcut keys Ctrl+C for copy, Esc for exit, etc.
Let us now see an example to implement the <kbd> tag −
 Live Demo
<!DOCTYPE html>
<html>
<body>
<h2>Shortcut Keys</h2>
<p>Use the following shortcut keys −</p>
<p><strong>Cut</strong> − <kbd>CTRL</kbd>+<KBD>X</kbd></p>
<p><strong>Copy</strong> − <kbd>CTRL</kbd>+<KBD>C</kbd></p>
<p><strong>Paste</strong> − <kbd>CTRL</kbd>+<KBD>V</kbd></p>
<p><strong>Undo</strong> − <kbd>CTRL</kbd>+<KBD>Z</kbd></p>
</body>
</html>
The <pre> tag in HTML is used to set preformatted text. The text in it preserved spaces and line breaks i.e. the text appears the same in the web page as it is added under the HTML code. Let us now see an example to implement the <pre> tag −
 Live Demo
<!DOCTYPE html>
<html>
<body>
<h2>Demo Heading</h2>
<pre>
   This is a demo text
   and will appear
   in the same format as
   it
   is visible
   here. The pre tag displays
   the text in a fixed-width
   font. It preserves
   both spaces and
   line breaks as you can see
   here.
</pre>
</body>
</html>
The <code> tag is used to format code in an HTML document. For example, if you want to write Java code and format it properly, then use the <code> element in HTML. Let us now see an example to implement the <code> element in HTML −
 Live Demo
<!DOCTYPE html>
<html>
<body>
<h1>Header Files</h1>
<h2>C++</h2>
<code>
   #include <iostream>
</code>
<h2>C</h2>
<code>
   #include <stdio>
</code>
</body>
</html>
The <var> element in HTML is used to display mathematical expression for calculations.
Let us now see an example to implement the <var> tag in HTML −
 Live Demo
<!DOCTYPE html>
<html>
<body>
<h2>Mathematical Equation</h2>
Sample equation − <var>2x</var> - <var>2z</var> = <var>3y</var> + 9
</body>
</html>
The <samp> tag in HTML is a phrase tag like <em>, <code>, <strong>, etc and is used to format text in an HTML document.
Let us now see an example to implement the <samp> element −
 Live Demo
<!DOCTYPE html>
<html>
<body>
<h2>Exam Results</h2>
<p>
Result would be announced on 6th June.
</p>
<samp>New date for results are 7th June.</samp>
</body>
</html>
Groovy - endsWith()

Tests whether this string ends with the specified suffix.
Boolean endsWith(String suffix)

Suffix – The suffix to search for
Suffix – The suffix to search for
This method returns true if the character sequence represented by the argument is a suffix of the character sequence represented by this object; false otherwise. Note that the result will be true if the argument is the empty string or is equal to this String object as determined by the equals(Object) method.
Following is an example of the usage of this method −
class Example {
   static void main(String[] args) {
      String s = "HelloWorld";
		
      println(s.endsWith("ld"));
      println(s.endsWith("lo"));
      println("Hello".endsWith("lo"));
   } 
} 
When we run the above program, we will get the following result −
true
false 
true 


    52 Lectures 
     8 hours 

 Krishna Sakinala

    49 Lectures 
     2.5 hours 

 Packt Publishing
 Print
 Add Notes
 Bookmark this page
How can I remove all elements except the first one using jQuery?

To remove all elements except the first one, use the remove() method with the slice() method in jQuery. You can try to run the following code to remove all elements except for first one using jQuery −
Live Demo
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $(".button1").click(function(){
        $("span").remove();
    });
   
     $(".button2").click(function(){
         $('span').slice(1).remove();
     });
     
  });
</script>
</head>
<body>
<button class="button2">Hide all, except first element</button>
<button class="button1">Hide all the elements</button>

<span>
<p>This is demo text.</p>
<p>This is demo text.</p>
</span>
<span>
<p>This is demo text.</p>
<p>This is demo text.</p>
</span>
<span>
<p>This is demo text.</p>
<p>This is demo text.</p>
</span>

</body>
</html>
Animate CSS border-bottom property

To implement animation on the border-bottom property with CSS, you can try to run the following code:
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <style>
         div {
            width: 500px;
            height: 400px;
            background: yellow;
            border: 5px dashed yellow;
            background-image: url('https://www.tutorialspoint.com/latest/microservice_architecture.png');
            animation: myanim 3s infinite;
            background-position: bottom left;
            background-size: 50px;
         }
         @keyframes myanim {
            20% {
               background-color: maroon;
               background-position: bottom right;
               background-size: 90px;
               border-bottom: 25px solid orange;
            }
         }
      </style>
   </head>
   <body>
      <h2>Performing Animation for bottom border</h2>
      <div></div>
   </body>
</html>
How to convert JSON to Java Map Object - onlinetutorialspoint

PROGRAMMINGJava ExamplesC Examples
Java Examples
C Examples
C Tutorials
aws
JAVAEXCEPTIONSCOLLECTIONSSWINGJDBC
EXCEPTIONS
COLLECTIONS
SWING
JDBC
JAVA 8
SPRING
SPRING BOOT
HIBERNATE
PYTHON
PHP
JQUERY
PROGRAMMINGJava ExamplesC Examples
Java Examples
C Examples
C Tutorials
aws
Here I am going to show you how to convert a JSON to Java Map object using Jackson.
In the previous tutorials we have seen how to convert a Java object to JSON string, you can see the required Jackson dependencies there.
Here I am going to create a JSON string and convert it into Java’s java.util.Map object.
[java]
package com.onlinetutorialspoint.json;
import java.util.HashMap;
import java.util.Map;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference;
public class JSON_String_TO_Map {
    public static void main(String[] a) {
        ObjectMapper mapperObj = new ObjectMapper();
        Map<String,String> jsonMap = new HashMap<String,String>();
        try {
            jsonMap = mapperObj.readValue(jsonString(),
                    new TypeReference<HashMap<String,String>>(){});
            System.out.println(jsonMap);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    public static String jsonString() {
        String str = "{\"studentId\": 1001, \"studentName\": \"Rajesh\","
                + "\"roleNumber\": \"106\",\"standard\": \"11th\"}";
        return str;
    }
}
[/java]
Output:
{studentId=1001, standard=11th, studentName=Rajesh, roleNumber=106}
Happy Learning 🙂

How to convert Java Object to JSON
How to convert JSON to Java Object Example
How to convert Java Map to JSON
Java program to Convert Ordinary Number to Roman
How to Convert Iterable to Stream Java 8
Java 8 How to convert Stream to List
How to Format JSON Output PrettyPrinter Example
How to Convert Java String to Int
How to Convert Java Int to String
4 ways to create an Object in Java
Java how to convert ArrayList to Array Example
How to convert Timestamp to Date in Java
JAXB XML to Java Object Conversion Example
JAXB Java Object to XML Conversion Example
Java – How to read CSV file and Map to Java Object

How to convert Java Object to JSON
How to convert JSON to Java Object Example
How to convert Java Map to JSON
Java program to Convert Ordinary Number to Roman
How to Convert Iterable to Stream Java 8
Java 8 How to convert Stream to List
How to Format JSON Output PrettyPrinter Example
How to Convert Java String to Int
How to Convert Java Int to String
4 ways to create an Object in Java
Java how to convert ArrayList to Array Example
How to convert Timestamp to Date in Java
JAXB XML to Java Object Conversion Example
JAXB Java Object to XML Conversion Example
Java – How to read CSV file and Map to Java Object
BigInteger gcd() Method in Java with Examples - GeeksforGeeks

04 Apr, 2019
GCD (Greatest Common Divisor) or HCF (Highest Common Factor) of two numbers is the largest number that divides both of them. The java.math.BigInteger.gcd(BigInteger val) method is used to calculate gcd of two BigIntegers. This method calculates gcd upon the current BigInteger by which this method is called and BigInteger passed as parameter
Syntax:
public BigInteger gcd(BigInteger val)

Parameters: This method accepts a parameter val which is one of the numbers out of two whose gcd is to be calculated. The number should be of BigInteger type.
Return value: This method returns a BigInteger which holds the calculated gcd of two BigIntegers.
Below program is used to illustrate the gcd() method of BigInteger.
Example 1:
// Java program to demonstrate// gcd() method of BigInteger  import java.math.BigInteger;  public class GFG {    public static void main(String[] args)    {          // BigInteger object to store the result        BigInteger result;          // For user input        // Use Scanner or BufferedReader          // Two objects of String created        // Holds the values to calculate gcd        String input1 = "54";        String input2 = "42";          // Creating two BigInteger objects        BigInteger a            = new BigInteger(input1);        BigInteger b            = new BigInteger(input2);          // Calculate gcd        result = a.gcd(b);          // Print result        System.out.println("The GCD of "                           + a + " and "                           + b + " is "                           + result);    }}
The GCD of 54 and 42 is 6

Example 2:
// Java program to demonstrate// gcd() method of BigInteger  import java.math.BigInteger;  public class GFG {    public static void main(String[] args)    {          // BigInteger object to store result        BigInteger result;          // For user input        // Use Scanner or BufferedReader          // Two objects of String        // Holds the values to calculate gcd        String input1 = "4095484568135646548";        String input2 = "9014548534231345454";          // Creating two BigInteger objects        BigInteger a            = new BigInteger(input1);        BigInteger b            = new BigInteger(input2);          // Calculate gcd        result = a.gcd(b);          // Print result        System.out.println("The GCD of "                           + a + " and "                           + b + " is "                           + result);    }}
The GCD of 4095484568135646548 and 9014548534231345454 is 2
Reference: https://docs.oracle.com/en/java/javase/12/docs/api/java.base/java/math/BigInteger.html#gcd(java.math.BigInteger)
Java-BigInteger
Java-Functions
Java-math-package
Java
Java-BigInteger
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Constructors in Java
Different ways of Reading a text file in Java
Exceptions in Java
Functional Interfaces in Java
Generics in Java
Comparator Interface in Java with Examples
Introduction to Java
HashMap get() Method in Java
Strings in Java
Underscore.js | _.clone() Function - GeeksforGeeks

27 Apr, 2020
The _.clone() function is used to create a shallow copy of the given object. The nested objects or arrays will be copied using reference, not duplicated.
Syntax:
_.clone( object )
Parameters: This function accept a single parameter as mentioned above and described below:
object: It contains the value of object that need to be copied.
Return Value: It returns the shallow-copy of the given object.
Below example illustrate the _.clone() function in Underscore.js:Example 1:
<!DOCTYPE html><html>  <head>    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js">    </script></head>  <body>    <script type="text/javascript">          var info = {            Company: 'GeeksforGeeks',            Address: 'Noida',            Contact: '+91 9876543210'        };          console.log(_.clone(info));    </script></body>  </html>
Output:
Example 2:
<!DOCTYPE html><html>  <head>    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js">    </script></head>  <body>    <script type="text/javascript">          var clon = _.clone({            Name: 'Ashok',            Age: 32,            Email: 'ashok@gfg.com'        });          console.log(clon);    </script></body>  </html>
Output:
JavaScript - Underscore.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Difference between var, let and const keywords in JavaScript
Convert a string to an integer in JavaScript
Differences between Functional Components and Class Components in React
How to append HTML code to a div using JavaScript ?
How to Open URL in New Tab using JavaScript ?
Top 10 Front End Developer Skills That You Need in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
How to insert an item in ArrayList in C#?

To insert an item in an already created ArrayList, use the Insert() method.
Firstly, set elements −
ArrayList arr = new ArrayList();

arr.Add(45);
arr.Add(78);
arr.Add(33);
Now, let’s say you need to insert an item at 2nd position. For that, use the Insert() method −
// inserting element at 2nd position
arr.Insert(1, 90);
Let us see the complete example −
 Live Demo
using System;
using System.Collections;

namespace Demo {
   public class Program {
      public static void Main(string[] args) {
         ArrayList arr = new ArrayList();

         arr.Add(45);
         arr.Add(78);
         arr.Add(33);
         Console.WriteLine("Count: {0}", arr.Count);
         Console.Write("ArrayList: ");

         foreach(int i in arr) {
            Console.Write(i + " ");
         }

         // inserting element at 2nd position
         arr.Insert(1, 90);
         Console.Write("\nArrayList after inserting a new element: ");

         foreach(int i in arr) {
            Console.Write(i + " ");
         }
         Console.WriteLine("\nCount: {0}", arr.Count);
      }
   }
}
Count: 3
ArrayList: 45 78 33
ArrayList after inserting a new element: 45 90 78 33
Count: 4
Python Mahotas – Introduction

09 Jun, 2021
Mahotas is a computer vision and image processing and manipulation library for Python. A library is a collection of functions and methods that allows you to perform many actions without having to write hundreds of lines of code. Mahotas includes many algorithms that operates with arrays, mahotas currently has over 100 functions for image processing and computer vision and is constantly growing.
Mahotas provides a good solution in finding patterns in the image for example “Where’s Wally Problem” can be solved easily using Mahotas.
How to install Mahotas :  
pip install mahotas
Notable algorithms available in Mahotas :1. Watershed 2. Convex points calculations. 3. Hit & miss, thinning. 4. Zernike & Haralick, LBP, and TAS features. 5. Speeded-Up Robust Features (SURF), a form of local features. 6. Thresholding. 7. Convolution. 8. Sobel edge detection. 9. Spline interpolation 10. SLIC super pixels.
Example 1: Loading Image  
Python3
# importing required librariesimport numpy as npimport mahotasimport pylab # loading imageimg = mahotas.imread('dog_image.png') # showing the original imageimshow(img)show()
Output :  
Example 2: Creating distance transform
Python3
# importing required librariesimport pylab as pimport numpy as npimport mahotas # creating numpy array of type boolf = np.ones((256, 256), bool) # setting false valuesf[200:, 240:] = Falsef[128:144, 32:48] = False # f is basically True with the exception of two islands:# one in the lower-right# corner, another, middle-left # creating a distance using numpy arraydmap = mahotas.distance(f) # showing imagep.imshow(dmap)p.show()
Output :  
 
arorakashish0911
Image-Processing
Python-Mahotas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Opacity Widget in Flutter - GeeksforGeeks

02 Sep, 2020
The Opacity widget that makes its child partially transparent. This class colors its child into an intermediate buffer and then merges the child back into the scene partially transparent. For values of opacity other than 0.0 and 1.0, this class is relatively expensive as it needs coloring the child into an intermediate buffer. For the value 0.0, the child is simply not colored at all. For the value 1.0, the child is colored without an intermediate buffer.
Syntax:
Opacity({Key key,
@required double opacity, 
bool alwaysIncludeSemantics: false, 
Widget child})
child: The widgets below this widget in the tree.
hashCode: The hash code for this object.
key: Controls how one widget replaces another widget in the tree.
runtimeType: A representation of the runtime type of the object.
opacity: The fraction to scale the child’s alpha value.
Example:
The image in the below app has 0.5 opacity.
Dart
import 'package:flutter/material.dart';  void main() {  runApp(MyApp());}  class MyApp extends StatelessWidget {  // This widget is  //the root of your application.  @override  Widget build(BuildContext context) {    return MaterialApp(      title: 'ClipOval',      theme: ThemeData(        primarySwatch: Colors.blue,      ),      home: MyHomePAGE(),      debugShowCheckedModeBanner: false,    );  }}  class MyHomePAGE extends StatefulWidget {  @override  _MyHomePAGEState createState() => _MyHomePAGEState();}  class _MyHomePAGEState extends State<MyHomePAGE> {  @override  Widget build(BuildContext context) {    return Scaffold(      appBar: AppBar(        title: Text('GeeksforGeeks'),        backgroundColor: Colors.green,      ),      body: Center(          child: Image.network(              'https://raw.githubusercontent.com/flutter/assets-for-api-docs/master/packages/diagrams/assets/blend_mode_destination.jpeg',              color: Color.fromRGBO(255, 255, 255, 0.5),              colorBlendMode: BlendMode.modulate          )      ),      backgroundColor: Colors.lightBlue[50],    );  }}  class MyClip extends CustomClipper<Rect> {  Rect getClip(Size size) {    return Rect.fromLTWH(0, 0, 100, 100);  }    bool shouldReclip(oldClipper) {    return false;  }}
Output:
First initialize the main app as a stateless widget.Second design the main widget as you desire.Build the Appbar with the scaffold widget.Now use the Image.Network widget inside the body of the the scaffold widget.Finally, set the opacity using colorBlendMode.
First initialize the main app as a stateless widget.
Second design the main widget as you desire.
Build the Appbar with the scaffold widget.
Now use the Image.Network widget inside the body of the the scaffold widget.
Finally, set the opacity using colorBlendMode.
android
Flutter
Flutter-widgets
Dart
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Flutter - DropDownButton Widget
Flutter - Custom Bottom Navigation Bar
Flutter - Checkbox Widget
ListView Class in Flutter
Flutter - Flexible Widget
Flutter - BoxShadow Widget
Flutter - Stack Widget
Operators in Dart
Flutter - Dialogs
Flutter - File Structure
Change collection name in MongoDB?

Use use renameCollection() to change collection name in MongoDB. Following is the syntax
db.yourOldCollectionName.renameCollection("yourNewCollectionName");
Let us create a collection with documents. Following is the query
> db.savingInformationDemo.insertOne({"StudentName":"Larry"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c9cb44da629b87623db1b07")
}
> db.savingInformationDemo.insertOne({"StudentName":"John"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c9cb45da629b87623db1b08")
}
> db.savingInformationDemo.insertOne({"StudentName":"Mike"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c9cb461a629b87623db1b09")
}
> db.savingInformationDemo.insertOne({"StudentName":"Sam"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c9cb465a629b87623db1b0a")
}
Following is the query to display all documents from a collection with the help of find() method
> db.savingInformationDemo.find().pretty();
This will produce the following output
{ "_id" : ObjectId("5c9cb44da629b87623db1b07"), "StudentName" : "Larry" }
{ "_id" : ObjectId("5c9cb45da629b87623db1b08"), "StudentName" : "John" }
{ "_id" : ObjectId("5c9cb461a629b87623db1b09"), "StudentName" : "Mike" }
{ "_id" : ObjectId("5c9cb465a629b87623db1b0a"), "StudentName" : "Sam" }
Following is the query to change collection name in MongoDB
> db.savingInformationDemo.renameCollection("saveStudentInformation");
This will produce the following output
{ "ok" : 1 }
Following is the query to check the documents are displayed with new collection name or not
> db.saveStudentInformation.find();
This will produce the following output
{ "_id" : ObjectId("5c9cb44da629b87623db1b07"), "StudentName" : "Larry" }
{ "_id" : ObjectId("5c9cb45da629b87623db1b08"), "StudentName" : "John" }
{ "_id" : ObjectId("5c9cb461a629b87623db1b09"), "StudentName" : "Mike" }
{ "_id" : ObjectId("5c9cb465a629b87623db1b0a"), "StudentName" : "Sam" }
How to Create Custom Class in Java? - GeeksforGeeks

20 Jul, 2021
Class is the collection of objects. Class is not a real-world entity it is just only templates and prototypes or blueprints. Class does not occupy memory. We can write a custom class as per our choice for an illustration purpose a sample is shown in the program below as a helper class.
Example:
Java
// Java Program to Creating our Own Custom Class // Importing input output classesimport java.io.*; // Class 1// Helper classclass Employee {     // Member variables of this class     // first attribute    int id;    // second attribute    int salary;    // third attribute    String name;     // Member function of this class     // Method 1    public void printDetails()    {        // Print and display commands        System.out.println("My id is " + id);        System.out.println("This is my name " + name);    }     // Method 2    public int getSalary()    {         // Simply returning the salary        return salary;    }} // Class 2// Main classclass Custom {     // Main driver method    public static void main(String[] args)    {         // Display message only        System.out.println("This is the custom class");         // Creating object of custom class in the main()        // method Instantiating a new Employee object        Employee harry = new Employee();         // Again creating object of custom class and        // instantiating a new Employee object        Employee robin = new Employee();         // Initializing values for first object created        // above        harry.id = 23;        harry.salary = 100000;        harry.name = "Ritu bhatiya";         // Initializing values for second object created        // above        robin.id = 25;        robin.salary = 150000;        robin.name = "Amit thripathi";         // Printing object attributes by        // calling the method as defined in our class        harry.printDetails();        robin.printDetails();         // Calling the method again of our class and        // storing it in a variable        int salary = robin.getSalary();         // Print and display the above salary        System.out.println("Salary of robin : " + salary                           + "$");         System.out.println("ID : " + harry.id);    }}
  
This is the custom class
My id is 23
This is my name Ritu bhatiya
My id is 25
This is my name Amit thripathi
Salary of robin : 150000$
ID : 23
 
sagartomar9927
Java-Class and Object
Java
Java-Class and Object
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Constructors in Java
Exceptions in Java
Functional Interfaces in Java
Different ways of Reading a text file in Java
Generics in Java
Introduction to Java
Comparator Interface in Java with Examples
PriorityQueue in Java
How to remove an element from ArrayList in Java?
Python | Scipy integrate.romberg() method - GeeksforGeeks

23 Jan, 2020
With the help of scipy.integrate.romberg() method, we can get the romberg integration of a callable function from limit a to b by using scipy.integrate.romberg() method.
Syntax : scipy.integrate.romberg(func, a, b)Return : Return the romberg integrated value of a callable function.
Example #1 :In this example we can see that by using scipy.integrate.romberg() method, we are able to get the romberg integration of a callable function from limit a to b by using scipy.integrate.romberg() method.
# import numpy and scipy.integrateimport numpy as npfrom scipy import integrategfg = lambda x: np.exp(-x**2)  # using scipy.integrate.romberg()geek = integrate.romberg(gfg, 0, 3, show = True)  print(geek)
Output :
Romberg integration of <function vectorize1..vfunc at 0x00000209C3641EA0> from [0, 3]

 Steps  StepSize   Results
     1  3.000000  1.500185
     2  1.500000  0.908191  0.710860
     4  0.750000  0.886180  0.878843  0.890042
     8  0.375000  0.886199  0.886206  0.886696  0.886643
    16  0.187500  0.886205  0.886207  0.886207  0.886200  0.886198
    32  0.093750  0.886207  0.886207  0.886207  0.886207  0.886207  0.886207
    64  0.046875  0.886207  0.886207  0.886207  0.886207  0.886207  0.886207  0.886207
   128  0.023438  0.886207  0.886207  0.886207  0.886207  0.886207  0.886207  0.886207  0.886207

The final result is 0.8862073482595311 after 129 function evaluations.

Example #2 :
# import numpy and scipy.integrateimport numpy as npfrom scipy import integrategfg = lambda x: np.exp(-x**2) + 1 / np.sqrt(np.pi)  # using scipy.integrate.romberg()geek = integrate.romberg(gfg, 1, 2, show = True)  print(geek)
Output :
Romberg integration of <function vectorize1..vfunc at 0x00000209E1605400> from [1, 2]

 Steps  StepSize   Results
     1  1.000000  0.757287
     2  0.500000  0.713438  0.698822
     4  0.250000  0.702909  0.699400  0.699438
     8  0.125000  0.700310  0.699444  0.699447  0.699447
    16  0.062500  0.699663  0.699447  0.699447  0.699447  0.699447
    32  0.031250  0.699501  0.699447  0.699447  0.699447  0.699447  0.699447

The final result is 0.6994468414978009 after 33 function evaluations.

Python-scipy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Iterate over a list in Python
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to convert std::string to lower case in C++?

In this section, we will see how to convert all letters of a C++ string to lowercase letters. To do this thing we have to use the transform function. This transform function is present in the algorithm library.
The transform function takes the beginning pointer of the string and the ending pointer of the string. It also takes the beginning of the string to store the result, then the fourth argument is ::tolower. This helps to convert the string into a lowercase string. We can use this same method if we want to convert some string into an uppercase string.
 Live Demo
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
   string my_str = "Hello WORLD";

   cout << "Main string: " << my_str << endl;
   transform(my_str.begin(), my_str.end(), my_str.begin(), ::tolower);

   cout << "Converted String: " << my_str;
}
Main string: Hello WORLD
Converted String: hello world
Compare two dates using JavaScript - GeeksforGeeks

23 Nov, 2021
In this article, we will compare the 2 dates in Javascript, along with understanding their implementation through the examples.
In JavaScript, we can compare two dates by converting them into numeric values to correspond to their time. First, we can convert the Date into a numeric value by using the getTime() function. By converting the given dates into numeric values we can directly compare them.
Example 1: This example illustrates the comparison of the dates using the getTime() function.
javascript
<script>     // Current Date    var g1 = new Date();    var g2 = new Date();    if (g1.getTime() === g2.getTime())        document.write("Both  are equal");    else        document.write("Not equal");    javascript: ;</script>
Output:
Both are equal
Example 2: This example illustrates the comparison of the current date with the assigned date using the getTime() function.
Javascript
<script>    var g1 = new Date();         // (YYYY-MM-DD)    var g2 = new Date(2019 - 08 - 03);    if (g1.getTime() < g2.getTime())        document.write("g1 is lesser than g2");    else if (g1.getTime() > g2.getTime())        document.write("g1 is greater than g2");    else        document.write("both are equal");</script>
Output:
g1 is greater than g2
Example 3: This example illustrates the comparison of 2 given dates using the getTime() function.
Javascript
<script>    var g1 = new Date(2019, 08, 03, 11, 45, 55);         // (YYYY, MM, DD, Hr, Min, Sec)    var g2 = new Date(2019, 08, 03, 10, 22, 42);    if (g1.getTime() < g2.getTime())        document.write("g1 is lesser than g2");    else if (g1.getTime() > g2.getTime())        document.write("g1 is greater than g2");    else        document.write("both are equal");</script>
Output:
g1 is greater than g2
JavaScript is best known for web page development but it is also used in a variety of non-browser environments. You can learn JavaScript from the ground up by following this JavaScript Tutorial and JavaScript Examples.
bhaskargeeksforgeeks
Picked
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
Differences between Functional Components and Class Components in React
How to append HTML code to a div using JavaScript ?
How to Open URL in New Tab using JavaScript ?
Roadmap to Become a Web Developer in 2022
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
\mod - Tex Command

\mathord - Used to create mod symbol.
{ \mod}
\mod command is used to draw mod symbol.

3\equiv 5 \mod 2

3≡5mod2



3\equiv 5 \mod 2

3≡5mod2


3\equiv 5 \mod 2

    14 Lectures 
     52 mins

 Ashraf Said

    11 Lectures 
     1 hours 

 Ashraf Said

    9 Lectures 
     1 hours 

 Emenwa Global, Ejike IfeanyiChukwu

    29 Lectures 
     2.5 hours 

 Mohammad Nauman

    14 Lectures 
     1 hours 

 Daniel Stern

    15 Lectures 
     47 mins

 Nishant Kumar
 Print
 Add Notes
 Bookmark this page
Structure Pointer

17 Aug, 2021
Structure Pointer: It is defined as the pointer which points to the address of the memory block that stores a structure is known as the structure pointer. Below is an example of the same:Example:
struct point
{
   int value;
};

// Driver Code
int main()
{
    struct point s;
    struct point *ptr = &s;
    return 0;
}
In the above code s is an instance of struct point and ptr is the struct pointer because it is storing the address of struct point. 
Below is the program to illustrate the above concepts:
C
C++
// C program to illustrate the// structure pointer #include <stdio.h> // Structure declaration for// verticesstruct point {    int x;    int y;}; // Structure declaration for// rectanglestruct rect {     // An object left is declared    // with 'point'    struct point left;     // An object right is declared    // with 'point'    struct point right;}; // Function to calculate area of// the given rectanglevoid areaOfRectangle(struct rect r){    // Find the area of the rectangle    // using variables of point    // structure where variables of    // point structure is accessed    // by left and right objects    int area        = (r.right.x - r.left.x)          * (r.right.y - r.left.y);     // Print the area    printf("%d", area);} // Driver Codeint main(){    // Initialize variable 'r'    // with vertices of rectangle    struct rect r = { { 0, 0 }, { 1, 1 } };     // Function Call    areaOfRectangle(r);     return 0;}
// C++ program to illustrate the// structure pointer#include <iostream>#include <stdio.h>using namespace std; // Structure declaration for// verticesstruct point {    int x;    int y;}; // Structure declaration for// rectanglestruct rect {     // An object left is declared    // with 'point'    struct point left;     // An object right is declared    // with 'point'    struct point right;}; // Function to calculate area of// the given rectanglevoid areaOfRectangle(struct rect r){    // Find the area of the rectangle    // using variables of point    // structure where variables of    // point structure is accessed    // by left and right objects    int area        = (r.right.x - r.left.x)          * (r.right.y - r.left.y);     // Print the area    cout << area;} // Driver Codeint main(){    // Initialize variable 'r'    // with vertices of rectangle    struct rect r = { { 0, 0 }, { 1, 1 } };     // Function Call    areaOfRectangle(r);     return 0;}
1
 
kalrap615
C Basics
CPP-Basics
cpp-structure
Pointers
C Language
C Programs
C++
C++ Programs
Pointers
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
TypeScript | Array sort() Method

18 Jun, 2020
The Array.sort() is an inbuilt TypeScript function which is used to sort the elements of an array. Syntax:
array.sort( compareFunction )
Parameter: This method accept a single parameter as mentioned above and described below: 
compareFunction : This parameter is the function that defines the sort order
Return Value: This method returns the sorted array. 
Below example illustrate the  Array sort() method in TypeScriptJS:Example 1: 
JavaScript
<script>    // Driver code    var arr = [ 11, 89, 23, 7, 98 ];       // use of sort() method     var val = arr.sort();           // printing    console.log( val );</script>
Output: 
[ 11, 23, 7, 89, 98 ]

Example 2: 
JavaScript
<script>    // Driver code    var arr = ["G", "e", "e", "k", "s", "f", "o", "r",                "g", "e", "e", "k", "s"];     var val;       // use of sort() method     val = arr.sort();    console.log( val );</script>
Output: 
[ 'G', 'e', 'e', 'e', 'e', 'f', 'g', 'k', 'k', 'o', 'r', 's', 's' ]

TypeScript
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C/C++ Program to Count trailing zeroes in factorial of a number

14 Jun, 2022
Given an integer n, write a function that returns count of trailing zeroes in n!.  Examples :
Input: n = 5
Output: 1 
Factorial of 5 is 120 which has one trailing 0.

Input: n = 20
Output: 4
Factorial of 20 is 2432902008176640000 which has
4 trailing zeroes.

Input: n = 100
Output: 24
Trailing 0s in n! = Count of 5s in prime factors of n!
                  = floor(n/5) + floor(n/25) + floor(n/125) + ....
C++
// C++ program to count// trailing 0s in n!#include <iostream>using namespace std; // Function to return trailing// 0s in factorial of nint findTrailingZeros(int n){    // Initialize result    int count = 0;     // Keep dividing n by powers of    // 5 and update count    for (int i = 5; n / i >= 1; i *= 5)        count += n / i;     return count;} // Driver Codeint main(){    int n = 100;    cout << "Count of trailing 0s in " << 100         << "! is " << findTrailingZeros(n);    return 0;}
Count of trailing 0s in 100! is 24
Time Complexity: O(log5n)
Auxiliary Space: O(1)
Please refer complete article on Count trailing zeroes in factorial of a number for more details!
chandramauliguptach
C Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PostgreSQL – CTE

28 Aug, 2020
In PostgreSQL, the CTE(Common Table Expression) is used as a temporary result set that the user can reference within another SQL statement like SELECT, INSERT, UPDATE or DELETE. CTEs are temporary in the sense that they only exist during the execution of the query. CTEs are typically used to simplify complex joins and subqueries in PostgreSQL.
Syntax:
WITH cte_name (column_list) AS (
    CTE_query_definition 
)
statement;
Let’s analyze the above syntax.
The first step is to set the name of the CTE followed by an optional column list.
Then we specify a query that returns the result set within the body of WITH clause. if not specified explicitly then the select list of the CTE_query_definition will become the column list of the CTE.
Finally use the CTE like a table or view in the statement which can be a SELECT, INSERT, UPDATE, or DELETE.
For examples we will be using the sample database (ie, dvdrental).
Example 1:In this, we will define a common table expression named cte_film using the WITH clause with the film and rental table as follows to determine the length of the films.
WITH cte_film AS (
    SELECT 
        film_id, 
        title,
        (CASE 
            WHEN length < 30 THEN 'Short'
            WHEN length < 90 THEN 'Medium'
            ELSE 'Long'
        END) length    
    FROM
        film
)
SELECT
    film_id,
    title,
    length
FROM 
    cte_film
WHERE
    length = 'Long'
ORDER BY 
    title;
Output:
Example 2:The following statement illustrates the use of the CTE with the RANK() window function in the film table to rank the films based on their length as follows:
WITH cte_film AS  (
    SELECT film_id,
        title,
        rating,
        length,
        RANK() OVER (
            PARTITION BY rating
            ORDER BY length DESC) 
        length_rank
    FROM 
        film
)
SELECT *
FROM cte_film
WHERE length_rank = 1;
Output:
postgreSQL-administration
PostgreSQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PyGame – Import and Initialize

21 Apr, 2021
In this article, we will see how to import and initialize PyGame.
The best way to install pygame is with the pip tool, we can install pygame by using the below command:
pip install pygame
To import the pygame library, make sure you have installed pygame already. Open the terminal or the IDE which you want to work upon and import this library to check whether pygame is installed or not by using the command given below:
import pygame 
This library imports all the available pygame modules into the pygame package.The below image how to perform it with the help of a command prompt. If you don’t find any error and get the message as shown in the image means the pygame library is imported successfully, and now you are good to proceed. 
Before we can do much with pygame, we first need to initialize it. Just call the method given below to initialize it. 
pygame.init()
This method initializes all the necessary pygame modules. This method has nothing like an argument and returns a tuple that returns the no of modules initialized successfully and the number of modules failed respectively. 
As you can see in the image pygame.init() method returns a tuple (7,0) which means 7 modules are initialized successfully and 0 is failed to initialize. 
There is a method named pygame.get_init() which shows whether all the pygame modules are initialized successfully or not. If all the modules are initialized successfully, this method returns true.
Picked
Python-PyGame
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Rexx - right String

This method returns a certain number of characters from the right of the string.
right(str,count) 

str − The source string.
str − The source string.
count − The number of characters to return from the left of the string.
count − The number of characters to return from the left of the string.
This method returns a certain number of characters from the right of the string.
/* Main program */ 
a = "Hello World" 
say right(a,5)  
When we run the above program, we will get the following result.
World

 Print
 Add Notes
 Bookmark this page
How to make a class singleton in Java?


A Singleton class is a class that has only a single object., which means that we can instantiate the class only once. When we declare the constructor of the class as private, it will limit the scope of the creation of the object. If we return an instance of the object to a static method, we can handle the object creation inside the class itself. We can create a static block for the creation of an object.
public class SingletonClassTest {
   private static SingletonClassTest obj;
   static {
      obj = new SingletonClassTest(); // creation of object in a static block
   }
   private SingletonClassTest() { } // declaring the constructor as private
   public static SingletonClassTest getObject() {
      return obj;
   }
   public void print() {
      System.out.println("Singlton Class Test");
   }
   public static void main(String[] args) {
      SingletonClassTest test = getObject();
      test.print();
   }
}
Singlton Class Test