code-rag-bench/online-tutorials huggingface dataset:
How to submit an HTML form using JavaScript?

To submit an HTML form using JavaScript, we are calling validate() to validate data when the onsubmit event is occurring.
You can try to run the following code to submit an HTML form −
<html>
   <head>
      <title>Form Validation</title>
      <script>
         // Form validation
         function validate() {
            if( document.myForm.Name.value == "" ) {
               alert( "Please provide your name!" );
               document.myForm.Name.focus() ;
               return false;
            }
            if( document.myForm.EMail.value == "" ) {
               alert( "Please provide your Email!" );
               document.myForm.EMail.focus() ;
               return false;
            }
            if( document.myForm.Zip.value == "" ||
            isNaN( document.myForm.Zip.value ) ||
            document.myForm.Zip.value.length != 5 ) {
               alert( "Please provide a zip in the format #####." );
               document.myForm.Zip.focus() ;
               return false;
            }
            if( document.myForm.Country.value == "-1" ) {
               alert( "Please provide your country!" );
               return false;
            }
            return( true );
         }
      </script>
   </head>
   <body>
      <form action = "/cgi-bin/test.cgi" name = "myForm" onsubmit = "return(validate());">
         <table cellspacing = "2" cellpadding = "2" border = "1">
            <tr>
               <td align = "right">Name</td>
               <td><input type = "text" name = "Name" /></td>
            </tr>
            <tr>
               <td align = "right">EMail</td>
               <td><input type = "text" name = "EMail" /></td>
            </tr>
            <tr>
               <td align = "right">Zip Code</td>
               <td><input type = "text" name = "Zip" /></td>
            </tr>
            <tr>
               <td align = "right">Country</td>
               <td>
                  <select name = "Country">
                     <option value = "-1" selected>[choose yours]</option>
                     <option value = "1">Canada</option>
                     <option value = "2">Sri Lanka</option>
                     <option value = "3">Mexico</option>
                  </select>
               </td>
            </tr>
            <tr>
               <td align = "right"></td>
               <td><input type = "submit" value = "Submit" /></td>
            </tr>
          </table>
      </form>
   </body>
</html>
How to get the readonly files using Get-ChildItem in PowerShell?

To get the Readonly files with Get-ChildItem in PowerShell, you need to use the –Readonly files. Readonly file has attribute ‘r’.
In the below example, you can check the attribute of the file.
Get-ChildItem D:\Temp\ -ReadOnly
PS C:\WINDOWS\system32> Get-ChildItem D:\Temp\* -ReadOnly
    Directory: D:\Temp
Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-ar---       13-01-2020     18:19              0 Readonlyfile.txt
You can check the read-only attribute value in Mode property.
How to extract numbers from a string using regular expressions?

You can match numbers in the given string using either of the following regular expressions −
“\\d+”
Or,
"([0-9]+)"
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ExtractingDigits {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter sample text: ");
      String data = sc.nextLine();
      //Regular expression to match digits in a string
      String regex = "\\d+";
      //Creating a pattern object
      Pattern pattern = Pattern.compile(regex);
      //Creating a Matcher object
      Matcher matcher = pattern.matcher(data);
      System.out.println("Digits in the given string are: ");
      while(matcher.find()) {
         System.out.print(matcher.group()+" ");
      }
   }
}
Enter sample text:
this is a sample 23 text 46 with 11223 numbers in it
Digits in the given string are:
23 46 11223
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Just {
   public static void main(String[] args) {
      String data = "abc12def334hjdsk7438dbds3y388";
      //Regular expression to digits
      String regex = "([0-9]+)";
      //Creating a pattern object
      Pattern pattern = Pattern.compile(regex);
      //Creating a Matcher object
      Matcher matcher = pattern.matcher(data);
      System.out.println("Digits in the given string are: ");
      while(matcher.find()) {
         System.out.print(matcher.group()+" ");
      }
   }
}
Digits in the given string are:
12 334 7438 3 388
Python - Tkinter LabelFrame

A labelframe is a simple container widget. Its primary purpose is to act as a spacer or container for complex window layouts.
This widget has the features of a frame plus the ability to display a label.
Here is the simple syntax to create this widget −
w = LabelFrame( master, option, ... )

master − This represents the parent window.
master − This represents the parent window.
options − Here is the list of most commonly used options for this widget. These options can be used as key-value pairs separated by commas.
options − Here is the list of most commonly used options for this widget. These options can be used as key-value pairs separated by commas.
bg
The normal background color displayed behind the label and indicator.
bd
The size of the border around the indicator. Default is 2 pixels.
cursor
If you set this option to a cursor name (arrow, dot etc.), the mouse cursor will change to that pattern when it is over the checkbutton.
font
The vertical dimension of the new frame.
height
The vertical dimension of the new frame.
labelAnchor 
Specifies where to place the label.
highlightbackground
Color of the focus highlight when the frame does not have focus.
highlightcolor
Color shown in the focus highlight when the frame has the focus.
highlightthickness
Thickness of the focus highlight.
relief
With the default value, relief=FLAT, the checkbutton does not stand out from its background. You may set this option to any of the other styles
text
Specifies a string to be displayed inside the widget.
width
Specifies the desired width for the window.
Try the following example yourself. Here is how to create a labelframe  widget −
from Tkinter import *

root = Tk()

labelframe = LabelFrame(root, text="This is a LabelFrame")
labelframe.pack(fill="both", expand="yes")
 
left = Label(labelframe, text="Inside the LabelFrame")
left.pack()
 
