code-rag-bench/online-tutorials huggingface dataset:
Functions that are executed before and after main() in C - GeeksforGeeks

28 May, 2017
With GCC family of C compilers, we can mark some functions to execute before and after main(). So some startup code can be executed before main() starts, and some cleanup code can be executed after main() ends. For example, in the following program, myStartupFun() is called before main() and myCleanupFun() is called after main().
#include<stdio.h>  /* Apply the constructor attribute to myStartupFun() so that it    is executed before main() */void myStartupFun (void) __attribute__ ((constructor));    /* Apply the destructor attribute to myCleanupFun() so that it   is executed after main() */void myCleanupFun (void) __attribute__ ((destructor));    /* implementation of myStartupFun */void myStartupFun (void){    printf ("startup code before main()\n");}  /* implementation of myCleanupFun */void myCleanupFun (void){    printf ("cleanup code after main()\n");}  int main (void){    printf ("hello\n");    return 0;}
Output:
startup code before main()
hello
cleanup code after main()

Like the above feature, GCC has added many other interesting features to standard C language. See this for more details.
Related Article :Executing main() in C – behind the scene
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
C-Functions
C Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Substring in C++
Multidimensional Arrays in C / C++
Left Shift and Right Shift Operators in C/C++
Converting Strings to Numbers in C/C++
Function Pointer in C
Core Dump (Segmentation fault) in C/C++
rand() and srand() in C/C++
std::string class in C++
fork() in C
Command line arguments in C/C++
How to select text nodes using jQuery ? - GeeksforGeeks

15 Nov, 2019
Text nodes are a type of node that denotes the actual text inside an element. The textNodes of any element can be selected using jQuery by selecting all the nodes and using the filter() method to check the nodeType property.
The required element is first selected using the jQuery selector. The contents() method is used on selected elements. This method is used to return the direct children of an element including all the text and comment nodes.
The filter() method is used on these returned elements to filter only the text nodes required. The custom filter function checks if the nodeType property of the nodes return equal to the Node.TEXT_NODE value.
The “Node.TEXT_NODE” value is used to identify a text node from other nodes. Alternatively, the integer value “3” could also be used to identify a text node. The filter() method will now only return the nodes that are textNodes. Therefore this method can be used to select the textNodes of any element.
Syntax:
selectedElement = $("elementRequired").contents(); textNodes = selectedElement.filter(function () {  return this.nodeType === Node.TEXT_NODE;});
Example:
<!DOCTYPE html><html>      <head>    <title>        How to select text nodes using jQuery?    </title>          <script src=        "https://code.jquery.com/jquery-3.3.1.min.js">    </script></head>  <body>    <h1 style="color: green">        GeeksforGeeks    </h1>          <b>        How to select text nodes using jQuery?    </b>          <p class="example">        This is line 1<br>        This is line 2<br>        This is line 3    </p>          <button onclick="getTextNodes()">        Click to get Text Nodes    </button>          <script type="text/javascript">        function getTextNodes() {            selectedElement = $(".example").contents();                      textNodes = selectedElement.filter(function ()            {                return this.nodeType === Node.TEXT_NODE;            });                          console.log(textNodes);        }    </script></body>  </html>
Output:
Display:
Console:
jQuery-Misc
Picked
JQuery
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
jQuery | children() with Examples
How to Show and Hide div elements using radio buttons?
How to prevent Body from scrolling when a modal is opened using jQuery ?
How to redirect to a particular section of a page using HTML or jQuery?
jQuery | ajax() Method
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 ?
How to insert spaces/tabs in text using HTML/CSS?
Vue.js | v-show directive - GeeksforGeeks

22 Jun, 2020
The v-show directive is a Vue.js directive used to toggle the display CSS property of a element with our data. If the data is true it will make it visible else it will make it invisible. First, we will create a div element with id as app and let’s apply the v-show directive to this element with data as a message. Now we will create this message by initializing a Vue instance with the data attribute containing either true or false.Syntax:
v-show="data"
Parameters: This directive accepts a single parameter which is the data. Example 1: This example uses VueJS to show an element with v-show.
HTML
<!DOCTYPE html><html>    <head>        <title>            VueJS | v-show directive        </title>          <!-- Load Vuejs -->        <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js">        </script>    </head>      <body>        <div style="text-align: center; width: 600px;">            <h1 style="color: green;">                GeeksforGeeks            </h1>            <b>                VueJS | v-show directive            </b>        </div>          <div id="canvas" style="border: 1px solid #000000;                                width: 600px; height: 200px;">            <div v-show="message" id="app">                Hello I'm visible.            </div>        </div>          <script>            var app = new Vue({                el: "#app",                data: {                    message: true,                },            });        </script>    </body></html>
Output:
Example 2: This example uses VueJS to hide an element with v-show.
HTML
<!DOCTYPE html><html>  <head>    <title>        VueJS | v-show directive    </title>      <!-- Load Vuejs -->    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js">    </script></head>  <body>    <div style="text-align: center;width: 600px;">        <h1 style="color: green;">            GeeksforGeeks        </h1>        <b>            VueJS | v-show directive        </b>    </div>      <div id="canvas" style="border:1px solid #000000;                            width: 600px;height: 200px;">        <div v-show="message" id="app">            Hello I'm invisible.        </div>    </div>      <script>        var app = new Vue({            el: '#app',            data: {                message: false            }        })    </script></body>  </html>
Output:
Vue.JS
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
How to append HTML code to a div using JavaScript ?
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 ?
How to insert spaces/tabs in text using HTML/CSS?
JavaScript String with Quotes

