code-rag-bench/online-tutorials huggingface dataset:
malloc() vs new - GeeksforGeeks

08 Jul, 2021
Following are the differences between malloc() and operator new.: 
Calling Constructors: new calls constructors, while malloc() does not. In fact primitive data types (char, int, float.. etc) can also be initialized with new. For example, below program prints 10.
Calling Constructors: new calls constructors, while malloc() does not. In fact primitive data types (char, int, float.. etc) can also be initialized with new. For example, below program prints 10.
CPP
#include<iostream>using namespace std;int main(){    // Initialization with new()    int *n = new int(10);    cout << *n;    getchar();    return 0;}
10
 
2. operator vs function: new is an operator, while malloc() is a function.
3. return type: new returns exact data type, while malloc() returns void *.
4. Failure Condition: On failure, malloc() returns NULL where as new throws bad_alloc exception.
5. Memory: In case of new, memory is allocated from free store where as in malloc() memory allocation is done from heap.
6. Size: Required size of memory is calculated by compiler for new, where as we have to manually calculate size for malloc().
7. Buffer Size: malloc() allows to change the size of buffer using realloc() while new doesn’t
new
malloc()
Please write comments if you find anything incorrect in the above post, or you want to share more information about the topic discussed above.
Yash Kumar Atri
anukashasingh
r237
singhbishalkumarsingh
C Language
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Substring in C++
Multidimensional Arrays in C / C++
Converting Strings to Numbers in C/C++
Left Shift and Right Shift Operators in C/C++
Function Pointer in C
Vector in C++ STL
Initialize a vector in C++ (6 different ways)
Inheritance in C++
Map in C++ Standard Template Library (STL)
C++ Classes and Objects
Python - Union of Tuples - GeeksforGeeks

30 Jan, 2020
Sometimes, while working with tuples, we can have a problem in which we need union of two records. This type of application can come in Data Science domain. Let’s discuss certain ways in which this problem can be solved.
Method #1 : Using set() + “+” operator This task can be performed using union functionality offered by + operator over sets. The conversion to set is done by set().
# Python3 code to demonstrate working of# Union of Tuples# Using set() + "+" operator  # initialize tuplestest_tup1 = (3, 4, 5, 6)test_tup2 = (5, 7, 4, 10)  # printing original tuplesprint("The original tuple 1 : " + str(test_tup1))print("The original tuple 2 : " + str(test_tup2))  # Union of Tuples# Using set() + "+" operatorres = tuple(set(test_tup1 + test_tup2))  # printing resultprint("The union elements from tuples are : " + str(res))
The original tuple 1 : (3, 4, 5, 6)
The original tuple 2 : (5, 7, 4, 10)
The union elements from tuples are : (3, 4, 5, 6, 7, 10)


 Method #2 : Using union() + set() This is method similar to above method, the difference is that instead of + operator, we use inbuilt function to perform the task of filtering dissimilar elements. 
# Python3 code to demonstrate working of# Union of Tuples# Using union() + set()  # initialize tuplestest_tup1 = (3, 4, 5, 6)test_tup2 = (5, 7, 4, 10)  # printing original tuplesprint("The original tuple 1 : " + str(test_tup1))print("The original tuple 2 : " + str(test_tup2))  # Union of Tuples# Using union() + set()res = tuple(set(test_tup1).union(set(test_tup2)))  # printing resultprint("The union elements from tuples are : " + str(res))
The original tuple 1 : (3, 4, 5, 6)
The original tuple 2 : (5, 7, 4, 10)
The union elements from tuples are : (3, 4, 5, 6, 7, 10)


 
Python tuple-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
How to print without newline in Python?
Puzzle | (Basketball shots) - GeeksforGeeks

26 Jul, 2017
You have a basketball hoop and someone says that you can play one of two games.Game1 : You get one shot to make the hoop.Game2 : You get three shots and you have to make two of three shots.If p is the probability of making a particular shot, for which values of p should you pick one game or the other?
Answer:
Probability of winning the Game 1:The probability of winning game 1 is p, by definition.
Probability of winning the Game 2:Let s(k, n) be the probability of making exactly k shots out of n.The probability of winning the Game 2 is the probability of making exactly two shots out of three OR making all three shots. In other words:
P(winning) = s(2, 3) + s(3, 3)
The probability of making all the three shots is:
s(3, 3) = 
The probability of making exactly two shots is:P(making 1 and 2, & missing 3) + P(making 1 and 3, & missing 2) + P(making 2 and 3, & missing 1)
   = [p * p * (1-p)] + [p * (1-p) * p] + [(1-p) * p * p]
   = 3*(1-p)*

Adding these together, we get:
   =  + 3(1-p)
   =  + 3 - 3
   = 3 - 2

Which game you should play?You should play Game 1 if P(Game 1) > P(Game 2):
    p > 3 - 2
    1 > 3p - 2
    2 - 3p + 1 > 0
    (2p - 1)(p - 1) > 0

Both terms must be positive, or both must be negative, But we know p < 1, so p – 1 < 0. This means both terms must be negative.
    2p - 1 < 0
    2p < 1
    p < 0.5

