code-rag-bench/online-tutorials huggingface dataset:
Chef - Roles

Roles in Chef are a logical way of grouping nodes. Typical cases are to have roles for web servers, database servers, and so on. One can set custom run list for all the nodes and override attribute value within roles.
vipin@laptop:~/chef-repo $ subl roles/web_servers.rb 
name "web_servers" 
description "This role contains nodes, which act as web servers" 
run_list "recipe[ntp]" 
default_attributes 'ntp' => { 
   'ntpdate' => { 
      'disable' => true 
   } 
}
Once we have the role created, we need to upload to the Chef server.
vipin@laptop:~/chef-repo $ knife role from file web_servers.rb 

Now, we need to assign a role to a node called server.
vipin@laptop:~/chef-repo $ knife node edit server 
"run_list": [ 
   "role[web_servers]" 
] 
Saving updated run_list on node server 
user@server:~$ sudo chef-client 
...TRUNCATED OUTPUT... 
[2013-07-25T13:28:24+00:00] INFO: Run List is [role[web_servers]] 
[2013-07-25T13:28:24+00:00] INFO: Run List expands to [ntp] 
...TRUNCATED OUTPUT... 

Define a role in a Ruby file inside the roles folder of Chef repository.
Define a role in a Ruby file inside the roles folder of Chef repository.
A role consists of a name and a description attribute.
A role consists of a name and a description attribute.
A role consists of role-specific run list and role-specific attribute settings.
A role consists of role-specific run list and role-specific attribute settings.
Every node that has a role in its run list will have the role’s run list exacted into its own.
Every node that has a role in its run list will have the role’s run list exacted into its own.
All the recipes in the role’s run list will be executed on the node.
All the recipes in the role’s run list will be executed on the node.
The role will be uploaded to Chef server using the knife role from file command.
The role will be uploaded to Chef server using the knife role from file command.
The role will be added to the node run list.
The role will be added to the node run list.
Running Chef client on a node having the role in its run list will execute all the recipes listed in the role.
Running Chef client on a node having the role in its run list will execute all the recipes listed in the role.
 Print
 Add Notes
 Bookmark this page
Storing value from a MySQL SELECT statement to a variable?

