code-rag-bench/online-tutorials huggingface dataset:
How to create a collapsible sidebar menu with CSS and JavaScript?

Following is the code to create a collapsible sidebar menu using CSS and JavaScript −
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
.sideNav {
   height: 100vh;
   width: 0;
   position: fixed;
   z-index: 1;
   top: 0;
   left: 0;
   background-color: rgb(46, 218, 195);
   overflow-x: hidden;
   padding-top: 60px;
   transition: 0.5s;
}
.sideNav a {
   padding: 8px 8px 8px 32px;
   text-decoration: none;
   font-size: 25px;
   color: #000000;
   font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   display: block;
   transition: 0.3s;
}
.sidenav a:hover {
   color: #f1f1f1;
}
.sideNav .closeBtn {
   position: absolute;
   top: 0;
   right: 25px;
   font-size: 36px;
   margin-left: 50px;
}
button {
   padding: 15px;
   background-color: rgb(0, 27, 145);
   color: rgb(255, 255, 255);
   font-size: 20px;
   border: none;
   border-radius: 2%;
}
.main-content{
   transition: 0.5s;
}
</style>
</head>
<body>
<nav class="sideNav">
<a href="#" class="closeBtn">×</a>
<a href="#">Login</a>
<a href="#">Register</a>
<a href="#">Home</a>
<a href="#">About Us</a>
</nav>
<main class="main-content">
<button class="openSideNav">Click here to open sideNav</button>
<h1>Here is some sample text</h1>
<p>Here is some random sample text too</p>
</main>
<script>
let openBtn = document.querySelector(".openSideNav");
openBtn.addEventListener("click", () => {
   showNav();
});
let closeBtn = document.querySelector(".closeBtn");
closeBtn.addEventListener("click", () => {
   hideNav();
});
function showNav() {
   document.querySelector(".sideNav").style.width = "300px";
   document.querySelector('.main-content').style.marginLeft = "300px";
}
function hideNav() {
   document.querySelector(".sideNav").style.width = "0";
   document.querySelector('.main-content').style.marginLeft = "0px";
}
</script>
</body>
</html>
The above code will produce the following output −
On clicking the open sideNav button the navigation menu will slide from left as follows −
How to get windows firewall profile settings using PowerShell?

Recent windows client and server operating systems like Windows 10, Windows Server 2008 onwards, supports advanced firewall versions and they have mainly 3 profiles.
Domain
Domain
Public
Public
Private profile.
Private profile.
To get the setting using GUI, you need to search in the box Windows Firewall with Advanced Security or Windows Defender Firewall with Advanced Security. Then you can see in the console that 3 available profiles.
The above same settings can be viewed with the PowerShell Get-NetFirewallProfile command.
PS C:\> Get-NetFirewallProfile
Name : Domain
Enabled : True
DefaultInboundAction : NotConfigured
DefaultOutboundAction : NotConfigured
AllowInboundRules : NotConfigured
AllowLocalFirewallRules : NotConfigured
AllowLocalIPsecRules : NotConfigured
AllowUserApps : NotConfigured
AllowUserPorts : NotConfigured
AllowUnicastResponseToMulticast : NotConfigured
NotifyOnListen : True
EnableStealthModeForIPsec : NotConfigured
LogFileName : %systemroot%\system32\LogFiles\Firewall\pfirewall.log
LogMaxSizeKilobytes : 4096
LogAllowed : NotConfigured
LogBlocked : NotConfigured
LogIgnored : NotConfigured
DisabledInterfaceAliases : {NotConfigured}
Name : Private
Enabled : True
DefaultInboundAction : NotConfigured
DefaultOutboundAction : NotConfigured
AllowInboundRules : NotConfigured
AllowLocalFirewallRules : NotConfigured
AllowLocalIPsecRules : NotConfigured
AllowUserApps : NotConfigured
AllowUserPorts : NotConfigured
AllowUnicastResponseToMulticast : NotConfigured
NotifyOnListen : True
EnableStealthModeForIPsec : NotConfigured
LogFileName : %systemroot%\system32\LogFiles\Firewall\pfirewall.log
LogMaxSizeKilobytes : 4096
LogAllowed : NotConfigured
LogBlocked : NotConfigured
LogIgnored : NotConfigured
DisabledInterfaceAliases : {NotConfigured}
Name : Public Enabled : True
DefaultInboundAction : NotConfigured
DefaultOutboundAction : NotConfigured
AllowInboundRules : NotConfigured
AllowLocalFirewallRules : NotConfigured
AllowLocalIPsecRules : NotConfigured
AllowUserApps : NotConfigured
AllowUserPorts : NotConfigured
AllowUnicastResponseToMulticast : NotConfigured
NotifyOnListen : True
EnableStealthModeForIPsec : NotConfigured
LogFileName : %systemroot%\system32\LogFiles\Firewall\pfirewall.log
LogMaxSizeKilobytes : 4096
LogAllowed : NotConfigured
LogBlocked : NotConfigured
LogIgnored : NotConfigured
DisabledInterfaceAliases : {NotConfigured}
The output is in the detailed view. If you need to check only Profile names and if they are enabled or not then use the select command.
Get-NetFirewallProfile | Select Name, Enabled
Name Enabled ---- ------- Domain True Private True Public True
Similarly, You can filter the different parameters from the above output as per your requirement.
To get the settings on the remote computer, you need to use Invoke-Command or PSSession because this command doesn’t support -ComputerName parameter directly.
Invoke-Command -ComputerName RemoteServerName -ScriptBlock{ Get-NetFirewallProfile | Select Name, Enabled}
How to work with Structs in JavaScript?