So, we should play Game 1 if 0 < p < 0.5 and Game 2 if 0.5 < p < 1.If p = 0, 0.5, or 1 then P(Game 1) = P(Game 2), so it doesn't matter which game we play.
This article is contributed by Brahmani Sai. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Probability
Puzzles
Puzzles
Probability
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
SDE SHEET - A Complete Guide for SDE Preparation
Algorithm to solve Rubik's Cube
Top 20 Puzzles Commonly Asked During SDE Interviews
Puzzle 15 | (Camel and Banana Puzzle)
Puzzle 21 | (3 Ants and Triangle)
Puzzle 16 | (100 Doors)
Puzzle 18 | (Torch and Bridge)
Container with Most Water
Puzzle | Set 35 (2 Eggs and 100 Floors)
Puzzle 11 | (1000 Coins and 10 Bags)
Python | Split strings in list with same prefix in all elements

25 Apr, 2019
Sometimes we face a problem in which we have a list of strings and there are some garbage/unwanted letters at its prefix or suffix or at the specified position uniformly, i.e this extends to all the strings in the list. Let’s discuss certain ways in which this problem can be solved.
Method #1 : Using list comprehension + list slicing
This task can be performed using list comprehension and list slicing. List slicing can be used to remove the unwanted letters and list comprehension can be used to extend the logic to the entire string.
# Python3 code to demonstrate# Split strings in list# Using list comprehension + list slicing  # initializing listtest_list = ['Rs.25', 'Rs.100', 'Rs.143', 'Rs.12', 'Rs.4010']  # printing original listprint("The original list : " + str(test_list))  # using list comprehension + list slicing# Split strings in listres = [sub[3:] for sub in test_list]  # print resultprint("The list after string slicing : " + str(res))
The original list : ['Rs.25', 'Rs.100', 'Rs.143', 'Rs.12', 'Rs.4010']
The list after string slicing : ['25', '100', '143', '12', '4010']

 
Method #2 : Using map() + slicing + lambda
This particular task can be performed using map function as well. The task of performing the same for each string is handled by lambda function and map function.
# Python3 code to demonstrate# Split strings in list# Using map() + slicing + lambda  # initializing listtest_list = ['Rs.25', 'Rs.100', 'Rs.143', 'Rs.12', 'Rs.4010']  # printing original listprint("The original list : " + str(test_list))  # using map() + slicing + lambda# Split strings in listres = list(map(lambda sub: sub[3:], test_list))  # print resultprint("The list after string slicing : " + str(res))
The original list : ['Rs.25', 'Rs.100', 'Rs.143', 'Rs.12', 'Rs.4010']
The list after string slicing : ['25', '100', '143', '12', '4010']

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
Python String | replace()
How to Install PIP on Windows ?
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
Matplotlib.pyplot.set_cmap() in Python

19 Apr, 2020
Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. Pyplot is a state-based interface to a Matplotlib module which provides a MATLAB-like interface. There are various plots which can be used in Pyplot are Line Plot, Contour, Histogram, Scatter, 3D Plot, etc.
The set_cmap() function in pyplot module of matplotlib library is used to set the default colormap, and applies it to the current image if any.
Syntax: matplotlib.pyplot.set_cmap(cmap)
Parameters:
cmap : This parameter is the colormap instance or the name of a registered colormap.
Returns: This method does not return any value.
Below examples illustrate the matplotlib.pyplot.set_cmap() function in matplotlib.pyplot:
Example 1:
# Implementation of matplotlib functionimport matplotlib.pyplot as pltimport matplotlib.tri as triimport numpy as npang = 40rad = 10radm = 0.35radii = np.linspace(radm, 0.95, rad)   angles = np.linspace(0, np.pi, ang)angles = np.repeat(angles[..., np.newaxis],                    rad, axis = 1)  angles[:, 1::2] += np.pi / ang   x = (radii * np.cos(angles)).flatten()y = (radii * np.sin(angles)).flatten()z = (np.sin(4 * radii) * np.cos(4 * angles)).flatten()   triang = tri.Triangulation(x, y)triang.set_mask(np.hypot(x[triang.triangles].mean(axis = 1),                         y[triang.triangles].mean(axis = 1))                < radm)   tpc = plt.tripcolor(triang, z,                     shading ='flat')plt.set_cmap("Greens")plt.title('matplotlib.pyplot.set_cmap() Example')plt.show()
Output:
Example 2:
# Implementation of matplotlib functionimport matplotlib.pyplot as pltimport numpy as npfrom matplotlib.colors import LogNorm      dx, dy = 0.015, 0.05x = np.arange(-4.0, 4.0, dx)y = np.arange(-4.0, 4.0, dy)X, Y = np.meshgrid(x, y)   extent = np.min(x), np.max(x), np.min(y), np.max(y)      Z1 = np.add.outer(range(8), range(8)) % 2plt.imshow(Z1, cmap ="binary_r",            interpolation ='nearest',           extent = extent, alpha = 1)   def geeks(x, y):    return (1 - x / 2 + x**5 + y**6) * np.exp(-(x**2 + y**2))   Z2 = geeks(X, Y)   plt.imshow(Z2, alpha = 0.7,           interpolation ='bilinear',           extent = extent)  plt.set_cmap("gist_rainbow")plt.title('matplotlib.pyplot.set_cmap() Example')plt.show()
Output:
Python-matplotlib
Python
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
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Python OOPs Concepts
Netcracker Interview Experience

