code-rag-bench/online-tutorials huggingface dataset:
numpy.hsplit

The numpy.hsplit is a special case of split() function where axis is 1 indicating a horizontal split regardless of the dimension of the input array.
import numpy as np 
a = np.arange(16).reshape(4,4) 

print 'First array:' 
print a 
print '\n'  

print 'Horizontal splitting:' 
b = np.hsplit(a,2) 
print b 
print '\n'
Its output would be as follows −
First array:
[[ 0 1 2 3]
 [ 4 5 6 7]
 [ 8 9 10 11]
 [12 13 14 15]]

Horizontal splitting:                                                         
[array([[ 0,  1],                                                             
       [ 4,  5],                                                              
       [ 8,  9],                                                              
       [12, 13]]), array([[ 2,  3],                                           
       [ 6,  7],                                                              
       [10, 11],                                                              
       [14, 15]])] 


    63 Lectures 
     6 hours 

 Abhilash Nelson

    19 Lectures 
     8 hours 

 DATAhill Solutions Srinivas Reddy

    12 Lectures 
     3 hours 

 DATAhill Solutions Srinivas Reddy

    10 Lectures 
     2.5 hours 

 Akbar Khan

    20 Lectures 
     2 hours 

 Pruthviraja L

    63 Lectures 
     6 hours 

 Anmol
 Print
 Add Notes
 Bookmark this page
auditctl - Unix, Linux Command

The following describes the valid actions for the rule:



auditctl -a exit,always -S open -F success=0 

auditctl -a exit,always -S truncate -F success=0 


could be re-written as one rule:



auditctl -a exit,always -S open -S truncate -F success=0 


Also, try to use file system auditing wherever practical. This improves performance. For example, if you were wanting to capture all failed opens & truncates like above, but were only concerned about files in /etc and didn’t care about /usr or /sbin, its possible to use this rule:



auditctl -a exit,always -S open -S truncate -F dir=/etc -F success=0 


This will be higher performance since the kernel will not evaluate it each and every syscall. It will be handled by the filesystem auditing code and only checked on filesystem related syscalls.



auditctl -a entry,always -S all -F pid=1005 


To see files opened by a specific user:



auditctl -a exit,always -S open -F auid=510 


To see unsuccessful open call’s:



auditctl -a exit,always -S open -F success=0 


To watch a file for changes (2 ways to express):



auditctl -w /etc/shadow -p wa 
auditctl -a exit,always -F path=/etc/shadow -F perm=wa 


To recursively watch a directory for changes (2 ways to express):



auditctl -w /etc/ -p wa 
auditctl -a exit,always -F dir=/etc/ -F perm=wa 





auditd (8)
auditd (8)

Advertisements


    129 Lectures 
     23 hours 

 Eduonix Learning Solutions

    5 Lectures 
     4.5 hours 

 Frahaan Hussain

    35 Lectures 
     2 hours 

 Pradeep D

    41 Lectures 
     2.5 hours 

 Musab Zayadneh

    46 Lectures 
     4 hours 

 GUHARAJANM

    6 Lectures 
     4 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
Global and Local Variables in Java

Local variables are declared in methods, constructors, or blocks. They are created when the method, constructor or block is entered and the variable will be destroyed once it exits the method, constructor, or block.
Access modifiers cannot be used for local variables. Local variables are visible only within the declared method, constructor, or block. These variables are implemented at stack level internally. Here, let us see an example of local variable −
 Live Demo
public class Demo {
   public void Rank() {
      int rank = 0;
      rank = rank + 7;
      System.out.println("Rank = " + rank);
   }
   public static void main(String args[]) {
      Demo d = new Demo();
      d.Rank();
   }
}
Rank = 7
There is no such concept of Global Variables in Java.
How to create an Animated Art on Your Linux Terminal?

Using the characters like - , / or | and many other from the keyboard, we can create animation characters. These characters can be static as well as moving in the screen. All this involves programming using shell scripting. These scripts are bundled into libraries or packages which can be installed in the terminal. Below we will see the examples of these animations.
This package produces a train animation when run from the terminal. But first we install it and then simple type sl in the terminal.
$ sudo apt-get install sl
$ sl
Running the above code gives us the following result −
We can create an animation of the castle by using the below command. In this url, you will also find a host of many other animated files.
curl -s http://artscene.textfiles.com/vt100/castle.vt | pv -q -L 9600
Running the above code gives us the following result −
We can also use a simple command line utility called figlet to get various ASCII text. First we have to install it, then we run it using various options along with giving the text that we want to animate.
$ sudo apt install figlet toilet
$ figlet -f slant "Today"
Running the above code gives us the following result −
JavaScript: Adjacent Elements Product Algorithm

We are given an array of integers. We are required to find the pair of adjacent elements that have the largest product and return that product.
For example −
If the input array is −
const arr = [3, 6, -2, -5, 7, 3];
Then the output should be 21 because [7, 3] is the pair with the greatest sum.
Following is the code −
const arr = [3, 6, -2, -5, 7, 3];
const adjacentElementsProduct = (arr = []) => {
   let prod, ind;
   for (ind = 1; ind < arr.length; ind++) {
      if (ind === 1 || arr[ind - 1] * arr[ind] > prod) {
         prod = arr[ind - 1] * arr[ind];
      };
   };
   return prod;
};
console.log(adjacentElementsProduct(arr));
Following is the output on console −
21
How to extract date from a string in Python?