root.mainloop()
When the above code is  executed, it produces the following result −

    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
Tryit Editor v3.7

Tryit: JavaScript not supported
C++ While Loop

Loops can execute a block of code as long as a specified condition is reached.
Loops are handy because they save time, reduce errors, and they make code more readable.
The while loop loops through a block of code as long as a specified condition is true:
In the example below, the code in the loop will run, over and over again, as long as 
a variable (i) is less than 5:
Note: Do not forget to increase the variable used in the condition, otherwise 
the loop will never end!
Print i as long as i is less than 6.
int i = 1;
 (i < 6) {
  cout << i << "\n";
  ;
}

Start the Exercise
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
How to swap two numbers without using a temp variable in C#

To swap two numbers, use the third variable and perform arithmetical operator without using a temp variable.
Set two variables for swapping −
val1 = 5;
val2 = 10;
Now perform the following operation for swap −
val1 = val1 + val2;
val2 = val1 - val2;
val1 = val1 - val2;
using System;
namespace Demo {
   class Program {
      static void Main(string[] args) {

         int val1,val2;
         val1 = 5;
         val2 = 10;

         Console.WriteLine("Values before swap...");
         Console.WriteLine(val1.ToString());
         Console.WriteLine(val2.ToString());

         val1 = val1 + val2;
         val2 = val1 - val2;
         val1 = val1 - val2;

         Console.WriteLine("Values after swap...");
         Console.WriteLine(val1.ToString());
         Console.WriteLine(val2.ToString());
         Console.ReadLine();
      }
   }
}
DAX Aggregation - SUMX function

Returns the sum of an expression evaluated for each row in a table.
SUMX (<table>, <expression>) 

table
The table containing the rows for which the expression will be evaluated.
expression
The expression to be evaluated for each row of the table.
A decimal number.
Only the numbers in the column that results by evaluating the expression are counted.
Blanks, logical values, and text are ignored.
USA Gold Medal Count:= SUMX(
   Results,IF(AND([Country] = "USA",[Medal] = "Gold") = TRUE(),1,0)
) 

    53 Lectures 
     5.5 hours 

 Abhay Gadiya

    24 Lectures 
     2 hours 

 Randy Minder

    26 Lectures 
     4.5 hours 

 Randy Minder
 Print
 Add Notes
 Bookmark this page
iftop command in Linux with Examples - GeeksforGeeks

26 May, 2020
iftop is a network analyzing tool used by system administrators to view the bandwidth related stats. It shows a quick overview of the networking activities on an interface. It stands from Interface TOP and the top is derived from op command in Linux. It even acts as a diagnostics to diagnose which program is causing the problem to the network.
For RedHat based Linux
yum install epel-release
yum install  iftop

For Debian or Ubuntu Linux
sudo apt install iftop

1. To display basic bandwidth usage of the default interface.
iftop
This command will now display all the bandwidth related stats of the default interface.
2. To display bandwidth details of a specific router
sudo iftop -i wlo1
This command will now display all the bandwidth related stats of the specified network interface which is wlo1.
3. To stop hostname lookup
sudo iftop -n -i wlo1
This command will now stop the lookup of the hostname for the specified network interface which is wlo1.
4. To stop the conversion of port number to services.
sudo iftop -N -i wlo1
This command will not convert the port number to services while printing stats for the specified network interface which is wlo1.
5. To stop the display of bar graph.
sudo iftop -b
This command will remove the bar graph of traffic from the output.
6. To display the text interface without ncurses
sudo iftop -t
This command will display the output in the text interface without ncurses.
7. To sort output by source address
sudo iftop -o source 
This command will sort the output on the basis of the source address.
8. To sort output by destination address
sudo iftop -o destination
This command will sort the output on the basis of the destination address.
9. To specify number of lines to be printed
sudo iftop -L 2 -i wlo1
This command will print 2 output lines of statistics or bandwidth usage and not more than 2 lines would be printed.
10. To display help
sudo iftop -h
This command will display the help section of the iftop command.
linux-command
Linux-networking-commands
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Thread functions in C/C++
nohup Command in Linux with Examples
mv command in Linux with examples
scp command in Linux with Examples
Docker - COPY Instruction
chown command in Linux with Examples
nslookup command in Linux with Examples
SED command in Linux | Set 2
Named Pipe or FIFO with example C program
uniq Command in LINUX with examples
Reading and writing Excel files using the openpyxl module in Python

openpyxl is a Python library to read/write Excel 2010 xlsx/xlsm/xltx/xltm files.
It was born from lack of existing library to read/write natively from Python the Office Open XML format.
An excel file that we use for operation is called Workbook that contains a minimum of one Sheet and a maximum of tens of sheets.
One sheet consists of rows starting from 1 and columns starting from A.
Using the openpxyl library, we can perform various functions including adding sheets and data, manipulate and even delete said data.
Now that we know what we are dealing with, let us get started.
The openpyxl does not come packaged with Python, which means we will have to download and install it using the PIP package manager. To do this, use launch your terminal and enter the command below.
pip install openpyxl
Once you have the library downloaded and installed, we’ll have to import it’s various modules to start working on the excel files.
Let us first import the workbook module from the openpyxl library
from openpyxl import Workbook
Now that we’ve made the necessary imports, we can work on creating and saving data to the excel sheet using the Workbook module.
Firstly, we create an instance of the Workbook() class.
wb = Workbook()
Next, we create a sheet.
sheet = wb.active