22 Feb, 2021
Round 1: The first round was an aptitude and coding test, an aptitude round quantitative aptitude, logical reasoning, and technical questions were asked. They were more intuitive. They were not very difficult but were very tricky.
Suggestion: Practice aptitude to gain confidence, accuracy, and speed.
There were 2 coding questions
https://www.geeksforgeeks.org/find-water-in-a-glass/A dynamic programming question, A 2D matrix was given with children as rows and toys as columns. The values at indexes are 0 or 1 as either a child can have this toy or not. I had to find a way to allocate a child a toy with a one-to-one relation. If exists then print “YES” then “NO”.
https://www.geeksforgeeks.org/find-water-in-a-glass/
A dynamic programming question, A 2D matrix was given with children as rows and toys as columns. The values at indexes are 0 or 1 as either a child can have this toy or not. I had to find a way to allocate a child a toy with a one-to-one relation. If exists then print “YES” then “NO”.
Round 2 (Technical round): The interviewer starts with some easy questions like personal questions to break the ice. After this, he starts asking questions based on my resume like projects, etc. He asked me to explain my projects and gave him my experience with creating projects and concepts used in them. The questions were based on OOPS. He then asked me some basic data structure questions. 
https://www.geeksforgeeks.org/check-if-two-trees-are-mirror/
https://www.geeksforgeeks.org/check-if-two-trees-are-mirror/
The interview goes about 40 minutes.
ROUND 3 (HR round):
Basic HR questions were asked.
Conclusion: Got selected
Marketing
Netcracker
Interview Experiences
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Google SWE Interview Experience (Google Online Coding Challenge) 2022
Samsung Interview Experience Research & Institute SRIB (Off-Campus) 2022
Amazon Interview Experience for SDE 1
TCS Ninja Interview Experience (2020 batch)
Amazon Interview Experience SDE-2 (3 Years Experienced)
Write It Up: Share Your Interview Experiences
Samsung RnD Coding Round Questions
Amazon Interview Experience for SDE-1
Nagarro Interview Experience
Tiger Analytics Interview Experience for Data Analyst (On-Campus)
TypeScript | Array push() Method

18 Jun, 2020
The Array.push() is an inbuilt TypeScript function which is used to append the given element(s) in the last of the array and returns the length of the new array. Syntax:
 array.push(element1, ..., elementN)
Parameter: This method accept a single parameter as mentioned above and described below:
element1, ..., elementN : This parameter is the elements to add to the end of the array.
Return Value: This method returns the length of the new array. Below examples illustrate Array push() method in TypeScript:
Example 1: 
JavaScript
<script>    // Driver code    var arr = [ 11, 89, 23, 7, 98 ];       // use of push() method     var val = arr.push(8)           // printing element    console.log( arr );</script>
Output: 
[11,89,23,7,98,8]

Example 2: 
JavaScript
<script>    // Driver code    var arr = [2, 5, 6, 3, 8, 9];     var val,j=0;       // use of push() method        for(j=0; j<4 ; j++){      var y = arr[j];      var x = y * j;      val = arr.push(x);    }    // printing element    console.log( arr );</script>
Output: 
[2,5,6,3,8,9,0,5,12,9]

TypeScript
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
How to append HTML code to a div using JavaScript ?
Difference Between PUT and PATCH Request
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
Interview Preparation for Software Developer - GeeksforGeeks

28 Jun, 2021
Most Important ones
Interview Preparation Course (Free)
How to prepare for ACM-ICPC
Internship Interview Experiences Company-Wise
How to prepare for Google Kickstart – a CodeJam competition?
How to prepare for Facebook Hacker Cup?
A step by step guide for placement preparation Set 1 – Basic
A step by step guide for placement preparation Set 2- Advanced
Top 10 algorithms in Interview Questions
Top 20 Greedy Algorithms Interview Questions
Top 20 Dynamic Programming Interview Questions
Top 20 Backtracking Algorithm Interview Questions
Top 20 Linked List Interview Question
Top 20 Hashing Technique based Interview Questions
Top 10 Interview Questions on Depth First Search (DFS)
Top 25 Interview Questions
Commonly asked Interview Questions for Front End Developers
Frequently asked questions for Java Developer Position from a fresher
Competitive Programming Contests
How to begin with Competitive Programming
Top 10 Algorithms and Data Structures for Competitive Programming
How to prepare for Google Asia Pacific University (APAC) Test ?
Subject Wise
10 Most asked Questions from Java Programmers
Commonly Asked C Programming Interview Questions | Set 1
Commonly Asked C Programming Interview Questions | Set 2
Commonly Asked Java Programming Interview Questions | Set 1
Commonly Asked Java Programming Interview Questions | Set 2
Commonly Asked OOP Interview Questions
Commonly Asked C++ Interview Questions
Commonly asked DBMS interview questions | Set 1
Commonly asked DBMS interview questions | Set 2
Commonly Asked Operating Systems Interview Questions | Set 1
Commonly Asked Data Structure Interview Questions.
Commonly Asked Algorithm Interview Questions
Commonly asked Computer Networks Interview Questions
Company Wise
Amazon’s most asked interview questions Set 1 Set 2
Microsoft’s most asked interview questions Set 1 Set 2
Accenture’s most asked Interview Questions
Prepare Yourself
Behavioral10 mistakes people tend to do in an Interview6 Tips to Prepare Behavioral Interview QuestionsTop 5 Common Mistakes in Technical On-site Interviews
10 mistakes people tend to do in an Interview
6 Tips to Prepare Behavioral Interview Questions
Top 5 Common Mistakes in Technical On-site Interviews
ProgrammingC++ STL TutorialJava Collections Tutorial
C++ STL Tutorial
Java Collections Tutorial
Aptitude, Reasoning and EnglishCampus Placement Preparation Course
Campus Placement Preparation Course
 
Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
JavaScript Comma operator

