code-rag-bench/online-tutorials huggingface dataset:
How to Read Data From Text File in Excel VBA? - GeeksforGeeks

29 Oct, 2021

VBA Program to read a Text file line by line (Sales Data) and places on a worksheet. 
Sales Data in Text File: 5 Fields [ Product, Qtr 1, Qtr 2, Qtr 3 and Qtr 4 ] and 25 Records (Incl. header)
Sales data
VBA code will read a text file and places on worksheet cells as below
Declaring variables:
    'Variable declarations
    Dim line As String, Filename As String, i As Integer, valuesArr() As String
Initialize “Filename” variable with full path and filename
    'Text file fullPath
    Filename = "D:\Excel\ReadTextFile\sales.txt" 'update your full file path
    i = 1
Open input file to read text 
    'Open file
    Open Filename For Input As #2
Read input file line by line
    'Read line by line - text file
    While Not EOF(2)
        Line Input #2, line
Split by comma and store it in valueArr().  In our example, each line has 5 values concatenated with comma.
        'split the line by comma separated, assigned in an array
        valuesArr() = Split(line, ",")
Add text to respective cells from valuesArr().  Read each item in an array by it’s index value
        Cells(i, "A").Value = valuesArr(0)
        Cells(i, "B").Value = valuesArr(1)
        Cells(i, "C").Value = valuesArr(2)
        Cells(i, "D").Value = valuesArr(3)
        Cells(i, "E").Value = valuesArr(4)
Increment counter i, to move next line.
        i = i + 1
Close while loop
    Wend
Close file
'Close file
Close #2
Approach:
Step 1: Open Excel.
Step 2: Add a shape (Read Text File) to your worksheet  .
Step 3: Right-click on “Read Text file” and “Assign Macro..”
Step 4: Select ReadTextFileLineByLine Macro
Step 5: Save your excel file as “Excel Macro-Enabled Workbook”  *.xlsm
Step 6: Click “Read Text file” 
Step 7: Adjust column width in your excel file.

Excel-VBA


Picked


Excel

Writing code in comment? 
                                    Please use ide.geeksforgeeks.org, 
                                    generate link and share the link here.
                                
Pivot Tables in Excel
How to Extract Text Only from Alphanumeric String in Excel?
How to Easily Calculate the Dot Product in Excel?
VLOOKUP Function in Excel With Examples
How to Create a Macro in Excel?
How to Calculate Relative Standard Deviation in Excel?
How to Check if the Number is Prime Number in Excel?
How to Delete a Module in Excel VBA?
How to Calculate Frequency Distribution in Excel?
Scenario Manager in Excel
aSYNcrone - SYN Flood DDoS Tool - GeeksforGeeks

28 Nov, 2021
aSYNcrone is a free and  Open source tool available on GitHub. It uses perfectly legitimate HTTP traffic. It makes a full TCP connection and then requires only a few hundred requests at long-term and regular intervals. As a result, the tool doesn’t need to send a lot of traffic to exhaust the available connections on a server. we can perform denial of service attacks using this tool. its a framework written in python .this tool  allows a single machine to take down another machine’s web server
It is an open-source tool so you can download it from GitHub for free of cost.
It uses perfectly legitimate HTTP traffic.
Denial of service attacks can be executed with the help of aSYNcrone by generating heavy traffic of botnets.
aSYNcrone sends multiple requests to the target as a result generates heavy traffic botnets.
aSYNcrone can be used to perform a DDoS attack on any webserver.
Denial of service attacks can be executed with the help of aSYNcrone by generating heavy traffic of botnets.
Step 1: Open your Kali Linux and then Open your Terminal.
git clone https://github.com/fatih4842/aSYNcrone.git
Step 2: Now use the following command to move into the directory of the tool.
cd aSYNcrone
Step 3: Now use the following command to install the tool.
gcc aSYNcrone.c -o aSYNcrone -lpthread
The tool has been downloaded successfully. Now we will see examples to use the tool.
Example 1: Use the aSYNcrone tool to perform a DDOS attack on an IP address.
DDoS
Attack has been started. This is how you can also perform a DDOS attack on a target.
Example 1: Use the aSYNcrone tool to perform a DDOS attack on an IP address.
./aSYNcrone <source port> <target IP> <target port> <thread number>
Kali-Linux
Linux-Tools
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
nohup Command in Linux with Examples
scp command in Linux with Examples
Thread functions in C/C++
mv command in Linux with examples
chown command in Linux with Examples
SED command in Linux | Set 2
Docker - COPY Instruction
Array Basics in Shell Scripting | Set 1
Basic Operators in Shell Scripting
nslookup command in Linux with Examples
Explain the variable declaration, initialization and assignment in C language

The main purpose of variables is to store data in memory. Unlike constants, it will not change during the program execution. However, its value may be changed during execution.
The variable declaration indicates that the operating system is going to reserve a piece of memory with that variable name.
The syntax for variable declaration is as follows −
type variable_name;
or
type variable_name, variable_name, variable_name;
For example,
iInt a,b;
float c;
double d;
Here, a, b, c, d are variables. The int, float, double are the data types.
The syntax for variable initialization is as follows −
data type variablename=value;
For example,
int width, height=20;
char letter='R';
float base, area; //variable declaration
double d;
/* actual initialization */
width = 10;
area = 26.5;
A variable assignment is a process of assigning a value to a variable.
For example,
int height = 40;
int base = 31;
A variable may be alphabets, digits, and underscore.
A variable may be alphabets, digits, and underscore.
A variable name can start with an alphabet, and an underscore but, can’t start with a digit.
A variable name can start with an alphabet, and an underscore but, can’t start with a digit.
Whitespace is not allowed in the variable name.
Whitespace is not allowed in the variable name.
A variable name is not a reserved word or keyword. For example, int, goto etc.
A variable name is not a reserved word or keyword. For example, int, goto etc.
Following is the C program for variable assignment −
 Live Demo