You need to know the format of date that can be there in the string in order to extract it. You can simply use a regular expression to extract the date and "datetime.datetime.strptime" to parse the date. For example, If you have the date in a string in the format YYYY-MM-DD, you can use the following code to extract and parse this date,
import re, datetime
s = "I have a meeting on 2018-12-10 in New York"
match = re.search('\d{4}-\d{2}-\d{2}', s)
date = datetime.datetime.strptime(match.group(), '%Y-%m-%d').date()
print date
This will give the output −
2018-12-10
C# program to add two matrices

Firstly, set three arrays.
int[, ] arr1 = new int[20, 20];
int[, ] arr2 = new int[20, 20];
int[, ] arr3 = new int[20, 20];
Now users will enter values in both the matrices. We have to set the row and size columns as n=3, since we want a square matrix of 3x3 size i.e 9 elements.
Add both the matrices and print the third array that has the sum.
for(i=0;i<n;i++)
for(j=0;j<n;j++)
arr3[i,j]=arr1[i,j]+arr2[i,j];
The following is the complete code to add two matrices in C#.
 Live Demo
using System;
public class Exercise19 {
   public static void Main() {
      int i, j, n;
      int[, ] arr1 = new int[20, 20];
      int[, ] arr2 = new int[20, 20];
      int[, ] arr3 = new int[20, 20];
      // setting matrix row and columns size
      n = 3;
      Console.Write("Enter elements in the first matrix:\n");
      for (i = 0; i < n; i++) {
         for (j = 0; j < n; j++) {
            arr1[i, j] = Convert.ToInt32(Console.ReadLine());
         }
      }
      Console.Write("Enter elements in the second matrix:\n");
      for (i = 0; i < n; i++) {
         for (j = 0; j < n; j++) {
            arr2[i, j] = Convert.ToInt32(Console.ReadLine());
         }
      }
      Console.Write("\nFirst matrix is:\n");
      for (i = 0; i < n; i++) {
         Console.Write("\n");
         for (j = 0; j < n; j++)
         Console.Write("{0}\t", arr1[i, j]);
      }
      Console.Write("\nSecond matrix is:\n");
      for (i = 0; i < n; i++) {
         Console.Write("\n");
         for (j = 0; j < n; j++)
         Console.Write("{0}\t", arr2[i, j]);
      }
      for (i = 0; i < n; i++)
      for (j = 0; j < n; j++)
      arr3[i, j] = arr1[i, j] + arr2[i, j];
      Console.Write("\nAdding two matrices: \n");
      for (i = 0; i < n; i++) {
         Console.Write("\n");
         for (j = 0; j < n; j++)
         Console.Write("{0}\t", arr3[i, j]);
      }
      Console.Write("\n\n");
   }
}
Enter elements in the first matrix:
Enter elements in the second matrix:

First matrix is:

000
000
000
Second matrix is:

000
000
000
Adding two matrices:

000
000
000
C - Strings

Strings are actually one-dimensional array of characters terminated by a null character '\0'. Thus a null-terminated string contains the characters that comprise the string followed by a null.
The following declaration and initialization create a string consisting of the word "Hello". To hold the null character at the end of the array, the size of the character array containing the string is one more than the number of characters in the word "Hello."
char greeting[6] = {'H', 'e', 'l', 'l', 'o', '\0'};

If you follow the rule of array initialization then you can write the above statement as follows −
char greeting[] = "Hello";

Following is the memory presentation of the above defined string in C/C++ −
Actually, you do not place the null character at the end of a string constant. The C compiler automatically places the '\0' at the end of the string when it initializes the array. Let us try to print the above mentioned string −
#include <stdio.h>

int main () {

   char greeting[6] = {'H', 'e', 'l', 'l', 'o', '\0'};
   printf("Greeting message: %s\n", greeting );
   return 0;
}
When the above code is compiled and executed, it produces the following result −
Greeting message: Hello

C supports a wide range of functions that manipulate null-terminated strings −
strcpy(s1, s2);
Copies string s2 into string s1.
strcat(s1, s2);
Concatenates string s2 onto the end of string s1.
strlen(s1);
Returns the length of string s1.
strcmp(s1, s2);
Returns 0 if s1 and s2 are the same; less than 0 if s1<s2; greater than 0 if s1>s2.
strchr(s1, ch);
Returns a pointer to the first occurrence of character ch in string s1.
strstr(s1, s2);
Returns a pointer to the first occurrence of string s2 in string s1.
The following example uses some of the above-mentioned functions −
#include <stdio.h>
#include <string.h>

int main () {

   char str1[12] = "Hello";
   char str2[12] = "World";
   char str3[12];
   int  len ;

   /* copy str1 into str3 */
   strcpy(str3, str1);
   printf("strcpy( str3, str1) :  %s\n", str3 );

   /* concatenates str1 and str2 */
   strcat( str1, str2);
   printf("strcat( str1, str2):   %s\n", str1 );

   /* total lenghth of str1 after concatenation */
   len = strlen(str1);
   printf("strlen(str1) :  %d\n", len );

   return 0;
}
When the above code is compiled and executed, it produces the following result −
strcpy( str3, str1) :  Hello
strcat( str1, str2):   HelloWorld
strlen(str1) :  10

 Print
 Add Notes
 Bookmark this page