06 Jan, 2022
Below is the example of the Comma operator.
Example:<script>     function x() {         document.write('one'+"</br>");         return 'one';     }     function y() {         document.write('two'+"</br>");         return 'two';     }     function z() {         document.write('three'+"</br>");         return 'three';     }       // Three expressions are     // given at one place     var x = (x(), y(), z());       document.write(x); </script> 
Example:
<script>     function x() {         document.write('one'+"</br>");         return 'one';     }     function y() {         document.write('two'+"</br>");         return 'two';     }     function z() {         document.write('three'+"</br>");         return 'three';     }       // Three expressions are     // given at one place     var x = (x(), y(), z());       document.write(x); </script> 
Output:one
two
three
three
Output:
one
two
three
three
A comma operator (,) in JavaScript is used in the same way as it is used in many programming languages like C, C++ etc. This operator mainly evaluates its operands from left to right sequentially and returns the value of the rightmost operand. A comma operator is used as a separator for multiple expressions at a place that requires a single expression. When a comma operator is placed in an expression, it executes each expression and returns the rightmost expression.
Syntax:
Expression1, Expression2, Expression3, ....so on
In the above syntax, multiple expressions are separated using a comma operator. During execution, each expression will be executed from left to right and the rightmost expression will be returned.
Example:
<script>    function x() {        document.write('Welcome');        return 'Welcome';    }    function y() {        document.write('to');        return 'to';    }    function z() {        document.write('Geeksforgeeks');        return 'Geeksforgeeks';    }      // Three expressions are     // given at one place    var x = (x(), y(), z());      document.write(x);</script>
Output:
In the output, first of all the function x() is executed then y() and lastly z(). Finally, comma operator returns rightmost expression.
The most useful application of comma operator is in loops. In loops, it is used to update multiple variables in the same expression.
Example:
<script> for (var a = 0, b =5; a <= 5; a++, b--) {  document.write(a, b);}</script> 
Output:
Supported Browsers:
Google Chrome
Internet Explorer
Firefox
Apple Safari
Opera
javascript-basics
javascript-operators
Picked
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Run Multiple Versions of Node.js ?

17 Aug, 2021
Usually, we work on different versions for our Node.js project and it’s hard to manage them, but fortunately, there is a tool called NVM(node version manager) which helps to manage your node version and switch between them according to your projects.
Install NVM Module:
You can install the nvm module using the following command:
Using curl: $ curl -o- https://raw.githubusercontent.com/nvm-sh/v0.34.0/install.sh | bash
 
 
After installation, you need to add a bit of configuration in your .bashrc file as shown below:
 
$ nano ~/.bashrc
Then add the following code to the end of the file: 
 