To work with Structs in JavaScript, you can try to run the following code −
 Live Demo
<!DOCTYPE html>
<html>
   <body>
      <script>
         function displayStruct(str) {
            var str = str.split(' ');
            var count = str.length;

            function constructor() {
               for (var i = 0; i < count; i++) {
                  this[str[i]] = arguments[i];
               }
            }
            return constructor;
         }

         var Item = displayStruct("player country");

         var res = new Item('Sachin', 'India');
         alert("Country: "+res.country);
      </script>
   </body>
   
</html>
Superscript in Python plots

To put some superscript in Python, we can take the following steps −
Create points for a and f using numpy.
Create points for a and f using numpy.
Plot f = ma curve using the plot() method, with label f=ma.
Plot f = ma curve using the plot() method, with label f=ma.
Add title for the plot with superscript, i.e., kgms-2.
Add title for the plot with superscript, i.e., kgms-2.
Add xlabel for the plot with superscript, i.e., ms-2.
Add xlabel for the plot with superscript, i.e., ms-2.
Add ylabel for the plot with superscript, i.e., kg.
Add ylabel for the plot with superscript, i.e., kg.
To place the legend, use legend() method.
To place the legend, use legend() method.
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
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
a = np.linspace(1, 10, 100)
m = 20
f = m*a
plt.plot(a, f, c="red", lw=5, label="f=ma")
plt.title("Force $\mathregular{kgms^{-2}}$")
plt.xlabel("Acceleration $\mathregular{ms^{-2}}$")
plt.ylabel("Acceleration $\mathregular{kg}$")
plt.legend()
plt.show()
C# program to reverse an array

Firstly, set the original array −
int[] arr = { 15, 16, 17, 18 };
// Original Array
Console.WriteLine("Original Array= ");
foreach (int i in arr) {
   Console.WriteLine(i);
}
Now, use the Array.reverse() method to reverse the array −
Array.Reverse(arr);
The following is the complete code to reverse an array in C#
Live Demo
using System;
class Demo {
   static void Main() {
      int[] arr = { 15, 16, 17, 18 };
      // Original Array
      Console.WriteLine("Original Array= ");
      foreach (int i in arr) {
         Console.WriteLine(i);
      }
      // Reverse Array
      Array.Reverse(arr);
      Console.WriteLine("Reversed Array= ");
      foreach (int j in arr) {
         Console.WriteLine(j);
      }
      Console.ReadLine();
   }
}
Original Array=  
15
16
17
18
Reversed Array=  
18
17
16
15
Add months to current date using Calendar.add() method in Java

Import the following package for Calendar class in Java.
import java.util.Calendar;
Firstly, create a Calendar object and display the current date and time.
Calendar calendar = Calendar.getInstance();
System.out.println("Current Date and Time = " + calendar.getTime());
Now, let us increment the months using the calendar.add() method and Calendar.MONTH constant.
calendar.add(Calendar.MONTH, 8);
 Live Demo
import java.util.Calendar;
public class Demo {
   public static void main(String[] args) {
      Calendar calendar = Calendar.getInstance();
      System.out.println("Current Date = " + calendar.getTime());
      // Add 8 months to current date
      calendar.add(Calendar.MONTH, 8);
      System.out.println("Updated Date = " + calendar.getTime());
   }
}
Current Date = Thu Nov 22 16:30:08 UTC 2018
Updated Date = Mon Jul 22 16:30:08 UTC 2019
C program to find the second largest and smallest numbers in an array

Enter the array elements and then, arrange the numbers in descending order by using the swapping technique. Later on, with the help of an index location, try to print the second largest and the second smallest element in an array.
An array is used to hold the group of common elements under one name.
The array operations in C programming language are as follows −
Insert
Delete
Search
Given below is an algorithm to find the second largest and the second smallest numbers in an array −
Step 1 − Declare and read the number of elements.
Step 2 − Declare and read the array size at runtime.
Step 3 − Input the array elements.
Step 4 − Arrange numbers in descending order.
Step 5 − Then, find the second largest and second smallest numbers by using an index.
Step 6 − Print the second largest and the second smallest numbers.
Given below is the C program to find the second largest and the second smallest numbers in an array −
#include<stdio.h>
void main(){
   int i,j,a,n,counter,ave,number[30];
   printf ("Enter the value of N\n");
   scanf ("%d", &n);
   printf ("Enter the numbers \n");
   for (i=0; i<n; ++i)
      scanf ("%d",&number[i]);
   for (i=0; i<n; ++i){
      for (j=i+1; j<n; ++j){
         if (number[i] < number[j]){
            a = number[i];
            number[i] = number[j];
            number[j] = a;
         }
      }
   }
   printf ("The numbers arranged in descending order are given below\n");
   for (i=0; i<n; ++i)
      printf ("%10d\n",number[i]);
   printf ("The 2nd largest number is = %d\n", number[1]);
   printf ("The 2nd smallest number is = %d\n", number[n-2]);
   ave = (number[1] +number[n-2])/2;
   counter = 0;
   for (i=0; i<n; ++i){
      if (ave==number[i])
         ++counter;
   }
   if (counter==0)
      printf("The average of 2nd largest & 2nd smallest is not in the array\n");
   else
      printf("The average of 2nd largest & 2nd smallest in array is %d in numbers\n", counter);
}
When the above program is executed, it produces the following result −
Enter the value of N

5
Enter the numbers
10
12
17
45
80

The numbers arranged in descending order are given below
80
45
17
12
10
The 2nd largest number is = 45
The 2nd smallest number is = 12
The average of 2nd largest & 2nd smallest is not in the array
Add a red border to an element in Bootstrap to indicate danger

