code-rag-bench/online-tutorials huggingface dataset:
Can we remove the Title Bar of a Frame in Java?

Yes, we can remove the title bar of a frame using the setUndecorated() method. Set it to TRUE if you don’t want to remove the Title Bar.
The following is an example to remove the title bar of a frame in Java −
package my;
import java.awt.GridLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
public class SwingDemo {
   public static void main(String[] args) throws Exception {
      JFrame frame = new JFrame("Login!");
      JLabel label1, label2, label3;
      frame.setLayout(new GridLayout(2, 2));
      label1 = new JLabel("DeptId", SwingConstants.CENTER);
      label2 = new JLabel("SSN", SwingConstants.CENTER);
      label3 = new JLabel("Password", SwingConstants.CENTER);
      JTextField deptid = new JTextField(20);
      JTextField ssn = new JTextField(20);
      JPasswordField passwd = new JPasswordField();
      passwd.setEchoChar('*');
      frame.add(label1);
      frame.add(label2);
      frame.add(label3);
      frame.add(deptid);
      frame.add(ssn);
      frame.add(passwd);
      frame.setUndecorated(true);
      frame.setSize(550, 400);
      frame.setVisible(true);
   }
}
The output is as follows. The title is hidden −
What are the local static variables in C language?

A local static variable is a variable, whose lifetime doesn’t stop with a function call where it is declared. It extends until the lifetime of a complete program. All function calls share the same copy of local static variables.
These variables are used to count the number of times a function is called. The default value of static variable is 0. Whereas, normal local scope specifies that the variables defined within the block are visible only in that block and are invisible outside the block.
The global variables which are outside the block are visible up to the end of the program.
Following is the C program for local variable −
 Live Demo
#include<stdio.h>
main ( ){
   int a=40 ,b=30,sum; //local variables life is within the block
   printf ("sum=%d" ,a+b);
}
When the above program is executed, it produces the following output −
sum=70
Following is the C program for global variable −
 Live Demo
int c= 30; /* global area */
main ( ){
   int a = 10; //local area
   printf ("a=%d, c=%d", a,c);
   fun ( );
}
fun ( ){
   printf ("c=%d",c);
}
When the above program is executed, it produces the following output −
a =10, c = 30
Following is the C program for the local static variable −
#include <stdio.h>
void fun(){
   static int x; //default value of static variable is 0
   printf("%d ", a);
   a = a + 1;
}
int main(){
   fun(); //local static variable whose lifetime doesn’t stop with a function
   call, where it is declared.
   fun();
   return 0;
}
When the above program is executed, it produces the following output −
0 1
Java program to generate and print Floyd’s triangle

Floyd's triangle, named after Robert Floyd, is a right-angled triangle, which is made using natural numbers. It starts at 1 and consecutively selects the next greater number in the sequence.
Take a number of rows to be printed, n.
Make outer iteration I for n times to print rows
Make inner iteration for J to I
Print K
Increment K
Print NEWLINE character after each inner iteration
import java.util.Scanner;
public class FloyidsTriangle {
   public static void main(String args[]){
      int n,i,j,k = 1;
      System.out.println("Enter the number of lines you need in the FloyidsTriangle");
      Scanner sc = new Scanner(System.in);
      n = sc.nextInt();

      for(i = 1; i <= n; i++) {
         for(j=1;j <= i; j++){
            System.out.print(" "+k++);
         }
         System.out.println();
      }
   }
}
Enter the number of lines you need in the FloyidsTriangle
9
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31 32 33 34 35 36
37 38 39 40 41 42 43 44 45
Change value of input on form submit in JavaScript?

To change value of input, use the concept of document. The syntax is as follows −
document.yourFormName.yourTextName.value=anyValue;
Let’s say the following is our input type calling submitForm() on clicking “Submit Form” −
<form name="studentForm" onsubmit="submitForm();">
   <input type="hidden" name="txtInput" value="10000" />
   <input type="submit" value="Submit Form"/>
</form>
The submitForm() function changing the value of input −
function submitForm(){
   document.studentForm.txtInput.value='STUDENT-100';
}
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initialscale=1.0">
<title>Document</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"
></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.
css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
crossorigin="anonymous">
</head>
<body>
<form name="studentForm" onsubmit="submitForm();">
<input type="hidden" name="txtInput" value="10000" />
<input type="submit" value="Submit Form"/>
</form>
<script>
   function submitForm(){
      document.studentForm.txtInput.value='STUDENT-100';
   }
</script>
</body>
</html>
To run the above program, save the file name “anyName.html(index.html)” and right click on the
file. Select the option “Open with Live Server” in VS Code editor.
This will produce the following output −
On clicking the button “Submit Form”, you will get the change value in query string. This will
produce the following output −
Python | Pandas dataframe.mean()