export NVM_DIR="${XDG_CONFIG_HOME/:-$HOME/.}nvm"
[ -s :$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
Reload your bash using the following command:
 
$ source ~/.bashrc 
Module Installation: To install the latest version of Node, the following command can be used:
 
$ nvm install node
To install the specific version of Node, the following command can be used:
 
$ nvm install {node_version}
$ nvm install 10.10.0
List all Node Version: To list out all the versions installed, the following command can be used:
 
$ nvm ls
Switch Node Version: The switching between different node versions can be done using the following command:
 
$ nvm use node  # to use latest version
$ nvm use 10.0.0  # for a specific version
Deleting Node versions: The node versions can be uninstalled using the following command:
 
$ nvm uninstall 10.0.0
Conclusion: Managing the node versions is very useful if you are working on multiple projects which requires a different version of node. Above given are some important commands for doing so.
 
Reference: 
 
About NVM: https://github.com/nvm-sh/nvm
About the Linux Command line: https://btholt.github.io/complete-intro-to-linux-and-the-cli/  
 
abhishek0719kadiyan
Node.js-Misc
JavaScript
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Remove elements from a JavaScript Array
Difference Between PUT and PATCH Request
Roadmap to Learn JavaScript For Beginners
JavaScript | Promises
How to update Node.js and NPM to next version ?
Installation of Node.js on Linux
Node.js fs.readFileSync() Method
Node.js fs.writeFile() Method
How to install the previous version of node.js and npm ?
Python Program to Generate Random binary string

08 Oct, 2021
Given a number n, the task is to generate a random binary string of length n.Examples: 
Input: 7
Output: Desired length random binary string is:  1000001

Input: 5
Output: Desired length random binary string is:  01001
Approach
Initialize an empty string, say key 
Generate a randomly either “0” or “1” using randint function from random package. 
Append the randomly generated “0” or “1” to the string, key 
Repeat step 2 and 3 for the desired length of the string  
Below is the implementation.
Python3
# Python program for random# binary string generation  import random  # Function to create the# random binary stringdef rand_key(p):       # Variable to store the    # string    key1 = ""     # Loop to find the string    # of desired length    for i in range(p):                 # randint function to generate        # 0, 1 randomly and converting        # the result into str        temp = str(random.randint(0, 1))         # Concatenation the random 0, 1        # to the final result        key1 += temp             return(key1) # Driver Coden = 7str1 = rand_key(n)print("Desired length random binary string is: ", str1)
Output:
Desired length random binary string is:  1000001
simmytarika5
Python string-programs
Python
Python Programs
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
Python OOPs Concepts
How to drop one or multiple columns in Pandas Dataframe
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
DorkScout – Automate google dork scan against the entiere internet or specific targets

23 Sep, 2021
Dorking is the technique used for advanced searching. Dorking can be useful in target domain detection or forgetting some sensitive data from the target domain, This can be done through automated tools which can reduce the time of manual searching. DorkScout is a tool to automate the finding of vulnerable applications or hidden files around the internet through google searches, dorkscout first starts by retrieving the dork’s lists from https://www.exploit-db.com/google-hacking-database, and then it scans a given target or everything it endows. DorkScout tool is developed in Golang language and is available on the GitHub platform. DorkScout tool is open-source and free-to-use.
Note: DorkScout is a Golang language-based tool, so you need to have a Golang environment on your system. So check this link to Install  Golang in your system. – Installation of Go Lang in Linux
Step 1: If you have downloaded Golang in your system, verify the installation by checking the version of Golang, use the following command.
go version
Step 2: Get the DorkScout repository or clone the DorkScout tool from Github, use the following command.
sudo GO111MODULE=on go get -u github.com/R4yGM/dorkscout
Step 3: Change the directory to access the tool. Use the following command
cd go/bin
Step 4: Check the help menu page to get a better understanding of the DorkScout tool, use the following command.
dorkscout -h
Example 1:  Scans a specific website for a list of dorks
dorkscout scan -d= “/home/kali/Desktop/dorkscout/dorks/Sensitive\ Directories.dorkscout” -H= “/home/kali/Desktop/dorkscout/results/”
We are displaying the list of dorks in the below screenshot.
We have got the results for our Dorking scan.
.html formatted results and displayed in the below screenshot.
Example 2: Install a list of dorks from exploit-db.com/ Install word-lists
dorkscout install -o /home/kali/Desktop/
In this example, we will be installing new and updated dorking lists for the exploit-db database.
Dorks are installed in the Desktop directory.
In the above screenshot, we can see that all the dork files are installed on the desktop directory. In the below screenshot, we have opened the “Network or Vulnerability Data.dorkscout” file which contains the dork query related to Network.
Kali-Linux
Linux-Tools
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Docker - COPY Instruction
scp command in Linux with Examples
chown command in Linux with Examples
SED command in Linux | Set 2
nohup Command in Linux with Examples
mv command in Linux with examples
chmod command in Linux with examples
Array Basics in Shell Scripting | Set 1
Introduction to Linux Operating System
Basic Operators in Shell Scripting
Wait for user input to start a sketch in Arduino

A problem faced by several people using Arduino, or any microcontroller board for that matter, is that you may forget to start the Serial Monitor before programming the board, and miss some print statements by the time you open the Serial Monitor.
One way to overcome this is to start the sketch only after an input is received from the user, via the Serial Monitor. This will ensure that you don’t miss any prints on the Serial Monitor because of the delay in starting the Serial Monitor.
void setup() {
   // put your setup code here, to run once:
   Serial.begin(9600);
   Serial.println();
   Serial.println("Please send a character to start the sketch");
   while (Serial.available() == 0) {
      Serial.print(".");
      delay(500);
   }
   while (Serial.available() > 0) {
      Serial.read(); //Empty the read buffer
   }
}

void loop() {
   // put your main code here, to run repeatedly:
   Serial.println("Looping!");
   delay(1000);
}
As you can see, the sketch first waits for the user input. As soon as the user input is received, the sketch clears the read buffer, and then proceeds with the rest of the tasks.
The Serial Monitor Outputs show that
Please note that waiting for user input should only be done in the test code, and not in the production code, where there is no possibility of getting the user input.
Retrieving specific documents from collection by _id in MongoDB

To retrieve document from collection by _id, use find() with $in. Let us create a collection with documents −
> db.demo281.insertOne({"Name":"Chris","Age":21});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e4aac28dd099650a5401a66")
}
> db.demo281.insertOne({"Name":"Bob","Age":23});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e4aac46dd099650a5401a67")
}
> db.demo281.insertOne({"Name":"David","Age":28});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e4aac4fdd099650a5401a68")
}
Display all documents from a collection with the help of find() method −
> db.demo281.find();
This will produce the following output −
{ "_id" : ObjectId("5e4aac28dd099650a5401a66"), "Name" : "Chris", "Age" : 21 }
{ "_id" : ObjectId("5e4aac46dd099650a5401a67"), "Name" : "Bob", "Age" : 23 }
{ "_id" : ObjectId("5e4aac4fdd099650a5401a68"), "Name" : "David", "Age" : 28 }
Following is the query to retrieve specific documents from collection by _id −
>db.demo281.find({_id:{$in:[ObjectId("5e4aac28dd099650a5401a66"),ObjectId("5e4aac46dd099650a5401a67")]}});
This will produce the following output −
{ "_id" : ObjectId("5e4aac28dd099650a5401a66"), "Name" : "Chris", "Age" : 21 }
{ "_id" : ObjectId("5e4aac46dd099650a5401a67"), "Name" : "Bob", "Age" : 23 }
How to call JavaScript function in an alert box?