#include <stdio.h>
int main (){
   /* variable definition: */
   int a, b;
   int c;
   float f;
   /* actual initialization */
   a = 40;
   b = 50;
   c = a + b;
   printf("value of c : %d \n", c);
   return 0;
}
When the above program is executed, it produces the following result −
Value of c: 90
C# - While Loop

A while loop statement in C# repeatedly executes a target statement as long as a given condition is true.
The syntax of a while loop in C# is −
while(condition) {
   statement(s);
}

Here, statement(s) may be a single statement or a block of statements. The condition may be any expression, and true is any non-zero value. The loop iterates while the condition is true.
When the condition becomes false, program control passes to the line immediately following the loop.
Here, key point of the while loop is that the loop might not ever run. When the condition is tested and the result is false, the loop body is skipped and the first statement after the while loop is executed.
using System;

namespace Loops {
   class Program {
      static void Main(string[] args) {
         /* local variable definition */
         int a = 10;

         /* while loop execution */
         while (a < 20) {
            Console.WriteLine("value of a: {0}", a);
            a++;
         }
         Console.ReadLine();
      }
   }
} 
When the above code is compiled and executed, it produces the following result −
value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 15
value of a: 16
value of a: 17
value of a: 18
value of a: 19


    119 Lectures 
     23.5 hours 

 Raja Biswas

    37 Lectures 
     13 hours 

 Trevoir Williams

    16 Lectures 
     1 hours 

 Peter Jepson

    159 Lectures 
     21.5 hours 

 Ebenezer Ogbu

    193 Lectures 
     17 hours 

 Arnold Higuit

    24 Lectures 
     2.5 hours 

 Eric Frick
 Print
 Add Notes
 Bookmark this page
GATE | GATE-CS-2006 | Question 49

28 Jun, 2021
An implementation of a queue Q, using two stacks S1 and S2, is given below:
void insert(Q, x) {   push (S1, x);}   void delete(Q){   if(stack-empty(S2)) then       if(stack-empty(S1)) then {          print(“Q is empty”);          return;      }      else while (!(stack-empty(S1))){          x=pop(S1);          push(S2,x);      }   x=pop(S2);}
Let n insert and m (<=n) delete operations be performed in an arbitrary order on an empty queue Q. Let x and y be the number of push and pop operations performed respectively in the process. Which one of the following is true for all m and n?(A) n+m <= x < 2n and 2m <= y <= n+m(B) n+m <= x < 2n and 2m<= y <= 2n(C) 2m <= x < 2n and 2m <= y <= n+m(D) 2m <= x <2n and 2m <= y <= 2nAnswer: (A)Explanation: Same as https://www.geeksforgeeks.org/data-structures-queue-question-10/Quiz of this Question
GATE-CS-2006
GATE-GATE-CS-2006
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python program to compute arithmetic operation from String

01 Oct, 2020
Given a String with the multiplication of elements, convert to the summation of these multiplications. 
Input : test_str = ‘5×10, 9×10, 7×8’ Output : 196 Explanation : 50 + 90 + 56 = 196.
Input : test_str = ‘5×10, 9×10’ Output : 140 Explanation : 50 + 90 = 140.  
Method 1 : Using map() + mul + sum() + split()
The combination of the above functions can be used to solve this problem. In this, we perform summation using sum() and multiplication using mul(), split() is used to split elements for creating operands for multiplication. The map() is used to extend the logic to multiplication to each computation.
Python3
# importing modulefrom operator import mul  # initializing stringtest_str = '5x6, 9x10, 7x8'  # printing original stringprint("The original string is : " + str(test_str))  # sum() is used to sum the product of each computationres = sum(mul(*map(int, ele.split('x'))) for ele in test_str.split(', '))  # printing resultprint("The computed summation of products : " + str(res))
The original string is : 5x6, 9x10, 7x8
The computed summation of products : 176


Method 2 : Using eval() + replace()
In this, we convert multiplication symbol to the operator for multiplication(‘*‘), similarly, comma symbol is converted to arithmetic “+” symbol. Then eval() performs internal computations and returns the result.
Python3
# initializing stringtest_str = '5x6, 9x10, 7x8'  # printing original stringprint("The original string is : " + str(test_str))  # using replace() to create eval friendly stringtemp = test_str.replace(',', '+').replace('x', '*')  # using eval() to get the required resultres = eval(temp)  # printing resultprint("The computed summation of products : " + str(res))
The original string is : 5x6, 9x10, 7x8
The computed summation of products : 176


Python string-programs
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 | os.path.join() method
Python OOPs Concepts
How to drop one or multiple columns in Pandas Dataframe
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
Reverse a String in JavaScript

