code-rag-bench/online-tutorials huggingface dataset:
VB.Net - Assignment Operators

There are following assignment operators supported by VB.Net −
Str1 &= Str2 is same as
Str1 = Str1 & Str2
Try the following example to understand all the assignment operators available in VB.Net −
Module assignment
   Sub Main()
      Dim a As Integer = 21
      Dim pow As Integer = 2
      Dim str1 As String = "Hello! "
      Dim str2 As String = "VB Programmers"
      Dim c As Integer
      c = a
      Console.WriteLine("Line 1 - =  Operator Example, _
      Value of c = {0}", c)
         c += a
         Console.WriteLine("Line 2 - +=  Operator Example, _
      Value of c = {0}", c)
         c -= a
         Console.WriteLine("Line 3 - -=  Operator Example, _
      Value of c = {0}", c)
         c *= a
         Console.WriteLine("Line 4 - *=  Operator Example, _
      Value of c = {0}", c)
         c /= a
         Console.WriteLine("Line 5 - /=  Operator Example, _
      Value of c = {0}", c)
         c = 20
         c ^= pow
         Console.WriteLine("Line 6 - ^=  Operator Example, _
      Value of c = {0}", c)
         c <<= 2
         Console.WriteLine("Line 7 - <<=  Operator Example,_
      Value of c = {0}", c)
         c >>= 2
         Console.WriteLine("Line 8 - >>=  Operator Example,_
      Value of c = {0}", c)
         str1 &= str2
         Console.WriteLine("Line 9 - &=  Operator Example,_
      Value of str1 = {0}", str1)
         Console.ReadLine()
   End Sub
End Module
When the above code is compiled and executed, it produces the following result −
Line 1 - =  Operator Example, Value of c = 21
Line 2 - += Operator Example, Value of c = 42
Line 3 - -= Operator Example, Value of c = 21
Line 4 - *= Operator Example, Value of c = 441
Line 5 - /= Operator Example, Value of c = 21
Line 6 - ^= Operator Example, Value of c = 400
Line 7 - <<= Operator Example, Value of c = 1600
Line 8 - >>= Operator Example, Value of c = 400
Line 9 - &= Operator Example, Value of str1 = Hello! VB Programmers


    63 Lectures 
     4 hours 

 Frahaan Hussain

    103 Lectures 
     12 hours 

 Arnold Higuit

    60 Lectures 
     9.5 hours 

 Arnold Higuit

    97 Lectures 
     9 hours 

 Arnold Higuit
 Print
 Add Notes
 Bookmark this page
HCL Interview Experience (On-Campus) - GeeksforGeeks

26 Jul, 2021
First we have aptitude test as normal by other companies like Accenture, Wipro, TCS but difficulty level was low.
Technical Interview:
Starts with introductionParadigms of OOPSPolymorphism in detailthis pointerOther some basic OOPS conceptsDiamond pattern to print –**********

****  ****

***    ***

**      **

*        *
Starts with introduction
Paradigms of OOPS
Polymorphism in detail
this pointer
Other some basic OOPS concepts
Diamond pattern to print –**********

****  ****

***    ***

**      **

*        *
**********

****  ****

***    ***

**      **

*        *
HR interview:
What is your weeknessDiscussed about college percentage and other detailsBond period of 2 yearsReady to relocate
What is your weekness
Discussed about college percentage and other details
Bond period of 2 years
Ready to relocate
Very basic interview.
HCL
Marketing
On-Campus
Interview Experiences
HCL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Amazon Interview Experience for SDE-1 (On-Campus)
Microsoft Interview Experience for Internship (Via Engage)
Amazon Interview Experience
Amazon Interview Experience for SDE-1
Amazon Interview Experience (Off-Campus) 2022
Amazon Interview Experience for SDE-1(Off-Campus)
Amazon Interview Experience for SDE-1
Amazon Interview Experience for SDE1 (8 Months Experienced) 2022
Persistent Systems Interview Experience (Martian Program)
Zoho Interview | Set 2 (On-Campus)
Get the average of marks in MongoDB with aggregate?

Use $avg operator along with aggregate framework. Let us first create a collection with documents. Here, one of the fields is StudentScore −
> db.averageReturiningNullDemo.insertOne(
   {"StudentDetails" : { "StudentScore" : 89 }
});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5ce9822e78f00858fb12e927")
}
> db.averageReturiningNullDemo.insertOne(
   {"StudentDetails" : { "StudentScore" : 34 }
});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5ce9822e78f00858fb12e928")
}
> db.averageReturiningNullDemo.insertOne(
   {"StudentDetails" : { "StudentScore" : 78 }
});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5ce9822e78f00858fb12e929")
}
Following is the query to display all documents from a collection with the help of find() method −
> db.averageReturiningNullDemo.find().pretty();
This will produce the following output −
{
   "_id" : ObjectId("5ce9822e78f00858fb12e927"),
   "StudentDetails" : {
      "StudentScore" : 89
   }
}
{
   "_id" : ObjectId("5ce9822e78f00858fb12e928"),
   "StudentDetails" : {
      "StudentScore" : 34
   }
}
{
   "_id" : ObjectId("5ce9822e78f00858fb12e929"),
   "StudentDetails" : {
      "StudentScore" : 78
   }
}
Following is the query to average returning −
> db.averageReturiningNullDemo.aggregate([
   {
      "$group": {
         "_id": null,
         "StudentScoreAverage": {
            "$avg": "$StudentDetails.StudentScore"
         }
      }
   }
]);
This will produce the following output −
{ "_id" : null, "StudentScoreAverage" : 67 }
How to find the maximum element of an Array using STL in C++?

Here we will see how to find the maximum element. So if the array is like [12, 45, 74, 32, 66, 96, 21, 32, 27], then max element is 96. We can use the max_element() function present in algorithm.h header file to get the maximum element.
 Live Demo
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
   int arr[] = {12, 45, 74, 32, 66, 96, 21, 32, 27};
   int n = sizeof(arr) / sizeof(arr[0]);
   cout << "Array is like: ";
   for (int i = 0; i < n; i++)
      cout << arr[i] << " ";
   cout << "\nMax Element is: " << *max_element(arr, arr + n);
}
Array is like: 12 45 74 32 66 96 21 32 27
Max Element is: 96
Upsampling an image using OpenCV

In this program, we will up sample an image. Up sampling is increasing the spatial resolution while keeping the 2D representation of an image. It is typically used for zooming in on a small region of an image. We will use the pyrup() function in the openCV library to complete this task.
Step 1: Read the image.
Step 2: Pass the image as a parameter to the pyrup() function.
Step 3: Display the output.
import cv2

image = cv2.imread('testimage.jpg')
print("Size of image before pyrUp: ", image.shape)

image = cv2.pyrUp(image)
print("Size of image after pyrUp: ", image.shape)
cv2.imshow('UpSample', image)
Size of image before pyrUp: (350, 700, 3)
Size of image after pyrUp: (700, 1400, 3)
If we observe the size of the image before and after using the pyrUp function, we see that the size is increased, i.e., we have up sampled the image.
C# Program to remove the end part of a string

Use the Regex.Replace method to remove the end part of a string in C#.
The following is the string −
string s1 = "Demo Text!";
Now, let us say you need to remove the exclamation mark (!) from the string. For that just set it to
empty using replace −
System.Text.RegularExpressions.Regex.Replace(s1, "!", "");
Here is the complete code −
 Live Demo
using System;
using System.Text.RegularExpressions;
namespace Demo {
   class Program {
      static void Main(string[] args) {
         string s1 = "Demo Text!";
         // replace the end part
         string s2 = System.Text.RegularExpressions.Regex.Replace(s1, "!", "");
         Console.WriteLine("\"{0}\"\n\"{1}\"", s1, s2);
      }
   }
}
"Demo Text!"
"Demo Text"
What does the operation c=a+++b mean in C/C++?

Let us consider in C or C++, there is a statement like:
c = a+++b;
Then what is the meaning of this line?
Well, Let the a and b are holding 2 and 5 respectively. this expression can be taken as two different types.
c = (a++) + b
c = a + (++b)
There are post increment operator, as well as pre increment operator. It depends on how they are used.
There are two basic concepts. The precedence and the associativity. Now if we check the expression from left to right, so the result will be these two.
c = (a++) + b → 2 + 5 = 7
c = a + (++b) → 2 + 6 = 8
Now let us check which option is taken by the compiler-
#include <iostream>
using namespace std;
main() {
   int a = 2, b = 5;
   int c;
   c = a+++b;
   cout << "C is : " << c;
}
C is : 7
Here the first option is taken.
Add a pressed effect on button click with CSS

You can try to run the following code to add a pressed effect on the click of a button
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <style>
         .button {
            background-color: orange;
            color: white;
            border: none;
            border-radius: 7px;
            box-shadow: 0 5px #999;
            display: inline-block;
            padding: 10px;
            font-size: 16px;
            cursor: pointer;
            text-align: center;
            outline: none;
         }
         .button:hover {
            background-color: blue;
         }
         .button:active {
            background-color: orange;
            box-shadow: 0 5px gray;
            transform: translateY(2px);
         }
      </style>
   </head>
   <body>
      <button class = "button">Result</button>
   </body>
</html>
How to print the contents of array horizontally using C#?

Set an array.
int[] array = new int[] { 50, 100, 150, 200, 250, 300, 350, 400 };
Now, if you will print this array using a loop and new line, then the arrays will be visible vertically.
To work it horizontally, use the Join() method and set spaces to separate array elements.
string.Join(" ", array)
Let us see the complete code.
 Live Demo
using System;
using System.Linq;
using System.IO;
class Program {
   static void Main() {
      int[] array = new int[] { 50, 100, 150, 200, 250, 300, 350, 400 };
      Console.WriteLine(string.Join(" ", array));
   }
}
50 100 150 200 250 300 350 400
How to create RadioMenuItem in JavaFX?

A menu is a list of options or commands presented to the user, typically menus contain items that perform some action. The contents of a menu are known as menu items and a menu bar holds multiple menus.
JavaFx supports three kinds of menu items namely − check menu item, custom menu item, and, radio menu item.
A RadioMenuItem is a special MenuItem that has a checkmark (tick) similar to a checkbox. This has two states selected (with a checkmark) and unselected (without checkmark). It is represented by the javafx.scene.control.RadioMenuItem class.
You can add a bunch of radio-menu-items to a toggle group just like a toggle button or a radio button. If not added, it acts like a CheckMenuItem.
To add a CheckMenuItem in the menu −
Instantiate the Menu class.
Instantiate the Menu class.
Instantiate the RadioMenuItem class.
Instantiate the RadioMenuItem class.
Add all the created check menu menu-item to the menu as −
Add all the created check menu menu-item to the menu as −
menu.getItems().add(item);
Create a menu bar by instantiating the MenuBar class.
Create a menu bar by instantiating the MenuBar class.
Add the menu to the menu bar as −
Add the menu to the menu bar as −
menuBar.getMenus().add(menu);
Add the menu bar to the scene.
Add the menu bar to the scene.
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
import javafx.scene.control.RadioMenuItem;
import javafx.scene.control.SeparatorMenuItem;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
public class RadioMenuItemExample extends Application {
   @Override
   public void start(Stage stage) {
      //Creating a menu
      Menu fileMenu = new Menu("File");
      //Creating menu Items
      Menu view = new Menu("Align");
      MenuItem edit = new MenuItem("Edit");
      MenuItem exit = new MenuItem("Exit");
      //Creating menu items for the sub item edit
      RadioMenuItem sub1 = new RadioMenuItem("Right");
      RadioMenuItem sub2 = new RadioMenuItem("Left");
      RadioMenuItem sub3 = new RadioMenuItem("Center");
      //Adding toggle group to the view menu item
      view.getItems().addAll(sub1, sub2, sub3);
      //Creating a separator
      SeparatorMenuItem sep = new SeparatorMenuItem();
      //Adding all the menu items to the menu
      fileMenu.getItems().addAll(edit, view, sep, exit);
      //Creating a menu bar and adding menu to it.
      MenuBar menuBar = new MenuBar(fileMenu);
      menuBar.setTranslateX(200);
      menuBar.setTranslateY(20);
      //Setting the stage
      Group root = new Group(menuBar);
      Scene scene = new Scene(root, 595, 200, Color.BEIGE);
      stage.setTitle("Menu Example");
      stage.setScene(scene);
      stage.show();
   }
   public static void main(String args[]){
      launch(args);
   }
}
How to read all HTTP headers in Python CGI script?

It is possible to get a custom request header's value in an apache CGI script with python. The solution is similar to this.
Apache's mod_cgi will set environment variables for each HTTP request header received, the variables set in this manner will all have an HTTP_ prefix, so for example x-client-version: 1.2.3 will be available as variable HTTP_X_CLIENT_VERSION.
So, to read the above custom header just call os.environ["HTTP_X_CLIENT_VERSION"].
The below script will print all HTTP_* headers and values −
#!/usr/bin/env python

import os
print "Content-Type: text/html"
print "Cache-Control: no-cache"
print

print "<html><body>"
for headername, headervalue in os.environ.iteritems():
    if headername.startswith("HTTP_"):
        print "<p>{0} = {1}</p>".format(headername, headervalue)
 
print "</html></body>"
Python - Extract domain name from Email address - GeeksforGeeks

02 Sep, 2020
Given a String Email address, extract the domain name.
Input : test_str = ‘manjeet@geeks.com’Output : geeks.comExplanation : Domain name, geeks.com extracted.
Input : test_str = ‘manjeet@gfg.com’Output : gfg.comExplanation : Domain name, gfg.com extracted.
Method #1 : Using index() + slicing
In this, we harness the fact that “@” symbol is separator for domain name and local-part of Email address, so, index() is used to get its index, and is then sliced till end.
Python3
# Python3 code to demonstrate working of # Extract domain name from Email address# Using index() + slicing   # initializing stringstest_str = 'manjeet@geeksforgeeks.com'  # printing original stringprint("The original string is : " + str(test_str))  # slicing domain name using slicing res = test_str[test_str.index('@') + 1 : ]  # printing result print("The extracted domain name : " + str(res)) 
The original string is : manjeet@geeksforgeeks.com
The extracted domain name : geeksforgeeks.com

Method #2 : Using split()
In this, we split the string on “@” and use its 1st index to get the required domain name.
Python3
# Python3 code to demonstrate working of # Extract domain name from Email address# Using split()  # initializing stringstest_str = 'manjeet@geeksforgeeks.com'  # printing original stringprint("The original string is : " + str(test_str))  # using split() to get domain nameres = test_str.split('@')[1]  # printing result print("The extracted domain name : " + str(res)) 
The original string is : manjeet@geeksforgeeks.com
The extracted domain name : geeksforgeeks.com

Python string-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
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Pandas dataframe.groupby()
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
numpy.char.strip()

This function returns a copy of array with elements stripped of the specified characters leading and/or trailing in it.
import numpy as np 
print np.char.strip('ashok arora','a') 
print np.char.strip(['arora','admin','java'],'a')
Here is its output −
shok aror
['ror' 'dmin' 'jav']


    63 Lectures 
     6 hours 

 Abhilash Nelson

    19 Lectures 
     8 hours 

 DATAhill Solutions Srinivas Reddy

    12 Lectures 
     3 hours 

 DATAhill Solutions Srinivas Reddy

    10 Lectures 
     2.5 hours 

 Akbar Khan

    20 Lectures 
     2 hours 

 Pruthviraja L

    63 Lectures 
     6 hours 

 Anmol
 Print
 Add Notes
 Bookmark this page
How to add new array elements at the beginning of an array in JavaScript?

JavaScript array unshift() method adds one or more elements to the beginning of an array and returns the new length of the array.
You can try to run the following code to learn how to add new array elements at the beginning of an array:
Live Demo
<html>    
   <head>      
      <title>JavaScript Array unshift Method</title>    
   </head>      
   <body>          
      <script>          
         var arr = new Array("orange", "mango", "banana", "sugar");                    
         var length = arr.unshift("water");          
         document.write("Returned array is : " + arr );          
         document.write("<br /> Length of the array is : " + length );      
     </script>          
   </body>
</html>                                                                                
Returned array is : water,orange,mango,banana,sugar
Length of the array is : 5
What are global variables in C++?

Global variables are defined outside of all the functions, usually on top of the program. The global variables will hold their value throughout the lifetime of your program.
A global variable can be accessed by any function. That is, a global variable is available for use throughout your entire program after its declaration. 
#include <iostream>
using namespace std;
// Global variable declaration:
int g;
int main () {
   // Local variable declaration:
   int a, b;
   a = 10;
   b = 20;
   g = a + b;
   cout << g;
   return 0;
}
This will give the output −
30
How Parallel and Sequence execution works in PowerShell Workflow?

PowerShell workflows are the best way to design the script to execute on more than one node parallel which saves extensive time for the output to produce but we always don’t want to run all the commands parallel but also need some of them to run sequentially and we can design both Parallel and Sequence commands using PowerShell Workflow.
Workflow TestWorkflow{
   parallel{
      Command1
      Command2
   }
   Sequence{
      Command3
      Command4
   }
}

TestWorkflow
In the above code, Command1, Command2 will be executed parallelly in any order while command3 and command4 will be executed in a serial manner because they are inside the sequence block as shown with the below example.
Workflow TestWorkflow{
   parallel{
      Get-CimInstance Win32_LogicalDisk
      Get-CimInstance Win32_BIOS
   }
   sequence{
      Get-Service WinRM
      Get-Process Notepad++
   }
}

TestWorkFlow
TestWorkFlow

SMBIOSBIOSVersion : F.13
Manufacturer     : AMI
Name : F.13
SerialNumber : 5CD015JY8D
Version : HPQOEM - 1072009
PSComputerName :

DeviceID : C:
DriveType : 3
ProviderName :
FreeSpace : 219602677760
Size : 511123124224
VolumeName : OSDisk
PSComputerName :

Status : Running
Name : WinRM
DisplayName : Windows Remote Management (WS-Management)
PSComputerName : localhost

Id : 676
Handles : 738
CPU : 15.875
Name : notepad++
PSComputerName : localhost
How to get a list of all sub-directories in the current directory using Python?

To get a list of all subdirectories in a directory, recursively, you can use the os.walk function. It returns a three tuple with first entry being all the subdirectories.
You can use it as follows:
import os
subdirs = [x[0] for x in os.walk('.')]
print(subdirs)
You can also list the directories(immediate only) using the os.listdir function and filtering the list using the os.path.isdir function.
import os
d = '.'
subdirs = [os.path.join(d, o) for o in os.listdir(d) if os.path.isdir(os.path.join(d,o))]
Math.Sqrt() Method in C#

The Math.Sqrt() method in C# is used to compute the square root of the specified number.
Following is the syntax −
public static double Sqrt (double val);
Above, Val is the number for which we want the square root.
Let us now see an example to implement Math.Sqrt() method −
using System;
public class Demo {
   public static void Main(){
      double val1 = 4;
      double val2 = 36;
      Console.WriteLine(Math.Sqrt(val1));
      Console.WriteLine(Math.Sqrt(val2));
   }
}
This will produce the following output −
2
6
Let us see another example to implement Math.Sqrt() method −
using System;
public class Demo {
   public static void Main(){
      double val1 = -144;
      double val2 = 0.49;
      Console.WriteLine(Math.Sqrt(val1));
      Console.WriteLine(Math.Sqrt(val2));
   }
}
This will produce the following output −
NaN
0.7
SAS - Repeated Measure Analysis

Repeated measure analysis is used when all members of a random sample are measured under a number of different conditions. As the sample is exposed to each condition in turn, the measurement of the dependent variable is repeated. Using a standard ANOVA in this case is not appropriate because it fails to model the correlation between the repeated measures.
One should be clear about the difference between a repeated measures design and a simple multivariate design. For both, sample members are measured on several occasions, or trials, but in the repeated measures design, each trial represents the measurement of the same characteristic under a different condition.
In SAS PROC GLM is used to carry out repeated measure analysis.
The basic syntax for PROC GLM in SAS is −
PROC GLM DATA = dataset;
   CLASS variable;
   MODEL variables = group / NOUNI;
   REPEATED TRIAL n;

Following is the description of the parameters used −
dataset is the name of the dataset.
dataset is the name of the dataset.
CLASS gives the variables the variable used as classification variable.
CLASS gives the variables the variable used as classification variable.
MODEL defines the model to be fit using certain variables form the dataset.
MODEL defines the model to be fit using certain variables form the dataset.
REPEATED defines the number of repeated measures of each group to test the hypothesis.
REPEATED defines the number of repeated measures of each group to test the hypothesis.
Consider the example below in which we have two groups of people subjected to test of effect of a drug. The reaction time of each person is recorded for each of the four drug types tested. Here 5 trials are done for each group of people to see the strength of correlation between the effect of the four drug types.
DATA temp;
   INPUT person group $ r1 r2 r3 r4;
CARDS;
1 A  2  1  6  5
2 A  5  4 11  9
3 A  6 14 12 10
4 A  2  4  5  8
5 A  0  5 10  9
6 B  9 11 16 13
7 B  12 4 13 14
8 B  15 9 13  8
9 B  6  8 12  5
10 B 5  7 11  9
;
RUN;

PROC PRINT DATA = temp ;
RUN;

   PROC GLM DATA = temp;
   CLASS group;
   MODEL r1-r4 = group / NOUNI ;
   REPEATED trial 5;
RUN;

When the above code is executed, we get the following result −

    50 Lectures 
     5.5 hours 

 Code And Create

    124 Lectures 
     30 hours 

 Juan Galvan

    162 Lectures 
     31.5 hours 

 Yossef Ayman Zedan

    35 Lectures 
     2.5 hours 

 Ermin Dedic

    167 Lectures 
     45.5 hours 

 Muslim Helalee
 Print
 Add Notes
 Bookmark this page
shown.bs.modal Bootstrap Event

The shown.bs.modal event in Bootstrap fires when the modal is completely displayed.
Here, on button click the modal would generate. The following is our button −
<button type="button" class="btn btn-default btn-lg" id="button1">
  Result
</button>
The following is the script to generate our modal on button click −
$("#button1").click(function(){
  $("#newModal").modal("show");
});
Now the alert would generate using the shown.bs.modal event after the modal is visible to the visitors −
$("#newModal").on('shown.bs.modal', function () {
  alert('The modal is displayed completely!');
});
Here is the complete code to learn how to implement the shown.bs.modal Bootstrap event −
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
  <h2>Entrance Exams</h2>
  <p>The following is the result of the entrance exams:</p>
  <button type="button" class="btn btn-default btn-lg" id="button1">Click for Result</button>
  <div class="modal fade" id="newModal" role="dialog">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">×</button>
          <h4 class="modal-title">Selected</h4>
        </div>
        <div class="modal-body">
          <p>Rahul, Amit and Shweta cleared the exam.</p>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
        </div>
      </div>
    </div>
  </div>
</div>

<script>
$(document).ready(function(){
  $("#button1").click(function(){
    $("#newModal").modal("show");
  });
  $("#newModal").on('shown.bs.modal', function () {
    alert('The modal is displayed completely!');
  });
});
</script>
</body>
</html>
Python – Replace None with Empty Dictionary

01 Oct, 2020
Given a dictionary, replace None values in every nesting with an empty dictionary.
Input : test_dict = {“Gfg” : {1 : None, 7 : None}, “is” : None, “Best” : [1, { 5 : None }, 9, 3]} Output : {‘Gfg’: {1: {}, 7: {}}, ‘is’: {}, ‘Best’: [1, {5: {}}, 9, 3]} Explanation : All None values are replaced by empty dictionaries.
Input : test_dict = {“Gfg” : {7 : None}, “is” : None, “Best” : [1, { 5 : None }, 9, 3]} Output : {‘Gfg’: {7: {}}, ‘is’: {}, ‘Best’: [1, {5: {}}, 9, 3]} Explanation : All None values are replaced by empty dictionaries. 
Method : Using recursion + isinstance()
In this, we check for dictionary instance using isinstance() and call for recursion for nested dictionary replacements. This also checks for nested instances in form of list elements and checks for the list using isinstance().
Python3
# Python3 code to demonstrate working of# Replace None with Empty Dictionary# Using recursion + isinstance()  # helper function to perform task    def replace_none(test_dict):      # checking for dictionary and replacing if None    if isinstance(test_dict, dict):                for key in test_dict:            if test_dict[key] is None:                test_dict[key] = {}            else:                replace_none(test_dict[key])      # checking for list, and testing for each value    elif isinstance(test_dict, list):        for val in test_dict:            replace_none(val)    # initializing dictionarytest_dict = {"Gfg": {1: None, 7: 4}, "is": None,             "Best": [1, {5: None}, 9, 3]}  # printing original dictionaryprint("The original dictionary is : " + str(test_dict))  # calling helper fncreplace_none(test_dict)  # printing resultprint("The converted dictionary : " + str(test_dict))
Output:
The original dictionary is : {‘Gfg’: {1: None, 7: 4}, ‘is’: None, ‘Best’: [1, {5: None}, 9, 3]}The converted dictionary : {‘Gfg’: {1: {}, 7: 4}, ‘is’: {}, ‘Best’: [1, {5: {}}, 9, 3]}
Python dictionary-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to call a Java function inside JavaScript Function?

JavaScript cannot call java method directly since it is on the server. You need a Java framework like JSP to call when a request is received from JavaScript. Let’s see how to use JSP to call a Java function inside JavaScript function.
Here’s the JavaScript code:
//javascript code
function initiateFunc() {
   $.get('localhost/project/myexecution.jsp);
}
$( initiateFunc);
 Here’s the JSP code for “myexecution.jsp”:
<%@ page import="deleteconfig"%>
<%
   deleteconfig.initiate();
%>
SQL | Declare Local Temporary Table

19 Aug, 2020
Declare Local Temporary Table statement used to create a temporary table. A temporary table is where the rows in it are visible only to the connection that created the table and inserted the rows.
Syntax –
DECLARE LOCAL TEMPORARY TABLE table-name
( column-name [ column-value ] );

Example :
DECLARE LOCAL TEMPORARY TABLE TempGeek ( number INT );

INSERT INTO Geeks 
VALUES (1), (2), (3), (4);

Select * 
from TempGeek; 
Once you create a local temporary table, you cannot create another temporary table of that name for as long as the temporary table exists.
Example –You can create a local temporary table by entering :
declare local temporary table Geektable

If you then try to select into “Geektable” or declare Geektable again, you receive an error indicating that Geektable already exists.
When you declare a temporary table, exclude the owner specification.
If you specify identical owner.table in addition to DECLARE LOCAL TEMPORARY TABLE statement within the same session, a syntax error is reported.
Example –
DECLARE LOCAL TEMPORARY TABLE user1.Gfgt(col1 int);
DECLARE LOCAL TEMPORARY TABLE user.Gfgt(col1 int);

The error “Item Gfgt already exists” is reported :
You can, however, create a temporary table with identical name as an existing base table or global temporary table, however local temporary tables are used first.
Example –Consider this sequence :
CREATE TABLE Geeks (num int);
INSERT INTO Geeks VALUES (9), (8) ;

DECLARE LOCAL TEMPORARY TABLE Geeks (num int);
INSERT INTO Geeks VALUES (6), (7);

SELECT * 
FROM Geeks; 
Output :The result returned is
Any reference to Geeks refers to the local temporary table Geeks until the local temporary table is dropped by the connection.
ALTER TABLE and DROP INDEX statements cannot be used on local temporary tables.
DBMS-SQL
DBMS
SQL
DBMS
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
File Organization in DBMS | Set 1
File Organization in DBMS | Set 2
File Organization in DBMS | Set 3
Record-Based Data Model
Introduction of B+ Tree
SQL | DDL, DQL, DML, DCL and TCL Commands
SQL using Python
SQL | ALTER (RENAME)
SQL | DDL, DML, TCL and DCL
SQL - SELECT from Multiple Tables with MS SQL Server
Python | Calculate City Block Distance

11 May, 2020
City block distance is generally calculated between 2-coordinates of a paired object. It is the summation of absolute difference between 2-coordinates. The city block distance of 2-points a and b with k dimension is mathematically calculated using below formula:
In this article two solution are explained for this problem – one with the Python code and the other one with the use of a predefined method.
Examples:
Input:array1 = [1, 2, 13, 5]array2 = [1, 27, 3, 4]Output:The CityBlock distance between 2 array is: 36
Input:a = [34, 44, 89, 81, 67, 49, 33, 59]b = [98, 34, 23, 12, 233, 23, 44]Output:The CityBlock distance between 2 array is: 412
Code: Python scratch code to calculate the distance using the above formula.
import numpy as np  def cityblock_distance(A, B):      result = np.sum([abs(a - b) for (a, b) in zip(A, B)])    return result  if __name__== "__main__":      array1 = [1, 2, 13, 5]    array2 = [1, 27, 3, 4]      result = cityblock_distance(array1, array2)      print("The CityBlock distance between 2 arrays is:", result)
Output:
The CityBlock distance between 2 arrays is: 36

There is no restriction for the same size of arrays. So, it’s easy to calculate City Block distance between 2-coordinates using above formula but we can calculate the same using predefined method for arrays having 2-dimension or more.
Code: Python code using the predefined method to calculate the distance using the above formula.
# Import necessary packageimport scipy.spatial.distance as d  def CityBlock_distance(A, B):      result = d.cdist(A, B, 'cityblock')    return result  if __name__== "__main__":      mat1 = [[1, 2, 13, 5], [2, 3, 4, 5]]    mat2 = [[1, 27, 3, 4], [8, 6, 9, 3]]      result = CityBlock_distance(mat1, mat2)      print(result)
Output:
[[ 36.  17.]
 [ 27.  16.]]

Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Node.js Building simple REST API in express

14 Oct, 2021
Let’s have a brief introduction about the Express framework before starting the code section:Express: It is an open-source NodeJs web application framework designed to develop websites, web applications, and APIs in a pretty easier way. Express helps us to handle different HTTP requests at specific routes.As it is NodeJs web framework so make sure that NodeJs has been installed on our system.
For verifying type the following command in the terminal: 
node -v
It will show the installed version of NodeJs to our system as shown in the below screenshot.
STEP-1: Create a separate folder and with the help of a terminal or command prompt navigate to this folder:  
STEP-2: Create package.json by typing the following command in the terminal:  
npm init -y
For knowing more about package.json click here.  
STEP-3: Create a file named server.js at the root of the project. Now, our folder structure will be as shown in the screenshot below:  
javascript
// server.js Fileconst express = require('express'); // Importing express module  const app = express(); // Creating an express object  const port = 8000;  // Setting an port for this application    // Starting server using listen functionapp.listen(port, function (err) {   if(err){       console.log("Error while starting server");   }   else{       console.log("Server has been started at "+port);   }})
STEP-4: Start server by typing the following command in the terminal:  
node server.js
STEP-5: Open the browser and type http://localhost:8000 and we will get the following response. We are getting Cannot GET / response as we are trying to access/route to the server and there is nothing mounted to that particular route.  
STEP-6: Handing the route to the server Handle the root route of the server by sending something back to it and adding the following code to the server.js 
app.get('/', function (req, res) {
  res.send('we are at the root route of our server');
})
Now, restart the server by typing the following command :
node server.js
mridulmanochagfg
NodeJS-Questions
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
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Difference Between PUT and PATCH Request
How to append HTML code to a div using JavaScript ?
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 ?
URL getQuery() method in Java with Examples

31 Dec, 2018
The getQuery() function is a part of URL class. The function getQuery() returns the Query of a specified URL.
Function Signature:
public String getQuery()
Syntax:
url.getQuery()
Parameter: This function does not require any parameter
Return Type: The function returns String Type Query of a specified URL.
Below programs illustrates the use of getQuery() function:
Example 1: Given a URL we will get the Query using the getQuery() function.
// Java program to show the use// of the function getQuery()  import java.net.*;  class Solution {    public static void main(String args[])    {        // url  object        URL url = null;          try {            // create a URL            url                = new URL(                    "https:// www.geeksforgeeks.org/url-getprotocol-method-in-java-with-examples?title=protocol");              // get the  Query            String _Query = url.getQuery();              // display the URL            System.out.println("URL = " + url);              // display the  Query            System.out.println(" Query=" + _Query);        }        // if any error occurs        catch (Exception e) {              // display the error            System.out.println(e);        }    }}
URL = https:// www.geeksforgeeks.org/url-getprotocol-method-in-java-with-examples?title=protocol
 Query=title=protocol

Example 2: Now we will not provide any query and use the function to get the query and see the results.
// Java program to show the use// of the function getQuery()  import java.net.*;  class Solution {    public static void main(String args[])    {        // url  object        URL url = null;          try {              // create a URL            url = new URL(                "https:// www.geeksforgeeks.org/url-getprotocol-method-in-java-with-examples");              // get the  Query            String _Query = url.getQuery();              // display the URL            System.out.println("URL = " + url);              // display the  Query            System.out.println(" Query=" + _Query);        }          // if any error occurs        catch (Exception e) {              // display the error            System.out.println(e);        }    }}
URL = https:// www.geeksforgeeks.org/url-getprotocol-method-in-java-with-examples
 Query=null

Java-Functions
Java-net-package
Java-URL
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Object Oriented Programming (OOPs) Concept in Java
How to iterate any Map in Java
Interfaces in Java
HashMap in Java with Examples
ArrayList in Java
Stream In Java
Collections in Java
Singleton Class in Java
Multidimensional Arrays in Java
Stack Class in Java
JavaScript Date toLocaleString() Method

21 Oct, 2021
Below is the example of Date toLocaleString() method.
Example:<script>    var d = new Date(Date.UTC(2020, 9, 26, 7, 0, 0));    var result = d.toLocaleString();    document.write("Date and Time of apocalypse: "    + result);</script>                    
<script>    var d = new Date(Date.UTC(2020, 9, 26, 7, 0, 0));    var result = d.toLocaleString();    document.write("Date and Time of apocalypse: "    + result);</script>                    
Output:Date and Time of apocalypse: 26/10/2020, 12:30:00
Date and Time of apocalypse: 26/10/2020, 12:30:00
The date.toLocaleString() method is used to convert a date and time to a string.Syntax:
dateObj.toLocaleString(locales, options)
Parameters: This methods accepts two parameters as mentioned above and described below:
locales: This parameter is an array of locale strings that contain one or more language or locale tags. Note that it is an optional parameter. If you want to use a specific format of the language in your application then specify that language in the locales argument.
Options:It is also an optional parameter and contains properties that specify comparison options.Some properties are localeMatcher, timeZone, weekday, year, month, day, hour, minute, second etc.
Return values: It returns date and time as a string value in the specific format that is specified by locale.
Note: The dateObj should be a valid Date object.
Program 1: This code prints the current date and time. Also, In this code toLocaleString() method does not use any parameter so it uses the operating system’s locale’s conventions and return the result which is machine-specific.
<script>  var d = new Date();  var result = d.toLocaleString();  document.write("date and time as a string =  " + result);</script>   
Output:
date and time as a string = 6/26/2018, 10:28:17 
Program 2: This code prints the date and time in string format specified by locale parameter.
<script>  var date = new Date(Date.UTC(2018, 5, 26, 7, 0, 0));    var options = { hour12: false };    document.write(date.toLocaleString("en-US"));  document.write("<br>");  document.write(date.toLocaleString("en-US", options));</script>
Output:
6/26/2018, 12:30:00 PM
6/26/2018, 12:30:00

Note: The toLocaleString() method is different from toLocaleDateString() as toLocaleDateString() converts only the date of a Date object into a string but toLocaleString() converts date and time to a string..
Supported Browsers: The browsers supported by JavaScript Date toLocaleString() Method are listed below:
Google Chrome 1 and above
Edge 12 and above
Firefox 1 and above
Internet Explorer 3 and above
Opera 3 and above
Safari 1 and above
ysachin2314
javascript-date
JavaScript-Methods
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
iomanip setprecision() function in C++ with Examples

18 Feb, 2022
The setprecision() method of iomanip library in C++ is used to set the ios library floating point precision based on the precision specified as the parameter to this method.
Syntax:
setprecision(int n)
Parameters: This method accepts n as a parameter which is the integer argument corresponding to which the floating-point precision is to be set.
Return Value: This method does not return anything. It only acts as stream manipulators.
Example 1:
C++
// C++ code to demonstrate// the working of setprecision() function #include <iomanip>#include <ios>#include <iostream> using namespace std; int main(){     // Initializing the decimal    double num = 3.142857142857;     cout << "Before setting the precision: \n"         << num << endl;     // Using setprecision()    cout << "Setting the precision using"         << " setprecision to 5: \n"         << setprecision(5);     cout << num << endl;     // Using setprecision()    cout << "Setting the precision using"           << " setprecision to 9 : \n "         << setprecision(9);     cout << num << endl;     return 0;}
Before setting the precision: 
3.14286
Setting the precision using setprecision to 5: 
3.1429
Setting the precision using setprecision to 9: 
3.14285714
Example 2:
C++
// C++ code to demonstrate// the working of setprecision() function #include <iomanip>#include <ios>#include <iostream> using namespace std; int main(){     // Initializing the decimal    double num = 3.14;     cout << fixed;     cout << "Before setting the precision: \n"         << num << endl;     // Using setprecision()    cout << "Setting the precision using"         << " setprecision to 5: \n"         << setprecision(5);     cout << num << endl;     // Using setprecision()    cout << "Setting the precision using"         << " setprecision to 9: \n"         << setprecision(9);     cout << num << endl;    return 0;}
Before setting the precision: 
3.140000
Setting the precision using setprecision to 5: 
3.14000
Setting the precision using setprecision to 9: 
3.140000000
Reference: http://www.cplusplus.com/reference/iomanip/setprecision/ 
user_3ums
praneypareek797
atlashere
CPP-Functions
cpp-input-output
cpp-manipulators
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Bitwise Operators in C/C++
Set in C++ Standard Template Library (STL)
vector erase() and clear() in C++
unordered_map in C++ STL
Inheritance in C++
Substring in C++
C++ Classes and Objects
The C++ Standard Template Library (STL)
Sorting a vector in C++
Priority Queue in C++ Standard Template Library (STL)
Java String compareToIgnoreCase() Method

❮ String Methods

Compare two strings, ignoring lower case and upper case differences:
String myStr1 = "HELLO";
String myStr2 = "hello";
System.out.println(myStr1.compareToIgnoreCase(myStr2));

Try it Yourself »

The compareToIgnoreCase() method compares two strings 
lexicographically, ignoring lower case and upper case differences.
The comparison is based on the Unicode value of each character in the 
string converted to lower case.
The method returns 0 if the string is equal to the other string, ignoring case differences.
  A value less than 0 is returned if the string is less than the other string 
  (less characters) and a value greater than 0 if the string is greater than the other string 
  (more characters).
public int compareToIgnoreCase(String string2)

We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
GitLab - Restore Backup

GitLab allows restoring the backup copy of your repository. In this chapter, we will discuss about how to restore the backup copy in the GitLab −
Step 1 − First, login to your GitLab server using SSH (Secure Shell).
Step 2 − Before restoring the backup copy, first make sure backup copy is in the /var/opt/gitlab/backups directory.


Step 3 − You can check the backup copy by using the ls -l command which is described in the Create Backup job chapter.
Step 4 − Now, stop the processes which are related to the database by using the below commands −
sudo gitlab-ctl stop unicorn

sudo gitlab-ctl stop sidekiq

The above commands can also be used to free up some memory temporarily by shutting down them.
Step 5 − You can verify status of the GitLab services by using the below command −
sudo gitlab-ctl status

Step 6 − Now, restore the backup by using the timestamp of the backup copy −
sudo gitlab-rake gitlab:backup:restore BACKUP = 1521884424_2018_03_24_10.5.3

Step 7 − Restart the GitLab components by using the below command −
sudo gitlab-ctl restart

Step 8 − Now check the GitLab by sanitizing the database as shown below −
sudo gitlab-rake gitlab:check SANITIZE = true

The SANITIZE = true flag removes all email addresses because they are confidential, removes the CI variables and access tokens as they can be used in the production instance.

 Print
 Add Notes
 Bookmark this page
Java Program to Print all unique words of a String

To find unique words in a string use Map utility of java because of its property that it does not contain duplicate keys.In order to find unique words first get all words in array so that compare each word,for this split string on the basis of space/s.If other characters such as comma(,) or fullstop (.) are present then using required regex first replace these characters from the string.
Insert each word of string as key of Map and provide initial value corresponding to each key as 'is unique' if this word does not inserted in map before.Now when a word repeats during insertion as key in Map delete its entry from map.Continue this for each word untill all words of string get check for insertion.
 Live Demo
import java.util.LinkedHashMap;
import java.util.Map;
public class Tester {
   public static void main(String[] args) {
      String str = "Guitar is instrument and Piano is instrument";
      String[] strArray = str.split("\\s+");
      Map<String, String> hMap = new LinkedHashMap<String, String>();
      for(int i = 0; i < strArray.length ; i++ ) {
         if(!hMap.containsKey(strArray[i])) {
            hMap.put(strArray[i],"Unique");
         }
      }
      System.out.println(hMap);
   }
}
{Guitar=Unique, is=Unique, instrument=Unique, and=Unique, Piano=Unique}
Tcl - Relational Operators

Following table shows all the relational operators supported by Tcl language. Assume variable A holds 10 and variable B holds 20, then −
Try the following example to understand all the relational operators available in Tcl language −
#!/usr/bin/tclsh

set a 21
set b 10

if { $a == $b } {
   puts "Line 1 - a is equal to b\n"
} else {
   puts "Line 1 - a is not equal to b\n" 
}
if { $a < $b } {
   puts "Line 2 - a is less than b\n"
} else {
   puts "Line 2 - a is not less than b\n"
}
if { $a > $b } {
   puts "Line 3 - a is greater than b\n"
} else {
   puts "Line 3 - a is not greater than b\n"
}
# Lets change value of a and b
set a 5
set b 20
if { $a <= $b } {
   puts "Line 4 - a is either less than or equal to  b\n"
}
if { $b >= $a } {
   puts "Line 5 - b is either greater than  or equal to a\n"
}
When you compile and execute the above program it produces the following result −
Line 1 - a is not equal to b

Line 2 - a is not less than b

Line 3 - a is greater than b

Line 4 - a is either less than or equal to  b

Line 5 - b is either greater than  or equal to a

 Print
 Add Notes
 Bookmark this page