To call a JavaScript function in an alert box, you can try to run the following code −
Live Demo
<!DOCTYPE html>
<html>
   <body>
      <script>
         function myFunction(warning) {
            alert(warning);
            catchedAlert();
         }
         function catchedAlert() {
            alert('Alert called!');
         }
      </script>
      <button onclick="myFunction('This is an alert box!')">Click me!</button>
   </body>
</html>
Python Program for BogoSort or Permutation Sort

08 Jun, 2021
BogoSort also known as permutation sort, stupid sort, slow sort, shotgun sort or monkey sort is a particularly ineffective algorithm based on generate and test paradigm. The algorithm successively generates permutations of its input until it finds one that is sorted.(Wiki) For example, if bogosort is used to sort a deck of cards, it would consist of checking if the deck were in order, and if it were not, one would throw the deck into the air, pick the cards up at random, and repeat the process until the deck is sorted. 
PseudoCode:  
while not Sorted(list) do
    shuffle (list)
done
 
Python3
# Python program for implementation of Bogo Sortimport random # Sorts array a[0..n-1] using Bogo sortdef bogoSort(a):    n = len(a)    while (is_sorted(a)== False):        shuffle(a) # To check if array is sorted or notdef is_sorted(a):    n = len(a)    for i in range(0, n-1):        if (a[i] > a[i+1] ):            return False    return True # To generate permutation of the arraydef shuffle(a):    n = len(a)    for i in range (0,n):        r = random.randint(0,n-1)        a[i], a[r] = a[r], a[i] # Driver code to test abovea = [3, 2, 4, 1, 0, 5]bogoSort(a)print("Sorted array :")for i in range(len(a)):    print ("%d" %a[i]),
Output:  
Sorted array :
0
1
2
3
4
5
Please refer complete article on BogoSort or Permutation Sort for more details! 
anikaseth98
python sorting-exercises
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Convert string dictionary to dictionary
Python program to add two numbers
Python Program for factorial of a number
Python program to find second largest number in a list
Iterate over characters of a string in Python
Python | Convert set into a list
Python program to interchange first and last elements in a list
Appending to list in Python dictionary
Python | Convert a list into a tuple
Add a key:value pair to dictionary in Python
numpy.flatnonzero() in Python

28 Nov, 2018
numpy.flatnonzero()function is used to Compute indices that are non-zero in the flattened version of arr.
Syntax : numpy.flatnonzero(arr)
Parameters :arr : [array_like] Input array.
Return : ndarrayOutput array, containing the indices of the elements of arr.ravel() that are non-zero.
Code #1 : Working
# Python program explaining# flatnonzero() function  import numpy as geekarr = geek.arange(-3, 4)  print ("Input  array : ", arr)    out_arr = geek.flatnonzero(arr)print ("Indices of non zero elements : ", out_arr) 
Output :
Input  array :  [-3 -2 -1  0  1  2  3]
Indices of non zero elements :  [0 1 2 4 5 6]

 Code #2 : Using the indices of the non-zero elements as an index array.
# Python program using the indices of the non-zero # elements as an index array to extract these elements  out_arr = arr.ravel()[geek.flatnonzero(arr)]  print ("Output array of non-zero number: ", out_arr) 
Output :
Output array of non-zero number:  [-3 -2 -1  1  2  3]

Python numpy-Sorting Searching
Python-numpy
Python
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
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Python OOPs Concepts
Convert integer to string in Python
Difference between Direct and Immediate Addressing Modes

29 Jun, 2022
Prerequisite – Addressing Modes 
1. Direct Addressing Mode: In direct addressing mode, the address field contains the address of the operand.
Effective Address (EA) = address field of operand 
 
