code-rag-bench/online-tutorials huggingface dataset:
Aurelia - Events

In this chapter, you will learn about Aurelia events.
Even delegation is a useful concept where the event handler is attached to one top level element instead of multiple elements on the DOM. This will improve the application memory efficiency and should be used whenever possible.
This is a simple example of using event delegation with Aurelia framework. Our view will have a button with click.delegate event attached.
<template>
   <button click.delegate = "myFunction()">CLICK ME</button>
</template>
Once the button is clicked, myFunction() will be called.
export class App {
   myFunction() {
      console.log('The function is triggered...');
   }
}
We will get the following output.
There are some cases when you can't use delegation. Some JavaScript events don’t support delegation; IOS supports it for some elements. To find out which events allow delegation, you can search for a bubble property of any event here. In these cases, you can use trigger() method.
The same functionality from the above example can be created with click.trigger.
<template>
   <button click.trigger = "myFunction()">CLICK ME</button>
</template>
export class App {
   myFunction() {
      console.log('The function is triggered...');
   }
}
 Print
 Add Notes
 Bookmark this page
Python program to find the sum of all items in a dictionary

In this article, we will learn about the solution to the problem statement given below.
Problem statement − We are given a dictionary, and we need to print the 3 highest value in a dictionary.
Three approaches to the problem statement are given below:
 Live Demo
# sum function
def Sum(myDict):
   sum_ = 0
   for i in myDict:
      sum_ = sum_ + myDict[i]
   return sum_
# Driver Function
dict = {'T': 1, 'U':2, 'T':3, 'O':4, 'R':5}
print("Sum of dictionary values :", Sum(dict))
Sum of dictionary values : 14
 Live Demo
# sum function
def Sum(dict):
   sum_ = 0
   for i in dict.values():
      sum_ = sum_ + i
   return sum_
# Driver Function
dict = {'T': 1, 'U':2, 'T':3, 'O':4, 'R':5}
print("Sum of dictionary values :", Sum(dict))
Sum of dictionary values : 14
 Live Demo
# sum function
def Sum(dict):
   sum_ = 0
   for i in dict.keys():
      sum_ = sum_ + dict[i]
   return sum_
# Driver Function
dict = {'T': 1, 'U':2, 'T':3, 'O':4, 'R':5}
print("Sum of dictionary values :", Sum(dict))
Sum of dictionary values : 14
In this article, we have learned how we can find the highest 3 values in a dictionary
How to create responsive column cards with CSS?

To create responsive column cards with CSS, the code is as follows −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   }
   * {
      box-sizing: border-box;
   }
   .card {
      color: white;
      float: left;
      width: calc(25% - 20px);
      padding: 10px;
      border-radius: 10px;
      margin: 10px;
      height: 200px;
   }
   .card p {
      font-size: 18px;
   }
   .cardContainer:after {
      content: "";
      display: table;
      clear: both;
   }
   @media screen and (max-width: 600px) {
      .card {
         width: 100%;
      }
   }
</style>
</head>
<body>
<h1>Responsive column card Example</h1>
<h2>Resize the screen to see the below cards resize themselves</h2>
<div class="cardContainer">
<div class="card" style="background-color:rgb(153, 29, 224);">
<h2>First card</h2>
<p>Some text</p>
</div>
<div class="card" style="background-color:rgb(12, 126, 120);">
<h2>Second card</h2>
<p>Some text</p>
</div>
<div class="card" style="background-color:rgb(207, 41, 91);">
<h2>Third card</h2>
<p>Some text</p>
</div>
<div class="card" style="background-color:rgb(204, 91, 39);">
<h2>Fourth card</h2>
<p>Some text</p>
</div>
</div>
</body>
</html>
The above code will produce the following output −
On resizing the screen to 600px or less −
chkconfig - Unix, Linux Command

chkconfig - Updates and queries runlevel information for system services.
chkconfig --list [name]
chkconfig --add name
chkconfig --del name
chkconfig [--level levels] name 
chkconfig [--level levels] name 
chkconfig provides a simple command-line tool for maintaining the /etc/rc[0-6].d directory hierarchy by relieving system administrators of the task of directly manipulating the numerous symbolic links in those directories. This implementation of chkconfig was inspired by the chkconfig command present in the IRIX operating system. Rather than maintaining configuration information outside of the /etc/rc[0-6].d hierarchy, however, this version directly manages the symlinks in /etc/rc[0-6].d. This leaves all of the configuration information regarding what services init starts in a single location.
chkconfig has five distinct functions: adding new services for management, removing services from management, listing the current startup information for services, changing the startup information for services, and checking the startup state of a particular service. When chkconfig is run without any options, it displays usage information. If only a service name is given, it checks to see if the service is configured to be started in the current runlevel. If it is, chkconfig returns true; otherwise it returns false. The --level option can be used to have chkconfig query an alternative runlevel rather than the current one.
If one of on, off, or reset is specified after the service name, chkconfig changes the startup information for the specified service. The on and off flags cause the service to be started or stopped, respectively, in the runlevels being changed. The reset flag resets the startup information for the service to whatever is specified in the init script in question. By default, the on and off options affect only runlevels 2, 3, 4, and 5, while reset affects all of the runlevels. The --level option can be used to specify which runlevels are affected.
Note that for every service, each runlevel has either a start script or a stop script. When switching runlevels, init will not re-start an already-started service, and will not re-stop a service that is not running. chkconfig also can manage xinetd scripts via the means of xinetd.d configuration files. Note that only the on, off, and --list commands are supported for xinetd.d services.
To list all startup services in alphabetic order.
$ chkconfig --list | sort | less
auditd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
...