31 Oct, 2021
Strings are the sequence of characters, symbols, and numbers. In JavaScript, the user can write strings either in ‘single quote‘ or in “double quote“. However, both print the same result on the terminal.
'GeeksforGeeks' === "GeeksforGeeks"
In some cases, users may need to print some part of the string with the quotes. For example, I’m, Hello “Geeks”, or It’s an apple, etc. In this situation, users have to use the single quote and double quote carefully. In this tutorial, the user will learn to write the string with quotation marks.
How simple string works in JavaScript?
As mentioned in the above section, the user gets the same output either it writes the string in a single quote or double quote. Users can see the example code below.
Example:
Javascript
<script>// String with double quotesvar string1 = "Hello Geeks!!!"  // String with single quotesvar string2 = 'You are on GeeksforGeeks!'  console.log(string1)console.log(string2)</script>
Output:
Hello Geeks!!!
You are on GeeksforGeeks!
How user can add the quotes inside the string?
There are several ways to write a string with a quotation mark. 
Approach 1: One can use the backslash (\) inside the string to escape from the quotation mark. They will need to follow the below example to follow this method.
Syntax:
var string = "I\'m user of GeeksForGeeks."
 
Example:
Javascript
<script>var string1 = "I\'m user of GeeksForGeeks."var string2 = 'I\'m user of GeeksForGeeks.'var string3 = 'Hello \'Geeks\''var string4 = "Hello \'Geeks\'"  console.log(string1)console.log(string2)console.log(string3)console.log(string4)</script>
Output:
I'm user of GeeksForGeeks.
I'm user of GeeksForGeeks.
Hello 'Geeks'
Hello 'Geeks'
Approach 2: One can write strings using alternative quotes. Users need to use single quotes inside the string if they have written string in double quotes and vice-versa.
Syntax:
var string1 = "Hello 'Geeks'"
var strign2 = 'Hello "Geeks"'
Example:
Javascript
<script>var string1 = "I'm user of GeeksForGeeks."var string2 = 'I"m user of GeeksForGeeks.'var string3 = 'Hello "Geeks"'var string4 = "Hello 'Geeks'"  console.log(string1)console.log(string2)console.log(string3)console.log(string4)</script>
Output:
I'm user of GeeksForGeeks."
I"m user of GeeksForGeeks.'
Hello "Geeks"
Hello 'Geeks'
JavaScript-Questions
javascript-string
Picked
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
Roadmap to Learn JavaScript For Beginners
Difference Between PUT and PATCH Request
JavaScript | Promises
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
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 ?
Select top in MS SQL Server

09 Jul, 2020
Prerequisite – Select in MS SQL ServerSuppose that a user wants to extract the top students from the whole institution but has to use some complex queries to extract the data. To avoid complexity, the user can use ‘Select Top’.‘Select Top’ extracts the limited number of rows. This results in accurate data along with less time consumption.
Syntax –
select top (expression) [percent] [with ties]
from table_name 
order by column_name 
Analyzing the Syntax –
Top is a keyword that extracts the data from the top of the list.
Expression is the data that is to be extracted from the table.
Percent is the number of rows that need to be extracted from the table.
With Ties returns the rows that share the same values with the last row. In some cases, more rows can be retrieved.
The order by clause is used for arranging the data in a chronological order. It is mandatory to use this clause in syntax otherwise, it results in an error.
Example –If a user wants to extract the top 5 students of an institution, the query is written as –
select top 5 name rollnumber gpa
from student 
order by name ASC

Output –
This way the desired data can be extracted. The last row student has a gpa of 7.7 and if there are a few more students that share the same numbers, the query must be written as –
select top 8 with ties
name rollnumber gpa
from student
order by name ASC

Output –
ASC arranges the data from ascending to descending order. DESC can be used if the data has to be arranged from descending to ascending order.
DBMS-SQL
mysql
DBMS
SQL
DBMS
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Perl | sprintf() Function

07 May, 2019
sprintf() function in Perl uses Format provided by the user to return the formatted string with the use of the values in the list. This function is identical to printf but it returns the formatted string instead of printing it.
Syntax: sprintf Format, List
Returns: a formatted scalar string
Example 1:
#!/usr/bin/perl -w  # Formatting the string using sprintf$text1 = sprintf("%8s", 'Geeks');$text2 = sprintf("%-8s", 'Geeks');  # Printing the formatted stringprint "$text1\n$text2";
        Geeks
Geeks        

Example 2:
#!/usr/bin/perl -w  # Formatting the string using sprintf$text1 = sprintf("%03d", '7');$text2 = sprintf("%03d", '123');$text3 = sprintf("%04d", '123');  # Printing the formatted stringprint "$text1\n$text2\n$text3";
007
123
0123