Shell Script To Check the String For a Particular Condition

14 Sep, 2021
Here, we are going to write a shell script that will echo (print) a suitable message if the accepted string does not meet a particular condition. Suppose we have given some certain conditions then our task is to print the message if the accepted string doesn’t match the condition.
Example 1: 
If the accepted string’s length is smaller than 10, we will display a message saying “String is too short“.
Input:  "abcdef"
Output:  String is too short
Length is 6, which is smaller than 10.
Approach:
We will take a string from the user
We have to find the length of the string so that we can decide whether it is smaller or larger than 10.
We will find the length using the following command:
len=`echo -n $str | wc -c`
Below is the Implementation:
# Shell script to print message 
# when condition doesn't matched

# taking user input
echo "Enter the String : "
read string

# Finding the length of string 
# -n flag to avoid new line
# wc -c count the chars in a file
len=`echo -n $string | wc -c`

# Checking if length is smaller
# than 10 or not
if [ $len -lt 10 ]
    then
        # if length is smaller 
        # print this message
        echo "String is too short."
fi
Output:
Example 2: We will accept two input String and find whether both are equal or not.
String1 -> a = “abc”
String2 -> b = “abc”
Here a and b are equal.
Below is the implementation:
# Shell script to check whether two 
# input strings is equal

# take user input
echo "Enter string a : "
read a

echo "Enter string b : "
read b

# check equality of input
if [ "$a" = "$b" ]; then

    # if equal print equal
    echo "Strings are equal."
else
      # if not equal
    echo "Strings are not equal."
fi
Output:
Geeks
Geeks
Strings are equal.
Example 3:
We are working with strings, so now we will take two strings as input and check which of the two is greater in respect of lexicographical (alphabetical) order.
string1 > string2 : The greater than operator returns true if the left operand is greater than the right sorted by lexicographical (alphabetical) order.
string1 < string2 : The less than operator returns true if the right operand is greater than the right sorted by lexicographical (alphabetical) order.
# Shell script to check which 
# string is lexicographically
# larger

# user input
echo "Enter String a : "
read a

echo "Enter String b : "
read b

# if a is greater than b
if [[ "$a" > "$b" ]]; then
    echo "${a} is lexicographically greater then ${b}."

# if b is greater than a
elif [[ "$a" < "$b" ]]; then
    echo "${b} is lexicographically greater than ${a}."

# if both are equal
else
    echo "Strings are equal"
fi
Output:
abc
def
def is lexicographically greater than abc.
kapoorsagar226
Picked
Shell Script
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Remove sublists that are present in another sublist

08 Apr, 2019
Given a list of lists, write a Python program to remove sublists from the given list of lists that are present in another sublist.
Examples:
Input : [['a', 'b', 'c'], ['a', 'c'], ['a', 'b', 'c'], ['d']]
Output : [['a', 'b', 'c'], ['d']]

Input : [[1], [1, 2], [1, 2, 3], [0], [0, 1]]
Output : [[1, 2, 3], [0, 1]]

 Approach #1 : Using Python Set (If order of list doesn’t matter)
This approach makes use of Python sets. Create two empty lists ‘curr_res’ to store current sublist and ‘result’ to store the finalized sublists. Convert the sub-lists in the given list of lists to sets and sort them by length in reverse order, so that you can iterate through them and add each set to the curr_res only if it is not a subset of any of the existing sets in the curr_res.The only drawback of this approach is that it may produce the result in an unordered way(Since sets are unordered).
# Python3 program to remove sublists from# list of lists that are in another sublist  def removeSublist(lst):    curr_res = []    result = []    for ele in sorted(map(set, lst), key = len, reverse = True):        if not any(ele <= req for req in curr_res):            curr_res.append(ele)            result.append(list(ele))              return result      # Driver codelst = [['a', 'b', 'c'], ['a', 'b'], ['a', 'b', 'c'], ['d']]print(removeSublist(lst))
[['c', 'b', 'a'], ['d']]

 Approach #2 : Using Python Dictionary (If order of list matters)
Dict may not always produce ordered output, therefore you can use OrderedDict from collections module.
# Python3 program to remove sublists from# list of lists that are in another sublistfrom collections import OrderedDict  def removeSublist(lst):    curr_result = []    result = []    for ele in sorted(map(OrderedDict.fromkeys, lst), key = len, reverse = True):        if not any(ele.keys() <= req.keys() for req in curr_result):            curr_result.append(ele)            result.append(list(ele))                  return result      # Driver codelst = [['a', 'b', 'c'], ['a', 'b'], ['a', 'b', 'c'], ['d']]print(removeSublist(lst))
[['a', 'b', 'c'], ['d']]

Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
How to Install PIP on Windows ?
Python String | replace()
Python program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python Program for Fibonacci numbers
Python – Slice till K dictionary value lists