To list the auditd service
$ chkconfig --list auditd
auditd 0:off 1:off 2:on 3:on 4:on 5:on 6:off

To turn auditd off in runlevels 3, 4, and 5.
$ chkconfig --level 345 auditd off
auditd 0:off 1:off 2:on 3:off 4:off 5:off 6:off


    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
How to use the CopyTo(,) method of array class in C#

The CopyTo() method in C# is used to copy elements of one array to another array. In this method, you can set the starting index from where you want to copy from the source array.
The following is the syntax.
CopyTo(dest, index);
Here dest = destination array
index= starting index
The following is an example showing the usage of CopyTo(,) method of array class in C#.
 Live Demo
using System;
class Program {
   static void Main() {
      int[] arrSource = new int[4];
      arrSource[0] = 5;
      arrSource[1] = 9;
      arrSource[2] = 1;
      arrSource[3] = 3;
      int[] arrTarget = new int[4];
      // CopyTo() method
      arrSource.CopyTo(arrTarget,0 );
      Console.WriteLine("Destination Array ...");
      foreach (int value in arrTarget) {
         Console.WriteLine(value);
      }
   }
}
Destination Array ...
5
9
1
3
Batch Script - NET ACCOUNTS

View the current password & logon restrictions for the computer.
NET ACCOUNT [/FORCELOGOFF:{minutes | NO}] [/MINPWLEN:length]
[/MAXPWAGE:{days | UNLIMITED}] [/MINPWAGE:days] 
[/UNIQUEPW:number] [/DOMAIN]

Wherein
FORCELOGOFF − Force the log-off of the current user within a defined time period.
FORCELOGOFF − Force the log-off of the current user within a defined time period.
MINPWLEN − This is the minimum password length setting to provide for the user.
MINPWLEN − This is the minimum password length setting to provide for the user.
MAXPWAGE − This is the maximum password age setting to provide for the user.
MAXPWAGE − This is the maximum password age setting to provide for the user.
MINPWAGE − This is the minimum password age setting to provide for the user.
MINPWAGE − This is the minimum password age setting to provide for the user.
NET ACCOUNT

Force user logoff how long after time expires?:      Never
Minimum password age (days):                         0
Maximum password age (days):                         42
Minimum password length:                             0
Length of password history maintained:               None
Lockout threshold:                                   Never
Lockout duration (minutes):                          30
Lockout observation window (minutes):                30
Computer role:                                       SERVER
The command completed successfully.

 Print
 Add Notes
 Bookmark this page
What is explode() function in PHP?

In this article, figure out how to utilize PHP Explode() function which is a predefined inbuilt PHP function.
The explode function is utilized to "Split a string into pieces of elements to form an array".The explode function in PHP enables us to break a string into smaller content with a break. This break is known as the delimiter.
explode(separator, String, Number of Elements)
The explode function acknowledges three parameters of which two are compulsory and one is optional.
Let's discuss the three parameters.
This character specifies the critical points or points at which the string will split, i.e. whenever this character is found in the string it symbolizes the end of one element of the array and start of another.
The input string is to be split in the array.
This is an optional parameter. It is utilized to determine the number of elements of the array. This parameter can be any integer(positive, negative or zero)
When this parameter is not provided the array returned contains the total number of the element formed after separating the string with the separator.
<?php
   $Original = "Hello,Welcome To Tutorials Point";
   print_r(explode(" ",$Original));
   print_r(explode(" ",$Original,3));
?>
Array ( [0] => Hello,Welcome [1] => To [2] => Tutorials [3] => Point )
Array ( [0] => Hello,Welcome [1] => To [2] => Tutorials Point )
In the above example, in the first expression, we have not passed the third parameter and we are only creating the new array with the help of "space" delimiter but in the second expression, we have instructed to create the new array with only three elements by passing the third parameter.
Is it fine to write void main() or main() in C/C++? - GeeksforGeeks

02 Dec, 2021
In C, void main() has no defined(legit) usage, and it can sometimes throw garbage results or an error. However, main() is used to denote the main function which takes no arguments and returns an integer data type.
The definition is not and never has been C++, nor has it even been C. See the ISO C++ standard 3.6.1[2] or the ISO C standard 5.1.2.2.1. for more.
void main(){
// Body
}
 A conforming implementation accepts the formats given below:
int main(){ 
// Body
}
and
int main(int argc, char* argv[]){
// Body
}
A conforming implementation may provide more versions of main(), but they must all have return type int. The int returned by main() is a way for a program to return a value to “the system” that invokes it. On systems that don’t provide such a facility the return value is ignored, but that doesn’t make “void main()” legal C++ or legal C. 
Note: Even if your compiler accepts void main() avoid it, or risk being considered ignorant by C and C++ programmers.  In C++, main() need not contain an explicit return statement. In that case, the value returned is 0, meaning successful execution.
Example:
CPP
// CPP Program to demonstrate main() with// return type#include <iostream>  // Driver Codeint main(){    std::cout        << "This program returns the integer value 0\n";}
This program returns the integer value 0
NOTE: Neither ISO C++ nor C99 allows you to leave the type out of a declaration. That is, in contrast to C89 and ARM C++, int is not assumed where a type is missing in a declaration. 
Consequently,
C++
#include <iostream>using namespace std;  main(){    // Body}
The above code has no error. If you write the whole error-free main() function without a return statement at the end then the compiler automatically adds a return statement with proper datatype at the end of the program. 
To summarize the above, it is never a good idea to use void main() or simply, main() as it doesn’t confirm standards. It may be allowed by some compilers though.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
sudhanshu29gupta
smrutiranjanrout2019
anshikajain26
C Basics
CPP-Basics
CPP-Functions
cpp-main
C Language
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Substring in C++
Multidimensional Arrays in C / C++
Left Shift and Right Shift Operators in C/C++
Function Pointer in C
rand() and srand() in C/C++
Vector in C++ STL
Initialize a vector in C++ (6 different ways)
Inheritance in C++
Map in C++ Standard Template Library (STL)
C++ Classes and Objects
Extract data.table Column as Vector Using Index Position in R - GeeksforGeeks