19 Nov, 2018
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Pandas dataframe.mean() function return the mean of the values for the requested axis. If the method is applied on a pandas series object, then the method returns a scalar value which is the mean value of all the observations in the dataframe. If the method is applied on a pandas dataframe object, then the method returns a pandas series object which contains the mean of the values over the specified axis.
Syntax: DataFrame.mean(axis=None, skipna=None, level=None, numeric_only=None, **kwargs)
Parameters :axis : {index (0), columns (1)}skipna : Exclude NA/null values when computing the result
level : If the axis is a MultiIndex (hierarchical), count along a particular level, collapsing into a Series
numeric_only : Include only float, int, boolean columns. If None, will attempt to use everything, then use only numeric data. Not implemented for Series.
Returns : mean : Series or DataFrame (if level specified)
Example #1: Use mean() function to find the mean of all the observations over the index axis.
# importing pandas as pdimport pandas as pd  # Creating the dataframe df = pd.DataFrame({"A":[12, 4, 5, 44, 1],                   "B":[5, 2, 54, 3, 2],                    "C":[20, 16, 7, 3, 8],                   "D":[14, 3, 17, 2, 6]})  # Print the dataframedf
Let’s use the dataframe.mean() function to find the mean over the index axis.
# Even if we do not specify axis = 0,# the method will return the mean over# the index axis by defaultdf.mean(axis = 0)
Output : Example #2: Use mean() function on a dataframe which has Na values. Also find the mean over the column axis.
# importing pandas as pdimport pandas as pd  # Creating the dataframe df = pd.DataFrame({"A":[12, 4, 5, None, 1],                   "B":[7, 2, 54, 3, None],                   "C":[20, 16, 11, 3, 8],.                   "D":[14, 3, None, 2, 6]})  # skip the Na values while finding the meandf.mean(axis = 1, skipna = True)
Output :
Python pandas-dataFrame
Python pandas-dataFrame-methods
Python-pandas
Python
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 ?
*args and **kwargs in Python
Python Classes and Objects
Convert integer to string in Python
Python | os.path.join() method
Create a Pandas DataFrame from Lists
Introduction To PYTHON
Python | Ways to determine common prefix in set of strings

22 Jun, 2022
Given a set of strings, write a Python program to determine common prefix from a set of strings. Given below are a few methods to solve the above task.Method #1: Using Naive Approach  
Python3
# Python code to demonstrate# to find common prefix# from set of strings # Initialising stringini_strlist = ['akshat', 'akash', 'akshay', 'akshita'] # Finding common prefix using Naive Approachres = ''prefix = ini_strlist[0] for string in ini_strlist[1:]:    while string[:len(prefix)] != prefix and prefix:        prefix = prefix[:len(prefix)-1]    if not prefix:        breakres = prefix # Printing resultprint("Resultant prefix", str(res))
Resultant prefix ak
 
  Method #2: Using itertools.takewhile and zip  
Python3
# Python code to demonstrate# to find common prefix# from set of strings from itertools import takewhile # Initialising stringini_strlist = ['akshat', 'akash', 'akshay', 'akshita'] # Finding common prefix using Naive Approachres = ''.join(c[0] for c in takewhile(lambda x:        all(x[0] == y for y in x), zip(*ini_strlist))) # Printing resultprint("Resultant prefix", str(res))
Resultant prefix ak
 
In both the solution time and space complexity are the same:
Time Complexity: O(n2)
Space Complexity: O(n)
sagar0719kumar
harshmaster07705
Python string-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to iterate through Excel rows in Python?
Rotate axis tick labels in Seaborn and Matplotlib
Deque in Python
Queue in Python
Defaultdict in Python
Defaultdict in Python
Python program to add two numbers
Python | Get dictionary keys as a list
Python Program for Fibonacci numbers
Python Program for factorial of a number
unique=True – Django Built-in Field Validation

13 Feb, 2020
Built-in Field Validations in Django models are the validations that come predefined to all Django fields. Every field comes in with built-in validations from Django validators. One can also add more built-in field validations for applying or removing certain constraints on a particular field. unique=True sets the field to be unique i.e. once entered a value in a field, the same value can not be entered in any other instance of that model in any manner. It is generally used for fields like Roll Number, Employee Id, etc which should be unique.
Syntax
field_name = models.Field(unique=True)
Illustration of unique using an Example. Consider a project named geeksforgeeks having an app named geeks.
Refer to the following articles to check how to create a project and an app in Django.
How to Create a Basic Project using MVT in Django?
How to Create an App in Django ?
Enter the following code into models.py file of geeks app. We will be using CharField for experimenting for all field options.
from django.db import modelsfrom django.db.models import Model# Create your models here.  class GeeksModel(Model):    geeks_field = models.CharField(                    max_length = 200,                      unique = True                    )
After running makemigrations and migrate on Django and rendering the above model, let us create an instance from Django admin interface with string “a“. Now to show the constraint of unique=True, let us try to create one more instance of the model using same string. Now it will show this error.
This is enforced at the database level and by model validation. If you try to save a model with a duplicate value in a unique field, a django.db.IntegrityError will be raised by the model’s save() method.This option is valid on all field types except ManyToManyField and OneToOneField.Note that when unique is True, you don’t need to specify db_index, because unique implies the creation of an index.
NaveenArora
Django-models
Python Django
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python | Get unique values from a list
Python | datetime.timedelta() function
Why would you use the return statement in Python?