10 Jul, 2022
Given dictionary with value as lists, slice each list till K.
Input : test_dict = {“Gfg” : [1, 6, 3, 5, 7], “Best” : [5, 4, 2, 8, 9], “is” : [4, 6, 8, 4, 2]}, K = 3 Output : {‘Gfg’: [1, 6, 3], ‘Best’: [5, 4, 2], ‘is’: [4, 6, 8]} Explanation : The extracted 3 length dictionary value list. Input : test_dict = {“Gfg” : [1, 6, 3, 5, 7], “Best” : [5, 4, 2, 8, 9], “is” : [4, 6, 8, 4, 2]}, K = 2 Output : {‘Gfg’: [1, 6], ‘Best’: [5, 4], ‘is’: [4, 6]} Explanation : The extracted 2 length dictionary value list.
Method #1 : Using loop + list slicing  
The combination of above functionalities can be used to solve this problem. In this, we perform task of list slicing using slice operation and loop to iterate through all the keys.
Python3
# Python3 code to demonstrate working of# Slice till K dictionary value lists# Using loop + list slicing # initializing dictionarytest_dict = {"Gfg" : [1, 6, 3, 5, 7],             "Best" : [5, 4, 2, 8, 9],             "is" : [4, 6, 8, 4, 2]} # printing original dictionaryprint("The original dictionary is : " + str(test_dict)) # initializing KK = 4 res = dict()for sub in test_dict:         # slicing till K and reassigning    res[sub] = test_dict[sub][:K] # printing resultprint("The dictionary after conversion " + str(res))
Method #2 : Using dictionary comprehension + list slicing
This is yet another way in which this task can be performed. In this, we perform task of reassigning using dictionary comprehension and provides one liner approach to this problem. 
Python3
# Python3 code to demonstrate working of# Slice till K dictionary value lists# Using dictionary comprehension + list slicing # initializing dictionarytest_dict = {"Gfg" : [1, 6, 3, 5, 7],             "Best" : [5, 4, 2, 8, 9],             "is" : [4, 6, 8, 4, 2]} # printing original dictionaryprint("The original dictionary is : " + str(test_dict)) # initializing KK = 4 # one-liner to slice elements of list# items() used to get all key-value pair of dictionaryres = {key: val[:K] for key, val in test_dict.items()} # printing resultprint("The dictionary after conversion " + str(res))
The Space and Time Complexity is the same for both methods:
Time Complexity: O(n)
Auxiliary Space: O(n)
harshmaster07705
Python dictionary-programs
Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Private and final methods in Java