To add a red border to an element, you need to implement the border-danger class.
Red border implement danger and you can set danger messages inside it.
Implementing the border-danger is quite easy −
<div class="new border border-danger">
  Red Border
</div>
Let us see an example to work with the border-danger Bootstrap 4 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>
    <style>
    .new {
      width: 120px;
      height: 120px;
      margin: 20px;
    }
    </style>
  </head>
<body>
  <div class="container">
    <p>Rectangle with red border:</p>
    <div class="new border border-danger">Red Border</div>
  </div>
</body>
</html>
Tryit Editor v3.7

Tryit: HTML table
How to retrieve the Azure VM vNet name using PowerShell?

To retrieve the Azure Virtual Network (vNet) or subnet name, we need the first name of the network interface of the VM. Below is the command to retrieve the name of the network interface.
$vm = Get-AzVM -VMName Testmachine2k16
TestMachine2k16 is the Azure VM name. Assuming this VM has a single NIC attached.
PS C:\> $nic = $vm.NetworkProfile.NetworkInterfaces
PS C:\> $networkinterface = ($nic.id -split '/')[-1]
PS C:\> $networkinterface
testmachine2k16619
So our NIC name is stored inside the $NetworkInterface variable.
If you have the multiple NICs attached, then use the below command to retrieve the NIC details.
$nics = $vm.NetworkProfile.NetworkInterfaces
foreach($nic in $nics) {
   ($nic.Id -split '/')[-1]
}
Once we have the nic details we can retrieve the NIC details using the Get-AzNetworkInterface command.
PS C:\> $nicdetails = Get-AzNetworkInterface -Name $networkinterface
vNet name is stored inside the IPConfigurations and Subnet property.
PS C:\> $nicdetails.IpConfigurations.Subnet
We need to retrieve the Subnet from the ID property. Use the below command to retrieve the same.
PS C:\> ($nicdetails.IpConfigurations.subnet.Id -split '/')[-3]
You will get the name of the vNet. For multiple NICs, repeat this process.
How to remove rows in data.table object in R that contains a specific number?

To remove rows in data.table object in R that contains a specific number, we can follow the below steps −
First of all, create a data.table object.
First of all, create a data.table object.
Then, use single square subsetting with apply function to remove rows that contains a specific number.
Then, use single square subsetting with apply function to remove rows that contains a specific number.
Let’s create a data.table object as shown below: −
library(data.table)
x<-sample(1:25,25)
y<-sample(1:25,25)
z<-sample(1:25,25)
DT<-data.table(x,y,z)
DT
On executing, the above script generates the below output(this output will vary on your system due to randomization) −
    x   y z
1:  24  3 24
2:  23  5 11
3:   2  2  8
4:  10  4  9
5:  21 12 20
6:   4 18 16
7:  11 19 19
8:   6 21 17
9:   9 23 23
10:  8  6 2
11: 20  7 15
12:  7 22 22
13: 13 17  4
14: 15 14 13
15: 25 16 14
16: 16  9 12
17:  1 24  5
18:  3 11 10
19: 19 20 25
20: 22 10  3
21: 14 25  7
22: 12  8  1
23: 18  1 18
24: 17 15 21
25:  5 13  6
    x  y  z
Remove rows that contains a specific number
Using single square subsetting with apply function to remove rows that contains 10 in data.table object DT −
library(data.table)
x<-sample(1:25,25)
y<-sample(1:25,25)
z<-sample(1:25,25)
DT<-data.table(x,y,z)
DT[!apply(DT==10,1,any),]
     x  y  z
1:  24  3 24
2:  23  5 11
3:   2  2  8
4:  21 12 20
5:   4 18 16
6:  11 19 19
7:   6 21 17
8:   9 23 23
9:   8  6  2
10: 20  7 15
11:  7 22 22
12: 13 17  4
13: 15 14 13
14: 25 16 14
15: 16  9 12
16:  1 24  5
17: 19 20 25
18: 14 25  7
19: 12  8  1
20: 18  1 18
21: 17 15 21
22:  5 13  6
    x  y  z
Extract a property from an array of objects in PHP

Given the below code, the task is to extract the ID of the my_object variable −
$my_object = Array
( [0] => stdClass Object
   (
      [id] => 12
   ),
   [1] => stdClass Object
   (
      [id] => 33
   ),
   [2] => stdClass Object
   (
      [id] => 59
   )
)
The array_map function can be used for older versions of PHP. Below is a demonstration of the same.
$object_id = array_map(create_function('$o', 'return $o->id;'), $objects);
For PHP version 5.5 or higher, the array_column function could be used. Below is a demonstration of the same −
$object_id = array_column($my_object, 'id');
This will produce the following output −
[12, 33, 59]
Readers-Writers Problem

