code-rag-bench/online-tutorials huggingface dataset:
Microsoft Azure - Working with PowerShell in Cosmos DB - GeeksforGeeks

26 Jan, 2021
Azure Cosmos DB is a fully managed NoSQL database for build applications designed by Microsoft. It is highly responsive, scalable, and fully automated. Azure Cloud Shell is an in-browser terminal used to manage cloud instances in Azure. The PowerShell is an application used for the same purpose but is installed locally.
In this article, we will look into Azure Cosmos DB with PowerShell where we will create a new Cosmos DB account, a database, and a container with PowerShell. Here we’ll use the Azure Cloud Shell, and you can also use a local installation of PowerShell.Some of the operations that you can perform using PowerShell in Cosmos DB are listed below:
Create a Cosmos DB database
Update Cosmos DB database
Delete Cosmos DB database
To create a Cosmos DB database with Powershell/ Cloud Shell follow the below steps:
Step 1: Before we can start, we need to install the Cosmos DB PowerShell module like with the below command:
Install-Module -Name Az.CosmosDB
At the end of the installation you need to verify again if to install the same as shown below:
Step 2: First, to see if it works, we will run the below command to list all Cosmos DB accounts in this resource group:
Get-AzCosmosDBAccount -ResourceGroupName "RESOURCE NAME"
This will list the accounts as shown below:
And we can see that there is one in this resource group.
Step 3: Now, let’s create a new Azure Cosmos DB account. This will contain a database that will contain containers with documents in it. This will be an account that uses the SQL API to work with data. This can take a while. At this stage, the Cosmos DB account is created.
Step 4: Now we need a database for the account. To do so use the below command:
New-AzCosmosDBSqlDatabase
It would result in something like below after completion:
This creates a database, and it is done. 
Step 5: Now, we can add a container to the database with the below command:
New-AzCosmosDBSqlContainer
This will result in the following:
 You can create multiple containers in a database, and this one would use the Autoscale feature as shown in the above image:
$ autoscaleMaxThroughput = 4000 #minimum = 4000
Now let’s go to the Azure portal to look at the result. We are in the Azure Cosmos DB account in the Data Explorer. Here is the database, and under that is the container.
It also has autoscale enabled. 
We’ve used PowerShell to list Azure Cosmos DB accounts and create a new one with a database and autoscale container.
Microsoft
Advanced Computer Subject
Microsoft
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Copying Files to and from Docker Containers
Markov Decision Process
Fuzzy Logic | Introduction
Q-Learning in Python
Principal Component Analysis with Python
ML | What is Machine Learning ?
OpenCV - Overview
Basics of API Testing Using Postman
Getting Started with System Design
ML | Introduction to Data in Machine Learning
Set dotted line for border with CSS

To set dotted line for border, use the border-style property. You can try to run the following code to implement border-style property value dotted to set dotted border:
<html>
   <head>
   </head>
   <body>
      <p style = "border-width:3px; border-style:dotted;">
         This is a dotted border.
      </p>
   </body>
</html>
Python - How to Concatenate Two or More Pandas DataFrames along rows?

To concatenate more than two Pandas DataFrames, use the concat() method. Set the axis parameter as axis = 0 to concatenate along rows. At first, import the required library −
import pandas as pd
Let us create the 1st DataFrame −
dataFrame1 = pd.DataFrame(
   {
      "Col1": [10, 20, 30],"Col2": [40, 50, 60],"Col3": [70, 80, 90],
   },
   index=[0, 1, 2],
)


Let us create the 2nd DataFrame −
dataFrame2 = pd.DataFrame(
   {
      "Col1": [100, 110, 120],"Col2": [130, 140, 150],"Col3": [160, 170, 180],
   },
   index=[3, 4, 5],
)


Let us create the 3rd DataFrame −
dataFrame3 = pd.DataFrame(
   {
      "Col1": [200, 210, 220],"Col2": [230, 240, 250],"Col3": [260, 270, 280],
   },
   index=[6, 7, 8],
)
Concatenate all the 3 DataFrames using concat(). Set "axis=1" for concatenation along rows −
res = [dataFrame1, dataFrame2, dataFrame3]
pd.concat(res, axis=1))
Following is the code −
import pandas as pd

# Create DataFrame1
dataFrame1 = pd.DataFrame(
   {
      "Col1": [10, 20, 30],"Col2": [40, 50, 60],"Col3": [70, 80, 90],
   },
   index=[0, 1, 2],
)

# DataFrame1
print"DataFrame1...\n",dataFrame1

# Create DataFrame2
dataFrame2 = pd.DataFrame(
   {
      "Col1": [100, 110, 120],"Col2": [130, 140, 150],"Col3": [160, 170, 180],
   },
   index=[3, 4, 5],
)

# DataFrame2
print"DataFrame2...\n",dataFrame2

dataFrame3 = pd.DataFrame(
   {
      "Col1": [200, 210, 220],"Col2": [230, 240, 250],"Col3": [260, 270, 280],
   },
   index=[6, 7, 8],
)

# DataFrame3
print"DataFrame3...\n",dataFrame3

# concatenating more than 2 dataframes
# set "axis=0" for concatenation along rows
res = [dataFrame1, dataFrame2, dataFrame3]
print"\n Concatenating all the 3 DataFrames (along rows)...\n", pd.concat(res, axis=0)


This will produce the following output −
DataFrame1...
   Col1   Col2   Col3
