code-rag-bench/online-tutorials huggingface dataset:
Python | Scramble strings in list

29 Nov, 2019
Sometimes, while working with different applications, we can come across a problem in which we require to shuffle all the strings in the list input we get. This kind of problem can particularly occur in gaming domain. Let’s discuss certain ways in which this problem can be solved.
Method #1 : Using list comprehension + sample() + join()The combination of above functions can be used to solve this problem. In this, we need to disintegrate string into character list, scramble using sample(), rejoin them using join() and then remake list using list comprehension.
# Python3 code to demonstrate working of# Scramble strings in list# using list comprehension + sample() + join()from random import sample   # initialize list test_list = ['gfg', 'is', 'best', 'for', 'geeks']  # printing original list print("The original list : " + str(test_list))  # Scramble strings in list# using list comprehension + sample() + join()res = [''.join(sample(ele, len(ele))) for ele in test_list]  # printing resultprint("Scrambled strings in lists are : " + str(res))
The original list : ['gfg', 'is', 'best', 'for', 'geeks']
Scrambled strings in lists are : ['fgg', 'is', 'btse', 'rof', 'sgeke']

 
Method #2 : Using list comprehension + shuffle() + join()This is similar to the above method. The only difference is that shuffle() is used to perform scramble task than using sample().
# Python3 code to demonstrate working of# Scramble strings in list# using list comprehension + shuffle() + join()from random import shuffle  # Utility function def perform_scramble(ele):    ele = list(ele)    shuffle(ele)    return ''.join(ele)  # initialize list test_list = ['gfg', 'is', 'best', 'for', 'geeks']  # printing original list print("The original list : " + str(test_list))  # Scramble strings in list# using list comprehension + shuffle() + join()res = [perform_scramble(ele) for ele in test_list]  # printing resultprint("Scrambled strings in lists are : " + str(res))
The original list : ['gfg', 'is', 'best', 'for', 'geeks']
Scrambled strings in lists are : ['fgg', 'is', 'btse', 'rof', 'sgeke']

Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Rotate axis tick labels in Seaborn and Matplotlib
Enumerate() in Python
Deque in Python
Stack in Python
sum() function in Python
Defaultdict in Python
Python | Split string into list of characters
Python | Get dictionary keys as a list
Iterate over characters of a string in Python
Python | Convert set into a list
How to change the playing speed of videos in HTML5?

Use the playbackRate property sets the current playback speed of the audio/video. With that, the defaultPlaybackRate property sets the default playback speed of the audio/video.
You can try to run the following code to change the playing speed of videos −
/* play video thrice as fast */
document.querySelector('video').defaultPlaybackRate = 3.0;
document.querySelector('video').play();
The following is to play the video twice as fast −
/* play video twice as fast */
document.querySelector('video').playbackRate = 2;
Assigning an integer to float and comparison in C/C++

The integer is a data type used to define a number that contains all positive, negative or zero non-fractional values. These cannot have decimals.
Float is a data type used to define a number that has a fractional value. These can have decimals also.
Now, we will check what will be the value of float and integer return by the compiler when we input the same value for both.
 Live Demo
#include <iostream>
using namespace std;
int main(){
   float f = 23;
   unsigned int x = 23;
   cout<<"Float f = "<<f<<endl;
   cout<<"Integer x = "<<x<<endl;
   f = 0xffffffff;
   x = 0xffffffff;
   cout << "f = " << f << endl;
   cout << "x = " << x << endl;
   return 0;
}
Float f = 23
Integer x = 23
f = 4.29497e+09
x = 4294967295
Here in this code, we can see that if we pass an integer value to a float then it will act as an integer and returns an integer value as output. But the max values for both of them come to be different.
Now, let’s see what if we initialize integer variable with float value.
 Live Demo
#include <iostream>
using namespace std;
int main(){
   float f = 23.768;
   unsigned int x = 23.768;
   cout<<"Float f = "<<f<<endl;
   cout<<"Integer x = "<<x<<endl;
   return 0;
}
Float f = 23.768
Integer x = 23
In this condition too the program compiled and run. The integer variable discarded the decimal point values of the initialize float value and gets initialized with the integer value of it.
Now, let's compare these values −
 Live Demo
#include <iostream>
using namespace std;
int main(){
   float f = 0xffffffff;
   unsigned int x = 0xffffffff;
   if(f == x ){
      cout<<"TRUE";
   }
   else
      cout<<"FALSE";
   return 0;
}
TRUE
Program to Convert Centimeter to Feet and Inches in C

Given with the length into centimeter as an input, the task is to convert the given length into feet and inches
We can use length conversion formula for this −
1 feet = 30.48 cm
1 inche = 2.54 cm
Input-: centimetre = 100
Output -: Length in meter = 3m
   Length in Kilometer = 0.003km
Start
Step 1 -> Declare function to perform conversion
   double convert(int centimeter)
      set double inch = 0.3937 * centimetre
      set double feet = 0.0328 * centimetre
      print inch and feet
Step 2 -> In main()
   Declare and set int centimetre=20
   Call convert(centimetre)
Stop
#include <stdio.h>
// Function to perform conversion
double convert(int centimeter){
   double inch = 0.3937 * centimeter;
   double feet = 0.0328 * centimeter;
   printf ("Inches is: %.2f \n", inch);
   printf ("Feet is: %.2f", feet);
   return 0;
}
// Driver Code
int main() {
   int centimeter = 20;
   convert(centimeter);
   return 0;
}
Inches is: 7.87
Feet is: 0.66
Get specific value of cell in MySQL