17 May, 2021
The column at a specified index can be extracted using the list sub-setting, i.e. [[, operator. The double bracket operator is faster in comparison to the single bracket, and can be used to extract the element or factor level at the specified index. In case, an index more than the number of rows is specified, then an exception stating index out of bounds is returned. Single bracket [, operator cannot be used here, because it returns a subset of the data table, that is a data.table element as the output, not an atomic vector. Constant time is required to perform this operation. 
Example:
R
library("data.table")  # declaring data tabledata_frame <- data.table(col1 = c(2,4,6),                          col2 = c(4,6,8),                          col3 = c(8,10,12),                          col4 = c(20,16,14))  print ("Original DataTable")print (data_frame)  # extracting column 2print ("Column 2 as a vector")  vec <-  data_frame[[2]]print (vec)
Output
[1] “Original DataTable”
  col1 col2 col3 col4
1:    2    4    8   20
2:    4    6   10   16
3:    6    8   12   14
[1] “Column 2 as a vector”
[1] 4 6 8
Every column of the data.table can also be extracted in a separate vector, by looping over the entire data.table. ncol() method can be used to return the total number of columns in the data.table. The total time required to carry this operation is equivalent to O(n), where n are the columns. 
Example:
R
# getting required librarieslibrary("data.table")  # declaring data tabledata_table <- data.table(col1 = c(2,4,6),                          col2 = FALSE,                          col3 = LETTERS[1:3])  print ("Original DataTable")print (data_table)  # getting number of columnscols <- ncol(data_table)  # looping through columnsfor (i in 1:cols){        # getting ith col    cat(i, "th col \n")    print(data_table[[i]])}
Output
[1] “Original DataTable”
  col1  col2 col3
1:    2 FALSE    A
2:    4 FALSE    B
3:    6 FALSE    C
1 th col
[1] 2 4 6
2 th col
[1] FALSE FALSE FALSE
3 th col
[1] “A” “B” “C”
Picked
R DataTable
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
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 Split Column Into Multiple Columns in R DataFrame?
Replace Specific Characters in String in R
How to filter R DataFrame by values in a column?
How to import an Excel File into R ?
R - if statement
Time Series Analysis in R
How to filter R dataframe by multiple conditions?
Displaying different images with actual size in a Matplotlib subplot

To display different images with actual size in a Matplotlib subplot, we can take the following
steps −
Set the figure size and adjust the padding between and around the subplots.
Read two images using imread() method (im1 and im2)
Create a figure and a set of subplots.
Turn off axes for both the subplots.
Use imshow() method to display im1 and im2 data.
To display the figure, use show() method.
import matplotlib.pyplot as plt

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

im1 = plt.imread("bird.jpg")
im2 = plt.imread("opencv-logo.png")

fig, ax = plt.subplots(nrows=1, ncols=2)

ax[1].axis('off')
ax[1].imshow(im1, cmap='gray')
ax[0].axis('off')
ax[0].imshow(im2, cmap='gray')
plt.show()
Java Program to convert int to binary string

The Integer.toBinaryString() method in Java converts int to binary string.
Let’s say the following are our integer values.
int val1 = 9;
int val2 = 20;
int val3 = 2;
Convert the above int values to binary string.
Integer.toBinaryString(val1);
Integer.toBinaryString(val2);
Integer.toBinaryString(val3);
 Live Demo
public class Demo {
   public static void main(String[] args) {
      int val1 = 9;
      int val2 = 20;
      int val3 = 30;
      int val4 = 78;
      int val5 = 2;
      System.out.println("Converting integer "+val1+" to Binary String: "+Integer.toBinaryString(val1));
      System.out.println("Converting integer "+val2+" to Binary String: "+Integer.toBinaryString(val2));
      System.out.println("Converting integer "+val3+" to Binary String: "+Integer.toBinaryString(val3));
      System.out.println("Converting integer "+val4+" to Binary String: "+Integer.toBinaryString(val4));
      System.out.println("Converting integer "+val5+" to Binary String: "+Integer.toBinaryString(val5));
   }
}
Converting integer 9 to Binary String: 1001
Converting integer 20 to Binary String: 10100
Converting integer 30 to Binary String: 11110
Converting integer 78 to Binary String: 1001110
Converting integer 2 to Binary String: 10
Display table records from a stored procedure in MySQL

Let us first create a table −
mysql> create table DemoTable1933
   (
   ClientName varchar(20)
   );
Query OK, 0 rows affected (0.00 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1933 values('Chris Brown');
Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1933 values('David Miller');
Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1933 values('Adam Smith');
Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1933 values('John Doe');
Query OK, 1 row affected (0.00 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1933;
This will produce the following output −
+--------------+
| ClientName   |
+--------------+
| Chris Brown  |
| David Miller |
| Adam Smith   |
| John Doe     |
+--------------+
4 rows in set (0.00 sec)
Here is the query to create a stored procedure and set SELECT in it to display records −
mysql> delimiter //
mysql> create procedure display_all_records()
   begin
   select * from DemoTable1933;
   end
   //
Query OK, 0 rows affected (0.00 sec)
mysql> delimiter ;
Now you can call a stored procedure using call command:
mysql> call display_all_records();
This will produce the following output −
+--------------+
| ClientName   |
+--------------+
| Chris Brown  |
| David Miller |
| Adam Smith   |
| John Doe     |
+--------------+
4 rows in set (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
How to change an HTML5 input's placeholder color with CSS?

HTML5 introduced a new attribute called placeholder. This attribute on <input> and <textarea> elements provides a hint to the user of what can be entered in the field.
Here’s an example showing what a placeholder is. The hint to email i.e. email@example.com is placeholder here:
You can try to run the following code to learn how to use placeholder attribute:
Live Demo
<!DOCTYPE HTML>
<html>
   <body>
      <form action="/cgi-bin/html5.cgi" method="get">
         Enter email : <input type="email" name="newinput" placeholder="email@example.com"/>
         <input type="submit" value="submit" />
      </form>
   </body>  
</html>
To change the input placeholder color, use CSS.
Live Demo
<!DOCTYPE HTML>
<html>
   <style>
      ::-webkit-input-placeholder { /* WebKit, Blink, Edge */
        color:   #7F0D10;
      }
      :-moz-placeholder { /* Mozilla Firefox 4 to 18 */
        color:    #7F0D10;
        opacity:  1;
      }
      ::-moz-placeholder { /* Mozilla Firefox 19+ */
        color:   #7F0D10;
        opacity:  1;
      }
   </style>
   <body>
      <form action="/cgi-bin/html5.cgi" method="get">
         Enter email : <input type="email" name="newinput" placeholder="email@example.com"/>
         <input type="submit" value="submit" />
      </form>
   </body>
</html>
Delete and Edit items in Tkinter TreeView

Tkinter Treeview widget is used to display the data in a hierarchical structure. In this structure, each row can represent a file or a directory. Each directory contains files or additional directories. If we want to create a Treeview widget, then we can use Treeview(parent, columns) constructor to build the table.
The Treeview widget items can be edited and deleted by selecting the item using tree.selection() function. Once an item is selected, we can perform certain operations to delete or edit the item.
# Import the required libraries
from tkinter import *
from tkinter import ttk

# Create an instance of tkinter frame
win = Tk()

# Set the size of the tkinter window
win.geometry("700x350")

# Create an instance of Style widget
style = ttk.Style()
style.theme_use('clam')

# Add a Treeview widget
tree = ttk.Treeview(win, column=("c1", "c2"), show='headings', height=8)
tree.column("# 1", anchor=CENTER)
tree.heading("# 1", text="ID")
tree.column("# 2", anchor=CENTER)
tree.heading("# 2", text="Company")

# Insert the data in Treeview widget
tree.insert('', 'end', text="1", values=('1', 'Honda'))
tree.insert('', 'end', text="2", values=('2', 'Hyundai'))
tree.insert('', 'end', text="3", values=('3', 'Tesla'))
tree.insert('', 'end', text="4", values=('4', 'Wolkswagon'))
tree.insert('', 'end', text="5", values=('5', 'Tata Motors'))
tree.insert('', 'end', text="6", values=('6', 'Renault'))

tree.pack()

def edit():
   # Get selected item to Edit
   selected_item = tree.selection()[0]
   tree.item(selected_item, text="blub", values=("foo", "bar"))

def delete():
   # Get selected item to Delete
   selected_item = tree.selection()[0]
   tree.delete(selected_item)

# Add Buttons to Edit and Delete the Treeview items
edit_btn = ttk.Button(win, text="Edit", command=edit)
edit_btn.pack()
del_btn = ttk.Button(win, text="Delete", command=delete)
del_btn.pack()

win.mainloop()
Executing the above code will display a window that contains a list of car models and ID in it.
If we select a particular row and press edit or delete button, then it will perform the operations defined in the program.
Select the 4th row and click the "Delete" button.
It will produce the following output −
Flood fill algorithm using C graphics

With respect of a given rectangle, our task is to fill this rectangle applying flood fill algorithm.
Input 
rectangle(left = 50, top = 50, right= 100, bottom = 100)
floodFill( a = 55, b = 55, NewColor = 12, OldColor = 0)
Output 
// A recursive function to replace previous color 'OldColor' at '(a, b)' and all surrounding pixels of (a, b) with new color 'NewColor' and floodFill(a, b, NewColor, OldColor)
If a or b is outside the screen, thenreturn.
If a or b is outside the screen, thenreturn.
If color of getpixel(a, b) is same asOldColor, then
If color of getpixel(a, b) is same asOldColor, then
Recur for top, bottom, right and left.floodFill(a+1, b, NewColor, OldColor);<floodFill(a-1, b, NewColor, OldColor);floodFill(a, b+1, NewColor, OldColor);floodFill(a, b-1, NewColor, OldColor);
Recur for top, bottom, right and left.
floodFill(a+1, b, NewColor, OldColor);<
floodFill(a-1, b, NewColor, OldColor);
floodFill(a, b+1, NewColor, OldColor);
floodFill(a, b-1, NewColor, OldColor);
// Shows program to fill polygon using floodfill
// algorithm
#include <graphics.h>
#include <stdio.h>
// Describes flood fill algorithm
void flood(int x1, int y1, int new_col, int old_col){
   // Checking current pixel is old_color or not
   if (getpixel(x1, y1) == old_col) {
      // Putting new pixel with new color
      putpixel(x1, y1, new_col);
      // Shows recursive call for bottom pixel fill
      flood(x1 + 1, y1, new_col, old_col);
      //Shows recursive call for top pixel fill
      flood(x1 - 1, y1, new_col, old_col);
      // Shows recursive call for right pixel fill
      flood(x1, y1 + 1, new_col, old_col);
      // Shows recursive call for left pixel fill
      flood(x1, y1 - 1, new_col, old_col);
   }
}
int main(){
   int gd1, gm1 = DETECT;
   // Initializing graph
   initgraph(&gd1, &gm1, "");
   //Shows rectangle coordinate
   int top1, left1, bottom1, right1;
   top1 = left1 = 50;
   bottom1 = right1 = 300;
   // Shows rectangle for print rectangle
   rectangle(left1, top1, right1, bottom1);
   // Fills start cordinate
   int x1 = 51;
   int y1 = 51;
   // Shows new color to fill
   int newcolor = 12;
   // Shows old color which you want to replace
   int oldcolor = 0;
   // Calling for fill rectangle
   flood(x1, y1, newcolor, oldcolor);
   getch();
   return 0;
}
C# | How to change the CursorLeft of the Console - GeeksforGeeks

28 Jan, 2019
Given the normal Console in C#, the task is to change the CursorLeft of the Console.
Approach: This can be done using the CursorLeft property in the Console class of the System package in C#. This changes the horizontal position of the Cursor. Basically, it gets or sets the column position of the cursor within the buffer area.
Program 1: Getting the value of CursorLeft
// C# program to illustrate the// Console.CursorLeft Propertyusing System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;  namespace GFG {  class Program {      static void Main(string[] args)    {          // Get the CursorLeft position        Console.WriteLine("Current CursorLeft position: {0}",                                         Console.CursorLeft);          // Get the CursorLeft position        Console.Write("Current CursorLeft position: {0};",                                      Console.CursorLeft);          Console.WriteLine(" and now :{0}",                      Console.CursorLeft);    }}}
Output:
Program 2: Setting the value of CursorLeft
// C# program to illustrate the// Console.CursorLeft Propertyusing System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;  namespace GFG {  class Program {      static void Main(string[] args)    {          // Get the CursorLeft position        Console.WriteLine("Current CursorLeft position: {0}",                                         Console.CursorLeft);          // Set the CursorLeft position        Console.CursorLeft = 25;          // Get the CursorLeft position        Console.Write("Current CursorLeft position: {0};",                                      Console.CursorLeft);    }}}
Output:
CSharp-Console-Class
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
C# Dictionary with examples
C# | Method Overriding
C# | Class and Object
C# | String.IndexOf( ) Method | Set - 1
Extension Method in C#
C# | Constructors
C# | Delegates
Introduction to .NET Framework
Difference between Ref and Out keywords in C#
C# | Data Types
How to add a title in anchor tag using jQuery?

To add a title in anchor tag in jQuery, use the prop() method. The prop() method is used to set properties and values of the selected elements.
You can try to run the following code to learn how to add a title in anchor tag using jQuery −
Live Demo
<html>
   <head>
      <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
      <script>
       $(document).ready(function(){
         $("#button1").click(function(){
            $('.myClass').prop('title', 'This is your new title');
            var myTitle = $('.myClass').prop('title');
            alert(myTitle);
         });
       });
      </script>
   </head>
   <body>
      <div id='div1' class="myclass">
         <a class="myClass" href='#'><img src='http://tutorialspoint.com/green/images/logo.png' /></a><br>
         <button id="button1">Get Title</button>
      </div>
   </body>
</html>
Adding an element to the List in C#

To add an element to the List, the code is as follows −
 Live Demo
using System;
using System.Collections.Generic;
public class Demo {
   public static void Main(String[] args) {
      List<String> list = new List<String>();
      list.Add("One");
      list.Add("Two");
      list.Add("Three");
      list.Add("Four");
      list.Add("Five");
      list.Add("Six");
      list.Add("Seven");
      list.Add("Eight");
      Console.WriteLine("Enumerator iterates through the list elements...");
      List<string>.Enumerator demoEnum = list.GetEnumerator();
      while (demoEnum.MoveNext()) {
         string res = demoEnum.Current;
         Console.WriteLine(res);
      }
   }
}
This will produce the following output −
Enumerator iterates through the list elements...
One
Two
Three
Four
Five
Six
Seven
Eight
Let us see another example −
 Live Demo
using System;
using System.Collections.Generic;
public class Demo {
   public static void Main(String[] args) {
      List<int> list = new List<int>();
      list.Add(50);
      list.Add(100);
      list.Add(150);
      list.Add(200);
      list.Add(250);
      list.Add(500);
      list.Add(750);
      list.Add(1000);
      list.Add(1250);
      list.Add(1500);
      Console.WriteLine("Enumerator iterates through the list elements...");
      List<int>.Enumerator demoEnum = list.GetEnumerator();
      while (demoEnum.MoveNext()) {
         int res = demoEnum.Current;
         Console.WriteLine(res);
      }
   }
}
This will produce the following output −
Enumerator iterates through the list elements...
50
100
150
200
250
500
750
1000
1250
1500
Hexadecimal color to RGB color JavaScript

We are required to write a JavaScript function that takes in a hexadecimal color and returns its RGB representation.
The function should return an object containing the respective values of red green and blue
color −
hexToRgb('#0080C0') should return 0, 128, 192
The code for this will be −
const hex = '#0080C0';
const hexToRGB = hex => {
   let r = 0, g = 0, b = 0;
   // handling 3 digit hex
   if(hex.length == 4){
      r = "0x" + hex[1] + hex[1];
      g = "0x" + hex[2] + hex[2];
      b = "0x" + hex[3] + hex[3];
      // handling 6 digit hex
   }else if (hex.length == 7){

      r = "0x" + hex[1] + hex[2];
      g = "0x" + hex[3] + hex[4];
      b = "0x" + hex[5] + hex[6];
   };

   return{
      red: +r,
      green: +g,
      blue: +b
   };
}
console.log(hexToRGB(hex));
Following is the output on console −
{ red: 0, green: 128, blue: 192 }
Find and Draw Contours using OpenCV | Python - GeeksforGeeks

29 Apr, 2019
Contours are defined as the line joining all the points along the boundary of an image that are having the same intensity. Contours come handy in shape analysis, finding the size of the object of interest, and object detection.
OpenCV has findContour() function that helps in extracting the contours from the image. It works best on binary images, so we should first apply thresholding techniques, Sobel edges, etc.
Below is the code for finding contours –
import cv2import numpy as np  # Let's load a simple image with 3 black squaresimage = cv2.imread('C://Users//gfg//shapes.jpg')cv2.waitKey(0)  # Grayscalegray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)  # Find Canny edgesedged = cv2.Canny(gray, 30, 200)cv2.waitKey(0)  # Finding Contours# Use a copy of the image e.g. edged.copy()# since findContours alters the imagecontours, hierarchy = cv2.findContours(edged,     cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)  cv2.imshow('Canny Edges After Contouring', edged)cv2.waitKey(0)  print("Number of Contours found = " + str(len(contours)))  # Draw all contours# -1 signifies drawing all contourscv2.drawContours(image, contours, -1, (0, 255, 0), 3)  cv2.imshow('Contours', image)cv2.waitKey(0)cv2.destroyAllWindows()
Output:We see that there are three essential arguments in cv2.findContours() function. First one is source image, second is contour retrieval mode, third is contour approximation method and it outputs the image, contours, and hierarchy. ‘contours‘ is a Python list of all the contours in the image. Each individual contour is a Numpy array of (x, y) coordinates of boundary points of the object.
Contours Approximation Method –Above, we see that contours are the boundaries of a shape with the same intensity. It stores the (x, y) coordinates of the boundary of a shape. But does it store all the coordinates? That is specified by this contour approximation method.If we pass cv2.CHAIN_APPROX_NONE, all the boundary points are stored. But actually, do we need all the points? For eg, if we have to find the contour of a straight line. We need just two endpoints of that line. This is what cv2.CHAIN_APPROX_SIMPLE does. It removes all redundant points and compresses the contour, thereby saving memory.
Image-Processing
OpenCV
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
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
Selecting rows in pandas DataFrame based on conditions
sum() function in Python
*args and **kwargs in Python
Align the components with Bootstrap

To align the components like nav links, forms, buttons, or text to left or right in a navbar using the utility classes .navbar-left or .navbar-right. Both classes will add a CSS float in the specified direction.
You can try to run the following code to align components
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet">
      <script src = "/scripts/jquery.min.js"></script>
      <script src = "/bootstrap/js/bootstrap.min.js"></script>
   </head>
   <body>
      <nav class = "navbar navbar-default" role = "navigation" style="background: orange;">
         <div class = "navbar-header">
            <a class = "navbar-brand" href = "#">Alignment</a>
         </div>
         <div>
            <!--Left Align-->
            <ul class = "nav navbar-nav navbar-left">
               <li class = "dropdown">
                  <a href = "#" class = "dropdown-toggle" data-toggle = "dropdown">
                     Java
                     <b class = "caret"></b>
                  </a>
                  <ul class = "dropdown-menu">
                     <li><a href = "#">jmeter</a></li>
                     <li><a href = "#">EJB</a></li>
                     <li><a href = "#">Jasper Report</a></li>
                     <li class = "divider"></li>
                     <li><a href = "#">Separated link</a></li>
                     <li class = "divider"></li>
                     <li><a href = "#">One more separated link</a></li>
                  </ul>
               </li>
            </ul>
            <form class = "navbar-form navbar-left" role = "search">
               <button type = "submit" class = "btn btn-default">Left align-Submit Button</button>
            </form>
            <p class = "navbar-text navbar-left">Left align-Text</p>
            <!--Right Align-->
            <ul class = "nav navbar-nav navbar-right">
               <li class = "dropdown">
                  <a href = "#" class = "dropdown-toggle" data-toggle = "dropdown">
                     Java
                     <b class = "caret"></b>
                  </a>
                  <ul class = "dropdown-menu">
                     <li><a href = "#">jmeter</a></li>
                     <li><a href = "#">EJB</a></li>
                     <li><a href = "#">Jasper Report</a></li>
                     <li class = "divider"></li>
                     <li><a href = "#">Separated link</a></li>
                     <li class = "divider"></li>
                     <li><a href = "#">One more separated link</a></li>
                  </ul>
               </li>
            </ul>
            <form class = "navbar-form navbar-right" role = "search">
               <button type = "submit" class = "btn btn-default">
                  Right align-Submit Button
               </button>
            </form>
            <p class = "navbar-text navbar-right">Right align-Text</p>
         </div>
      </nav>
   </body>
</html>
How to sort a random number array in java?

To sort an array in Java, you need to compare each element of the array to all the remaining elements and verify whether it is greater if so swap them.
One solution to do so you need to use two loops (nested) where the inner loop starts with i+1 (where i is the variable of outer loop) to avoid repetitions in comparison.
 Live Demo
import java.util.Arrays;
import java.util.Scanner;

public class ArrayInOrder {
   public static void main(String args[]) {
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter the size of the array that is to be created::");
      int size = sc.nextInt();
      int[] myArray = new int[size];
      System.out.println("Enter the elements of the array ::");
   
      for(int i = 0; i<size; i++) {
         myArray[i] = sc.nextInt();
      }

      for(int i = 0; i<size-1; i++) {
         for (int j = i+1; j<myArray.length; j++) {
            if(myArray[i] > myArray[j]) {
               int temp = myArray[i];
               myArray[i] = myArray[j];
               myArray[j] = temp;
            }
         }
      }
      System.out.println(Arrays.toString(myArray));
   }
}
Enter the size of the array that is to be created ::
6
Enter the elements of the array ::
54
63
14
78
2
3
[2, 3, 14, 54, 63, 78]
Copy and paste to your clipboard using the pyperclip module in Python

We will be using the pyperclip module in order to copy and paste content to the clipboard. It is cross−platform and works on both Python 2 and Python 3.
Copying and pasting from and to the clipboard could be very useful when you want the output of the data to be pasted elsewhere in a different file or software.
The pyperclip module does not come packaged with Python. In order to access it, you must first download and install it. You can do this using the PIP package manager.
Launch your terminal and type the command below to install pyperclip
pip install pyperclip
Once you have it installed, you must import it to your python script.
We can do this using the import command,
import pyperclip
In order to copy text to the clipboard we use the pyperclip.copy() function.
import pyperclip
pyperclip.copy("Hello world!")
The above lines of code will copy “Hello world!” to your clipboard and would be ready to paste.
import pyperclip
text = pyperclip.paste()
print(text)
Hello world!
We use the pyperclip.paste() function to paste the latest content present in the clipboard.
Sometimes while working on a project you might want to paste new messages after you copy a different message.
In order to achieve this, we use the pyperclip. waitForNewPaste() function.
import pyperclip
pyperclip.copy("Hello world!")
text = pyperclip.paste()
print(text)
pyperclip.copy('Hello world!')
text = pyperclip.waitForNewPaste()
print(text)
Hello world! Random message copied
Note − In the above example, the program would terminate after it prints out the new copies text. The new copied text should be anything but “Hello world!”.
If you want to just paste, even if the text is same as the already existing text in the clip board, just go for pyperclip.waitForPaste() function.
Data stored in the clipboard and pasted is always a String datatype.
You now know how to copy and paste text or string datatype into your clipboard for quick access.
You can use this for developing simple automation tools that help you build tables, where data has to be constantly copied and pasted.
There are various other scenarios you can use this module in. And since it’s cross−platform, you can work with it on Linux, MacOS and Windows.
Express.js | app.delete() Function

06 Jun, 2021
The app.delete() function is used to route the HTTP DELETE requests to the path which is specified as parameter with the callback functions being passed as parameter.Syntax:  
app.delete(path, callback)
Parameters:  
path: It is the path for which the middleware function is being called.callback: It is a middleware function or a series/array of middleware functions.  
path: It is the path for which the middleware function is being called.
callback: It is a middleware function or a series/array of middleware functions.  
Installation of express module:  
You can visit the link to Install express module. You can install this package by using this command.  
You can visit the link to Install express module. You can install this package by using this command.  
npm install express
After installing express module, you can check your express version in command prompt using the command.  
After installing express module, you can check your express version in command prompt using the command.  
npm version express
After that, you can just create a folder and add a file for example, index.js. To run this file you need to run the following command.  
After that, you can just create a folder and add a file for example, index.js. To run this file you need to run the following command.  
node index.js
Filename: index.js  
javascript
var express = require('express');var app = express();var PORT = 3000; app.delete('/', (req, res) => {  res.send("DELETE Request Called")}) app.listen(PORT, function(err){    if (err) console.log(err);    console.log("Server listening on PORT", PORT);});
Steps to run the program:  
The project structure will look like this:  
The project structure will look like this:  
Make sure you have installed express module using following command:  
Make sure you have installed express module using following command:  
npm install express
Run index.js file using below command:  
Run index.js file using below command:  
node index.js
Output:  
Output:  
Server listening on PORT 3000
 Now make DELETE request to http://localhost:3000/ and you will get the following output:  
 
Now make DELETE request to http://localhost:3000/ and you will get the following output:  
DELETE Request Called
 
 
 
arorakashish0911
Express.js
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Node.js fs.existsSync() Method

12 Oct, 2021
The fs.existsSync() method is used to synchronously check if a file already exists in the given path or not. It returns a boolean value which indicates the presence of a file.
Syntax:
fs.existsSync( path )
Parameters: This method accepts a single parameter as mentioned above and described below:
path: It holds the path of the file that has to be checked. It can be a String, Buffer or URL.
Return Value: It returns a boolean value i.e true if the file exists otherwise returns false.
Below programs illustrate the fs.existsSync() method in Node.js:
Example 1:
// Node.js program to demonstrate the// fs.existsSync() method  // Import the filesystem moduleconst fs = require('fs');  // Get the current filenames// in the directorygetCurrentFilenames();  let fileExists = fs.existsSync('hello.txt');console.log("hello.txt exists:", fileExists);  fileExists = fs.existsSync('world.txt');console.log("world.txt exists:", fileExists);  // Function to get current filenames// in directoryfunction getCurrentFilenames() {  console.log("\nCurrent filenames:");  fs.readdirSync(__dirname).forEach(file => {    console.log(file);  });  console.log("\n");}
Output:
Current filenames:
hello.txt
index.js
package.json


hello.txt exists: true
world.txt exists: false
Example 2:
// Node.js program to demonstrate the// fs.existsSync() method  // Import the filesystem moduleconst fs = require('fs');  // Get the current filenames// in the directorygetCurrentFilenames();  // Check if the file existslet fileExists = fs.existsSync('hello.txt');console.log("hello.txt exists:", fileExists);  // If the file does not exist// create itif (!fileExists) {  console.log("Creating the file")  fs.writeFileSync("hello.txt", "Hello World");}  // Get the current filenames// in the directorygetCurrentFilenames();  // Check if the file exists againfileExists = fs.existsSync('hello.txt');console.log("hello.txt exists:", fileExists);  // Function to get current filenames// in directoryfunction getCurrentFilenames() {  console.log("\nCurrent filenames:");  fs.readdirSync(__dirname).forEach(file => {    console.log(file);  });  console.log("\n");}
Output:
Current filenames:
hello.txt
index.js
package.json


hello.txt exists: true

Current filenames:
hello.txt
index.js
package.json


hello.txt exists: true
Reference: https://nodejs.org/api/fs.html#fs_fs_existssync_path
Node.js-fs-module
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Playing Star Wars in Command Prompt

28 Feb, 2021
Most of us “Geeks” have watched The epic Star Wars movie countless times. You are here, that proves that you are one too. So in this article let’s do some geeky stuff. And as computer science enthusiasts that we are, let’s keep it inside the domain of computer science. So, what if we can play the entire Star Wars movie in Command Prompt (or terminal/bash)?
In this article, we are going to play the Star Wars movie in Command Prompt. This task is done by Telnet, which is a network protocol. It is used for communication purposes via command-line interface. For this, we will be using Telnet. Telnet is a connection method that allows character-based terminals to communicate to a remote server in text-based command-oriented terminal sessions.
In the previous versions of windows, it was given inbuilt but in today’s windows we need to first activate Telnet and that’s quite simple. For a Windows machine, you need to activate the Telnet. To do so follow the below steps:
Step 1:  Simply type “Turn Windows features on or off” in the search bar. 
Step 2: Find Telnet and Mark the checkbox and click ok. 
It’s pretty simple for macOS. Just use the below command in the bash/terminal and hit enter:
telnet towel.blinkenlights.nl
Open terminal and type the below command for the installation of telnet server and hit enter:
sudo apt install telnet
Now follow the below steps to play star wars in the terminal:
Step 1: Open Command Prompt and type the following commands:
Telnet 
As you hit enter, you enter Microsoft telnet portal.
Step 2: Type ‘o’ and hit enter.
Step 3: Now use the below command and hit enter.
telnet towel.blinkenlights.nl
As we hit enter the movie starts. Try in your system and enjoy.
Technical Scripter 2020
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.