The print() function writes, i.e., "prints", a string or a number on the console. The return statement does not print out the value it returns when the function is called. It however causes the function to exit or terminate immediately, even if it is not the last statement of the function.
Functions that return values are sometimes called fruitful functions. In many other languages, a function that doesn’t return a value is called a procedure.
In the given code the value returned (that is 2) when function foo() is called is used in the function bar(). These return values are printed on console only when the print statements are used as shown below.
def foo():
    print("Hello from within foo")
    return 2
def bar():
    return 10*foo()
print foo()
print bar()
Hello from within foo
2
Hello from within foo
20
We see that when foo() is called from bar(), 2 isn't written to the console. Instead it is used to calculate the value returned from bar().
Python program to Count Uppercase, Lowercase, special character and numeric values using Regex

19 Feb, 2022
Prerequisites: Regular Expression in PythonGiven a string. The task is to count the number of Uppercase, Lowercase, special character and numeric values present in the string using Regular expression in Python.Examples:  
Input : 
"ThisIsGeeksforGeeks!, 123" 

Output :
No. of uppercase characters = 4
No. of lowercase characters = 15
No. of numerical characters = 3
No. of special characters = 2
Approach: The re.findall(pattern, string, flags=0) method can be used to find all non-overlapping matches of a pattern in the string. The return value is a list of strings.Below is the implementation.  
Python3
import re  string = "ThisIsGeeksforGeeks !, 123" # Creating separate lists using# the re.findall() method.uppercase_characters = re.findall(r"[A-Z]", string)lowercase_characters = re.findall(r"[a-z]", string)numerical_characters = re.findall(r"[0-9]", string)special_characters = re.findall(r"[, .!?]", string) print("The no. of uppercase characters is", len(uppercase_characters))print("The no. of lowercase characters is", len(lowercase_characters))print("The no. of numerical characters is", len(numerical_characters))print("The no. of special characters is", len(special_characters))
Output: 
The no. of uppercase characters is 4
The no. of lowercase characters is 15
The no. of numerical characters is 3
The no. of special characters is 4
 
rithiksuthan123
Python Regex-programs
python-regex
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
Read a file line by line in Python
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 | Convert string dictionary to dictionary
Python | Filter list by Boolean list

27 Sep, 2019
Sometimes, while working with Python list, we can have a problem in which we have to filter a list. This can sometimes, come with variations. One such variation can be filtering by the use of Boolean list. Let’s discuss a way in which this task can be done.
Method : Using itertools.compress()The most elegant and straightforward method to perform this particular task is to use inbuilt functionality of compress() to filter out all the elements from list which exists at Truth positions with respect to index of other list.
# Python3 code to demonstrate working of# Filter list by Boolean list# Using itertools.compressfrom itertools import compress  # initializing listtest_list = [6, 4, 8, 9, 10]  # printing listprint("The original list : " + str(test_list))  # initializing Boolean listbool_list = [True, False, False, True, True]  # printing boolean list print("The bool list is : " + str(bool_list))  # Filter list by Boolean list# Using itertools.compressres = list(compress(test_list, bool_list))  # Printing resultprint("List after filtering is : " + str(res))
 
The original list : [6, 4, 8, 9, 10]
The bool list is : [True, False, False, True, True]
List after filtering is : [6, 9, 10]

Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
What’s the yield keyword in JavaScript?