Perl-function
Perl-String-Functions
Perl
Perl
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Perl Tutorial - Learn Perl With Examples
Perl | Basic Syntax of a Perl Program
Perl | ne operator
Perl | Opening and Reading a File
Perl | Writing to a File
Perl | File Handling Introduction
Perl | Decision Making (if, if-else, Nested–if, if-elsif ladder, unless, unless-else, unless-elsif)
Perl | Multidimensional Hashes
Perl | Data Types
Perl | CGI Programming
Espionage – Network Packet And Traffic Interceptor

12 Jan, 2022
Espionage is a free and open-source tool available on GitHub. This is a free tool that can be downloaded and installed free of cost. Espionage is a network sniffer. Espionage performs sniffing on data packets of the network. Espionage is used to intercept data packets at the time when data is passed through the network interface card. Espionage can be used to analyze the network with both normal and verbose analysis. Espionage is used to reveal packet direction, protocols, flags, etc. Espionage supports all IPv4, TCP/UDP, ICMP, and HTTP protocols.  Espionage is developed in the python language. You must have python language installed in your kali Linux operating system in order to use the tool. Espionage can be used to spoof ARP.
Step 1: Use the following command to install the tool from GitHub.
git clone https://www.github.com/josh0xA/Espionage.git
Step 2: The tool has been downloaded now use the following command to install the dependencies of the tool.
sudo python3 -m pip install -r requirements.txt
Step 3: Now use the following command to run the tool.
sudo python3 espionage.py --help
The tool is running successfully.  Now we will see examples to use the tool.
Example 1: Use the espionage tool to execute a clean packet sniff and save the output to the pcap file provided by the user.
performs
The tool perform clean packet sniffing.
Example 2:  Use the espionage tool to execute a more detailed (verbose) IPV4 packet sniff.
sudo python3 espionage.py –verbose –iface wlan0 -f capture_output.pcap
The tool performs clean packet sniffing on IPV4.
adnanirshad158
Kali-Linux
Linux-Tools
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
mv command in Linux with examples
nohup Command in Linux with Examples
chmod command in Linux with examples
Introduction to Linux Operating System
Array Basics in Shell Scripting | Set 1
Basic Operators in Shell Scripting
Python PostgreSQL - Drop Table

You can drop a table from PostgreSQL database using the DROP TABLE statement.
Following is the syntax of the DROP TABLE statement in PostgreSQL −
DROP TABLE table_name;

Assume we have created two tables with name CRICKETERS and EMPLOYEES using the following queries −
postgres=# CREATE TABLE CRICKETERS (
   First_Name VARCHAR(255), Last_Name VARCHAR(255), Age int, 
   Place_Of_Birth VARCHAR(255), Country VARCHAR(255)
);
CREATE TABLE
postgres=#
postgres=# CREATE TABLE EMPLOYEE(
   FIRST_NAME CHAR(20) NOT NULL, LAST_NAME CHAR(20), 
   AGE INT, SEX CHAR(1), INCOME FLOAT
);
CREATE TABLE
postgres=#
Now if you verify the list of tables using the “\dt” command, you can see the above created tables as −
postgres=# \dt;
            List of relations
 Schema | Name       | Type  | Owner
--------+------------+-------+----------
 public | cricketers | table | postgres
 public | employee   | table | postgres
(2 rows)
postgres=#

Following statement deletes the table named Employee from the database −
postgres=# DROP table employee;
DROP TABLE

Since you have deleted the Employee table, if you retrieve the list of tables again, you can observe only one table in it.
postgres=# \dt;
            List of relations
Schema  | Name       | Type  | Owner
--------+------------+-------+----------
public  | cricketers | table | postgres
(1 row)


postgres=#

If you try to delete the Employee table again, since you have already deleted it, you will get an error saying “table does not exist” as shown below −
postgres=# DROP table employee;
ERROR: table "employee" does not exist
postgres=#

To resolve this, you can use the IF EXISTS clause along with the DELTE statement. This removes the table if it exists else skips the DLETE operation.
postgres=# DROP table IF EXISTS employee;
NOTICE: table "employee" does not exist, skipping
DROP TABLE
postgres=#

You can drop a table whenever you need to, using the DROP statement. But you need to be very careful while deleting any existing table because the data lost will not be recovered after deleting a table.
import psycopg2
#establishing the connection
conn = psycopg2.connect(database="mydb", user='postgres', password='password', host='127.0.0.1', port= '5432')

#Setting auto commit false
conn.autocommit = True

#Creating a cursor object using the cursor() method
cursor = conn.cursor()

#Doping EMPLOYEE table if already exists
cursor.execute("DROP TABLE emp")
print("Table dropped... ")

#Commit your changes in the database
conn.commit()

#Closing the connection
conn.close()
#Table dropped...


    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
C++ Array Library - at() Function