16 Apr, 2019
Given an input string and the task is to reverse the input string.
Examples:
Input: str = "Geeks for Geeks"
Output:  "skeeG rof skeeG"

Input: str = "Hello"
Output: "olleH"

There are many methods to reverse a string in JavaScript some of them are discussed below:
Method 1:
Check the input string that if given string is empty or just have one character or it is not of string type then it return “Not Valid string”.
If the above condition false create an array where we can store the result. Here revArray[] is the new array.
Loop through the array from the end to the beginning and push each and every item in the array revArray[].
Use join() prebuilt function in JavaScript to join the elements of an array into a string.
Example:
<script>function ReverseString(str) {      // Check input    if(!str || str.length < 2 ||             typeof str!== 'string') {        return 'Not valid';     }          // Take empty array revArray    const revArray = [];    const length = str.length - 1;          // Looping from the end    for(let i = length; i >= 0; i--) {        revArray.push(str[i]);    }          // Joining the array elements    return revArray.join('');}  document.write(ReverseString("Geeks for Geeks"))</script>
Output:
skeeG rof skeeG
Method 2:
Use split() inbuilt function in JavaScript to split string into array of characters i.e. [ ‘G’, ‘e’, ‘e’, ‘k’, ‘s’, ‘ ‘, ‘f’, ‘o’, ‘r’, ‘ ‘, ‘G’, ‘e’, ‘e’, ‘k’, ‘s’ ]
Use reverse() function in JavaScript to reversal the array of characters i.e. [ ‘s’, ‘k’, ‘e’, ‘e’, ‘G’, ‘ ‘, ‘r’, ‘o’, ‘f’, ‘ ‘, ‘s’, ‘k’, ‘e’, ‘e’, ‘G’ ]
Use join() function in JavaScript to join the elements of an array into a string.
Example:
<script>  // Function to reverse stringfunction ReverseString(str) {   return str.split('').reverse().join('')}  // Function call document.write(ReverseString("Geeks for Geeks"))</script>
Output:
skeeG rof skeeG
Method 3:
Use spread operator instead of split() function to convert string into array of characters i.e. [ ‘G’, ‘e’, ‘e’, ‘k’, ‘s’, ‘ ‘, ‘f’, ‘o’, ‘r’, ‘ ‘, ‘G’, ‘e’, ‘e’, ‘k’, ‘s’ ]. Learn more about the spread operator here Spread Operator
Use reverse() function in JavaScript to reversal the array of characters i.e. [ ‘s’, ‘k’, ‘e’, ‘e’, ‘G’, ‘ ‘, ‘r’, ‘o’, ‘f’, ‘ ‘, ‘s’, ‘k’, ‘e’, ‘e’, ‘G’ ]
Use join() function in JavaScript to join the elements of an array into a string.
Example:
<script>const ReverseString = str => [...str].reverse().join('');  document.write(ReverseString("Geeks for Geeks"))</script>
Output:
skeeG rof skeeG
javascript-string
JavaScript
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python program to check a sentence is a pangrams or not.

Given a sentence. Our task is to check whether this sentence is pan grams or not. The logic of Pan grams checking is that words or sentences containing every letter of the alphabet at least once. To solve this problem we use set () method and list comprehension technique.
Input: string = 'abc def ghi jkl mno pqr stu vwx yz'
Output: Yes
// contains all the characters from ‘a’ to ‘z’
Input: str='python program'
Output: No
// Does not contains all the characters from ‘a’ to 'z'

Step 1: create a string.
Step 2: Convert the complete sentence to a lower case using lower () method.
Step 3: convert the input string into a set (), so that we will list of all unique characters present in the sentence.
Step 4: separate out all alphabets ord () returns ASCII value of the character.
Step 5: If length of list is 26 that means all characters are present and sentence is Pangram otherwise not.

def checkPangram(s):
   lst = []
   for i in range(26):
      lst.append(False)
   for c in s.lower(): 
      if not c == " ":
         lst[ord(c) -ord('a')]=True
   for ch in lst:
      if ch == False:
         return False
   return True
# Driver Program 
str1=input("Enter The String ::7gt;")
if (checkPangram(str1)):
   print ('"'+str1+'"')
   print ("is a pangram")
else:
   print ('"'+str1+'"')
   print ("is not a pangram")
Enter The String ::abc def ghi jkl mno pqr stu vwx yz
"abc def ghi jkl mno pqr stu vwx yz"
is a pangram
Enter The String ::> python program
"pyhton program"
is not a pangram
Tryit Editor v3.7

Tryit: Create a full-width input field
Python 3 - String center() Method

The method center() returns centered in a string of length width. Padding is done using the specified fillchar. Default filler is a space.
Following is the syntax for center() method −
str.center(width[, fillchar])

width − This is the total width of the string.
width − This is the total width of the string.
fillchar − This is the filler character.
fillchar − This is the filler character.
This method returns a string that is at least width characters wide, created by padding the string with the character fillchar (default is a space).
The following example shows the usage of center() method.
#!/usr/bin/python3

str = "this is string example....wow!!!"
print ("str.center(40, 'a') : ", str.center(40, 'a'))
When we run above program, it produces the following result −
str.center(40, 'a') :  aaaathis is string example....wow!!!aaaa


    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
Maximum equlibrium sum in an array in C++

Given an array arr[]. Find maximum value of prefix sum which is also suffix sum for index i in arr[].
If input array is −
Arr[] = {1, 2, 3, 5, 3, 2, 1} then output is 11 as −
Prefix sum = arr[0..3] = 1 + 2 + 3 + 5 = 11 and
Suffix sum = arr[3..6] = 5 + 3 + 2 + 1 = 11
Traverse the array and store prefix sum for each index in array presum[], in which presum[i] stores sum of subarray arr[0..i]
Traverse array again and store suffix sum in another array suffsum[], in which suffsum[i] stores sum of subarray arr[i..n-1]
For each index check if presum[i] is equal to suffsum[i] and if they are equal then compare, there value with overall maximum so far
 Live Demo
#include <bits/stdc++.h>
using namespace std;
int getMaxSum(int *arr, int n) {
   int preSum[n];
   int suffSum[n];
   int result = INT_MIN;
   preSum[0] = arr[0];
   for (int i = 1; i < n; ++i) {
      preSum[i] = preSum[i - 1] + arr[i];
   }
   suffSum[n - 1] = arr[n - 1];
   if (preSum[n - 1] == suffSum[n - 1]) {
      result = max(result, preSum[n - 1]);
   }
   for (int i = n - 2; i >= 0; --i) {
      suffSum[i] = suffSum[i + 1] + arr[i];
      if (suffSum[i] == preSum[i]) {
         result = max(result, preSum[i]);
      }
   }
   return result;
}
int main() {
   int arr[] = {1, 2, 3, 5, 3, 2, 1};
   int n = sizeof(arr) / sizeof(arr[0]);
   cout << "Max equlibrium sum = " << getMaxSum(arr, n) << endl;
   return 0;
}
When you compile and execute above program. It generates following output −
Max equlibrium sum = 11
JavaScript - Math random Method

This method returns a random number between 0 (inclusive) and 1 (exclusive).
Its syntax is as follows −
Math.random() ;

Returns a random number between 0 (inclusive) and 1 (exclusive).
Try the following example program.
<html>
   <head>
      <title>JavaScript Math random() Method</title>
   </head>
   
   <body>
      <script type = "text/javascript">
         var value = Math.random( );
         document.write("First Test Value : " + value ); 
         
         var value = Math.random( );
         document.write("<br />Second Test Value : " + value ); 
         
         var value = Math.random( );
         document.write("<br />Third Test Value : " + value ); 
         
         var value = Math.random( );
         document.write("<br />Fourth Test Value : " + value ); 
      </script>
   </body>
</html>

    25 Lectures 
     2.5 hours 

 Anadi Sharma

    74 Lectures 
     10 hours 

 Lets Kode It

    72 Lectures 
     4.5 hours 

 Frahaan Hussain

    70 Lectures 
     4.5 hours 

 Frahaan Hussain

    46 Lectures 
     6 hours 

 Eduonix Learning Solutions

    88 Lectures 
     14 hours 

 Eduonix Learning Solutions
 Print
 Add Notes
 Bookmark this page
C++ Program to Implement Euler Theorem

This is a C++ Program which demonstrates the implementation of Euler Theorem. The number and modular must be coprime for the modular multiplicative inverse to exist.
Begin
   Take input to find modular multiplicative inverse
   Take input as modular value
   Perform inverse array function:
   modInverse(x + 1, 0);
   modInverse[1] = 1;
   for i = 2 to x
      modInverse[i] = (-(y / i) * modInverse[y mod i]) mod y + y
   return modInverse
End
#include <iostream>
#include <vector>
using namespace std;
vector<int> inverseArray(int x, int y) {
   vector<int> modInverse(x + 1, 0);
   modInverse[1] = 1;
   for (int i = 2; i <= x; i++) {
      modInverse[i] = (-(y / i) * modInverse[y % i]) % y + y;
   }
   return modInverse;
}
int main() {
   vector<int>::iterator it;
   int a, m;
   cout<<"Enter number to find modular multiplicative inverse: ";
   cin>>a;
   cout<<"Enter Modular Value: ";
   cin>>m;
   cout<<inverseArray(a, m)[a]<<endl;
}
Enter number to find modular multiplicative inverse: 26
Enter Modular Value: 7
7
Subtracting a day in MySQL

To subtract a day in MySQL, use the DATE_SUB() method. Let us first create a table −
mysql> create table DemoTable
   -> (
   -> AdmissionDate timestamp
   -> );
Query OK, 0 rows affected (1.05 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('2019-01-01');
Query OK, 1 row affected (0.10 sec)
mysql> insert into DemoTable values('2018-12-31');
Query OK, 1 row affected (0.12 sec)
mysql> insert into DemoTable values('2017-03-13');
Query OK, 1 row affected (0.19 sec)
mysql> insert into DemoTable values('2019-01-02');
Query OK, 1 row affected (0.08 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+---------------------+
| AdmissionDate       |
+---------------------+
| 2019-01-01 00:00:00 |
| 2018-12-31 00:00:00 |
| 2017-03-13 00:00:00 |
| 2019-01-02 00:00:00 |
+---------------------+
4 rows in set (0.00 sec)
Here is the query to subtract a day−
mysql> select date_sub(AdmissionDate,interval 1 day) from DemoTable;
This will produce the following output −
+----------------------------------------+
| date_sub(AdmissionDate,interval 1 day) |
+----------------------------------------+
| 2018-12-31 00:00:00                    |
| 2018-12-30 00:00:00                    |
| 2017-03-12 00:00:00                    |
| 2019-01-01 00:00:00                    |
+----------------------------------------+
4 rows in set (0.00 sec)
HTML - <input> Tag

The HTML <input>tag is used within a form to declare an input element − a control that allows the user to input data.
<!DOCTYPE html>
<html>

   <head>
      <title>HTML input Tag</title>
   </head>
	
   <body>
      <form action = "/cgi-bin/hello_get.cgi" method = "get">
         First name: 
            <input type = "text" name = "first_name" value = "" maxlength = "100" />
            <br />
            
         Last name: 
            <input type = "text" name = "last_name" value = "" maxlength = "100" />
         <input type = "submit" value = "Submit" />
      </form>
   </body>
	
</html>
This will produce the following result −
This tag supports all the global attributes described in − HTML Attribute Reference
The HTML <input> tag also supports the following additional attributes −
application/x-www-form-urlencoded
multipart/form-data
text/plain
This tag supports all the event attributes described in HTML Events Reference

    19 Lectures 
     2 hours 

 Anadi Sharma

    16 Lectures 
     1.5 hours 

 Anadi Sharma

    18 Lectures 
     1.5 hours 

 Frahaan Hussain

    57 Lectures 
     5.5 hours 

 DigiFisk (Programming Is Fun)

    54 Lectures 
     6 hours 

 DigiFisk (Programming Is Fun)

    45 Lectures 
     5.5 hours 

 DigiFisk (Programming Is Fun)
 Print
 Add Notes
 Bookmark this page
Adding OrbitControls in React using reactthree-fiber

In this article, we will see how to add OrbitControls in React using react-three-fiber. It is like making a camera; we can move on screen and view each side of any 3D object. We can use OrbitControl to provide zoom and sliding effects too. So, let's get started.
Install the react-three/fiber library −
npm i --save @react-three/fiber three
threejs and react-three/fiber will be used to add webGL renderer to the website. three-fiber will be used to connect threejs and react.
First create an orbital control object in App.js −
import React, { useEffect } from "react";
import { Canvas, useThree } from "@react-three/fiber";
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls";
import * as THREE from "three";
import "./App.scss";

const CameraController = () => {
   const { camera, gl } = useThree();
   useEffect(
      () => {
         const controls = new OrbitControls(camera, gl.domElement);
         controls.minDistance = 3;
         controls.maxDistance = 20;
         return () => {
           controls.dispose();
         };
      },
      [camera, gl]
   );
   return null;
};
CameraController is used to add orbital control on the whole screen.
CameraController is used to add orbital control on the whole screen.
useThree() gives you a camera object, which is used to move on screen.
useThree() gives you a camera object, which is used to move on screen.
gl indicates the area on which you are moving.
gl indicates the area on which you are moving.
In useEffect, we combined both the OrbitControls object.
In useEffect, we combined both the OrbitControls object.
Then we added the minDistance and maxDistance parameters
to restrict the movement on screen.
Then we added the minDistance and maxDistance parameters
to restrict the movement on screen.
Next, add the following lines in App.css −
* {
   box-sizing: border-box;
}
   html,body,#root{
   width: 100%;
   height: 100%;
   margin: 0;
   padding: 0;
}

body{
   background: #f1f4f8;
   position: fixed;
}
This CSS is used to make the canvas match parent size.
Now, let's add OrbitControl in the App component. Add the following lines of code in App.js −
export default function App(){
   return (
      <Canvas>
         <CameraController />
         <ambientLight />
         <spotLight intensity={0.3} position={[5, 10, 50]} />
         <mesh>
            <boxGeometry attach="geometry" args={[3, 2, 1]} />
            <meshPhongMaterial attach="material" color="hotpink" />
         </mesh>
      </Canvas>
   );
};
We created a cuboid and added our previous orbitcontrol object “CameraController” in the App component. OrbitControl is used to add zoomIn, zoomOut, moving, and other effects on our canvas.
On execution, it will produce the following output −
Your browser does not support HTML5 video.
Instead of using a semicolon (;) terminator symbol, is there any other built-in-commands which execute the MySQL query?

With the help of the following built-in commands, MySQL can execute a query even if semicolon (;) terminator symbol is not used.
We can use this command by using \G option. It means to send the current statement to the server to be executed and display the result in vertical format. When we use \G and omitting semicolon(;) in a statement (single or multiple lines), MySQL determines the end of the statement as and when it encounters \G. Consider the example below −
mysql> Select * from ratelist\G
*************************** 1. row ***************************
   Sr: 1
 Item: A
Price: 502
*************************** 2. row ***************************
Sr: 2
Item: B
Price: 630
*************************** 3. row ***************************
   Sr: 3
 Item: C
Price: 1005
*************************** 4. row ***************************
   Sr: 4
 Item: h
Price: 850
*************************** 5. row ***************************
   Sr: 5
 Item: T
Price: 250
5 rows in set (0.00 sec)
We can use this command by using \g option. It means to send the current statement to the server to be executed. When we use \g and omitting semicolon (;) in a statement (single or multiple line), MySQL determines the end of the statement as and when it encounters \g. It gives the output in same format as we get by using semicolon (;). Consider the example below −
mysql> Select * from ratelist\g
+----+------+-------+
| Sr | Item | Price |
+----+------+-------+
|  1 | A    |   502 |
|  2 | B    |   630 |
|  3 | C    |  1005 |
|  4 | h    |   850 |
|  5 | T    |   250 |
+----+------+-------+
5 rows in set (0.00 sec)
Adding a new NOT NULL column to an existing table with records

To add a new NOT NULL column to an already created table, use ALTER command. Let us first create a table −
mysql> create table DemoTable
   -> (
   -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   -> StudentName varchar(20)
   -> );
Query OK, 0 rows affected (0.60 sec)
Following is the query to add a new NOT NULL column to an existing table −
mysql> alter table DemoTable add column StudentAge int NOT NULL;
Query OK, 0 rows affected (0.52 sec)
Records: 0 Duplicates: 0 Warnings: 0
Insert some records in the table using insert command −
mysql> insert into DemoTable(StudentName,StudentAge) values('Chris',21);
Query OK, 1 row affected (0.14 sec)
mysql> insert into DemoTable(StudentName,StudentAge) values('David',23);
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable(StudentName,StudentAge) values('Mike',NULL);
ERROR 1048 (23000): Column 'StudentAge' cannot be null
Display all records from the table using select statement −
mysql> select * from DemoTable;
This will produce the following output −
+-----------+-------------+------------+
| StudentId | StudentName | StudentAge |
+-----------+-------------+------------+
|         1 | Chris       |         21 |
|         2 | David       |         23 |
+-----------+-------------+------------+
2 rows in set (0.00 sec)
Creating a Queue in Javascript

Though Arrays in JavaScript provide all the functionality of a Queue, let us implement our own Queue class. Our class will have the following functions −
 enqueue(element): Function to add an element in the queue.
 dequeue(): Function that removes an element from the queue.
 peek(): Returns the element from the front of the queue.
 isFull(): Checks if we reached the element limit on the queue.
 isEmpty(): checks if the queue is empty.
 clear(): Remove all elements.
 display(): display all contents of the array
Let's start by defining a simple class with a constructor that takes the max size of the queue and a helper function that'll help us when we implement the other functions for this class. As we implemented stacks, we'll implement queues using Arrays as well.
class Queue {
   constructor(maxSize) {
      // Set default max size if not provided
      if (isNaN(maxSize)) {
         maxSize = 10;
       }
      this.maxSize = maxSize;
      // Init an array that'll contain the queue values.
      this.container = [];
   }
   // Helper function to display all values while developing
   display() {
      console.log(this.container);
   }
   // Checks if queue is empty
   isEmpty(){
      return this.container.length === 0;
   }
   // checks if queue is full
   isFull() {
      return this.container.length >= this.maxSize;
   }
}
We have also defined 2 more functions, isFull and isEmpty to check if the queue is full or empty.
The isFull function just checks if the length of the container is equal to or more than maxSize and returns accordingly.
The isEmpty function checks if the size of the container is 0.
These will be helpful when we define other operations. The functions we define from this point onwards will all go inside the Queue class.
How to set the font size of Matplotlib axis Legend?

To set the font size of matplotlib axis legend, we can take the following steps −
Create the points for x and y using numpy.
Create the points for x and y using numpy.
Plot x and y using the plot() method with label y=sin(x).
Plot x and y using the plot() method with label y=sin(x).
Title the plot using the title() method.
Title the plot using the title() method.
To set the fontsize, we can override rcParams legend fontsize by value 20.
To set the fontsize, we can override rcParams legend fontsize by value 20.
Use the legend() method, and fit the legend at the top-right position.
Use the legend() method, and fit the legend at the top-right position.
To display the figure, use the show() method.
To display the figure, use the show() method.
import numpy as np
from matplotlib import pyplot as plt
import matplotlib
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
x = np.linspace(1, 10, 50)
y = np.sin(x)
plt.plot(x, y, c="red", lw=7, label="y=sin(x)")
plt.title("Sine Curve")
matplotlib.rcParams['legend.fontsize'] = 20
plt.legend(loc=1)
plt.show()
Write a Python program to export a dataframe to an html file

Assume, we have already saved pandas.csv file and export the file to Html format
To solve this, we will follow the steps given below −
Read the csv file using the read_csv method as follows −
Read the csv file using the read_csv method as follows −
df = pd.read_csv('pandas.csv')
Create new file pandas.html in write mode using file object,
Create new file pandas.html in write mode using file object,
f = open('pandas.html','w')
Declare result variable to convert dataframe to html file format,
Declare result variable to convert dataframe to html file format,
result = df.to_html()
Using the file object, write all the data from the result. Finally close the file object,
Using the file object, write all the data from the result. Finally close the file object,
f.write(result)
f.close()
Let’s see the below implementation to get a better understanding −
import pandas as pd
df = pd.read_csv('pandas.csv')
print(df)
f = open('pandas.html','w')
result = df.to_html()
f.write(result)
f.close()
pandas.html
<table border="1" class="dataframe">
   <thead>
      <tr style="text-align: right;">
         <th></th>
         <th>Id</th>
         <th>Data</th>
      </tr>
   </thead>
   <tbody>
      <tr>
         <th>0</th>
         <td>1</td>
         <td>11</td>
      </tr>
      <tr>
         <th>1</th>
         <td>2</td>
         <td>22</td>
      </tr>
      <tr>
         <th>2</th>
         <td>3</td>
         <td>33</td>
      </tr>
      <tr>
         <th>3</th>
         <td>4</td>
         <td>44</td>
      </tr>
      <tr>
         <th>4</th>
         <td>5</td>
         <td>55</td>
      </tr>
   </tbody>
</table>
Ionic - Cordova Icon and Splash Screen

Every mobile app needs an icon and splash screen. Ionic provides excellent solution for adding it and requires minimum work for the developers. Cropping and resizing is automated on the Ionic server.
In the earlier chapters, we have discussed how to add different platforms for the Ionic app. By adding a platform, Ionic will install Cordova splash screen plugin for that platform so we do not need to install anything afterwards. All we need to do is to find two images.
The images should be png, psd or ai files. The minimum dimension should be 192x192 for icon image and 2208×2208 for the splash screen image. This dimensions will cover all the devices. In our example, we will use the same image for both. The images need to be saved to resources folder instead of the default ones. After we are done with it, all we need is to run the following in the command prompt window.
C:\Users\Username\Desktop\MyApp>ionic resources

Now, if you check resources/android or resources/ios folders, you will see that the images we added before are resized and cropped to accommodate different screen sizes. When we run our app on the device, we will see a splash screen before the app is started and we will see that a default Ionic icon is changed.
NOTE − If you want to use different images for Android and iOS, you can add it to resources/android and resources/ios instead of the resources folder.

    16 Lectures 
     2.5 hours 

 Frahaan Hussain

    185 Lectures 
     46.5 hours 

 Nikhil Agarwal
 Print
 Add Notes
 Bookmark this page
What does built-in class attribute __bases__ do  in Python?

This built-in class attribute when called prints the tuple of base classes of a class object.
The following code shows how the __bases__ works. B is a child class of the parent/base class A.
class A(object): pass
class B(A): pass
b = B()
print B.__bases__
This gives the output
(<class '__main__.A'>,)
Format date with DateFormat.MEDIUM in Java

DateFormat.MEDIUM is a constant for medium style pattern.
Firstly, we will create date object −
Date dt = new Date();
DateFormat dateFormat;
Let us format date for different locale with DateFormat.MEDIUM −
// CHINESE
dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.CHINESE);
// CANADA
dateFormat = DateFormat.getDateInstance(DateFormat. MEDIUM, Locale.CANADA);
The following is an example −
 Live Demo
import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
public class Demo {
   public static void main(String args[]) {
      Date dt = new Date();
      DateFormat dateFormat;
      // Date Format MEDIUM constant
      dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.FRENCH);
      System.out.println("Locale FRENCH = " + dateFormat.format(dt));
      dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.GERMANY);
      System.out.println("Locale GERMANY = " + dateFormat.format(dt));
      dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.CHINESE);
      System.out.println("Locale CHINESE = " + dateFormat.format(dt));
      dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.CANADA);
      System.out.println("Locale CANADA = " + dateFormat.format(dt));
      dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.ITALY);
      System.out.println("Locale ITALY = " + dateFormat.format(dt));
      dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.TAIWAN);
      System.out.println("Locale TAIWAN = " + dateFormat.format(dt));
   }
}
Locale FRENCH = 22 nov. 2018
Locale GERMANY = 22.11.2018
Locale CHINESE = 2018-11-22
Locale CANADA = 22-Nov-2018
Locale ITALY = 22-nov-2018
Locale TAIWAN = 2018/11/22
Replace a specific duplicate record with a new value in MySQL