0   10     40     70
1   20     50     80
2   30     60     90
DataFrame2...
   Col1   Col2   Col3
3  100    130    160
4  110    140    170
5  120    150    180
DataFrame3...
   Col1   Col2   Col3
6   200    230    260
7   210    240    270
8   220    250    280

Concatenating all the 3 DataFrames (along rows)...
   Col1   Col2   Col3
0   10     40     70
1   20     50     80
2   30     60     90
3   100    130    160
4   110    140    170
5   120    150    180
6   200    230    260
7   210    240    270
8   220    250    280
Check if a string contains only alphabets in Java using Lambda expression

Let’s say our string is −
String str = "Amit123";
Now, using allMatch() method, get the boolean result whether the string has only alphabets or now −
boolean result = str.chars().allMatch(Character::isLetter);
Following is an example to check if a string contains only alphabets using Lambda Expressions −
class Main {
   public static void main(String[] args) {
      String str = "Amit123";
      boolean result = str.chars().allMatch(Character::isLetter);
      System.out.println("String contains only alphabets? = "+result);
   }
}
Let us see another example with a different input −
String contains only alphabets? = false
class Main {
   public static void main(String[] args) {
      String str = "Jacob";
      boolean result = str.chars().allMatch(Character::isLetter);
      System.out.println("String contains only alphabets? = "+result);
   }
}
String contains only alphabets? = true
gzip.compress(s) in Python - GeeksforGeeks

23 Mar, 2020
With the help of gzip.compress(s) method, we can get compress the bytes of string by using gzip.compress(s) method.
Syntax : gzip.compress(string)Return : Return compressed string.
Example #1 :In this example we can see that by using gzip.compress(s) method, we are able to compress the string in the byte format by using this method.
# import gzip and compressimport gzip  s = b'This is GFG author, and final year student.'print(len(s))  # using gzip.compress(s) methodt = gzip.compress(s)print(len(t))
Output :
4361
Example #2 :
# import gzip and compressimport gzip  s = b'GeeksForGeeks@12345678'print(len(s))  # using gzip.compress(s) methodt = gzip.compress(s)print(len(t))
Output :
2239
Python-gzip
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
Bar Plot in Matplotlib
Python | Get dictionary keys as a list
Python | Convert set into a list
Ways to filter Pandas DataFrame by column values
Python - Call function from another file
loops in python
Multithreading in Python | Set 2 (Synchronization)
Python Dictionary keys() method
Python Lambda Functions
HTML Tables with Fixed Header on Scroll in CSS

By setting postion: sticky and top: 0, we can create a fixed header on a scroll in HTML tables.
The following examples give us an idea of how to implement this −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
div {
   color: white;
   display: flex;
   padding: 2%;
   background-color: rgba(190,155,150);
   height: 135px;
   overflow-y: scroll;
}
td,th,p {
   text-align: center;
   font-size: 1.25em;
}
table {
   padding: 3%;
   border-collapse: collapse;
   border: 2px ridge green;
}
th {
   top: 0;
   position: sticky;
   background: #e5d2f1;
   color: black;
}
</style>
</head>
<body>
<div>
<table>
<thead>
<tr>
<th>A </th>
<th>B </th>
<th>C </th>
<th>D </th>
<th>E </th>
</tr>
</thead>
<tr>
<td>Hey</td>
<td>Hey</td>
<td>Hey</td>
<td>Hey</td>
<td>Hey</td>
</tr>
<tr>
<td>Demo</td>
<td>Demo</td>
<td>Demo</td>
<td>Demo</td>
<td>Demo</td>
</tr>
<tr>
<td>Yo</td>
<td>Yo</td>
<td>Yo</td>
<td>Yo</td>
<td>Yo</td>
</tr>
<tr>
<td>Demo</td>
<td>Demo</td>
<td>Demo</td>
<td>Demo</td>
<td>Demo</td>
</tr>
</table>
<p>
Duis tincidunt fermentum ipsum vel sagittis. Sed ultrices quis dui ut rutrum. Quisque et varius tellus, ut vestibulum purus. Etiam in erat fringilla, laoreet libero eu, facilisis ante. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Duis eu ornare augue, ut facilisis odio.
</p>
</div>
</body>
</html>
This will produce the following result −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
div {
   padding: 2%;
   height: 40px;
   overflow-y: scroll;
   box-shadow: inset 0 0 12px lightgreen;
}
tr th {
   background: #25f2f1;
}
table {
   text-align: center;
   position: relative;
   border-collapse: separated;
   width: 100%;
}
th {
   top: 0;
   position: sticky;
   background: white;
}
</style>
</head>
<body>
<div>
<table>
<thead>
<tr>
<th>A </th>
<th>B </th>
<th>C </th>
<th>D </th>
<th>E </th>
</tr>
</thead>
<tr>
<td>Hey</td>
<td>Hey</td>
<td>Hey</td>
<td>Hey</td>
<td>Hey</td>
</tr>
<tr>
<td>Demo</td>
<td>Demo</td>
<td>Demo</td>
<td>Demo</td>
<td>Demo</td>
</tr>
<tr>
<td>Yo</td>
<td>Yo</td>
<td>Yo</td>
<td>Yo</td>
<td>Yo</td>
</tr>
<tr>
<td>Demo</td>
<td>Demo</td>
<td>Demo</td>
<td>Demo</td>
<td>Demo</td>
</tr>
</table>
</div>
</body>
</html>
This will produce the following result −
How to create a MySQL table with indexes?