The C++ function std::array::at() returns a reference to the element present at location N in given array container.
Following is the declaration for std::array::at() function form std::array header.
reference at(size_type n);
cont_referece at(size_t n) const;
N − index of an element in the array.
Returns a element present at index N in given array if N is valid index otherwise throws out_of_range exception.
If array object is const-qualified method returns const reference otherwise it returns reference.
This member function throws out_of_range expception if value of N is not valid array index.
Constant i.e. O(1)
In below example step-1 prints array contents without exception. Step-2 shows exception handling using try-catch block.
#include <iostream>
#include <array>
#include <stdexcept>

using namespace std;

int main(void) {
   array<int, 5> arr = {10, 20, 30, 40, 50};
   size_t i;

   /* print array contents */
   for (i = 0; i < 5; ++i)
      cout << arr.at(i) << " ";
   cout << endl;

   /* generate out_of_range exception. */
   try {
      arr.at(10);
   } catch(out_of_range e) {
      cout << "out_of_range expcepiton caught for " << e.what() << endl;
   }

   return 0;
}
Let us compile and run the above program, this will produce the following result −
10 20 30 40 50 
out_of_range expcepiton caught for array::at: __n (which is 10) >= _Nm (which is 5)

 Print
 Add Notes
 Bookmark this page
Convert a String to Integer Array in C/C++

31 Aug, 2020
Given a string str containing numbers separated with “, “. The task is to convert it into an integer array and find the sum of that array.
Examples:
Input : str  = "2, 6, 3, 14"
Output : arr[] = {2, 6, 3, 14}
Sum of the array is = 2 + 6 + 3 + 14 = 25

Input : str = "125, 4, 24, 5543, 111"
Output : arr[] = {125, 4, 24, 5543, 111} 

Approach:
Create an empty array with size as string length and initialize all of the elements of array to zero.
Start traversing the string.
Check if the character at the current index in the string is a comma(,). If yes then, increment the index of the array to point to the next element of array.
Else, keep traversing the string until a ‘,’ operator is found and keep converting the characters to number and store at the current array element.To convert characters to number:arr[j] = arr[j] * 10 + (Str[i] – 48)
arr[j] = arr[j] * 10 + (Str[i] – 48)
Below is the implementation of the above idea:
// C++ program to convert a string to// integer array#include <bits/stdc++.h>using namespace std;  // Function to convert a string to// integer arrayvoid convertStrtoArr(string str){    // get length of string str    int str_length = str.length();      // create an array with size as string    // length and initialize with 0    int arr[str_length] = { 0 };      int j = 0, i, sum = 0;      // Traverse the string    for (i = 0; str[i] != '\0'; i++) {          // if str[i] is ', ' then split        if (str[i] == ',')            continue;         if (str[i] == ' '){            // Increment j to point to next            // array location            j++;        }        else {              // subtract str[i] by 48 to convert it to int            // Generate number by multiplying 10 and adding            // (int)(str[i])            arr[j] = arr[j] * 10 + (str[i] - 48);        }    }      cout << "arr[] = ";    for (i = 0; i <= j; i++) {        cout << arr[i] << " ";        sum += arr[i]; // sum of array    }      // print sum of array    cout << "\nSum of array is = " << sum << endl;}  // Driver codeint main(){    string str = "2, 6, 3, 14";      convertStrtoArr(str);      return 0;}
arr[] = 2 6 3 14 
Sum of array is = 25

Time Complexity: O(N), where N is the length of the string.
Rudragouda
Akanksha_Rai
number-theory
Traversal
Arrays
Strings
Arrays
number-theory
Strings
Traversal
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python – How to Extract all the digits from a String

When it is required to extract strings with a digit, a list comprehension and ‘isdigit’ method is used.
Below is a demonstration of the same −
my_string = "python is 12 fun 2 learn"

print("The string is : ")
print(my_string)

my_result = [int(i) for i in my_string.split() if i.isdigit()]

print("The numbers list is :")
print(my_result)
The string is :
python is 12 fun 2 learn
The numbers list is :
[12, 2]
A string is defined and is displayed on the console.
A string is defined and is displayed on the console.
A list comprehension is used to iterate over the string, and every element is checked to see if it is a digit using the ‘isdigit’ function and is converted to an integer.
A list comprehension is used to iterate over the string, and every element is checked to see if it is a digit using the ‘isdigit’ function and is converted to an integer.
These are stored in a list and assigned to a variable.
These are stored in a list and assigned to a variable.
This is the output that is displayed on the console.
This is the output that is displayed on the console.
Python – Convert 2D list to 3D at K slicing