Let us first create a table −
mysql> create table DemoTable631 (
   StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,StudentName varchar(100)
);
Query OK, 0 rows affected (0.83 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable631(StudentName) values('John Smith');
Query OK, 1 row affected (0.17 sec)
mysql> insert into DemoTable631(StudentName) values('Adam Smith');
Query OK, 1 row affected (0.16 sec)
mysql> insert into DemoTable631(StudentName) values('David Miller');
Query OK, 1 row affected (0.16 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable631;
This will produce the following output −
+-----------+--------------+
| StudentId | StudentName  |
+-----------+--------------+
|         1 | John Smith   |
|         2 | Adam Smith   |
|         3 | David Miller |
+-----------+--------------+
3 rows in set (0.00 sec)
Following is the query to store value from select to a variable −
mysql> set @fullName=(select StudentName from DemoTable631 where StudentId=2);
Query OK, 0 rows affected (0.00 sec)
Now you can display the value of a variable −
mysql> select @fullName;
This will produce the following output −
+------------+
| @fullName  |
+------------+
| Adam Smith |
+------------+
1 row in set (0.00 sec)
Python Overview and Installation

Python is an open source scripting language which is high-level, interpreted, interactive and object-oriented. It is designed to be highly readable. The syntax of Python language is easy to understand and uses English keywords frequently.
Python provides the following major features −
Python is processed at runtime using the interpreter. There is no need to compile a program before execution. It is similar to PERL and PHP.
Python follows object-oriented style and design patterns. It includes class definition with various features like encapsulation and polymorphism.
The key points of Python programming language are as follows −
It includes functional and structured programming and methods as well as object oriented programming methods.
It includes functional and structured programming and methods as well as object oriented programming methods.
It can be used as a scripting language or as a programming language.
It can be used as a scripting language or as a programming language.
It includes automatic garbage collection.
It includes automatic garbage collection.
It includes high-level dynamic data types and supports various dynamic type checking.
It includes high-level dynamic data types and supports various dynamic type checking.
Python includes a feature of integration with C, C++ and languages like Java.
Python includes a feature of integration with C, C++ and languages like Java.
The download link for Python language is as follows − www.python.org/downloadsIt includes packages for various operating systems like Windows, MacOS and Linux distributions.
The basic declaration of strings is shown below −
str = 'Hello World!'

The lists of python can be declared as compound data types, separated by commas and enclosed within square brackets ([]).
list = [ 'abcd', 786 , 2.23, 'john', 70.2 ]
tinylist = [123, 'john']

A tuple is dynamic data type of Python which consists of number of values separated by commas. Tuples are enclosed with parentheses.
tinytuple = (123, 'john')

Python dictionary is a type of hash table. A dictionary key can be almost any data type of Python, which are usually numbers or strings.
tinydict = {'name': 'omkar','code':6734, 'dept': 'sales'}

Python includes a package called cryptography which provides cryptographic recipes and primitives. It supports Python 2.7, Python 3.4+, and PyPy 5.3+. The basic installation of cryptography package is achieved through following command −
pip install cryptography

There are various packages with both high level recipes and low level interfaces to common cryptographic algorithms such as symmetric ciphers, message digests and key derivation functions.
Throughout this tutorial, we will be using various packages of Python for implementation of cryptographic algorithms.

    10 Lectures 
     2 hours 

 Total Seminars

    10 Lectures 
     2 hours 

 Stone River ELearning
 Print
 Add Notes
 Bookmark this page
Code a Deep Neural Network. Hands on Practice of Building a Deep... | by Jeremy Zhang | Towards Data Science

In last post, we’ve built a 1-hidden layer neural network with basic functions in python. To generalize and empower our network, in this post, we will build a n-layer neural network to do a binary classification task, in which n is customisable (it is recommended to go over my last introduction of neural network as the basics of theory would not be repeated here).
All images created on my own, referred images are source-added.
Firstly, weights need to be initialized for different layers. Note that in general, the input is not considered as a layer, but output is.
(For detailed training and testing process, please check here)
We’ve learnt that for lth layer:
where n^[0] equals the number input feature.
Consider a neural network below:
In this case, the first W^[1] would have shape (4, 2) , and the second W^[2] would have shape (1, 4) .
Where input requires to be a list, for the case above the input layer would be
[2, 4, 1]
And our initialized weights need to be small enough so that the gradient would large in the backpropagation process and learning would be faster.
The forward process would be straight-forward as listed below:
Where l is the lth layer and g(x) is the activation function. Here we would use 2 different activation function:
All the function above applies to matrix.
The forward propagation would be following the equations above. Note that in our implementation, except the last layer we use sigmoid activation, the rest we use relu activation function.
Still we consider this a binary classification, the cost of a batch would be:
Where a is the predicted value, and y is the actual one.
Now that our forward process has finished, in order to let our model to improve through iterations, let’s get to the key which is backward propagation.
[source: https://github.com/enggen/Deep-Learning-Coursera ]
The backward gradient can be calculated in recurrent fashion:
First, implementation of derivative of sigmoid and relu is required.
For symmetrical reasons, here we have both functions with the same input even though it is not required.
Following the equations above, we have our implementation of backward propagation. Note that except the last layer where sigmoid function is used, the rest we all apply relu derivative to get the gradients.
Now given the gradients, we have our weights updated as following:
Let’s have our model apply on created dataset with 200 features.
Now let’s have our model trained.
Here we have a 3-layer NN with 200 input features.
To have the detailed training process, please check my github.
W3Schools Code Game

W3Schools is optimized for learning, testing, and training.
    Examples might be simplified to improve reading and basic understanding.
    Tutorials, references, and examples are constantly reviewed to avoid errors,
    but we cannot warrant full correctness of all content.
    While using this site, you agree to have read and accepted our
    terms of use,
    cookie and privacy policy.
Copyright 1999-2022 by Refsnes Data.
    All Rights Reserved.
Gulp - Installation

This article provides a step-by-step procedure of Gulp installation.
Operating System − Cross-platform
Operating System − Cross-platform
Browser Support − IE (Internet Explorer 8+), Firefox, Google Chrome, Safari, Opera
Browser Support − IE (Internet Explorer 8+), Firefox, Google Chrome, Safari, Opera
Step 1 − We need Node.js to run Gulp examples. To download Node.js, open the https://nodejs.org/en/, you will see a screen as shown below −
Download the latest features version of the zip file.
Step 2 − Next, run the setup to install the NodeJs on your computer.
Step 3 − You need to set environment variables.
Right-click on My Computer.
Select Properties.
Select Advanced tab and click ‘Environment Variables’.
Under Environment Variables window, double-click on the PATH as shown in the following screen.
Under Environment Variables window, double-click on the PATH as shown in the following screen.
You will get an Edit User Variable window as shown in the following screenshot. Add Node.js folder path in the Variable Value field as C:\Program Files\nodejs\node_modules\npm. If the path is set already for other files, then you need to put a semicolon (;) after that and add the Node.js path as shown in the following screenshot.
You will get an Edit User Variable window as shown in the following screenshot. Add Node.js folder path in the Variable Value field as C:\Program Files\nodejs\node_modules\npm. If the path is set already for other files, then you need to put a semicolon (;) after that and add the Node.js path as shown in the following screenshot.
At the end, click the ‘Ok’ button.
System Variable
Under System variables, double-click on Path as shown in the following screen.
Under System variables, double-click on Path as shown in the following screen.
You will get an Edit System Variable window as shown in the following screenshot. Add Node.js folder path in the Variable Value field as C:\Program Files\nodejs\ and click ‘Ok’ as shown in the following screenshot.
You will get an Edit System Variable window as shown in the following screenshot. Add Node.js folder path in the Variable Value field as C:\Program Files\nodejs\ and click ‘Ok’ as shown in the following screenshot.
Step 4 − Open the command prompt in your system and enter the following command. It will display the installed Node.js version.
node -v

Step 5 − In the command prompt, enter the following command to display the version of npm (Node.js package manager) which is used to install modules. It will display the installed Node.js version.
npm -v

Step 6 − In the command prompt, enter the following command to install Gulp. Adding “-g” flag ensures that the Gulp is globally available for any project.
npm install gulp -g

Step 7 − To verify that Gulp has been installed successfully, enter the following command to display the Gulp version.
gulp -v

 Print
 Add Notes
 Bookmark this page
What is STORED PROCEDURE in a DB2? How will you create a new stored procedure?

The DB2 STORED PROCEDURE are the programs which are directly managed by DBMS. The STORED PROCEDURE generally contains SQLs and they can be called by application programs. The STORED PROCEDURE processes the query and returns the result to the application program. The STORED PROCEDURES can be used for the SQLs which are very often used, so instead of using the same SQL query again and again, we can simply use STORED PROCEDURE.
The other benefit of STORED PROCEDURE is that they are fast and have good performance as compared to static SQLs used in application programs. The STORED PROCEDURE can be written in many languages like COBOL, JAVA, C++, etc. Once we have written a STORED PROCEDURE in any of the languages, we have to register this STORED PROCEDURE in DB2 using below command.
CREATE PROCEDURE ORDERSTAT (IN ORDER_ID CHAR(8),
   OUT ORDER_STATUS CHAR(3))
A STORED PROCEDURE with the name ORDERSTAT will be created using the above command which will take the input as ORDER_ID and gives ORDER_STATUS in output.
Python | Sort dictionary by value list length - GeeksforGeeks

11 May, 2020
While working with Python, one might come to a problem in which one needs to perform a sort on dictionary list value length. This can be typically in case of scoring or any type of count algorithm. Let’s discuss a method by which this task can be performed.
Method : Using sorted() + join() + lambdaThe combination of above functions can be used to perform this particular task. In this, we just use the lambda function to perform this particular task, sorted and join function perform the required sorting and encapsulation of result respectively.
# Python3 code to demonstrate working of# Sort dictionary by value list length# using sorted() + join() + lambda  # Initialize dictionarytest_dict = {'is' : [1, 2], 'gfg' : [3], 'best' : [1, 3, 4]}  # Printing original dictionaryprint("The original dictionary is : " + str(test_dict))  # using sorted() + join() + lambda# Sort dictionary by value list lengthres = ' '.join(sorted(test_dict, key = lambda key: len(test_dict[key])))  # printing result print("Sorted keys by value list : " + res)
The original dictionary is : {'is': [1, 2], 'best': [1, 3, 4], 'gfg': [3]}
Sorted keys by value list : gfg is best

Python dictionary-programs
Python-sort
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Python program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
Why Transition properties does not work with display properties ?

21 Dec, 2020
When we want to use transition for display:none to display:block, transition properties do not work. The reason for this is, display:none property is used for removing block and display:block property is used for displaying block. A block cannot be partly displayed. Either it is available or unavailable. That is why the transition property does not work.
So for animation, we use keyframes CSS.
@keyframes animationname {keyframes-selector {css-styles;}}

What does keyframes do?The @keyframes rule specifies the code for animation. When one set of CSS style is changed to another set of CSS style, the animation is created and specify whenever the style changes. It can be in percent or with the keywords “from” and “to”, which will be equivalent to 0% and 100%. Here 0% is the beginning of the animation and 100% is the end of the animation.
Which Browser supports keyframes and what is prefix for that browser?
Chrome  & safari=> -webkit-
Mozilla => -moz-
Opera => -o-
Code snippet:
HTML
<!DOCTYPE html><html>  <head>    <style>        html,        body {            height: 100%;            padding: 0;            font: 20px/40px sans-serif;        }          h1 {            padding: 20px;        }          div {            width: 100%;            background: pink;            padding: 20px;            display: none;        }          body:hover div {            display: block;            -webkit-animation: slide-down 2.3s ease-out;            -moz-animation: slide-down 3.3s ease-out;        }          @-webkit-keyframes slide-down {            0% {                opacity: 0;            }              100% {                opacity: 1;            }        }          @-moz-keyframes slide-down {            0% {                opacity: 0;            }              100% {                opacity: 1;            }        }    </style></head>  <body>    <h1>Hover me</h1>    <div>Hello</div></body>  </html>
arorakashish0911
CSS-Misc
HTML-Misc
CSS
HTML
Web Technologies
Web technologies Questions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Generating random Id’s in Python

28 Sep, 2021
In python there are different ways to generate id’s. Let’s see how different types of Id’s can be generated using python without using inbuilt Python libraries. 
Code #1 : Print 10 random values of numbers between 1 and 100.  
Python3
# Python3 code to demonstrate the# random generation of Integer id's import random # determines how many values# will be printedfor x in range(10):         # print 10 random values    # between 1 and 100    print (random.randint(1, 101))
Output : 
76
72
7
78
77
19
24
23
77
96
Code #2 : Print random numbers between 1 and 100 which are multiple of 5.
Python3
# Python3 code to demonstrate# the random generation of id's# which are multiple of 5 import random # determines how many# values will be printedfor x in range(10):             # print 10 random values between    # 1 and 100 which are multiple of 5    print (random.randint(1, 20) * 5)
Output : 
60
30
35
100
85
25
100
20
90
85
Drawbacks : 
Generating Random numbers is not unique, Same number can repeat itself.
It generates only Integer values.
Generating Random string id’s consists of letters and digits. This can be useful in generating passwords as its provide the encryption and decryption technique.
Code #1 : Show how to generate random string id’s.  
Python3
# Python3 code to demonstrate the# random generation of string id's import randomimport string # Generate a random string# with 32 characters.random = ''.join([random.choice(string.ascii_letters            + string.digits) for n in range(32)]) # print the random# string of length 32print (random)
Output : 
Rf2IdqUNkURNN6mw82kSpyxQe9ib3usX
Code #2 : Using Function call
Python3
# Python3 code to demonstrate# the random generation of string id's import randomimport string # defining function for random# string id with parameterdef ran_gen(size, chars=string.ascii_uppercase + string.digits):    return ''.join(random.choice(chars) for x in range(size)) # function call for random string# generation with size 8 and stringprint (ran_gen(8, "AEIOSUMA23"))
Output : 
S2M2IEAO
Generating Random id’s using UUID in Python 
varshagumber28
python-string
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Python OOPs Concepts
Python | All possible N combination tuples

11 Jan, 2022
Sometimes, while working with Python tuples, we might have a problem in which we need to generate all possible combination pairs till N. This can have application in mathematics domain. Let’s discuss certain ways in which this problem can be solved.
Method #1 : Using list comprehension + product()This task can be performed using list comprehension which can be used to iterate the container of N numbers and product() performs the task of formation of combinations from them.
Python3
# Python3 code to demonstrate working of# All possible N combination tuples# Using list comprehension + product()from itertools import product  # initialize N N = 3  # All possible N combination tuples# Using list comprehension + product()res = [ele for ele in product(range(1, N + 1), repeat = N)]  # printing resultprint("Tuple Combinations till N are : " + str(res))
Tuple Combinations till N are : [(1, 1, 1), (1, 1, 2), (1, 1, 3), (1, 2, 1), (1, 2, 2), (1, 2, 3), (1, 3, 1), (1, 3, 2), (1, 3, 3), (2, 1, 1), (2, 1, 2), (2, 1, 3), (2, 2, 1), (2, 2, 2), (2, 2, 3), (2, 3, 1), (2, 3, 2), (2, 3, 3), (3, 1, 1), (3, 1, 2), (3, 1, 3), (3, 2, 1), (3, 2, 2), (3, 2, 3), (3, 3, 1), (3, 3, 2), (3, 3, 3)]
 
Method #2 : Using product()This task can also be performed by using just the single function. The use of list comprehension can be eliminated using the conversion to list.
Python3
# Python3 code to demonstrate working of# All possible N combination tuples# Using product()from itertools import product  # initialize N N = 3  # All possible N combination tuples# Using product()res = list(product(range(1, N + 1), repeat = N))  # printing resultprint("Tuple Combinations till N are : " + str(res))
Tuple Combinations till N are : [(1, 1, 1), (1, 1, 2), (1, 1, 3), (1, 2, 1), (1, 2, 2), (1, 2, 3), (1, 3, 1), (1, 3, 2), (1, 3, 3), (2, 1, 1), (2, 1, 2), (2, 1, 3), (2, 2, 1), (2, 2, 2), (2, 2, 3), (2, 3, 1), (2, 3, 2), (2, 3, 3), (3, 1, 1), (3, 1, 2), (3, 1, 3), (3, 2, 1), (3, 2, 2), (3, 2, 3), (3, 3, 1), (3, 3, 2), (3, 3, 3)]
rajeev0719singh
Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
jQuery | [attribute] Selector

12 Mar, 2019
The [attribute] Selector is an inbuilt selector in jQuery, used to select all the elements with the specified attribute.
Syntax:
$("[attribute_name]")

Parameter:
attribute_name: It is the required parameter which specify the attribute to be select.
Example-1:
<!DOCTYPE html><html>  <head>    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">    </script>        <script>        $(document).ready(function() {            $("[class]").css("color",                             "green");        });    </script></head>  <body>    <center>          <!-- Class attribute-->          <h3 class>GeeksforGeeks</h3>        <p>A computer science portal for geeks</p>          <!--id attribute-->          <p id>Geek1</p>          <!--class attribute-->          <p class>Geek2</p>        <p>Geek3</p>          <!--class attribute-->          <div class> Thank You! </div>      </center></body>  </html>
Output:
In the above example, all the elements with the specified attribute (class) are formatted into green color i.e, “GeeksforGeeks”, “Geek2” and “Thank You!”.
Example-2:
<!DOCTYPE html><html>  <head>    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">    </script>        <script>        $(document).ready(function() {            $("[class]").css("color",                             "green");        });    </script></head>  <body>    <center>          <!-- Class(demo) attribute-->          <h3 class="demo">GeeksforGeeks</h3>        <p>A computer science portal for geeks</p>          <!--id attribute-->          <p id>Geek1</p>        <p>Geek2</p>          <!--class(test) attribute-->          <p class="test">Geek3</p>          <!--class(sample) attribute-->          <div class="sample"> Thank You! </div>      </center></body>  </html>
Output:
In the above example, all the elements with the specified attribute (class) are formatted into green color rather considering the value of the attribute. “GeeksforGeeks”, “Geek3” and “Thank You!” are formatted.
jQuery-Selectors
Picked
JQuery
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Form validation using jQuery
How to Dynamically Add/Remove Table Rows using jQuery ?
Scroll to the top of the page using JavaScript/jQuery
How to get the value in an input text box using jQuery ?
jQuery | children() with Examples
How to insert spaces/tabs in text using HTML/CSS?
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Node.js fs.readFileSync() Method
How to set the default value for an HTML <select> element ?
Extract numbers from a text file and add them using Python - GeeksforGeeks

19 May, 2021
Python too supports file handling and allows users to handle files i.e., to read and write files, along with many other file handling options, to operate on files. Data file handling in Python is done in two types of files:  
Text file (.txt extension)  
Binary file (.bin extension)  
Here we are operating on the .txt file in Python. Through this program, we can extract numbers from the content in the text file and add them all and print the result. 
Reading the contents of the file, we will match the characters’ type against int. If the result of equality is true, then the number will be added to the number stored in the memory allocated to the variable ‘a’. We initiate the variable ‘a’ here with the value 0. 
Python3
# Python program for writing# to file  file = open('GFG.txt', 'w') # Data to be writtendata ='Geeks1 f2or G8e8e3k2s0' # Writing to filefile.write(data) # Closing filefile.close()
Using the above code, we opened a new file named ‘GFG’ in write mode. Using, the write() function we inserted the data allocated to the variable data in the memory. After this, we closed the file.Reading from the above-created file and extracting the integers. 
Python3
# Python program for reading# from file  h = open('GFG.txt', 'r') # Reading from the filecontent = h.readlines() # Variable for storing the suma = 0 # Iterating through the content# Of the filefor line in content:         for i in line:                 # Checking for the digit in        # the string        if i.isdigit() == True:                         a += int(i) print("The sum is:", a)
Output: 
The sum is: 24
The above program emphasizes on extracting the numbers from the content stored in the text file named ‘GFG’. Furthermore, the numbers are then added after typecasting and stored in the variable ‘a’. 
arorakashish0911
Python file-handling-programs
python-file-handling
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Box Plot in Python using Matplotlib
Python | Get dictionary keys as a list
Bar Plot in Matplotlib
Multithreading in Python | Set 2 (Synchronization)
Python Dictionary keys() method
loops in python
Python - Call function from another file
Ways to filter Pandas DataFrame by column values
Python | Convert set into a list
Python program to find number of days between two given dates
How to handle date in JDBC?

You can insert date values in SQL using the date datatype, The java.sql.Date class maps to the SQL DATE type.
The PreparedStatement interface provides a method named setDate(). Using this you can insert date into a table. This method accepts two parameters −
An integer representing the parameter index of the place holder (?) to which we need to set date value.
An integer representing the parameter index of the place holder (?) to which we need to set date value.
a Date object representing the date value to be passed. The constructor of java.sql.Date class accepts a variable of long type representing the number of milliseconds from the epoch (standard base time I.e. January 1, 1970, 00:00:00 GMT).
a Date object representing the date value to be passed. The constructor of java.sql.Date class accepts a variable of long type representing the number of milliseconds from the epoch (standard base time I.e. January 1, 1970, 00:00:00 GMT).
Assume we have created a table named Emp in MySQL database with the following description −
+----------+--------------+------+-----+---------+-------+
| Field    | Type         | Null | Key | Default | Extra |
+----------+--------------+------+-----+---------+-------+
| Name     | varchar(255) | YES  |     | NULL    |       |
| DOB      | date         | YES  |     | NULL    |       |
| Location | varchar(255) | YES  |     | NULL    |       |
+----------+--------------+------+-----+---------+-------+
Following JDBC program inserts records in to this table −
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.Date;
public class InsertingDate {
   public static void main(String args[])throws Exception {
      //Getting the connection
      String mysqlUrl = "jdbc:mysql://localhost/sampleDB";
      Connection con = DriverManager.getConnection(mysqlUrl, "root", "password");
      System.out.println("Connection established......");
      //Inserting values to a table
      String query = "INSERT INTO Emp(Name, DOB, Location) VALUES (?, ?, ?)";
      PreparedStatement pstmt = con.prepareStatement(query);
      pstmt.setString(1, "Amit"); pstmt.setDate(2, new Date(622790105000L));
      pstmt.setString(3, "Hyderabad");
      pstmt.execute();
      pstmt.setString(1, "Sumith"); pstmt.setDate(2, new Date(620611200000L));
      pstmt.setString(3, "Vishakhapatnam");
      pstmt.execute();
      pstmt.setString(1, "Sudha");
      pstmt.setDate(2, new Date(336614400000L));
      pstmt.setString(3, "Vijayawada");
      pstmt.execute();
      System.out.println("Records inserted......");
   }
}
Connection established......
Records inserted......
If you verify the table in MySQL database, you can observe the contents of the table as −
mysql> select * from Emp;
+--------+------------+----------------+
| Name   | DOB        | Location       |
+--------+------------+----------------+
| Amit   | 1989-09-26 | Hyderabad      |
| Sumith | 2019-03-19 | Vishakhapatnam |
| Sudha  | 2019-03-19 | Vijayawada     |
+--------+------------+----------------+
3 rows in set (0.00 sec)
How to Find the Length of a String in Dart? - GeeksforGeeks

15 Jul, 2020
To find a length of a string in the dart, we make use of length property of a string class in Dart. This method returns the length of string which in integer.
Syntax: string_name.length
Return Type: integer
Example: Finding the length of the string in Dart.
Dart
// Main functionmain() {      // Declaring a string variable  String gfg = "Welcome to GeeksForGeeks";      // Finding the length  int length = gfg.length;      // Printing the length of the string  print(length);}
Output:
24

Explanation: The length of the string including spaces in the above example count up to 24.
Note: The length of the empty string is equal to 0. 
Dart-String
Dart
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Flutter - Custom Bottom Navigation Bar
Flutter - Flexible Widget
ListView Class in Flutter
Flutter - Stack Widget
Android Studio Setup for Flutter Development
Format Dates in Flutter
Flutter - Positioned Widget
Simple Calculator App using Flutter
Flutter - Dialogs
Dart - Static Keyword
Elixir - Bitwise Operators

Bitwise operators work on bits and perform bit by bit operation. Elixir provides bitwise modules as part of the package Bitwise, so in order to use these, you need to use the bitwise module. To use it, enter the following comand in your shell −
use Bitwise

 Assume A to be 5 and B to be 6 for the following examples −
Try the following code to understand all arithmetic operators in Elixir.
a = 5
b = 6

use Bitwise

IO.puts("a &&& b " <> to_string(a &&& b))

IO.puts("a ||| b " <> to_string(a ||| b))

IO.puts("a >>> b " <> to_string(a >>> b))

IO.puts("a <<< b" <> to_string(a <<< b))

IO.puts("a ^^^ b " <> to_string(a ^^^ b))

IO.puts("~~~a " <> to_string(~~~a))
The above program generates the following result −
a &&& b 4
a ||| b 7
a >>> b 0
a <<< b 320
a ^^^ b 3
~~~a -6


    35 Lectures 
     3 hours 

 Pranjal Srivastava

    54 Lectures 
     6 hours 

 Pranjal Srivastava, Harshit Srivastava

    80 Lectures 
     9.5 hours 

 Pranjal Srivastava

    43 Lectures 
     4 hours 

 Mohammad Nauman
 Print
 Add Notes
 Bookmark this page
HTML | <source> media Attribute - GeeksforGeeks

13 Dec, 2021
The HTML source media attribute accepts any valid media query that would normally be defined in a CSS. This attribute can accept several values.
Syntax:
<source media="media_query">
Possible Operators:
Devices:
Values:
Note: Prefixes like “min-“ and “max-“ can be used.
Example:
<!DOCTYPE html><html>  <head>    <meta name="viewport"          content="width=device-width, initial-scale=1.0"></head>  <body>      <picture>        <source media="(min-width: 600px)"                srcset="img1.png">        <source media="(min-width: 400px)"                 srcset="img2.png">        <img src="img3.png" style="width:auto;">    </picture>  </body>  </html>
Output: Change the browser size.
Supported Browsers: The browsers supported by HTML source media attribute are listed below:
Google Chrome
Edge 12.0
Internet Explorer 9.0
Firefox 15.0
Apple Safari
Opera
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
ManasChhabra2
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to update Node.js and NPM to next version ?
REST API (Introduction)
How to Insert Form Data into Database using PHP ?
CSS to put icon inside an input element in a form
HTML Cheat Sheet - A Basic Guide to HTML
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
XAML - Dialog Box

All standalone applications have a main window that exposes some functionality and displays some data over which the application operates through its GUI. An application may also display additional windows to do the following −
To display some specific information to users.
To gather useful information from users.
To both display and gather important information.
Let’s have a look at the following example. On the main window, there is a button and a textbox. When the user clicks this button, it opens another dialog box with Yes, No, and Cancel buttons and displays a message on it that prompts the user to click a button.
When the user clicks a button, then the current dialog box gets closed and shows a textbox with the information "which button has been clicked".
Here is the XAML code to create and initialize a button and a textbox with some properties −
<Window x:Class = "XAMLDialog.MainWindow" 
   xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:x = "http://schemas.microsoft.com/winfx/2006/xaml"
   Title = "MainWindow" Height = "350" Width = "604"> 
	
   <Grid> 
      <Button Height = "23" 
         Margin = "100" 
         Name = "ShowMessageBox" 
         VerticalAlignment = "Top" 
         Click = "ShowMessageBox_Click">Show Message Box</Button>
			
      <TextBox Height = "23" 
         HorizontalAlignment = "Left" 
         Margin = "181,167,0,0" 
         Name = "textBox1" 
         VerticalAlignment = "Top" 
         Width = "120" /> 
   </Grid> 
</Window>
Given below is the C# code to implement a button click event.
using System; 
using System.Windows; 
using System.Windows.Controls;

namespace XAMLDialog {
   /// <summary> 
      /// Interaction logic for MainWindow.xaml 
   /// </summary> 
	
   public partial class MainWindow : Window {
      public MainWindow() { 
         InitializeComponent(); 
      } 
      private void ShowMessageBox_Click(object sender, RoutedEventArgs e) { 
         string msgtext = "Click any button"; 
         string txt = "My Title"; 
         MessageBoxButton button = MessageBoxButton.YesNoCancel;
         MessageBoxResult result = MessageBox.Show(msgtext, txt, button);

         switch (result) { 
            case MessageBoxResult.Yes: 
               textBox1.Text = "Yes"; 
               break;
            case MessageBoxResult.No: 
               textBox1.Text = "No"; 
               break; 
            case MessageBoxResult.Cancel: 
               textBox1.Text = "Cancel"; 
               break; 
         }
      }
   }
}
When you compile and execute the above code, it will produce the following output −
When you click on the button, it displays another dialog box as shown below that prompts the user to click a button. Now, click the Yes button.
It updates the textbox with the button content.
 Print
 Add Notes
 Bookmark this page
How do I get SUM function in MySQL to return '0' if no values are found?

To return Sum as ‘0’ if no values are found, use IFNULL or COALESCE commands.
The following is the syntax for IFNULL.
SELECT IFNULL(SUM(NULL), 0) AS aliasName;

Let us now implement the above syntax in the following query.
mysql> SELECT IFNULL(SUM(NULL), 0) AS SUMOFTWO;
The following is the output of the above query, which returns 0.
+----------+
| SUMOFTWO |
+----------+
|        0 |
+----------+
1 row in set (0.00 sec)

Here is the syntax for COALESCE.
mysql> SELECT COALESCE(SUM(NULL),0) as SUMOFTWO;
The following is the output that returns 0 using the SUM() function.
+----------+
| SUMOFTWO |
+----------+
|        0 |
+----------+
1 row in set (0.00 sec)
System() Function in C/C++

Given the task is to show the working of system() in C/C++.
The system() function is a part of the C/C++ standard library. It is used to pass the commands that can be executed in the command processor or the terminal of the operating system, and finally returns the command after it has been completed.
<stdlib.h> or <cstdlib> should be included to call this function.
The syntax is as follows −
int system(char command)
This function returns zero if the command is executed without any errors.
Input: system(“date”)
Output: The current date is: Fri 12/27/2019
Explanation − The following example shows how we can use the system function to display the current date. The output is shown inside the command processor of the operating system. This shows how we can use the system() function to execute terminal commands or the command that are used inside the command processor.
Input: system(“color a”)
Output:
The following example shows how we can use the system() function by simply passing a string into it that contains the command to be executed. Here we have given the “color a” command that is used to change the color of the text in the command processor and here it works properly.
Approach used in the below program as follows −
First create a variable of type char and give it some suitable size, let’s say cmd[10], so that this string can be used for storing commands.
Then use the strcpy() function to store the desired command into the string that we created before. (Do include the <string.h> header file in order to use the strcpy() function)
Now pass the string that is storing the command, into the system function.
Start
Step 1-> In function main()
   Declare a char cmd[10]
   Call function strcpy(cmd, “dir”)
   Call function system(cmd)
Stop
#include <iostream>
#include<stdlib.h>
#include<string.h>
using namespace std;
int main() {
   char cmd[10];
   strcpy(cmd,"dir");
   system(cmd);
   return0;
}
If we run the above code it will generate the following output −
12/25/2019 10:04 AM <DIR> .
12/25/2019 06:33 AM <DIR> ..
12/24/2019 09:56 AM <DIR> bin
12/25/2019 10:04 AM 183 main.cpp
12/25/2019 10:04 AM 1,564,278 main.exe
12/25/2019 06:33 AM 1,046 main.o
12/24/2019 06:33 AM <DIR> obj
12/24/2019 06:33 AM 1,062 Test.cbp
12/24/2019 06:36 AM 358 Test.layout
5 File
 1,566,927 bytes
4 Dir
 169,866,692,120 bytes free
Here we have given the system function “dir” command as the input, so in return it will show us all the directories present in the computer as the output.
The following method can be used to check if command processor is available in the operating system or not −
This can be done by passing a Null pointer into the system() function. If the system returns a non-zero value, then it means that command processor is available.
Else if the system returns zero, then it means that command processor does not exist and the system() function cannot be called.
#include <iostream>
#include<stdlib.h>
using namespace std;
int main() {
   if(system(Null))
      cout<<”Command Processor is present”;
   else
      cout<<”Command processor is not present”;
   return 0;
}
Apache Presto - concat(string1, ..., stringN)

presto:default> select concat('tut','orials','point') as string_concat; 
 string_concat 
---------------- 
 tutorialspoint 

The above output is concatenation of the given strings.

    46 Lectures 
     3.5 hours 

 Arnab Chakraborty

    23 Lectures 
     1.5 hours 

 Mukund Kumar Mishra

    16 Lectures 
     1 hours 

 Nilay Mehta

    52 Lectures 
     1.5 hours 

 Bigdata Engineer

    14 Lectures 
     1 hours 

 Bigdata Engineer

    23 Lectures 
     1 hours 

 Bigdata Engineer
 Print
 Add Notes
 Bookmark this page
Setup and use Jupyter (IPython) Notebooks on AWS | by Michael Galarnyk | Towards Data Science

A while ago, I wrote a post, “Start a Jupyter (IPython) Notebook Server on AWS”. While that approach allows for multiple people to access the server with just a password, it suffers from being complicated to setup. Most people just want to use a Jupyter Notebook using their AWS resources without the hassle. With that, here is how you do it.
Starting a Jupyter Notebook on AWS
SSH to your EC2 instance. If you don’t know how to do this or would like a reference, please see this tutorial.
SSH to your EC2 instance. If you don’t know how to do this or would like a reference, please see this tutorial.
2. Make sure you have installed Anaconda. If you don’t have it installed, you do it using this tutorial.
3. Type the following command in your terminal:
jupyter notebook --no-browser --port=8888
The reason why we add “ — no-browser” is because if we don’t, you might get an error like “Jupyter Notebook requires JavaScript”. Having said that, if you get that error, you can ignore the error by pressing Q and then press Y to confirm.
SSH to your Jupyter Notebook
4. Open a new terminal and SSH to your Jupyter Notebook. Your command should be similar to the one below. If you don’t know how to do this, please see tutorial.
ssh -i thisIsmyKey.pem -L 8000:localhost:8888 ubuntu@ec2–34–227–222–100.compute-1.amazonaws.com
-i Specifies an alternate identification file to use for public key authentication. Basically for this tutorial, I have my key in current directory.
-L specifies that the given port on the local (client) host is to be forwarded to the given host and port on the remote side (AWS). This means that whatever is running on the second port number (i.e. 8888) on AWS will appear on the first port number (i.e. 8000) on your local computer. You should change 8888 to the port which Jupyter Notebook is running on. 99.9% of the time Jupyter will run on port 8888. Optionally change port 8000 to one of your choosing (for example, if 8000 is used by another process).
5. Open your browser and go to localhost:8000
6. (Optional) If you want to use different conda environments (including the ability to access both Python 2 and Python 3 environments in Jupyter Notebooks, please see this tutorial).
Please let me know if you have any questions either here, on the youtube video page, or through Twitter!
Explain Merge Sort in Python

Merge sort is a sorting technique. It is an efficient sorting algorithm with a time complexity of (n logn) where n is the length of the array to be sorted.
Merge sort is an algorithm that follows the Divide and Conquers paradigm. It continuously divides the array into two equal halves. Later it starts sorting the lists having a single element each and continuously merges the sorted lists to form the complete sorted list.
Hence, we obtain a sorted array.
Example
The purple boxes and black arrows show the splitting of the list into two halves.
The green boxes and red arrows show the merging of the two sorted lists.
Splitting the list into two halves is quite easy and it is done recursively until we have only one element left. Later the merging procedure is done which is actually where we apply the logic of merging the two sorted lists together.
The merge function takes the two sorted arrays to be merged. The frontmost element of a1 is compared with the frontmost element of a2. The smallest of two is added to list c and the pointer of that array is incremented.
 Live Demo
def merge(a1,a2):
   c=[]
   x=0
   y=0
   while(x<len(a1) and y<len(a2)):
      if(a1[x]<a2[y]):
         c.append(a1[x])
         x+=1
      else:
         c.append(a2[y])
         y+=1
   while(x<len(a1)):
      c.append(a1[x])
      x+=1
   while(y<len(a2)):
      c.append(a2[y])
      y+=1
   return c

def mergesort(array):
   if(len(array)==1):
      return array
   mid=(len(array))//2
   a1=mergesort(array[:mid])
   a2=mergesort(array[mid:])
   return merge(a1,a2)
array=[2,3,1,5,4,6,8,10,7,9]
print(mergesort(array))
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
How to get the value of custom attribute in jQuery?

To get the value in jQuery, use the data-attributes with the data() method. You can try to run the following code to implement how to get the value of custom attribute:
Live Demo
<html>
   <head>
      <title>Selector Example</title>
      <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
      <script>

         $(document).ready(function() {
            alert($('#my_id').data('original-title'));
         });
         
      </script>
   </head>
   <body>
      <strong id="my_id" data-original-title="Hello">Demo</strong>
   </body>
</html>
How to create "next" and "previous" buttons with CSS?

Following is the code to create next and previous buttons with CSS −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
a {
   text-decoration: none;
   display: inline-block;
   padding: 20px;
   font-size: 35px;
   width: 40px;
   text-align: center;
}
.back:hover {
   background-color: #ddd;
   color: black;
}
.next:hover {
   background-color: rgb(121, 37, 133);
   color: white;
}
.back {
   border-radius: 50%;
   background-color: #acacac;
   color: black;
}
.next {
   border-radius: 50%;
   background-color: rgb(68, 30, 112);
   color: white;
}
</style>
</head>
<body>
<h1>Previous and Next Button Example</h1>
<a href="#" class="back">‹</a>
<a href="#" class="next">›</a>
</body>
</html>
The above code will produce the following output −
Java byte Keyword

❮ Java Keywords

byte myNum = 100;
System.out.println(myNum);


Try it Yourself »

The byte keyword is a data type that can store whole numbers from -128 to 127.
Read more about data types in our Java Data Types Tutorial.

❮ Java Keywords

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.