Example: Add the contents of register 1303 to the accumulator.
Add (1303) 
Only a single memory reference is required to access data. So no additional calculations are required to work out the effective address. 
2. Immediate Addressing Mode: In immediate addressing mode, the operand is a part of the instruction.
Here the Operand = Address Field 
 
Example: Add 3 to the accumulator.
ADD 3
No memory reference is required to fetch data. So no additional calculations are required to work out the effective address. It is a fast method. But the downside is that it has a limited range. Now let’s compare Direct and Immediate addressing modes.
annieahujaweb2020
Picked
Computer Organization & Architecture
Difference Between
GATE CS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PyQt5 QDockWidget – Setting Floating Property

28 Jul, 2020
In this article, we will see how we can set floating property to the QDockWidget. QDockWidget provides the concept of dock widgets, also know as tool palettes or utility windows. Dock windows are secondary windows placed in the dock widget area around the central widget in a QMainWindow(original window). This property holds whether the dock widget is floating.A floating dock widget is presented to the user as an independent window “on top” of its parent QMainWindow, instead of being docked in the QMainWindow.
In order to do this we will use setFloating method with the dock widget object.
Syntax : dock.setFloating(True)
Argument : It takes bool as argument
Return : It returns None
Below is the implementation
# importing librariesfrom PyQt5.QtWidgets import * from PyQt5 import QtCore, QtGuifrom PyQt5.QtGui import * from PyQt5.QtCore import * import sys    class Window(QMainWindow):      def __init__(self):        super().__init__()          # setting title        self.setWindowTitle("Python ")          # setting geometry        self.setGeometry(100, 100, 500, 400)          # calling method        self.UiComponents()          # showing all the widgets        self.show()      # method for components    def UiComponents(self):          # creating dock widget        dock = QDockWidget("GeeksforGeeks", self)          # push button        push = QPushButton("Press", self)          # setting widget to the dock        dock.setWidget(push)          # creating a label        label = QLabel("GeeksforGeeks", self)          # setting geometry to the label        label.setGeometry(100, 200, 300, 80)          # making label multi line        label.setWordWrap(True)          # setting geometry tot he dock widget        dock.setGeometry(100, 0, 200, 30)          # setting floating property        dock.setFloating(True)        # create pyqt5 appApp = QApplication(sys.argv)  # create the instance of our Windowwindow = Window()  # start the appsys.exit(App.exec())
Output :
Python PyQt-QDockWidget
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
turtle.tilt() function in Python

26 Jul, 2020
The turtle module provides turtle graphics primitives, in both object-oriented and procedure-oriented ways. Because it uses tkinter for the underlying graphics, it needs a version of Python installed with Tk support.
This function is used to rotate the turtleshape by the angle from its current tilt-angle, but do NOT change the turtle’s heading (direction of movement).
Syntax :
turtle.tilt(angle)

Below is the implementation of the above method with some examples :
Example 1 :
Python3
# import packageimport turtle  # set turtle screensc=turtle.Screen()sc.setup(500,300)  # set turtleturtle.speed(1)turtle.up()turtle.setpos(-200,0)turtle.down()turtle.shape("square")turtle.width(2)  # motionturtle.forward(200)  # tilt turtleshape by 45turtle.tilt(45)  # motionturtle.forward(200)
Output :
Example 2 :
Python3
# import packageimport turtle  # set screensc=turtle.Screen()sc.setup(500,350)  # set turtleturtle.speed(1)turtle.up()turtle.setpos(-50,100)turtle.down()turtle.shape("turtle")turtle.width(2)  # loop for patternfor i in range(6):        # motion    turtle.forward(100)          # tilt turtleshpae by 180    turtle.tilt(180)          # print turtleshape    turtle.stamp()          # move to right by 60    turtle.right(60)      # hide the turtleturtle.ht()
Output :
Python-turtle
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
Introduction To PYTHON
Python | os.path.join() method
How to drop one or multiple columns in Pandas Dataframe
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
Python – Summation of Unique elements

27 Feb, 2020
This article focuses on one of the operation of getting the unique list from a list that contains a possible duplicates and performing its summation. This operations has large no. of applications and hence it’s knowledge is good to have.
Method 1 : Naive method + sum()In naive method, we simply traverse the list and append the first occurrence of the element in new list and ignore all the other occurrences of that particular element. The task of summation is performed using sum().
# Python 3 code to demonstrate # Summation of Unique elements# using naive methods + sum()  # initializing listtest_list = [1, 3, 5, 6, 3, 5, 6, 1]print ("The original list is : " + str(test_list))  # using naive method + sum()# Summation of Unique elements# from list res = []for i in test_list:    if i not in res:        res.append(i)res = sum(res)  # printing list after removal print ("The unique elements summation : " + str(res))
The original list is : [1, 3, 5, 6, 3, 5, 6, 1]
The unique elements summation : 15

 
Method 2 : Using set() + sum()This is the most popular way by which the duplicated are removed from the list. After that the summation of list can be performed using sum().
# Python 3 code to demonstrate # Summation of Unique elements# using set() + sum()  # initializing listtest_list = [1, 5, 3, 6, 3, 5, 6, 1]print ("The original list is : " + str(test_list))  # using set() + sum()# Summation of Unique elements# from list res = sum(list(set(test_list)))  # Summation of Unique elements# using set() + sum()print ("The unique elements summation : " + str(res))
The original list is : [1, 3, 5, 6, 3, 5, 6, 1]
The unique elements summation : 15

Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
std::to_wstring in c++