The readers-writers problem relates to an object such as a file that is shared between multiple processes. Some of these processes are readers i.e. they only want to read the data from the object and some of the processes are writers i.e. they want to write into the object.
The readers-writers problem is used to manage synchronization so that there are no problems with the object data. For example - If two readers access the object at the same time there is no problem. However if two writers or a reader and writer access the object at the same time, there may be problems.
To solve this situation, a writer should get exclusive access to an object i.e. when a writer is accessing the object, no reader or writer may access it. However, multiple readers can access the object at the same time.
This can be implemented using semaphores. The codes for the reader and writer process in the reader-writer problem are given as follows −
The code that defines the reader process is given below −
wait (mutex);
rc ++;
if (rc == 1)
wait (wrt);
signal(mutex);
.
. READ THE OBJECT
.
wait(mutex);
rc --;
if (rc == 0)
signal (wrt);
signal(mutex);
In the above code, mutex and wrt are semaphores that are initialized to 1. Also, rc is a variable that is initialized to 0. The mutex semaphore ensures mutual exclusion and wrt handles the writing mechanism and is common to the reader and writer process code.
The variable rc denotes the number of readers accessing the object. As soon as rc becomes 1, wait operation is used on wrt. This means that a writer cannot access the object anymore. After the read operation is done, rc is decremented. When re becomes 0, signal operation is used on wrt. So a writer can access the object now.
The code that defines the writer process is given below:
wait(wrt);
.
. WRITE INTO THE OBJECT
.
signal(wrt);
If a writer wants to access the object, wait operation is performed on wrt. After that no other writer can access the object. When a writer is done writing into the object, signal operation is performed on wrt.
Counting the frequencies in a list using dictionary in Python

In this article we develop a program to calculate the frequency of each element present in a list.
Here we capture the items as the keys of a dictionary and their frequencies as the values.
 Live Demo
list = ['a','b','a','c','d','c','c']
frequency = {}
for item in list:
   if (item in frequency):
      frequency[item] += 1
   else:
      frequency[item] = 1
for key, value in frequency.items():
   print("% s -> % d" % (key, value))
Running the above code gives us the following result −
a -> 2
b -> 1
c -> 3
d -> 1
Here we use the in-built count() function to count the number of occurrences of an item in the list.
 Live Demo
list = ['a','b','a','c','d','c','c']
frequency = {}
for item in list:
   frequency[item] = list.count(item)
for key, value in frequency.items():
   print("% s -> % d" % (key, value))
Running the above code gives us the following result >
a -> 2
b -> 1
c -> 3
d -> 1
How do I select data from one table only where column values from that table match the column values of another table in MySQL?

For this, you can use subquery along with EXISTS. Let us first create a table −
mysql> create table DemoTable1
   -> (
   -> Id int,
   -> SubjectName varchar(20)
   -> );