27 May, 2017
When we use final specifier with a method, the method cannot be overridden in any of the inheriting classes. Methods are made final due to design reasons.Since private methods are inaccessible, they are implicitly final in Java. So adding final specifier to a private method doesn’t add any value. It may in-fact cause unnecessary confusion.
class Base {     private final void foo() {}     // The above method foo() is same as following. The keyword    // final is redundant in above declaration.     // private void foo() {}}
For example, both ‘program 1’ and ‘program 2’ below produce same compiler error “foo() has private access in Base”.
Program 1
// file name: Main.javaclass Base {    private final void foo() {}}   class Derived extends Base {    public void foo() {} }   public class Main {    public static void main(String args[]) {        Base b = new Derived();        b.foo();    }}
Program 2
// file name: Main.javaclass Base {    private void foo() {}}   class Derived extends Base {    public void foo() {} }   public class Main {    public static void main(String args[]) {        Base b = new Derived();        b.foo();    }}
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Java
School Programming
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Tkinter – Frame Widget

05 May, 2021
Python offers multiple options for developing GUI (Graphical User Interface). Out of all the GUI methods, tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with tkinter is the fastest and easiest way to create the GUI applications. Creating a GUI using tkinter is an easy task.
Note: For more information, refer to Python GUI – tkinter
A frame is a rectangular region on the screen. A frame can also be used as a foundation class to implement complex widgets. It is used to organize a group of widgets.
Syntax:The syntax to use the frame widget is given below.
w = frame( master, options)
Parameters:
master: This parameter is used to represents the parent window.
options:There are many options which are available and they can be used as key-value pairs separated by commas.
Options:Following are commonly used Option can be used with this widget :-
bg: This option used to represent the normal background color displayed behind the label and indicator.
bd: This option used to represent the size of the border around the indicator and the default value is 2 pixels.
cursor: By using this option, the mouse cursor will change to that pattern when it is over the frame.
height: The vertical dimension of the new frame.
highlightcolor: This option used to represent the color of the focus highlight when the frame has the focus.
highlightthickness: This option used to represent the color of the focus highlight when the frame does not have focus.
highlightbackground: This option used to represent the thickness of the focus highlight..
relief: The type of the border of the frame. It’s default value is set to FLAT.
width: This option used to represents the width of the frame.
Example:
from tkinter import * root = Tk()root.geometry("300x150")  w = Label(root, text ='GeeksForGeeks', font = "50") w.pack()  frame = Frame(root)frame.pack()  bottomframe = Frame(root)bottomframe.pack( side = BOTTOM )  b1_button = Button(frame, text ="Geeks1", fg ="red")b1_button.pack( side = LEFT)  b2_button = Button(frame, text ="Geeks2", fg ="brown")b2_button.pack( side = LEFT )  b3_button = Button(frame, text ="Geeks3", fg ="blue")b3_button.pack( side = LEFT )  b4_button = Button(bottomframe, text ="Geeks4", fg ="green")b4_button.pack( side = BOTTOM)  b5_button = Button(bottomframe, text ="Geeks5", fg ="green")b5_button.pack( side = BOTTOM)  b6_button = Button(bottomframe, text ="Geeks6", fg ="green")b6_button.pack( side = BOTTOM)  root.mainloop()
Output:
Python-tkinter
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe
Enumerate() in Python
Different ways to create Pandas Dataframe
Read a file line by line in Python
How to Install PIP on Windows ?
Python String | replace()
Python OOPs Concepts
How to Install Chrome in Ubuntu?

06 Oct, 2021
If you want to install Google Chrome Browser in ubuntu 18.10 via terminal then follow the below steps: 
Step 1: First, you need to Download Chrome for Debian/Ubuntu. It will download “google-chrome-stable_current_amd64.deb” file in your default download folder. 
 
Step 2: Your chrome file is a .deb file. To install Chrome, you have to first unpack that file. So to unpack that file you need to execute the following command in the terminal. Before doing this, please set the download location in the terminal. 
 
sudo dpkg -i google-chrome-stable_current_amd64.deb
 
Step 3: Now you need to install other dependencies by running this command 
 
sudo apt-get install -f
 
Step 4: Now you need to reinstall package 
 
sudo dpkg -i google-chrome-stable_current_amd64.deb
 
After running this command successfully google chrome is installed. Now go to the search bar and search chrome. You got Google Chrome in the list! 
 
varshagumber28
how-to-install
How To
Installation Guide
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to filter object array based on attributes?
How to Align Text in HTML?
How to Install FFmpeg on Windows?
How to Set Git Username and Password in GitBash?
How to integrate Git Bash with Visual Studio Code?
Installation of Node.js on Linux
How to Install FFmpeg on Windows?
How to Install Anaconda on Windows?
How to Install and Run Apache Kafka on Windows?
Installation of Node.js on Windows
How to create custom arrows for your website using HTML and CSS?

22 Jun, 2020
Arrows are widely used in modern websites. These are mainly used for sliding images and change pages. Although there are many icons available for these arrows. Sometimes you need to design a custom image depending on the client’s requirement. Creating arrows using CSS has many benefits such as they do not affect the page loading time, also very beneficial for SEO providing custom touch to the website.
Approach: Creating an arrow using CSS is very simple. First, create an L(alphabet) shape using some box-shadow property and then rotate it to some angle to align them (both left and right arrows) together.
HTML Code: In this section, two div elements are created, one for each arrow.
<!DOCTYPE html><html lang="en">  <head>    <meta charset="UTF-8" />    <meta name="viewport" content=      "width=device-width, initial-scale=1.0" />    <title>Arrow</title></head><body>    <div class="left"></div>    <div class="right"></div></body></html>
CSS Code:
Step 1: First use box-shadow property to make the div element as L-shaped.
Step 2: Now rotate both of them at 45deg and -135deg angles to align them just opposite of each other.
Note: You can use some other values for the right arrow such as 225deg. You can find the perfect value of def using the developers console. You can also add hover effects depending on the requirement.
<style>    body {        padding: 280px 0 0 500px;        background: green;    }      .left,    .right {        width: 100px;        height: 100px;        transition: .5s;        float: left;        box-shadow: -2px 2px 0 black;    }      .left {        transform: rotate(45deg);    }      .right {        transform: rotate(-135deg);    }</style>
Complete Code: It is the combination of the above two sections of codes.
<!DOCTYPE html><html lang="en">  <head>    <meta charset="UTF-8" />      <meta name="viewport" content=        "width=device-width, initial-scale=1.0" />      <title>Arrow</title>      <style>        body {            padding: 280px 0 0 500px;            background: green;        }          .left,        .right {            width: 100px;            height: 100px;            transition: .5s;            float: left;            box-shadow: -2px 2px 0 black;        }          .left {            transform: rotate(45deg);        }          .right {            transform: rotate(-135deg);        }    </style></head>  <body>    <div class="left"></div>    <div class="right"></div></body>  </html>
Output:
CSS-Misc
HTML-Misc
CSS
HTML
Web Technologies
Web technologies Questions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between CAD and CAM

09 Dec, 2020
1. Computer Aided Design (CAD) :Computer Aided Design (CAD) is the use of computers for designing models of physical product which means computers are used to aid in creating the design, modifying the design and analyzing the designing activities. Computer Aided Design is also known as Computer Aided Drafting. The purpose of CAD is making 2D technical drawings and 3D models. So in Simple we can say CAD represents your part geometry to the computer. Computer Aided Design (CAD) software is mostly used by an engineer.
Examples of CAD software includes AutoCAD, Autodesk Inventor, CATIA, Solid Works etc.
Computer + Designed Software = CAD 
2. Computer Aided Manufacturing (CAM) :Computer Aided Manufacturing (CAM) is the use of computer software to control machine tools in the manufacturing of modules. CAM transforms engineering designs into end products. CAM is different than the conventional manufacturing as it implements automation in the manufacturing process. Computer Aided Manufacturing is also known as Computer Aided Modeling or Machining. The purpose of CAM is using 3D models to design machining processes. So in Simple we can say CAM converts the geometry to machine tool. So, without Computer Aided Design (CAD), Computer Aided Manufacturing (CAM) has no meaning. Computer Aided Manufacturing (CAM) software is mostly used by a trained machinist.
Examples of CAM software includes Work NC, Siemens NX, Power MILL, SolidCAM etc.
Manufacturing Tools + Computer = CAM 
Difference between CAD and CAM :
Difference Between
Software Engineering
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How To Get the Default Color Codes of ggplot2 in R?

29 Oct, 2021
In this article, we are going to see how to get the default color codes of ggplot2 in R Programming Language.
Format of Hex Color Codes: Each Hex color code contains the symbol “#” followed by 6 alphabets or numbers. Numbers are in the hexadecimal numeric system. There are 1,67,77,216 different color possibilities. 00 value range of the code represents the lowest intensity of color on the other hand FF value range of code represents the highest intensity.
Meaning of a Hex code:
The 1st and 2nd variable in Hex color code represents the intensity of red color.
The 3rd and 4th variable represents the intensity of green.
The 5th and 6th variable represents the intensity of blue.
By combining the intensities of red, green, and blue almost any color can be made:
Syntax: hue_pal()(n)
Parameters:
hue_pal(): it is a function present in “scales” package
n: this indicates number of levels
Note: We can adjust the value of “n” to get the color code of different levels
R
library(scales)hue_pal()(6)
 
 
Output:
 
[1] "#F8766D" "#B79F00" "#00BA38" "#00BFC4" "#619CFF" "#F564E3"
 
Visualizing Hex code using show_col, we will be using the show_col() function to visualize the color codes in grid format.
 
Syntax: show_col(hue_pal()(n))
Parameters:
hue_pal(): it is a function present in “scales” package
n: this indicates number of levels
 
The only extra step we have to do is to pass whatever we did in the previous step into show_col() function as an argument.
 
R
library(scales)show_col(hue_pal()(16))
 
 
Output:
 
 
We can also visualize in the reverse direction by using the direction parameter
 
Syntax: show_col(hue_pal(direction=-1)(n))
Parameters:
hue_pal(): it is a function present in “scales” package
n: this indicates number of levels
direction: this param specifies the direction in which order we want our colors
 
Code:
 
R
library(scales)show_col(hue_pal(direction=-1)(16))
 
 
Output:
 
 
adnanirshad158
anikaseth98
Picked
R-ggplot
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Split Column Into Multiple Columns in R DataFrame?
Change Color of Bars in Barchart using ggplot2 in R
Group by function in R using Dplyr
How to Change Axis Scales in R Plots?
How to filter R DataFrame by values in a column?
Logistic Regression in R Programming
How to import an Excel File into R ?
R - if statement
Replace Specific Characters in String in R
Joining of Dataframes in R Programming
HTML | <table> frame Attribute

29 May, 2019
The HTML <table> frame Attribute is used to specify the visibility of outside borders.
Syntax:
<table frame="value">
Attribute Values:
void: It is used to hide the outside border.
above: It is used to display the top outside border.
below: It is used to display the bottom outside border.
hsides: It is used to display the top and bottom outside border.
vsides: It is used to display the left and right outside border.
lhs: It is used to display the left outside border.
rhs: It is used to display the right outside border.
box: It is used to display all sides outside border.
border: It is used to display all outside border.
Note: The <table> frame Attribute is not supported by HTML 5.
Example:
<!DOCTYPE html><html>  <head>    <title>        HTML table frame Attribute    </title></head>  <body>    <h1>GeeksforGeeks</h1>      <h2>HTML table frame Attribute</h2>      <table frame="box">        <tr>            <th>NAME</th>            <th>AGE</th>            <th>BRANCH</th>        </tr>        <tr>            <td>BITTU</td>            <td>22</td>            <td>CSE</td>        </tr>    </table>    <br>    <table frame="vsides">        <tr>            <th>NAME</th>            <th>AGE</th>            <th>BRANCH</th>        </tr>        <tr>            <td>BITTU</td>            <td>22</td>            <td>CSE</td>        </tr>    </table>    <br>    <table frame="hsides">        <tr>            <th>NAME</th>            <th>AGE</th>            <th>BRANCH</th>        </tr>        <tr>            <td>BITTU</td>            <td>22</td>            <td>CSE</td>        </tr>    </table></body>  </html>
Output:
Supported Browsers: The browser supported by HTML <table> frame Attribute are listed below:
Google Chrome
Internet Explorer 9.0
Firefox
Safari
Opera
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
SAP Labs Interview Preparation - GeeksforGeeks

Goldman Sachs Interview Preparation
TCS Recruitment Process
Infosys Recruitment Process
Wipro Recruitment Process
IBM Recruitment Process
Cognizant Recruitment Process
SAP Labs Interview Preparation
Morgan Stanley Interview Preparation
Accenture Recruitment Process
Swiggy Recruitment Process
Flipkart Interview Preparation
Paytm Interview Preparation
Samsung Interview Preparation
Walmart Labs Recruitment Process
Directi Interview Preparation
Qualcomm Recruitment Process
MakeMyTrip Recruitment Process
Company Preparation
Amazon Interview Preparation
Microsoft Interview Preparation
Google Interview Preparation
D E Shaw Interview Preparation
SAP-Labs Interview Preparation
Popular Articles
Sort an array of 0s, 1s and 2s
K'th Smallest/Largest Element in Unsorted Array | Set 1
Check if a number is Bleak
Reverse words in a given string
Check if a number is a power of another number
Remove spaces from a given string
Heap Sort
Bubble Sort
QuickSort
Breadth First Traversal or BFS for a Graph
Design a stack that supports getMin() in O(1) time and O(1) extra space
Show All Articles
Popular Coding Problems
Reverse words in a given string
Sort an array of 0s, 1s and 2s
Remove Spaces
Find median in a stream
Second Largest
Reverse a linked list
Get minimum element from stack
Quick Sort
BFS traversal of graph
Bubble Sort
Show All Coding Problems
Popular Video Tutorials
Recent Interview Experiences
Print characters and their frequencies in order of occurrence
SAP Interview Experience | Set 26 (On-Campus)
SAP Labs Interview Experience | Set 25 (On-Campus)
SAP Labs Interview Experience | Set 24 (On-Campus)
SAP Labs Interview Experience | Set 23 (Pool Campus)
SAP Labs Interview Experience | Set 22 (Pool Drive)
SAP Labs Interview Experience | Set 21 (On-Campus for Associate Developer)
SAP Labs Interview Experience | Set 20 (For Internship)
SAP Labs Interview Experience | Set 20 (On-Campus)
SAP Labs Interview Experience | Set 19 (On-Campus)
Show All Interview Experiences
Moment.js moment().unix() Function

29 Jul, 2020
The moment().unix() function is used to get the number of seconds since the Unix Epoch. Basically the Unix time is a system for describing a point in time.
Syntax:
moment().unix();
Parameters: This function has no parameter.
Return Value: This function returns the Unix Timestamp in seconds.
Installation of moment module:
You can visit the link to Install moment module. You can install this package by using this command.npm install momentAfter installing the moment module, you can check your moment version in command prompt using the command.npm version momentAfter that, you can just create a folder and add a file for example, index.js as shown below.
You can visit the link to Install moment module. You can install this package by using this command.npm install moment
npm install moment
After installing the moment module, you can check your moment version in command prompt using the command.npm version moment
npm version moment
After that, you can just create a folder and add a file for example, index.js as shown below.
Example 1: Filename: index.js
// Requiring the moduleconst moment = require('moment');  // Function callvar result = moment().unix();  console.log("Result:", result)
Steps to run the program:
The project structure will look like this:Run index.js file using below command:node index.jsOutput:Result: 1595007379

The project structure will look like this:
Run index.js file using below command:node index.jsOutput:Result: 1595007379

node index.js
Output:
Result: 1595007379

Example 2: Filename: index.js
// Requiring the moduleconst moment = require('moment');   function getUnixTimeStamp() {   return moment().unix();}   // Function callvar result = getUnixTimeStamp();console.log("Unix Timestamp in seconds:", result)
Steps to run the program:
The project structure will look like this:Run index.js file using below command:node index.jsOutput:Unix Timestamp in seconds: 1595007321

The project structure will look like this:
Run index.js file using below command:node index.jsOutput:Unix Timestamp in seconds: 1595007321

node index.js
Output:
Unix Timestamp in seconds: 1595007321

Reference: https://momentjs.com/docs/#/displaying/unix-timestamp/
Moment.js
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to set Temporary and Permanent Paths in Java

24 Mar, 2018
If the Java source file is inside the jdk/bin folder,path is not required to be set because the tools like javac,java are inside the current folder.But if the java source file is outside the jdk/bin folder,path is required to be set in order to execute java source file.There are two ways to set java path:
TemporaryPermanent
Temporary
Permanent
Setting Temporary Java Path:To set temporary java path:Open command promptCopy the path of jdk/bin directoryWrite in command prompt:SET PATH=copied_pathFor example:SET PATH=C:\Program Files\Java\jdk1.7.0_79\binSetting Permanent Java Path:To set permanent java path:Go to MyPC propertiesClick on Advanced system settingsClick on Environment VariablesClick on New tab of User variablesAssign value Gfg_path to Variable name:Copy the path of bin folderPaste path of bin folder in Variable value:Click on OK buttonClick on OK buttonIn this way Temporary and Permanent Path for Java can be set in Windows.My Personal Notes
arrow_drop_upSave
Setting Temporary Java Path:
To set temporary java path:
Open command prompt
Copy the path of jdk/bin directory
Write in command prompt:SET PATH=copied_path
For example:
SET PATH=C:\Program Files\Java\jdk1.7.0_79\bin
Setting Permanent Java Path:
To set permanent java path:
Go to MyPC propertiesClick on Advanced system settingsClick on Environment VariablesClick on New tab of User variablesAssign value Gfg_path to Variable name:Copy the path of bin folderPaste path of bin folder in Variable value:Click on OK buttonClick on OK buttonIn this way Temporary and Permanent Path for Java can be set in Windows.My Personal Notes
arrow_drop_upSave
Go to MyPC properties
Click on Advanced system settings
Click on Environment Variables
Click on New tab of User variables
Assign value Gfg_path to Variable name:
Copy the path of bin folder
Paste path of bin folder in Variable value:
Click on OK button
Click on OK button
In this way Temporary and Permanent Path for Java can be set in Windows.
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to close only the TopLevel window in Python Tkinter?

The Toplevel window is an option to create a child window in an application. It works similar to the default main tkinter window. We can configure the size of a Toplevel window, customize its properties and attributes as well as add widgets that we want to build the component with.
For a particular application, if we have defined a Toplevel window, then we can close it using the destroy() method.
In the following example, we have created an application that contains a button to open a Toplevel window. The Toplevel window or child window contains a label text and a button to close the corresponding window. Whenever the button is clicked, the Toplevel window gets closed.
# Import required libraries
from tkinter import *

# Create an instance of tkinter window
win = Tk()
win.geometry("700x400")
win.title("Root Window")

# Function to create a toplevel window
def create_top():
   top=Toplevel(win)
   top.geometry("400x250")
   top.title("Toplevel Window")
   Label(top, text="Hello, Welcome to Tutorialspoint", font='Arial 15 bold').pack()

