code-rag-bench/online-tutorials huggingface dataset:
How to group Bar Charts in Python-Plotly?

03 Jul, 2020
Plotly is a Python library which is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histogram, barplot, boxplot, spreadplot and many more. It is mainly used in data analysis as well as financial analysis. plotly is an interactive visualization library. 
Grouping bar charts can be used to show multiple set of data items which are been compared with a single color which is used to indicate a specific  series across all sets.
Method 1: Using graph_objects class
Example:
Python3
import plotly.graph_objects as pximport numpy    # creating random data through randomint # function of numpy.random np.random.seed(42)  random_x= np.random.randint(1,101,100) random_y= np.random.randint(1,101,100)  x = ['A', 'B', 'C', 'D']  plot = px.Figure(data=[go.Bar(    name = 'Data 1',    x = x,    y = [100, 200, 500, 673]   ),                       go.Bar(    name = 'Data 2',    x = x,    y = [56, 123, 982, 213]   )])                   plot.show()
Output:
Method 2: Using express class
Example 1: Iris dataset
Python3
import plotly.express as px   df = px.data.iris()   fig = px.bar(df, x="sepal_width", y="sepal_length",             color="species", hover_data=['petal_width'],             barmode = 'group')   fig.show()
Output:
Example 2: Tips dataset
Python3
import plotly.express as px  df = px.data.tips()  fig = px.bar(df, x="tota_bill", y="day",              color="sex", barmode = 'group')  fig.show()
Output:
Python-Plotly
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Python | os.path.join() method
How to drop one or multiple columns in Pandas Dataframe
Introduction To PYTHON
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | datetime.timedelta() function
Python | Get unique values from a list
Java - String copyValueOf() Method

This method returns a String that represents the character sequence in the array specified.
Here is the syntax of this method −
public static String copyValueOf(char[] data)

Here is the detail of parameters −
data − the character array.
data − the character array.
This method returns a String that contains the characters of the character array.
This method returns a String that contains the characters of the character array.
public class Test {

   public static void main(String args[]) {
      char[] Str1 = {'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd'};
      String Str2 = "";
      Str2 = Str2.copyValueOf( Str1 );
      System.out.println("Returned String: " + Str2);
   }
}
This will produce the following result −
Returned String: hello world
How to Install Lazy Script in Kali Linux?

05 Oct, 2021
Kali Linux is one of the most advanced hacking OS systems from Linux family. Kali Linux is filled with many hacking tools and supporting learners and hackers worldwide. There are many versions of Kali Linux which provides a good user interface and desired environment.The Lazy Script is designed to help many users to save time and work. The script can install many hacking tools easily with just a few inputs, saving a lot of time of the users. The user is helped in the way all the manual tasks are avoided.
To Install the Lazy Script you will first need Kali Linux system which you can download from its official website.
Step 1: Copy the github repository from the following Link. Before doing everything note that it is all about Linux and not windows so please make sure you are doing everything in Kali Linux itself.
Step 2: Open the terminal and type the following commands:
cd Desktop
git clone https://github.com/arismelachroinos/lscript.git

We used cd Desktop for simplicity and to find the folder easily. After cloning the script change your directory to lscript by using the following command
cd lscript
Step 3: After that check for the installer .sh file and follow the command:
./install.sh
If the terminal shows permission denied, then it is because the file is not given executable permission. To give it permission type the following command
chmod +x install.sh
Again type the command ./install.sh and this time you have prior permissions to do that.
Step 4: After running the script you will be asked to accept terms and conditions, type YES to accept. Then you will be asked to enter network interfaces that the system use. For the first line type eth0mon and for second line type eth0.
The Script looks like this after installing.
Use the script and enjoy many tools with one choice, no wasting of time in searching and installing, make your life easier.A sample working:
Madhusudan_Soni
how-to-install
How To
Installation Guide
Linux-Unix
TechTips
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Java Tutorial
How to filter object array based on attributes?
How to Align Text in HTML?
How to Install FFmpeg on Windows?
How to Set Git Username and Password in GitBash?
Installation of Node.js on Linux
How to Install FFmpeg on Windows?
How to Install Anaconda on Windows?
Installation of Node.js on Windows
How to Install and Run Apache Kafka on Windows?
Python - geometry method in Tkinter

Python has capability to create GUI applications using the Tkinter library. The library provides many methods useful for GUI applications. The geometry method is a fundamental one which decides the size, position and some other attributes of the screen layout we are going to create.
In the below program we create a window of size 22x200 pixels using the geometry method. Then we add a button to it and decide button position in the window using the side and pady options.
from tkinter import *
base = Tk()
base.geometry('200x200')
stud = Button(base, text = 'Tutorialspoint', font =('Courier',14, 'bold'))
stud.pack(side = TOP, pady = 6)
mainloop()
Running the above code gives us the following result:
In this example we create a canvas with a clickable link which will enable us to visit a URL. Again we use the geometry method to create the canvas of the required size.
import webbrowser
from tkinter import*
def Uniform_Resource_Locator():
   url=webbrowser.open_new("http://tutorialspoint.com")
main=Tk()
main.geometry("300x250")
stud=Button(main, text="visit Tutorialspoint", font=('Courier',15,'bold'), command=Uniform_Resource_Locator)stud.pack(side = RIGHT, pady = 6)
main.mainloop()
Running the above code gives us the following result
ML | Momentum-based Gradient Optimizer introduction