Query OK, 0 rows affected (0.58 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1 values(111,'MySQL');
Query OK, 1 row affected (0.12 sec)
mysql> insert into DemoTable1 values(112,'MongoDB');
Query OK, 1 row affected (0.15 sec)
mysql> insert into DemoTable1 values(113,'Java');
Query OK, 1 row affected (0.17 sec)
mysql> insert into DemoTable1 values(114,'C');
Query OK, 1 row affected (0.27 sec)
mysql> insert into DemoTable1 values(115,'MySQL');
Query OK, 1 row affected (0.23 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1;
This will produce the following output −
+------+-------------+
| Id   | SubjectName |
+------+-------------+
|  111 | MySQL       |
|  112 | MongoDB     |
|  113 | Java        |
|  114 | C           |
|  115 | MySQL       |
+------+-------------+
5 rows in set (0.00 sec)
Here is the query to create second table −
mysql> create table DemoTable2
    -> (
    -> FirstName varchar(20),
    -> StudentSubject varchar(20)
    -> );
Query OK, 0 rows affected (0.73 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable2 values('Chris','MySQL');
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable2 values('Bob','MySQL');
Query OK, 1 row affected (0.12 sec)
mysql> insert into DemoTable2 values('Sam','MySQL');
Query OK, 1 row affected (0.12 sec)
mysql> insert into DemoTable2 values('Carol','C');
Query OK, 1 row affected (0.19 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable2;
This will produce the following output −
+-----------+----------------+
| FirstName | StudentSubject |
+-----------+----------------+
| Chris     | MySQL          |
| Bob       | MySQL          |
| Sam       | MySQL          |
| Carol     | C              |
+-----------+----------------+
4 rows in set (0.00 sec)
Here is the query to select data from one table only where column values from that table match the column values of another table −
mysql> select Id from DemoTable1
   -> where exists
   -> (
   -> select 1 from DemoTable2
   -> where SubjectName=StudentSubject
   -> );
This will produce the following output −
+------+
| Id   |
+------+
|  111 |
|  114 |
|  115 |
+------+
3 rows in set (0.00 sec)
TIKA - Extracting Image File

Given below is the program to extract content and meta data from a JPEG image.
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

import org.apache.tika.exception.TikaException;
import org.apache.tika.metadata.Metadata;
import org.apache.tika.parser.ParseContext;
import org.apache.tika.parser.jpeg.JpegParser;
import org.apache.tika.sax.BodyContentHandler;

import org.xml.sax.SAXException;

public class JpegParse {

   public static void main(final String[] args) throws IOException,SAXException, TikaException {

      //detecting the file type
      BodyContentHandler handler = new BodyContentHandler();
      Metadata metadata = new Metadata();
      FileInputStream inputstream = new FileInputStream(new File("boy.jpg"));
      ParseContext pcontext = new ParseContext();
      
      //Jpeg Parse
      JpegParser  JpegParser = new JpegParser();
      JpegParser.parse(inputstream, handler, metadata,pcontext);
      System.out.println("Contents of the document:" + handler.toString());
      System.out.println("Metadata of the document:");
      String[] metadataNames = metadata.names();
      
      for(String name : metadataNames) { 		        
         System.out.println(name + ": " + metadata.get(name));
      }
   }
}
Save the above code as JpegParse.java, and compile it from the command prompt by using the following commands −
javac JpegParse.java
java JpegParse 

Given below is the snapshot of Example.jpeg −
The JPEG file has the following properties −
After executing the program, you will get the following output.
Output −
Contents of the document:

Meta data of the document:

Resolution Units: inch
Compression Type: Baseline
Data Precision: 8 bits
Number of Components: 3
tiff:ImageLength: 3000
Component 2: Cb component: Quantization table 1, Sampling factors 1 horiz/1 vert
Component 1: Y component: Quantization table 0, Sampling factors 2 horiz/2 vert
Image Height: 3000 pixels
X Resolution: 300 dots
Original Transmission Reference: 53616c7465645f5f2368da84ca932841b336ac1a49edb1a93fae938b8db2cb3ec9cc4dc28d7383f1
Image Width: 4000 pixels
IPTC-NAA record: 92 bytes binary data
Component 3: Cr component: Quantization table 1, Sampling factors 1 horiz/1 vert
tiff:BitsPerSample: 8
Application Record Version: 4
tiff:ImageWidth: 4000
Y Resolution: 300 dots

 Print
 Add Notes
 Bookmark this page
\lim - Tex Command

\lim - Used to draw lim symbol.
{ \lim }
\lim command draws lim symbol.

\lim_{n\rightarrow\infty} f(x) = \ell

limn→∞f(x)=l



\lim_{n\rightarrow\infty} f(x) = \ell

limn→∞f(x)=l


\lim_{n\rightarrow\infty} f(x) = \ell

    14 Lectures 
     52 mins

 Ashraf Said

    11 Lectures 
     1 hours 

 Ashraf Said

    9 Lectures 
     1 hours 

 Emenwa Global, Ejike IfeanyiChukwu

    29 Lectures 
     2.5 hours 

 Mohammad Nauman

    14 Lectures 
     1 hours 

 Daniel Stern

    15 Lectures 
     47 mins

 Nishant Kumar
 Print
 Add Notes
 Bookmark this page
Change Image Opacity on Mouse Over

Use the opacity property with the :hover selector to change the opacity on mouse-over. Following is the code to change image opacity on mouse over −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
body{
   font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
.transparent{
   width:270px;
   height:200px;
   opacity: 1;
   transition: 0.3s;
}
.transparent:hover{
   opacity: 0.3;
}
</style>
</head>
<body>
<h1>Image opacity on hover example</h1>
<img class="transparent" src="https://i.picsum.photos/id/505/800/800.jpg" >
<h2>Hover over the above image to change its opacity</h2>
</body>
</html>
The above code will produce the following output −
jQuery | :contains() Selector - GeeksforGeeks

27 Feb, 2019
The :contains() selector in jQuery is used to select elements containing the specified string.
Syntax:
$(":contains(text)")
Parameters: This selector contains single parameter text which is mandatory and used to specify the text to find.
Example 1: This example uses :contains() selector to select element.
<!DOCTYPE html><html>   <head>      <title>jQuery :contains() Selector</title>              <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">      </script>              <!-- Script to use :contains selector -->      <script>         $(document).ready(function(){           $("h3:contains(is)").css("background-color", "green");         });      </script>   </head>        <body>      <center>         <h1 id="geeks1" style = "color:green;">GeeksForGeeks</h1>         <h2 id="geeks2">jQuery :contains() Selector</h2>         <h3>Who is your favourite Geek:</h3>                    <div id="choose">             <h3>Geek 1</h3>             <h3>Geek 2</h3>             <h3>Geek 3</h3>         </div>      </center>   </body></html>
Output:
Example 2: This example use :contains() selector to select element.
<!DOCTYPE html><html>   <head>      <title>jQuery :contains() Selector</title>              <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">      </script>              <!-- Script to use :contains selector -->      <script>         $(document).ready(function(){           $("h3:contains(Geek)").css("background-color", "green");         });      </script>   </head>   <body>      <center>         <h1 id="geeks1" style = "color:green;">GeeksForGeeks</h1>         <h2 id="geeks2">jQuery :contains() Selector</h2>         <h3>Who is your favourite candidate:</h3>                    <div id="choose">             <h3>Geek 1</h3>             <h3>Geek 2</h3>             <h3>Geek 3</h3>         </div>      </center>   </body></html>
Output:
jQuery-Selectors
JQuery
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Form validation using jQuery
How to Dynamically Add/Remove Table Rows using jQuery ?
Scroll to the top of the page using JavaScript/jQuery
How to get the ID of the clicked button using JavaScript / jQuery ?
jQuery | children() with Examples
Top 10 Front End Developer Skills That You Need in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Apache Camel - Endpoints

We have learnt about how the endpoints look like in our integration code. The expressions that we have used so far such as file:/order, jms:orderQueue, direct:distributeOrderDSL are the endpoints. As you see, they follow the URI specification formats. While evaluating this URI, the CamelContext creates the Endpoint instance; you need not worry about instantiating Endpoint implementation in your DSL.
Taking our earlier examples, you specify endpoints in Java DSL as here −
from ("file:/order").to("jms:orderQueue");

And in Spring as here −
<route>
   <from uri = "file:/order"/>
   <to uri = "jms:orderQueue"/>
</route>

In both the cases, the endpoint is a constant string. In certain cases, you may like to build this string at runtime. You can do so by using Java String formatter methods. Camel provides another simpler approach to create these URI strings at runtime. For this purpose, Camel provides fromF and toF methods that accept the arguments with the user-specified parameters. The following statement illustrates the use of toF method −
from("direct:distributeOrderDSL”).toF("file://%s?fileName=%s", path, name);

Because of these methods, the need for using the Java built-in String formatter methods is obviated.
Camel uses Simple language by default to compute the endpoint expression. The Simple language was designed primarily to evaluate Expressions and Predicateswithout bothering much about the intricacies of XPath. For evaluating predicates, you can combine another language such as xpath with the default Simple language. This is done by using the plus sign to separate the other language. The code snippet here shows how to concatenate xpath string to the expression written in Simple.
from("direct:start")
.toD("jms:${orderQueue}+language:xpath:/order/@id");

In Spring, you can achieve the same as here −
<route>
   <from uri = "direct:start"/>
   <toD uri = "jms:${orderQueue}+language:xpath:/order/@id"/>
</route>

You may concatenate as many languages as you want, each separated with a plus sign from the previous one. The list of supported languages can be found here.

    46 Lectures 
     3.5 hours 

 Arnab Chakraborty

    23 Lectures 
     1.5 hours 

 Mukund Kumar Mishra

    16 Lectures 
     1 hours 

 Nilay Mehta

    52 Lectures 
     1.5 hours 

 Bigdata Engineer

    14 Lectures 
     1 hours 

 Bigdata Engineer

    23 Lectures 
     1 hours 

 Bigdata Engineer
 Print
 Add Notes
 Bookmark this page
Powershell - Move File

Move-Item cmdlet is used to move a file by passing the path of the file to be moved and destination path where the file is to be moved.
In this example, we'll move a folder D:\Temp\Test\Test.txt to D:\Temp\Test1
Type the following command in PowerShell ISE Console
Move-Item D:\temp\Test\Test.txt D:\temp\Test1
You can see the Test.txt in Test1 directory now. Test.txt has been moved from Test to Test1.

    15 Lectures 
     3.5 hours 

 Fabrice Chrzanowski

    35 Lectures 
     2.5 hours 

 Vijay Saini

    145 Lectures 
     12.5 hours 

 Fettah Ben
 Print
 Add Notes
 Bookmark this page
Get Hash Code for Integer in Java

The HashCode for an Integer can be obtained using the hashCode() method in Java. This method does not accept any parameters and it returns a hash code value of the Integer object.
A program that demonstrates the hashCode() method in Java is given as follows:
 Live Demo
import java.lang.*;
public class Demo {
   public static void main(String args[]) {
      Integer i = new Integer(60);
      System.out.println("The integer value is: " + i);
      System.out.println("The Hashcode for the above value is: " + i.hashCode());
   }
}
The integer value is: 60
The Hashcode for the above value is: 60
Now let us understand the above program.
The Integer i is defined. Then the Integer value is printed and its HashCode is also printed using the hashCode() method. A code snippet which demonstrates this is as follows:
Integer i = new Integer(60);
System.out.println("The integer value is: " + i);
System.out.println("The Hashcode for the above value is: " + i.hashCode());
Python Tweepy – Getting the number of tweets a user has liked - GeeksforGeeks

18 Jun, 2020
In this article we will see how we can get number of statuses/tweets a user has liked/favourited. The favourites_count attribute provides us with an integer which denotes the number of statuses the user has favourited.
In order to get the number of statuses the user has favourited, we have to do the following :
Identify the user ID or the screen name of the profile.Get the User object of the profile using the get_user() method with the user ID or the screen name.From this object, fetch the favourites_count attribute present in it.
Identify the user ID or the screen name of the profile.
Get the User object of the profile using the get_user() method with the user ID or the screen name.
From this object, fetch the favourites_count attribute present in it.
Example 1: Consider the following profile :We will use the user ID to fetch the user. The user ID of the above mentioned profile is 57741058.
# import the moduleimport tweepy  # assign the values accordinglyconsumer_key = ""consumer_secret = ""access_token = ""access_token_secret = ""  # authorization of consumer key and consumer secretauth = tweepy.OAuthHandler(consumer_key, consumer_secret)  # set access to user's access key and access secret auth.set_access_token(access_token, access_token_secret)  # calling the api api = tweepy.API(auth)  # the ID of the userid = 57741058  # fetching the useruser = api.get_user(id)  # fetching the favourites_count attributefavourites_count = user.favourites_count  print("The number of tweets the user has liked are : " + str(favourites_count))
Output :
The number of tweets the user has liked are : 483

Example 2: Consider the following profile :We will use the screen name to fetch the user. The screen name of the above mentioned profile is PracticeGfG.
# the screen name of the userscreen_name = "PracticeGfG"  # fetching the useruser = api.get_user(screen_name)  # fetching the favourites_count attributefavourites_count = user.favourites_count  print("The number of tweets the user has liked are : " + str(favourites_count))
Output :
The number of tweets the user has liked are : 0

Python-Tweepy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Enumerate() in Python
How to Install PIP on Windows ?
Different ways to create Pandas Dataframe
Python String | replace()
Create a Pandas DataFrame from Lists
Reading and Writing to text files in Python
*args and **kwargs in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Display the month number with SimpleDateFormat(“M”) in Java

To display the month number, use the SimpleDateFormat(“M”)
// displaying month number
Format f = new SimpleDateFormat("M");
String strMonth = f.format(new Date());
System.out.println("Month Number = "+strMonth);
Since, we have used the Format and SimpleDateFormat class above, therefore import the following packages. With that, we have also used the Date.
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Date;
 Live Demo
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Calendar;
public class Demo {
   public static void main(String[] args) throws Exception {
      // displaying current date and time
      Calendar cal = Calendar.getInstance();
      SimpleDateFormat simpleformat = new SimpleDateFormat("dd/MMMM/yyyy hh:mm:s");
      System.out.println("Today's date and time = "+simpleformat.format(cal.getTime()));
      // displaying date
      Format f = new SimpleDateFormat("dd/MMMM/yyyy");
      String strDate = f.format(new Date());
      System.out.println("Current Date = "+strDate);
      // displaying month number
      f = new SimpleDateFormat("M");
      String strMonth = f.format(new Date());
      System.out.println("Month Number = "+strMonth);
      // current time
      f = new SimpleDateFormat("HH.mm.ss Z");
      String strTime = f.format(new Date());
      System.out.println("Current Time = "+strTime);
      // displaying hour
      f = new SimpleDateFormat("H");
      String strHour = f.format(new Date());
      System.out.println("Current Hour = "+strHour);
      // displaying minutes
      f = new SimpleDateFormat("mm");
      String strMinute = f.format(new Date());
      System.out.println("Current Minutes = "+strMinute);
      // displaying seconds
      f = new SimpleDateFormat("ss");
      String strSeconds = f.format(new Date());
      System.out.println("Current Seconds = "+strSeconds);
   }
}
Today's date and time = 26/November/2018 09:16:16
Current Date = 26/November/2018
Month Number = 11
Current Time = 09.16.16 +0000
Current Hour = 9
Current Minutes = 16
Current Seconds = 16
String to binary in JavaScript

We are required to write a JavaScript function that takes in a string as the only input. The function should construct and return the binary representation of the input string.
For example −
If the input string is −
const str = 'Hello World';
Then the output should be −
const output = '1001000 1100101 1101100 1101100 1101111 100000 1010111
1101111 1110010 1101100 1100100';
The code for this will be −
const str = 'Hello World';
const textToBinary = (str = '') => {
   let res = '';
   res = str.split('').map(char => {
      return char.charCodeAt(0).toString(2);
   }).join(' ');
   return res;
};
console.log(textToBinary('Hello World'));
And the output in the console will be −
1001000 1100101 1101100 1101100 1101111 100000 1010111 1101111 1110010 1101100 1100100
Python Pandas - Get the hour of the day component of the Period

To get the hour of the day component of the Period, use the period.hour property.
At first, import the required libraries −
import pandas as pd
The pandas.Period represents a period of time. Creating two Period objects −
period1 = pd.Period("2020-09-23 05:55:30")
period2 = pd.Period(freq="H", year = 2021, month = 7, day = 16, hour = 2, minute = 35)
Get the hour of the day from two Period objects −
res1 = period1.hour
res2 = period2.hour
Following is the code −
import pandas as pd

# The pandas.Period represents a period of time
# creating two Period objects
period1 = pd.Period("2020-09-23 05:55:30")
period2 = pd.Period(freq="H", year = 2021, month = 7, day = 16, hour = 2, minute = 35)

# display the Period objects
print("Period1...\n", period1)
print("Period2...\n", period2)

# get the hour of the day from two Period objects
res1 = period1.hour
res2 = period2.hour

# Return the hour of the day from the two Period objects
print("\nHour of the day from the 1st Period object ...\n", res1)
print("\nHour of the day from the 2nd Period object...\n", res2)
This will produce the following code −
Period1...
2020-09-23 05:55:30

Period2...
2021-07-16 02:00

Hour of the day from the 1st Period object ...
5

Hour of the day from the 2nd Period object...
2
How to ignore a field of JSON object using the Jackson library in Java?


The Jackson @JsonIgnore annotation can be used to ignore a certain property or field of a Java object. The property can be ignored both when reading JSON into Java objects and when writing Java objects into JSON. We can use the readValue() and writeValueAsString() methods of ObjectMapper class to read a JSON to Java Object and to write a Java object to JSON.
@Target(value={ANNOTATION_TYPE,METHOD,CONSTRUCTOR,FIELD})
@Retention(value=RUNTIME)
public @interface JsonIgnore
import java.io.*;
import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.*;
public class JsonIgnoreTest {
   public static void main(String[] args) throws IOException {
      Customer customer = new Customer("110", "Surya Kiran", "Chennai");
      System.out.println(customer);
      ObjectMapper mapper = new ObjectMapper();
      String jsonString = mapper.writeValueAsString(customer);
      System.out.println("JSON: " + jsonString);
      System.out.println("---------");
      jsonString = "{\"id\":\"120\",\"name\":\"Devaraj\", \"address\":\"Banglore\"}";
      System.out.println("JSON: " + jsonString);
      customer = mapper.readValue(jsonString, Customer.class);
      System.out.println(customer);
   }
}
// Customer class
class Customer {
   private String id;
   private String name;
   @JsonIgnore
   private String address;
   public Customer() {
   }
   public Customer(String id, String name, String address) {
      this.id = id;
      this.name = name;
      this.address = address;
   }
   public String getId() {
      return id;
   }
   public String getName() {
      return name;
   }
   public String getAddress() {
      return address;
   }
   @Override
   public String toString() {
      return "Customer [id=" + id + ", name=" + name + ", address=" + address + "]";
   }
}
Customer [id=110, name=Surya Kiran, address=Chennai]
JSON: {"id":"110","name":"Surya Kiran"}
---------
JSON: {"id":"120","name":"Devaraj", "address":"Banglore"}
Customer [id=120, name=Devaraj, address=null]
Loop through all MongoDB collections and execute query?

First of all, you need to get your collection with the help of getCollectionNames().
The database name is “test”. Let us loop through all MongoDB collections and execute the query. The query is as follows −
> db.getCollectionNames().forEach(function(collectioNameDemo)
... {
   ... var nextDemo = db[(collectioNameDemo) ].find().sort({_id:-1}).limit(1);
   ... if (nextDemo.hasNext())
   ... {
      ... printjson(nextDemo.next()._id.getTimestamp());
   ... }
... });
The following is the output −
ISODate("2019-02-21T18:52:43Z")
ISODate("2019-03-19T17:49:00Z")
ISODate("2019-03-06T15:40:12Z")
ISODate("2019-03-15T16:31:50Z")
ISODate("2019-02-21T15:40:52Z")
ISODate("2019-03-06T06:14:37Z")
ISODate("2019-02-21T19:29:15Z")
ISODate("2019-03-15T13:35:33Z")
ISODate("2019-03-14T21:13:58Z")
ISODate("2019-03-18T22:02:54Z")
ISODate("2019-03-22T18:01:45Z")
ISODate("2019-03-06T16:21:14Z")
ISODate("2019-02-20T15:04:32Z")
ISODate("2019-03-06T07:45:42Z")
ISODate("2019-03-19T12:33:17Z")
ISODate("2019-03-20T21:39:21Z")
ISODate("2019-03-15T16:44:26Z")
ISODate("2019-03-22T06:20:45Z")
ISODate("2019-02-21T16:40:55Z")
ISODate("2019-02-21T12:45:20Z")
ISODate("2019-03-06T16:05:48Z")
ISODate("2019-03-06T16:00:08Z")
ISODate("2019-02-28T12:43:56Z")
ISODate("2019-03-20T22:11:41Z")
ISODate("2019-03-06T05:56:45Z")
ISODate("2019-03-06T07:34:12Z")
ISODate("2019-03-14T21:00:16Z")
ISODate("2019-02-28T10:33:39Z")
ISODate("2019-03-06T05:11:10Z")
ISODate("2019-02-28T09:44:28Z")
ISODate("2019-03-06T10:13:22Z")
ISODate("2019-03-17T21:35:26Z")
C# Queryable TakeLast() Method

Get specified number of elements from the end using the TakeLast() method.
The following is our array.
int[] pages = { 492, 290, 129, 602, 152 };
Now, use OrderBy to order the elements in ascending order. Then use the TakeLast() method to get specified number of elements from the end.
marks.AsQueryable().OrderByDescending(s => s).Take(5);
Let us see the complete example.
 Live Demo
using System;
using System.Linq;
using System.Collections.Generic;
public class Demo {
   public static void Main() {
      // pages of books
      int[] pages = { 492, 290, 129, 602, 152 };
      // get pages of last two books
      IEnumerable<int> last = pages.AsQueryable().OrderBy(s => s).TakeLast(2);
      foreach (int res in last) {
         Console.WriteLine(res);
      }
   }
}
492
602
How to check whether a string ends with one from a list of suffixes in Python?

Python has a method endswith(tuple) in the String class. This method accepts a tuple of strings that you want to search and is called on a string object. You can call this method in the following way:
string = 'core java'
print(string.endswith(('txt', 'xml', 'java', 'orld')))
OUTPUT
True
There is another way to find if a string ends with a given list of suffixes. You can use re.search from the re module(regular expression) to do so. Regex interprets $ as end of line. We also need to seperate out the suffixes using grouping and | symbol in regex. For example,
import re
string = 'core java'
print(bool(re.search('(java|xml|py|orld)$', string)))
print(bool(re.search('(java|xml|py|orld)$', 'core java')))
print(bool(re.search('(java|xml|py)$', 'Hello world')))
OUTPUT
True
True
False
re.search returns an object, to check if it exists or not, we need to convert it to a boolean using bool(). You can read more about Python regex here.
PHP | getimagesize() Function - GeeksforGeeks

01 Aug, 2021
The getimagesize() function in PHP is an inbuilt function which is used to get the size of an image. This function accepts the filename as a parameter and determines the image size and returns the dimensions with the file type and height/width of image.
Syntax:
array getimagesize( $filename, $image_info )
Parameters: This function accepts two parameters as mentioned above and described below:
$filename: It is a mandatory parameter which specifies the image file name.
$image_info: It is an optional parameter which allows you to extract some extended information from the image file such as the different JPG APP markers as associative array.
Return Value: It returns the dimensions along with the file type and a height/width text string.
Exceptions:
The getimagesize() function returns zero for width and height if the formats which may contain no image or multiple images.
The imageinfo parameter only supports JFIF files.
The getimagesize() function will generate an error of level E_WARNING, if accessing the filename image is impossible.
The getimagesize() will generate an error of level E_NOTICE, if there is any error in reading.
Below programs illustrate the getimagesize() function in PHP:
Note: The image (geeks.png) given below used in the following program.
Program 1:
<?php  // Calling getimagesize() function$image_info = getimagesize("geeks.png");print_r($image_info);?>
Output:
Array ( [0] => 667 
        [1] => 184 
        [2] => 3 
        [3] => width="667" height="184" 
        [bits] => 8 
        [mime] => image/png )

Program 2:
<?php  // Calling getimagesize() functionlist($width, $height, $type, $attr) = getimagesize("geeks.png");   // Displaying dimensions of the imageecho "Width of image : " . $width . "<br>";  echo "Height of image : " . $height . "<br>";  echo "Image type :" . $type . "<br>";  echo "Image attribute :" .$attr;?>
Output:
Width of image : 667
Height of image : 184
Image type :3
Image attribute :width="667" height="184"

Reference: http://php.net/manual/en/function.getimagesize.php
PHP is a server-side scripting language designed specifically for web development. You can learn PHP from the ground up by following this PHP Tutorial and PHP Examples.
PHP-function
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to execute PHP code using command line ?
How to Insert Form Data into Database using PHP ?
PHP in_array() Function
How to convert array to string in PHP ?
How to delete an array element based on key in PHP?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?