code-rag-bench/online-tutorials huggingface dataset:
JSON | modify an array value of a JSON object - GeeksforGeeks

06 Jun, 2018
The arrays in JSON (JavaScript Object Notation) are similar to arrays in Javascript. Arrays in JSON can have values of following types:
null
boolean
number
string
array
object
The arrays in JavaScript can have all these but it can also have other valid JavaScript expressions which are not allowed in JSON.
Array value of a JSON object can be modified. It can be simply done by modifying the value present at a given index.
Example: Modifying the value present at an index in array
<!DOCTYPE html><html><body><p id = "GFG">< /p>  <script>  var myObj, i, x = "";myObj = {          // stored the values    "words":[ "I", "am", "Good" ]};  // modifying the value present at index 2myObj.words[2] = "bad";   for (i in myObj.words) {      // Displaying the modified content    x += myObj.words[i] + "<br>"; }  document.getElementById("GFG").innerHTML = x;  </script></body></html>                    
Output :
I
am
bad

Note: If value is modified at an index which is out of the array size, then the new modification will not replace anything in the original information but rather will be an add-on.
Example: Modifying the value of index which is out of the array size.
<!DOCTYPE html><html><body><p id = "GFG"></p>  <script>  var myObj, i, x = "";myObj = {          // stored values    "words":[ "I", "am", "Good" ] };  // trying to change a value at// an index out of array sizemyObj.words[3] = "bad";   for (i in myObj.words) {       // display the modification    x += myObj.words[i] + "<br>";}  document.getElementById("GFG").innerHTML = x;  </script></body></html>                    
Output :
I
am
Good
bad

javascript-array
JSON
JavaScript
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
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 ?
Difference Between PUT and PATCH Request
JavaScript | console.log() with Examples
How to read a local text file using JavaScript?
Node.js | fs.writeFileSync() Method
Backing up a Docker Container - GeeksforGeeks

28 Oct, 2020
If you are a Docker Developer, you would surely know how important it is to backup your Docker Container file system. If you are working on an important Docker Application, it becomes very necessary to backup all the files and folders related to it so that in case anything goes wrong, you can get back all those files. It also helps you in managing different versions of your project and also sharing the files and folders of your project among your team members.
In this article, we are going to see how can we back up a Docker Container by saving it as a tar file in your local system. We will also see how you can push that Docker Image Backup directly into your Docker Hub accounts for ease of sharing. Follow the below steps to backup a docker container:
For our example, we are going to create an Ubuntu Container with a single file inside it.
sudo docker run -it ubuntu bash

After you fire up the bash, use the below command to create a file.
echo "geeksforgeeks" > geeksforgeeks.txt
ls

Creating a Container and File
You will need the Container ID in order to create the backup.
sudo docker container ls

Note that if the container is not running, you can start the Container using the below command.
sudo docker start <container-id>

Copying Container ID
To create a snapshot, you need to commit the Container.
sudo docker commit -p 6cb599fe30ea my-backup

Committing the Container
You can use this command, to save the backup as a Tar File in your local machine.
sudo docker save -o ~/my-backup.tar my-backup

Saving Backup
You will find the backup Tar file in your Home Directory.
Tar File
In order to push it back to the Docker Hub, you need to have an account on Docker Hub.
Login using your command line and push the Tar File.
sudo docker login
sudo docker push my-backup:latest

Pushing Image
To conclude, in this article we saw how to create a backup of a Docker Image into a Tar File and pushing it into a Docker Hub account for ease of sharing.
Docker Container
linux
Advanced Computer Subject
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Copying Files to and from Docker Containers
Markov Decision Process
Q-Learning in Python
Fuzzy Logic | Introduction
An introduction to Machine Learning
Basics of API Testing Using Postman
Principal Component Analysis with Python
ML | What is Machine Learning ?
OpenCV - Overview
Deep Learning | Introduction to Long Short Term Memory
JavaScript Error() constructor - GeeksforGeeks

14 Aug, 2021
Javascript Error() constructor is used to create a new error object. Error objects are arising at runtime errors. The error object also uses as the base object for the exceptions defined by the user.
Syntax:
new Error([message[, fileName[, lineNumber]]])
Parameters:
message: It contains information about this error object which is in human-readable form. An error message can be set using javascript Error message property. It is an optional parameter.
fileName: It is the name of the file for this error object. If no name is provided than fileName is equal to the name of file containing the the code that called the Error() constructor. It is an optional parameter.
lineNumber: It is the value for the lineNumber property on the created Error object. If no number is provided Than the lineNumber is equal to the line number containing the Error() constructor invocation. It is an optional parameter.
Example 1: Creating error object using new keyword.
Javascript
<script>try {    const error = new Error('This object is created using new keyword')    document.write("Error object created successfully using new keyword");} catch(err) {     document.write(err.message);}</script>
Output:
Error object created successfully using new keyword
Example 2: Creating error object using function call.
Javascript
<script>try {    const error =  Error('This is created is using function call')    document.write("Error object created successfully using function call");} catch(err) {     document.write(err.message);}</script>
Output:
Error object created successfully using function call
Supported Browsers:
Google Chrome
Firefox
Edge
Internet Explorer
Opera
Safari
surinderdawra388
JavaScript-Errors
Picked
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Difference between var, let and const keywords in JavaScript
Difference Between PUT and PATCH Request
JavaScript | Promises
How to get character array from string in JavaScript?
Remove elements from a JavaScript Array
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
Difference between var, let and const keywords in JavaScript
Batch Script - ECHO

This batch command displays messages, or turns command echoing on or off.
ECHO “string”

The following example shows the different variants of the dir command.
Rem Turns the echo on so that each command will be shown as executed 
echo on 
echo "Hello World" 

Rem Turns the echo off so that each command will not be shown when executed 
@echo off 
echo "Hello World" 

Rem Displays the contents of the PATH variable 
echo %PATH%
The following output will be displayed in the command prompt.
C:\>Rem Turns the echo on so that each command will be shown as executed

C:\>echo on

C:\>echo "Hello World"
"Hello World"

C:\>Rem Turns the echo off so that each command will not be shown when executed

"Hello World"
C:\Users\ADMINI~1\AppData\Local\Temp

 Print
 Add Notes
 Bookmark this page
Check if a given string is made up of two alternating characters in C++

Here we will see how to check a string is made up of alternating characters or not. If a string is like XYXYXY, it is valid, if a string is like ABCD, that is invalid.
The approach is simple. We will check whether all ith character and i+2 th character are same or not. if they are not same, then return false, otherwise return true.
 Live Demo
#include <iostream>
using namespace std;
bool hasAlternateChars(string str){
   for (int i = 0; i < str.length() - 2; i++) {
      if (str[i] != str[i + 2]) {
         return false;
      }
   }  
   if (str[0] == str[1])
   return false;  
   return true;
}
int main() {
   string str = "XYXYXYX";
   if(hasAlternateChars(str)){
      cout << "Valid String";
   }else{
      cout << "Not a Valid String";
   }
}
Valid String
CICS - Handle Abend

If a program abends due to some reasons like input-output error, then it can be handled using Handle Abend CICS command. Following is the syntax of Handle Abend command −
EXEC CICS HANDLE ABEND
   PROGRAM(name) 
   LABEL(Label)   
   CANCEL         
   RESET
END-EXEC

Program name or label name is used to transfer the control to the program or paragraph if abend occurs. CANCEL is used to cancel previous HANDLE CONDITIONS. RESET is used to re-activate the previously cancelled HANDLE ABEND.
Following is the example of Handle Abend −
IDENTIFICATION DIVISION.                                         
PROGRAM-ID. HELLO.                                               
PROCEDURE DIVISION.

EXEC CICS HANDLE ABEND
    LABEL (X0000-HANDLE-ABEND-PARA)
END-EXEC.

X0000-HANDLE-ABEND-PARA.
DISPLAY 'Program Abended'.
 Print
 Add Notes
 Bookmark this page
How to make vertical scrollable rows in bootstrap? - GeeksforGeeks

05 May, 2022
Here is the task to make vertically scrollable in a bootstrap row.
It can be done by the following approach:
Approach:
Making all the div element in next line using position: absolute; property (arrange all div column-wise).
Adding the scroll bar to all the div element using overflow-y: scroll; property.
Example:
HTML
<!DOCTYPE html><html lang="en"><head>    <title>          How to make vertical        scrollable in a bootstrap row?      </title>    <meta charset="utf-8">    <meta name="viewport"        content="width=device-width, initial-scale=1">    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">    <style>        .vertical-scrollable>.row {            position: absolute;            top: 120px;            bottom: 100px;            left: 180px;            width: 50%;            overflow-y: scroll;        }        .col-sm-8 {            color: white;            font-size: 24px;            padding-bottom: 20px;            padding-top: 18px;        }        .col-sm-8:nth-child(2n+1) {            background: green;        }        .col-sm-8:nth-child(2n+2) {            background: black;        }    </style></head><body>    <center>        <div class="container">             <h1 style="text-align:center;color:green;">                GeeksforGeeks            </h1>            <h3>                To make vertical scrollable                in a bootstrap row?            </h3>            <div class="container vertical-scrollable">                <div class="row text-center">                    <div class="col-sm-8">                        1                      </div>                    <div class="col-sm-8">                        2                      </div>                    <div class="col-sm-8">                        3                      </div>                    <div class="col-sm-8">                        4                      </div>                    <div class="col-sm-8">                        5                         </div>                    <div class="col-sm-8">                        6                      </div>                    <div class="col-sm-8">                        7                      </div>                </div>            </div>        </div>    </center></body></html>
Output:
sahilintern
Bootstrap-Misc
Bootstrap
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to change navigation bar color in Bootstrap ?
Form validation using jQuery
How to pass data into a bootstrap modal?
How to align navbar items to the right in Bootstrap 4 ?
How to Show Images on Click using HTML ?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
Max(), Min() and Mod() Function in MariaDB - GeeksforGeeks

13 Oct, 2020
1. Max() Function :In MariaDB, the Max() function is used to returns the maximum value of an expression. In this function, a query is passed and in the eligible records which value will be maximum, that will return a result. It works like maximum function in the processed query. An expression will be passed as a parameter and it will return the maximum value in the expression.
Syntax :
Max(expression)
Parameter : Required. An expression.expression : The input value.Returns : The maximum value in the expression.
Table – IPL
Example-1 :
SELECT Max(Score) AS MAX_Score
FROM IPL;
Output :
Example-2 :
SELECT Max(Score) AS MAX_Score
FROM IPL
WHERE Score < 190;
Output :
Example-3 :
SELECT Max(Score) AS MAX_Score
FROM IPL
WHERE Score < 160;
Output :
2. Min() Function :In MariaDB, the Min() function is used to returns the minimum value of an expression. In this function, a query is passed and in the eligible records which value will be minimum, that will return a result. It works like minimum function in the processed query. An expression will be passed as a parameter and it will return the minimum value in the expression.
Syntax :
Min(expression)
Parameter : Required. An expression.expression : The input value.Returns : The minimum value in the expression.
Example-1 :
SELECT Min(Score) AS Min_Score
FROM IPL;
Output :
Example-2 :
SELECT Min(Score) AS Min_Score
FROM IPL
WHERE Score > 150;
Output :
Example-3 :
SELECT Min(Score) AS Min_Score
FROM IPL
WHERE Score > 170; 
Output :
3. Mod() Function :In MariaDB, the Mod() function used to return the remainder of n divided by m.In this function, two-parameter will be passed first is n (a value that will be divided by m) and the second will be m (a value that will be divided into n). The function uses the formula of n / m and returned what will be a remainder without any rounding.
Syntax :
MOD(n, m)
OR
n MOD m
OR
n % m 
Parameters : Required. Two numeral values.
n : Divident (Value that will be divided).
m : Divisor (Value which the dividend is being divided by).
Returns : Remainder value (without any rounding) as the result of the division.
Example-1 :
SELECT MOD(20, 5);
Output :
0
Example-2 :
SELECT 21 MOD 4;
Output :
1
Example-3 :
SELECT 51 % 7;
Output :
2
DBMS-SQL
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Update Multiple Columns in Single Update Statement in SQL?
SQL | Subquery
How to Create a Table With Multiple Foreign Keys in SQL?
What is Temporary Table in SQL?
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
SQL Query to Convert VARCHAR to INT
SQL using Python
How to Write a SQL Query For a Specific Date Range and Date Time?
How to Select Data Between Two Dates and Times in SQL Server?
SQL Query to Compare Two Dates
How to Count the Number of Rows in a MySQL Table in Python? - GeeksforGeeks

12 Nov, 2020
MySQL server is an open-source relational database management system which is a major support for web-based applications. Databases and related tables are the main component of many websites and applications as the data is stored and exchanged over the web. In order to access MySQL databases from a web server we use various modules in Python such as PyMySQL, mysql.connector, etc. 
In this article, we are going to get the number of rows in a specific MySQL table in a Database. First, we are going to connect to a database having a MySQL table. The SQL query that is going to be used is:
SELECT * FROM table-name

 And finally, display the number of rows in the table.
Below are some programs which depict how to count the number of rows from a MySQL table in a Database:
Example 1
Below is the table geeksdemo in database geek which is going to be accessed by a Python script:
Below is the program to get the number of rows in a MySQL table:
Python3
# import required modulesimport pymysqlpymysql.install_as_MySQLdb()import MySQLdb  # connect python with mysql with your hostname, # username, password and databasedb= MySQLdb.connect("localhost", "root", "", "geek")  # get cursor objectcursor= db.cursor()  # get number of rows in a table and give your table# name in the querynumber_of_rows = cursor.execute("SELECT * FROM geeksdemo")  # print the number of rowsprint(number_of_rows)
Output:
Example 2:
Here is another example to get the number of rows from a table in a given database, below is the table scheme and rows:
Below is the python script to get row count from the table TechCompanies:
Python3
# import required modulesimport pymysqlpymysql.install_as_MySQLdb()import MySQLdb  # connect python with mysql with your hostname, # username, password and databasedb= MySQLdb.connect("localhost", "root", "", "techgeeks")  # get cursor objectcursor= db.cursor()  # get number of rows in a table and give your table# name in the querynumber_of_rows = cursor.execute("SELECT * FROM techcompanies")  # print the number of rowsprint(number_of_rows)
Output:
Python-mySQL
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | os.path.join() method
Python | Get unique values from a list
Create a directory in Python
Defaultdict in Python
Python | Pandas dataframe.groupby()
wxPython - Set tooltip for Button - GeeksforGeeks

24 Jun, 2020
In this article we will learn how we can assign a tooltip to a Button. In order to assign tooltip we use SetToolTip() function associated with wx.Button class of wxPython. SetToolTip() function takes a string argument that would be used as a tooltip.
Syntax: wx.Button.SetToolTip(self, string)
Parameters:
Code Example:
import wx    class Example(wx.Frame):      def __init__(self, *args, **kwargs):        super(Example, self).__init__(*args, **kwargs)        self.InitUI()      def InitUI(self):        self.locale = wx.Locale(wx.LANGUAGE_ENGLISH)          # create parent panel        self.pnl = wx.Panel(self)          # create button at point (20, 20)        self.btn = wx.Button(self.pnl, id = 1, label ="Button")                  # set tooltip for button        self.btn.SetToolTip("Button ToolTip")          self.SetSize((350, 250))        self.SetTitle('wx.Button')        self.Centre()  def main():    app = wx.App()    ex = Example(None)    ex.Show()    app.MainLoop()  if __name__ == '__main__':    main()
Output Window
Python wxPython-Button
Python-gui
Python-wxPython
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Python | Get unique values from a list
Defaultdict in Python
Python | os.path.join() method
Create a directory in Python
Python | Pandas dataframe.groupby()
Python NOT EQUAL operator - GeeksforGeeks

13 Sep, 2021
In this article, we are going to see != (Not equal) operators. In Python != is defined as not equal to operator. It returns True if operands on either side are not equal to each other, and returns False if they are equal. 
Note: It is important to keep in mind that this comparison operator will return True if the the values are same but are of different data types.
Syntax: Value A != Value B
Python3
A = 1B = 2C = 2 print(A!=B)print(B!=C)
Output:
True
False
Python3
A = 1B = 1.0C = "1" print(A!=B)print(B!=C)print(A!=C)
Output:
False
True
True
The __ne__() gets called whenever the not equal operator is used. We can override this function to alter the nature of the not equal operator.
Python3
class Student:     def __init__(self, name):        self.student_name = name     def __ne__(self, x):        # return true for different types        # of object        if type(x) != type(self):            return True                   # return True for different values        if self.student_name != x.student_name:            return True        else:            return False s1 = Student("Shyam")s2 = Student("Raju")s3 = Student("babu rao") print(s1 != s2)print(s2 != s3)
Output:
True
True
sweetyty
Blogathon-2021
Picked
Python-Operators
Blogathon
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Create a Table With Multiple Foreign Keys in SQL?
How to Import JSON Data into SQL Server?
Stratified Sampling in Pandas
How to Install Tkinter in Windows?
Python program to convert XML to Dictionary
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe
Array product in C++ using STL - GeeksforGeeks

19 Apr, 2021
In C++, we can quickly find array product using accumulate() and multiplies<>(). 
The initialProduct specifies the initial value to be considered.
For multiplication, the initial value is 1.
Eg: array = [5, 10, 15], 
So, Product = 1 x 5 x 10 x 15 = 750  (Notice that 1 is the initial value here)
CPP
// C++ program to find array product#include <iostream>#include <numeric>using namespace std; // User defined function that returns product of// arr[] using accumulate() library function.int arrayProduct(int a[], int n){    int initialProduct = 1;    return accumulate(a, a + n, initialProduct, multiplies<int>());} int main(){    int a[] = { 5, 10, 15 };    int n = sizeof(a) / sizeof(a[0]);    cout << arrayProduct(a, n);    return 0;}
750
 
product of vector  
CPP
// C++ program to find vector product#include <iostream>#include <numeric>#include <vector>using namespace std; // User defined function that returns product of// v using accumulate() library function.int arrayProduct(vector<int>& v){    int initialProduct = 1;    return accumulate(v.begin(), v.end(), initialProduct, multiplies<int>());} int main(){    vector<int> v{ 5, 10, 15 };    cout << arrayProduct(v);    return 0;}
750
 
We can also use a custom function in accumulate. Refer numeric header in C++ STL | Set 1 (accumulate() and partial_product()) for details. 
puneethgr
cpp-vector
STL
C++
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Operator Overloading in C++
Polymorphism in C++
Friend class and function in C++
Sorting a vector in C++
std::string class in C++
Inline Functions in C++
Pair in C++ Standard Template Library (STL)
Array of Strings in C++ (5 Different Ways to Create)
Convert string to char array in C++
Queue in C++ Standard Template Library (STL)
LinkedHashSet add() method in Java with Examples - GeeksforGeeks

30 Sep, 2019
The add() method in Java LinkedHashSet is used to add a specific element into a LinkedHashSet. This method will add the element only if the specified element is not present in the LinkedHashSet else the function will return False if the element is already present in the LinkedHashSet.
Syntax:
Hash_Set.add(Object element)
Parameters: The parameter element is of the type LinkedHashSet and refers to the element to be added to the Set.
Return Value: The function returns True if the element is not present in the LinkedHashSet otherwise False if the element is already present in the LinkedHashSet.
Below program illustrate the Java.util.LinkedHashSet.add() method:
// Java code to illustrate add()import java.io.*;import java.util.LinkedHashSet;  public class LinkedHashSetDemo {    public static void main(String args[])    {        // Creating an empty LinkedHashSet        LinkedHashSet<String> set = new LinkedHashSet<String>();          // Use add() method to add elements into the Set        set.add("Welcome");        set.add("To");        set.add("Geeks");        set.add("4");        set.add("Geeks");          // Displaying the LinkedHashSet        System.out.println("LinkedHashSet: " + set);    }}
LinkedHashSet: [Welcome, To, Geeks, 4]

Java-Functions
java-LinkedHashSet
Java
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
Internal Working of HashMap in Java
Strings in Java
Select all duplicate MySQL rows based on one or two columns?

For this, use subquery along with HAVING clause. Let us first create a table −
mysql> create table DemoTable
   (
   StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   StudentFirstName varchar(20),
   StudentLastName varchar(20)
   );
Query OK, 0 rows affected (0.27 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable(StudentFirstName,StudentLastName) values('John','Smith');
Query OK, 1 row affected (0.04 sec)

mysql> insert into DemoTable(StudentFirstName,StudentLastName) values('Carol','Taylor');
Query OK, 1 row affected (0.04 sec)

mysql> insert into DemoTable(StudentFirstName,StudentLastName) values('John','Doe');
Query OK, 1 row affected (0.17 sec)

mysql> insert into DemoTable(StudentFirstName,StudentLastName) values('John','Brown');
Query OK, 1 row affected (0.05 sec)

mysql> insert into DemoTable(StudentFirstName,StudentLastName) values('David','Miller');
Query OK, 1 row affected (0.06 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+-----------+------------------+-----------------+
| StudentId | StudentFirstName | StudentLastName |
+-----------+------------------+-----------------+
| 1         | John             | Smith           |
| 2         | Carol            | Taylor          |
| 3         | John             | Doe             |
| 4         | John             | Brown           |
| 5         | David            | Miller          |
+-----------+------------------+-----------------+
5 rows in set (0.00 sec)
Following is the query to select all duplicate rows based on one or two columns. Here, we are counting the names appearing more than once i.e. duplicates −
mysql> select StudentId from DemoTable
   where StudentFirstName=(select StudentFirstName from DemoTable having count(StudentFirstName) > 1);
This will produce the following output −
+-----------+
| StudentId |
+-----------+
| 1         |
| 3         |
| 4         |
+-----------+
3 rows in set (0.03 sec)
How to deserialize a Java object from Reader Stream using flexjson in Java?

The Flexjson is a lightweight library for serializing and deserializing Java objects into and from JSON format. We can deserialize a Java object from a Reader stream using the deserialize() method of JSONDeserializer class, it uses an instance of Reader class as JSON input.
public T deserialize(Reader input)
import java.io.*;
import flexjson.JSONDeserializer;
public class JSONDeserializeReaderTest {
   public static void main(String[] args) {
      JSONDeserializer<Student> deserializer = new JSONDeserializer<Student>();
      String jsonStr =
                       "{" +
                        "\"firstName\": \"Adithya\"," +
                        "\"lastName\": \"Sai\"," +
                        "\"age\": 25," +
                        "\"address\": \"Hyderabad\"" +
                        "\"class\": \"Student\"" +
                       "}";
      Student student = deserializer.deserialize(new StringReader(jsonStr));
      System.out.println(student);
   }
}
// Student class
class Student {
   private String firstName;
   private String lastName;
   private int age;
   private String address;
   public Student() {}
   public Student(String firstName, String lastName, int age, String address) {
      super();
      this.firstName = firstName;
      this.lastName = lastName;
      this.age = age;
      this.address = address;
   }
   public String getFirstName() {
      return firstName;
   }
   public void setFirstName(String firstName) {
      this.firstName = firstName;
   }
   public String getLastName() {
      return lastName;
   }
   public void setLastName(String lastName) {
      this.lastName = lastName;
   }
   public int getAge() {
      return age;
   }
   public void setAge(int age) {
      this.age = age;
   }
   public String getAddress() {
      return address;
   }
   public void setAddress(String address) {
      this.address = address;
   }
   public String toString() {
      return "Student[ " +
      "firstName = " + firstName +
      ", lastName = " + lastName +
      ", age = " + age +
      ", address = " + address +
      " ]";
   }
}
Student[ firstName = Adithya, lastName = Sai, age = 25, address = Hyderabad ]
Solve ERROR 1396 (HY000): Operation DROP USER failed for 'user'@'localhost' in MySql?

This error occurs when you drop a user with localhost while you have created a user with ‘%’.
Let us create a user with ‘%’ and drop the user as a localhost. The syntax is as follows
CREATE USER 'yourUserName'@'%' IDENTIFIED BY 'yourPassword';
Let us create a user using the above syntax. The query to create a user is as follows
mysql> CREATE USER 'Jack'@'%' IDENTIFIED BY '1234';
Query OK, 0 rows affected (0.26 sec)
Check user is created successfully or not
mysql> select user,host from MySQL.user;
The following is the output
+------------------+-----------+
| user             | host      |
+------------------+-----------+
| Jack             | %         |
| Manish           | %         |
| User2            | %         |
| mysql.infoschema | %         |
| mysql.session    | %         |
| mysql.sys        | %         |
| root             | %         |
| Adam Smith       | localhost |
| User1            | localhost |
| am               | localhost |
+------------------+-----------+
10 rows in set (0.00 sec)
Look at the above sample output, we have a user with name ‘Jack’ and host is ‘%’. Whenever you try to drop the user with localhost then you will get an error which is as follows
mysql> DROP USER 'Jack'@'localhost';
ERROR 1396 (HY000): Operation DROP USER failed for 'Jack'@'localhost'
Let us drop the above user with host ‘%’. The query is as follows
mysql> DROP USER 'Jack'@'%';
Query OK, 0 rows affected (0.19 sec)
Check the user has been dropped or not from MySQL.user table. The query is as follows
mysql> select user,host from MySQL.user;
The following is the output displaying that the user Jack is removed successfully
+------------------+-----------+
| user             | host      |
+------------------+-----------+
| Manish           | %         |
| User2            | %         |
| mysql.infoschema | %         |
| mysql.session    | %         |
| mysql.sys        | %         |
| root             | %         |
| Adam Smith       | localhost |
| User1            | localhost |
| am               | localhost |
+------------------+-----------+
9 rows in set (0.00 sec)
MS SQL Server - Restoring Databases

Restoring is the process of copying data from a backup and applying logged transactions to the data. Restore is what you do with backups. Take the backup file and turn it back into a database.
The Restore database option can be done using either of the following two methods.
Restore database <Your database name> from disk = '<Backup file location + file name>'

The following command is used to restore database called 'TestDB' with backup file name 'TestDB_Full.bak' which is available in 'D:\' location if you are overwriting the existed database.
Restore database TestDB from disk = ' D:\TestDB_Full.bak' with replace

If you are creating a new database with this restore command and there is no similar path of data, log files in target server, then use move option like the following command.
Make sure the D:\Data path exists as used in the following command for data and log files.
RESTORE DATABASE TestDB FROM DISK = 'D:\ TestDB_Full.bak' WITH MOVE 'TestDB' TO 
   'D:\Data\TestDB.mdf', MOVE 'TestDB_Log' TO 'D:\Data\TestDB_Log.ldf'

Step 1 − Connect to database instance named 'TESTINSTANCE' and right-click on databases folder. Click Restore database as shown in the following snapshot.
Step 2 − Select device radio button and click on ellipse to select the backup file as shown in the following snapshot.
Step 3 − Click OK and the following screen pops up.
Step 4 − Select Files option which is on the top left corner as shown in the following snapshot.
Step 5 − Select Options which is on the top left corner and click OK to restore 'TestDB' database as shown in the following snapshot.

    32 Lectures 
     2.5 hours 

 Pavan Lalwani

    18 Lectures 
     1.5 hours 

 Dr. Saatya Prasad

    102 Lectures 
     10 hours 

 Pavan Lalwani

    52 Lectures 
     4 hours 

 Pavan Lalwani

    239 Lectures 
     33 hours 

 Gowthami Swarna

    53 Lectures 
     5 hours 

 Akshay Magre
 Print
 Add Notes
 Bookmark this page
MySQL query to multiply values of two rows and add the result

For this, use aggregate function SUM(). Within this method, multiply the row values. Let us first create a table −
mysql> create table DemoTable(
   ProductQuantity int,
   ProductPrice int
);
Query OK, 0 rows affected (0.48 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(10,9);
Query OK, 1 row affected (0.14 sec)
mysql> insert into DemoTable values(6,20);
Query OK, 1 row affected (0.19 sec)
mysql> insert into DemoTable values(7,100);
Query OK, 1 row affected (0.08 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+-----------------+--------------+
| ProductQuantity | ProductPrice |
+-----------------+--------------+
| 10              |            9 |
| 6               |           20 |
| 7               |          100 |
+-----------------+--------------+
3 rows in set (0.00 sec)
Following is the query to multiply values of two rows and add the result −
mysql> select SUM(ProductQuantity*ProductPrice) AS Total_Value from DemoTable;
This will produce the following output −
+-------------+
| Total_Value |
+-------------+
| 910         |
+-------------+
1 row in set (0.00 sec)
How to override class methods in Python?

Overriding is the property of a class to change the implementation of a method provided by one of its base classes.
Overriding is a very important part of OOP since it makes inheritance utilize its full power. By using method overriding a class may "copy" another class, avoiding duplicated code, and at the same time enhance or customize part of it. Method overriding is thus a part of the inheritance mechanism.
In Python method overriding occurs by simply defining in the child class  a method with the same name of a method in the parent class. When you  define a method in the object you make this latter able to satisfy that  method call, so the implementations of its ancestors do not come in  play.
class Parent(object):
     def __init__(self):
         self.value = 4
     def get_value(self):
         return self.value
 
class Child(Parent):
     def get_value(self):
         return self.value + 1
 
Now Child objects behave differently
>>> c = Child()
>>> c.get_value()
5
Print a number 100 times without using loop, recursion and macro expansion in C

In this section we will see how to print a number 100 times in C. There are some constraints. We cannot use loops, recursions or macro expansions.
To solve this problem we will use the setjump and longjump in C. The setjump() and longjump() is located at setjmp.h library. The syntax of these two functions are like below.
#include <stdio.h>
#include <setjmp.h>
jmp_buf buf;
main() {
   int x = 1;
   setjmp(buf); //set the jump position using buf
   printf("5"); // Prints a number
   x++;
   if (x <= 100)
      longjmp(buf, 1); // Jump to the point located by setjmp
}
5555555555555555555555555555555555555555555555555555555555555555555555555555
555555555555555555555555
D3.js stack.keys() Method - GeeksforGeeks

07 Sep, 2020
The stack.keys() method makes an array of strings as an argument and returns the stack generator.
Syntax:
 stack.keys([keys])

Parameters: This method accepts a single parameter as mentioned above and described below.
domain: This parameter holds an array of strings as key arguments.
Return Value: This method returns the stack generator.
Example:
HTML
<!DOCTYPE html><html><head>    <meta charset="utf-8">    <script src=        "https://d3js.org/d3.v5.min.js">    </script></head>  <body>    <h1 style="text-align: center; color: green;">        GeeksforGeeks    </h1>    <center>        <canvas id="gfg" width="200" height="200">        </canvas>    </center>      <script>        var data = [              {a: 3840, b: 1920, c: 960, d: 400},              {a: 1600, b: 1440, c: 960, d: 400},              {a:  640, b:  960, c: 640, d: 400},              {a:  320, b:  480, c: 640, d: 400}            ];          var stackGen = d3.stack()            // Defining keys            .keys(["a", "b", "c", "d"])          var stack = stackGen(data);                  console.log(stack);          for (i = 0; i < 4; i++) {              // Displaying keys            console.log(stack[i].key);           }    </script></body></html>
Output:
D3.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
Difference Between PUT and PATCH Request
How to filter object array based on attributes?
How to get selected value in dropdown list using JavaScript ?
How to remove duplicate elements from JavaScript Array ?
Roadmap to Become a Web Developer 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?
Select and filter the records on month basis in a MySQL table?

You can use aggregate function SUM() with GROUP BY clause to achieve this.
Let us create a table. The query to create a table is as follows −
mysql> create table SelectPerMonthDemo
   -> (
   -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   -> Price int,
   -> PurchaseDate datetime
   -> );
Query OK, 0 rows affected (2.34 sec)
Insert some records in the table using insert command with one of them would be the date of purchase. The query is as follows −
mysql> insert into SelectPerMonthDemo(Price,PurchaseDate) values(600,date_add(now(),
interval -1 month));
Query OK, 1 row affected (0.42 sec)
mysql> insert into SelectPerMonthDemo(Price,PurchaseDate) values(600,date_add(now(),
interval 2 month));
Query OK, 1 row affected (0.34 sec)
mysql> insert into SelectPerMonthDemo(Price,PurchaseDate) values(400,now());
Query OK, 1 row affected (0.20 sec)
mysql> insert into SelectPerMonthDemo(Price,PurchaseDate) values(800,date_add(now(),
interval 3 month));
Query OK, 1 row affected (0.13 sec)
mysql> insert into SelectPerMonthDemo(Price,PurchaseDate) values(900,date_add(now(),
interval 4 month));
Query OK, 1 row affected (0.10 sec)
mysql> insert into SelectPerMonthDemo(Price,PurchaseDate) values(100,date_add(now(),
interval 4 month));
Query OK, 1 row affected (0.22 sec)
mysql> insert into SelectPerMonthDemo(Price,PurchaseDate) values(1200,date_add(now(),
interval -1 month));
Query OK, 1 row affected (0.09 sec)
Display all records from the table using a select statement. The query is as follows −
mysql> select *from SelectPerMonthDemo;
The following is the output displaying the price and purchase date of the products −
+----+-------+---------------------+
| Id | Price | PurchaseDate        |
+----+-------+---------------------+
|  1 |  600 | 2019-01-10 22:39:30 |
|  2 |  600 | 2019-04-10 22:39:47 |
|  3 |  400 | 2019-02-10 22:40:03 |
|  4 |  800 | 2019-05-10 22:40:18 |
|  5 |  900 | 2019-06-10 22:40:29 |
|  6 |  100 | 2019-06-10 22:40:41 |
|  7 | 1200 | 2019-01-10 22:40:50 |
+----+-------+---------------------+
7 rows in set (0.00 sec)
Here is the query to get the records according to individual months based on the Purchase Date −
mysql> select monthname(PurchaseDate) as MONTHNAME,sum(Price) from
SelectPerMonthDemo
-> group by monthname(PurchaseDate);
+-----------+------------+
| MONTHNAME | sum(Price) |
+-----------+------------+
| January | 1800 |
| April | 600 |
| February | 400 |
| May | 800 |
| June | 1000 |
+-----------+------------+
5 rows in set (0.07 sec)
If you do not want the month name (only the month number), then use the following query −
mysql> select month(PurchaseDate),sum(Price) from SelectPerMonthDemo
-> group by month(PurchaseDate);
+---------------------+------------+
| month(PurchaseDate) | sum(Price) |
+---------------------+------------+
| 1 | 1800 |
| 4 | 600 |
| 2 | 400 |
| 5 | 800 |
| 6 | 1000 |
+---------------------+------------+
5 rows in set (0.00 sec)
Removing the default underlines from links using CSS

By default, all links in HTML are decorated with an underline. We can remove this underline using CSS text-decoration property.
The syntax of CSS text-decoration property is as follows −
Selector {
   text-decoration: /*value*/
}
The following examples illustrate CSS text-decoration property.
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
p {
   padding: 5px;
   box-shadow: inset 0 0 5px violet;
}
a {
   font-style: italic;
   text-decoration: none;
}
</style>
</head>
<body>
<a href="#">Demo</a>
<p>
<a href="https://example.com/">Example domain</a>
</p>
</body>
</html>
This gives the following output −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
div {
   margin: auto;
   width: 50%;
   text-align: right;
   color: green;
   border: thin dashed red;
}
a {
   text-decoration: none;
}
a:last-child {
   color: inherit;
   background-color: moccasin;
}
</style>
</head>
<body>
<div>
<a href="#">Link Demo</a>
<p>
Watch this: <a href="https://example.com/">Example site</a>
</p>
</div>
</body>
</html>
This gives the following output −
How to find the sum of all elements of a given array in JavaScript ?

08 Oct, 2021
In this article, we will learn how we can find the sum of all elements/numbers of the given array. There are many approaches to solve the problems that are described below through examples.
Example 1: In this example, we are simply going to iterate over all the elements of the array using a for loop to find the sum.
Filename: gfg.js
Javascript
<script>    // Creating array    var arr = [4, 8, 7, 13, 12]      // Creating variable to store the sum    var sum = 0;      // Running the for loop    for (let i = 0; i < arr.length; i++) {        sum += arr[i];    }      document.write("Sum is " + sum) // Prints: 44</script>
Output:
Sum is 44
Example 2: In this example, we are going to use forEach method of the array to calculate the sum.
Filename: gfg.js
Javascript
<script>          // Creating array    var arr = [4, 8, 7, 13, 12]      // Creating variable to store the sum    var sum = 0;      // Calculation the sum using forEach    arr.forEach(x => {        sum += x;    });      // Prints: 44    document.write("Sum is " + sum);</script>
Output:
Sum is 44
Example 3: In this example, we are going to use reduce() method to find the sum of the array.
Filename: gfg.js
Javascript
<script>      // Creating array    var arr = [4, 8, 7, 13, 12]      // Using reduce function to find the sum    var sum = arr.reduce(function (x, y) {        return x + y;    }, 0);      // Prints: 44    document.write("Sum using Reduce method: " + sum);  </script>
Output:
Sum using Reduce method: 44
javascript-array
JavaScript-Methods
JavaScript-Questions
Picked
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Remove elements from a JavaScript Array
Difference Between PUT and PATCH Request
Roadmap to Learn JavaScript For Beginners
JavaScript | Promises
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
Puzzle 5 | (Finding the Injection for Anesthesia)

24 Feb, 2022
In a Medical Laboratory, you have 240 Injections, one of which is for Anesthesia for a rat. If Anesthesia injection is injected in a rat, it will faint in within 24 hours. You have 5 rats available to determine which one injection contains the Anesthesia. How do you achieve this in 48 hours ? 
Solution: Let us number the each injection with unique 5 digit numbers consisting of only 0, 1 and 2. Let us number the Rats as 1, 10, 100, 1000, 10000.  
The action corresponding to the digit in the unit place will be executed by rat numbered 1. The action corresponding to the digit in the tenth place will be executed by rat numbered 10. The action corresponding to the digit in the 100th place will be executed by rat numbered 100. The action corresponding to the digit in the 1000th place will be executed by rat numbered 1000. The action corresponding to the digit in the 10000th place will be executed by rat numbered 10000.
Number 0 on an Injection represents that the injection will not be injected to rat. Number 1 on an Injection represents that the injection will be injected to rat on 1st day. Number 2 on an Injection represents that the injection will be injected to rat on 2nd day (after 24 hours). 
Example: Let us say the Injection is numbered 11201. The Injections is injected on the first day to rat numbered 10000, 1000 and 1. It is injected on the second day to rat numbered 100. And it is not injected to rat numbered 10. 
So if the rats numbered 10000, 1000 and 1 faint within first 24 hours, rat numbered 100 faints in the next 24 hours and the rat numbered 10 does not faint, then the Anesthesia Injection has to be 11201. 
Total number of injections that can be tested in this way will be:
= 3 * 3 * 3 * 3 * 3 = 3^5 = 243 Injections 
So with the help of 5 rats and within 48 hours we will be able to find a Anesthesia Injection among 243 Injections.  
Note – The language of this puzzle has been changed: rats from slaves, Anesthesia injection from poison, faint from death, etc. 
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above. 
YouTube<div class="player-unavailable"><h1 class="message">An error occurred.</h1><div class="submessage"><a href="https://www.youtube.com/watch?v=NRSk7hUblos" target="_blank">Try watching this video on www.youtube.com</a>, or enable JavaScript if it is disabled in your browser.</div></div>
SHREYAS6652
Chandan
akshi2
trilokeshtarala18
Puzzles
Puzzles
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Algorithm to solve Rubik's Cube
Top 20 Puzzles Commonly Asked During SDE Interviews
Puzzle 21 | (3 Ants and Triangle)
Puzzle 24 | (10 Coins Puzzle)
Container with Most Water
Puzzle | Set 35 (2 Eggs and 100 Floors)
Puzzle 31 | (Minimum cut Puzzle)
Puzzle | Heaven and Hell
Puzzle | 3 cuts to cut round cake into 8 equal pieces
Puzzle 27 | (Hourglasses Puzzle)