18 Nov, 2021
Gradient Descent is an optimization technique used in Machine Learning frameworks to train different models. The training process consists of an objective function (or the error function), which determines the error a Machine Learning model has on a given dataset. While training, the parameters of this algorithm are initialized to random values. As the algorithm iterates, the parameters are updated such that we reach closer and closer to the optimal value of the function.However, Adaptive Optimization Algorithms are gaining popularity due to their ability to converge swiftly. All these algorithms, in contrast to the conventional Gradient Descent, use statistics from the previous iterations to robustify the process of convergence. 
An Adaptive Optimization Algorithm uses exponentially weighted averages of gradients over previous iterations to stabilize the convergence, resulting in quicker optimization. For example, in most real-world applications of Deep Neural Networks, the training is carried out on noisy data. It is, therefore, necessary to reduce the effect of noise when the data are fed in batches during Optimization. This problem can be tackled using Exponentially Weighted Averages (or Exponentially Weighted Moving Averages).
In order to approximate the trends in a noisy dataset of size N: , we maintain a set of parameters . As we iterate through all the values in the dataset, we calculate the parameters as below: 
On iteration t:
    Get next 

This algorithm averages the value of over its values from previous iterations. This averaging ensures that only the trend is retained and the noise is averaged out. This method is used as a strategy in momentum-based gradient descent to make it robust against noise in data samples, resulting in faster training.As an example, if you were to optimize a function on the parameter , the following pseudo-code illustrates the algorithm:  
On iteration t:
    On the current batch, compute 


The HyperParameters for this Optimization Algorithm are , called the Learning Rate and, , similar to acceleration in mechanics.Following is an implementation of Momentum-based Gradient Descent on a function : 
Python3
import math # HyperParameters of the optimization algorithmalpha = 0.01beta = 0.9 # Objective functiondef obj_func(x):    return x * x - 4 * x + 4     # Gradient of the objective functiondef grad(x):    return 2 * x - 4     # Parameter of the objective functionx = 0 # Number of iterationsiterations = 0 v = 0 while (1):    iterations += 1    v = beta * v + (1 - beta) * grad(x)         x_prev = x         x = x - alpha * v         print("Value of objective function on iteration", iterations, "is", x)         if x_prev == x:        print("Done optimizing the objective function. ")        break
punamsingh628700
Machine Learning
Machine Learning
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Print all string combination from given numbers

16 Jan, 2019
Given an integer N as input, the task is to print the all the string combination from it in lexicographical order.
Examples:
Input :  191
Output : aia sa
Explanation: 
The Possible String digit are 
1, 9 and 1 --> aia
19 and 1 --> sa

Input : 1119
Output : aaai aas aki kai ks

Approach:
Get the String and find all its combination list in the given order.
Find the list whose integers lies in the range of 0 to 25.
Convert the integers to the alphabets.
Sort it in lexicographical order.
# Python program to print all string# combination from given numbers  # Function to find the combinationdef Number_to_String(String):          # length of string     length = len(String)          # temporary lists    temp1 =[]    temp2 =[]          # alphabets Sequence    alphabet ="abcdefghijklmnopqrstuvwxyz"          # Power variable    power = 2**(length-1)          for i in range(0, power):                  # temporary String        sub = ""        Shift = i         x = 0        sub += String[x]        x += 1        for j in range(length - 1):            if Shift&1:                sub+=" "            Shift = Shift>>1            sub += String[x]            x += 1         temp1.append(list(map(int, sub.split())))              # Integer to String         for index in temp1:         substring =""        for j in index:            if j > 0 and j <= 26:                 substring += alphabet[j-1]        if len(substring) == len(index):            temp2.append(substring)                  # lexicographical order sorting    print(*sorted(temp2), sep =" ")  # Driver CodeNumber_to_String("191")Number_to_String("1991")Number_to_String("1532")Number_to_String("1191")
aia sa
aiia sia
aecb ocb
aaia asa kia

Python
Python Programs
Strings
Strings
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python | os.path.join() method
Introduction To PYTHON
Python OOPs Concepts
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python | Convert string dictionary to dictionary
Python Program for Fibonacci numbers
How to Convert Hex String to Hex Number in C#?

Firstly, set the Hex String −
string str = "7D";
Now, use the Convert.ToSByte() method to convert the Hex string to Hex number −
Console.WriteLine(Convert.ToSByte(str, 16));
Let us see the complete code −
 Live Demo
using System;

namespace Demo {
   public class Program {
      public static void Main(string[] args) {
         string str = "7D";
         Console.WriteLine(Convert.ToSByte(str, 16));
      }
   }
}
125
Another way of converting Hex String to Hex Number −
 Live Demo
using System;

namespace Demo {
   public class Program {
      public static void Main(string[] args) {
         string str = "7D";
         Console.WriteLine(Convert.ToInt32(str, 16));
      }
   }
}
125
Arduino - for loop

A for loop executes statements a predetermined number of times. The control expression for the loop is initialized, tested and manipulated entirely within the for loop parentheses. It is easy to debug the looping behavior of the structure as it is independent of the activity inside the loop.
Each for loop has up to three expressions, which determine its operation. The following example shows general for loop syntax. Notice that the three expressions in the for loop argument parentheses are separated with semicolons.
for ( initialize; control; increment or decrement) {
   // statement block
}