03 Jul, 2020
Sometimes, while working with Python lists, we can have a problem in which we need to convert a 2D list to 3D, at every Kth list. This type of problem is peculiar, but can have application in various data domains. Let’s discuss certain ways in which this task can be performed.
Input : test_list = [[6, 5], [2, 3], [3, 1], [4, 6], [3, 2], [1, 6]] , K = 3Output : [[[6, 5], [2, 3], [3, 1]], [[4, 6], [3, 2], [1, 6]]]
Input : test_list = [[6, 5], [2, 3], [3, 1]] , K = 1Output : [[[6, 5]], [[2, 3]], [[3, 1]]]
Method #1 : Using loopThis is brute way in which this task can be performed. In this, we iterate through each element, and maintain a counter, at every Kth sublist, create a new list and append accordingly.
# Python3 code to demonstrate working of # Convert 2D list to 3D at K slicing# Using loop  # initializing listtest_list = [[6, 5], [2, 3], [3, 1], [4, 6], [3, 2], [1, 6]]   # printing original listprint("The original list is : " + str(test_list))  # initializing K K = 2  # Convert 2D list to 3D at K slicing# Using loopres = []subl = []cnt = 0for sub in test_list:    subl.append(sub)    cnt = cnt + 1    if cnt >= K:        res.append(subl)        subl = []        cnt = 0  # printing result print("Records after conversion : " + str(res))
The original list is : [[6, 5], [2, 3], [3, 1], [4, 6], [3, 2], [1, 6]]
Records after conversion : [[[6, 5], [2, 3]], [[3, 1], [4, 6]], [[3, 2], [1, 6]]]

 
Method #2 : Using zip() + list comprehensionThe combination of above functions can also be used to solve this problem. In this, we perform task by first chunking the values according to size and then list comprehension along with zip() is used for dimension conversion.
# Python3 code to demonstrate working of # Convert 2D list to 3D at K slicing# Using zip() + list comprehension  # initializing listtest_list = [[6, 5], [2, 3], [3, 1], [4, 6], [3, 2], [1, 6]]   # printing original listprint("The original list is : " + str(test_list))  # initializing K K = 2  # Convert 2D list to 3D at K slicing# Using zip() + list comprehensiontest_list = iter(test_list)temp = [test_list] * Kres = [list(ele) for ele in zip(*temp)]  # printing result print("Records after conversion : " + str(res))
The original list is : [[6, 5], [2, 3], [3, 1], [4, 6], [3, 2], [1, 6]]
Records after conversion : [[[6, 5], [2, 3]], [[3, 1], [4, 6]], [[3, 2], [1, 6]]]

Python list-programs
Python-list-of-lists
Python
Python Programs
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
Python | os.path.join() method
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python | Convert string dictionary to dictionary
Python Program for Fibonacci numbers
How to delete the azure blob (File) using Azure CLI in PowerShell?

