code-rag-bench/online-tutorials huggingface dataset:
How to GROUP BY in a select query on positive or negative values?

Following is the syntax to GROUP BY in a select query on positive or negative values:
select *from yourTableName group by -yourColumnName;
Let us first create a table:
mysql> create table DemoTable (Value int);
Query OK, 0 rows affected (0.60 sec)
Following is the query to insert some records in the table using insert command:
mysql> insert into DemoTable values(-10);
Query OK, 1 row affected (0.20 sec)
mysql> insert into DemoTable values(-20);
Query OK, 1 row affected (0.10 sec)
mysql> insert into DemoTable values(20);
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable values(10);
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable values(-10);
Query OK, 1 row affected (0.15 sec)
mysql> insert into DemoTable values(-10);
Query OK, 1 row affected (0.19 sec)
mysql> insert into DemoTable values(-20);
Query OK, 1 row affected (0.16 sec)
mysql> insert into DemoTable values(-30);
Query OK, 1 row affected (0.07 sec)
mysql> insert into DemoTable values(30);
Query OK, 1 row affected (0.12 sec)
Following is the query to display records from the table using select command:
mysql> select *from DemoTable;
This will produce the following output
+-------+
| Value |
+-------+
|   -10 |
|   -20 |
|    20 |
|    10 |
|   -10 |
|   -10 |
|   -20 |
|   -30 |
|    30 |
+-------+
9 rows in set (0.00 sec)
Following is the query to group by positive and negative values:
mysql> select *from DemoTable group by -Value;
This will produce the following output
+-------+
| Value |
+-------+
|   -10 |
|   -20 |
|    20 |
|    10 |
|   -30 |
|    30 |
+-------+
6 rows in set (0.00 sec)
Tryit Editor v3.7

Tryit: HTML image - size attributes or style?
HTML DOM childElementCount Property

The HTML DOM childElementCount property is a read-only property that returns the number of child elements of a given element. The return type of the childElementCount is of unsigned long. It will only return the child element of the node on which it is queried and not all the child nodes of a HTML document.
Following is the syntax for childElementCount property −
node.childElementCount
Let us see an example for the HTML DOM childElementCount property −
<!DOCTYPE html>
<html>
<head>
<style>
   div {
      border: 2px solid blue;
      margin: 7px;
      padding-left:20px;
   }
</style>
</head>
<body>
<p>Click the button below to find out the no of children of the div element</p>
<button onclick="childCount()">COUNT</button>
<div id="myDIV">
<h3>HEADING</h3>
<p>First p element</p>
<p>Second p element</p>
</div>
<p id="Sample"></p>
<script>
   function childCount() {
      var x = document.getElementById("myDIV").childElementCount;
      document.getElementById("Sample").innerHTML = "The div element has "+x+" children";
   }
</script>
</body>
</html>
This will produce the following output −
On clicking the COUNT button −
In the above example −
We have created a <div> element with id “myDIV” and three elements inside it. Two <p> elements and a <h3> header. We have also added colored border, margin and padding to the div to distinguish it from other elements −
div {
   border: 2px solid blue;
   margin: 7px;
   padding-left:20px;
}
<div id="myDIV">
<h3>HEADING</h3>
<p>First p element</p>
<p>Second p element</p>
</div>
We have then created a button COUNT which will execute the childCount() method on click.
<button onclick="childCount()">COUNT</button>
The childCount() method takes the element with id “myDIV”, which in our case is the <div>, element and assigns its childElementCount property value to variable x. Since we have two<p> elements and a <h3> element inside the <div>, so the childElementCount returned 3.
The value returned is then displayed in the paragraph with id “Sample” using the innerHTML() method on the paragraph −
function childCount() {
   var x = document.getElementById("myDIV").childElementCount;
   document.getElementById("Sample").innerHTML = "The div element has "+x+" children";
}
How to call a static constructor or when static constructor is called in C#?

Static constructor are called automatically before the first instance is created or any static members are referenced.
A static constructor is used to initialize any static data, or to perform a particular action that needs to be performed once only.
In c#, only one static constructor is allowed to create
Static constructors have the following properties −
A static constructor does not take access modifiers or have parameters.
A static constructor does not take access modifiers or have parameters.
A class or struct can only have one static constructor.
A class or struct can only have one static constructor.
Static constructors cannot be inherited or overloaded.
Static constructors cannot be inherited or overloaded.
A static constructor cannot be called directly and is only meant to be called by the common language runtime (CLR). It is invoked automatically.
A static constructor cannot be called directly and is only meant to be called by the common language runtime (CLR). It is invoked automatically.
The user has no control on when the static constructor is executed in the program.
class Program{
   static Program(){
      // Your Code
   }
   static void Main(){
      Console.ReadLine();
   }
}
GATE | GATE-CS-2015 (Set 2) | Question 65 - GeeksforGeeks

28 Jun, 2021
Host A sends a UDP datagram containing 8880 bytes of user data to host B over an Ethernet LAN. Ethernet frames may carry data up to 1500 bytes (i.e. MTU = 1500 bytes). Size of UDP header is 8 bytes and size of IP header is 20 bytes. There is no option field in IP header. How may total number of IP fragments will be transmitted and what will be the contents of offset field in the last fragment?(A) 6 and 925(B) 6 and 7400(C) 7 and 1110(D) 7 and 8880Answer: (C)Explanation:
UDP data = 8880 bytes
UDP header = 8 bytes
IP Header = 20 bytes

