code-rag-bench/online-tutorials huggingface dataset:
How to add a class on click of anchor tag using jQuery ? - GeeksforGeeks

30 Sep, 2021
In this article, we will see how to add a class on click of anchor tag using jQuery. To add a class on click of anchor tag, we use addClass() method. The addClass() method is used to add more property to each selected element. It can also be used to change the property of the selected element.
Syntax:
$(selector).addClass("active");
In the below example, we are creating an anchor class element and a button, when the user clicks on the button, the addClass() method is called and this method adds a class named “active”. 
Example:
HTML
<!DOCTYPE html><html>  <head>    <title>        How to add a class on click         of anchor tag using jQuery?    </title>      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">    </script>      <style>        .active {            font-size: 32px;            color: green;            font-weight: bold;            text-decoration: none;        }    </style>      <script>        $(document).ready(function() {            $("#btn").on('click', function() {                $("a").addClass("active");            });        });    </script></head>  <body>    <center>        <h1 style="color: green;">            GeeksforGeeks        </h1>          <h3>            How to add a class on click             of anchor tag using jQuery?        </h3>          <input type="button" id="btn"             value="Add Class"             style="padding: 5px 10px;">        <br><br>          <a class="" href=            "https://www.geeksforgeeks.org/">            GeeksforGeeks        </a>    </center></body>  </html>
Output:
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-Questions
jQuery-Methods
jQuery-Questions
HTML
JQuery
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
REST API (Introduction)
Design a web page using HTML and CSS
Angular File Upload
Form validation using jQuery
How to Dynamically Add/Remove Table Rows using jQuery ?
JQuery | Set the value of an input text field
Form validation using jQuery
How to change selected value of a drop-down list using jQuery?
How to Dynamically Add/Remove Table Rows using jQuery ?
How to change the background color after clicking the button in JavaScript ?
What is difference in getattr() and setattr() functions in Python?

The getattr() method returns the value of the named attribute of an object. If not found, it returns the default value provided to the function.
The syntax of getattr() method is −
getattr(object, name[, default])
The getattr() method can take multiple parameters −
The getattr() method returns −
value of the named attribute of the given object
default, if no named attribute is found
AttributeError exception, if named attribute is not found and default is not defined
The setattr() method sets the value of given attribute of an object.
The syntax of setattr() method is −
setattr(object, name, value)
The setattr() method takes three parameters −
The setattr() method returns None.
MomentJS - Calendar Time

This method displays the time difference to given reference time and the Calendar time.
moment().calendar();
moment().calendar(referenceTime);
moment().calendar(referenceTime, formats);

var changeddate = moment().calendar();
We have discussed chaining method in earlier chapter, so we can use the add/subtract methods with moment to get the calendar value as shown below −
var changeddate = moment().add(24, 'h').calendar();
var changeddate = moment().subtract(24, 'h').calendar();
 Print
 Add Notes
 Bookmark this page
Tryit Editor v3.7

CSS Attr Selectors
Tryit: The [attribute="value"] selector
PHP | ceil( ) Function - GeeksforGeeks

03 Feb, 2021
We have often used the ceiling function in mathematical problems to round up a decimal number to next greater integral value. PHP provides us with a built-in function ceil() to perform such operation. The ceil() function is a built-in function in PHP and is used to round a number to the nearest greater integer.
Syntax:  
float ceil(value)
Parameters: The ceil() function accepts a single parameter value which represents the number which you want to round up to the nearest greater integer.
Return Value: The return type of the ceil() function is float as shown in the syntax. It returns the number which represents the value rounded up to the next highest integer. 
Examples:  
Input : ceil(0.70)
Output : 1

Input : ceil(-4.1)
Output : -4

Input : ceil(6)
Output : 6
Below programs illustrate the ceil() function in PHP:  
When a positive number with decimal places is passed as a parameter:
PHP
<?php echo (ceil(0.70)); ?>     
Output: 
1
When a negative number with decimal places is passed as a parameter:
PHP
<?php echo (ceil(-4.1)); ?>
Output: 
-4
When a number with no decimal places is passed as a parameter:
PHP
<?php echo (ceil(6)); ?>
Output: 
6
Reference: http://php.net/manual/en/function.ceil.php 
arorakashish0911
PHP-function
PHP-math
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to fetch data from localserver database and display on HTML table using PHP ?
How to create admin login page using PHP?
PHP Database connection
How to pass a PHP array to a JavaScript function?
String comparison using == vs strcmp() in PHP
Express.js express.Router() Function
How to set input type date in dd-mm-yyyy format using HTML ?
Installation of Node.js on Linux
Differences between Functional Components and Class Components in React
How to create footer to stay at the bottom of a Web page?
Python | Find all close matches of input string from a list - GeeksforGeeks

26 Nov, 2018
We are given a list of pattern strings and a single input string. We need to find all possible close good enough matches of input string into list of pattern strings.
Examples:
Input : patterns = ['ape', 'apple', 
                  'peach', 'puppy'], 
          input = 'appel'
Output : ['apple', 'ape']

We can solve this problem in python quickly using in built function difflib.get_close_matches().
difflib.get_close_matches(word, possibilities, n, cutoff) accepts four parameters in which n, cutoff are optional. word is a sequence for which close matches are desired, possibilities is a list of sequences against which to match word. Optional argument n (default 3) is the maximum number of close matches to return, n must be greater than 0. Optional argument cutoff (default 0.6) is a float in the range [0, 1]. Possibilities that don’t score at least that similar to word are ignored.The best (no more than n) matches among the possibilities are returned in a list, sorted by similarity score, most similar first.
# Function to find all close matches of # input string in given list of possible stringsfrom difflib import get_close_matches  def closeMatches(patterns, word):     print(get_close_matches(word, patterns))  # Driver programif __name__ == "__main__":    word = 'appel'    patterns = ['ape', 'apple', 'peach', 'puppy']    closeMatches(patterns, word)
References : https://docs.python.org/2/library/difflib.html
Output:
['apple', 'ape']