14 Sep, 2021
This function is used to convert the numerical value to the wide string i.e. it parses a numerical value of datatypes (int, long long, float, double ) to a wide string. It returns a wide string of data type wstring representing the numerical value passed in the function. In this function data type is being internally typecasted to the wstring data type and bypassing the numerical value as its parameter we can obtain a wstring type of string in return where the numerical value has been typecasted to the desired data type. 
Syntax : 
wstring to_wstring (int val);
wstring to_wstring (long long val);
wstring to_wstring (float val);
wstring to_wstring (double val);
Parameters :
val :This is the numerical value that is to be converted to the wide string.

Return Value :
It returns the passed numerical value into the wide string of data type wstring.
C++
// C++ code to convert numerical value// to wide string data type// using the to_wstring function // These header files contains wcout,// wstring and to_wstring#include <iostream>#include <string>    using namespace std; //Driver codeint main (){ // Data types to be typecastedfloat x = 3.1415926;int a = 5 , b = 9;double y = 6.29; // numerical values being typecasted into wstringwstring pi = L"Pi is " + to_wstring(x);wstring perfect = to_wstring(a+b) +                    L" is a number";wstring num = to_wstring(y/x) +                    L"is division of two numbers"; // Printing the typecasted wstringwcout << pi << L'\n';wcout << perfect << L'\n';wcout << num <<L'\n';return 0;}
Output: 
Pi is 3.141593
14 is a number
2.002169is division of two numbers
Applications : It can be used for calculation to be used in report statement such as average value so we need not write any statement for this purpose and we can directly use this function to convert numerical values.
Example: Suppose the HOD of a department is filing a report for number of sections in his department and he has to avoid data type casting so he can use to_wstring function to do this particular task. 
Below is the implementation : 
C++
// These header files contains wcout and wstring#include <iostream>#include <string>     using namespace std; // Driver codeint main (){ // Data types to be typecastedint a = 600 , b = 150; // numerical values being typecasted into wstringwstring rep = L"Number of section = " + to_wstring(a/b);wstring sec_rep = to_wstring(b) +            L" is the number of students in each section"; // Printing the typecasted wstringwcout << rep << L'\n';wcout << sec_rep << L'\n';return 0;}
Output: 
Number of section =  4
150 is the number of students in each section
In the above example we need not typecast the data type every time but with the help of this function external typecasting is avoided which is beneficial for the system as external typecasting takes more time then the stl functions.  
arorakashish0911
sweetyty
STL
C++
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Convert MySQL Table Field Type from BLOB to JSON?

16 Dec, 2021
In this article, we would be learning a MySQL query to convert a field of BLOB Data Type to JSON Data Type in a table. To execute this query, we would need to alter the table and subsequently the field’s definition. We would first need to use the ALTER TABLE command to start making changes to the table.
ALTER TABLE: ALTER TABLE is a command used to add, delete, or modify fields in an existing table. It is also used to add and drop various constraints on an existing table. We have two commands for alter table, MODIFY and CHANGE.
Step 1: Database Creation
Creation of a Database is done by using the CREATE DATABASE command in MySQL.
Query:  
CREATE DATABASE geek;
Step 2: Change Database in use, to one we created.
To use a particular database among multiple ones or to specify the database whose data we are interested in,we use the USE command in MySQL.
Query: 
USE geek;
Step 3: MySQL Table creation
We are going to create a table in MySQL where one field has BLOB values. Please note you can do this with multiple fields in a table.
Query:  
CREATE TABLE table1(ID INT,
DOCS BLOB,
REVIEW VARCHAR(100));
Step 4: Showing structure of the table
We will use the DESCRIBE table command to cross-check if our table has created a field with BLOB Data Type.
Query:
DESCRIBE table1;
Output:
Step 5: Changing field Data Type from BLOB to JSON. DOCS field would be changed as it is of the BLOB Data Type.
Method 1: USING MODIFY command
To change a field definition use MODIFY along with the ALTER command.
Query:  
ALTER TABLE table1
MODIFY DOCS JSON;
Method 2: USING CHANGE  
The syntax of the CHANGE command is different. After the CHANGE keyword, we name the field that has to be changed, then specify the new definition of the field, which includes the name of the changed field. Here we are changing the name of DOCS to DOCS_CHANGE.
Query:  
ALTER TABLE table1 CHANGE  
DOCS DOCS_CHANGE JSON;
Step 6: Use the DESCRIBE command to see the changes made for each of the commands : MODIFY and CHANGE.
DESCRIBE table1;
Output: Results after using MODIFY
Output: Results after using CHANGE
mysql
Picked
SQL-Query
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.