for(counter = 2;counter <= 9;counter++) {
   //statements block will executed 10 times
}

    65 Lectures 
     6.5 hours 

 Amit Rana

    43 Lectures 
     3 hours 

 Amit Rana

    20 Lectures 
     2 hours 

 Ashraf Said

    19 Lectures 
     1.5 hours 

 Ashraf Said

    11 Lectures 
     47 mins

 Ashraf Said

    9 Lectures 
     41 mins

 Ashraf Said
 Print
 Add Notes
 Bookmark this page
\dot - Tex Command

\dot - Used to draw dot accent over the argument.
{ \dot #1 }
\dot command draws dot accent over the argument.

\dot x

x ̇



\dot x

x ̇


\dot x

    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
Checkbox-inline Bootstrap class

Use .checkbox-inline class to a series of checkboxes for controls to appear on the same line.
You can try to run the following code to implement the .checkbox-inline class
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Forms</title>
      <meta name = "viewport" content = "width=device-width, initial-scale = 1">
      <link rel = "stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css">
      <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <script src = "https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
   </head>
   <body>
      <label for = "name">Best IDE (You can select more than one)</label>
      <div>
         <label class = "checkbox-inline">
            <input type = "checkbox" id = "inlineCheckbox1" value = "option1"> NetBeans IDE
         </label>
         <label class = "checkbox-inline">
            <input type = "checkbox" id = "inlineCheckbox2" value = "option2"> Eclipse IDE
         </label>
      </div>
   </body>
</html>
How to find the Current Context id of the Thread in C#?

To create a new thread.
Thread thread = Thread.CurrentThread;
thread.Name = "My new Thread”;
To get the current context id, use the ContextID property.
Thread.CurrentContext.ContextID
Let us see the complete code −
 Live Demo
using System;
using System.Threading;
namespace Demo {
   class MyClass {
      static void Main(string[] args) {
         Thread thread = Thread.CurrentThread;
         thread.Name = "My new Thread";
         Console.WriteLine("Thread Name = {0}", thread.Name);
         Console.WriteLine("current Context id: {0}", Thread.CurrentContext.ContextID);
         Console.ReadKey();
      }
   }
}
Thread Name = My new Thread
current Context id: 0
Count odd and even digits in a number in PL/SQL - GeeksforGeeks

11 Aug, 2021
Prerequisite – PL/SQL introduction In PL/SQL code groups of commands are arranged within a block. A block group related declarations or statements. In declare part, we declare variables and between begin and end part, we perform the operations.Given a number and task is to find the number of odd and even digits present in the number.  
Examples:  
Input: 123456
Output: Odd digits = 3
        Even digits = 3

Input: 246
Output: Odd digits = 0
        Even digits = 3
Approach is to take a number and one by one check its digits, if it is odd or even.Below is the required implementation: 
SQL
--Odd and Even digits in a number--in PL/SQLDECLARE  --num variable declared  --num assign with a number  num NUMBER := 123456;   --len variable char declared  len VARCHAR2(20);   --cntvariable declared  cnt1 NUMBER(5) := 0;  cnt2 NUMBER(5) := 0;BEGIN   --for loop go from 1 to length of the number  FOR i IN 1..Length(num)  LOOP    len := Substr(num, i, 1);    IF mod(len, 2) != 0 THEN      cnt1 := cnt1 + 1;    ELSE      cnt2:=cnt2+1;    END IF;  END LOOP;  --end loop   dbms_output.Put_line('Odd Digits: '  || cnt1);  dbms_output.Put_line('Even Digits: '  || cnt2);  --display resultEND;--end program
Output: 
Odd Digits: 3
Even Digits: 3
Akanksha_Rai
clintra
SQL-PL/SQL
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
SQL | Views
Difference between DDL and DML in DBMS
CTE in SQL
SQL Interview Questions
How to Update Multiple Columns in Single Update Statement in SQL?
How to Alter Multiple Columns at Once in SQL Server?
Difference between DELETE, DROP and TRUNCATE
Difference between SQL and NoSQL
MySQL | Group_CONCAT() Function
What is Temporary Table in SQL?
Case-insensitive Dictionary in C#

To compare, ignoring case, use the case-insensitive Dictionary.
While declaring a Dictionary, set the following property to get case-insensitive Dictionary −
StringComparer.OrdinalIgnoreCase
Add the property like this −
Dictionary <string, int> dict = new Dictionary <string, int> (StringComparer.OrdinalIgnoreCase);
Here is the complete code −
 Live Demo
using System;
using System.Collections.Generic;
public class Program {
   public static void Main() {
      Dictionary <string, int> dict = new Dictionary <string, int>       (StringComparer.OrdinalIgnoreCase);
      dict.Add("cricket", 1);
      dict.Add("football", 2);
      foreach (var val in dict) {
         Console.WriteLine(val.ToString());
      }
      // case insensitive dictionary i.e. "cricket" is equal to "CRICKET"
      Console.WriteLine(dict["cricket"]);
      Console.WriteLine(dict["CRICKET"]);
   }
}
[cricket, 1]
[football, 2]
1
1
GATE | GATE CS 2019 | Question 24 - GeeksforGeeks

01 Oct, 2021
For Σ = {a, b}, let us consider the regular language
L = {x ∣ x = a2 + 3k or x = b10 + 12k, k ≥ 0} 
Which one of the following can be a pumping length (the constant guaranteed by the pumping lemma) for L?(A) 3(B) 5(C) 9(D) 24Answer: (D)Explanation: According to Pumping lemma, there must be repeation (DFA then it repeats some states, and regular grammar repeats its nonterminal in derivation.) for all acceptable stings.
Therefore, minimum Pumping Length should be 11, because string with length 10 (i.e., w = b10) does not repeat anything, but string with length 11 (i.e., w = b11) will repeat states.
Therefore, pumping length for given language should greater than 10, which is 24.
Option (D) is correct.
YouTubeGeeksforGeeks GATE Computer Science16.3K subscribersGATE PYQ's on Grammars with Praddyumn Shukla | GeeksforGeeks GATEWatch laterShareCopy linkInfoShoppingTap to unmuteIf playback doesn't begin shortly, try restarting your device.You're signed outVideos you watch may be added to the TV's watch history and influence TV recommendations. To avoid this, cancel and sign in to YouTube on your computer.CancelConfirmMore videosMore videosSwitch cameraShareInclude playlistAn error occurred while retrieving sharing information. Please try again later.Watch on0:000:003:22 / 1:02:45•Live•<div class="player-unavailable"><h1 class="message">An error occurred.</h1><div class="submessage"><a href="https://www.youtube.com/watch?v=zAzS1PzU0NQ" target="_blank">Try watching this video on www.youtube.com</a>, or enable JavaScript if it is disabled in your browser.</div></div>Quiz of this Question
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | Gate IT 2007 | Question 25
GATE | GATE-CS-2000 | Question 41
GATE | GATE-CS-2001 | Question 39
GATE | GATE-CS-2005 | Question 6
GATE | GATE MOCK 2017 | Question 21
GATE | GATE-CS-2006 | Question 47
GATE | GATE MOCK 2017 | Question 24
GATE | Gate IT 2008 | Question 43
GATE | GATE-CS-2009 | Question 38
GATE | GATE-CS-2003 | Question 90
VBA - Minute Function

The Minute Function returns a number between 0 and 59 that represents the minute of the hour for the specified time stamp.
Minute(time) 

Add a button and add the following function.
Private Sub Constant_demo_Click()
   msgbox("Line 1: " & Minute("3:13:45 PM"))
   msgbox("Line 2: " & Minute("23:43:45"))
   msgbox("Line 3: " & Minute("2:20 PM"))
End Sub
When you execute the above function, it produces the following output.
Line 1: 13
Line 2: 43
Line 3: 20


    101 Lectures 
     6 hours 

 Pavan Lalwani

    41 Lectures 
     3 hours 

 Arnold Higuit

    80 Lectures 
     5.5 hours 

 Prashant Panchal

    25 Lectures 
     2 hours 

 Prashant Panchal

    26 Lectures 
     2 hours 

 Arnold Higuit

    92 Lectures 
     10.5 hours 

 Vijay Kumar Parvatha Reddy
 Print
 Add Notes
 Bookmark this page
C++ | References | Question 6 - GeeksforGeeks

28 Jun, 2021
Which of the following is FALSE about references in C++(A) References cannot be NULL(B) A reference must be initialized when declared(C) Once a reference is created, it cannot be later made to reference another object; it cannot be reset.(D) References cannot refer to constant valueAnswer: (D)Explanation: We can create a constant reference that refers to a constant. For example, the following program compiles and runs fine.
#include<iostream>
using namespace std;

int main()
{
  const int x = 10;
  const int& ref = x;

  cout << ref;
  return 0;
}
Quiz of this Question
C++-References
References
C Language
C++ Quiz
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
TCP Server-Client implementation in C
Multithreading in C
Exception Handling in C++
'this' pointer in C++
Arrow operator -> in C/C++ with Examples
C++ | Exception Handling | Question 3
C++ | new and delete | Question 4
C++ | Inheritance | Question 7
C++ | Operator Overloading | Question 10
C++ | Inheritance | Question 1
How to Call a Lua function from C?

Calling a Lua function from C is something that requires a series of steps and a mastery in the Lua library functions. Lua provides several library functions that we can use whenever we want to call Lua functions from C or the opposite.
Some of the most commonly used Lua library functions for calling a Lua function from C are −
luaL_dofile(L, "myFile.lua");
lua_getglobal(L, "add");
lua_pushnumber(L, a);
and much more.
We will make use of these functions when we will call a Lua function from C.
The first step is to shut down the Lua interpreter and for that we need to write a code in C.
Consider the example shown below −
extern "C" {
   #include "lua.h"
   #include "lualib.h"
   #include "lauxlib.h"
}
int main(int argc, char *argv[]) {
   lua_State* L;
   L = luaL_newstate();
   luaL_openlibs(L);
   lua_close(L);
   printf( "Press enter to exit..." );
   getchar();
   return 0;
}
Now, we just need to call the luaL_dofile(L, "myFile.lua"); function for the file in which we will write some Lua code that will get invoked from the C code.
Consider the code shown below as written inside the myFile.lua −
add = function(a,b)
return a + b
end
Now the C file which will call the above Lua function will look something like this −
int luaAdd(lua_State* L, int a, int b) {
   // Push the add function on the top of the lua stack
   lua_getglobal(L, "add");
   // Push the first argument on the top of the lua stack
   lua_pushnumber(L, a);
   // Push the second argument on the top of the lua stack
   lua_pushnumber(L, b);
   // Call the function with 2 arguments, returning 1 result
   lua_call(L, 2, 1);
   // Get the result
   int sum = (int)lua_tointeger(L, -1);
   lua_pop(L, 1);
   return sum;
}
And when we call this luaAdd() function in C, the output will be:(for a = 2,b = 3)
5
How to display all constraints on a table in MySQL?

To display all constraints on a table, you can try any of the following methods −
You can check with the help of show command. The syntax is as follows −
SHOW CREATE TABLE yourTableName;
You can use information.schema. The syntax is as follows −
select COLUMN_NAME, CONSTRAINT_NAME, REFERENCED_COLUMN_NAME, REFERENCED_TABLE_NAME
from information_schema.KEY_COLUMN_USAGE
where TABLE_NAME = 'yourTableName';
To display all constraints on a table, implement the above syntax. Let’s say we already have a table ‘ConstraintDemo’.
The query is as follows −
mysql> select COLUMN_NAME, CONSTRAINT_NAME, REFERENCED_COLUMN_NAME, REFERENCED_TABLE_NAME
   −> from information_schema.KEY_COLUMN_USAGE
   −> where TABLE_NAME = 'ConstraintDemo';
The following is the output displaying the constraints −
+-------------+-----------------+------------------------+-----------------------+
| COLUMN_NAME | CONSTRAINT_NAME | REFERENCED_COLUMN_NAME | REFERENCED_TABLE_NAME |
+-------------+-----------------+------------------------+-----------------------+
| Id          | PRIMARY         | NULL                   |                  NULL |
| Id          | Id              | NULL                   |                  NULL |
+-------------+-----------------+------------------------+-----------------------+
2 rows in set, 2 warnings (0.04 sec)
Now let us check using the show command. The query is as follows −
mysql> show create table ConstraintDemo;
The following is the output −
+----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table          | Create Table          |
+----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ConstraintDemo | CREATE TABLE `constraintdemo` (`Id` int(11) NOT NULL,`Name` varchar(100) NOT NULL, PRIMARY KEY (`Id`), UNIQUE KEY `Id` (`Id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci |
+----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
How can I pass parameters to on_key in fig.canvas.mpl_connect('key_press_event',on_key)?

To pass parameters to on_key in fig.canvas.mpl_connect('key_press_event', on_key), we can take the following steps −
Set the figure size and adjust the padding between and around the subplots.
Create a figure and a set of subplots.
Set x and y scale of the axes.
Bind the function to the event.
To display the figure, use show() method.
import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True

fig, ax = plt.subplots()
ax.set_xlim(0, 10)
ax.set_ylim(0, 10)

def onkey(event):
   if event.key.isalpha():
      if event.xdata is not None and event.ydata is not None:
         ax.plot(event.xdata, event.ydata, 'bo-')
         fig.canvas.draw()

cid2 = fig.canvas.mpl_connect('key_press_event', onkey)
plt.show()
mysqlcheck - A MySQL Table Maintenance Program

The mysqlcheck client performs table maintenance. It checks, repairs, optimizes, or analyses tables. If the user uses the --databases or --all-databases option to process all tables in one or more databases, invoking mysqlcheck would take a long time. This is true for the MySQL upgrade procedure as well, if it determines that the table checking is required since it processes tables in the same way.
The command mysqlcheck should be used when the mysqld server is running. This means that the user need not have to stop the server to perform table maintenance. It uses the SQL statements such as CHECK TABLE, REPAIR TABLE, ANALYZE TABLE, and OPTIMIZE TABLE in a convenient way for the user.
The command mysqlcheck should be used when the mysqld server is running. This means that the user need not have to stop the server to perform table maintenance. It uses the SQL statements such as CHECK TABLE, REPAIR TABLE, ANALYZE TABLE, and OPTIMIZE TABLE in a convenient way for the user.
It helps determine which statements need to be used for the operation that needs to be performed. It then sends the statements to the server so as to be executed.
It helps determine which statements need to be used for the operation that needs to be performed. It then sends the statements to the server so as to be executed.
The three ways to invoke mysqlcheck −
shell> mysqlcheck [options] db_name [tbl_name ...]
shell> mysqlcheck [options] --databases db_name ...
shell> mysqlcheck [options] --all-databases
The default behaviour of mysqlcheck is checking tables (--check) that can be changed by renaming the binary. If the user has a tool that repairs tables by default, then a copy of mysqlcheck named mysqlrepair needs to be made. Otherwise, a symbolic link to mysqlcheck named mysqlrepair need to be made. If the user invokes mysqlrepair, it repairs tables.
mysqlrepair: It is the default option is –repair.
mysqlrepair: It is the default option is –repair.
mysqlanalyze: It is the default option is –analyze.
mysqlanalyze: It is the default option is –analyze.
mysqloptimize: It is the default option is –optimize.
mysqloptimize: It is the default option is –optimize.
Add minimum number to an array so that the sum becomes even in C programming

Given an array, add the minimum number (which should be greater than 0) to the array so that the sum of array becomes even.
Input - 1 2 3 4,
Output - 2
Explanation - Sum of array is 10, so we 
add minimum number 2 to make the sum even.
Method 1: calculate the sum of all elements of the array, then check if the sum is even then add minimum number is 2, else add minimum number is 1.
Input - 1 2 3 4,
Output - 2
Explanation - Sum of array is 10, so we
add minimum number 2 to make the sum even.
#include<iostream>
using namespace std;
int main() {
   int arr[] = { 1, 2, 3, 4};
   int n=4;
   int sum=0;
   for (int i = 0; i <n; i++) {
      sum+=arr[i];
   }
   if (sum % 2==0) {
      cout <<"2";
   } else {
      cout <<"1";
   }
   return 0;
}
Method 2 - calculate count of odd number of elements in the array. If count of odd numbers present is even we return 2, else we return 1.
Input - 1 2 3 4 5
Output - 1
Explanation - no. of in the array is 3add minimum number 1 to make the sum even.
#include<iostream>
using namespace std;
int main() {
   int arr[] = { 1, 2, 3, 4,5};
   int n=5;
   int odd = 0;
   for (int i = 0; i < n; i++) {
      if (arr[i] % 2!=0) {
         odd += 1;
      }
   }
   if (odd % 2==0) {
      cout <<"2";
   } else {
      cout <<"1";
   }
   return 0;
}
Method 3 - Take a flag variable (initialized as 0). Whenever we find the odd element in the array we perform the NOT(!) operation on the boolean variable. This logical operator inverts the value of the flag variable (meaning if it is 0, it converts the variable to 1 and vice-versa).
Input - 1 2 3 4 5
Output - 1
Explanation - variable initialized as 0.Traversing the array1 is odd, variable changed 1.2 is even3 is odd, variable changed 0.4 is even5 is odd, variable changed 1
If variable value is 1 it means odd number of odd elements are present, minimum number to make sum of elements even is by adding 1.
Else minimum number is 2.
#include<iostream>
using namespace std;
int main() {
   int arr[] = { 1, 2, 3, 4,5};
   int n=5;
   bool odd = 0;
   for (int i = 0; i < n; i++) {
      if (arr[i] % 2!=0) {
         odd = !odd;
      }
   }
   if (odd) {
      cout <<"1";
   } else {
      cout <<"2";
   }
   return 0;
}
How can we implement line wrap and word wrap text inside a JTextArea in Java?

A JTextArea is a multi-line text component to display text or allow the user to enter the text and it will generate a CaretListener interface when we are trying to implement the functionality of the JTextArea component. A JTextArea class inherits the JTextComponent class in Java.
In the below example, we can implement a JTextArea class with a user can select either word wrap or line wrap checkboxes using the ItemListener interface.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class JTextAreaTest {
   public static void main(String[] args ) {
      EventQueue.invokeLater(new Runnable() {
         @Override
         public void run() {
            JFrame frame = new JFrame("JTextArea Test");
            frame.setSize(350, 275);
            final JTextArea textArea = new JTextArea(15, 65);
            frame.add(new JScrollPane(textArea));
            final JCheckBox wordWrap = new JCheckBox("word wrap");
            wordWrap.setSelected(textArea.getWrapStyleWord());
            wordWrap.addItemListener(new ItemListener() {
               @Override
               public void itemStateChanged(ItemEvent ie) {
                  textArea.setWrapStyleWord(wordWrap.isSelected());
               }
            });
            frame.add(wordWrap, BorderLayout.NORTH);
            final JCheckBox lineWrap = new JCheckBox("line wrap");
            lineWrap.setSelected(textArea.getLineWrap());
            lineWrap.addItemListener(new ItemListener() {
               @Override
               public void itemStateChanged(ItemEvent ie) {
                  textArea.setLineWrap(lineWrap.isSelected());
               }
            });
            frame.add(lineWrap, BorderLayout.SOUTH );
            frame.setLocationRelativeTo(null);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );
            frame.setVisible(true);
         }
      });
   }
}
How to create a list in SAPUI5?

I have gone through your code and it looks your list binding is incorrect. When you bind your data, your data should be in a JSON array format.  Please find below the updated working code.
var oModelData =
[
  {Animal: "Kangaroo", Zoo: "Sydney"},
  {Animal: "Tiger", Zoo: "Melbourne"},
  {Animal: "Lion", Zoo: "Alaska"}
];
var oItem = new sap.m.StandardListItem({
   title : "{ Animal }",
   description : "{ Zoo }"
});
var oList = new sap.m.List({
   headerText:" Items",
   items: {
        path: "/",
        template: oItem
    }
});
Hope it helps!
Transform data from a nested array to an object in JavaScript

Suppose, we have the following array of arrays −
const arr = [
   [
      ['dog', 'Harry'], ['age', 2]
   ],
   [
      ['dog', 'Roger'], ['age', 5]
   ]
];
We are required to write a JavaScript function that takes in one such nested array. The function should then prepare an object based on the array.
The object for the above array should look like −
const output = [
   {dog: 'Harry', age: 2},
   {dog: 'Roger', age: 5}
];
The code for this will be −
const arr = [
   [
      ['dog', 'Harry'], ['age', 2]
   ],
   [
      ['dog', 'Roger'], ['age', 5]
   ]
];
const prepareObjectArray = (arr = []) => {
   const copy = arr.slice();
   copy.forEach((el, ind, array) => {
      el.forEach((element, index, subArray) => {
         subArray[element[0]] = element[1];
      });
      el.length = 0;
      array[ind] = Object.assign({}, array[ind]);
   });
   return copy;
};
console.log(prepareObjectArray(arr));
And the output in the console will be −
[ { dog: 'Harry', age: 2 }, { dog: 'Roger', age: 5 } ]
Can we change return type of main() method in java?

The public static void main() method is the entry point of the Java program. Whenever you execute a program in Java, the JVM searches for the main method and starts executing from it.
You can write the main method in your program with return type other than void, the program gets compiled without compilation errors. 
But, at the time of execution JVM does not consider this new method (with return type other than void) as the entry point of the program.
It searches for the main method which is public, static, with return type void, and a String array as an argument.
public static int main(String[] args){
}
If such a method is not found, a run time error is generated.
In the following Java program, we are trying to write the main method with the return type integer −
 Live Demo
import java.util.Scanner;
public class Sample{
   public static int main(String[] args){
      Scanner sc = new Scanner(System.in);
      int num = sc.nextInt();
      System.out.println("This is a sample program");
      return num;
   }
}
On executing, this program generates the following error −
Error: Main method must return a value of type void in class Sample, please
define the main method as:
public static void main(String[] args)
Check input character is alphabet, digit or special character in C

In this section, we will see how to check whether a given character is number, or the alphabet or some special character in C.
The alphabets are from A – Z and a – z, Then the numbers are from 0 – 9. And all other characters are special characters. So If we check the conditions using these criteria, we can easily find them.
#include <stdio.h>
#include <conio.h>
main() {
   char ch;
   printf("Enter a character: ");
   scanf("%c", &ch);
   if((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z'))
      printf("This is an alphabet");
   else if(ch >= '0' && ch <= '9')
      printf("This is a number");
   else
      printf("This is a special character");
}
Enter a character: F
This is an alphabet
Enter a character: r
This is an alphabet
Enter a character: 7
This is a number
Enter a character: #
This is a special character
What’s the best way to reload / refresh an iframe? - GeeksforGeeks

17 Jun, 2019
Suppose that a user creates a webpage. Now he has a webpage, which contains an IFrame and a Button. Once the user presses the button, he/she needs the IFrame to be reloaded/refreshed. How are we going to make this possible? We are going to be finding it in the article.
The following syntax is work for both cases, where the IFrame is provided & loaded from the same domain, and where the IFrame is not from the same domain.
Syntax:
document.getElementById('YOUR IFRAME').contentDocument.location.reload(true);
NOTE: In Firefox, if you are going to use window.frames[], it might not be indexed by id. So you have to index it by index or name.
Example 1:
<!DOCTYPE html><html>  <head>    <style>        iframe {            width: 786px;            height: 600px;            border: 0;            overflow: hidden;        }    </style></head>  <body>    <center>        <h2 style="color:green">GeeksforGeeks</h2>        <h4 style="color:purple">Reload / Refresh an iframe</h4>        <iframe id="iframeid"                src="https://ide.geeksforgeeks.org/"                 width="600"                 height="450"                frameborder="0"                 style="border:0"                 allowfullscreen>      </iframe>        <input type="button"               id="btn"                value="Refresh" />          <script>            function reload() {                document.getElementById('iframeid').src += '';            }            btn.onclick = reload;        </script>    </center>  </body>  </html>
Output:Before Refresh:
After Refresh:
Example 2:
<!DOCTYPE html><html>  <head>    <style>        body {            text-align: center;        }                  iframe {            width: 786px;            height: 600px;            border: 0;            overflow: hidden;        }    </style></head>  <body>    <h2 style="color:green">GeeksforGeeks</h2>    <h4 style="color:purple">Reload / Refresh an iframe</h4>    <iframe id="iframeid"             src="Map Source"            width="600"             height="450"             frameborder="0"            style="border:0"             allowfullscreen>  </iframe>    <input type="button"            id="btn"            value="Refresh" />      <script>        function reload() {            document.getElementById('iframeid').src += '';        }        btn.onclick = reload;    </script>  </body>  </html>
Output:When we load the code:
The Working:
JavaScript-Misc
Picked
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?
PDFBox - Loading a Document

In the previous examples, you have seen how to create a new document and add pages to it. This chapter teaches you how to load a PDF document that already exists in your system, and perform some operations on it.
The load() method of the PDDocument class is used to load an existing PDF document. Follow the steps given below to load an existing PDF document.
Load an existing PDF document using the static method load() of the PDDocument class. This method accepts a file object as a parameter, since this is a static method you can invoke it using class name as shown below.
File file = new File("path of the document") 
PDDocument.load(file);

Perform the required operations such as adding pages adding text, adding images to the loaded document.
After adding all the pages, save the PDF document using the save() method of the PDDocument class as shown in the following code block.
document.save("Path");

Finally close the document using the close() method of the PDDocument class as shown below.
document.close();

Suppose we have a PDF document which contains a single page, in the path, C:/PdfBox_Examples/ as shown in the following screenshot.
This example demonstrates how to load an existing PDF Document. Here, we will load the PDF document sample.pdf shown above, add a page to it, and save it in the same path with the same name.
Step 1 − Save this code in a file with name LoadingExistingDocument.java.
import java.io.File;
import java.io.IOException;
 
import org.apache.pdfbox.pdmodel.PDDocument; 
import org.apache.pdfbox.pdmodel.PDPage;
public class LoadingExistingDocument {

   public static void main(String args[]) throws IOException {
   
      //Loading an existing document 
      File file = new File("C:/PdfBox_Examples/sample.pdf"); 
      PDDocument document = PDDocument.load(file); 
        
      System.out.println("PDF loaded"); 
        
      //Adding a blank page to the document 
      document.addPage(new PDPage());  

      //Saving the document 
      document.save("C:/PdfBox_Examples/sample.pdf");

      //Closing the document  
      document.close(); 
        
   }  
}
Compile and execute the saved Java file from the command prompt using the following commands
javac LoadingExistingDocument.java  
java LoadingExistingDocument 

Upon execution, the above program loads the specified PDF document and adds a blank page to it displaying the following message.
PDF loaded

If you verify the specified path, you can find an additional page added to the specified PDF document as shown below.
 Print
 Add Notes
 Bookmark this page
How do I put a jQuery code in an external .js file?

Create an external JavaScript file and add the jQuery code in it.
Let’s say the name of the external file is demo.js. To add it in the HTML page, include it like the following −
<html>
   <head>
      <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
      <script src="demo.js"></script>
   </head>

   <body>
      <h1>Hello</h1>
   </body>
</html>
Above we added jQuery using Google CDN and the external file was included after that.Add jQuery code in demo.js, since you wanted to place jQuery code −
$(document).ready(function(){
   alert(“amit”)
});
Excel Absolute References

Absolute reference is when a reference has the dollar sign ($).
It locks a reference in the formula. 
Add $ to the formula to use absolute references.
The dollar sign has three different states:
Absolute for column and row. The reference is absolutely locked.

Example =$A$1
Absolute for the column. The reference is locked to that column. The row remains relative.

Example =$A1

Absolute for the row. The reference is locked to that row. The column remains relative.

Example =A$1

Let's have a look at an example helping the Pokemon trainers to calculate prices for Pokeballs
Type or copy the following data:
Data explained
There are 6 trainers: Iva, Liam, Adora, Jenny, Iben and Kasper. 
They have different amount of Pokeballs each in their shop cart
The price per Pokeball is 2 coins
Help them to calculate the prices for the Pokeballs.
The price's reference is B11, we do not want the fill function to change this, so we lock it. 
The reference is absolutely locked by using the formula $B$11.
How to do it, step by step:

Type C2(=)
Select B11
Type ($) before the B and 11 ($B$11)
Type (*)
Select B2
Hit enter
Auto fill C2:C7

Type C2(=)
Select B11
Type ($) before the B and 11 ($B$11)
Type (*)
Select B2
Hit enter
Auto fill C2:C7
Congratulations! You successfully calculated the prices for the Pokeballs using an absolute reference. 

Type reference A1 as absolute:
A$1

Start the Exercise
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
Calculate the cross-product of a Matrix in R Programming - crossprod() Function - GeeksforGeeks

03 Jun, 2020
crossprod() function in R Language is used to return the cross-product of the specified matrix.
Syntax: crossprod(x)
Parameters:x: numeric matrix
Example 1:
# R program to illustrate# crossprod function  # Initializing a matrix with# 2 rows and 2 columnsx <- matrix(1:4, 2, 2)  # Getting the matrix representationx  # Calling the crossprod() functioncrossprod(x)
Output:
     [, 1] [, 2]
[1, ]    1    3
[2, ]    2    4

     [, 1] [, 2]
[1, ]    5   11
[2, ]   11   25

Example 2:
# R program to illustrate# crossprod function  # Initializing a matrix with# 3 rows and 3 columnsx <- matrix(1:9, 3, 3)  # Getting the matrix representationx  # Calling the crossprod() functioncrossprod(x)
Output:
     [, 1] [, 2] [, 3]
[1, ]    1    4    7
[2, ]    2    5    8
[3, ]    3    6    9

     [, 1] [, 2] [, 3]
[1, ]   14   32   50
[2, ]   32   77  122
[3, ]   50  122  194

R Matrix-Function
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Change Color of Bars in Barchart using ggplot2 in R
How to Change Axis Scales in R Plots?
Group by function in R using Dplyr
How to Split Column Into Multiple Columns in R DataFrame?
How to filter R DataFrame by values in a column?
How to import an Excel File into R ?
How to filter R dataframe by multiple conditions?
Replace Specific Characters in String in R
Time Series Analysis in R
R - if statement
DAX Information - ISTEXT function

Checks if a value is text, and returns TRUE or FALSE.
ISTEXT (<value>) 

value
The value you want to check.
TRUE or FALSE.
Empty strings are considered as text.
Blank cells, BLANK () are considered as non-text.
= ISTEXT("") returns TRUE. 
= ISTEXT("AB") returns TRUE. 
= ISTEXT(4) returns FALSE. 
= ISTEXT(TRUE()) returns FALSE. 

    53 Lectures 
     5.5 hours 

 Abhay Gadiya

    24 Lectures 
     2 hours 

 Randy Minder

    26 Lectures 
     4.5 hours 

 Randy Minder
 Print
 Add Notes
 Bookmark this page