To create a MySQL table with indexes, the syntax is as follows −
create table yourTableName
(
yourColumnName1 dataType,
yourColumnName2 dataType
.
.
.
N
);
create index yourIndexName1 on(yourColumnName1 );
create index yourIndexName2 on(yourColumnName2 );
Let us first create a table −
mysql> create table DemoTable
   -> (
   -> Id int,
   -> Name varchar(20)
   -> );
Query OK, 0 rows affected (0.63 sec)
Here is the query to create indexes with table −
mysql> create index id_index on DemoTable(Id);
Query OK, 0 rows affected (0.36 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> create index Name_index on DemoTable(Name);
Query OK, 0 rows affected (0.38 sec)
Records: 0 Duplicates: 0 Warnings: 0
Now you can check the structure of table −
mysql> show create table DemoTable;
This will produce the following output −
+---------------+-----------------------------------------------------------------------------------------+
| Table         | Create Table                                                                            |  
+---------------+-----------------------------------------------------------------------------------------+
| DemoTable     | CREATE TABLE `DemoTable` ( `Id` int(11) DEFAULT NULL, `Name` varchar(20) COLLATE                               utf8_unicode_ci DEFAULT NULL, KEY `id_index` (`Id`), KEY `Name_index` (`Name`) )                            ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci                             |
+---------------+------------------------------------------------------------------------------------------+
1 row in set (0.05 sec)
Java Numeric Literals with Underscore - GeeksforGeeks

24 Nov, 2020
 A new feature was introduced by JDK 7 which allows writing numeric literals using the underscore character. Numeric literals are broken to enhance the readability. This feature is used to separate a group of digits in numeric literal which can improve the readability of source code. There are some rules the programmer has to follow before using numeric literals like
1. We should not use underscore before or after an integer number.
int p = _10; // Error, this is an identifier, not a numeric literal  
int p = 10_; // Error, cannot put underscores at the end of a number  
2. We should not use underscore before or after a decimal point in a floating-point literal.
float a = 10._0f; // Error, cannot put underscores adjacent to a decimal point  
float a = 10_.0f; // Error, cannot put underscores adjacent to a decimal point  
3. We should not use prior to L or F suffix in long and float integers respectively.
long a = 10_100_00_L; // Error, cannot put underscores prior to an L suffix  
float a = 10_100_00_F; // Error, cannot put underscores prior to an F suffix  
4. We cannot use underscore in positions where a string of digits is expected.
Example
Java
// Java program to demonstrate Numeric Literals with// Underscore  public class Example {    public static void main(String args[])    {        // Underscore in integral literal        int a = 7_7;        System.out.println("The value of a is=" + a);          // Underscore in floating literal        double p = 11.239_67_45;        System.out.println("The value of p is=" + p);          float q = 16.45_56f;        System.out.println("The value of q is=" + q);          // Underscore in binary literal        int c = 0B01_01;        System.out.println("c = " + c);          // Underscore in hexadecimal literal        int d = 0x2_2;        System.out.println("d = " + d);          // Underscore in octal literal        int e = 02_3;        System.out.println("e = " + e);    }}
The value of a is=77
The value of p is=11.2396745
The value of q is=16.4556
c = 5
d = 34
e = 19

Picked
Java
Java Programs
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Different ways of Reading a text file in Java
Constructors in Java
Exceptions in Java
Functional Interfaces in Java
Convert a String to Character array in Java
Java Programming Examples
Convert Double to Integer in Java
Implementing a Linked List in Java using Class
How to Iterate HashMap in Java?
XPath - Axes

As location path defines the location of a node using absolute or relative path, axes are used to identify elements by their relationship like parent, child, sibling, etc. Axes are named so because they refer to axis on which elements are lying relative to an element.
Following is the list of various Axis values.
ancestor
Represents the ancestors of the current node which include the parents up to the root node.
ancestor-or-self
Represents the current node and it's ancestors.
attribute
Represents the attributes of the current node.
child
Represents the children of the current node.
descendant
Represents the descendants of the current node. Descendants include the node's children upto the leaf node(no more children).
descendant-or-self
Represents the current node and it's descendants.
following
Represents all nodes that come after the current node.
following-sibling
Represents the following siblings of the context node. Siblings are at the same level as the current node and share it's parent.
namespace
Represents the namespace of the current node.
parent
Represents the parent of the current node.
preceding
Represents all nodes that come before the current node (i.e. before it's opening tag).
self
Represents the current node.
Following are a few examples on the uses of axes.
firstname − select firstname related to student nodes.
<p><xsl:value-of select = "firstname"/></p>
<xsl:value-of select = "/class/student/preceding-sibling::comment()"/>
In this example, we've created a sample XML document students.xml and its stylesheet document students.xsl which uses the XPath expressions.
Following is the sample XML used.
<?xml version = "1.0"?>
<?xml-stylesheet type = "text/xsl" href = "students.xsl"?>
<class>
   <!-- Comment: This is a list of student -->
   <student rollno = "393">
      <firstname>Dinkar</firstname>
      <lastname>Kad</lastname>
      <nickname>Dinkar</nickname>
      <marks>85</marks>
   </student>
   <student rollno = "493">
      <firstname>Vaneet</firstname>
      <lastname>Gupta</lastname>
      <nickname>Vinni</nickname>
      <marks>95</marks>
   </student>
   <student rollno = "593">
      <firstname>Jasvir</firstname>
      <lastname>Singh</lastname>
      <nickname>Jazz</nickname>
      <marks>90</marks>
   </student>
</class>
<?xml version = "1.0" encoding = "UTF-8"?>
<xsl:stylesheet version = "1.0"
   xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"> 
	
   <xsl:template match = "/" >
      <html>
         <body>  
            <xsl:value-of select = "/class/student/preceding-sibling::comment()"/>
            <br/>
            <xsl:text>First Student: </xsl:text>
            <xsl:value-of select = "/class/student/child::firstname" />    
         </body>
      </html>
   </xsl:template>
</xsl:stylesheet>

    90 Lectures 
     20 hours 

 Arun Motoori

    23 Lectures 
     8 hours 

 Sanjay Kumar

    13 Lectures 
     1.5 hours 

 Sanjay Kumar

    24 Lectures 
     1.5 hours 

 Sanjay Kumar

    47 Lectures 
     3 hours 

 Krishna Sakinala
 Print
 Add Notes
 Bookmark this page
How to convert a String containing Scientific Notation to correct JavaScript number format?

To convert a string with Scientific Notation, use the Number function. Pass the value to this function.
You can try to run the following code to convert a string to correct number format −
Live Demo
<!DOCTYPE html>
<html>
   <body>
      <script>
         document.write("String with Scientific Notation converted below:<br>");
         document.write(Number("7.53245683E7"));
      </script>
   </body>
</html>
String with Scientific Notation converted below:
75324568.3
HISTTIMEFORMAT variable in Linux with Example

24 Dec, 2020
The bash shell in Linux allows us to access the command history i.e, the list of previously executed commands in sequence using the history command. The history command is used to keep track of all commands that were executed. It is very important during troubleshooting or for auditing. History command without setting the HISTTIMEFORMAT displays only command# and command but it does not display the time when the command was executed. So, to display the time stamp information associated with each history entry the HISTTIMEFORMAT has to be set. 
By default, the display of the history command is only the serial number and the command. The Syntax for the history command:
$ history
The output of the command can be seen in the image below:
The above command does not display the time when the command was executed and hence we use HISTTIMEFORMAT variable.
Syntax:
HISTTIMEFORMAT='%d/%m/%y %T'
or,
HISTTIMEFORMAT="%F %T "
After using any of the above commands both date and time will be displayed along with the commands.
Output:
1  2020-12-14 14:09:17 whoami
2  2020-12-14 14:09:17 pwd
3  2020-12-14 14:09:17 echo "abc"
4  2020-12-14 14:09:17 pwd
5  2020-12-14 14:09:17 whoami
6  2020-12-14 14:09:17 clear
7  2020-12-14 14:09:17 man bash
8  2020-12-14 14:09:17 history
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Docker - COPY Instruction
scp command in Linux with Examples
chown command in Linux with Examples
SED command in Linux | Set 2
nohup Command in Linux with Examples
mv command in Linux with examples
chmod command in Linux with examples
Array Basics in Shell Scripting | Set 1
Introduction to Linux Operating System
Basic Operators in Shell Scripting
How to dynamically add or remove items from a list in Vue.js ?

19 Feb, 2021
Vue is a progressive framework for building user interfaces. The core library is focused on the view layer only and is easy to pick up and integrate with other libraries. Vue is also perfectly capable of powering sophisticated Single-Page Applications in combination with modern tooling and supporting libraries. 
Using Vue.js one can easily add or remove items in a list dynamically using the v-model directive. This directive binds all the possibilities to a single channel. When the user selects an option from the list of available ones, it adds it to the list of values. Similarly, if the user deselects any option, it removes it from the list of values.
Example:
index.html
<html><head>    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js">      </script></head><body>    <div id='parent'>      <h1 style="color: green;">        GeeksforGeeks      </h1>                    <p><strong>Favourite Sports:</strong>          </p>          <input type="checkbox" id="cricket"                value="cricket" v-model="sports">        <label for="cricket">Cricket</label>        <input type="checkbox" id="football"                value="football" v-model="sports">        <label for="football">Football</label>        <input type="checkbox" id="hockey"                value="hockey" v-model="sports">        <label for="hockey">Hockey</label>        <input type="checkbox" id="badminton"               value="badminton" v-model="sports">        <label for="badminton">Badminton</label>        <input type="checkbox" id="arching"                value="arching" v-model="sports">        <label for="arching">Arching</label>                  <p><strong>Sports You  Like:</strong>          {{ sports }}        </p>      </div>    <script src='app.js'></script></body></html>
app.js
const parent = new Vue({    el : '#parent',    data : {        sports : []    }})
Output:
Vue.JS
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Remove elements from a JavaScript Array
Difference Between PUT and PATCH Request
Roadmap to Learn JavaScript For Beginners
JavaScript | Promises
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
Sorting of a Vector in R Programming – sort() Function

05 Jun, 2020
sort() function in R Language is used to sort a vector by its values. It takes Boolean value as argument to sort in ascending or descending order.
Syntax:sort(x, decreasing, na.last)
Parameters:x: Vector to be sorteddecreasing: Boolean value to sort in descending orderna.last: Boolean value to put NA at the end
Example 1:
# R program to sort a vector  # Creating a vectorx <- c(7, 4, 3, 9, 1.2, -4, -5, -8, 6, NA)  # Calling sort() functionsort(x)
Output:
[1] -8.0 -5.0 -4.0  1.2  3.0  4.0  6.0  7.0  9.0

Example 2:
# R program to sort a vector  # Creating a vectorx <- c(7, 4, 3, 9, 1.2, -4, -5, -8, 6, NA)  # Calling sort() function# to print in decreasing ordersort(x, decreasing = TRUE)  # Calling sort() function# to print NA at the endsort(x, na.last = TRUE)
Output:
[1]  9.0  7.0  6.0  4.0  3.0  1.2 -4.0 -5.0 -8.0
[1] -8.0 -5.0 -4.0  1.2  3.0  4.0  6.0  7.0  9.0   NA

R Vector-Function
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Filter data by multiple conditions in R using Dplyr
How to Replace specific values in column in R DataFrame ?
Change Color of Bars in Barchart using ggplot2 in R
How to Split Column Into Multiple Columns in R DataFrame?
Loops in R (for, while, repeat)
Group by function in R using Dplyr
How to change Row Names of DataFrame in R ?
R Programming Language - Introduction
How to Change Axis Scales in R Plots?
How to filter R DataFrame by values in a column?
HTML <q> Tag

17 Mar, 2022
The <q> tag is a standard quotation tag and used for short quotation. The browser normally inserts a quotation mark around the quotation. For longer quotations, the <blockquote> tag must be used since it is a block-level element. The <q> tag requires a starting as well as end tag.Syntax:  
<q> Contents... </q>
Attributes 
cite: It contains the value i.e URL which specify the source URL of the Quote.Below examples illustrate the <q> tag in HTML:Example 1:  
HTML
<html>    <body>          <p>          <!-- html q tag is used here -->          <q>GeeksforGeeks</q>            A computer science portal for geeks        </p>      </body></html>                   
Output:  
Example 2(Use CSS in q tag):  
HTML
<html>    <head>        <title>q tag</title>        <style>            q {                color: #00cc00;                font-style: italic;            }        </style>    </head>    <body>      <p>      <!-- html q tag is used here -->      <q>GeeksforGeeks</q>    A computer science portal for geeks    </p>       </body></html>
Output:  
Supported Browsers:  
Google Chrome
Internet Explorer
Firefox
Opera
Safari
 
shubhamyadav4
ManasChhabra2
HTML-Tags
HTML
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 ?
Types of CSS (Cascading Style Sheet)
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to set the default value for an HTML <select> element ?
Hide or show elements in HTML using display property
How to set input type date in dd-mm-yyyy format using HTML ?
How to Upload Image into Database and Display it using PHP ?
How to position a div at the bottom of its container using CSS?
How to Insert Form Data into Database using PHP ?
PHP | decbin( ) Function

09 Mar, 2018
While working with numbers, many times we need to convert the bases of number and one of the most frequent used conversion is decimal to binary conversion. PHP provides us with a built-in function, decbin() for this purpose.The decbin() function in PHP is used to return a string containing a binary representation of the given decimal number argument.decbin stands for decimal to binary.
Syntax:
string decbin(value)
Parameters: This function accepts a single parameter value. It is the decimal number which you want to convert in binary representation.
Return Value: It returns a string that represent the binary value of the decimal number passed to the function as argument.
Examples:
Input : decbin(12)
Output : 1100

Input : decbin(26)
Output : 11010

Input : decbin(2147483647)
Output : 1111111111111111111111111111111 (31 1's)

Below programs illustrate the decbin() function in PHP:
Passing 12 as a parameter<?php  echo decbin(12);  ?>    Output:1100
<?php  echo decbin(12);  ?>    
Output:
1100
Passing 26 as a parameter:<?php  echo decbin(26);  ?>   Output:11010
<?php  echo decbin(26);  ?>   
Output:
11010
When the largest signed integer is passed as a parameter:<?php  echo decbin(2147483647);  ?>      Output: 1111111111111111111111111111111  
<?php  echo decbin(2147483647);  ?>      
Output:
 1111111111111111111111111111111  
Reference:http://php.net/manual/en/function.decbin.php
PHP-function
PHP-math
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Convert Tuples to Dictionary

20 Aug, 2020
Conversions among datatypes are quite popular utility and hence having knowledge of it always proves out to be quite handy. The conversion of a list of tuples into a dictionary had been discussed earlier, sometimes, we might have a key and a value tuple to be converted to a dictionary. Let’s discuss certain ways in which this can be performed.
Method #1 : Using Dictionary ComprehensionThis task can be performed using the dictionary comprehension in which we can iterate through the key and value tuple simultaneously using enumerate() and construct the desired dictionary.
# Python3 code to demonstrate working of# Convert Tuples to Dictionary# Using Dictionary Comprehension# Note: For conversion of two tuples into a dictionary, we've to have the same length of tuples. Otherwise, we can not match all the key-value pairs  # initializing tuplestest_tup1 = ('GFG', 'is', 'best')test_tup2 = (1, 2, 3)  # printing original tuplesprint("The original key tuple is : " + str(test_tup1))print("The original value tuple is : " + str(test_tup2))  # Using Dictionary Comprehension# Convert Tuples to Dictionaryif len(test_tup1) == len(test_tup2):    res = {test_tup1[i] : test_tup2[i] for i, _ in enumerate(test_tup2)}  # printing result print("Dictionary constructed from tuples : " + str(res))
The original key tuple is : ('GFG', 'is', 'best')
The original value tuple is : (1, 2, 3)
Dictionary constructed from tuples : {'best': 3, 'is': 2, 'GFG': 1}

 
Method #2 : Using zip() + dict()This is yet another method in which this task can be performed in which a combination of zip function and dict function achieve this task. The zip function is responsible for conversion of tuple to key-value pair with corresponding indices. The dict function performs the task of conversion to dictionary.
# Python3 code to demonstrate working of# Convert Tuples to Dictionary# Using zip() + dict()  # initializing tuplestest_tup1 = ('GFG', 'is', 'best')test_tup2 = (1, 2, 3)  # printing original tuplesprint("The original key tuple is : " + str(test_tup1))print("The original value tuple is : " + str(test_tup2))  # Using zip() + dict()# Convert Tuples to Dictionaryif len(test_tup1) == len(test_tup2):    res = dict(zip(test_tup1, test_tup2))  # printing result print("Dictionary constructed from tuples : " + str(res))
The original key tuple is : ('GFG', 'is', 'best')
The original value tuple is : (1, 2, 3)
Dictionary constructed from tuples : {'GFG': 1, 'is': 2, 'best': 3}

parthsankhavara29
Python dictionary-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Parse Data From JSON into Python?

05 Jul, 2021
JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write for machines to parse and generate. Basically it is used to represent data in a specified format to access and work with data easily. Here we will learn, how to create and parse data from JSON and work with it.
Before starting the details of parsing data, We should know about ‘json’ module in Python. It provides an API that is similar to pickle for converting in-memory objects in Python to a serialized representation as well as makes it easy to parse JSON data and files. Here are some ways to parse data from JSON using Python below:
 
Python JSON to Dictionary: With the help of json.loads() function, we can parse JSON objects to dictionary.
Python3
# importing json libraryimport json geek = '{"Name": "nightfury1", "Languages": ["Python", "C++", "PHP"]}'geek_dict = json.loads(geek) # printing all elements of dictionaryprint("Dictionary after parsing: ", geek_dict) # printing the values using keyprint("\nValues in Languages: ", geek_dict['Languages'])
Output:
Dictionary after parsing:  {‘Name’: ‘nightfury1’, ‘Languages’: [‘Python’, ‘C++’, ‘PHP’]}
Values in Languages:  [‘Python’, ‘C++’, ‘PHP’]
Python JSON to Ordered Dictionary: We have to use same json.loads() function for parsing the objects, but for getting in ordered, we have to add keyword ‘object_pairs_hook=OrderedDict‘ from collections module.
Python3
import jsonfrom collections import OrderedDict  #create Ordered Dictionary using keyword# 'object_pairs_hook=OrderDict'data = json.loads('{"GeeksforGeeks":1, "Gulshan": 2, "nightfury_1": 3, "Geek": 4}',                  object_pairs_hook=OrderedDict)print("Ordered Dictionary: ", data)
Output:
Ordered Dictionary:  OrderedDict([(‘GeeksforGeeks’, 1), (‘Gulshan’, 2), (‘nightfury_1’, 3), (‘Geek’, 4)])
Parse using JSON file: With the help of json.load() method, we can parse JSON objects to dictionary format by opening the required JSON file.
Python3
# importing json libraryimport json with open('data.json') as f:  data = json.load(f) # printing data after loading the json fileprint(data)
Output:
{‘Name’: ‘nightfury1’, ‘Language’: [‘Python’, ‘C++’, ‘PHP’]}
anikakapoor
Python-json
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python | Get unique values from a list
Python | datetime.timedelta() function
Matplotlib.axes.Axes.hlines() in Python

13 Apr, 2020
Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute.
The Axes.hlines() function in axes module of matplotlib library is used to Plot vertical lines at each y from xmin to xmax.
Syntax: Axes.hlines(self, y, xmin, xmax, colors=’k’, linestyles=’solid’, label=”, *, data=None, **kwargs)
Parameters: This method accept the following parameters that are described below:
y: This parameter is the sequence of y-indexes where to plot the lines.
xmin, xmax: These parameter contains an array.And they represents the beginning and end of each line.
colors: This parameter is an optional parameter. And it is the color of the lines with default value k.
linetsyle: This parameter is also an optional parameter. And it is used to represent the linestyle{‘solid’, ‘dashed’, ‘dashdot’, ‘dotted’}.
label: This parameter is also an optional parameter.It is the label of the plot.
Returns: This returns the LineCollection.
Below examples illustrate the matplotlib.axes.Axes.hlines() function in matplotlib.axes:
Example #1:
# Implementation of matplotlib function       import numpy as npfrom matplotlib import patchesimport matplotlib.pyplot as plt   fig, ax = plt.subplots()ax.hlines([1, 3, 5], -3, 5, color ="green")ax.set_title('matplotlib.axes.Axes.hlines Example')  plt.show()
Output:
Example #2:
# Implementation of matplotlib function       import numpy as npfrom matplotlib import patchesimport matplotlib.pyplot as plt   t = np.arange(0.0, 5.0, 0.1)s = np.exp(-t) + np.cos(3 * np.pi * t) + np.sin(np.pi * t)nse = np.random.normal(0.0, 0.8, t.shape) * s  fig, ax = plt.subplots()  ax.hlines(t, [0], s)ax.set_xlabel('time (s)')ax.hlines([1, 3, 5], -3, 5, color ="lightgreen")ax.set_title('matplotlib.axes.Axes.hlines Example')  plt.show()
Output:
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
gpasswd command in Linux with examples

20 May, 2019
gpasswd command is used to administer the /etc/group and /etc/gshadow. As every group in Linux has administrators, members, and a password. It is an inherent security problem as more than one person is permitted to know the password. However, groups can perform co-operation between different users. This command assigns a user to a group with some security criteria. This command is called by a group administrator with a group name only which prompts for the new password of the group. System administrators can use the -A option to define group administrator(s) and -M option to define members. They have all rights of the group administrators and members.
Syntax:
gpasswd [option] group
Options: Here only -A and -M options can be combined.
-a, –add : This option is used to add a user to the named group.
-d, –delete : It is used to remove a user from the named group.
-r, –remove-password : It is used to remove the password from the named group.
-R, –restrict : This option will restrict the access to the named group.
-A, –administrators : Set the list of administrative users.
-M, –members : It set the list of group members.
-h, –help : It displays the help message and exit.$ sudo gpasswd -h 
$ sudo gpasswd -h 
Example: Creating a group and adding a user to it. After that deleting the user.
Adding a group named as geeks.$ sudo groupadd geeks
$ sudo groupadd geeks
To display the created group with their id you can use:$cat /etc/group
$cat /etc/group
Now the group geeks is added so now execute command under to add the user to group geeks:$ sudo gpasswd -a umang geeks
$ sudo gpasswd -a umang geeks
Deleting the created user from group geeks.$ sudo gpasswd -d umang geeks
$ sudo gpasswd -d umang geeks
linux-command
Linux-system-commands
Picked
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
tar command in Linux with examples
'crontab' in Linux with Examples
Conditional Statements | Shell Script
Tail command in Linux with examples
Docker - COPY Instruction
UDP Server-Client implementation in C
scp command in Linux with Examples
diff command in Linux with examples
echo command in Linux with Examples
Cat command in Linux with examples
Python – Split String on vowels

01 Jun, 2021
Given a String, perform split on vowels. 
Input : test_str = ‘GFGaBst’ Output : [‘GFG’, ‘Bst’] Explanation : a is vowel and split happens on that.Input : test_str = ‘GFGaBstuforigeeks’ Output : [‘GFG’, ‘Bst’, ‘for’, ‘geeks’] Explanation : a, u, i are vowels and split happens on that.  
Method : Using regex() + split()
In this, we use regex split() which accepts multiple characters to perform split, passing list of vowels, performs split operation over string.
Python3
# Python3 code to demonstrate working of# Split String on vowels# Using split() + regeximport re # initializing stringstest_str = 'GFGaBste4oCS' # printing original stringprint("The original string is : " + str(test_str)) # splitting on vowels# constructing vowels list# and separating using | operatorres = re.split('a|e|i|o|u', test_str) # printing resultprint("The splitted string : " + str(res))
The original string is : GFGaBste4oCS
The splitted string : ['GFG', 'Bst', '4', 'CS']
gabaa406
Python string-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Rotate axis tick labels in Seaborn and Matplotlib
Enumerate() in Python
Deque in Python
Stack in Python
Python Dictionary
Defaultdict in Python
Python | Split string into list of characters
Python | Get dictionary keys as a list
Iterate over characters of a string in Python
Python | Convert set into a list
Python - Proxy Server

Proxy servers are used to browse to some website through another server so that the browsing remains anonymous. It can also be used to bypass the blocking of specific IP addresses.
We use the urlopen method from the urllib module to access the website by passing the proxy server address as a parameter.
In the below example we use a proxy address to access the website twitter.con for anonymous access. The response status of OK proves the successful access through a proxy server. 
import urllib
URL = 'https://www.twitter.com'
PROXY_ADDRESS = "265.24.11.6:8080"
if __name__ == '__main__':
    resp = urllib.urlopen(URL, proxies = {"http" : PROXY_ADDRESS})
print "Proxy server returns response headers: %s " %resp.headers
When we run the above program, we get the following output −
Proxy server returns response headers: cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0
content-length: 145960
content-type: text/html;charset=utf-8
date: Mon, 02 Jul 2018 02:06:19 GMT
expires: Tue, 31 Mar 1981 05:00:00 GMT
last-modified: Mon, 02 Jul 2018 02:06:19 GMT
pragma: no-cache
server: tsa_n
set-cookie: fm=0; Expires=Mon, 02 Jul 2018 02:06:10 GMT; Path=/; Domain=.twitter.com; Secure; HTTPOnly
set-cookie: _twitter_sess=BAh7CSIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNo%250ASGFzaHsABjoKQHVzZWR7ADoPY3JlYXRlZF9hdGwrCAifvVhkAToMY3NyZl9p%250AZCIlNzlhY2ZhMzdmNGFkYTU0ZTRmMDkxODRhNWNiYzI0MDI6B2lkIiUyZTgy%250AOTAyYjY4NTBkMzE3YzNjYTQwNzZjZDhhYjZhMQ%253D%253D--6807256d74a01129a7b0dcf383f56f169fb8a66c; Path=/; Domain=.twitter.com; Secure; HTTPOnly
set-cookie: personalization_id="v1_iDacJdPWUx3e81f8UErWTA=="; Expires=Wed, 01 Jul 2020 02:06:19 GMT; Path=/; Domain=.twitter.com
set-cookie: guest_id=v1%3A153049717939764273; Expires=Wed, 01 Jul 2020 02:06:19 GMT; Path=/; Domain=.twitter.com
set-cookie: ct0=50c8b59b09322825cd750ea082e43bdc; Expires=Mon, 02 Jul 2018 08:06:19 GMT; Path=/; Domain=.twitter.com; Secure
status: 200 OK
strict-transport-security: max-age=631138519
x-connection-hash: 89dfbab81abc35dd8f618509c6171bd3
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-response-time: 312
x-transaction: 007b998000f86eaf
x-twitter-response-tags: BouncerCompliant
x-ua-compatible: IE=edge,chrome=1
x-xss-protection: 1; mode=block; report=https://twitter.com/i/xss_report



    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
How to use MySQL Date functions with WHERE clause?

By using the WHERE clause with any of the MySQL date functions, the query will filter the rows based on the condition provided in the WHERE clause. To understand it, consider the data from ‘Collegedetail’ table as follows
mysql> Select * from Collegedetail;
+------+---------+------------+
| ID   | Country | Estb       |
+------+---------+------------+
| 111  | INDIA   | 2010-05-01 |
| 130  | INDIA   | 1995-10-25 |
| 139  | USA     | 1994-09-25 |
| 1539 | UK      | 2001-07-23 |
| 1545 | Russia  | 2010-07-30 |
+------+---------+------------+
5 rows in set (0.00 sec)
Now, suppose if want to get the details of only those colleges which established in the year 2010 then following query, having WHERE clause with YEAR(), can be used −
mysql> Select * from Collegedetail WHERE YEAR(Estb) = '2010';
+------+---------+------------+
| ID   | Country | Estb       |
+------+---------+------------+
| 111  | INDIA   | 2010-05-01 |
| 1545 | Russia  | 2010-07-30 |
+------+---------+------------+
2 rows in set (0.07 sec)
C++ Algorithm Library - count() Function

The C++ function std::algorithm::count() returns the number of occurrences of value in range. This function uses operator == for comparison.
Following is the declaration for std::algorithm::count() function form std::algorithm header.
template <class InputIterator, class T>
typename iterator_traits<InputIterator>::difference_type
count (InputIterator first, InputIterator last, const T& val);

first − Input iterators to the initial positions of the searched sequence.
first − Input iterators to the initial positions of the searched sequence.
last − Input iterators to the final positions of the searched sequence.
last − Input iterators to the final positions of the searched sequence.
val − Value to search for in the range.
val − Value to search for in the range.
Returns the number of elements in the range of first to last.
Throws an exception if either element assignment or an operation on an iterator throws exception.
Please note that invalid parameters cause undefined behavior.
Linear in the distance between first to last.
The following example shows the usage of std::algorithm::count() function.
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
   vector<int> v = {1, 3, 3, 3, 3};
   int cnt;

   cnt = count(v.begin(), v.end(), 3);

   cout << "Number 3 occurs " << cnt << " times." << endl;

   return 0;
}
Let us compile and run the above program, this will produce the following result −
Number 3 occurs 4 times.

 Print
 Add Notes
 Bookmark this page
Check replication type in MySQL?

To check replication type, you can use SHOW GLOBAL VARIABLES command. The syntax is as follows −
SHOW GLOBAL VARIABLES LIKE 'binlog_format';
The above syntax returns either ROW, MIXED or STATEMENT. The default resultant is ROW.
Now you can implement the above syntax to check replication type. The query is as follows −
mysql> SHOW GLOBAL VARIABLES LIKE 'binlog_format';
Here is the output −
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| binlog_format | ROW   |
+---------------+-------+
1 row in set (0.10 sec)
Here is the query to switch from ROW to STATEMENT −
mysql> SET GLOBAL binlog_format = 'STATEMENT';
Query OK, 0 rows affected (0.04 sec)
Now check the replication type once again. The query is as follows −
mysql> SHOW GLOBAL VARIABLES LIKE 'binlog_format';
Here is the output −
+---------------+-----------+
| Variable_name | Value     |
+---------------+-----------+
| binlog_format | STATEMENT |
+---------------+-----------+
1 row in set (0.01 sec)
Now the binlog_format is STATEMENT.
You can change from STATEMENT to MIXED or MIXED to ROW and so on.
Change by session also. The query is as follows −
mysql> SET SESSION binlog_format = 'ROW';
Query OK, 0 rows affected (0.00 sec)
Now check the value of binlog_format once again. The query is as follows −
mysql> SHOW VARIABLES LIKE 'binlog_format';
The following is the output −
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| binlog_format | ROW   |
+---------------+-------+
1 row in set (0.04 sec)
The intersection of two arrays in Python (Lambda expression and filter function )

In this article, we will learn about the intersection of two arrays in Python with the help of Lambda expression and filter function.
The problem is that we are given two arrays we have to find out common elements in both of them.
1. Declaring an intersection function with two arguments.
2. Now we use the lambda expression to create an inline function for selection of elements with the help of filter function checking that element is contained in both the list or not.
3. Finally, we convert all the common elements in the form of a list by the help of typecasting.
4. And then we display the output by the help of the print statement.
Now let’s take a look at its implementation:
def interSection(arr1,arr2): # finding common elements

# using filter method oto find identical values via lambda function
values = list(filter(lambda x: x in arr1, arr2))
print ("Intersection of arr1 & arr2 is: ",values)

# Driver program
if __name__ == "__main__":
   arr1 = ['t','u','t','o','r','i','a','l']
   arr2 = ['p','o','i','n','t']
   interSection(arr1,arr2)
Intersection of arr1 & arr2 is: ['o', 'i', 't']
In this article, we learned about the intersection of two arrays in Python with the help of Lambda expression and filter function and its implementation.