Total Size excluding IP Header = 8888 bytes.

Number of fragments  = ⌈ 8888 / 1480 ⌉ 
                     = 7
Refer the Kurose book slides on IP (Offset is always scaled by 8)

Offset of last segment = (1480 * 6) / 8 = 1110 
Quiz of this Question
GATE-CS-2015 (Set 2)
GATE-GATE-CS-2015 (Set 2)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | Gate IT 2007 | Question 25
GATE | GATE-CS-2000 | Question 41
GATE | GATE-CS-2001 | Question 39
GATE | GATE-CS-2005 | Question 6
GATE | GATE MOCK 2017 | Question 21
GATE | GATE-CS-2006 | Question 47
GATE | GATE MOCK 2017 | Question 24
GATE | Gate IT 2008 | Question 43
GATE | GATE-CS-2009 | Question 38
GATE | GATE-CS-2003 | Question 90
How to save a plot as SVG created with ggplot2 in R?

There are multiple ways to save a plot created in R. Base R provides, metafile, bitmap, and postscript options to copy and save the plots created in R but we can also save the plots created with ggplot2 as an SVG file with the help of svglite package. The ggsave function of svglite package does this job easily and we can also define the height and width of the plot inside this function.
 Live Demo
Install the svglite package −
install.packages("svglite")
Consider the ToothGrowth data and create a scatterplot between len and dose −
head(ToothGrowth)
  len supp dose
1  4.2 VC  0.5
2 11.5 VC  0.5
3  7.3 VC  0.5
4  5.8 VC  0.5
5  6.4 VC  0.5
6 10.0 VC  0.5
library(ggplot2)
library(svglite)
ScatterPlotImage<-ggplot(ToothGrowth,aes(len,dose))+geom_point(size=3)
ScatterPlotImage
ggsave(file="Scatter.svg", plot=ScatterPlotImage, width=10, height=10)
This plot will be saved as an SVG in the default folder for your R version as shown above.
How to resolve unhandled exceptions in Node.js ?