To delete the Azure blob using Azure CLI, we can use “az storage blob” command with the “delete” parameter. Before running this command, we first need to make sure that the azure account is connected (az login) and the proper subscription is set (az account set).
To work with the azure storage account we need to authenticate to the storage. We can use storage key or the storage connections string. Here, we have shown how to retrieve the connections string.
$storageaccount = 'az204storage05june'
$connectionstring = az storage account show-connection-string -
n $storageaccount -otsv
The below command will delete the azure storage blob named ‘Test1.txt’ from the storage container container1.
az storage blob delete --account-name $storageaccount `
   --container-name 'container1' `
   --name 'Test1.txt' `
   --connection-string $connectionstring --verbose
NATURALINNERJOIN function

Performs an inner join of a table with another table. The tables are joined on common columns (by name) in the two tables. The two tables are to be related by one of these common columns.
If the two tables have no common column names, or if there is no relation between the two tables, an error is returned.
DAX NATURALINNERJOIN function is new in Excel 2016.
NATURALINNERJOIN (<leftJoinTable>, <rightJoinTable>)

leftJoinTable
A table expression defining the table on the left side of the join.
rightJoinTable
A table expression defining the table on the right side of the join.
A table which includes only rows for which the values in the common columns specified are present in both tables. The table returned will have the common columns from the left table and other columns from both the tables.
There is no sort order guarantee for the results.
Columns being joined on must have the same data type in both tables.
Only columns from the same source table are joined on.
Strict comparison semantics are used during join. There is no type coercion.
= SUMX (NATURALINNERJOIN (Salesperson,Sales),[Sales Amount]) 

    53 Lectures 
     5.5 hours 

 Abhay Gadiya

    24 Lectures 
     2 hours 

 Randy Minder

    26 Lectures 
     4.5 hours 

 Randy Minder
 Print
 Add Notes
 Bookmark this page
Tryit Editor v3.7

HTML form elements
Tryit: HTML select element
Playit

#myDIV {  background-color:lightblue;  transform:rotate(10deg);}
How to calculate timestamp difference in hours with MongoDB?

To calculate timestamp difference, use aggregate framework. Let us first create a collection with documents −
> db.timestampDifferenceDemo.insertOne({
   "MovieBeginningTime": new ISODate("2019-05-12 10:20:30"),
   "MovieEndingTime":new ISODate("2019-05-12 12:30:20")
});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5cd7ba1f6d78f205348bc644")
}
> db.timestampDifferenceDemo.insertOne({
   "MovieBeginningTime": new ISODate("2019-05-12 04:00:00"),
   "MovieEndingTime":new ISODate("2019-05-12 07:10:00")
});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5cd7ba3b6d78f205348bc645")
}
Following is the query to display all documents from a collection with the help of find() method −
> db.timestampDifferenceDemo.find().pretty();
This will produce the following output −
{
   "_id" : ObjectId("5cd7ba1f6d78f205348bc644"),
   "MovieBeginningTime" : ISODate("2019-05-12T10:20:30Z"),
   "MovieEndingTime" : ISODate("2019-05-12T12:30:20Z")
}
{
   "_id" : ObjectId("5cd7ba3b6d78f205348bc645"),
   "MovieBeginningTime" : ISODate("2019-05-12T04:00:00Z"),
   "MovieEndingTime" : ISODate("2019-05-12T07:10:00Z")
}
Following is the query to calculate timestamp difference in MongoDB (in hours) −
> db.timestampDifferenceDemo.aggregate([
   {$project: {
      DifferenceInHours: {$divide: [{$subtract: ["$MovieEndingTime", "$MovieBeginningTime"]}, 3600000]}
   }}
]);
This will produce the following output −
{ "_id" : ObjectId("5cd7ba1f6d78f205348bc644"), "DifferenceInHours" : 2.1638888888888888 }
{ "_id" : ObjectId("5cd7ba3b6d78f205348bc645"), "DifferenceInHours" : 3.1666666666666665 }
Ruby | Enumerable sort() function - GeeksforGeeks

05 Dec, 2019
The sort() of enumerable is an inbuilt method in Ruby returns an array which contains the enum items in a sorted order. The comparisons are done using operator or the optional block. The block must implement a comparison between a and b and return an integer less than 0 when b follows a, 0 when a and b are equivalent, or an integer greater than 0 when a follows b. The result returned is not stable. The order of the element is not stable when the comparison of two elements returns 0.
Syntax: enu.sort { |a, b| block }
Parameters: The function accepts an optional comparison block.
Return Value: It returns the an array.
Example 1:
# Ruby program for sort method in Enumerable  # Initialize enu = (1..10)  # Printsenu.sort 
Output:
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

Example 2:
# Ruby program for sort method in Enumerable  # Initialize enu = [10, 9, 8, 12, 10, 13]  # Printsenu.sort {|a, b| a <=> b}
Output:
[8, 9, 10, 10, 12, 13]

Ruby Collections
Ruby Enumerable-class
Ruby-Methods
Ruby
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Include v/s Extend in Ruby
Global Variable in Ruby
Ruby | Hash delete() function
Ruby | Case Statement
Ruby | Enumerator each_with_index function
Ruby | Array select() function
Ruby | Data Types
Ruby | Numeric round() function
Ruby For Beginners
Ruby | Decision Making (if, if-else, if-else-if, ternary) | Set - 1
How to add header row to a Pandas Dataframe?

17 Jun, 2021
A header necessarily stores the names or headings for each of the columns. It basically helps the user to identify the role of the respective column in the data frame. The top row containing column names is called the header row of the data frame. There are basically two approaches to add a header row in Python in case the original data frame doesn’t have a header.
Method 1: Creating a data frame from CSV file and creating row header
While reading the data and storing it in a data frame, or creating a fresh data frame , column names can be specified by using the names attribute of the read_csv() method. Names attribute contains an array of names for each of the columns of the data frame in order. The length of the array is equivalent to the length of this frame structure. 
Python3
# pandas package is requiredimport pandas as pd # converting csv file to data framedata_frame = pd.read_csv("test.txt", sep='\t',                         names=['Name', 'Age', 'Profession'])  # printing data frameprint("Data frame")print(data_frame) # printing row headerprint("Row header")print(list(data_frame.columns))
 Output:
We can also specify the header=none as an attribute of the read_csv() method and later on give names to the columns explicitly when desired. 
Python3
# pandas package is requiredimport pandas as pd # declaring a data frame  with three rowsand three columnsdata_frame = pd.read_csv("test.txt") # printing data frameprint("Original Data frame")print(data_frame) # adding column namesdata_frame_new = pd.read_csv("test.txt", names=['A', 'B', 'C'])print("New Data frame")print(data_frame_new) # printing row headerprint("Row header")print(list(data_frame_new.columns))
Output:
Originally, the rows are numbered by index numbers beginning from 0, in case the CSV file does not have any row header. 
Method 2: Creating a data frame and creating row header in Python itself
We can create a data frame of specific number of rows and columns by first creating a multi -dimensional array and then converting it into a data frame by the pandas.DataFrame() method. The columns argument is used to specify the row header or the column names. It contains an array of column values with its length equal to the number of columns in the data frame. 
Python3
# pandas package is requiredimport pandas as pd # declaring a data frame  with three rowsand three columnsdata = [['Mallika', 23, 'Student'], [    'Yash', 25, 'Tutor'], ['Abc', 14, 'Clerk']] # creating a pandas data framedata_frame = pd.DataFrame(data, columns=['Name', 'Age', 'Profession']) # printing data frameprint("Data frame")print(data_frame) # printing row headerprint("Row header") print(list(data_frame.columns))
 Output:
adnanirshad158
Picked
Python pandas-dataFrame
Python Pandas-exercise
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to remove a key and its value from an associative array in PHP ?

20 Sep, 2019
Given an associative array containing array elements and the task is to remove a key and its value from the associative array.
Examples:
Input : array( "name" => "Anand", "roll"=> "1")
Output : Array (
    [roll] => 1
)

Input : array( "1" => "Add", "2" => "Multiply", "3" => "Divide")
Output : Array (
    [2] => Multiply
    [3] => Divide
)

Method 1: Using unset() function: The unset() function is used to unset a key and its value in an associative array.
Syntax:
void unset( $array_name['key_to_be_removed'] )
Program:
<?php  // Declare an associative array$arr = array(     "1" => "Add",    "2" => "Multiply",    "3" => "Divide");  // Remove the key 1 and its value// from associative arrayunset($arr['1']);  // Display the array elementsprint_r($arr);  ?>
Array
(
    [2] => Multiply
    [3] => Divide
)

Method 2: Using array_diff_key() function: This function is used to get the difference between one or more arrays. This function compares the keys between one or more arrays and returns the difference between them.
Syntax:
array array_diff_key( $array_name, array_flip((array) ['keys_to_be_removed'] )
Program:
<?php  // Declare an associative array$arr = array(     "1" => "a",    "2" => "b",    "3" => "c");  // Remove the key 1 and its value// from associative array$result = array_diff_key($arr,             array_flip((array) ['1']));  // Display the resultprint_r($result);  ?>
Array
(
    [2] => b
    [3] => c
)

Picked
PHP
PHP Programs
Web Technologies
Web technologies Questions
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to fetch data from localserver database and display on HTML table using PHP ?
Difference between HTTP GET and POST Methods
Different ways for passing data to view in Laravel
PHP | file_exists( ) Function
PHP | Ternary Operator
How to call PHP function on the click of a Button ?
How to fetch data from localserver database and display on HTML table using PHP ?
PHP | Ternary Operator
How to create admin login page using PHP?
How to send an email using PHPMailer ?
Find the sum of series 3, 7, 13, 21, 31....

22 Mar, 2021
Given a number N. The task is to find the sum of below series upto nth term. 
3, 7, 13, 21, 31, ....  
Examples:  
Input : N = 3
Output : 23

Input : N = 25
Output : 5875
 
Approach:
    
Subtracting the above two equations, we have:  
Below is the implementation of the above approach: 
C++
Java
Python 3
C#
PHP
Javascript
// C++ Program to find the sum of given series #include <iostream>#include <math.h> using namespace std; // Function to calculate sumint findSum(int n){    // Return sum    return (n * (pow(n, 2) + 3 * n + 5)) / 3;} // Driver codeint main(){    int n = 25;     cout << findSum(n);     return 0;}
// Java program to find sum of// n terms of the given seriesimport java.util.*; class GFG{static int calculateSum(int n){    // returning the final sum    return (n * ((int)Math.pow(n, 2) + 3 *                               n + 5)) / 3;} // Driver Codepublic static void main(String arr[]){    // number of terms to    // find the sum    int n = 25;    System.out.println(calculateSum(n));}} // This code is contributed// by Surendra_Gangwar
# Python program to find the# sum of given series # Function to calculate sumdef findSum(n):    # Return sum    return (n*(pow(n, 2)+3 * n + 5))/3 # driver coden = 25 print(int(findSum(n)))
// C# program to find// sum of n terms of// the given seriesusing System; class GFG{static int calculateSum(int n){    // returning the final sum    return (n * ((int)Math.Pow(n, 2) + 3 *                               n + 5)) / 3;} // Driver Codepublic static void Main(){    // number of terms to    // find the sum    int n = 25;    Console.WriteLine(calculateSum(n));}} // This code is contributed// by inder_verma.
<?php// PHP Program to find the// sum of given series // Function to calculate sumfunction findSum($n){    // Return sum    return ($n * (pow($n, 2) +             3 * $n + 5)) / 3;} // Driver code$n = 25; echo findSum($n); // This code is contributed// by inder_verma?>
<script> // javascript program to find sum of// n terms of the given series   function calculateSum(n){    // returning the final sum    return (n * (parseInt(Math.pow(n, 2) + 3 *                               n + 5)) / 3);} // Driver Code// number of terms to// find the sumvar n = 25;document.write(calculateSum(n));  // This code contributed by shikhasingrajput </script>
5875
 
Time Complexity : O(1) 
SURENDRA_GANGWAR
inderDuMCA
shikhasingrajput
series
series-sum
Mathematical
School Programming
Mathematical
series
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to merge table cells in HTML ?

20 Dec, 2020
The purpose of this article is to merge table cells in HTML. It can be done by using the rowspan and colspan attribute in HTML.  The rowspan is used to merge or combine the number of cells in a row whereas the colspan is used to merge column cells in a table.  
Example 1: In this example, we will merge two table row and make a single row.
HTML
<!DOCTYPE html><html>  <head>    <style>        table,        th,        td {            border: 1px solid black;            border-collapse: collapse;            padding: 6px;        }    </style></head>  <body style="text-align:center">      <h1 style="color:green;">        GeeksforGeeks    </h1>          <h2>How to merge table cells in HTML?</h2>      <table align="center">        <tr>            <th>Name</th>            <th>Age</th>        </tr>        <tr>            <td>Akku</td>              <!-- This cell will take up                space on two rows -->            <td rowspan="2">44</td>        </tr>        <tr>            <td>fahad</td>        </tr>    </table></body>  </html>
Output:
Example 2: In this example, we will merge two table column and make a single column.
HTML
<!DOCTYPE html><html>  <head>    <style>        table,        th,        td {            border: 1px solid black;            border-collapse: collapse;            padding: 6px;            text-align: center;        }    </style></head>  <body>    <center>        <h1 style="color: green;">            GeeksforGeeks        </h1>                  <h2>            How to merge table             cells in HTML?        </h2>                  <table>            <tr>                <th>Name</tMh>                <th>Marks</th>            </tr>            <tr>                <td>Aman</td>                <td>10</td>            </tr>            <tr>                <td>riya</td>                <td>18</td>            </tr>            <!-- The last row -->              <tr>                <!-- This td will span two                     columns, that is a                     single column will take                     up the space of 2 -->                <td colspan="2">Sum: 28</td>            </tr>        </table>    </center></body>  </html>
Output:
Supported Browsers:
Google Chrome
Internet Explorer
Firefox
Safari
Opera
CSS-Misc
HTML-Misc
CSS
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Types of CSS (Cascading Style Sheet)
Design a Tribute Page using HTML & CSS
How to set space between the flexbox ?
How to position a div at the bottom of its container using CSS?
How to Upload Image into Database and Display it using PHP ?
REST API (Introduction)
Hide or show elements in HTML using display property
How to set the default value for an HTML <select> element ?
How to set input type date in dd-mm-yyyy format using HTML ?
Types of CSS (Cascading Style Sheet)
Node.js – Base64 Encoding & Decoding

The buffer object can be encoded and decoded into Base64 string. The buffer class can be used to encode a string into a series of bytes. The Buffer.from() method takes a string as an input and converts it into Base64.
The converted bytes can be changed again into String. The toString() method is used for converting the Base64 buffer back into the string format.
Buffer.from(string, [encoding])
object.toString(encoding)
The parameters are described below:
string − This input parameter takes input for the string that will be encoded into the base64 format.
encoding − This input parameter takes input for the encoding in which string will be encoded and decoded.
Create a file with the name "base64.js" and copy the following code snippet. After creating the file, use the command "node base64.js" to run this code.
 Live Demo
// Base64 Encoding Demo Example

// String data to be encoded
let string = "TutorialsPoint";

// Creating the buffer object with utf8 encoding
let bufferObj = Buffer.from(string, "utf8");

// Encoding into base64
let base64String = bufferObj.toString("base64");

// Printing the base64 encoded string
console.log("The encoded base64 string is:", base64String);
C:\home\node>> node base64.js
The encoded base64 string is: VHV0b3JpYWxzUG9pbnQ=
 Live Demo
// Base64 Encoding Demo Example

// Base64 Encoded String
let base64string = "VHV0b3JpYWxzUG9pbnQ=";

// Creating the buffer object with utf8 encoding
let bufferObj = Buffer.from(base64string, "base64");

// Decoding base64 into String
let string = bufferObj.toString("utf8");

// Printing the base64 decoded string
console.log("The Decoded base64 string is:", string);
C:\home\node>> node base64.js
The Decoded base64 string is: TutorialsPoint
Python Bokeh – Plotting a Scatter Plot on a Graph

10 Jul, 2020
Bokeh is a Python interactive data visualization. It renders its plots using HTML and JavaScript. It targets modern web browsers for presentation providing elegant, concise construction of novel graphics with high-performance interactivity.
Bokeh can be used to plot a scatter plot on a graph. Plotting squares on a graph can be done using the scatter() method of the plotting module.
Syntax : scatter(parameters)
Parameters :
x : x-coordinates of the center of the glyphs
y : y-coordinates of the center of the glyphs
marker : signifies the type of the glyph
Returns : an object of class GlyphRenderer
Example 1 : In this example we will be using the default values for plotting the graph.
# importing the modulesfrom bokeh.plotting import figure, output_file, show        # file to save the modeloutput_file("gfg.html")        # instantiating the figure objectgraph = figure(title = "Bokeh Scatter Graph")      # the points to be plottedx = [1, 2, 3, 4, 5]y = [1, 2, 3, 4, 5]     # plotting the graphgraph.scatter(x, y)      # displaying the modelshow(graph)
Output :
Example 2 : In this example we will be plotting multiple scatter points with various other parameters
# importing the modules from bokeh.plotting import figure, output_file, show from bokeh.palettes import magmaimport random  # file to save the model output_file("gfg.html")        # instantiating the figure object graph = figure(title = "Bokeh Scatter Graph")   # name of the x-axis graph.xaxis.axis_label = "x-axis"       # name of the y-axis graph.yaxis.axis_label = "y-axis"  # points to be plottedx = [n for n in range(256)]y = [random.random() + 1 for n in range(256)]size = 10  # color value of the scatter pointscolor = magma(256)  # plotting the graph graph.scatter(x, y,              size = size,              color = color)        # displaying the model show(graph)
Output :
Data Visualization
Python Bokeh-plotting-figure-class
Python-Bokeh
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.