Let us first create a table −
mysql> create table DemoTable
(
   Name varchar(40),
   Score int
);
Query OK, 0 rows affected (0.72 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('Chris Brown',78);
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable values('John Doe',88);
Query OK, 1 row affected (0.11 sec)
mysql> insert into DemoTable values('Carol Taylor',98);
Query OK, 1 row affected (0.14 sec)
mysql> insert into DemoTable values('David Miller',80);
Query OK, 1 row affected (0.68 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+--------------+-------+
| Name         | Score |
+--------------+-------+
| Chris Brown  |    78 |
| John Doe     |    88 |
| Carol Taylor |    98 |
| David Miller |    80 |
+--------------+-------+
4 rows in set (0.00 sec)
Following is the query to get specific value of cell −
mysql> select Score from DemoTable where Name='Carol Taylor';
This will produce the following output −
+-------+
| Score |
+-------+
|    98 |
+-------+
1 row in set (0.00 sec)
Make multiple checkboxes appear on the same line with Bootstrap

Use the .checkbox-line class in Bootstrap to make multiple checkboxes appear on the same line:
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 = "container">
         <h2>Programming Survey</h2>
         <p>Which programming languages do you like?</p>
         <form>
            <label class = "checkbox-inline">
               <input type = "checkbox" value = "">Java
            </label>
            <label class = "checkbox-inline">
               <input type="checkbox" value="">C++
            </label>
            <label class = "checkbox-inline">
               <input type = "checkbox" value = "">C
            </label>
         </form>
      </div>
   </body>
</html>
C | Storage Classes and Type Qualifiers | Question 9 - GeeksforGeeks

28 Jun, 2021
Output?
#include <stdio.h>int fun(){  static int num = 16;  return num--;}  int main(){  for(fun(); fun(); fun())    printf("%d ", fun());  return 0;}
(A) Infinite loop(B) 13 10 7 4 1(C) 14 11 8 5 2(D) 15 12 8 5 2Answer: (C)Explanation: Since num is static in fun(), the old value of num is preserved for subsequent functions calls. Also, since the statement return num– is postfix, it returns the old value of num, and updates the value for next function call.
fun() called first time: num = 16 // for loop initialization done;


In test condition, compiler checks for non zero value

fun() called again : num = 15

printf("%d \n", fun());:num=14 ->printed

Increment/decrement condition check

fun(); called again : num = 13

----------------

fun() called second time: num: 13 

In test condition,compiler checks for non zero value

fun() called again : num = 12

printf("%d \n", fun());:num=11 ->printed

fun(); called again : num = 10

--------

fun() called second time : num = 10 

In test condition,compiler checks for non zero value

fun() called again : num = 9

printf("%d \n", fun());:num=8 ->printed

fun(); called again   : num = 7

--------------------------------

fun() called second time: num = 7

In test condition,compiler checks for non zero value

fun() called again : num = 6

printf("%d \n", fun());:num=5 ->printed

fun(); called again   : num = 4

-----------

fun() called second time: num: 4 

In test condition,compiler checks for non zero value

fun() called again : num = 3

printf("%d \n", fun());:num=2 ->printed

fun(); called again   : num = 1

----------

fun() called second time: num: 1 

In test condition,compiler checks for non zero value

fun() called again : num = 0 => STOP 
Quiz of this Question
C-Storage Classes and Type Qualifiers
Storage Classes and Type Qualifiers
C Language
C Quiz
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Multidimensional Arrays in C / C++
rand() and srand() in C/C++
fork() in C
Core Dump (Segmentation fault) in C/C++
Left Shift and Right Shift Operators in C/C++
Compiling a C program:- Behind the Scenes
Operator Precedence and Associativity in C
C | Pointer Basics | Question 15
C | Structure & Union | Question 4
C | File Handling | Question 1
Which is the fastest algorithm to find prime numbers using C++?

The Sieve of Eratosthenes is one of the most efficient ways to find the prime numbers smaller than n when n is smaller than around 10 million.
A program that demonstrates the Sieve of Eratosthenes is given as follows.
#include <bits/stdc++.h>
using namespace std;
void SieveOfEratosthenes(int num) {
   bool pno[num+1];
   memset(pno, true, sizeof(pno));
   for (int i = 2; i*i< = num; i++) {
      if (pno[i] == true) {
         for (int j = i*2; j< = num; j + = i)
         pno[j] = false;
      }
   }
   for (int i = 2; i< = num; i++)
   if (pno[i])
   cout << i << " ";
}
int main() {
   int num = 15;
   cout << "The prime numbers smaller or equal to "<< num <<" are: ";
   SieveOfEratosthenes(num);
   return 0;
}
The output of the above program is as follows.
The prime numbers smaller or equal to 15 are: 2 3 5 7 11 13
Now, let us understand the above program.
The function SieveOfEratosthenes() finds all the prime numbers that occur before num that is provided as argument. The code snippet for this is given as follows.
void SieveOfEratosthenes(int num) {
   bool pno[num+1];
   memset(pno, true, sizeof(pno));
   for (int i = 2; i*i< = num; i++) {
      if (pno[i] == true) {
         for (int j = i*2; j< = num; j + = i)
         pno[j] = false;
      }
   }
   for (int i = 2; i< = num; i++)
   if (pno[i])
   cout << i << " ";
}
The function main() sets the value of num and then prints all the prime numbers that are smaller or equal to num. This is done by calling the function SieveOfEratosthenes(). The code snippet for this is given as follows.
int main() {
   int num = 15;
   cout << "The prime numbers smaller or equal to "<< num <<" are: ";
   SieveOfEratosthenes(num);
   return 0;
}
How to install Elasticsearch on Windows 10 - onlinetutorialspoint

PROGRAMMINGJava ExamplesC Examples
Java Examples
C Examples
C Tutorials
aws
JAVAEXCEPTIONSCOLLECTIONSSWINGJDBC
EXCEPTIONS
COLLECTIONS
SWING
JDBC
JAVA 8
SPRING
SPRING BOOT
HIBERNATE
PYTHON
PHP
JQUERY
PROGRAMMINGJava ExamplesC Examples
Java Examples
C Examples
C Tutorials
aws
In this tutorials, we will show how to install Elasticsearch on Windows 10 operating system.
Windows 10 Pro, 64 bit
Elasticsearch 6.7.1
Elasticsearch requires Java 8 (or later) installation to run. If you haven’t installed Java yet, follow our previous article to install Java on Windows operating system.
Follow the below steps to download and install Elasticsearch.
Download the latest Elasticsearchthe from the official website. Usually, it will be available as a .zip file.
The elasticsearch-x.x.x.zip file will be download, upon clicking the above-highlighted URL.
Extract the downloaded file; then you would see the below folder structure.
/bin folder contains all binaries required to run Elasticsearch.
/config folder contains all configuration properties related to Elasticsearch, Java and user settings.
Once the downloading process completed; now we can start the Elasticsearch from the command line.
D:\softwares\elasticsearch-6.7.1\bin>elasticsearch.exe
If everything went well, the command line terminal would display output similar to the following:
Elasticsearch loads the configuration details from an elasticsearch.yml file while running it. If you wanted to change the configurations; you always free to change it from the elasticsearch.yml file or you can even provide as parameters while executing the elasticsearch.exe file.
You can test that your Elasticsearch node is running by sending an HTTP request to port 9200 on localhost:
Elasticsearch Installation guide
Install Java on Windows 10
Happy Learning 🙂

How to install AWS CLI on Windows 10
Install Mysql on Windows 10 Step by Step
How to install Minikube on Windows 10
How to insert documents to Elasticsearch cluster Java
How to Install Ant on Windows 10
How install Python on Windows 10
How to install PuTTY on windows 10
How to install RabbitMQ on Windows 10
How to install Gradle on Windows 10
How to install SOAPUI on Windows 10
How to Install Git windows 10 Operating System
How to setup or install MongoDB on Windows 10
How to install Android Studio on Windows 10
Setup/Install Redis Server on Windows 10
Install Apache Solr on Windows 10

How to install AWS CLI on Windows 10
Install Mysql on Windows 10 Step by Step
How to install Minikube on Windows 10
How to insert documents to Elasticsearch cluster Java
How to Install Ant on Windows 10
How install Python on Windows 10
How to install PuTTY on windows 10
How to install RabbitMQ on Windows 10
How to install Gradle on Windows 10
How to install SOAPUI on Windows 10
How to Install Git windows 10 Operating System
How to setup or install MongoDB on Windows 10
How to install Android Studio on Windows 10
Setup/Install Redis Server on Windows 10
Install Apache Solr on Windows 10
How to use an Image as a button in Tkinter?

In this example, we will create a rounded button in a window that can be used in
many other applications like forms, games, dialogue boxes, etc.
The best way to create rounded buttons in Tkinter is to use the desired images of buttons and turn it into a clickable button in the frame. That is really possible by using PhotoImage() function which grabs the desired image of the button.
So, the following steps make the desired image a button,
First, we will create a dummy button which can be used to make the image
clickable.
First, we will create a dummy button which can be used to make the image
clickable.
Grab the image from the source using PhotoImage(file) function.
Grab the image from the source using PhotoImage(file) function.
Pass the image file as the value in Button function
Pass the image file as the value in Button function
Remove the borderwidth=0.
Remove the borderwidth=0.
Now, we got the button rounded.
Now, we got the button rounded.
For this example we will use this image and will make it clickable.
#Import all the necessary libraries
from tkinter import *

#Define the tkinter instance
win= Toplevel()
win.title("Rounded Button")

#Define the size of the tkinter frame
win.geometry("700x300")

#Define the working of the button

def my_command():
   text.config(text= "You have clicked Me...")

#Import the image using PhotoImage function
click_btn= PhotoImage(file='clickme.png')

#Let us create a label for button event
img_label= Label(image=click_btn)

#Let us create a dummy button and pass the image
button= Button(win, image=click_btn,command= my_command,
borderwidth=0)
button.pack(pady=30)

text= Label(win, text= "")
text.pack(pady=30)

win.mainloop()
Running the above code will produce the following output −
PHP Throwing Exceptions

Throwable interface is implemented by Error and Exception class. All predefined Error classes are inherited from Error class. Instance of corresponding Error class is thrown inside try block and processed inside appropriate catch block.
Normal execution (when no exception is thrown within the try block) will continue after that last catch block defined in sequence.
 Live Demo
<?php
function div($x, $y) {
   if (!$y) {
      throw new Exception('Division by zero.');
   }
return $x/$y;
}
try {
   echo div(10,5) . "\n";
   echo div(10,0) . "\n";
} catch (Exception $e) {
   echo 'Caught exception: ', $e->getMessage(), "\n";
}
// Continue execution
echo "Execution continues\n";
?>
Following output is displayed
2
Caught exception: Division by zero.
Execution continues
In following example, TypeError is thrown while executing a function because appropriate arguments are not passed to it. Corresponding error message is displayed
 Live Demo
<?php
function add(int $num1, int $num2){
   return $num1 + $num2;
}
try {
   $value = add(1, 'one');
} catch (TypeError $e) {
   echo $e->getMessage(). "\n";
}
?>
Following output is displayed
Argument 2 passed to add() must be of the type integer, string given
Standard PHP library contains predefined exceptions
Following example shows OutOfBoundsException thrown when a key in PHP array is not found
 Live Demo
<?php
$arr=array("one"=>1, "two"=>2,"three"=>3,"four"=>4);
$key="ten";
try{
   if (array_key_exists($key, $arr)==FALSE){
      throw new OutOfBoundsException("key not found");}
   else {
      echo $arr[$key];}
   }
   catch (OutOfBoundsException $e){
      echo $e->getMessage(). "\n";
}
?>
Following output is displayed
key not found
Difference Between Cellpadding and Cellspacing

In this post, we will understand the difference between cellpadding and cell spacing.
It is associated with a single cell.
It is associated with a single cell.
It helps control the white space that is present between the border of the cell and the contents within the cell.
It helps control the white space that is present between the border of the cell and the contents within the cell.
The default value of cell padding is 1.
The default value of cell padding is 1.
It is used as an effective method.
It is used as an effective method.
It is created using HTML <table> tag.
It is created using HTML <table> tag.
The type of attribute is set to ‘cellpadding’.
The type of attribute is set to ‘cellpadding’.
<table cellpadding="value" >.....</table>
It is associated with more than a single cell.
It is associated with more than a single cell.
It helps set the space between the single cells.
It helps set the space between the single cells.
It is less effective than cell padding.
It is less effective than cell padding.
The default cell spacing value is 2.
The default cell spacing value is 2.
It can be created using HTML <table> tag.
It can be created using HTML <table> tag.
The type of attribute is set to ‘cellspacing’.
The type of attribute is set to ‘cellspacing’.
<table cellspacing="value" >.....</table>
How to find a replace a word in a string in C#?

Firstly, set the string to be replaced.
string str = "Demo text!";
Now use the replace() method to replace the above string.
string res = str.Replace("Demo ", "New ");
The following is the complete code to replace a word in a string.
 Live Demo
using System;
public class Demo {
   public static void Main() {

      string str = "Demo text!";
      Console.WriteLine(str);

      string res = str.Replace("Demo ", "New ");
      Console.WriteLine("After replacing...");
      Console.WriteLine(res);
   }
}
Demo text!
After replacing...
New text!
What is a static polymorphism in C#?

Static Polymorphism is the linking of a function with an object during compile time is called static. It is also called static binding. C# provides two techniques to implement static polymorphism i.e. Function overloading and Operator overloading.
Let us learn about Function Overloading. You can have multiple definitions for the same function name in the same scope. The definition of the function must differ from each other by the types and/or the number of arguments in the argument list. You cannot overload function declarations that differ only by return type.
The following is the complete example −
using System;

namespace PolymorphismApplication {
   class Printdata {
      void print(int i) {
         Console.WriteLine("Printing int: {0}", i );
      }

      void print(double f) {
         Console.WriteLine("Printing float: {0}" , f);
      }

      void print(string s) {
         Console.WriteLine("Printing string: {0}", s);
      }

      static void Main(string[] args) {
         Printdata p = new Printdata();

         // Call print to print integer
         p.print(5);

         // Call print to print float
         p.print(500.263);

         // Call print to print string
         p.print("Hello C++");
         Console.ReadKey();
      }
   }
}
How to use Try/catch blocks in C#?

Exceptions provide a way to transfer control from one part of a program to another. C# exception handling is built upon four keywords: try, catch, finally, and throw.
try − A try block identifies a block of code for which particular exceptions is activated. It is followed by one or more catch blocks.
try − A try block identifies a block of code for which particular exceptions is activated. It is followed by one or more catch blocks.
catch − A program catches an exception with an exception handler at the place in a program where you want to handle the problem. The catch keyword indicates the catching of an exception.
catch − A program catches an exception with an exception handler at the place in a program where you want to handle the problem. The catch keyword indicates the catching of an exception.
The following is an example showing how to use the try, catch, and finally in C#.
 Live Demo
using System;
namespace Demo {
   class DivNumbers {
      int result;
      DivNumbers() {
         result = 0;
      }
      public void division(int num1, int num2) {
         try {
            result = num1 / num2;
         } catch (DivideByZeroException e) {
            Console.WriteLine("Exception caught: {0}", e);
         } finally {
            Console.WriteLine("Result: {0}", result);
         }
      }
      static void Main(string[] args) {
         DivNumbers d = new DivNumbers();
         d.division(25, 0);
         Console.ReadKey();
      }
   }
}
Result: 0
GATE | GATE-CS-2004 | Question 55 - GeeksforGeeks

28 Jun, 2021
The routing table of a router is shown below:
 Destination     Sub net mask          Interface
 128.75.43.0      255.255.255.0             Eth0
 128.75.43.0      255.255.255.128     Eth1
 192.12.17.5      255.255.255.255     Eth3
 default                           Eth2
On which interfaces will the router forward packets addressed to destinations 128.75.43.16 and 192.12.17.10 respectively?(A) Eth1 and Eth2(B) Eth0 and Eth2(C) Eth0 and Eth3(D) Eth1 and Eth3Answer: (A)Explanation: To find the interface, we need to do AND of incoming IP address and Subnet mask. Compare the result of AND with the destination. Note that if there is a match between multiple Destinations, then we need to select the destination with longest length subnet mask.
128.75.43.16, matches with 128.75.43.0 and 128.75.43.0, the packet is forwarded to Eth1 as length of subnet mask in Eth11 is more.
If a result is not matching with any of the given destinations then the packet is forwarded to the default interface (here Eth2). Therefore the packet’s addressed to 192.12.17.10 will be forwarded to Eth2.Quiz of this Question
GATE-CS-2004
GATE-GATE-CS-2004
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
GATE | GATE-IT-2004 | Question 83
GATE | GATE-CS-2014-(Set-3) | Question 38
GATE | GATE CS 2018 | Question 37
GATE | GATE-CS-2016 (Set 1) | Question 65
GATE | GATE-CS-2016 (Set 1) | Question 63
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE-CS-2007 | Question 17
GATE | GATE-CS-2016 (Set 2) | Question 48
GATE | GATE CS 2019 | Question 37
GATE | GATE-CS-2014-(Set-3) | Question 65
How to add current date to an existing MySQL table?

To update an existing table, use UPDATE. With that, to set the current date, use the CURDATE() method −
update yourTableName set yourCoumnName=CURDATE();
Let us first create a table −
mysql> create table DemoTable
-> (
-> DueDate datetime
-> );
Query OK, 0 rows affected (0.58 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('2019-01-10') ;
Query OK, 1 row affected (0.21 sec)

mysql> insert into DemoTable values('2019-03-31');
Query OK, 1 row affected (0.18 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+---------------------+
| DueDate             |
+---------------------+
| 2019-01-10 00:00:00 |
| 2019-03-31 00:00:00 |
+---------------------+
2 rows in set (0.00 sec)
Following is the query to add current date to existing table −
mysql> update DemoTable set DueDate=CURDATE();
Query OK, 2 rows affected (0.13 sec)
Rows matched: 2 Changed: 2 Warnings: 0
Let us check the table records once again −
mysql> select *from DemoTable;
This will produce the following output −
+---------------------+
| DueDate             |
+---------------------+
| 2019-06-22 00:00:00 |
| 2019-06-22 00:00:00 |
+---------------------+
2 rows in set (0.00 sec)
Set the image path with CSS

The border-image-source property is used in CSS to set the image path. You can try to run the following code to set the image path −
<html>
   <head>
      <style>
         #borderimg1 {
            border: 15px solid transparent;
            padding: 15px;
            border-image-source: url(https://tutorialspoint.com/css/images/border.png);
            border-image-repeat: round;
         }
      </style>
   </head>
   
   <body>
      <p id = "borderimg1">This is image border example.</p>
   </body>
</html>
What is .htaccess in PHP?

.htaccess is a configuration file for use on web servers running on the web apache server software. when a .htaccess file is placed in a directory which in turn loaded via the Apache web server, then the .htaccess file detected and executed by the Apache server software. 
.htaccess files can be utilized to modify the setup of the Apache server software to empower additional functionality and fetures that the apache web server softwatre brings to the table. We can use the .htaccess file for alteration various configuration in apache web server software. Some of them are listed below:
Creating custom error pages is very useful, it allows us to show web site visitors a friendly error message, in case of if a URL on your web site does not work.
ErrorDocument 404 /error_pages/404.html
Very easily, we can password protect a directory of an application that requires a username and password to access.
AuthName "Admin Area"
AuthUserFile /path/to/password/file/.htpasswd
AuthType Basic
require valid-user
The first line tells the Apache Web Server the secure directory is called 'Admin Area', this will be displayed when the pop-up login prompt appears. The subsequent line indicates the location of the password file. The third line determines the authentication type, in this example, we are using 'Basic' because we are using basic HTTP authentication lastly the fourth line indicates that we require valid login credentials
Redirects enable us to direct web site visitors from one document within your web site to another.
Redirect /old_dir/ http://www.test.com(your domain)/new_dir/index.html
order allow,deny
deny from 155.0.2.0
deny from 123.45.6.1
allow from all
The above lines tell the Apache Web Server to block visitors from the IP address '155.0.2.0' and '123.45.6.1' and allow all other IP addresses.
To set up a MIME type, create a .htaccess file following the main instructions and guidance which includes the following text:
AddType text/html htm0
'AddType' determines that you are including a MIME type. TThe subsequent part is the MIME type, for this situation content or HTML, and the last part is the file extension, in this example 'htm0'.
HTML DOM Form submit() method

The HTML DOM Form submit() method is used for submitting the form data to the address specified by the action attribute. It acts as a submit button to submit form data and it doesn’t take any kind of parameters.
Following is the syntax for Form submit() method −
formObject.submit()
Let us look at an example for the Form submit() method −
<!DOCTYPE html>
<html>
<head>
<style>
   form{
      border:2px solid blue;
      margin:2px;
      padding:4px;
   }
</style>
<script>
   function ResetForm() {
      document.getElementById("FORM1").reset();
      document.getElementById("Sample").innerHTML="Form has been reset";
   }
</script>
</head>
<body>
<h1>Form reset() method example</h1>
<form id="FORM1" method="post" action="/sample_page.php">
<label>User Name <input type="text" name="usrN"></label> <br><br>
<label>Age <input type="text" name="Age"><label> <br><br>
<input type="submit" value="SUBMIT">
<input type="button" onclick="ResetForm()" value="RESET">
</form>
<p id="Sample"></p>
</body>
</html>
This will produce the following output −
On clicking the SUBMIT button the form will be submitted and the “sample_page.php” will display this −
In the above example −
We have first created a form with id=”FORM1”, method=”post” and action=”/sample_page.php”. It contains two input fields with type text and a button named SUBMIT −
<form id="FORM1" method="post" action="/sample_page.php">
<label>User Name <input type="text" name="usrN"></label> <br><br>
<label>Age <input type="text" name="Age"><label> <br><br>
<input type="submit" value="SUBMIT">
<input type="button" onclick="ResetForm()" value="RESET">
</form>
The SUBMIT button executes the SubmitForm() method on being clicked by the user −
<input type="button" onclick="SubmitForm()" value="SUBMIT">
The ResetForm() method gets the <form> element using the document object getElementById() method and calls the submit() method on it. This submits the form data to the address specified by the action attribute −
function SubmitForm() {
   document.getElementById("FORM1").submit();
}
C# Enum Equals Method

To find the equality between enums, use the Equals() method.
Let’s say we have the following Enum.
enum Products { HardDrive, PenDrive, Keyboard};
Create two Products objects and assign the same values.
Products prod1 = Products.HardDrive;
Products prod2 = Products.HardDrive;
Now check for equality using Equals() method. It would be True since both have the same underlying value.
 Live Demo
using System;
class Program {
   enum Products {HardDrive, PenDrive, Keyboard};
   enum ProductsNew { Mouse, HeadPhone, Speakers};
   static void Main() {
      Products prod1 = Products.HardDrive;
      Products prod2 = Products.HardDrive;
      ProductsNew newProd1 = ProductsNew.HeadPhone;
      ProductsNew newProd2 = ProductsNew.Speakers;
      Console.WriteLine("Both are same products = {0}", prod1.Equals(prod2) ? "Yes" : "No");
      Console.WriteLine("Both are same products = {0}", newProd1.Equals(newProd2) ? "Yes" : "No");
   }
}
Both are same products = Yes
Both are same products = No
Dart Programming - Logical Operators

The following example shows how you can use Logical Operators in Dart −
void main() {  
   var a = 10; 
   var b = 12; 
   var res = (a<b)&&(b>10); 
   print(res);  
}    
It will produce the following output −
true 

Let’s take another example −
void main() { 
   var a = 10; 
   var b = 12; 
   var res = (a>b)||(b<10); 
   
   print(res);  
   var res1 =!(a==b); 
   print(res1); 
}    
It will produce the following output −
false 
true 

The && and || operators are used to combine expressions. The && operator returns true only when both the conditions return true.
Let us consider the following expression −
var a = 10 
var result = (a<10 && a>5)
In the above example, a<10 and a>5 are two expressions combined by an && operator. Here, the first expression returns false. However, the && operator requires both the expressions to return true. So, the operator skips the second expression.
The || operator returns true if one of the expressions returns true. For example −
var a = 10 
var result = ( a>5 || a<10)
In the above snippet, two expressions a>5 and a<10 are combined by a || operator. Here, the first expression returns true. Since, the first expression returns true, the || operator skips the subsequent expression and returns true.
Due to this behavior of the && and || operator, they are called as short-circuit operators.

    44 Lectures 
     4.5 hours 

 Sriyank Siddhartha

    34 Lectures 
     4 hours 

 Sriyank Siddhartha

    69 Lectures 
     4 hours 

 Frahaan Hussain

    117 Lectures 
     10 hours 

 Frahaan Hussain

    22 Lectures 
     1.5 hours 

 Pranjal Srivastava

    34 Lectures 
     3 hours 

 Pranjal Srivastava
 Print
 Add Notes
 Bookmark this page
Bootstrap 4 .flex-row class

Use the flex-row class in Bootstrap to dispay flex items horizontally.
Achieve the following using the flex-row class −
<div class="d-flex flex-row bg-primary mb-3">
Now add the flex-items in the class to allow horizontal alignment −
<div class="d-flex flex-row bg-primary mb-3">
  <div class="p-2 bg-primary">Audi</div>
  <div class="p-2 bg-danger">BMW</div>
  <div class="p-2 bg-info">Benz</div>
</div>
You can try to run the following code to implement the flex-row class −
Live Demo
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Bootstrap Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
  </head>

<body>
  <div class="container mt-3">
    <h2>Flex Row</h2>
    <div class="d-flex flex-row bg-primary mb-3">
     <div class="p-2 bg-primary">Audi</div>
     <div class="p-2 bg-danger">BMW</div>
     <div class="p-2 bg-info">Benz</div>
    </div>
 </div>

</body>
</html>
Getting screens height and width using Tkinter Python

Tkinter is the library which gives GUI programming capability to python programs. As part of GUI creation we need to create screen layouts of different sizes and depth. In this program we will see how to calculate the size of a screen in terms of pixels as well as in mm. We can also get the depth of the screen in pixels. There are various methods available as part of Tkinter which we use for this.
from tkinter import *
# creating tkinter window
base = Tk()
#screen's length and width in pixels and mm
length_1= base.winfo_screenheight()
width_1= base.winfo_screenwidth()
length_2 = base.winfo_screenmmheight()
width_2 = base.winfo_screenmmwidth()
#screen Depth
screendepth = base.winfo_screendepth()
print("\n width x length (in pixels) = ",(width_1,length_1))
print("\n width x length (in mm) = ", (width_2, length_2))
print("\n Screen depth = ",screendepth)
mainloop()
Running the above code gives us the following result
width x length (in pixels) = (1600, 900)
width x length (in mm) = (423, 238)
Screen depth = 32
Kotlin Classes and Objects

Everything in Kotlin is associated with classes and objects, along with its properties and 
functions. For example: in real life, a car is an object. The car has properties, such as 
brand, weight and color, and 
functions, such as drive and brake. 
A Class is like an object constructor, or a "blueprint" for creating objects.
To create a class, use the class keyword, and specify the name of the class:
Create a Car class along with some properties (brand, model and year)
class Car {
  var brand = ""
  var model = ""
  var year = 0
} 
A property is basically a variable that belongs to the class.
Good to Know: It is considered good practice to start the 
  name of a class with an upper case letter, for better organization.
Now we can use the class named Car to create objects.
In the example below, we create an object of Car called
c1, and then we access the properties of c1 by 
using the dot syntax (.), just like we did to 
access array and string properties:
// Create a c1 object of the Car class
val c1 = Car()

// Access the properties and add some values to it
c1.brand = "Ford"
c1.model = "Mustang"
c1.year = 1969

println(c1.brand)   // Outputs Ford
println(c1.model)   // Outputs Mustang
println(c1.year)    // Outputs 1969 
You can create multiple objects of one class:
val c1 = Car()
c1.brand = "Ford"
c1.model = "Mustang"
c1.year = 1969

val c2 = Car()
c2.brand = "BMW"
c2.model = "X5"
c2.year = 1999

println(c1.brand)  // Ford
println(c2.brand)  // BMW

We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
Batch Script - Remove Both Ends

This is used to remove the first and the last character of a string
@echo off 
set str = Batch scripts is easy. It is really easy 
echo %str% 

set str = %str:~1,-1% 
echo %str%
The key thing to note about the above program is, the ~1,-1 is used to remove the first and last character of a string.
The above command produces the following output.
Batch scripts is easy. It is really easy 
atch scripts is easy. It is really eas

 Print
 Add Notes
 Bookmark this page
Metagoofil – Tool to Extract Information from Docs, Images in Kali Linux

31 Oct, 2021
The Metagoofil is an information-gathering tool. This is a free and open-source tool designed to extract all the metadata information from public documents that are available on websites. This tool uses two libraries to extract data. These are Hachoir and PdfMiner. After extracting all the data, this tool will generate a report which contains usernames, software versions, and servers or machine names that will help Penetration testers in the information-gathering phase. This tool can also extract MAC addresses from Microsoft office documents. This tool can give information about the hardware of the system by which they generated the report of the tool.
Step 1: Open your kali Linux operating system and install the tool using the following command.
git clone https://github.com/laramies/metagoofil.git
cd metagoofil
Step 2: Now use the following command to run the tool.
python metagoofil.py
The tool is running successfully. Now we will see some examples of using the tool.
Example 1: Use the metagoofil tool to extract PDFs from a website.
python metagoofil.py -d flipkart.com -l 100 -n 5 -t pdf -o newflipkart
In this way, you can extract PDFsf and information on files from a website. 
Example 2: Use the metagoofil tool to extract pdf from a website.
python metagoofil.py -d microsoft.com -l 20 -f all -o micro.html -t micro-files
In this way, the tool will find all the details of the tool. You can find the details, if any, available on the website. 
surinderdawra388
Kali-Linux
Linux-Tools
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Using Tags in Git

08 Jun, 2020
Tagging in GIT refers to creating specific points in the history of your repository/data. It is usually done to mark the release points.
Two main purposes of tags are:
Make Release point on your code.
Create historic restore points.
You can create tags when you want to create a release point for a stable version of your code. You can also create tags when you want to create a historic point for your code that you can refer to in the future to restore your data.
To create a tag we need to go through the following steps:
Step 1: Checkout to the branch you want to create the tag.
 git checkout {branch name} 
Step 2: Create a tag with some name
 git tag {tag name} 
There are many more ways in which we create tags.Annotated Tags
 git tag -a {tag name} -m {some message} 
Step 3: See all the created tags.
 git tag
To see the details of the tag we can use
 git show {tag name} 
To see tags starting with some letters
 git tag -l "v2.*"
Step 4: Push tags to remote.
 
git push origin {tag name}
git push --tags
 
“git push –tags” will push all tags at once.
Before
After
Step 5: Delete Tags. (locally)
git tag -d {tag name}
git tag --delete {tag name}
  
Step 6: Delete tags from remote
git push origin -d {tag name}
git push origin --delete {tag name}
git push origin :{tag name}

“git push origin -d {tag name}” can also delete tag locally and remote at the same time.
GitHub
Picked
Git
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Git - Difference Between Git Fetch and Git Pull
How to Set Upstream Branch on Git?
How to Push Git Branch to Remote?
How to Export Eclipse projects to GitHub?
Merge Conflicts and How to handle them
How to Add Git Credentials in Eclipse?
What is README.md File?
Git - Origin Master
How to Add Videos on README .md File in a GitHub Repository?
Git - Cherry Pick
C++ Stack Library - push() Function

The C++ function std::stack::push() inserts new element at the top of the stack and increases size of stack by one.
Following is the declaration for std::stack::push() function form std::stack header.
void push (const value_type& val);

void push (const value_type& val);

val − Value to be assigned to the newly inserted element.
None.
Depends upon underlying container.
Constant i.e. O(1)
The following example shows the usage of std::stack::push() function.
#include <iostream>
#include <stack>

using namespace std;

int main(void) {
   stack<int> s;

   for (int i = 0; i < 5; ++i)
      s.push(i + 1);

   cout << "Stack contents are" << endl;

   while (!s.empty()) {
      cout << s.top() << endl;
      s.pop();
   }

   return 0;
}
Let us compile and run the above program, this will produce the following result −
Stack contents are
5
4
3
2
1

 Print
 Add Notes
 Bookmark this page
Check for perfect square in JavaScript

We are required to write a JavaScript function that takes in a number and returns a boolean
based on the fact whether or not the number is a perfect square.
Examples of perfect square numbers −
Some perfect square numbers are −
144, 196, 121, 81, 484
The code for this will be −
const num = 484;
const isPerfectSquare = num => {
   let ind = 1;
   while(ind * ind <= num){
      if(ind * ind !== num){
         ind++;
         continue;
      };
      return true;
   };
   return false;
};
console.log(isPerfectSquare(num));
The output in the console −
true
Tryit Editor v3.7

Tryit: HTML link titles
Tk - Message Widget

A message widget is used for displaying multiple lines of text. The syntax for message widget is shown below −
message messageName options

The options available for the message widget are listed below in the following table −
-background color
Used to set background color for widget.
-borderwidth width
Used to draw with border in 3D effects.
-font fontDescriptor
Used to set font for widget.
-foreground color
Used to set foreground color for widget.
-padx number
Sets the padx for the widget.
-pady number
Sets the pady for the widget.
-relief condition
Sets the 3D relief for this widget. The condition may be raised, sunken, flat, ridge, solid, or groove.
-text text
Sets the text for the widget.
-textvariable varName
Variable associated with the widget. When the text of widget changes, the variable is set to text of widget.
-justify alignment
Sets the alignment of text, which can be left, center, or right.
-aspect ratio
Sets the aspect ratio in percent. The default is 150. It is available when width option is not used.
-width number
Sets the width for widget.
A simple example for message widget is shown below −
#!/usr/bin/wish

grid [message .myMessage -background red -foreground white -text "Hello\nWorld" -relief
   ridge -borderwidth 8 -padx 10 -pady 10 -font {Helvetica -18 bold} -textvariable
   myvariable -justify right -aspect 100 ]
When we run the above program, we will get the following output −
 Print
 Add Notes
 Bookmark this page
Laravel - Event Handling

Events provide a simple observer implementation which allows a user to subscribe and listen to various events triggered in the web application. All the event classes in Laravel are stored in the app/Events folder and the listeners are stored in the app/Listeners folder.
The artisan command for generating events and listeners in your web application is shown below −
php artisan event:generate

This command generates the events and listeners to the respective folders as discussed above.
Events and Listeners serve a great way to decouple a web application, since one event can have multiple listeners which are independent of each other. The events folder created by the artisan command includes the following two files: event.php and SomeEvent.php. They are shown here −
<?php
namespace App\Events;
abstract class Event{
   //
}
As mentioned above, event.php includes the basic definition of class Event and calls for namespace App\Events. Please note that the user defined or custom events are created in this file.
<?php

namespace App\Events;

use App\Events\Event;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

class SomeEvent extends Event{
   use SerializesModels;
   /**
      * Create a new event instance.
      *
      * @return void
   */
   
   public function __construct() {
      //
   }
   
   /**
      * Get the channels the event should be broadcast on.
      *
      * @return array
   */
   
   public function broadcastOn() {
      return [];
   }
}
Observe that this file uses serialization for broadcasting events in a web application and that the necessary parameters are also initialized in this file.
For example, if we need to initialize order variable in the constructor for registering an event, we can do it in the following way −
public function __construct(Order $order) {
   $this->order = $order;
}
Listeners handle all the activities mentioned in an event that is being registered. The artisan command event:generate creates all the listeners in the app/listeners directory. The Listeners folder includes a file EventListener.php which has all the methods required for handling listeners.
<?php

namespace App\Listeners;

use App\Events\SomeEvent;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;

class EventListener{
   /**
      * Create the event listener.
      *
      * @return void
   */
   
   public function __construct() {
      //
   }

   /**
      * Handle the event.
      *
      * @param SomeEvent $event
      * @return void
   */
   
   public function handle(SomeEvent $event) {
      //
   }
}
As mentioned in the code, it includes handle function for managing various events. We can create various independent listeners that target a single event.

    13 Lectures 
     3 hours 

 Sebastian Sulinski

    35 Lectures 
     3.5 hours 

 Antonio Papa

    7 Lectures 
     1.5 hours 

 Sebastian Sulinski

    42 Lectures 
     1 hours 

 Skillbakerystudios

    165 Lectures 
     13 hours 

 Paul Carlo Tordecilla

    116 Lectures 
     13 hours 

 Hafizullah Masoudi
 Print
 Add Notes
 Bookmark this page