Python string-programs
python-string
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
Enumerate() in Python
Read a file line by line in Python
Defaultdict in Python
Different ways to create Pandas Dataframe
sum() function in Python
Iterate over a list in Python
How to Install PIP on Windows ?
Deque in Python
Python String | replace()
Alter a table column from VARCHAR to NULL in MySQL

To alter, use the ALTER command with CHANGE as in the below syntax −
alter table yourTableName change yourColumnName yourColumnName datatype NULL DEFAULT NULL;
Let us first create a table −
mysql> create table DemoTable1356
    -> (
    -> FirstName varchar(30)
    -> );
Query OK, 0 rows affected (0.56 sec)
Let us implement the above syntax to alter a table column to NULL −
mysql> alter table DemoTable1356 change FirstName FirstName varchar(30) NULL DEFAULT NULL;
Query OK, 0 rows affected (0.17 sec)
Records: 0  Duplicates: 0  Warnings: 0
Insert some records in the table using insert command −
mysql> insert into DemoTable1356 values('Adam');
Query OK, 1 row affected (0.10 sec)
mysql> insert into DemoTable1356 values('John');
Query OK, 1 row affected (0.10 sec)
mysql> insert into DemoTable1356 values();
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable1356 values('Bob');
Query OK, 1 row affected (0.14 sec)
mysql> insert into DemoTable1356 values(NULL);
Query OK, 1 row affected (0.24 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1356;
This will produce the following output −
+-----------+
| FirstName |
+-----------+
| Adam      |
| John      |
| NULL      |
| Bob       |
| NULL      |
+-----------+
5 rows in set (0.00 sec)
How to get the input from a Checkbox in Python Tkinter?

A checkbox widget is an input widget that has two values, either True or False. A checkbox is useful in many applications where a particular value needs to be validated.
Let us suppose that we want to get the Input value from a checkbox such that if it is selected, then print the selected value. To print the value of the selected checkbox, we can use the get() method. It returns the input value of a particular widget.
# Import Tkinter library
from tkinter import *

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

# Set the geometry of Tkinter frame
win.geometry("700x250")

# Define Function to print the input value
def display_input():
   print("Input for Python:", var1.get())
   print("Input for C++:", var2.get())

# Define empty variables
var1 = IntVar()
var2 = IntVar()

# Define a Checkbox
t1 = Checkbutton(win, text="Python", variable=var1, onvalue=1, offvalue=0, command=display_input)
t1.pack()
t2 = Checkbutton(win, text="C++", variable=var2, onvalue=1, offvalue=0, command=display_input)
t2.pack()

win.mainloop()
Executing the above code will display a window containing two checkboxes. We can trace the input by clicking over the checkbutton.
Checking the button will return the Boolean value representing the status of the Checkbutton.
Input for Python: 1
Input for C++: 0
Angular forms FormArrayName Directive - GeeksforGeeks

04 Jun, 2021
In this article, we are going to see what is Style in Angular 10 and how to use it.
The FormArrayName is used to sync a nested FormArray to a DOM element.
Syntax:
<div formArrayName="arrayName">
NgModule: Module used by FormArrayName is:
ReactiveFormsModule
 
Selectors:
[FormArrayName]
Approach: 
Create the Angular app to be used
In app.component.ts make an array that takes the value from the form
In app.component.html make a form and send the value to the array to the submission.
Serve the angular app using ng serve to see the output.
Example 1:
app.component.ts
import { Component, Inject } from '@angular/core';import { FormGroup, FormControl, FormArray } from '@angular/forms'@Component({    selector: 'app-root',    templateUrl: './app.component.html',    styleUrls: ['./app.component.css']})export class AppComponent {    form = new FormGroup({        courses: new FormArray([]),    });      get courses(): FormArray {        return this.form.get('courses') as FormArray;    }      addCourse() {        this.courses.push(new FormControl());    }      onSubmit() {        console.log(this.courses.value);    }  }
app.component.html
<br><form [formGroup]="form" (ngSubmit)="onSubmit()">    <div formArrayName="courses">          <div *ngFor="let course of courses.controls; index as i">            <input [formControlName]="i" placeholder="Course">        </div>    </div>    <br>    <button>Submit</button>    <br><br></form>  <button (click)="addCourse()">Add Course</button>
Output:
Reference: https://angular.io/api/forms/FormArrayName
Angular10
AngularJS-Directives
AngularJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 10 Angular Libraries For Web Developers
How to use <mat-chip-list> and <mat-chip> in Angular Material ?
How to make a Bootstrap Modal Popup in Angular 9/8 ?
Angular 10 (blur) Event
Angular PrimeNG Dropdown Component
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
PHP | bcmul() Function - GeeksforGeeks

19 Apr, 2018
The bcmul() function in PHP is an inbuilt function and is used to multiply two arbitrary precision numbers. This function accepts two arbitrary precision numbers as strings and returns the multiplication of the two numbers after scaling the result to a specified precision.
Syntax:
string bcmul ( $num_str1, $num_str2, $scaleVal)
Parameters: This function accepts three parameters as shown in the above syntax and explained below:
$num_str1: This parameter is of string type and represents the left operand or one of the two numbers among which we want to perform the multiplication. This parameter is mandatory.
$num_str2: This parameter is of string type and represents the right operand or one of the two numbers among which we want to perform the multiplication. This parameter is mandatory.
$scaleVal: This parameter is of int type and is optional. This parameter tells the number of digits that will appear after the decimal in the result of multiplication. It’s default value is zero.
Return Value: This function returns the multiplication of the two numbers $num_str1 and $num_str2 as string.
Examples:
Input:  $num_str1 = 3, $num_str2 = 11.222
Output: 33
Explanation: Since the parameter $scaleVal is not 
specified so no digits after decimal is appeared 
in the result after multiplication.

Input:  $num_str1 = 3, $num_str2 = 11.222, $scaleVal = 4
Output: 36.6660

Below programs illustrate the bcmul() function in PHP :
Program 1:
<?php// PHP program to illustrate bcmul() function   // input numbers with arbitrary precision$num_str1 = "3";$num_str2 = "11.222";   // calculates the multiplication of the two// numbers when $scaleVal is not specified$res = bcmul($num_str1, $num_str2);  echo $res;   ?>
Output:
33

Program 2:
<?php// PHP program to illustrate bcmul() function   // input numbers with arbitrary precision$num_str1 = "3";$num_str2 = "11.222";  // scale value$scaleVal = 3;   // calculates the multiplication of the two// numbers when $scaleVal is specified$res = bcmul($num_str1, $num_str2, $scaleVal);  echo $res;   ?>
Output:
33.666

Reference:http://php.net/manual/en/function.bcmul.php
PHP-bc
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to fetch data from localserver database and display on HTML table using PHP ?
How to create admin login page using PHP?
Different ways for passing data to view in Laravel
How to generate PDF file using PHP ?
Create a drop-down list that options fetched from a MySQL database in PHP
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
Tryit Editor v3.6 - Show Python

x = input("Enter your name:")
print("Hello, " + x)
Data Enumeration in Dart - GeeksforGeeks

11 Sep, 2021
Enumerated types (also known as enumerations or enums) are primarily used to define named constant values. The enum keyword is used to define an enumeration type in Dart. The use case of enumeration is to store finite data members under the same type definition. 
Syntax:
enum variable_name{
  // Insert the data members as shown
  member1, member2, member3, ...., memberN
}
Let’s analyze the above syntax:
The enum is the keyword used to initialize enumerated data type.The variable_name as the name suggests is used for naming the enumerated class. The data members inside the enumerated class must be separated by the commas.Each data member is assigned an integer greater than then the previous one, starting with 0 (by default).Make sure not to use semi-colon or comma at the end of the last data member.
The enum is the keyword used to initialize enumerated data type.
The variable_name as the name suggests is used for naming the enumerated class. 
The data members inside the enumerated class must be separated by the commas.
Each data member is assigned an integer greater than then the previous one, starting with 0 (by default).
Make sure not to use semi-colon or comma at the end of the last data member.
Example 1: Printing all the elements from the enum data class.  
Dart
// dart program to print all the// elements from the enum data class // Creating enum with name Gfgenum Gfg {     // Inserting data  Welcome, to, GeeksForGeeks} void main() {     // Printing the value  // present in the Gfg  for (Gfg geek in Gfg.values) {    print(geek);  }}
Output:   
Gfg.Welcome
Gfg.to
Gfg.GeeksForGeeks
Note: Notice in the above example the strings are not enclosed with quotes, so that it can be used to print different results by comparing them with the values inside the enum. 
Example 2: Using switch-case to print result. 
Dart
enum Gfg {  Welcome, to, GeeksForGeeks} void main() {      // Assign a value from  // enum to a variable geek  var geek = Gfg.GeeksForGeeks;     // Switch-case  switch(geek) {    case Gfg.Welcome: print("This is not the correct case.");    break;    case Gfg.to: print("This is not the correct case.");    break;    case Gfg.GeeksForGeeks: print("This is the correct case.");    break;  }}
Output:  
This is the correct case. 
Note: The enumerated class does not hold all types of data, rather it stores only string values without the quotes over them.  Limitation of Enumerated Data Type:   
It cannot be subclassed or mixed in.It is not possible to explicitly instantiate an enum. 
It cannot be subclassed or mixed in.
It is not possible to explicitly instantiate an enum. 
sagartomar9927
Dart-Enum
Dart
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Flutter - DropDownButton Widget
Flutter - Custom Bottom Navigation Bar
Flutter - Checkbox Widget
Flutter - Flexible Widget
Dart Tutorial
ListView Class in Flutter
Operators in Dart
Flutter - BoxShadow Widget
Flutter - Stack Widget
Flutter - Read and Write Data on Firebase
How to check if an item exists in a C# list collection?

Set a list −
List < string > list1 = new List < string > () {
   "Lawrence",
   "Adams",
   "Pitt",
   "Tom"
};
Now use the Contains method to check if an item exits in a list or not.
if (list1.Contains("Adams") == true) {
   Console.WriteLine("Item exists!");
}
The following is the code to check if an item exists in a C# list or not.
using System;
using System.Collections.Generic;
public class Program {

   public static void Main() {
      List < string > list1 = new List < string > () {
         "Lawrence",
         "Adams",
         "Pitt",
         "Tom"
      };

      Console.Write("List...\n");
      foreach(string list in list1) {
         Console.WriteLine(list);
      }

      Console.Write("Finding an item in the list...\n");
      if (list1.Contains("Adams") == true) {
         Console.WriteLine("Item exists!");
      } else {
         Console.WriteLine("Item does not exist!");
      }
   }
}
Tryit Editor v3.7 - Show Java

public class CreateFile {  
  public static void main(String[] args) {  
    try {  
      File myObj = new File("filename.txt");  
      if (myObj.createNewFile()) {  
        System.out.println("File created: " + myObj.getName());  
      } else {  
        System.out.println("File already exists.");  
      }  
    } catch (IOException e) {
      System.out.println("An error occurred.");
Ajax Form Submit

Framework7 allows you to automatically send data using Ajax by using the following two ways −
When the user submits the form or submit event is triggered on form programmatically.
When the user submits the form or submit event is triggered on form programmatically.
When the user modifies any form field or change event triggered on form programmatically.
When the user modifies any form field or change event triggered on form programmatically.
To enable Ajax form and send the form data on clicking Submit, automatically, you need to add the ajax-submit class to form. After the user submits the form, Ajax will automatically send the form data using the following rules −
Form data will be sent to the file or the URL mentioned in action attribute of the form.
Form data will be sent to the file or the URL mentioned in action attribute of the form.
Request method will be similar as mentioned in the method attribute of the form.
Request method will be similar as mentioned in the method attribute of the form.
Content type will be the same as mentioned in the enctype attribute of the form. If not mentioned by default, it is application/x-www-form-urlencoded.
Content type will be the same as mentioned in the enctype attribute of the form. If not mentioned by default, it is application/x-www-form-urlencoded.
We can submit the form data when the user makes any changes in the form fields by using ajax-submit-onchange class as shown below −
<form action = "send.html" method = "GET" class = "ajax-submit-onchange">
   ...
</form>  

When the user modifies any form field, form data will be sent automatically using Ajax with same rules as discussed above.
To get actual XHR response from the file/URL where you sent data, you can use special events as shown below −
submitted
This event will be triggered after successful Ajax request.
Form Element
<form class = "ajax-submit">
This event will be triggered right before the Ajax request.
Form Element
<form class = "ajax-submit">
submitError
This event will be triggered on Ajax request error.
Form Element
<form class="ajax-submit">

    7 Lectures 
     1 hours 

 Anadi Sharma

    22 Lectures 
     6 hours 

 Malhar Lathkar

    102 Lectures 
     8 hours 

 Karthikeya T

    19 Lectures 
     5 hours 

 Trevoir Williams

    20 Lectures 
     1 hours 

 John Elder

    13 Lectures 
     3 hours 

 Darwish
 Print
 Add Notes
 Bookmark this page
MySQL Query to convert from datetime to date?

You can use CAST() function from MySQL to achieve this. The syntax is as follows −
SELECT CAST(yourColumnName as Date) as anyVariableName from yourTableName;
To understand the above syntax, let us first create a table. The query to create a table is as follows −
mysql> create table ConvertDateTimeToDate
-> (
-> ArrivalDatetime datetime
-> );
Query OK, 0 rows affected (0.37 sec)
Insert the datetime in the table using insert command. The query is as follows −
mysql> insert into ConvertDateTimeToDate values(date_add(now(),interval -1 year));
Query OK, 1 row affected (0.19 sec)

mysql> insert into ConvertDateTimeToDate values('2017-11-21 13:10:20');
Query OK, 1 row affected (0.14 sec)

mysql> insert into ConvertDateTimeToDate values('2016-05-24 21:11:24');
Query OK, 1 row affected (0.26 sec)

mysql> insert into ConvertDateTimeToDate values('2012-04-30 04:05:50');
Query OK, 1 row affected (0.13 sec)
Let us now display all records from the table using select command. The query is as follows.
mysql> select *from ConvertDateTimeToDate;
The following is the output.
+---------------------+
| ArrivalDatetime     |
+---------------------+
| 2017-12-27 10:05:21 |
| 2017-11-21 13:10:20 |
| 2016-05-24 21:11:24 |
| 2012-04-30 04:05:50 |
+---------------------+
4 rows in set (0.00 sec)
Here is the query to convert from datetime to date in MySQL.
mysql> select cast(ArrivalDatetime as Date) as Date from ConvertDateTimeToDate;
The following is the output.
+------------+
| Date       |
+------------+
| 2017-12-27 |
| 2017-11-21 |
| 2016-05-24 |
| 2012-04-30 |
+------------+
4 rows in set (0.00 sec)
How to change the TLS version in PowerShell?

Transport Layer Security known as TLS is a very important part while using URI commands such as Invoke−WebRequest or Invoke−Restmethod commands and package commands such as Find−Package or Install−Package because they interact on the internet and PowerShell needs TLS1.2 version for that.
We may get the below errors when we use the lower TLS version.
WARNING: Unable to download the list of available providers. Check your internet connection.
WARNING: Unable to resolve package source 'https://www.powershellgallery.com/api/v2'.
Find-Package : No match was found for the specified search criteria and package name
To resolve the above error, we need to change the TLS version. To check the existing TLS version, we can use the below command,
PS C:\> [Net.ServicePointManager]::SecurityProtocol
Ssl3, Tls
To change the TLS version to 1.2 below command can be used.
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
org.json - CDL

CDL class provides static methods to convert a comma delimited text into a JSONArray, and vice versa.
Following methods are covered in the example.
rowToJSONArray(String) − Converts a comma delimited text to JSONArray Object.
rowToJSONArray(String) − Converts a comma delimited text to JSONArray Object.
rowToString(JSONArray) − Converts a JSONArray to comma delimited text.
rowToString(JSONArray) − Converts a JSONArray to comma delimited text.
toJSONArray(String) − Converts a multi-line comma delimited text to Object of JSONArray objects.
toJSONArray(String) − Converts a multi-line comma delimited text to Object of JSONArray objects.
toJSONArray(JSONArray, String) − Converts a JSONArray Object and comma delimited text to JSONArray Object.
toJSONArray(JSONArray, String) − Converts a JSONArray Object and comma delimited text to JSONArray Object.
import org.json.CDL;
import org.json.JSONArray;
import org.json.JSONTokener;

public class JSONDemo {
   public static void main(String[] args) {
      String csvData = "INDIA, UK, USA";

      //Case 1: CSV to JSON Array 
      JSONArray jsonArray = CDL.rowToJSONArray(new JSONTokener(csvData));        
      System.out.println(jsonArray);

      //Case 2: JSONArray to CSV        
      System.out.println(CDL.rowToString(jsonArray));

      //Case 3: CSV to JSONArray of Objects
      csvData = "empId, name, age \n" +
         "1, Mark, 22 \n" +
         "2, Robert, 35 \n" +
         "3, Julia, 18";
      System.out.println(CDL.toJSONArray(csvData));

      //Case 4: CSV without header        
      jsonArray = new JSONArray();
      jsonArray.put("empId");
      jsonArray.put("name");
      jsonArray.put("age");
      csvData = "1, Mark, 22 \n" + "2, Robert, 35 \n" + "3, Julia, 18";
      System.out.println(CDL.toJSONArray(jsonArray,csvData));
   }
}
["INDIA","UK","USA"]
INDIA,UK,USA

[{"name":"Mark","empId":"1","age":"22"},
   {"name":"Robert","empId":"2","age":"35"},
   {"name":"Julia","empId":"3","age":"18"}]
[{"name":"Mark","empId":"1","age":"22"},
   {"name":"Robert","empId":"2","age":"35"},
   {"name":"Julia","empId":"3","age":"18"}]


    18 Lectures 
     1.5 hours 

 Dr. Saatya Prasad

    107 Lectures 
     13.5 hours 

 Arnab Chakraborty

    75 Lectures 
     5 hours 

 Revathi Ramachandran

    14 Lectures 
     44 mins

 Zach Miller

    12 Lectures 
     54 mins

 Prof. Paul Cline, Ed.D

    54 Lectures 
     4 hours 

 Gilad James, PhD
 Print
 Add Notes
 Bookmark this page
Bootstrap 4 .flex-*-column class

Use the .flex-*- column class in Bootstrap to show flex items vertically on different screen sizes:
Set it vertically on small, medium, large, etc screen size. Let us see it on small and medium screen size:
<p>Flex on different screen size (Small)</p>
<div class="d-flex flex-sm-column mb-3">
  <div class="p-2 bg-warning">One</div>
  <div class="p-2 bg-danger">Two</div>
  <div class="p-2 bg-secondary">Three</div>
</div>
<p>Flex on different screen size (Medium)</p>
<div class="d-flex flex-md-column mb-3">
  <div class="p-2 bg-warning">One</div>
  <div class="p-2 bg-danger">Two</div>
  <div class="p-2 bg-secondary">Three</div>
</div>
The following is an example implementing what I have shown above the usage of flex-*-column −
Live Demo
<!DOCTYPE html>
<html lang="en">
  <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/4.1.0/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/4.1.0/js/bootstrap.min.js"></script>
  </head>
<body>
  <div class="container mt-3">
    <h2>Example</h2>
    <p>Default </p>
    <div class="d-flex flex-column mb-3">
      <div class="p-2 bg-primary">One</div>
      <div class="p-2 bg-secondary">Two</div>
      <div class="p-2 bg-info">Three</div>
    </div>
    <p>Flex on different screen size (Small)</p>
    <div class="d-flex flex-sm-column mb-3">
      <div class="p-2 bg-warning">One</div>
      <div class="p-2 bg-danger">Two</div>
      <div class="p-2 bg-secondary">Three</div>
    </div>
    <p>Flex on different screen size (Medium)</p>
    <div class="d-flex flex-md-column mb-3">
      <div class="p-2 bg-warning">One</div>
      <div class="p-2 bg-danger">Two</div>
      <div class="p-2 bg-secondary">Three</div>
    </div>
    <p>Flex on different screen size (Large)</p>
    <div class="d-flex flex-lg-column mb-3">
      <div class="p-2 bg-primary">One</div>
      <div class="p-2 bg-secondary">Two</div>
      <div class="p-2 bg-danger">Three</div>
    </div>
  </div>
</body>
</html>
Chef - Testing Cookbooks

In case the cookbook is directly deployed and run on the production server, there are high chances that the cookbook can break up in production. The best way to prevent this from happening is, testing the cookbook in the setup environment.
Following are the steps for testing.
Step 1 − Install the cookbook using the following command.
vipin@laptop:~/chef-repo $ knife cookbook site install <cookbook name> 

Step 2 − Run the knife cookbook test commands on the working cookbook.
vipin@laptop:~/chef-repo $ knife cookbook test VTest  
checking ntp 
Running syntax check on ntp 
Validating ruby files 
Validating templates

Step 3 − Break something in the cookbook and test again.
vipin@laptop:~/chef-repo $ subl cookbooks/VTest/recipes/default.rb 
... 
[ node['ntp']['varlibdir'] 
node['ntp']['statsdir'] ].each do |ntpdir| 
   directory ntpdir do 
      owner node['ntp']['var_owner'] 
      group node['ntp']['var_group'] 
      mode 0755 
   end 
end
Step 4 − Run the knife test command again.
vipin@laptop:~/chef-repo $ knife cookbook test ntp 
checking ntp 
Running syntax check on ntp 
Validating ruby files 
FATAL: Cookbook file recipes/default.rb has a ruby syntax error: 
FATAL: cookbooks/ntp/recipes/default.rb:25: syntax error, 
unexpected tIDENTIFIER, expecting ']' 
FATAL: node['ntp']['statsdir'] ].each do |ntpdir| 
FATAL: ^ 
FATAL: cookbooks/ntp/recipes/default.rb:25: syntax error, 
unexpected ']', expecting $end 
FATAL: node['ntp']['statsdir'] ].each do |ntpdir| 
FATAL: 

Knife cookbook test executes a Ruby syntax check on all the Ruby files within the cookbook as well as all ERB templates. It loops through Ruby files and runs Ruby –c against each of them. Ruby –c checks the syntax of the script and quits without running it.
After going through all the Ruby files, knife cookbook test goes through all ERB templates and pipes, the redundant version created by –x through Ruby –c.
Knife cookbook test does only a simple syntax check on the Ruby files and ERB templates. We can go ahead fully test driven by using ChefSpec and test kitchen.
 Print
 Add Notes
 Bookmark this page
MongoDB - Indexing

Indexes support the efficient resolution of queries. Without indexes, MongoDB must scan every document of a collection to select those documents that match the query statement. This scan is highly inefficient and require MongoDB to process a large volume of data.
Indexes are special data structures, that store a small portion of the data set in an easy-to-traverse form. The index stores the value of a specific field or set of fields, ordered by the value of the field as specified in the index.
To create an index, you need to use createIndex() method of MongoDB.
The basic syntax of createIndex() method is as follows().
>db.COLLECTION_NAME.createIndex({KEY:1})
Here key is the name of the field on which you want to create index and 1 is for ascending order. To create index in descending order you need to use -1.
>db.mycol.createIndex({"title":1})
{
	"createdCollectionAutomatically" : false,
	"numIndexesBefore" : 1,
	"numIndexesAfter" : 2,
	"ok" : 1
}
>
In createIndex() method you can pass multiple fields, to create index on multiple fields.
>db.mycol.createIndex({"title":1,"description":-1})
>
This method also accepts list of options (which are optional). Following is the list −
You can drop a particular index using the dropIndex() method of MongoDB.
The basic syntax of DropIndex() method is as follows().
>db.COLLECTION_NAME.dropIndex({KEY:1})

Here, "key" is the name of the file on which you want to remove an existing index. Instead of the index specification document (above syntax), you can also specify the name of the index directly as:
dropIndex("name_of_the_index")

> db.mycol.dropIndex({"title":1})
{
	"ok" : 0,
	"errmsg" : "can't find index with key: { title: 1.0 }",
	"code" : 27,
	"codeName" : "IndexNotFound"
}
This method deletes multiple (specified) indexes on a collection.
The basic syntax of DropIndexes() method is as follows() −
>db.COLLECTION_NAME.dropIndexes()

Assume we have created 2 indexes in the named mycol collection as shown below −
> db.mycol.createIndex({"title":1,"description":-1})
Following example removes the above created indexes of mycol −
>db.mycol.dropIndexes({"title":1,"description":-1})
{ "nIndexesWas" : 2, "ok" : 1 }
>
This method returns the description of all the indexes int the collection.
Following is the basic syntax od the getIndexes() method −
db.COLLECTION_NAME.getIndexes()

Assume we have created 2 indexes in the named mycol collection as shown below −
> db.mycol.createIndex({"title":1,"description":-1})
Following example retrieves all the indexes in the collection mycol −
> db.mycol.getIndexes()
[
	{
		"v" : 2,
		"key" : {
			"_id" : 1
		},
		"name" : "_id_",
		"ns" : "test.mycol"
	},
	{
		"v" : 2,
		"key" : {
			"title" : 1,
			"description" : -1
		},
		"name" : "title_1_description_-1",
		"ns" : "test.mycol"
	}
]
>

    44 Lectures 
     3 hours 

 Arnab Chakraborty

    54 Lectures 
     5.5 hours 

 Eduonix Learning Solutions

    44 Lectures 
     4.5 hours 

 Kaushik Roy Chowdhury

    40 Lectures 
     2.5 hours 

 University Code

    26 Lectures 
     8 hours 

 Bassir Jafarzadeh

    70 Lectures 
     2.5 hours 

 Skillbakerystudios
 Print
 Add Notes
 Bookmark this page
AngularJS | ng-style Directive - GeeksforGeeks

28 Mar, 2019
The ng-style Directive in AngularJS is used to apply custom CSS styles on an HTML element. The expression inside the ng-style directive must be an object. It is supported by all the HTML elements.Syntax:
<element ng-style="expression"> Content ... </element> 

Example:
<!DOCTYPE html>    <head>        <title>ng-style Directive</title>        <script src=        "https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js">        </script><style type="text/css">    .bg-color {        background-color: pink;        padding:10px;        font-size: 18px;    }</style>    </head>    <body ng-app="app" style="text-align:center">      <h1 style="color:green">GeeksforGeeks</h1>      <h2>ng-style Directive</h2>        <div ng-controller="controllerName">        Input:        <input type="text" ng-model="color" placeholder="Enter any color." />        <p ng-repeat="i in sort" ng-style="{color:color}">         <span class="bg-color">  Name: {{i.name}}</span>        </p>    </div>    <script>    var app = angular.module("app", []);    app.controller('controllerName', ['$scope', function ($scope) {        $scope.sort = [       { name: 'Merge sort' },        { name: 'Quick sort' },        { name: 'Radix sort' }];    }]);</script></body></html>
Output:Before:After:
AngularJS-Directives
AngularJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Angular PrimeNG Dropdown Component
How to make a Bootstrap Modal Popup in Angular 9/8 ?
Angular 10 (blur) Event
How to create module with Routing in Angular 9 ?
How to setup 404 page in angular routing ?
Top 10 Front End Developer Skills That You Need in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Git - Review Changes

After viewing the commit details, Jerry realizes that the string length cannot be negative, that’s why he decides to change the return type of my_strlen function.
Jerry uses the git log command to view log details.
[jerry@CentOS project]$ git log

The above command will produce the following result.
commit cbe1249b140dad24b2c35b15cc7e26a6f02d2277
Author: Jerry Mouse <jerry@tutorialspoint.com>
Date: Wed Sep 11 08:05:26 2013 +0530

Implemented my_strlen function

Jerry uses the git show command to view the commit details. The git show command takes SHA-1 commit ID as a parameter.
[jerry@CentOS project]$ git show cbe1249b140dad24b2c35b15cc7e26a6f02d2277

The above command will produce the following result −
commit cbe1249b140dad24b2c35b15cc7e26a6f02d2277
Author: Jerry Mouse <jerry@tutorialspoint.com>
Date: Wed Sep 11 08:05:26 2013 +0530

Implemented my_strlen function


diff --git a/string.c b/string.c
new file mode 100644
index 0000000..187afb9
--- /dev/null
+++ b/string.c
@@ -0,0 +1,24 @@
+#include <stdio.h>
+
+int my_strlen(char *s)
+{
   +
   char *p = s;
   +
   +
   while (*p)
   + ++p;
   + return (p -s );
   +
}
+

He changes the return type of the function from int to size_t. After testing the code, he reviews his changes by running the git diff command.
[jerry@CentOS project]$ git diff

The above command will produce the following result −
diff --git a/string.c b/string.c
index 187afb9..7da2992 100644
--- a/string.c
+++ b/string.c
@@ -1,6 +1,6 @@
#include <stdio.h>

-int my_strlen(char *s)
+size_t my_strlen(char *s)
{
   char *p = s;
   @@ -18,7 +18,7 @@ int main(void)
};
for (i = 0; i < 2; ++i)
{
   - printf("string lenght of %s = %d\n", s[i], my_strlen(s[i]));
   + printf("string lenght of %s = %lu\n", s[i], my_strlen(s[i]));
   return 0;
}

Git diff shows '+' sign before lines, which are newly added and '−' for deleted lines.

    251 Lectures 
     35.5 hours 

 Gowthami Swarna

    23 Lectures 
     2 hours 

 Asif Hussain

    15 Lectures 
     1.5 hours 

 Abhilash Nelson

    125 Lectures 
     9 hours 

 John Shea

    13 Lectures 
     2.5 hours 

 Raghu Pandey

    13 Lectures 
     3 hours 

 Sebastian Sulinski
 Print
 Add Notes
 Bookmark this page
JSF - f:validateLongRange

f:validateLongRange tag is used to validate the long value in a particular range.
<f:validateLongRange minimum = "5" maximum = "200" />

minimum
Minimum long value within an optional range
maximum
Maximum long value within an optional range
Let us create a test JSF application to test the above tag.
package com.tutorialspoint.test;

import java.io.Serializable;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

@ManagedBean(name = "userData", eager = true)
@SessionScoped
public class UserData implements Serializable {
   private static final long serialVersionUID = 1L;
   private int age;
  
   public int getAge() {
      return age;
   }
   
   public void setAge(int age) {
      this.age = age;
   }  
}
<?xml version = "1.0" encoding = "UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns = "http://www.w3.org/1999/xhtml"   
   xmlns:h = "http://java.sun.com/jsf/html"
   xmlns:f = "http://java.sun.com/jsf/core">
   
   <h:head>
      <title>JSF tutorial</title>			
   </h:head>
   
   <h:body>   
      <h2>h:validateLongRange Example</h2>
      
      <h:form>
         <h:inputText id = "ageInput" value = "#{userData.age}" 
            label = "age" >
            <f:validateLongRange minimum = "5" maximum = "200" />
         </h:inputText>			
         <h:commandButton value = "submit" action = "result"/>
         <h:message for = "ageInput" style = "color:red" />
      </h:form>  
   
   </h:body>
</html>
<?xml version = "1.0" encoding = "UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns = "http://www.w3.org/1999/xhtml"
   xmlns:f = "http://java.sun.com/jsf/core"    
   xmlns:h = "http://java.sun.com/jsf/html">
   
   <h:head>
      <title>JSF Tutorial!</title>   
   </h:head>
   
   <h:body>
      <h2>Result</h2>
      Age:  #{userData.age}    
   </h:body>
</html>  
Once you are ready with all the changes done, let us compile and run the application as we did in JSF - First Application chapter. If everything is fine with your application, this will produce the following result.
Enter an invalid value. Following will be the output.
Enter a valid value. Following will be the output.

    37 Lectures 
     3.5 hours 

 Chaand Sheikh
 Print
 Add Notes
 Bookmark this page
Python Program to Determine all Pythagorean Triplets in the Range

When it is required to determine the Pythagorean triplets within a given range, a method is defined, that helps calculate the triplet values.
Below is the demonstration of the same −
 Live Demo
def pythagorean_triplets(limits) :
   c, m = 0, 2
   while c < limits :
   for n in range(1, m) :
      a = m * m - n * n
      b = 2 * m * n
      c = m * m + n * n
      if c > limits :
         break
      print(a, b, c)
   m = m + 1
upper_limit = 15
print("The upper limit is :")
print(upper_limit)
print("The Pythagorean triplets are :")
pythagorean_triplets(upper_limit)
The upper limit is :
15
The Pythagorean triplets are :
3 4 5
8 6 10
5 12 13
A method is defined that defines variables to define values for each of the Pythagorean triplet.
A method is defined that defines variables to define values for each of the Pythagorean triplet.
Outside the method, the integer is defined.
Outside the method, the integer is defined.
This method is called by passing the integer.
This method is called by passing the integer.
The output is displayed on the console.
The output is displayed on the console.
MySQL convert timediff output to day, hour, minute, second format?

To understand the MySQL convert timediff output to day, hour, minute, and second format, you need to use CONCAT() from MySQL.
Let us create a table. The query to create a table is as follows:
mysql> create table convertTimeDifferenceDemo
   -> (
   -> Id int NOT NULL AUTO_INCREMENT,
   -> StartDate datetime,
   -> EndDate datetime,
   -> PRIMARY KEY(Id)
   -> );
Query OK, 0 rows affected (0.68 sec)
Insert some records in the table using insert command. The query to insert record is as follows:
mysql> insert into convertTimeDifferenceDemo(StartDate,EndDate) values(date_add(now(),interval -3 hour),date_add(now(),interval 3 hour));
Query OK, 1 row affected (0.41 sec)
mysql> insert into convertTimeDifferenceDemo(StartDate,EndDate) values(date_add(now(),interval -2 hour),date_add(now(),interval 2 hour));
Query OK, 1 row affected (0.27 sec)
mysql> insert into convertTimeDifferenceDemo(StartDate,EndDate) values('2018-04-05 12:30:35','2018-05-17 14:30:50');
Query OK, 1 row affected (0.14 sec)
mysql> insert into convertTimeDifferenceDemo(StartDate,EndDate) values('2017-10-11 11:20:30','2017-12-17 15:21:55');
Query OK, 1 row affected (0.20 sec)
Display all records from the table using select statement. The query is as follows:
mysql> select *from convertTimeDifferenceDemo;
The following is the output:
+----+---------------------+---------------------+
| Id | StartDate           | EndDate             |
+----+---------------------+---------------------+
|  1 | 2019-01-28 20:55:33 | 2019-01-29 02:55:33 |
|  2 | 2019-01-28 21:57:42 | 2019-01-29 01:57:42 |
|  3 | 2018-04-05 12:30:35 | 2018-05-17 14:30:50 |
|  4 | 2017-10-11 11:20:30 | 2017-12-17 15:21:55 |
+----+---------------------+---------------------+
4 rows in set (0.00 sec)
Here is the query to get timediff output to day, hour, minute, and second format:
mysql> SELECT CONCAT(
   -> FLOOR(HOUR(TIMEDIFF(StartDate,EndDate)) / 24), ' DAYS ',
   -> MOD(HOUR(TIMEDIFF(StartDate,EndDate)), 24), ' HOURS ',
   -> MINUTE(TIMEDIFF(StartDate,EndDate)), ' MINUTES ') AS DESCRIPTION
   -> FROM convertTimeDifferenceDemo;
The following is the output:
+------------------------------+
| DESCRIPTION                  |
+------------------------------+
| 0 DAYS 6 HOURS 0 MINUTES     |
| 0 DAYS 4 HOURS 0 MINUTES     |
| 34 DAYS 22 HOURS 59 MINUTES  |
| 34 DAYS 22 HOURS 59 MINUTES  |
+------------------------------+
4 rows in set, 6 warnings (0.04 sec)
C# program to get the file name in C#

Set the path name in a string −
string myPath = "D:\\new\\quiz.txt";
Now, use the GetFileName() method to get the name of the file −
Path.GetFileName(myPath)
The following is the complete code −
 Live Demo
using System;
using System.IO;
namespace Demo {
   class Program {
      static void Main(string[] args) {
         string myPath = "D:\\new\\quiz.txt";
         // get extension
         Console.WriteLine("Extension: "+Path.GetExtension(myPath));
         // get path
         Console.WriteLine("File Path: "+Path.GetFileName(myPath));
      }
   }
}
Extension: .txt
File Path: D:\new\quiz.txt
Create a new database with MySQL Workbench?

To create a new database with MySQL Workbench, you need to launch MySQL workbench. The screenshot is as follows.
Now, let us test connection with MySQL. Follow the below steps −
Database->Connect to database (Ctrl +U).
The following is the screenshot that displays the “Connect to Database” dialog box. Add password to continue.
After that, you need to press the OK button twice to establish a connection.
Now, to create a database, you need to click the symbol shown in the following screenshot −
After clicking the symbol, you will get the following wizard to create a database −
In the above wizard, you need to give the database name. I have given the database name “Education”.
Now, you need to press the “Apply” button.
After pressing the apply button, we will get another wizard as shown above. This itself states that we have successfully created the database. You can check whether the database has been created or not under the “Schemas” tab as shown in the following screenshot −
Convert a C++ String to Upper Case

Here is the program to convert a string to uppercase in C++ language,
 Live Demo
#include<iostream>
#include<string.h>
using namespace std;

int main() {
   char s[30] = "This_is_string";
   int i;

   for(i=0;i<=strlen(s);i++) {
      if(s[i]>=97 && s[i]<=122) {
         s[i]=s[i]-32;
      }
   }
   cout<<"The String in Uppercase = "<<s;
   return 0;
}
Here is the output
The String in Uppercase = THIS_IS_STRING
In the program, the actual code of conversion of string to upper case is present in main() function. An array of char type s[30] is declared which stores the given string.
Then, for loop is used to convert the string into upper case string and if block is used to check that if characters are in lower case then, convert them in upper case by subtracting 32 from their ASCII value.
for(i=0;i<=strlen(s);i++) {
   if(s[i]>=97 && s[i]<=122) {
      s[i]=s[i]-32;
   }
}
C# Percent ("P") Format Specifier

The percent ("P") format specifier is used to multiply a number by 100.
It converts the number into a string representing a % (percentage).
We have the following double type −
double val = .975746;
If we will set (“P”) format specifier, then the above would result as −
97.57 %
In the same way, using (“P1”), would only include a single vale after decimal-point.
97.6%
 Live Demo
using System;
using System.Globalization;
class Demo {
   static void Main() {
      double val = .975746;
      Console.WriteLine(val.ToString("P", CultureInfo.InvariantCulture));
      Console.WriteLine(val.ToString("P1", CultureInfo.InvariantCulture));
      Console.WriteLine(val.ToString("P4", CultureInfo.InvariantCulture));
   }
}
97.57 %
97.6 %
97.5746 %