20 Sep, 2019
yield keyword is used to resume or pause a generator function asynchronously. A generator function is just like a normal function but the difference is that whenever the function is returning any value, it does it with the help of ‘yield’ keyword instead of return it. Yield can’t be called from nested functions or from callbacks.
The yield expression returns an object with two properties, “value” which is the actual value and “done” which is a boolean value, it returns true when generator function is full completed else it returns false.
If we pause the yield expression, the generator function will also get paused and resumes only when we call the next() method. When the next() method is encountered the function keeps on working until it faces another yield or returns expression.
Example 1:
function* showPrices(i) {    while (i < 3) {        yield i++;    }}  //creating an object for our function showPricesconst gfg = showPrices(0);   //return 0 because 0 value is passed to the showPrices yield expressionconsole.log(gfg.next().value);   // return 1console.log(gfg.next().value);   //return 2console.log(gfg.next().value); 
Output:
Example 2:
function* geeksforGeeks() {    /*expression paused here and return  value is undefined as nothing is declared*/    yield;         //wait for next() to finish    gfg(yield "Welcome to GFG"); }  function gfg(x) {    console.log("Hello World ", x)}  var generator = geeksforGeeks();  //return undefinedconsole.log(generator.next());   //return Welcome to GFG console.log(generator.next());   /*done remains false as we have not called next so that "Hello World" is still left there to process*/
Output:
Picked
JavaScript
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
How to append HTML code to a div using JavaScript ?
Difference Between PUT and PATCH Request
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
C# Program to Get the Full Path of the Current Directory Using Environment Class - GeeksforGeeks

01 Nov, 2021
In C#, Environment Class provides information about the current platform and manipulates, the current platform. It is useful for getting and setting various operating system-related information. We can use it in such a way that it retrieves command-line arguments information, exit codes information, environment variable settings information, contents of the call stack information, and time since the last system boot in milliseconds information. In this article, we will discuss how to get the full path of the current directory. So to solve this problem we use the CurrentDirectory property of the Environment Class. This property returns the complete path of the current working directory of your computer. This property also throws the following exceptions:
ArgumentException: This exception is thrown when the CurrentDirectory property tries to set to an empty string.
ArgumentNullException: This exception is thrown when the CurrentDirectory property tries to set to null.
IOException: This exception is thrown when the input/output error occurred.
DirectoryNoFoundException: This exception is thrown when the CurrentDirectory property tries to set a local path/address that cannot be found.
SecurityException: This exception is thrown when the caller does not have suitable permission.
Syntax:
Environment.CurrentDirectory
Return Type: The return type of this property is a string. And the returned string represents the current directory path.
Example:
C#
// C# program to find the current directory path// Using Environment Classusing System;  class GFG{      static public void Main(){          // Declaring a string    string resultPath = "";          // Get the complete path of the current    // working directory. Using     // CurrentDirectory property of     // Environment class    resultPath = Environment.CurrentDirectory;          Console.WriteLine("System Directory:\n" + resultPath);}}
Output:
System Directory:
/Users/Projects/newprogram/
CSharp-programs
Picked
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 50 C# Interview Questions & Answers
Extension Method in C#
HashSet in C# with Examples
Partial Classes in C#
C# | Inheritance
Convert String to Character Array in C#
Linked List Implementation in C#
C# | How to insert an element in an Array?
C# | List Class
Difference between Hashtable and Dictionary in C#
Ruby | Enumerable sum() function - GeeksforGeeks

05 Dec, 2019
The sum() of enumerable is an inbuilt method in Ruby returns the sum of all the elements in the enumerable. If a block is given, the block is applied to the enumerable, then the sum is computed. If the enumerable is empty, it returns init.
Syntax: enu.sum { |obj| block }
Parameters: The function accepts a block.
Return Value: It returns the sum of the enumerable.
Example #1:
# Initialize enu = (1..5)  # Prints enu.sum
Output:
15

Example #2:
# Ruby program for sum method in Enumerable  # Initialize enu = [10, 13, 12, 11]  # Prints enu.sum {|obj| obj * 5}
Output:
230

Ruby Enumerable-class
Ruby-Methods
Ruby
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Ruby | Array select() function
Ruby | Enumerator each_with_index function
Global Variable in Ruby
Ruby | Hash delete() function
Include v/s Extend in Ruby
Ruby | String gsub! Method
Ruby | Case Statement
Ruby | Decision Making (if, if-else, if-else-if, ternary) | Set - 1
Ruby | Enumerable find() function
Ruby | Data Types
Python - Divide and Conquer

In divide and conquer approach, the problem in hand, is divided into smaller sub-problems and then each problem is solved independently. When we keep on dividing the subproblems into even smaller sub-problems, we may eventually reach a stage where no more division is possible. Those "atomic" smallest possible sub-problem (fractions) are solved. The solution of all sub-problems is finally merged in order to obtain the solution of an original problem.
Broadly, we can understand divide-and-conquer approach in a three-step process.
This step involves breaking the problem into smaller sub-problems. Sub-problems should represent a part of the original problem. This step generally takes a recursive approach to divide the problem until no sub-problem is further divisible. At this stage, sub-problems become atomic in nature but still represent some part of the actual problem.
This step receives a lot of smaller sub-problems to be solved. Generally, at this level, the problems are considered 'solved' on their own.
When the smaller sub-problems are solved, this stage recursively combines them until they formulate a solution of the original problem. This algorithmic approach works recursively and conquer &s; merge steps works so close that they appear as one.
The following program is an example of divide-and-conquer programming approach where the binary search is implemented using python.
In binary search we take a sorted list of elements and start looking for an element at the middle of the list. If the search value matches with the middle value in the list we complete the search. Otherwise we eleminate half of the list of elements by choosing whether to procees with the right or left half of the list depending on the value of the item searched.
This is possible as the list is sorted and it is much quicker than linear search.Here we divide the given list and conquer by choosing the proper half of the list. We repeat this approcah till we find the element or conclude about it's absence in the list.
def bsearch(list, val):
   list_size = len(list) - 1
   idx0 = 0
   idxn = list_size
# Find the middle most value
   while idx0 <= idxn:
      midval = (idx0 + idxn)// 2
      if list[midval] == val:
         return midval
# Compare the value the middle most value
   if val > list[midval]:
      idx0 = midval + 1
   else:
      idxn = midval - 1
   if idx0 > idxn:
      return None
# Initialize the sorted list
list = [2,7,19,34,53,72]

# Print the search result
print(bsearch(list,72))
print(bsearch(list,11))
When the above code is executed, it produces the following result −
5
None


    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
Set a border around navbar with CSS

To add a border around navbar, set border to <ul>
ul {
   border: 2px solid blue;
}
You can try to run the following code to set border
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <style>
         ul {
            list-style-type: none;
            margin: 0;
            padding: 0;
            width: 200px;
            border: 2px solid blue;
         }
         li a {
            display: block;
            background-color: #F0E7E7;
         }
         .active {
            background-color: #4CAF50;
            color: white;
         }
         li {
            text-align: center;
            border-bottom: 1px solid #555;
         }
      </style>
   </head>
   <body>
      <ul>
         <li><a href = "#home">Home</a></li>
         <li><a href = "#company" class = "active">Company</a></li>
         <li><a href = "#product">Product</a></li>
         <li><a href = "#services">Services</a></li>
         <li><a href = "#contact">Contact</a></li>
      </ul>
   </body>
</html>
How to resize an image in Node Jimp?

NodeJS – Resize() is an inbuilt function that is used to resize the images to the desired size. We can use resize to set the height and width using a 2-pass bilinear algorithm. It can resize an image into any size as declared by the user. We can take input from the user or resize it into fixed Width*Height size.
resize(w, h, mode, cb)
w – This parameter is used to declare the width of the image. This is a required parameter.
w – This parameter is used to declare the width of the image. This is a required parameter.
h – This parameter is used to declare the height of the resized image. This parameter is also required.
h – This parameter is used to declare the height of the resized image. This parameter is also required.
mode – This is an optional parameter that is used to store the scaling method.
mode – This is an optional parameter that is used to store the scaling method.
cb – This is also an optional parameter that can be invoked after the compilation is complete.
cb – This is also an optional parameter that can be invoked after the compilation is complete.
Before proceeding to use resize() functions, please check that the following statements are already executed for setting up the environment.
npm init -y // Initialising the Node environment
npm init -y // Initialising the Node environment
npm install jimp --save // Installing the jimp dependency
npm install jimp --save // Installing the jimp dependency
Create a resize.js file and copy-paste the following code snippet in it.
Create a resize.js file and copy-paste the following code snippet in it.
Use node resize.js to run the code.
Use node resize.js to run the code.
Note – The method name should match with the JS file name. Only then it will be able to call the desired method.
const Jimp = require('jimp');

async function resize() { // Function name is same as of file name
   // Reading Image
   const image = await Jimp.read
   ('/home/jimp/tutorials_point_img.jpg');
   image.resize(200,200, function(err){
      if (err) throw err;
   })
   .write('/home/jimp/resize.jpeg');
}

resize(); // Calling the function here using async
console.log("Image is processed successfully");
const Jimp = require('jimp') ;
async function resize() {
   // Reading Image
   const image = await Jimp.read
   ('/home/jimp/tutorials_point_img.jpg');
   // Used RESIZE_BEZIER as cb for finer images
   image.resize(1024,768,Jimp.RESIZE_BEZIER, function(err){
      if (err) throw err;
   })
   .write('/home/jimp/resize.jpeg');
}

resize();
console.log("Image is processed successfully");
Display Month in MMMM format in Java

The MMMM format for months is like entire month name: January, February, March, etc. We will use it like this.
SimpleDateFormat("MMM");
Let us see an example.
// displaying month in MMMM format SimpleDateFormat simpleformat = new SimpleDateFormat("MMMM");
String strMonth= simpleformat.format(new Date());
System.out.println("Month in MMMM format = "+strMonth);
Above, we have used the SimpleDateFormat class, therefore the following package is imported.
import java.text.SimpleDateFormat;
The following is an example.
 Live Demo
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Calendar;
public class Demo {
   public static void main(String[] args) throws Exception {
      // displaying current date and time
      Calendar cal = Calendar.getInstance();
      SimpleDateFormat simpleformat = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss");
      System.out.println("Date and time = "+simpleformat.format(cal.getTime()));
      // displaying date
      simpleformat = new SimpleDateFormat("dd/MMMM/yyyy");
      String str = simpleformat.format(new Date());
      System.out.println("Current Date = "+str);
      // displaying month in MMMM format
      simpleformat = new SimpleDateFormat("MMMM");
      String strMonth= simpleformat.format(new Date());
      System.out.println("Month in MMMM format = "+strMonth);
      // current time
      simpleformat = new SimpleDateFormat("HH.mm.ss");
      String strTime = simpleformat.format(new Date());
      System.out.println("Current Time = "+strTime);
   }
}
Date and time = Mon, 26 Nov 2018 10:46:10
Current Date = 26/November/2018
Month in MMMM format = November
Current Time = 10.46.10
Symmetric Tree in Python

Suppose we have one binary tree. We have to check whether the tree is a symmetric tree or not. A tree will be said to be symmetric if it is the same when we take the mirror image of it. From these two trees, the first one is symmetric, but the second one is not.
To solve this, we will follow these steps.
We will call following steps recursively. The function will be solve(root, root)
if the node1 and node2 are empty, then return true
if either node1 or node2 is empty, then return false
return true when node1.val = node2.val and solve(node1.left, node2.right) and solve(node1.right, node2.left)
Let us see the following implementation to get better understanding −
 Live Demo
class TreeNode:
   def __init__(self, data, left = None, right = None):
      self.data = data
      self.left = left
      self.right = right
def insert(temp,data):
   que = []
   que.append(temp)
   while (len(que)):
      temp = que[0]
      que.pop(0)
      if (not temp.left):
         if data is not None:
            temp.left = TreeNode(data)
         else:
            temp.left = TreeNode(0)
         break
      else:
         que.append(temp.left)
      if (not temp.right):
         if data is not None:
            temp.right = TreeNode(data)
         else:
            temp.right = TreeNode(0)
         break
      else:
         que.append(temp.right)
def make_tree(elements):
   Tree = TreeNode(elements[0])
   for element in elements[1:]:
      insert(Tree, element)
   return Tree
class Solution(object):
   def isSymmetric(self, root):
      """
      :type root: TreeNode
      :rtype: bool
      """
      return self.solve(root,root)
   def solve(self,node1,node2):
      if not node1 and not node2:
         return True
      if not node1 or not node2:
         return False
      # print(node1.val, node2.val)
      return node1.data == node2.data and
self.solve(node1.left,node2.right) and
self.solve(node1.right,node2.left)
tree1 = make_tree([1,2,2,3,4,4,3])
tree2 = make_tree([1,2,2,3,4,None,3])
ob1 = Solution()
print(ob1.isSymmetric(tree1))
print(ob1.isSymmetric(tree2))
tree1 = make_tree([1,2,2,3,4,4,3])
tree2 = make_tree([1,2,2,3,4,None,3])
True
False
How can I select every alternative row and display in descending order in SQL?

To fetch every alternative row, use MOD() under WHERE. Then use ORDER BY DESC to display the result in descending order −
select *from yourTableName where mod(yourColumnName,2)=1 order by yourColumnName DESC;
Let us first create a table −
mysql> create table DemoTable
(
   UniqueId int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   ClientName varchar(40),
   ClientAge int
);
Query OK, 0 rows affected (1.02 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable(ClientName,ClientAge) values('Chris',34);
Query OK, 1 row affected (0.47 sec)
mysql> insert into DemoTable(ClientName,ClientAge) values('Tom',45);
Query OK, 1 row affected (0.19 sec)
mysql> insert into DemoTable(ClientName,ClientAge) values('Sam',36);
Query OK, 1 row affected (0.16 sec)
mysql> insert into DemoTable(ClientName,ClientAge) values('Carol',42);
Query OK, 1 row affected (0.25 sec)
mysql> insert into DemoTable(ClientName,ClientAge) values('David',38);
Query OK, 1 row affected (0.12 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+----------+------------+-----------+
| UniqueId | ClientName | ClientAge |
+----------+------------+-----------+
|        1 | Chris      |        34 |
|        2 | Tom        |        45 |
|        3 | Sam        |        36 |
|        4 | Carol      |        42 |
|        5 | David      |        38 |
+----------+------------+-----------+
5 rows in set (0.00 sec)
Let us now select every alternative row and display in descending order −
mysql> select *from DemoTable where mod(UniqueId,2)=1 order by UniqueId DESC;
This will produce the following output −
+----------+------------+-----------+
| UniqueId | ClientName | ClientAge |
+----------+------------+-----------+
|        5 | David      |        38 |
|        3 | Sam        |        36 |
|        1 | Chris      |        34 |
+----------+------------+-----------+
3 rows in set (0.00 sec)
How to set the height/width of a Label widget in Tkinter?

The Label widgets are used for displaying text and images in the application. The size of the label widget depends on a number of factors such as width, height, and Font-size of the Label text.
The height and width define how the label widget should appear in the window. To set the height and width of the label widget, we should declare the Label widget with a variable. Instantiating the label widget with a variable allows the users to add/edit the properties of the Label widget.
# Import the required libraries
from tkinter import *

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

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

# Add a Label widget
label=Label(win, text="How to set the height/width " "of a Label widget in Tkinter?", font=('Times 14'), width=60, height=15)
label.pack()

win.mainloop()
Running the above code will display a window that contains a label widget within width and height.
Dart Programming - for Loop

The for loop is an implementation of a definite loop. The for loop executes the code block for a specified number of times. It can be used to iterate over a fixed set of values, such as an array.
Following is the syntax of the for loop.
for (initial_count_value; termination-condition; step) { 
   //statements 
}    

void main() { 
   var num = 5; 
   var factorial = 1; 
   
   for( var i = num ; i >= 1; i-- ) { 
      factorial *= i ; 
   } 
   print(factorial); 
}
The program code will produce the following output −
120

The for loop has three parts: the initializer (i=num), the condition ( i>=1) and the final expression (i--).
The program calculates the factorial of the number 5 and displays the same. The for loop generates the sequence of numbers from 5 to 1, calculating the product of the numbers in every iteration.
Multiple assignments and final expressions can be combined in a for loop, by using the comma operator (,). For example, the following for loop prints the first eight Fibonacci numbers −
void main() { 
   for(var temp, i = 0, j = 1; j<30; temp = i, i = j, j = i + temp) { 
      print('${j}'); 
   } 
} 
It should produce the following output −
1 
1 
2 
3 
5
8 
13 
21


    44 Lectures 
     4.5 hours 

 Sriyank Siddhartha

    34 Lectures 
     4 hours 

 Sriyank Siddhartha

    69 Lectures 
     4 hours 

 Frahaan Hussain

    117 Lectures 
     10 hours 

 Frahaan Hussain

    22 Lectures 
     1.5 hours 

 Pranjal Srivastava

    34 Lectures 
     3 hours 

 Pranjal Srivastava
 Print
 Add Notes
 Bookmark this page
C++ Vector Library - data() Function

The C++ function std::vector::data() returns a pointer to the first element of the vector container.
Following is the declaration for std::vector::data() function form std::vector header.
value_type* data() noexcept;
const value_type* data() const noexcept;

None
Returns constant pointer if vector object is constant qualified otherwise non-constant pointer.
This member function never throws exception.
Constant i.e. O(1)
The following example shows the usage of std::vector::data() function.
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
   vector<int> v = {1, 2, 3, 4, 5};
   int *p;

   p = v.data();

   for (int i = 0; i < v.size(); ++i)
      cout << *p++ << endl;

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

 Print
 Add Notes
 Bookmark this page
Python | Pandas Timedelta.seconds - GeeksforGeeks

14 Jan, 2019
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Timedelta is a subclass of datetime.timedelta, and behaves in a similar manner. It is the pandas equivalent of python’s datetime.timedelta and is interchangeable with it in most cases. Timedelta.seconds property in pandas.Timedelta is used to return Number of seconds.
Syntax: Timedelta.seconds
Parameters: None
Returns: return the Number of seconds.
Code #1:
# importing pandas as pd import pandas as pd   # Create the Timedelta object td = pd.Timedelta('3 days 06:05:01.000000111')   # Print the Timedelta object print(td)   print(td.seconds)
3 days 06:05:01.000000
21901

Code #2:
# importing pandas as pd import pandas as pd   # Create the Timedelta object td = pd.Timedelta('7 days 15 min 3 s')   # Print the Timedelta object print(td)   print(td.seconds)
7 days 00:15:03
903

Code #3:
# importing pandas as pd import pandas as pd import datetime  # Create the Timedelta object td = pd.Timedelta(133, unit ='s')  # Print the Timedelta object print(td)   print(td.seconds)
0 days 00:02:13
133

Python pandas-timedelta
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
How to Install PIP on Windows ?
Different ways to create Pandas Dataframe
Enumerate() in Python
Create a Pandas DataFrame from Lists
*args and **kwargs in Python
Check if element exists in list in Python
Convert integer to string in Python
How To Convert Python Dictionary To JSON?
isupper(), islower(), lower(), upper() in Python and their applications
Life Cycle Phases of Project Management - GeeksforGeeks

25 Mar, 2020
Life cycle phases consist of various separated modules with defined functionalities. Life cycle phases describe the various phases of project management. Life cycle phases are mainly divided into two broad categories:
1. Engineering Phase
2. Production Phase 
These are explained as following below.
1. Engineering Phase:Engineering phase involves establishing the goal and defines the overall scope of the project. Engineering phase involves the small team size and it is usually less predicted. Engineering phase is further divided into 2 Phases: Inception Phase, and Elaboration Phase.
(i). Inception Phase –Inception Phase involves establishing goals and gathering the requirements needed for the software development. It involves the cost estimation and identifying the risk factors. In the inception phase, we mainly work on the scope of the project and architecture. Feasibility analysis is also an important part of the inception phase.
(ii). Elaboration Phase –Elaboration phase involves in-depth evaluation and study as well as establishing the strong architecture and infrastructure. In the elaboration phase, we work on the efficiency of our architecture. In this phase, we also analyze use cases and other software diagrams. We reduce the risk to a certain extent and a preliminary user modules in prepared in this phase.
2. Production Phase:In the Production phase, we mainly focus on the Implementation of Project and optimization including the reduced cost and risk factors of our project. It also involves various testing for efficient deployment of the project. It involves the large team size and most of the time it is predictable. It is broadly divided into 2 Phases: Construction Phase, Transition Phase.
(i). Construction Phase –In the construction phase, we perform the implementation of our software. In this phase, we minimize the risk and eliminate it. All the features and components are integrated into an application. In this phase, we perform strict testing and process optimization is done. We minimize the development cost and work to improve its efficiency.Construction phase mainly focuses on the implementation and testing of our software.
(ii). Transition Phase –In the Transition phase, we perform strict testings mainly beta testing and deployment of software or project. After receiving the feedback from the user, we perform some changes in our software to make it more efficacious. In this phase, the developer works on a project with an user’s view to make software more supportable and user friendly.
Software Engineering
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
DFD for Library Management System
What is DFD(Data Flow Diagram)?
Software Engineering | Software Design Process
RUP and its Phases
Software Engineering | Black box testing
System Testing
Software Development Life Cycle (SDLC)
Software Engineering | Incremental process model
Data Dictionaries in Software Engineering
Use Case Diagram for Library Management System
Calculate Age from given Date of Birth in MySQL?

To calculate age in MySQL from Date of Birth, you can use the following syntax −
SELECT YEAR(CURRENT_TIMESTAMP) - YEAR(yourColumnName)
- (RIGHT(CURRENT_TIMESTAMP, 5) < RIGHT(yourColumnName, 5)) as anyVariableName from yourTableName;
To understand the above concept, let us create a table. The following is the query to create a table.
mysql> create table AgeCalculatesDemo
   −> (
   −> YourDateOfBirth datetime
   −> );
Query OK, 0 rows affected (0.50 sec)
Insert some records in the table with the help of insert command. These records are the DOBs through which we will calculate the age. The following is the query −
mysql> insert into AgeCalculatesDemo values(date_add(now(),interval 22 year));
Query OK, 1 row affected (0.23 sec)

mysql> truncate table AgeCalculatesDemo;
Query OK, 0 rows affected (0.89 sec)

mysql> insert into AgeCalculatesDemo values(date_add(now(),interval -22 year));
Query OK, 1 row affected (0.16 sec)

mysql> insert into AgeCalculatesDemo values(date_add(now(),interval -12 year));
Query OK, 1 row affected (0.18 sec)

mysql> insert into AgeCalculatesDemo values(date_add(now(),interval -19 year));
Query OK, 1 row affected (0.15 sec)

mysql> insert into AgeCalculatesDemo values('2010-4-05');
Query OK, 1 row affected (0.25 sec)
Now you can display all records with the help of select statement. The following is the query −
mysql> select *from AgeCalculatesDemo;
The following is the output −
+---------------------+
| YourDateOfBirth     |
+---------------------+
| 1996-12-06 23:35:26 |
| 2006-12-06 23:35:32 |
| 1999-12-06 23:35:42 |
| 2010-04-05 00:00:00 |
+---------------------+
4 rows in set (0.00 sec)
Here is the query that can be used to calculate age.
mysql> SELECT YEAR(CURRENT_TIMESTAMP) - YEAR(YourDateOfBirth)
   −> - (RIGHT(CURRENT_TIMESTAMP, 5) < RIGHT(YourDateOfBirth, 5)) as YourAge
   −> from AgeCalculatesDemo;
The following is the output displaying age −
+---------+
| YourAge |
+---------+
|      22 |
|      12 |
|      19 |
|       8 |
+---------+
4 rows in set (0.00 sec)
Linear Search Program in C

Here we present the implementation of linear search in C programming language. The output of the program is given after the code.
#include <stdio.h>

#define MAX 20

// array of items on which linear search will be conducted.
int intArray[MAX] = {1,2,3,4,6,7,9,11,12,14,15,16,17,19,33,34,43,45,55,66};

void printline(int count) {
   int i;
	
   for(i = 0;i <count-1;i++) {
      printf("=");
   }
	
   printf("=\n");
}

// this method makes a linear search. 
int find(int data) {

   int comparisons = 0;
   int index = -1;
   int i;

   // navigate through all items 
   for(i = 0;i<MAX;i++) {
	
      // count the comparisons made 
      comparisons++;
		
      // if data found, break the loop
      if(data == intArray[i]) {
         index = i;
         break;
      }
   }   
	
   printf("Total comparisons made: %d", comparisons);
   return index;
}

void display() {
   int i;
   printf("[");
	
   // navigate through all items 
   for(i = 0;i<MAX;i++) {
      printf("%d ",intArray[i]);
   }
	
   printf("]\n");
}

void main() {
   printf("Input Array: ");
   display();
   printline(50);
	
   //find location of 1
   int location = find(55);

   // if element was found 
   if(location != -1)
      printf("\nElement found at location: %d" ,(location+1));
   else
      printf("Element not found.");
}
If we compile and run the above program, it will produce the following result −
Input Array: [1 2 3 4 6 7 9 11 12 14 15 16 17 19 33 34 43 45 55 66 ]
==================================================
Total comparisons made: 19
Element found at location: 19


    42 Lectures 
     1.5 hours 

 Ravi Kiran

    141 Lectures 
     13 hours 

 Arnab Chakraborty

    26 Lectures 
     8.5 hours 

 Parth Panjabi

    65 Lectures 
     6 hours 

 Arnab Chakraborty

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    64 Lectures 
     10.5 hours 

 Eduonix Learning Solutions
 Print
 Add Notes
 Bookmark this page
Tryit Editor v3.7

Tryit: The border property