   # Button to close the toplevel window
   button=Button(top, text="Close", command=top.destroy)
   button.pack()

# Create a button to open the toplevel window
button=Button(win, text="Click Here", font='Helvetica 15', command=create_top)
button.pack(pady=30)

win.mainloop()
Running the above code will display a window containing a button that opens a Toplevel window.
Once the Toplevel is opened, you can click the button "close" to close the toplevel window.
How to make an image center-aligned (vertically & horizontally) inside a bigger div using CSS? - GeeksforGeeks

02 Nov, 2021
In this article, we will know how to center-aligned the image in div tag using CSS & will also understand its implementation through the example. Given an image and we need to set the image that aligns to the center (vertically and horizontally) inside a bigger div. It can be done by using the position property of the element.
Example 1: This example uses the position property to make the image align to the center.
HTML
<!DOCTYPE html><html> <head>    <title>Horizontal and Vertical alignment</title>         <!-- Style to set horizontal and        vertical alignment -->    <style>    #Outer {        border: 2px solid black;        height: 300px;        position: relative;    }         img {        position: absolute;        margin: auto;        top: 0;        left: 0;        right: 0;        bottom: 0;    }    </style></head> <body>    <div id="Outer">        <img src="https://media.geeksforgeeks.org/wp-content/uploads/20211101104133/1-300x139.png" />    </div></body> </html>
Output:
Example 2: This example uses the center property to set the image to center in a div. We can also use this method for aligning the item to the center.
HTML
<!DOCTYPE html><html> <head>    <title> Horizontal and Vertical alignment </title>    <style>    #Outer {        border: 2px solid black;        height: 300px;        background: url(https://media.geeksforgeeks.org/wp-content/uploads/20211101104133/1-300x139.png)          no-repeat center center;    }    </style></head> <body>    <div id="Outer"></div></body> </html>
Output: From the output, we can see the output is same as the previous output.
bhaskargeeksforgeeks
CSS-Misc
Picked
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to create footer to stay at the bottom of a Web page?
How to update Node.js and NPM to next version ?
Types of CSS (Cascading Style Sheet)
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
Check if a number is multiple of 5 without using / and % operators in C++

Here we will see how to check a number is divisible by 5 or not. One simple approach is that if the number mod 5 = 0, then, the number is divisible by 5. But here we will not use / or % operator. To check whether a number is divisible by 5, we have to see the last number is 0 or 5. If that is 0 or 5, the number is divisible by 5, otherwise not. Here we can use some large numbers also as a string to check.
#include <bits/stdc++.h>
using namespace std;
bool isDiv5(string num){
   int n = num.length();
   if(num[n - 1] != '5' && num[n - 1] != '0')
      return false;
   return true;
}
int main() {
   string num = "154484585745184258458158245285265";
   if(isDiv5(num)){
      cout << "Divisible";
   } else {
      cout << "Not Divisible";
   }
}
Divisible
Python Truth Value Testing

We can use any object to test the truth value. By providing the condition in the if or while statement, the checking can be done.
Until a class method __bool__() returns False or __len__() method returns 0, we can consider the truth value of that object is True.
The value of a constant is False, when it is False, or None. 
The value of a constant is False, when it is False, or None. 
When a variable contains different values like 0, 0.0, Fraction(0, 1), Decimal(0), 0j, then it signifies the False Value.
When a variable contains different values like 0, 0.0, Fraction(0, 1), Decimal(0), 0j, then it signifies the False Value.
The empty sequence ‘‘, [], (), {}, set(0), range(0), Truth value of these elements are False.
The empty sequence ‘‘, [], (), {}, set(0), range(0), Truth value of these elements are False.
The truth value 0 is equivalent to False and 1 is same as True.
 Live Demo
class A: #The class A has no __bool__ method, so default value of it is True
   def __init__(self):
      print('This is class A')
        
a_obj = A()

if a_obj:
   print('It is True')
else:
   print('It is False')
    
class B: #The class B has __bool__ method, which is returning false value
   def __init__(self):
      print('This is class B')
        
   def __bool__(self):
      return False
b_obj = B()
if b_obj:
   print('It is True')
else:
   print('It is False')
 myList = [] # No element is available, so it returns False
if myList:
   print('It has some elements')
else:
   print('It has no elements')
    
mySet = (10, 47, 84, 15) # Some elements are available, so it returns True
if mySet:
   print('It has some elements')
else:
   print('It has no elements')
This is class A
It is True
This is class B
It is False
It has no elements
It has some elements
Tryit Editor v3.7

CSS Grid Container
Tryit: The grid-template-rows property