20 May, 2020
There are two approaches to resolve unhandled exceptions in Node.js that are discussed below:
Approach 1: Using try-catch block: We know that Node.js is a platform built on JavaScript runtime for easily building fast and scalable network applications. Being part of JavaScript, we know that the most prominent way to handle the exception is we can have try and catch block.
Example:
try {          // The synchronous code that    // we want to catch thrown    // errors on    var err = new Error('Hello')    throw err} catch (err) {          // Handle the error safely    console.log(err)}
Note: However, be careful not to use try-catch in asynchronous code, as an asynchronously thrown error will not be caught.
try {    setTimeout(function() {        var err = new Error('Hello')        throw err    }, 1000)}catch (err) {          // Example error won't be caught    // here... crashing our application    // hence the need for domains}
Approach 2: Using Process: A good practice says, you should use Process to handle exception. A process is a global object that provides information about the current Node.js process. The process is a listener function that is always listening to the events.Few events are:
Disconnect
Exit
Message
Multiple Resolves
Unhandled Exception
Rejection Handled
Uncaught Exception
Warning
The most effective and efficient approach is to use Process. If any uncaught or unhandled exception occurs in your code flow, that exception will be caught in code shown below:
Example:
process.on('uncaughtException', function(err) {      // Handle the error safely    console.log(err)})
The above code will be able to handle any sort of unhandled exception which occurs in Node.js.
Node.js-Misc
Picked
Node.js
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
8085 program to exchange content of HL register pair with DE register pair

In this program we will see how to exchange the content of DE and HL pair.
Write 8085 Assembly language program to swap the content of HL and DE register pair.
This process is very simple, 8085 has XCHG instruction. This instruction swaps DE and HL pair content. We are storing some values to DE and HL pair directly, and then exchange them using XCHG.
DE = 5678H
HL = CDEFH
DE = CDEFH
HL = 5678H
Java switch statement with multiple cases.

Following is the required program.
Live Demo
public class Test {
   public static void main(String args[]) {
      // char grade = args[0].charAt(0); char grade = 'C'; switch(grade) {
         case 'A' : System.out.println("Excellent!"); break;
         case 'B' :
         case 'C' : System.out.println("Well done");
         break;
         case 'D' : System.out.println("You passed");
         case 'F' : System.out.println("Better try again");
         break;
         default : System.out.println("Invalid grade");
      }
      System.out.println("Your grade is " + grade);
   }
}
Compile and run the above program using various command line arguments. This will produce the following result −
Well done
Your grade is C
How to center align text in table cells in HTML?

To center align text in table cells, use the CSS property text-align. The <table> tag align attribute was used before, but HTML5 deprecated the attribute. Do not use it. So, use CSS to align text in table cells. The text-align will be used for the <td> tag.
We’re using the style attribute for adding CSS. The style attribute specifies an inline style for an element. The attribute is used with the HTML <td> tag, with the CSS property text-align. HTML5 do not support the align tag,
Just keep in mind, the usage of style attribute overrides any style set globally. It will override any style set in the HTML <style> tag or external style sheet.
For text-align, set the table cell as left, right or center align
You can try to run the following code to center align text in table cells in HTML
<!DOCTYPE html>
<html>
   <head>
      <style>
         table, td, th {
            border: 1px solid black;
            width: 300px;
         }
      </style>
   </head>
   <body>
      <h1>Our Technologies</h1>
      <table>
         <tr>
            <th>IDE</th>
            <th>Database</th>
         </tr>
         <tr>
            <td style="text-align:center">NetBeans</td>
            <td style="text-align:center">MySQL</td>
         </tr>
      </table>
   </body>
</html>
Insertion Sort in Python Program

In this article, we will learn about the implementation of Insertion sort in Python 3.x. Or earlier.
Iterate over the input elements by growing the sorted array at each iteration.
Iterate over the input elements by growing the sorted array at each iteration.
Compare the current element with the largest value available in the sorted array.
Compare the current element with the largest value available in the sorted array.
If the current element is greater, then it leaves the element in its place and moves on to the next element else it finds its correct position in the sorted array and moves it to that position in the array.
If the current element is greater, then it leaves the element in its place and moves on to the next element else it finds its correct position in the sorted array and moves it to that position in the array.
This is achieved by shifting all the elements towards the right, which are larger than the current element, in the sorted array to one position ahead.
This is achieved by shifting all the elements towards the right, which are larger than the current element, in the sorted array to one position ahead.
Now let’s see the visual representation of the algorithm
Now let’s see the implementation
def insertionSort(arr):
   for i in range(1, len(arr)):
      key = arr[i]
      # Move elements of arr[0..i-1], that are greater
      than key,
      # to one position ahead of their current position
      j = i-1
      while j >=0 and key < arr[j] :
         arr[j+1] = arr[j]
         j -= 1
      arr[j+1] = key
# main
arr = ['t','u','t','o','r','i','a','l']
insertionSort(arr)
print ("The sorted array is:")
for i in range(len(arr)):
   print (arr[i])
The sorted array is:
a
i
l
o
r
t
t
u
Time Complexity: O(n*2)
Auxiliary Space: O(1)
All the variables are declared in the global frame as shown in the figure below −
In this article, we learnt about the Insertion sort and its implementation in Python 3.x. or earlier.
How and why to avoid global variables in JavaScript?

Avoid global variables or minimize the usage of global variables in JavaScript. This is because global variables are easily overwritten by other scripts. Global Variables are not bad and not even a security concern, but it shouldn’t overwrite values of another variable.
On the usage of more global variables in our code, it may lead to a maintenance issue. Let’s say we added a variable with the same name. In that case, get ready for some serious bugs.
To avoid the usage of global variables, use the local variables and wrap your code in closures. You can also avoid this by wrapping the variables with json −
var wrapperDemo= {
   x:5,
   y:function(myObj){
   }
};
Above, if you want to call x, then call it using −
wrapperDemo.
Set user variable from result of query in MySQL?

To set user variable from result of query in MySQL, you need to move that variable into the assignment.
To understand the above concept, let us first create a table. The query to create a table is as follows −
mysql> create table UserVariable
   -> (
   -> Id int,
   -> Name varchar(100)
   -> );
Query OK, 0 rows affected (0.53 sec)
Insert some records in the table using insert command. The query is as follows −
mysql> insert into UserVariable values(101,'John');
Query OK, 1 row affected (0.17 sec)

mysql> insert into UserVariable values(200,'Tom');
Query OK, 1 row affected (0.18 sec)

mysql> insert into UserVariable values(500,'Carol');
Query OK, 1 row affected (0.13 sec)
Display all records from the table using select command. The query is as follows −
mysql> select *from UserVariable;
+------+-------+
| Id   | Name  |
+------+-------+
|  101 | John  |
|  200 | Tom   |
|  500 | Carol |
+------+-------+
3 rows in set (0.00 sec)
Write a query with a user variable that display the records with maximum id. First, I am going to create a variable and initialize this variable by selecting maximum id from the above table. The query is as follows −
mysql> set @Maxid=(select MAX(Id) from UserVariable);
Query OK, 0 rows affected (0.00 sec)
After that, create another variable which has only name with that particular maximum id. The query is as follows −
mysql> set @Name=(select Name from UserVariable where Id=@Maxid);
Query OK, 0 rows affected (0.00 sec)
Now you can check what value is present in variable Name. The query is as follows −
mysql> select @Name;
The following is the output that displays the name with the highest Id −
+-------+
| @Name |
+-------+
| Carol |
+-------+
1 row in set (0.00 sec)
Bootstrap class pull-right

Float an element to the right with class pull-right.
You can try to run the following code to implement the pull-right class
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet">
      <script src = "/scripts/jquery.min.js"></script>
      <script src = "/bootstrap/js/bootstrap.min.js"></script>
   </head>
   <body>
      <div class = "pull-right">
         Float to right
      </div>
   </body>
</html>
Jackson Annotations - @JsonIgnore

@JsonIgnore is used at field level to mark a property or list of properties to be ignored.
import java.io.IOException;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.ObjectMapper;

public class JacksonTester {
   public static void main(String args[]){
      ObjectMapper mapper = new ObjectMapper();
      try{
         Student student = new Student(1,11,"1ab","Mark");       
         String jsonString = mapper
            .writerWithDefaultPrettyPrinter()
            .writeValueAsString(student);
         System.out.println(jsonString);
      }
      catch (IOException e) { 
         e.printStackTrace();
      }     
   }
}
class Student { 
   public int id;
   @JsonIgnore
   public String systemId;
   public int rollNo;
   public String name;

   Student(int id, int rollNo, String systemId, String name){
      this.id = id;
      this.systemId = systemId;
      this.rollNo = rollNo;
      this.name = name;
   }
}
{
   "id" : 1,
   "rollNo" : 11,
   "name" : "Mark"
}

 Print
 Add Notes
 Bookmark this page
Program to generate Pascal's triangle in Python

Suppose we have a number n. We have to generate Pascal's triangle up to n lines. The Pascal's triangle will be look like this −
The property of Pascal's triangle is the sum of each adjacent two numbers of previous row is the value of the number which is placed just below on the second row. For example, the first 10 at row 6 is sum of 4 and 6 at row 5 and second 10 is sum of two numbers 6 and 4 at row 5.
So, if the input is like n = 5, then the output will be
    1
   1 1
  1 2 1
 1 3 3 1
1 4 6 4 1
To solve this, we will follow these steps −
for i in range 0 to n+1, dofor j in range 0 to n-i, doprint one blank spaceC := 1for j in range 1 to i+1, doprint C then a single blank spaceC := quotient of (C *(i - j) / j)go to next line
for j in range 0 to n-i, doprint one blank space
print one blank space
C := 1
for j in range 1 to i+1, doprint C then a single blank spaceC := quotient of (C *(i - j) / j)
print C then a single blank space
C := quotient of (C *(i - j) / j)
go to next line
Let us see the following implementation to get better understanding −
def solve(n):
   for i in range(n+1):
      for j in range(n-i):
         print(' ', end='')

      C = 1
      for j in range(1, i+1):
         print(C, ' ', sep='', end='')
         C = C * (i - j) // j
      print()

n = 5
solve(n)
5
    1
   1 1
  1 2 1
 1 3 3 1
1 4 6 4 1
How to remove Specific Element from a Swift Array?

To remove a specific object from an element in swift, we can use multiple ways of doing it. Let’s see this in the playground with help of an example.
First, let’s create an array of String.
var arrayOfString = ["a","b","c","f"]
We’ll do it with the following methods as shown below:
Arrays in swift have a filter method, which filters the array object depending on some conditions and returns an array of new objects.
let modifiedArray = arrayOfString.filter { $0 != "f" }
print(modifiedArray)
When we run the above code, we get the following result.
Now, we’ll use the indexPath of the object to remove it from the array.
if arrayOfString.contains("c") {
   let index = arrayOfString.firstIndex(of: "c")
   arrayOfString.remove(at: index!)
   print(arrayOfString)
}
When we run the above code, we get the following result.
Let’s see one more example of both methods, with numbers.
var arry = [1,2,6,44]
let modifiedArray = arry.filter { $0 != 6 }
print(modifiedArray)
if arry.contains(1) {
   let index = arry.firstIndex(of: 1)
   arry.remove(at: index!)
   print(arry)
}
We get the following output when we run the above code.
Sort an arrays of 0’s, 1’s and 2’s using C++

Given an array of 0, 1, and 2, sort the elements in an order such that all the zeros come first before 1 and all the 2’s in the end. We have to sort all the elements of the array in-place.
We can solve this problem using DNF (Dutch National Flag) Sorting Algorithm. For example,
Input-1 −
arr[ ]= {2,0,0,1,2,1 }
Output −
0 0 1 1 2 2
Explanation − Sorting the given array of elements containing 0,1 and 2 using DNF Sorting Algorithm, it will print the output as {0,0,1,1,2,2}.
Input-2 −
arr[ ]= {0,1,1,2,1,1,0}
Output −
0 0 1 1 1 1 2
Explanation − Sorting the given array of elements containing 0,1 and 2 using the DNF Sorting Algorithm, it will print the output as {0,0,1,1,1,1,2}.
In the given array of 0, 1 and 2, we can use the DNF sorting algorithm.
DNF Sorting Algorithm − The algorithm requires 3 pointers to iterate throughout the array by swapping the necessary elements.
Create a low pointer at the beginning of the array and high pointer pointing at the end of the array.
Create a low pointer at the beginning of the array and high pointer pointing at the end of the array.
Find the Midpoint of the array and create a mid pointer as well that iterates from the beginning of the array till the end.
Find the Midpoint of the array and create a mid pointer as well that iterates from the beginning of the array till the end.
If the mid-pointer of the array is ‘0’, then swap the element pointing at low. Increment the low pointer and mid pointer.
If the mid-pointer of the array is ‘0’, then swap the element pointing at low. Increment the low pointer and mid pointer.
If the mid-pointer of the array is ‘2’, then swap it with the element pointing at the high. Increment the mid pointer and decrement the high pointer.
If the mid-pointer of the array is ‘2’, then swap it with the element pointing at the high. Increment the mid pointer and decrement the high pointer.
If the mid-pointer of the array is ‘1’, then increase the mid pointer.
If the mid-pointer of the array is ‘1’, then increase the mid pointer.
 Live Demo
#include<iostream>
using namespace std;
void dnfsort(int a[], int n){
   int low= 0;
   int high= n-1;
   int mid=0;
   while(mid<=high){
      if(a[mid]==0){
         swap(a[mid],a[low]);
         mid++;
         low++;
      }
      if(a[mid]==1){
         mid++;
      }
      if(a[mid]==2){
         swap(a[mid],a[high]);
         high--;
      }
   }
}
int main(){
   int a[]= {1,0,0,2,1,1,0,0,1};
   int n= sizeof(a)/sizeof(int);
   dnfsort(a,n);
   for(int i=0;i<n;i++){
      cout<<a[i]<<" ";
   }
   return 0;
}
Running the above code will generate the output as,
0 0 0 0 1 1 1 1 2
Java Program to create rounded borders in Swing

Let us first create a Frame:
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setUndecorated(true);
Now, create rounded borders:
double x = 50;
double y = 50;

frame.setShape(new RoundRectangle2D.Double(x, y, 100, 100, 50, 50));
The following is an example to create rounded borders in Swing:
import java.awt.geom.RoundRectangle2D;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class SwingDemo extends JPanel {
   public static void main(String[] args) {
      JFrame frame = new JFrame();
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setUndecorated(true);
      double x = 50;
      double y = 50;
      frame.setShape(new RoundRectangle2D.Double(x, y, 100, 100, 50, 50));
      frame.setSize(600, 500);
      frame.setLocationByPlatform(true);
      frame.setVisible(true);
   }
}
Program to print number pattern in C

A numerical pattern is a sequence of numbers that have been created based on a rule called a pattern rule. Pattern rules can use one or more mathematical operations to describe the relationship between consecutive numbers in the sequence.
Examples for Patterns
Pattern 1
1
2 6
3 7 10
4 8 11 13
5 9 12 14 15
Pattern 2
        1
      1 2 3
    1 2 3 4 5
  1 2 3 4 5 6 7
1 2 3 4 5 6 7 8 9
  1 2 3 4 5 6 7
    1 2 3 4 5
      1 2 3
        1
Pattern 1:
i stands for rows and j stands for columns.
5 stands for making pattern for 5 Rows and Columns
Loop for each Row (i)
K is initialized to i
Loop for each Column (j)
Do the Pattern for the current Column (j)
Display the Value of K
Reinitialize the Value of K = k + 5 - j
Pattern 2:
First Row: Display 1
Second Row: Display 1,2,3
Third Row: Display 1,2,3,4,5
Fourth Row: Display 1,2,3,4,5,6,7
Fifth Row: Display 1,2,3,4,5,6,7,8,9
Display the same contents from 4th Row till First Row below the fifth Row.
/* Program to print Numeric Pattern */
#include<stdio.h>
int main(){
   int i,j,k;
   printf("Numeric Pattern 1");
   printf("\n");
   printf("\n");
   for(i=1;i<=5;i++){
      k = i;
      for(j=1;j<=i;j++){
         printf("%d ", k);
         k += 5-j;
      }
      printf("\n");
   }
   printf("\n");
   printf("Numeric Pattern 2");
   printf("\n");
   printf("\n");
   for(i = 1;i<=5;i++){
      for(j = i;j<5;j++){
         printf(" ");
      }
      for(k = 1;k<(i*2);k++){
         printf("%d",k);
      }
      printf("\n");
   }
   for(i = 4;i>=1;i--){
      for(j = 5;j>i;j--){
         printf(" ");
      }
      for(k = 1;k<(i*2);k++){
         printf("%d",k);
      }
      printf("\n");
   }
   getch();
   return 0;
}
F# Azure Functions. Creating Azure Functions in F# | by Ian Ormesher | Towards Data Science

F# is a great language and is also a good choice for programming your Azure Functions. Unfortunately, Microsoft hasn’t made it easy to implement them. It’s certainly easier than it used to be, but there’s a bit of work to get things set up at the beginning. But I would argue it’s well worth the effort!
To start you’ll need to have the Azure CLI installed on your machine. If you haven’t already got this, click on the link below:
https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest
This will enable you to use the Azure CLI from the Windows Command Line or a PowerShell prompt. I prefer the PowerShell prompt because this also gives you TAB completion.
From a PowerShell prompt type the following to get a list of the currently installed Azure templates for F#:
dotnet new --list -lang F#
You should see something like this:
First, we’ll create our project template for the Azure function from the prompt:
dotnet new func -lang F# --name AzureFunctionFSharp
This will create 4 files:
Of all the Azure Function templates available, the easiest one to use is the HttpTrigger. To create this from the prompt:
dotnet new http -lang F# --name HttpTrigger
This will create the HttpTrigger.fs
Once you’ve done all this the next step is to create the solution file in Visual Studio 2019. If you open the project file AzureFunctionFSharp.fsproj you should find almost everything you’ve added so far:
However, you’ll notice it doesn’t have our HttpTrigger.fs file! Simply add this file to the project. You also need to add the hosts.json and localhost.settings.json. For these last two files you must ensure that their Build Action is None and they are copied to the output directory if newer:
Once you’ve done that, build the project and save the solution.
I find the FSharp.Data NuGet package extremely helpful when working with F# projects. You can add this through the Manage Packages option for the project.
Having done all of this you can save this whole project as a custom template for future projects. This will save you having to go through all of this again. If you select your project in the Solution Explorer tab and then choose Export Template from the Project menu you can export this project as a future template:
The next time you want to create an F# Azure Function project you can then use the custom template you’ve created:
If everything is set up correctly, you should now be able to press F5 and debug your project. You should see something like this:
You can then use something like Postman to send a request to the REST API and see your output.
As I said at the beginning, it’s not as straightforward as creating an Azure Function in C#, but it is certainly worth the effort. Hopefully, Microsoft will continue to improve their support for F# Azure Functions and put a proper template in Visual Studio 2019 or a future version. In the meantime, this is how you can do it yourself.
How to plot magnitude spectrum in Matplotlib in Python?

To plot magintude spectrum, we can take the following steps −
Set the figure size and adjust the padding between and around the subplots.
Get random seed value.
Initialize dt for sampling interval and find the sampling frequency.
Create random data points for t.
To generate noise, get nse, r, cnse and s using numpy
Create a figure and a set of subplots, using subplots() method.
Set the title of the plot.
Plot the magnitude spectrum.
To display the figure, use show() method.
import matplotlib.pyplot as plt
import numpy as np

plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True

np.random.seed(0)

dt = 0.01 # sampling interval
Fs = 1 / dt # sampling frequency
t = np.arange(0, 10, dt)

# generate noise:
nse = np.random.randn(len(t))
r = np.exp(-t / 0.05)
cnse = np.convolve(nse, r) * dt
cnse = cnse[:len(t)]
s = 0.1 * np.sin(4 * np.pi * t) + cnse

fig, axs = plt.subplots()

axs.set_title("Magnitude Spectrum")
axs.magnitude_spectrum(s, Fs=Fs, color='C1')

plt.show()
Use LIKE % to fetch multiple values in a single MySQL query

To fetch multiple values wit LIKE, use the LIKE operator along with OR operator. Let us first create a table −
mysql> create table DemoTable1027
(
   Id int,
   Name varchar(100)
);
Query OK, 0 rows affected (1.64 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1027 values(100,'John');
Query OK, 1 row affected (0.72 sec)
mysql> insert into DemoTable1027 values(20,'Chris');
Query OK, 1 row affected (0.56 sec)
mysql> insert into DemoTable1027 values(200,'Robert');
Query OK, 1 row affected (0.84 sec)
mysql> insert into DemoTable1027 values(400,'Mike');
Query OK, 1 row affected (0.47 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable1027;
This will produce the following output −
+------+--------+
| Id   | Name   |  
+------+--------+
| 100  | John   |
| 20   | Chris  |
| 200  | Robert |
| 400  | Mike   |
+------+--------+
4 rows in set (0.00 sec)
Following is the query to use LIKE and fetch multiple records −
mysql> select *from DemoTable1027 where Id LIKE '%100%' or Id LIKE '%200%';
This will produce the following output −
+------+--------+
| Id   | Name   |
+------+--------+
| 100  | John   |
| 200  | Robert |
+------+--------+
2 rows in set (0.74 sec)
How to work with Invoke-Command Scriptblock output?

When we simply write the Invoke-Command, it shows the output on the console.
Invoke-Command -ComputerName Test1-Win2k12 -ScriptBlock {Get-Service}
It shows the output along with the computer name.
Now let's say you want to sort the output or you want to work with the output you need to store it. It is similar like we store the output in the variable but we can’t store the output inside the scriptblock and display it outside.
$ser = @()
Invoke-Command -ComputerName Test1-Win2k12 -ScriptBlock {$ser = Get-Service}
Write-Output "Services output"
$ser
You won’t get any output of the above command because Invoke-Command is known to work on the remote computer. Instead, we can use the RETURN command to return the output to the main console.
$ser = @()
Invoke-Command -ComputerName Test1-Win2k12 -ScriptBlock {$ser = Get-Service
   return $ser
}
Write-Output "Services output"
$ser
You will get the output shown in the first image. You can also store the entire output in the variable if you further want to work with the output.
$sb = Invoke-Command -ComputerName Test1-Win2k12 -ScriptBlock { Get-Service}
Write-Output "Services output"
$sb
You can also filter the above output.
$sb = Invoke-Command -ComputerName Test1-Win2k12 -ScriptBlock {Get-Service}
Write-Output "Services output"
$sb | Select Name, Status
strchr() function in C++ and its applications

In this article, we will be discussing the working, syntax, and examples of strchr() function in C++ STL.
strchr() function is an inbuilt function in C++ STL, which is defined in the <cstring> header file. strchr() function is used to find when the character first occurred in the string. This function returns the pointer to the location where the character first appeared in the string.
If the character doesn’t exist in the string the function returns the null pointer.
char* strchr( char* str, char charac );
The function accepts the following parameter(s)−
str − It is the string in which we have to look for the character.
str − It is the string in which we have to look for the character.
charac − It is the character that we want to search in the string str.
charac − It is the character that we want to search in the string str.
This function returns a pointer to the location where the character first appeared in the string. If the character is not found it returns the null pointer.
Input −
char str[] = "Tutorials Point";
char ch = ‘u’;
Output − u is present in the string.
 Live Demo
#include <iostream>
#include <cstring>
using namespace std;
int main(){
   char str[] = "Tutorials Point";
   char ch_1 = 'b', ch_2 = 'T';
   if (strchr(str, ch_1) != NULL)
      cout << ch_1 << " " << "is present in string" << endl;
   else
      cout << ch_1 << " " << "is not present in string" << endl;
   if (strchr(str, ch_2) != NULL)
      cout << ch_2 << " " << "is present in string" << endl;
   else
      cout << ch_2 << " " << "is not present in string" << endl;
   return 0;
}
b is not present in string
T is present in string
 Live Demo
#include <iostream>
#include <cstring>
using namespace std;
int main(){
   char str[] = "Tutorials Point";
   char str_2[] = " is a learning portal";
   char ch_1 = 'b', ch_2 = 'T';
   if (strchr(str, ch_1) != NULL){
      cout << ch_1 << " " << "is present in string" << endl;
   }
   else{
      cout << ch_1 << " " << "is not present in string" << endl;
   }
   if (strchr(str, ch_2) != NULL){
      cout << ch_2 << " " << "is present in string" << endl;
      strcat(str, str_2);
      cout<<"String after concatenation is : "<<str;
   }
   else{
      cout << ch_2 <<" " << "is not present in string" << endl;
   }
   return 0;
}
b is not present in string
T is present in string
String after concatenation is : Tutorials Point is a learning portal
Map a 10-bit number to 8-bit in Arduino

Mappings often have to be performed in Arduino for a variety of reasons. One example would be mapping the 10-bit ADC output to 8-bit to save on storage. A 10-bit number would occupy 2-bytes for storage, whereas an 8-bit number would occupy just one byte and still preserve most of the information of the 10-bit number.
Arduino has a readymade map() function for achieving this.
map(value, fromLow, fromHigh, toLow, toHigh)
where, value is the value to be mapped; fromLow and fromHigh are the bounds of the range of the current value; toHigh and toLow are the bounds of the range of the new value.
Thus, if I need to map a 10-bit number to 8-bit number,
map(value, 0, 1023, 0, 255)
This is because a 10-bit number’s minimum value is 0, and maximum is 1023. For an 8-bit number, the min and max values are 0 and 255 respectively.
What you can notice from the syntax is that you can use this function to map a number from any range to any new range. You need not restrict yourself to powers of 2.
The following example illustrates the use of this function −
void setup() {
   // put your setup code here, to run once:
   Serial.begin(9600);
   Serial.println();

   int a = 200;
   Serial.println(map(a,0,500,0,1000));
   Serial.println(map(a,0,1023,0,255));
}

void loop() {
   // put your main code here, to run repeatedly:
}
The Serial Monitor output is −
As you can see, this function can be used for both up-scaling and down-scaling a given number. First, we upscaled the number 200 from the (0,500) range to (0,1000) range. As expected, the function returned 400. In the second case, we down-scaled 200 from (0,1023) range to (0,255) range. The function returned 49, which matches the integer part of 200*255/1023 (=49.85).
You can refer to Arduino’s documentation for more information related to this function: − https://www.arduino.cc/reference/en/language/functions/math/map/
How to create transparent widgets using Tkinter?

A Tkinter widget in an application can be provided with Transparent background. The background property of any widget is controlled by the widget itself.
However, to provide a transparent background to a particular widget, we have to use wm_attributes('transparentcolor', 'colorname') method. It works in the widget only after adding the same transparent color as the background color of the widget.
#Import the required libraries
from tkinter import *

#Create an instance of Tkinter Frame
win = Tk()

#Set the geometry
win.geometry("700x250")

#Adding transparent background property
win.wm_attributes('-transparentcolor', '#ab23ff')

#Create a Label
Label(win, text= "This is a New line Text", font= ('Helvetica 18'), bg= '#ab23ff').pack(ipadx= 50, ipady=50, padx= 20)

win.mainloop()
When we compile the above code, it will display a window with a Label widget in transparent background.
Unity - The Slider

In this chapter, we will learn about the last UI element in this series. The Slider is commonly used where a certain value should be set between a maximum and minimum value pair. One of the most common usage of this is for audio volume, or screen brightness.
To create a slider, go to Create → UI → Slider. A new Slider element should show up on your scene.
If you go to the properties of this Slider, you will notice a ist of options to customize it.
Let us try to make a volume slider out of this slider. For this, open the ButtonBehaviour script (you can rename the ButtonManager GameObject as it is certainly doing more than just managing a button now) and add a reference to the Slider. We will also change the code around a bit again.
public class ButtonBehaviour : MonoBehaviour {
   int n;
   public Text myText;
   public Slider mySlider;
   void Update() {
      myText.text = "Current Volume: " + mySlider.value;
   }
}
Understand how we are using the Update method to constantly update the value of myText.text.
In the slider properties, let us check the “Whole Numbers” box, and set the maximum value to 100.
We will set the color of the text through its properties for a more visible color.
Let us follow the same procedure of dragging the Slider GameObject onto the new slot, and hit play.
It is highly recommended you explore and experiment with the other UI controls as well, to see which ones work in which way.
In our subsequent section, we will learn about lighting, materials and shaders.

    119 Lectures 
     23.5 hours 

 Raja Biswas

    58 Lectures 
     10 hours 

 Three Millennials

    16 Lectures 
     1 hours 

 Peter Jepson

    23 Lectures 
     2.5 hours 

 Zenva

    21 Lectures 
     2 hours 

 Zenva

    43 Lectures 
     9.5 hours 

 Raja Biswas
 Print
 Add Notes
 Bookmark this page
SQL Tryit Editor v1.6

SELECT CustomerName,City FROM Customers;
​
Edit the SQL Statement, and click "Run SQL" to see the result.
This SQL-Statement is not supported in the WebSQL Database.
The example still works, because it uses a modified version of SQL.
Your browser does not support WebSQL.
Your are now using a light-version of the Try-SQL Editor, with a read-only Database.
If you switch to a browser with WebSQL support, you can try any SQL statement, and play with the Database as much as you like. The Database can also be restored at any time.
Our Try-SQL Editor uses WebSQL to demonstrate SQL.
A Database-object is created in your browser, for testing purposes.
You can try any SQL statement, and play with the Database as much as you like. The Database can be restored at any time, simply by clicking the "Restore Database" button.
WebSQL stores a Database locally, on the user's computer. Each user gets their own Database object.
WebSQL is supported in Chrome, Safari, Opera, and Edge(79).
If you use another browser you will still be able to use our Try SQL Editor, but a different version, using a server-based ASP application, with a read-only Access Database, where users are not allowed to make any changes to the data.
close driver method - Selenium Python - GeeksforGeeks

15 May, 2020
Selenium’s Python Module is built to perform automated testing with Python. Selenium Python bindings provides a simple API to write functional/acceptance tests using Selenium WebDriver. To open a webpage using Selenium Python, checkout – Navigating links using get method – Selenium Python. Just being able to go to places isn’t terribly useful. What we’d really like to do is to interact with the pages, or, more specifically, the HTML elements within a page. There are multiple strategies to find an element using Selenium, checkout – Locating Strategies. Selenium WebDriver offers various useful methods to control the session, or in other words, browser. For example, adding a cookie, pressing back button, navigating among tabs, etc.
This article revolves around close driver method in Selenium. close method is used to close the current window of browser.
Syntax –
driver.close()
Example –Now one can use close method as a driver method as below –
diver.get("https://www.geeksforgeeks.org/")
driver.close()

To demonstrate, close method of WebDriver in Selenium Python. Let’ s visit https://www.geeksforgeeks.org/ and operate on driver object.
Program –
# import webdriverfrom selenium import webdriver  # create webdriver objectdriver = webdriver.Firefox()  # get geeksforgeeks.orgdriver.get("https://www.geeksforgeeks.org/")  # close current windowdriver.close()
Output –Browser gets closed as verified below –
Python-selenium
selenium
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | os.path.join() method
Create a directory in Python
Defaultdict in Python
Python | Pandas dataframe.groupby()
Python | Get unique values from a list
How to Add a TextView with Rounded Corner in Android?

18 Feb, 2021
TextView is an essential object of an Android application. It comes in the list of some basic objects of android and used to print text on the screen. In order to create better apps, we should learn that how can we create a TextView which have a background with rounded corners. We can implement this skill in a practical manner for any android application. For creating professional-looking user interfaces, we need to take care of these small things. 
In this article, You will be learning how to create a TextView with Rounded Corners. First of all, we need to create a drawable resource file, which has a proper definition to make TextView corners rounded, and then we have to add a background attribute to that special TextView object. Let’s do it in steps!
Step 1: Create a new android studio project, and select an empty activity. You can also refer to this GFG Tutorial for Creating a new android studio project.
Step 2: Make sure that you have selected the Android option for project structure on the top left corner of the screen, then go to the res/drawable folder.
Step 3: Here right-click on the drawable folder and click on new and select drawable resource file. Give it a name of your choice, we are giving it rounded_corner_view.
Note: In android studio you can’t give a name of a resource file (Layout file, Color File, Image File, or any XML file) in uppercase and camelCase, you have to follow the lowercase letters only and it’s a good habit to use lowercase letters with underscores in place of spaces. 
Step 4: Now in the drawable resource file, which you have just created, remove all the default code and paste the following code.
XML
<?xml version="1.0" encoding="utf-8"?>  <shape     xmlns:android="http://schemas.android.com/apk/res/android"    android:shape="rectangle">      <corners android:radius="10dp" />          <!-- This is the border color -->    <stroke android:width="2dp" android:color="#ccc" />        <!--- This is the background color -->      <solid android:color="#ccc" />   </shape>
Step 5: Now go to the activity_main.xml file and add an attribute to that TextView, for which you want to add rounded corners. The attribute is android: background=”@drawable/rounded_corner_view”.
Tip: Don’t forget to replace your drawable resource file name if you have given a different name and you don’t need to add xml extension after file name.
android
Android-View
Android
Android
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Input in C++

01 Feb, 2021
The cin object in C++ is used to accept the input from the standard input device i.e., keyboard. it is the instance of the class istream. It is associated with the standard C input stream stdin. The extraction operator(>>) is used along with the object cin for reading inputs. The extraction operator extracts the data from the object cin which is entered using the keyboard.
Program 1:
Below is the C++ program to implement cin object to take input from the user:
C++
// C++ program to demonstrate the// cin object#include <iostream>using namespace std;  // Driver Codeint main(){    int i;      // Take input using cin    cin >> i;      // Print output    cout << i;      return 0;}
Input:
Output:
Note: Multiple inputs can also be taken using the extraction operators(>>) with cin.
Program 2:
Below is the C++ program to implement multiple inputs from the user:
C++
// C++ program to demonstrate the taking// multiple inputs from the user#include <iostream>using namespace std;  // Driver Codeint main(){    string name;    int age;      // Take multiple input using cin    cin >> name >> age;      // Print output    cout << "Name : " << name << endl;    cout << "Age : " << age << endl;      return 0;}
Input:
Output:
cpp-input-output
Input and Output
Input Output Systems
Picked
C++
C++ Programs
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.