It’s time to start adding data.
sheet['A1'] = "Hello"
sheet['A2'] = "World!"
sheet['A3'] = 41.80
sheet['A4'] = 10
Now that we’ve added some content, let us save and preview the file we’ve created.
wb.save("example.xlsx")
Similarly, you can add values using cell coordinates instead of A1 or B1.
sheet.cell(row=2, column=2).value = 5
This will add 5 to B2.
Now that we’ve learnt how to write data into an excel file, let us now read data from an excel file.
This time we need not import the Workbook module, just importing openpyxl should do.
import openpyxl

In order to read from a file, we must first provide it’s location to the reader.
wb = openpyxl.load_workbook("example.xlsx")
sheet = wb.active
This will load up the excel file. We can now start reading data from it.
temp1 = sheet['A1']
temp2 = sheet['B1']
temp3 = sheet.cell(row = 3, column = 1)
temp4 = sheet.cell(row = 4, column = 1)
print(temp1.value, temp2.value, temp3.value, temp4.value)
Hello World! 41.8 10
from openpyxl import Workbook
import openpyxl

wb = Workbook()
sheet = wb.active
sheet['A1'] = "Hello"
sheet['B1'] = "World!"
sheet['A3'] = 41.80
sheet['A4'] = 10

wb.save("example.xlsx")

wb = openpyxl.load_workbook("example.xlsx")
sheet = wb.active
temp1 = sheet['A1']
temp2 = sheet['B1']
temp3 = sheet.cell(row = 3, column = 1)
temp4 = sheet.cell(row = 4, column = 1)
print(temp1.value, temp2.value, temp3.value, temp4.value)
You can now read and write excel files using Python!
There are a lot more features within the openpyxl library, you can add multiple data at once, build charts, display stats and much more!
If you are curious and want to learn more, check out their official documentation at https://pypi.org/project/openpyxl/.
C# Linq Select Method

Use the Select method to modify the elements in an array.
The following is our string array.
string[] stationery = { "diary", "board", "pencil", "whiteboard" };
The Select method also specifies Lambda Expressions as shown below −
 Live Demo
using System;
using System.Linq;
using System.Collections.Generic;
public class Demo {
   public static void Main() {
      string[] stationery = { "diary", "board", "pencil", "whiteboard" };
      var res = stationery.AsQueryable().Select((item, index) => new { result = item.Substring(0, index + 4) });
      foreach (var str in res) {
         Console.WriteLine("{0}", str);
      }
   }
}
{ result = diar }
{ result = board }
{ result = pencil }
{ result = whitebo }
\sideset - Tex Command