Let us first create a table −
mysql> create table DemoTable
(
   Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   Name varchar(50)
);
Query OK, 0 rows affected (0.62 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable(Name) values('Chris');
Query OK, 1 row affected (0.17 sec)
mysql> insert into DemoTable(Name) values('Robert');
Query OK, 1 row affected (0.17 sec)
mysql> insert into DemoTable(Name) values('Chris');
Query OK, 1 row affected (0.19 sec)
mysql> insert into DemoTable(Name) values('David');
Query OK, 1 row affected (0.11 sec)
mysql> insert into DemoTable(Name) values('Mike');
Query OK, 1 row affected (0.13 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+----+--------+
| Id | Name   |
+----+--------+
|  1 | Chris  |
|  2 | Robert |
|  3 | Chris  |
|  4 | David  |
|  5 | Mike   |
+----+--------+
5 rows in set (0.00 sec)
Here is the query to replace a specific duplicate record i.e. the name “Chris” here with a new name −
mysql> update DemoTable set Name=replace(Name,'Chris','Adam Smith');
Query OK, 2 rows affected (0.17 sec)
Rows matched: 5 Changed: 2 Warnings: 0
Let us check the table records once again −
mysql> select *from DemoTable;
This will produce the following output −
+----+------------+
| Id | Name       |
+----+------------+
|  1 | Adam Smith |
|  2 | Robert     |
|  3 | Adam Smith |
|  4 | David      |
|  5 | Mike       |
+----+------------+
5 rows in set (0.00 sec)
C# | Command Line Arguments

26 Feb, 2019
The arguments which are passed by the user or programmer to the Main() method is termed as Command-Line Arguments. Main() method is the entry point of execution of a program. Main() method accepts array of strings. But it never accepts parameters from any other method in the program. In C# the command line arguments are passed to the Main() methods by stating as follows:
static void Main(string[] args)
or 
static int Main(string[] args)

Note : To enable command-line arguments in the Main method in a Windows Forms Application, one must manually modify the signature of Main in program.cs. Windows Forms designer generates code and creates Main without an input parameter. One can also use Environment.CommandLine or Environment.GetCommandLineArgs to access the command-line arguments from any point in a console or Windows application.
Example:
// C# program to illustrate the // Command Line Argumentsusing System;  namespace ComLineArg  {      class Geeks {                    // Main Method which accepts the        // command line arguments as         // string type parameters          static void Main(string[] args)         {                            // To check the length of             // Command line arguments              if(args.Length > 0)            {                Console.WriteLine("Arguments Passed by the Programmer:");                                // To print the command line                 // arguments using foreach loop                foreach(Object obj in args)                  {                      Console.WriteLine(obj);                       }              }                            else            {                Console.WriteLine("No command line arguments found.");            }    }   }}
To Compile and execute the above program follow below commands :
Compile: csc Geeks.cs  
Execute: Geeks.exe Welcome To GeeksforGeeks!

Output :
Arguments Passed by the Programmer:
Welcome
To
GeeksforGeeks!

In above program Length is used to find the number of command line arguments and command line arguments will store in args[] array. With the help of Convert class and parse methods, one can also convert string argument to numeric types. For examples:
long num = Int64.Parse(args[0]);
or
long num = long.Parse(args[0]);

This will changes the string to a long type by using the Parse method. It is also possible to use the C# type long, which aliases Int64. Similarly one can parse using predefined parsing methods in C#.
Reference:https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/main-and-command-args/command-line-arguments
CSharp-Basics
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C# | Multiple inheritance using interfaces
Differences Between .NET Core and .NET Framework
Extension Method in C#
C# | List Class
HashSet in C# with Examples
C# | .NET Framework (Basic Architecture and Component Stack)
Switch Statement in C#
Lambda Expressions in C#
Partial Classes in C#
Hello World in C#
LocalDateTime compareTo() method in Java with Examples

30 Nov, 2018
The compareTo() method of LocalDateTime class in Java is used to compare this date-time to the date-time passed as the parameter.
Syntax:
public int compareTo(ChronoLocalDateTime anotherDate)

Parameter: This method accepts a parameter anotherDate which specifies the other date-time to be compare to. It should not be null.
Returns: The function returns an integer value which is the comparator value after comparison.
Below programs illustrate the LocalDateTime.compareTo() method:
Program 1:
// Program to illustrate the compareTo() method  import java.util.*;import java.time.*;  public class GfG {    public static void main(String[] args)    {        // Parses the date        LocalDateTime dt1            = LocalDateTime                  .parse("2018-11-03T12:45:30");          // Prints the date        System.out.println("Date 1: " + dt1);          // Parses the date        LocalDateTime dt2            = LocalDateTime                  .parse("2015-01-05T12:45:30");          // Prints the date        System.out.println("Date 2: " + dt2);          // Compares the date        System.out.println("After comparison: "                           + dt2.compareTo(dt1));    }}
Date 1: 2018-11-03T12:45:30
Date 2: 2015-01-05T12:45:30
After comparison: -3

Program 2:
// Program to illustrate the compareTo() method  import java.util.*;import java.time.*;  public class GfG {    public static void main(String[] args)    {        // Parses the date        LocalDateTime dt1            = LocalDateTime                  .parse("2010-12-05T12:50:30");          // Prints the date        System.out.println("Date 1: " + dt1);          // Parses the date        LocalDateTime dt2            = LocalDateTime                  .parse("2012-05-10T12:50:30");          // Prints the date        System.out.println("Date 2: " + dt2);          // Compares the date        System.out.println("After comparison: "                           + dt2.compareTo(dt1));    }}
Date 1: 2010-12-05T12:50:30
Date 2: 2012-05-10T12:50:30
After comparison: 2

Reference: https://docs.oracle.com/javase/10/docs/api/java/time/LocalDateTime.html#compareTo(java.time.chrono.ChronoLocalDateTime)
Java-Functions
Java-LocalDateTime
Java-time package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Object Oriented Programming (OOPs) Concept in Java
How to iterate any Map in Java
Interfaces in Java
HashMap in Java with Examples
Stream In Java
ArrayList in Java
Collections in Java
Singleton Class in Java
Multidimensional Arrays in Java
Set in Java
How to style social media buttons with CSS?

Following is the code to style social media buttons with CSS −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<link
href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
rel="stylesheet"
integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN"
crossorigin="anonymous"
/>
<style>
button {
   margin: 0px;
   border-radius: 50%;
   width: 120px;
   height: 120px;
   border: none;
   padding: 15px;
   font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   font-weight: bold;
   font-size: 40px;
   border:1px solid black;
}
button:nth-of-type(1){
   margin-left: 40%;
}
button:hover {
   background: black;
   box-shadow: 5px 10px 18px rgb(20, 20, 20);
}
</style>
</head>
<body>
<h1 style="text-align: center;">Social Media Buttons Example</h1>
<button><i class="fa fa-facebook-f" style="color:#3B5998"></i></button>
<button><i class="fa fa-hashtag" style="color:#55ACEE"></i></button>
<button><i class="fa fa-linkedin" style="color:#007bb5"></i></button>
</body>
</html>
The above code will produce the following output −
On hovering above any of the icons −