code-rag-bench/online-tutorials huggingface dataset:
Write a SQL query to count the number of duplicate TRANSACTION_ID in an ORDERS DB2 table

We can find the duplicate TRANSACTION_ID in the ORDERS DB2 table using the below query:
SELECT TRANSACTION_ID, COUNT(*) AS TRANSACTION_COUNT FROM ORDER
GROUP BY TRANSACTION_ID
HAVING COUNT(*) > 1
The purpose of COUNT(*) is to count the number of rows. We will group the result based on the TRANSACTION_ID using GROUP BY function and to display the duplicate transaction ids, we will place a predicate using HAVING statement for COUNT(*) greater than one.
For example, consider the below TRANSACTIONS DB2 table:
The query will give the below result:
How to use $regex in MongoDB?

Following is the syntax to use $regex in MongoDB −
db.yourCollectionName.find({yourFieldName: { $regex: yourValue}});
Let us first create a collection with documents −
> db.regularExpressionDemo.insertOne({"UserName":"John"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5cdffc25bf3115999ed51210")
}
> db.regularExpressionDemo.insertOne({"UserName":"JOHN"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5cdffc2ebf3115999ed51211")
}
> db.regularExpressionDemo.insertOne({"UserName":"john"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5cdffc35bf3115999ed51212")
}
> db.regularExpressionDemo.insertOne({"UserName":"JoHn"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5cdffc3ebf3115999ed51213")
}
Following is the query to display all documents from a collection with the help of find() method −
> db.regularExpressionDemo.find();
This will produce the following output −
{ "_id" : ObjectId("5cdffc25bf3115999ed51210"), "UserName" : "John" }
{ "_id" : ObjectId("5cdffc2ebf3115999ed51211"), "UserName" : "JOHN" }
{ "_id" : ObjectId("5cdffc35bf3115999ed51212"), "UserName" : "john" }
{ "_id" : ObjectId("5cdffc3ebf3115999ed51213"), "UserName" : "JoHn" }
Following is the query to use $regex −
> db.regularExpressionDemo.find({'UserName': { $regex: 'JOHN'}});
This will produce the following output −
{ "_id" : ObjectId("5cdffc2ebf3115999ed51211"), "UserName" : "JOHN" }
Let us now match all the cases. Following is the query −
> db.regularExpressionDemo.find({'UserName': { $regex: 'JOHN', $options: 'i' }});
This will produce the following output −
{ "_id" : ObjectId("5cdffc25bf3115999ed51210"), "UserName" : "John" }
{ "_id" : ObjectId("5cdffc2ebf3115999ed51211"), "UserName" : "JOHN" }
{ "_id" : ObjectId("5cdffc35bf3115999ed51212"), "UserName" : "john" }
{ "_id" : ObjectId("5cdffc3ebf3115999ed51213"), "UserName" : "JoHn" }
Python - Get Nth column elements in Tuple Strings - GeeksforGeeks

29 Dec, 2019
Yet another peculiar problem which might not be common, but can occur in python programming while playing with tuples. Since tuples are immutable, they are difficult to manipulate and hence knowledge of possible variation solutions always helps. This articles solves problem of extracting only the Nth index element of each string in tuple. Let’s discuss certain ways in which this problem can be solved.
Method #1 : Using list comprehensionAlmost every problem can be solved using list comprehension as a shorthand to naive approach and this problem isn’t an exception. In this, we just iterate through each list picking just the Nth index element to build the resultant list.
# Python3 code to demonstrate# Nth column in Tuple Strings# using list comprehension  # initializing tupletest_tuple = ('GfG', 'for', 'Geeks')  # initializing N N = 1  # printing original tuple print("The original tuple : " + str(test_tuple))  # using list comprehsion# Nth column in Tuple Stringsres = list(sub[N] for sub in test_tuple)  # print resultprint("The Nth index string character list : " + str(res))
The original tuple : ('GfG', 'for', 'Geeks')
The Nth index string character list : ['f', 'o', 'e']

 
Method #2 : Using next() + zip()This particular task can also be performed using the combination of above two in more efficient way, using the iterators to do this task. The zip function can be used bind together the string elements.
# Python3 code to demonstrate# Nth column in Tuple Strings# using next() + zip()  # initializing tupletest_tuple = ('GfG', 'for', 'Geeks')  # printing original tuple print("The original tuple : " + str(test_tuple))  # initializing N N = 1  # using next() + zip()# Nth column in Tuple Stringstemp = zip(*test_tuple)for idx in range(0, N):    next(temp)res = list(next(temp))  # print resultprint("The Nth index string character list : " + str(res))
The original tuple : ('GfG', 'for', 'Geeks')
The Nth index string character list : ['f', 'o', 'e']

Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
Python OOPs Concepts
Python | Get unique values from a list
Check if element exists in list in Python
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
Python program to check whether a number is Prime or not
jMeter - JMS Test Plan

In this chapter, we will learn how to write a simple test plan to test Java Messaging Service (JMS). JMS supports two types of messaging −
Point-to-Point messaging − Queue messaging is generally used for transactions where the sender expects a response. Messaging systems are quite different from normal HTTP requests. In HTTP, a single user sends a request and gets a response.
Point-to-Point messaging − Queue messaging is generally used for transactions where the sender expects a response. Messaging systems are quite different from normal HTTP requests. In HTTP, a single user sends a request and gets a response.
Topic messaging − Topic messages are commonly known as pub/sub messaging. Topic messaging is generally used in cases where a message is published by a producer and consumed by multiple subscribers.
Topic messaging − Topic messages are commonly known as pub/sub messaging. Topic messaging is generally used in cases where a message is published by a producer and consumed by multiple subscribers.
Let us see a test example for each of these. The pre-requisites for testing JMS are −
We use Apache ActiveMQ in the example. There are various JMS servers like IBM WebSphere MQ (formerly MQSeries), Tibco, etc. Download it from  the binaries from the Apache ActiveMQ website.
We use Apache ActiveMQ in the example. There are various JMS servers like IBM WebSphere MQ (formerly MQSeries), Tibco, etc. Download it from  the binaries from the Apache ActiveMQ website.
Unzip the archive, go to the decompressed directory, and run the following command from the command console to start the ActiveMQ server −
Unzip the archive, go to the decompressed directory, and run the following command from the command console to start the ActiveMQ server −
.\bin\activemq  start

You can verify if the ActiveMQ server has started by visiting the admin interface at the following address http://localhost:8161/admin/. If it asks for authentication, then enter the userid and password as admin. The screen is similar as shown below −
Now copy the activemq-all-x.x.x.jar (XXX depending on the version) from the ActiveMQ unzipped directory to /home/manisha/apache-jmeter-2.9/lib.
Now copy the activemq-all-x.x.x.jar (XXX depending on the version) from the ActiveMQ unzipped directory to /home/manisha/apache-jmeter-2.9/lib.
With the above setup, let us build the test plan for −
JMS Point-to-Point Test Plan
JMS Point-to-Point Test Plan
JMS Topic Test Plan
JMS Topic Test Plan

    59 Lectures 
     9.5 hours 

 Rahul Shetty

    54 Lectures 
     13.5 hours 

 Wallace Tauriac

    23 Lectures 
     1.5 hours 

 Anuja Jain

    12 Lectures 
     1 hours 

 Spotle Learn
 Print
 Add Notes
 Bookmark this page
Particular field as result in MongoDB?

To get particular field as a result in MongoDB, you can use findOne(). Following is the syntax −
db.yourCollectionName.findOne({"yourFieldName1":yourValue},{yourFieldName2:1});
Let us first create a collection with documents −
> db.particularFieldDemo.insertOne({"EmployeeName":"John Smith","EmployeeAge":26,"EmployeeTechnology":"MongoDB"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5cd9b4abb50a6c6dd317ada2")
}
> db.particularFieldDemo.insertOne({"EmployeeName":"Chris Brown","EmployeeAge":28,"EmployeeTechnology":"Java"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5cd9b4d2b50a6c6dd317ada3")
}
> db.particularFieldDemo.insertOne({"EmployeeName":"David Miller","EmployeeAge":30,"EmployeeTechnology":"MySQL"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5cd9b4e8b50a6c6dd317ada4")
}
> db.particularFieldDemo.insertOne({"EmployeeName":"John Doe","EmployeeAge":31,"EmployeeTechnology":"C++"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5cd9b527b50a6c6dd317ada5")
}
Following is the query to display all documents from a collection with the help of find() method −
> db.particularFieldDemo.find().pretty();
This will produce the following output −
{
   "_id" : ObjectId("5cd9b4abb50a6c6dd317ada2"),
   "EmployeeName" : "John Smith",
   "EmployeeAge" : 26,
   "EmployeeTechnology" : "MongoDB"
}
{
   "_id" : ObjectId("5cd9b4d2b50a6c6dd317ada3"),
   "EmployeeName" : "Chris Brown",
   "EmployeeAge" : 28,
   "EmployeeTechnology" : "Java"
}
{
   "_id" : ObjectId("5cd9b4e8b50a6c6dd317ada4"),
   "EmployeeName" : "David Miller",
   "EmployeeAge" : 30,
   "EmployeeTechnology" : "MySQL"
}
{
   "_id" : ObjectId("5cd9b527b50a6c6dd317ada5"),
   "EmployeeName" : "John Doe",
   "EmployeeAge" : 31,
   "EmployeeTechnology" : "C++"
}
Following is the query to find particular field as result in MongoDB −
> db.particularFieldDemo.findOne({"EmployeeTechnology":"Java"},{EmployeeName:1});
This will produce the following output −
{
   "_id" : ObjectId("5cd9b4d2b50a6c6dd317ada3"),
   "EmployeeName" : "Chris Brown"
}
How to properly enable ffmpeg for matplotlib.animation?

To enable ffmpeg for matplotlib.animation, we can take the following steps −
Set the figure size and adjust the padding between and around the subplots.
Set the figure size and adjust the padding between and around the subplots.
Set the ffmpeg directory.
Set the ffmpeg directory.
Create a new figure or activate an existing figure, using figure() method.
Create a new figure or activate an existing figure, using figure() method.
Add an 'ax1' to the figure as part of a subplot arrangement.
Add an 'ax1' to the figure as part of a subplot arrangement.
Plot the divider based on the pre-existing axes.
Plot the divider based on the pre-existing axes.
Create random data to be plotted, to display the data as an image, i.e., on a 2D regular raster.
Create random data to be plotted, to display the data as an image, i.e., on a 2D regular raster.
Create a colorbar for a ScalarMappable instance, cb.
Create a colorbar for a ScalarMappable instance, cb.
Set the title as the current frame.
Set the title as the current frame.
Make a list of colormaps.
Make a list of colormaps.
Make an animation by repeatedly calling a function, animate. The function creates new random data, then use imshow() method to display the data as an image.
Make an animation by repeatedly calling a function, animate. The function creates new random data, then use imshow() method to display the data as an image.
Get an instance of Pipe-based ffmpeg writer.
Get an instance of Pipe-based ffmpeg writer.
Save the current animated figure.
Save the current animated figure.
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from mpl_toolkits.axes_grid1 import make_axes_locatable

plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
plt.rcParams['animation.ffmpeg_path'] = 'ffmpeg'

fig = plt.figure()
ax = fig.add_subplot(111)
div = make_axes_locatable(ax)
cax = div.append_axes('right', '5%', '5%')
data = np.random.rand(5, 5)
im = ax.imshow(data)
cb = fig.colorbar(im, cax=cax)
tx = ax.set_title('Frame 0')

cmap = ["copper", 'RdBu_r', 'Oranges', 'cividis', 'hot', 'plasma']

def animate(i):
   cax.cla()
   data = np.random.rand(5, 5)
   im = ax.imshow(data, cmap=cmap[i%len(cmap)])
   fig.colorbar(im, cax=cax)
   tx.set_text('Frame {0}'.format(i))

ani = animation.FuncAnimation(fig, animate, frames=10)
FFwriter = animation.FFMpegWriter()
ani.save('plot.mp4', writer=FFwriter)
When we execute the code, it will create an mp4 file with the name 'plot.mp4' and save it in the Project Directory.
Your browser does not support HTML5 video.
Node.js fs.realpathSync() Method - GeeksforGeeks

11 Oct, 2021
The fs.realpathSync() method is used to synchronously compute the canonical pathname of a given path. It does so by resolving the ., .. and the symbolic links in the path and returning the resolved path.Syntax: 
fs.realpathSync( path, options )
Parameters: This method accept two parameters as mentioned above and described below:  
path: It holds the path of the directory that has to be resolved. It can be a String, Buffer or URL.
options: It is an string or object that can be used to specify optional parameters that will affect the operation. It has one optional parameter:encoding: It is a string which defines the encoding of the resolved path.
encoding: It is a string which defines the encoding of the resolved path.
Returns: It returns a String or a Buffer that represents the resolved path.Below examples illustrate the fs.realpathSync() method in Node.js:Example 1: 
javascript
// Node.js program to demonstrate the// fs.realpathSync() method  // Import the filesystem moduleconst fs = require('fs');  console.log("Current Directory Path:", __dirname);  // Finding the canonical path// one directory uppath1 = __dirname + "\\..";  resolvedPath = fs.realpathSync(path1);console.log("One directory up resolved path is: ",             resolvedPath);  // Finding the canonical path// two directories uppath2 = __dirname + "\\..\\..";  resolvedPath = fs.realpathSync(path2);console.log("Two directories up resolved path is: ",             resolvedPath);
Output:
Current Directory Path: G:\tutorials\nodejs-fs-realPathSync
One directory up resolved path is:  G:\tutorials
Two directories up resolved path is:  G:\
Example 2: 
javascript
// Node.js program to demonstrate the// fs.realpathSync() method  // Import the filesystem moduleconst fs = require('fs');  path = __dirname + "\\..";  // Getting the canonical path is utf8 encodingresolvedPath = fs.realpathSync(path, { encoding: "utf8" });console.log("The resolved path is: ", resolvedPath);  // Getting the canonical path is hex encodingresolvedPath = fs.realpathSync(path, { encoding: "hex" });console.log("The resolved path is: ", resolvedPath);  // Getting the canonical path is base64 encodingresolvedPath = fs.realpathSync(path, { encoding: "base64" });console.log("The resolved path is: ", resolvedPath);
Output:
The resolved path is:  G:\tutorials
The resolved path is:  473a5c7475746f7269616c73
The resolved path is:  RzpcdHV0b3JpYWxz
Reference: https://nodejs.org/api/fs.html#fs_fs_realpathsync_path_options 
surindertarika1234
Node.js-fs-module
Picked
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Express.js express.Router() Function
Express.js req.params Property
JWT Authentication with Node.js
Difference between npm i and npm ci in Node.js
Mongoose Populate() Method
Roadmap to Become a Web Developer in 2022
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
Convert a string to an integer in JavaScript
How to get the differences between two dates in iOS?

Getting difference between two dates is easy. You should know how to play between the dates.
We will be using DateFormatter class for formatting the dates.
Instances of DateFormatter create string representations of  NSDate objects, and convert textual representations of dates and times into  NSDate objects.
You can read more about it here
 https://developer.apple.com/documentation/foundation/dateformatter
We will also be using Calendar structure, apple has provided beautiful documentation of it,
 https://developer.apple.com/documentation/foundation/calendar
So let’s get started.
Open Xcode, New Playground.
Copy the below code
import UIKit
// create object of DateFormatter and Calendar
let formatter = DateFormatter()
let calendar = Calendar.current
// specify the format,
formatter.dateFormat = "dd-MM-yyyy"
// specify the start date
let startDate = formatter.date(from: "10-08-2018")
// specify the end date
let endDate = formatter.date(from: "23-09-2019")
print(startDate!)
print(endDate!)
let diff = calendar.dateComponents([.day], from: startDate!, to: endDate!)
// print the diff between the two dates
print(diff)
How to design a custom alert box using JavaScript?

To design a custom alert box, try to run the following code. The code uses a JavaScript library jQuery and CSS to create an alert box different from the standard alert box −
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
      <script>
         function functionAlert(msg, myYes) {
            var confirmBox = $("#confirm");
            confirmBox.find(".message").text(msg);
            confirmBox.find(".yes").unbind().click(function() {
               confirmBox.hide();
            });
            confirmBox.find(".yes").click(myYes);
            confirmBox.show();
         }
      </script>
      <style>
         #confirm {
            display: none;
            background-color: #91FF00;
            border: 1px solid #aaa;
            position: fixed;
            width: 250px;
            left: 50%;
            margin-left: -100px;
            padding: 6px 8px 8px;
            box-sizing: border-box;
            text-align: center;
         }
         #confirm button {
            background-color: #48E5DA;
            display: inline-block;
            border-radius: 5px;
            border: 1px solid #aaa;
            padding: 5px;
            text-align: center;
            width: 80px;
            cursor: pointer;
         }
         #confirm .message {
            text-align: left;
         }
      </style>
   </head>
   <body>
      <div id = "confirm">
         <div class = "message">This is a warning message.</div>
         <button class = "yes">OK</button>
      </div>
      <input type = "button"  value = "Click Me"  onclick = "functionAlert();" />
   </body>
</html>
PowerShell: Wait for the First command to finish

We know that PowerShell executes commands sequentially until we specify some parallel Jobs but sometimes the next command executes before the First command because the first command might be taking a long time to retrieve the data. In that case, if you want the previous command to finish first and then the next command to get executed, you can use PowerShell Job functionality.
For example, we need to write a script to ask for the user input to terminate process ID but the program should retrieve the process IDs first.
$job = Start-Job {Get-Process}
Wait-Job $job | Out-Null
Receive-Job $job
$id = Read-Host "Enter the Process ID to terminate the Process "
Stop-Process -Id $id -PassThru -Verbose
In the above example, we are starting a PowerShell process job inside the Start-Job command and waiting for it to proceed further until it gets executed using the Wait-Jobcommand. Once Get-Process
command execution completes, the output will be displayed using the Receive-Job command and at the next, it asks for the process ID to get it terminate the specific process.
SQLite - TRUNCATE TABLE Command

Unfortunately, we do not have TRUNCATE TABLE command in SQLite but you can use SQLite DELETE  command to delete complete data from an existing table, though it is recommended to use DROP TABLE command to drop the complete table and re-create it once again.
Following is the basic syntax of DELETE command.
sqlite> DELETE FROM table_name;

Following is the basic syntax of DROP TABLE.
sqlite> DROP TABLE table_name;

If you are using DELETE TABLE command to delete all the records, it is recommended to use VACUUM command to clear unused space.
Consider COMPANY table with the following records.
ID          NAME        AGE         ADDRESS     SALARY
----------  ----------  ----------  ----------  ----------
1           Paul        32          California  20000.0
2           Allen       25          Texas       15000.0
3           Teddy       23          Norway      20000.0
4           Mark        25          Rich-Mond   65000.0
5           David       27          Texas       85000.0
6           Kim         22          South-Hall  45000.0
7           James       24          Houston     10000.0
Following is the example to truncate the above table −
SQLite> DELETE FROM COMPANY;
SQLite> VACUUM;
Now, COMPANY table is truncated completely and nothing will be the output from SELECT statement.

    25 Lectures 
     4.5 hours 

 Sandip Bhattacharya

    17 Lectures 
     1 hours 

 Laurence Svekis

    5 Lectures 
     51 mins

 Vinay Kumar
 Print
 Add Notes
 Bookmark this page
How to  generate non-repeating random numbers in Python?

Following program generates 10 random, non-repetitive integers between 1 to 100. It generates a random integer in the given interval and adds it in a list if it is not previously added.
>>> import random
>>> list=[]
>>> for i in range(10):
          r=random.randint(1,100)
          if r not in list: list.append(r)

>>> list
[13, 53, 25, 95, 64, 87, 27, 93, 74, 60]
Scala List exists() method with example - GeeksforGeeks

29 Jul, 2019
The exists() method is utilized to check if the given predicate satisfy the elements of the list or not.
Method Definition: def exists(p: (A) => Boolean): Boolean
Return Type: It returns true if the stated predicate holds true for some elements of the list else it returns false.
Example #1:
// Scala program of exists()// method  // Creating objectobject GfG{       // Main method    def main(args:Array[String])    {        // Creating a list        val m1 = List(1, 2, 3, 4, 5)                  // Applying exists method        val result = m1.exists(y => {y % 3 == 0})                  // Displays output        println(result)              }} 
true

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

Scala
Scala-list
Scala-Method
Scala
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Scala Lists
Class and Object in Scala
Operators in Scala
Scala Tutorial – Learn Scala with Step By Step Guide
Scala Constructors
How to get the first element of List in Scala
Scala Map get() method with example
Scala | Arrays
Scala String replace() method with example
Break statement in Scala
How to switch back from a frame to default in Selenium Webdriver?

We can switch back from a frame to default in Selenium webdriver using the switchTo().defaultContent() method. Initially, the webdriver control remains on the main web page.
In order to access elements within the frame, we have to shift the control from the main page to the frame with the help of the switchTo().frame and pass the frame name/id or webelement of the frame as a parameter to that method.
Finally, again we can switch the control to the main page with the switchTo().defaultContent() method. A frame is identified in the html code with the tag names – frame, iframe or frameset.
Let us identify the text Iframe which is inside a frame and the text click on the below link − which is outside a frame
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import java.util.concurrent.TimeUnit;
public class FrameDefaultSwitch{
public static void main(String[] args) {
   System.setProperty("webdriver.gecko.driver",
      "C:\\Users\\ghs6kor\\Desktop\\Java\\geckodriver.exe");
   WebDriver driver = new FirefoxDriver();
   //implicit wait
   driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
   //URL launch
   driver.get("http://www.uitestpractice.com/Students/Switchto");
   // switch to frame
   driver.switchTo().frame("iframe_a");
   //identify element inside frame
   WebElement d = driver.findElement(By.tagName("h1"));
   System.out.println("Text inside frame: " + d.getText());
   //switch to default
   driver.switchTo().defaultContent();
   //identify element outside frame
   WebElement e = driver.findElement(By.tagName("h3"));
   System.out.println("Text outside frame: " + e.getText());
   driver.quit();}
}
scipy stats.skew() | Python - GeeksforGeeks

11 Feb, 2019
scipy.stats.skew(array, axis=0, bias=True) function calculates the skewness of the data set.
skewness = 0 : normally distributed.
skewness > 0 : more weight in the left tail of the distribution.
skewness < 0 : more weight in the right tail of the distribution. 

Its formula –
Parameters :array : Input array or object having the elements.axis : Axis along which the skewness value is to be measured. By default axis = 0.bias : Bool; calculations are corrected for statistical bias, if set to False.
Returns : Skewness value of the data set, along the axis.
Code #1:
# Graph using numpy.linspace() # finding Skewness  from scipy.stats import skewimport numpy as np import pylab as p   x1 = np.linspace( -5, 5, 1000 )y1 = 1./(np.sqrt(2.*np.pi)) * np.exp( -.5*(x1)**2  )  p.plot(x1, y1, '*')  print( '\nSkewness for data : ', skew(y1))
Output :


Skewness for data : 1.1108237139164436

 Code #2:
# Graph using numpy.linspace() # finding Skewness    from scipy.stats import skewimport numpy as np import pylab as p   x1 = np.linspace( -5, 12, 1000 )y1 = 1./(np.sqrt(2.*np.pi)) * np.exp( -.5*(x1)**2  )  p.plot(x1, y1, '.')  print( '\nSkewness for data : ', skew(y1))
Output :


Skewness for data : 1.917677776148478

 Code #3: On Random data
# finding Skewness  from scipy.stats import skewimport numpy as np   # random values based on a normal distributionx = np.random.normal(0, 2, 10000)  print ("X : \n", x)  print('\nSkewness for data : ', skew(x))
Output :
X : 
 [ 0.03255323 -6.18574775 -0.58430139 ...  3.22112446  1.16543279
  0.84083317]

Skewness for data :  0.03248837584866293

Python scipy-stats-functions
Python-scipy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
Enumerate() in Python
Read a file line by line in Python
Python OOPs Concepts
Different ways to create Pandas Dataframe
sum() function in Python
How to Install PIP on Windows ?
Stack in Python
Bar Plot in Matplotlib
Reading and Writing to text files in Python
Java Regex Example - Character \t Match

The character \t matches the tab character.
The following example shows the usage of character matching.
package com.tutorialspoint;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class CharactersDemo {
   private static final String REGEX = "\t";
   private static final String INPUT = "abc\tabc";

   public static void main(String[] args) {
      // create a pattern
      Pattern pattern = Pattern.compile(REGEX);
      
      // get a matcher object
      Matcher matcher = pattern.matcher(INPUT); 

      if(matcher.find()) {
         //Prints the start index of the match.
         System.out.println("Match String start(): "+matcher.start());
      }
   }
}
Let us compile and run the above program, this will produce the following result −
Match String start(): 3

 Print
 Add Notes
 Bookmark this page
Lodash _.camelCase() Method - GeeksforGeeks

09 Sep, 2020
The _.camelCase() method is used to convert a string into a camel case string. The string can be space-separated, dash-separated, or can be separated by underscores.
Syntax:
_.camelCase(string)

Parameters: This method accepts a single parameter as mentioned above and described below:
string: This parameter holds the string that needs to be converted into a camel case string.
Return Value: This method returns the camel case string.
Below example illustrate the Lodash _.camelCase() method in JavaScript:
Example 1:
Javascript
// Requiring the lodash library const _ = require('lodash');   // Use of _.camelCase() methodvar str1 = _.camelCase("Geeks for Geeks");  // Printing the output console.log(str1);  // Use of _.camelCase() methodvar str2 = _.camelCase("GFG-Geeks");  // Printing the output console.log(str2);
Output:
geeksForGeeks
gfgGeeks

Example 2:
Javascript
// Requiring the lodash library const _ = require('lodash');   // Use of _.camelCase() methodvar str1 = _.camelCase("Geeks__for__Geeks");  // Printing the output console.log(str1);  // Use of _.camelCase() methodvar str2 = _.camelCase("GFG--Geeks");  // Printing the output console.log(str2);
Output:
geeksForGeeks
gfgGeeks

JavaScript-Lodash
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Convert a string to an integer in JavaScript
How to calculate the number of days between two dates in javascript?
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
File uploading in React.js
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 insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
What are single row and multiple row subqueries?

A single-row subquery is used when the outer query's results are based on a single, unknown value. Although this query type is formally called "single-row," the name implies that the query returns multiple columns-but only one row of results. However, a single-row subquery can return only one row of results consisting of only one column to the outer query.
In the below SELECT query, inner MySQL returns only one row i.e. the minimum salary for the company. It, in turn, uses this value to compare the salary of all the employees and displays only those, whose salary is equal to minimum salary.
SELECT first_name, salary, department_id
FROM employees
WHERE salary = (SELECT MIN (salary)
FROM employees);
A HAVING clause is used when the group results of a query need to be restricted based on some condition. If a subquery's result must be compared with a group function, you must nest the inner query in the outer query's HAVING clause.
SELECT department_id, MIN (salary)
FROM employees
GROUP BY department_id
HAVING MIN (salary) < (SELECT AVG (salary)
FROM employees)
Multiple-row subqueries are nested queries that can return more than one row of results to the parent query. Multiple-row subqueries are used most commonly in WHERE and HAVING clauses. Since it returns multiple rows, it must be handled by set comparison operators (IN, ALL, ANY).While IN operator holds the same meaning as discussed in the earlier chapter, ANY operator compares a specified value to each value returned by the subquery while ALL compares a value to every value returned by a subquery. The below query will show the error because single-row subquery returns multiple rows.
SELECT first_name, department_id FROM employees WHERE department_id = (SELECT department_id FROM employees WHERE LOCATION_ID = 100)
jQuery - removeClass( class ) Method

The removeClass( class ) method removes all or the specified class(es) from the set of matched elements.
Here is the simple syntax to use this method −
selector.removeClass( class )

Here is the description of all the parameters used by this method −
class − The name of CSS class.
class − The name of CSS class.
Following example would remove class red from the first para −
<html>
   <head>
      <title>The Selecter Example</title>
      <script type = "text/javascript" 
         src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
      </script>
   
      <script type = "text/javascript" language = "javascript">
         $(document).ready(function() {
            $("p#pid1").removeClass("red");
         });
      </script>
		
      <style>
         .red { color:red; }
         .green { color:green; }
      </style>
   </head>
	
   <body>
      <p class = "red" id = "pid1">This is first paragraph.</p>
      <p class = "green" id = "pid2">This is second paragraph.</p>
   </body>
</html>
This will produce following result −
This is first paragraph.
This is second paragraph.

    27 Lectures 
     1 hours 

 Mahesh Kumar

    27 Lectures 
     1.5 hours 

 Pratik Singh

    72 Lectures 
     4.5 hours 

 Frahaan Hussain

    60 Lectures 
     9 hours 

 Eduonix Learning Solutions

    17 Lectures 
     2 hours 

 Sandip Bhattacharya

    12 Lectures 
     53 mins

 Laurence Svekis
 Print
 Add Notes
 Bookmark this page
How to open MySQL command line on Windows10?

To open the MySQL command line from cmd, you need to use username root with your password.
Follow the below given steps. The syntax is as follows −
cd \> press enter key
cd Program Files\MySQL\MySQL Server 8.0\bin> press enter key
C:\Program Files\MySQL\MySQL Server 8.0\bin>mysql -uroot -p press enter key
Enter password: ******
Here is the step by step instruction to open MySQL command line. First, Go to START > RUN or Open Run using Windows+R command −
Type CMD and hit OK button −
After pressing OK button, the CMD will open −
Now you need to follow the above instruction. First reach your bin directory and follow the below given steps −
Step 1 −
Step 2 −
Now write the below command to open MySQL command line.
Step 3 −
Now press the enter button.
Step 4 −
After that you need to provide the password.
Step 5 −
After that you need to press enter key to open the MySQL command line −
forward_list::begin() and forward_list::end() in C++ STL

In this article we will be discussing the working, syntax and examples of forward_list::begin() and forward_list::end() functions in C++.
Forward list are sequence containers that allow constant time insert and erase operations anywhere within the sequence. Forward list are implement as a singly-linked lists. The ordering is kept by the association to each element of a link to the next element in the sequence.
forward_list::begin() is an inbuilt function in C++ STL which is declared in header file. begin() returns the iterator which is referred to the first element in the forward_list container. Mostly we use begin() and end() together to give the range of an forward_list container.
forwardlist_container.begin();
This function accepts no parameter.
This function returns a bidirectional iterator pointing to the first element of the container.
 Live Demo
#include <bits/stdc++.h>
using namespace std;
int main(){
   //creating a forward list
   forward_list<int> forwardList = { 4, 1, 2, 7 };
   cout<<"Printing the elements of a forward List\n";
   //calling begin() to point to the first element
   for (auto i = forwardList.begin(); i != forwardList.end(); ++i)
      cout << ' ' << *i;
   return 0;
}
If we run the above code it will generate the following output
Printing the elements of a forward List
4 1 2 7
forward_list::end() is an inbuilt function in C++ STL which is declared in header file. end() returns the iterator which is referred to the last element in the forward_list container. Mostly we use begin() and end() together to give the range of an forward_list container.
forwardlist_container.end();
This function accepts no parameter.
This function returns a bidirectional iterator pointing to the first element of the container.
 Live Demo
#include <bits/stdc++.h>
using namespace std;
int main(){
   //creating a forward list
   forward_list<int> forwardList = { 4, 1, 2, 7 };
   cout<<"Printing the elements of a forward List\n";
   //calling begin() to point to the first element
   for (auto i = forwardList.begin(); i != forwardList.end(); ++i)
      cout << ' ' << *i;
   return 0;
}
If we run the above code it will generate the following output
Printing the elements of a forward List
4 1 2 7
How to find specific row with a MySQL query?

Let us first create a table −
mysql> create table DemoTable
(
   UserId int,
   UserName varchar(100)
);
Query OK, 0 rows affected (0.66 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(100,'Chris');
Query OK, 1 row affected (0.19 sec)
mysql> insert into DemoTable values(101,'Bob');
Query OK, 1 row affected (0.07 sec)
mysql> insert into DemoTable values(102,'David');
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable values(103,'Mike');
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable values(104,'Sam');
Query OK, 1 row affected (0.16 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+--------+----------+
| UserId | UserName |
+--------+----------+
|    100 | Chris    |
|    101 | Bob      |
|    102 | David    |
|    103 | Mike     |
|    104 | Sam      |
+--------+----------+
5 rows in set (0.00 sec)
Following is the query to find the specific row and display the record of that row −
mysql> select *from DemoTable where UserId=102 and UserName='David';
This will produce the following output −
+--------+----------+
| UserId | UserName |
+--------+----------+
|    102 | David    |
+--------+----------+
1 row in set (0.00 sec)
Operating Systems | Memory Management | Question 9 - GeeksforGeeks

28 Jun, 2021
A computer uses 46–bit virtual address, 32–bit physical address, and a three–level paged page table organization. The page table base register stores the base address of the first–level table (T1), which occupies exactly one page. Each entry of T1 stores the base address of a page of the second–level table (T2). Each entry of T2 stores the base address of a page of the third–level table (T3). Each entry of T3 stores a page table entry (PTE). The PTE is 32 bits in size. The processor used in the computer has a 1 MB 16 way set associative virtually indexed physically tagged cache. The cache block size is 64 bytes.
What is the size of a page in KB in this computer? (GATE 2013)(A) 2(B) 4(C) 8(D) 16Answer: (C)Explanation:
Let the page size is of 'x' bits

Size of T1 = 2 ^ x bytes

(This is because T1 occupies exactly one page)

Now, number of entries in T1 = (2^x) / 4

(This is because each page table entry is 32 bits
  or 4 bytes in size)

Number of entries in T1 = Number of second level 
page tables

(Because each I-level page table entry stores the 
 base address of page of II-level page table)

Total size of second level page tables = ((2^x) / 4) * (2^x)

Similarly, number of entries in II-level page tables = Number
 of III level page tables = ((2^x) / 4) * ((2^x) / 4)

Total size of third level page tables = ((2^x) / 4) * 
                                        ((2^x) / 4) * (2^x)

Similarly, total number of entries (pages) in all III-level 
page tables = ((2^x) / 4) * ((2^x) / 4) * ((2^x) / 4)
            = 2^(3x - 6)

Size of virtual memory = 2^46

Number of pages in virtual memory = (2^46) / (2^x) = 2^(46 - x)

Total number the pages in the III-level page tables = 
                              Number of pages in virtual memory

2^(3x - 6) = 2^(46 - x)

3x - 6 = 46 - x

4x = 52
x = 13

That means, page size is of 13 bits
or Page size = 2^13 bytes = 8 KB 
Quiz of this Question
memory-management
Operating Systems-Memory Management
Operating Systems Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Scheduling in Greedy Algorithms
Introduction and Installation of Git
CPU Scheduling Numerical Questions
Operating Systems | CPU Scheduling | Question 4
Operating Systems | Input Output Systems | Question 2
Operating Systems | CPU Scheduling | Question 5
Operating Systems | CPU Scheduling | Question 3
File System Inconsistency
Operating Systems | Deadlock | Question 1
Program to show that Linux provides time sharing environment to processes
AIML - First Application

Let us start creating first bot which will simply greet a user with Hello User! when a user types Hello Alice.
As in AIML Environment Setup, we've extracted content of program-ab in C > ab with the following directory structure.
c:/ab/bots
Stores AIML bots
c:/ab/lib
Stores Java libraries
c:/ab/out
Java class file directory
c:/ab/run.bat
batch file for running Program AB
Now, create a directory test inside C > ab > bots and create the following directories in it.
c:/ab/bots/test/aiml
Stores AIML files
c:/ab/bots/test/aimlif
Stores AIMLIF files
c:/ab/bots/test/config
Stores configuration files
c:/ab/bots/test/sets
Stores AIML Sets
c:/ab/bots/test/maps
Stores AIML Maps
Create test.aiml inside C > ab > bots > test > aiml and test.aiml.csv inside C > ab > bots > test > aimlif directories.
<?xml version = "1.0" encoding = "UTF-8"?>
<aiml version="1.0.1" encoding = "UTF-8"?>
   <category>
      <pattern> HELLO ALICE </pattern>
      
      <template>
         Hello User
      </template>
      
   </category>
</aiml>
0,HELLO ALICE,*,*,Hello User,test.aiml

Open the command prompt. Go to C > ab > and type the following command −
java -cp lib/Ab.jar Main bot = test action = chat trace = false

You'll see the following output −
Working Directory = C:\ab

Program AB 0.0.4.2 beta -- AI Foundation Reference AIML 2.0 implementation
bot = test
action = chat
trace = false
trace mode = false
Name = test Path = C:\ab/bots/test

C:\ab
C:\ab/bots
C:\ab/bots/test
C:\ab/bots/test/aiml
C:\ab/bots/test/aimlif
C:\ab/bots/test/config
C:\ab/bots/test/logs
C:\ab/bots/test/sets
C:\ab/bots/test/maps

Preprocessor: 0 norms 0 persons 0 person2
Get Properties: C:\ab/bots/test/config/properties.txt
addAIMLSets: C:\ab/bots/test/sets does not exist.
addCategories: C:\ab/bots/test/aiml does not exist.
AIML modified Tue Apr 07 22:24:29 IST 2015 AIMLIF modified Tue Apr 07 22:26:53 I
ST 2015
No deleted.aiml.csv file found
No deleted.aiml.csv file found
Loading AIML files from C:\ab/bots/test/aimlif

Reading Learnf file
Loaded 1 categories in 0.009 sec
--> Bot test 1 completed 0 deleted 0 unfinished
(1[6])--HELLO-->(1[5])--ALICE-->(1[4])--<THAT>-->(1[3])--*-->(1[2])--<TOPIC>-->(
1[1])--*-->(0[null,null]) Hello User...
7 nodes 6 singletons 1 leaves 0 shortcuts 0 n-ary 6 branches 0.85714287 average
branching
Human:

Type Hello Alice and see the result and then type anything else to see the changed result.
Human: hello alice
Robot: Hello User
Human: bye
Robot: I have no answer for that.
Human:

 Print
 Add Notes
 Bookmark this page
Python | Replace elements in second list with index of same element in first list

18 Aug, 2021
Given two lists of strings, where first list contains all elements of second list, the task is to replace every element in second list with index of elements in first list.Method #1: Using Iteration  
Python3
# Python code to replace every element# in second list with index of first element. # List InitializationInput1 = ['cut', 'god', 'pass']Input2 = ['god', 'cut', 'cut', 'cut',          'god', 'pass', 'cut', 'pass'] # List InitializationOutput = [] # Using iterationfor x in Input2:    for y in Input1:        if x == y:            Output.append(Input1.index(y)) # Printing outputprint("initial 2 list are")print(Input1, "\n", Input2)print("Second list after replacement is:", Output)
initial 2 list are
['cut', 'god', 'pass'] 
 ['god', 'cut', 'cut', 'cut', 'god', 'pass', 'cut', 'pass']
Second list after replacement is: [1, 0, 0, 0, 1, 2, 0, 2]
 
  Method #2: Using List comprehension  
Python3
# Python code to replace every element# in second list with index of first element. # List initializationInput1 = ['cut', 'god', 'pass'] # using enumeratetemp = {y:x for x, y in enumerate(Input1)} # List initializationInput2 = ['god', 'cut', 'cut', 'cut',          'god', 'pass', 'cut', 'pass'] # Using list comprehensionOutput = [temp.get(elem) for elem in Input2] # Printing outputprint("initial 2 list are")print(Input1, "\n", Input2)print("Second list after replacement is:", Output)
initial 2 list are
['cut', 'god', 'pass'] 
 ['god', 'cut', 'cut', 'cut', 'god', 'pass', 'cut', 'pass']
Second list after replacement is: [1, 0, 0, 0, 1, 2, 0, 2]
 
  Method #3 : Using map  
Python3
# Python code to replace every element# in second list with index of first element. # List initializationInput1 = ['cut', 'god', 'pass'] # List initializationInput2 = ['god', 'cut', 'cut', 'cut',          'god', 'pass', 'cut', 'pass'] elem = {k: i for i, k in enumerate(Input1)}Output = list(map(elem.get, Input2)) # Printing outputprint("initial 2 list are")print(Input1, "\n", Input2)print("Second list after replacement is:", Output)
initial 2 list are
['cut', 'god', 'pass'] 
 ['god', 'cut', 'cut', 'cut', 'god', 'pass', 'cut', 'pass']
Second list after replacement is: [1, 0, 0, 0, 1, 2, 0, 2]
 
varshagumber28
Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
How to Install PIP on Windows ?
*args and **kwargs in Python
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 does Selenium Webdriver handle SSL certificate in Chrome?

We can handle SSL certificate with Selenium webdriver in Chrome browser. A SSL is the standardized protocol used to create a connection between the browser and server.
The information exchanged via a SSL certificate is encrypted and it verifies if the information is sent to the correct server. It authenticates a website and provides protection from hacking.
An untrusted SSL certificate error is thrown if there are problems in the SSL certificate. We shall receive such an error while we launch a website. In Chrome, we use the ChromeOptions class to work with SSL certificates.
We shall create an instance of this class and set the capability - setAcceptInsecureCerts to true. Finally, this property of the Chrome browser shall be passed to the webdriver object.
ChromeOptions c = new ChromeOptions();
c.setAcceptInsecureCerts(true);
import org.openqa.selenium.By;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.WebDriver;
public class SSLErrorChrome {
   public static void main(String[] args) throws IOException {
      //object of ChromeOptions
      ChromeOptions c = new ChromeOptions();

      //set browser properties
      c.setAcceptInsecureCerts(true);
      System.setProperty("webdriver.chrome.driver",
         "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      // pass browser option to webdriver
      WebDriver driver = new ChromeDriver(c);
      //implicit wait
      driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
      //URL launch
      driver.get("application url to be entered");
      driver.quit();
   }
}