\sideset - used for putting symbols at the four 'corners' of a large operator.
{ \sideset{_#1^#2}{_#3^#4} <large operator>}
\sideset command is used for putting symbols at the four 'corners' of a large operator.

\sideset{_1^2}{_3^4}\sum

∑12∑34



\sideset{_1^2}{_3^4}\sum

∑12∑34


\sideset{_1^2}{_3^4}\sum

    14 Lectures 
     52 mins

 Ashraf Said

    11 Lectures 
     1 hours 

 Ashraf Said

    9 Lectures 
     1 hours 

 Emenwa Global, Ejike IfeanyiChukwu

    29 Lectures 
     2.5 hours 

 Mohammad Nauman

    14 Lectures 
     1 hours 

 Daniel Stern

    15 Lectures 
     47 mins

 Nishant Kumar
 Print
 Add Notes
 Bookmark this page
Caffe2 - Verifying Access to Pre-Trained Models

Before you learn to use a pre-trained model in your Python application, let us first verify that the models are installed on your machine and are accessible through the Python code.
When you install Caffe2, the pre-trained models are copied in the installation folder. On the machine with Anaconda installation, these models are available in the following folder.
anaconda3/lib/python3.7/site-packages/caffe2/python/models

Check out the installation folder on your machine for the presence of these models. You can try loading these models from the installation folder with the following short Python script −
CAFFE_MODELS = os.path.expanduser("/anaconda3/lib/python3.7/site-packages/caffe2/python/models")
INIT_NET = os.path.join(CAFFE_MODELS, 'squeezenet', 'init_net.pb')
PREDICT_NET = os.path.join(CAFFE_MODELS, 'squeezenet', 'predict_net.pb')
print(INIT_NET)
print(PREDICT_NET)

When the script runs successfully, you will see the following output −
/anaconda3/lib/python3.7/site-packages/caffe2/python/models/squeezenet/init_net.pb
/anaconda3/lib/python3.7/site-packages/caffe2/python/models/squeezenet/predict_net.pb

This confirms that the squeezenet module is installed on your machine and is accessible to your code.
Now, you are ready to write your own Python code for image classification using Caffe2 squeezenet pre-trained module.
 Print
 Add Notes
 Bookmark this page
Missing letter from strings in JavaScript

We have a string of length m that contains first m letters of the English alphabets, but somehow, one element went missing from the string. So now the string contains m-1 letters.
We are required to write a function that takes in one such string and returns the missing element from the string
Therefore, let’s write the code for this function −
The code for this will be −
const str = "acdghfbekj";
const missingCharacter = str => {
   // to make the function more consistent
   const s = str.toLowerCase();
   for(let i = 97; ; i++){
      if(s.includes(String.fromCharCode(i))){
         continue;
      };
      return String.fromCharCode(i);
   };
   return false;
};
console.log(missingCharacter(str));
The output in the console will be −
i
How do I check that a number is float or integer - JavaScript?

Let’s say we have the following variables −
var value1 = 10;
var value2 = 10.15;
Use the Number() condition to check that a number is float or integer −
Number(value) === value && value % 1 !== 0;
}
Following is the code −
function checkNumberIfFloat(value) {
   return Number(value) === value && value % 1 !== 0;
}
var value1 = 10;
var value2 = 10.15;
if (checkNumberIfFloat(value1) == true)
   console.log("The value is float=" + value1);
else
   console.log("The value is not float=" + value1);
if (checkNumberIfFloat(value2) == true)
   console.log("The value is float=" + value2);
else
   console.log("The value is not float=" + value2);
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo218.js.
The output is as follows −
PS C:\Users\Amit\JavaScript-code> node demo218.js
The value is not float=10
The value is float=10.15
How to change the mouse pointer color in Tkinter?

Tkinter is a standard Python library for developing GUI-based applications. We can change the properties of its widgets by using the built-in functions and methods. In some applications, the properties affect the mouse pointer as well.
Tkinter provides us a way to change the mouse pointer color in the window. To configure the mouse pointer color, we can specify the cursor value with (cursor type and its color). For example, to change the cursor color in a label widget, we can specify the value as, cursor="plus #aab1212" where "plus" defines the cursor type and #aab1212 is the Hex value of the color.
# Import the required libraries
from tkinter import *

# Create an instance of tkinter frame or window
win=Tk()

# Set the size of the window
win.geometry("700x350")

# Add bottom widget
label=Label(win, text="label cursor", cursor="plus red", font=('calibri 18'))
label.pack(pady=20)

Button(win, text="Button cursor",cursor="dot blue").pack()

win.mainloop()
If we run the above code, it will display a window with a label widget and a button. Hovering on the widget will change the cursor property.
Tryit Editor v3.7 - Show Java

import java.time.LocalDate;  // import the LocalDate class

public class Main {  
  public static void main(String[] args) {  
    LocalDate myObj = LocalDate.now();  // Create a date object
    System.out.println(myObj);  // Display the current date
Perl | uc() Function - GeeksforGeeks

07 May, 2019
uc() function in Perl returns the string passed to it after converting it into uppercase. It is similar to ucfirst() function which returns only first character in uppercase.
Note: The characters which are already in UpperCase are not modified.
Syntax: uc String
Returns: string in uppercase.
Example 1:
#!/usr/bin/perl -w  # String to be converted to UPPERCASE$string = "geeksfOrGeeks";  print "Original String: $string\n";  # Converting the string to # UPPERCASE using uc() function$UPPER_STRING = uc($string);  print "Modified String: $UPPER_STRING";
Original String: geeksfOrGeeks
Modified String: GEEKSFORGEEKS

Example 2:
#!/usr/bin/perl -w  # String to be converted to UPPERCASE$string = "WelComEToGeeKS";  print "Original String: $string\n";  # Converting the string to # UPPERCASE using uc() function$UPPER_STRING = uc($string);  print "Modified String: $UPPER_STRING";
Original String: WelComEToGeeKS
Modified String: WELCOMETOGEEKS

Perl-function
Perl-String-Functions
Perl
Perl
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Perl | Arrays
Perl | Arrays (push, pop, shift, unshift)
Perl Tutorial - Learn Perl With Examples
Use of print() and say() in Perl
Perl | Subroutines or Functions
Perl | Boolean Values
Perl | length() Function
Introduction to Perl
Perl | join() Function
Perl | sleep() Function
Program to perform string compression in Python

Suppose we have a string s. We have to compress this string into Run length encoding form. So when a character is repeated k number of times consecutively like 'bbbb' here letter 'b' is repeated four times consecutively, so the encoded form will be 'b4'. For single characters we shall not add the count into it.
So, if the input is like s = "abbbaaaaaaccdaaab", then the output will be ab3a6c2da3b
To solve this, we will follow these steps −
res := blank string
cnt := 1
for i in range 1 to size of s - 1, doif s[i - 1] is same as s[i], thencnt := cnt + 1otherwise,res := res concatenate s[i - 1]if cnt > 1, thenres := res concatenate cntcnt := 1
if s[i - 1] is same as s[i], thencnt := cnt + 1
cnt := cnt + 1
otherwise,res := res concatenate s[i - 1]if cnt > 1, thenres := res concatenate cntcnt := 1
res := res concatenate s[i - 1]
if cnt > 1, thenres := res concatenate cnt
res := res concatenate cnt
cnt := 1
res := res + last character of s
if cnt > 1, thenres := res concatenate cnt
res := res concatenate cnt
return res
Let us see the following implementation to get better understanding −
def solve(s):
   res = ""
   cnt = 1
   for i in range(1, len(s)):
      if s[i - 1] == s[i]:
         cnt += 1
      else:
         res = res + s[i - 1]
         if cnt > 1:
            res += str(cnt)
         cnt = 1
   res = res + s[-1]
   if cnt > 1:
      res += str(cnt)
   return res

s = "abbbaaaaaaccdaaab"
print(solve(s))
"abbbaaaaaaccdaaab"

ab3a6c2da3b
Absolute Deviation and Absolute Mean Deviation using NumPy

In Statistical analysis study of data variability in a sample indicates how dispersed are the values in a given data sample. The two important ways we calculate the variability are Absolute Deviation and  Mean Absolute Deviation.
In this method we first find the mean value of the given sample and then calculate the difference between each value and the mean value of the sample called as the absolute deviation value of each data sample. So for the values higher than mean the value the deviation value will be positive and for those lower than the mean value the deviation value will be negative. Next we take the absolute values using the absolute function to make each deviation as positive. Summing up all these absolute deviation gives a positive result. Without absolute value the sum of these deviations would be zero.
In the below example we take a data sample and calculate the absolute deviation for each data element.
from numpy import mean, absolute
   data = [12, 42, 53, 13, 112]
# Find mean value of the sample
M = mean(data)
print "Sample Mean Value = ",mean(data)
print "\n"
# Calculate absolute deviation
print "Data-Mean","","deviation"
for i in range(len(data)):
   dev = absolute(data[i] - M)
   print data[i],"-",M,round((dev),2)
Running the above code gives us the following result −
Sample Mean Value = 46.4
Data-Mean deviation
12 - 46.4 34.4
42 - 46.4 4.4
53 - 46.4 6.6
13 - 46.4 33.4
112 - 46.4 65.6
Mean Absolute Deviation (MAD) is the mean value of all the absolute deviations we calculate for each data point. Taking the same sample as in previous example, we add code to sum up the value of the absolute deviations and divide it by the sample size.
from numpy import mean, absolute
data = [12, 42, 53, 13, 112]
# Find mean value of the sample
M = mean(data)
print "Sample Mean Value = ",mean(data)
sum = 0
# Calculate mean absolute deviation
for i in range(len(data)):
   dev = absolute(data[i] - M)
   sum = sum + round(dev,2)
print "Mean Absolute Deviation: ", sum/len(data)
Running the above code gives us the following result −
Sample Mean Value = 46.4
Mean Absolute Deviation: 28.88
How can SciPy be used to calculate the permutations and combination values in Python?

SciPy can be used to determine the permutation and combination with respect to two values.
A function named ‘perm’ present in the class ‘special’ in ‘SciPy’ is used.
Syntax of ‘perm’ function
scipy.special.perm(N, k)
Performing permutation on a set of values has been shown below
 Live Demo
from scipy.special import perm
my_permute = perm(6, 2, exact = True)
print("The permutation of 6 and 2 is ")
print(my_permute)
The permutation of 6 and 2 is
30
The required libraries are imported.
Parameters are passed to the ‘perm’ function that computes the value.
The value is assigned to a variable.
This variable is displayed on the console.
A function named ‘comb’ present in the class ‘special’ in ‘SciPy’ is used.
Syntax of ‘comb’ function
scipy.special.comb(N, k)

Performing permutation on a set of values has been shown below
 Live Demo
from scipy.special import comb
my_comb = comb(6, 2, exact = True)
print("The combination of 6 and 2 is ")
print(my_comb)
The combination of 6 and 2 is
15
The required libraries are imported.
Parameters are passed to the ‘comb’ function that computes the value.
The value is assigned to a variable.
This variable is displayed on the console.
ntptrace - Unix, Linux Command

ntptrace determines where a given Network Time Protocol (NTP) server gets its time from, and follows the chain of NTP servers back to their master time source. If given no arguments, it starts with localhost[char46] Here is an example of the output from ntptrace:



% ntptrace
localhost: stratum 4, offset 0.0019529, synch distance 0.144135
server2ozo.com: stratum 2, offset 0.0124263, synch distance 0.115784
usndh.edu: stratum 1, offset 0.0019298, synch distance 0.011993, refid ’WWVB’











This program makes no attempt to improve accuracy by doing multiple samples.




Primary source of documentation: /usr/share/doc/ntp-*


This file was automatically generated from HTML source.













Advertisements


    129 Lectures 
     23 hours 

 Eduonix Learning Solutions

    5 Lectures 
     4.5 hours 

 Frahaan Hussain

    35 Lectures 
     2 hours 

 Pradeep D

    41 Lectures 
     2.5 hours 

 Musab Zayadneh

    46 Lectures 
     4 hours 

 GUHARAJANM

    6 Lectures 
     4 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
What are the steps involved to use a CURSOR in any COBOL-DB2 program?

The CURSOR is used when we have to fetch multiple rows from a table. There are 4 steps involved in order to use a cursor in a COBOL-DB2 program.
DECLARE cursor− In this step we will define the layout of the cursor. We will give the query we want to use. For example−
DECLARE cursor− In this step we will define the layout of the cursor. We will give the query we want to use. For example−
EXEC SQL
DECLARE ORDER_CUR CURSOR FOR
SELECT ORDER_ID FROM ORDERS
WHERE ORDER_DATE = ‘2020-07-28’
END-EXEC
OPEN cursor− Next we will open our cursor. This statement readies the cursor for data retrieval. For example−
OPEN cursor− Next we will open our cursor. This statement readies the cursor for data retrieval. For example−
EXEC SQL
OPEN ORDER_CUR
END-EXEC
FETCH cursor− In this statement, we start fetching the data from DB2 and the row data is stored in host variables. The syntax is like below.
FETCH cursor− In this statement, we start fetching the data from DB2 and the row data is stored in host variables. The syntax is like below.
EXEC SQL
FETCH ORDER_CUR INTO :ORDER-ID
END-EXEC
CLOSE cursor− In this last step we close the cursor which will release all the resources held by the cursor.
CLOSE cursor− In this last step we close the cursor which will release all the resources held by the cursor.
EXEC SQL
CLOSE ORDER_CUR
END-EXEC
Tcl - While Loop

A while loop statement in Tcl language repeatedly executes a target statement as long as a given condition is true.
The syntax of a while loop in Tcl language is −
while {condition} {
   statement(s)
}

Here, statement(s) may be a single statement or a block of statements. The condition may be any expression, and true is any nonzero value. The loop iterates while the condition is true.
When the condition becomes false, program control passes to the line immediately following the loop.
The point to note about the while loop is that the loop might not ever run. When the condition is tested and the result is false, the loop body will be skipped and the first statement after the while loop will be executed.
#!/usr/bin/tclsh

set a 10

#while loop execution 
while { $a < 20 } {
   puts "value of a: $a"
   incr a
}
When the above code is compiled and executed, it produces the following result −
value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 15
value of a: 16
value of a: 17
value of a: 18
value of a: 19

 Print
 Add Notes
 Bookmark this page
Iterating over Enum Values in Java

The Enum class is the common base class of all Java language enumeration types.
Let us see an example to iterate over enum values using for loop −
public class Demo {
   public enum Vehicle { CAR, BUS, BIKE }
   public static void main(String[] args) {
      for (Vehicle v : Vehicle.values())
         System.out.println(v);
   }
}
CAR
BUS
BIKE
Let us now see another example to iterate over enum values using for each −
import java.util.stream.Stream;
public class Demo {
   public enum Work { TABLE, CHAIR, NOTEPAD, PEN, LAPTOP }
   public static void main(String[] args) {
      Stream.of(Work.values()).forEach(System.out::println);
   }
}
TABLE
CHAIR
NOTEPAD
PEN
LAPTOP
JavaScript - Date getDay() Method

Javascript date getDay() method returns the day of the week for the specified date according to local time. The value returned by getDay() is an integer corresponding to the day of the week: 0 for Sunday, 1 for Monday, 2 for Tuesday, and so on.
Its syntax is as follows −
Date.getDay()

Returns the day of the week for the specified date according to local time.
Try the following example.
<html>
   <head>
      <title>JavaScript getDay Method</title>
   </head>
   
   <body>   
      <script type = "text/javascript">
         var dt = new Date("December 25, 1995 23:15:00");
         document.write("getDay() : " + dt.getDay() ); 
      </script>      
   </body>
</html>
getDay() : 1 


    25 Lectures 
     2.5 hours 

 Anadi Sharma

    74 Lectures 
     10 hours 

 Lets Kode It

    72 Lectures 
     4.5 hours 

 Frahaan Hussain

    70 Lectures 
     4.5 hours 

 Frahaan Hussain

    46 Lectures 
     6 hours 

 Eduonix Learning Solutions

    88 Lectures 
     14 hours 

 Eduonix Learning Solutions
 Print
 Add Notes
 Bookmark this page
Ant - JUnit Integration

JUnit is the commonly used unit testing framework for Java-based developments. It is easy to use and easy to extend. There are a number of JUnit extensions available. If you are unfamiliar with JUnit, you should download it from www.junit.org and read its manual.
This chapter shows how to execute JUnit tests by using Ant. The use of Ant makes it straight forward through the JUnit task.
The attributes of the JUnit task are presented below −
dir
Where to invoke the VM from. This is ignored when fork is disabled.
jvm
Command used to invoke the JVM. This is ignored when fork is disabled.
fork
Runs the test in a separate JVM.
errorproperty
The name of the property to set if there is a JUnit error.
failureproperty
The name of the property to set if there is a JUnit failure.
haltonerror
Stops execution when a test error occurs.
haltonfailure
Stops execution when a failure occurs.
printsummary
Advises Ant to display simple statistics for each test.
showoutput
Advises Ant to send the output to its logs and formatters.
tempdir
Path to the temporary file that Ant will use.
timeout
Exits the tests that take longer to run than this setting (in milliseconds).
Let us continue the theme of the Hello World Fax web application and add a JUnit target.
The following example shows a simple JUnit test execution −
<target name="unittest">
   <junit haltonfailure="true" printsummary="true">
      <test name="com.tutorialspoint.UtilsTest"/>
   </junit>
</target>
This example shows the execution of JUnit on the com.tutorialspoint.UtilsTest junit class.
Running the above code produces the following output −
test:
[echo] Testing the application
[junit] Running com.tutorialspoint.UtilsTest
[junit] Tests run: 12, Failures: 0, Errors: 0, Time elapsed: 16.2 sec
BUILD PASSED


    20 Lectures 
     2 hours 

 Deepti Trivedi

    19 Lectures 
     2.5 hours 

 Deepti Trivedi

    139 Lectures 
     14 hours 

 Er. Himanshu Vasishta

    30 Lectures 
     1.5 hours 

 Pushpendu Mondal

    65 Lectures 
     6.5 hours 

 Ridhi Arora

    10 Lectures 
     2 hours 

 Manish Gupta
 Print
 Add Notes
 Bookmark this page
Vim - Editing

Vim provides many commands which make editing functionality really powerful. In this chapter, we will discuss following items −
Insert
Append
Open new line
Substitute
Change
Replace
Join
To insert text before cursor perform following steps −
To insert text before cursor perform following steps
Switch to insert mode
i

Let us suppose you are in the middle of line and you want to insert text at the beginning of current line then perform following steps −
Switch to command mode
Esc

Activate insert mode
I

This action will move cursor to the beginning of current line and switch Vim in insert mode
To append text after cursor perform following steps
Switch to command mode and move cursor to appropriate position
Esc

Switch to insert mode
a

This action will move cursor next by one position and switch Vim in insert mode.
Let us suppose you are in the middle of line and you want to append text at the end of current line then perform following steps −
Switch to command mode
Esc

Switch to insert mode
A

This action will move cursor to the end of line and switch Vim in insert mode
Let us suppose you are in the middle of line and you want to open new line below current line then perform following steps −
Switch to command mode
Esc

Switch to insert mode
o

This action will insert blank line below current line and switch Vim in insert mode
Let us suppose you are in the middle of line and you want to open new line above current line then perform following steps −
Switch to command mode
Esc

Switch to insert mode
o

This action will insert blank line above current line and switch Vim in insert mode
Let us suppose you want to substitute single character then perform following steps −
Switch to command mode
Esc

Move cursor to appropriate position
Switch to insert mode
s

This action will delete character under cursor and switch Vim in insert mode To substitute entire line use −
s

This action will delete entire line and switch Vim in insert mode.
Let us suppose you want to change text in current line then perform following steps −
Switch to command mode
Esc

Execute following command −
cc

This is similar to substitute action using S
To change text from current cursor position, execute following command
C

This action will delete text after current cursor position and switch Vim in insert mode.
To replace single character perform following steps −
Switch to command mode
Esc

Move cursor to appropriate position
Execute following command −
r

Enter character to be substituted.
Note that this command will not switch Vim in insert mode
To replace entire line execute −
R

It will switch Vim in replace mode as shown in below image −
To join two lines perform following steps −
Switch to command mode
Esc

Move cursor to appropriate line
Execute following command −
J


    46 Lectures 
     5.5 hours 

 Jason Cannon
 Print
 Add Notes
 Bookmark this page
How do I check if a column is empty or null in MySQL?

To check if a column is empty or null , we can use the where clause with IS NULL and for empty
we can use the condition ‘ ‘ i.e. empty space. The steps required for this are as folllows:
First a table is created with the help of create command as follows −
mysql> CREATE table ColumnValueNullDemo
-> (
-> ColumnName varchar(100)
-> );
Query OK, 0 rows affected (0.61 sec)
An empty value is inserted into the table using insert command. This is given below −
mysql> INSERT into ColumnValueNullDemo values(' ');
Query OK, 1 row affected (0.14 sec)
After that, the table records are displayed using the select command. This is given as follows −
mysql> SELECT * from ColumnValueNullDemo;

After executing the above query, we will get the following output −
+-------------------+
| ColumnName        |
+-------------------+
|                   |
+-------------------+
1 row in set (0.00 sec)
To check if the column has null value or empty, the syntax is as follows −
SELECT * FROM yourTableName WHERE yourSpecificColumnName IS NULL OR
yourSpecificColumnName = ' ';
The IS NULL constraint can be used whenever the column is empty and the symbol ( ‘ ‘) is used
when there is empty value.
Now, the query using the above syntax is given as follows −
mysql> SELECT * FROM ColumnValueNullDemo WHERE ColumnName IS NULL OR
ColumnName = ' ';
After executing the above query, the output obtained is.
+------------+
| ColumnName |
+------------+
|            | 
+------------+
1 row in set (0.00 sec)
This output was obtained as the second condition is true for empty value.
Now, NULL value is inserted into the table with the help of the insert command as follows −
mysql> INSERT into ColumnValueNullDemo values();
Query OK, 1 row affected (0.14 sec)
The select command is used to view the contents of the table as follows −
mysql> SELECT * from ColumnValueNullDemo;

After executing the above query, the following output is obtained −
+------------+
| ColumnName |
+------------+
|            |
| NULL       |
+------------+
2 rows in set (0.00 sec)
Now, the condition to check for null or emptyis applied −
mysql> SELECT * FROM ColumnValueNullDemo WHERE ColumnName IS NULL OR
ColumnName = '';
Both the table rows are obtained as output because it is true in both conditions.
+------------+
| ColumnName |
+------------+
|            |
| NULL       |
+------------+
2 rows in set (0.00 sec)
How to convert nested array pairs to objects in an array in JavaScript ?

Suppose, we have an array of arrays like this −
const arr = [
   [
      ['firstName', 'Joe'],
      ['lastName', 'Blow'],
      ['age', 42],
      ['role', 'clerk'],
      [
         ['firstName', 'Mary'],
         ['lastName', 'Jenkins'],
         ['age', 36],
         ['role', 'manager']
      ]
   ]
];
We are required to write a JavaScript function that takes in one such array. The function should construct an array of objects based on this array of arrays.
The output array should contain an object for each unique user and other details about it.
Therefore, the output for the array should look like −
const output = [
   {firstName: 'Joe', lastName: 'Blow', age: 42, role: 'clerk'},
   {firstName: 'Mary', lastName: 'Jenkins', age: 36, role: 'manager'}
];
The code for this will be −
const arr = [
   [
      ['firstName', 'Joe'],
      ['lastName', 'Blow'],
      ['age', 42],
      ['role', 'clerk'],
      [
         ['firstName', 'Mary'],
         ['lastName', 'Jenkins'],
         ['age', 36],
         ['role', 'manager']
      ]
   ]
];
const convertToObject = (arr = []) => {
   const empty = {};
   const res = arr.map(el => {
      const object = this;
      el.forEach(attr => {
         let name = attr[0], value = attr[1];
         object[name] = value;
         return object;
      }, object);
      return this;
   }, empty);
   return res;
}
console.log(convertToObject(arr));
And the output in the console will be −
[
   {
      firstName: 'Joe',
      lastName: 'Blow',
      age: 42,
      role: 'clerk',
      'firstName,Mary': [ 'lastName', 'Jenkins' ]
   }
]
\fbox - Tex Command

\fbox - Used to put a box around argument; argument is in text mode.
{ \fbox #1 }
\fbox command draws a box around argument; argument is in text mode.

\boxed{Hi there!}

Hithere!


\fbox{Hi there!}

Hi there!



\boxed{Hi there!}

Hithere!


\boxed{Hi there!}
\fbox{Hi there!}

Hi there!


\fbox{Hi there!}

    14 Lectures 
     52 mins

 Ashraf Said

    11 Lectures 
     1 hours 

 Ashraf Said

    9 Lectures 
     1 hours 

 Emenwa Global, Ejike IfeanyiChukwu

    29 Lectures 
     2.5 hours 

 Mohammad Nauman

    14 Lectures 
     1 hours 

 Daniel Stern

    15 Lectures 
     47 mins

 Nishant Kumar
 Print
 Add Notes
 Bookmark this page
C# and Selenium: Wait Until Element is Present

We can wait until an element is present in Selenium webdriver using the explicit wait. It is mainly used whenever there is a synchronization issue for an element to be available on page.
The WebDriverWait and the ExpectedCondition classes are used for an explicit wait implementation. We have to create an object of the WebDriverWait which shall invoke the methods of the ExpectedCondition class.
The webdriver waits for a specified amount of time for the expected criteria to be met. After the time has elapsed, an exception gets thrown. To wait for an element to be present, we have to use the expected condition – ElementExists.
WebDriverWait w = new WebDriverWait(driver, TimeSpan.FromSeconds(20));
w.Until(ExpectedConditions.ElementExists(By.TagName("h1")));
Let us try to wait for the text - About Careers at Tutorials Point to be available on the page −
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Support.UI;
namespace NUnitTestProject2{
   public class Tests{
      String url ="https://www.tutorialspoint.com/about/about_careers.htm";
      IWebDriver driver;
      [SetUp]
      public void Setup(){
         //creating object of FirefoxDriver
         driver = new FirefoxDriver("");
      }
      [Test]
      public void Test2(){
         //URL launch
         driver.Navigate().GoToUrl(url);
         //identify element then click
         IWebElement l = driver.FindElement(By.XPath("//*[text()='Careers']"));
         l.Click();
         //expected condition of ElementExists
         WebDriverWait w = new WebDriverWait(driver, TimeSpan.FromSeconds(20));
         w.Until(ExpectedConditions.ElementExists(By.TagName("h1")));
         //identify element then obtain text
         IWebElement m = driver.FindElement(By.TagName("h1"));
         Console.WriteLine("Element text is: " + m.Text);
      }
      [TearDown]
      public void close_Browser(){
         driver.Quit();
      }
   }
}
Style to highlight active HTML anchor with CSS

To highlight active HTML anchor with CSS, use the :target selector.
You can try to run the following code to implement the :target Selector:
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <style>
         :target {
            border: 2px solid #D4D4D4;
            background-color: orange;
            color: white;
         }
      </style>
   </head>
   <body>
      <p>Click any of the subject below.</p>
      <p><a href = "#tut1">Maths</a></p>
      <p><a href = "#tut2">Java</a></p>
      <p><a href = "#tut3">C++</a></p>
      <p><a href = "#tut4">C</a></p>
      <p>This is demo text.</p>
      <p>This is demo text.</p>
      <p>This is demo text.</p>
      <p>This is demo text.</p>
      <p>This is demo text.</p>
      <p id = "tut1"><b>Maths Tutorial</b></p>
      <p id = "tut2"><b>Java Tutorial</b></p>
      <p id = "tut3"><b>C++ Tutorial</b></p>
      <p id = "tut4"><b>C Tutorial</b></p>
   </body>
</html>
How to create a plot title with unicode characters using ggplot2 in R?

If we want to use unicode characters in the title for a plot created with the help of ggplot2 package then the ggtitle function will be used combined with functions called expression and paste. Using the expression and paste functions, we can write unicode characters for the title of the plot. Check out the below examples to understand how it works.
Consider the below data frame −
Live Demo
> x<-rnorm(20,3,1.04)
> y<-rnorm(20,5,1.04)
> df<-data.frame(x,y)
> df
      x        y
1 3.4501307 6.354644
2 2.1561511 5.349282
3 4.5018653 6.080046
4 2.5512959 5.957558
5 3.6818738 5.749713
6 3.3348023 3.915156
7 2.1848075 4.906206
8 4.6387566 5.648459
9 3.6686153 4.008336
10 3.0933511 4.435458
11 3.2876128 5.604236
12 3.7064604 5.798906
13 3.0934262 5.482318
14 -0.1128137 4.078793
15 3.2962783 3.856228
16 2.6180760 6.573215
17 3.1926398 5.268238
18 3.6050967 5.091978
19 4.4557263 4.874268
20 2.2436163 3.757898
Loading ggplot2 package and creating the plot with title having unicode character mu −
> library(ggplot2)
> ggplot(df,aes(x,y))+geom_point()+ggtitle(expression(paste("Scatterplot: Normal ",mu,"=3 ","and Normal ",mu,"=5")))
How to initialize a const field in constructor?

Here we will see how to initialize the const type variable using constructor?
To initialize the const value using constructor, we have to use the initialize list. This initializer list is used to initialize the data member of a class. The list of members, that will be initialized, will be present after the constructor after colon. members will be separated using comma.
#include <iostream>
using namespace std;
class MyClass {
   private:
   const int x;
   public:
      MyClass(int a) : x(a) {
         //constructor
      }
      void show_x() {
         cout >> "Value of constant x: " >> x ;
      }
};
int main() {
   MyClass ob1(40);
   ob1.show_x();
}
Value of constant x: 40