Sunday, October 30, 2022

JavaScript Functions as JavaScript Variables

In Javascript instead of declaring and executing a function in two different steps.
for example
step 1 - 
function add(a,b){return a+b;}
step 2-
add(3,4);
result 7

Javascript provides an approach to declare and execute the function immediately. Which is known as IIFE(Immediately Invoked Function Expression)

Example:
(
function add(x,y){
alert(x+y);
})();

Direct View Storage Tube (DVST).

It is a technique that 

Introduction To Mobile And Mobile Programming.

Introduction to mobile programming.


Saturday, October 29, 2022

Birthday Cake Candles Problem(Hacker Rank)

 You are in charge of the cake for a child's birthday. You have decided the cake will have one candle for each year of their total age. They will only be able to blow out the tallest of the candles. Count how many candles are tallest.

Example

The maximum height candles are  units high. There are  of them, so return .


SOLUTION:

    public static int birthdayCakeCandles(List<int> candles)
    {
       int max = candles.Max();
       int result = candles.Count(x=>x==max);
       return result;
    }

Description
  1. Find the tallest candle.
  2. Count the number of tallest candles using linq.
  3. return result.


Friday, November 19, 2021

What is image processing? What are the applications of image processing in computer science?

 What is image processing?

Image processing is a method to perform some operations on an image, in order to get an enhanced image or to extract some useful information from it. it is a type of signal processing in which input is an image and output may be image or characteristics associated with that image. Nowadays, image processing is among rapidly growing technologies. it forms core research are within engineering and computer science disciplines too.


Image processing basically includes the following three steps.

1. Importing the image via image acquisition tools.

2. Analyzing and manipulating the image.

3. Output in which result can be altered image or report that is based on image analysis.

What are the applications of image processing in computer science?

Some of the major fields in which digital image processing is widely used are mentioned below

  • 1. Image sharpening and restoration

  • 2. Medical field

  • 3. Remote sensing

  • 4. Transmission and encoding

  • 5. Machine/Robot vision

  • 6. Color processing

  • 7. Pattern recognition

  • 8. Video processing

  • 9. Microscopic Imaging

  • 10. Others

What is the interactive computer system? Explain. What is resolution? What is the impact of resolution in display devices?

 What is the interactive computer system?

interactive computer system involves a two-way communication between computer and user.

here the observer is given some control over the image by providing him with an input device for example the video game controller of the ping pong game.

this helps him to signal his request to the computer. The computer on receiving signals from the input device can modify the displayed picture appropriately.

the picture changes according to the users command.

 What is resolution?

The maximum number of points (pixels) that can be displayed without overlap on a CRT is referred to as their solution. It is also defined as maximum number of points displayed horizontally and vertically without overlapping on a display screen.

More precise definition of resolution is no of dots per inch(dpi/pixel per inch) that can be plotted horizontally and vertically. Resolution of 1280*720 means that there are 1280 horizontal lines and 720 vertical lines or 1280 pixels horizontally and 720 pixels vertically. We can say that the higher is the pixel resolution, the higher is the quality of the image. there are two types of resolutions.

1. Image resolution

Image resolution is defined as the distance from one pixel to the next pixel i.e., pixel spacing.

2. Screen resolution

screen resolution is defined as the number of pixels in the horizontal and vertical dirrection.

What is the impact of resolution on display devices?


Thursday, November 18, 2021

Define pixel. What is the use of pixel in display devices?

 A pixel is the smallest unit of a digital image or graphic that can be displayed and represented on a digital display device.

A pixel is the basic logical unit in digital graphics. Pixels are combined to form a complete image, video, text, or any visible thing on a computer display.

A pixel is also known as a picture element (pix = picture, el = element).

Pixel

The full form of the pixel is "Picture Element." It is also known as "PEL." Pixel is the smallest element of an image on a computer display, whether they are LCD or CRT monitors. A screen is made up of a matrix of thousands or millions of pixels. A pixel is represented with a dot or a square on a computer screen.

Concept of Pixel

The good thing is that a pixel cannot be seen as they are very small which result in a smooth and clear image rather than "pixelated." Each pixel has a value, or we can say a unique logical address. It can have only one color at a time. Colour of a pixel is determined by the number of bits which is used to represent it. A resolution of a computer screen depends upon graphics card and display monitor, the quantity, size and color combination of pixels.

Concept of Pixel Concept of Pixel
Concept of Pixel

As we know that an image is build up of thousands and millions of pixels. In the above images, if we zoom in the image, we will be able to see some of the pixels.

Uses of pixel in display devices


THE USE OF THE PIXEL IN GRAPHIC DESIGN

When we open our graphics editing program, when you start with a new project, you will ask us for the resolution or, as we have already seen, for the number of pixels.
The purpose of the resolution is to be able to classify the devices where we are going to show the image:

The resolution is no more than the total number of pixels that will form the bitmap image. The advanced the number of pixels, the better the image will be. The number of pixels associated with a given image depends on how many pixels the camera’s CCD sensor is using at the time of capturing.

The pixels of the height multiplies by its width to rapid the resolve of an image

Example: An image that has a determination of 1000 x 1000 pixels will result in 1,000,000 pixels. To make it easier to understand, It expresses in megapixels (MP), such that 1,000,000 pixels is equal to 1.0 MP.

It is one of the first concepts that the professional will learn in the world of graphic design. And will be crucial when it comes to achieving the best quality results.


describe types of computer graphics with suitable example. describe uses of computer graphics in computer field.

 There are two types of computer graphics:

1. Interactive computer graphics.

computer graphics in which there is an interaction between user and the graphics for example game console and game graphics.

2. Non-interactive computer graphics.

computer graphics where there is no interaction between user and computer graphics for example printing someting.

Uses of computer graphics in the computer field.

there are several uses of CG which are very useful in the current scenario. some of  its uses in computer field includes.

1. computer program development

2. making movies

3. video game

4. catalog design

5. creating commercial arts

6. scientific modeling( for example weather forcasting, meteorological data)

What do you mean by image processing? How it is differ from computer graphics?

Image processing

Image processing is a method to perform some operation on an image, in order to get an enhanced image or to extract some useful information from it. It is a type of signal processing in which input is an image and output may be an image or characteristics associated with that image.

major steps of image processing.

1. importing the image via image acquisition tools

2. analyzing and manipulating the image

3. output in which result can be altered image or report that is based on image analysis.

Difference between computer graphics and image processing.

The process of synthesize picture from mathematical or geometrical models is called computer grapics.

simply in computer graphics we take pixels as mathematical input parameters and draw different images from these pixels.

whereas the process of analyze picture to derive descriptions (often in mathematical or geometrical forms) of objects appeared in the pictures is called image processing.

image processing is the reverse process of computer graphics. where we take any one of the picture as input parameter and return their mathematical form.





history of computer graphics.

 The brief history of computer graphics.

1950 - The first graphics displays, military applications.

1962 - The first graphics station (sketchpad) consisting of a monitor, light pen, and software for interactive operation constructed by Ivan Sutherland.

1964 - Research team working on the algorithms in computer graphics employed at the university of utah (including ivan sutherland, james blinn, edwin catmull)

1965 - The first commercial graphics station: IBM 2250 Display Unit and the IBM PC 1130

1969 - Beginning of a group SIGGRAPH (special interest group on graphics) in the organization of ACM (Association for computing Machinary) gathering of IT professionals.

1974 - Creation of graphics laboratory at the new york institute of technology

1980 - Tuner Whitted published article about creating realistic images, beginning of method of ray tracing.

1982 - TRON, the first film that uses computer graphics. The first completely computer generated scene in the movie star trek II: The Wrath of Khan.

1984 - work of c.goral, k. torrance, d. greenberg and b. battile and proposing a new approach for visualization - the method of radiosity.

1988 - the first film sequence with morphing in willow

1989 - the first character created using 3d graphics in the studio industrial light and magic (ILM)

1993 - dinosaurs in jurassic park - the first complete and detailed living organisms generated digital technology

1995 - toy story implemented complete using computer graphics, the first photo realistic hair and fur computer generated.

1999 - the world wide web consortium (W3C) begins development of SVG (Scalable Vector Graphics), a way of using text-based (XML) files to provide higher-quality images on the web. SVG images can include elements of both conventional vector and raster graphics.

2007 - apple launches its iPhone and iPod touch products with touch screen graphic user interface.

2017 - Microsoft announce it will not kill off its basic but very popular paint program, loved by computer artists for over 30 years.


Sunday, October 31, 2021

git and github commands

 generate ssh key

for windows user

go to gitbash and use command

ssh-keygen -t rsa -b 4096 -C "youremail@example.com"

Saturday, October 30, 2021

what is middleware?

 Middleware are functions that can be used for handling request and response objects.

In practice, you can use several middlewares at the same time. When you have more than one, they're executed one by one in the order that they were taken into use in the express.

In practice, you can use several middleware at the same time. When you have more than one, they're executed one by one in the order that they were taken into use in express.


Middleware is a function that receives three parameters:

const requestLogger = (request, response, next) => {
  console.log('Method:', request.method)
  console.log('Path:  ', request.path)
  console.log('Body:  ', request.body)
  console.log('---')
  next()
}

Thursday, October 28, 2021

Mongodb general commands

 //cheatsheet


/* key words */

collection = table



/* for databses */


view all databases

-show dbs


create a new or switch databases

-use <databse_name>


view current database

-db


delete database

-db.dropDatabase()



/* for collections */


Show Collections

-show collections


create a collection name 'comments'

-db.createCollection('comments')


delete collections

-db.<collection_name>.drop()


/* mongodb command for rows*/


Show All Rows In a Collection

-db.<collection_name>.find()

-db.<collection_name>.find().pretty() //for preetyfied view

-db.<collection_name>.findOne() // for finding 1st row


Insert One Rows

-db.<collection_name>.insert({'name':'Gyanendra','lang':'javaScript','age':'24'})


Insert Many Rows

-db.<collection_name>.insertMany([{'name':'Gyanendra','lang':'javaScript','age':'24'},{'name':'Gyanendra','lang':'javaScript','age':'24'},{'name':'Arvind','lang':'javaScript','age':'24'},])


Search In a Mongodb Database

-db.<collection_name>.find({'name':'Arvind'})


Limit The Number of Rows In Output

-db.<collection_name>.find().limit(10)


Count Rows

-db.<collection_name>.count()

or 

-db.<collection_namee>.limit(3).count()

//these two has same output because limit only limits the output data not the whole data



REST

 REST TABLE

Sunday, October 24, 2021

Passing Data Between a Parent and Child in React

Passing Data Between a Parent and Child in React

Today I’ll be going over how data is passed between parent and child components in React. There are two directions a data can go and it’s the following:

  1. From parent to child
  2. From child to parent

I’ll be going over these in the following sections.

Passing Data From Parent to Child

When you need to pass data from a parent to child class component, you do this by using props.

For example, let’s say you have two class components, Parent and Child, and you want to pass a state in the parent to the child. You would do something like this:

import React from 'react';
class Parent extends React.Component{
constructor(props){
super(props);
this.state = {
data: 'Data from parent'
}
}
render(){
const {data} = this.state;
return(
<div>
<Child dataParentToChild = {data}/>
</div>
)
}
}
class Child extends React.Component{
constructor(props){
super(props);
this.state = {
data: this.props.dataParentToChild
}
}
render(){
const {data} = this.state;
return(
<div>
{data}
</div>
)
}
}
export default Parent;
Parent to Child Using Class Components

As you can see, the parent component passes props to the child component and the child can then access the data from the parent via this.props.

For the same example, if you have two function components instead of class components, you don’t even need to use props. You can do something like the following:

import React from 'react';
function Parent(){
const data = 'Data from parent';
return(
<div>
<Child dataParentToChild = {data}/>
</div>
)
}
function Child ({dataParentToChild}){
return(
<div>
{dataParentToChild}
</div>
)
}
export default Parent;
Parent to Child using Function Components

Passing Data from Child to Parent

Passing the data from the child to parent component is a bit trickier. In order to do this, you need to do the following steps:

  1. Create a callback function in the parent component. This callback function will get the data from the child component.
  2. Pass the callback function in the parent as a prop to the child component.
  3. The child component calls the parent callback function using props.

Let’s see how these steps are implemented using an example. You have two class components, Parent and Child. The Child component has a form that can be submitted in order to send its data up to the Parent component. It would look something like this:

import React from 'react';
class Parent extends React.Component{
constructor(props){
super(props);
this.state = {
data: null
}
}
handleCallback = (childData) =>{
this.setState({data: childData})
}
render(){
const {data} = this.state;
return(
<div>
<Child parentCallback = {this.handleCallback}/>
{data}
</div>
)
}
}
class Child extends React.Component{
onTrigger = (event) => {
this.props.parentCallback("Data from child");
event.preventDefault();
}
render(){
return(
<div>
<form onSubmit = {this.onTrigger}>
<input type = "submit" value = "Submit"/>
</form>
</div>
)
}
}
export default Parent;

As you can see, when the Child component is triggered, it will call the Parent component’s callback function with data it wants to pass to the parent. The Parent’s callback function will handle the data it received from the child.

Conclusion

We’ve gone over passing data between a parent and child components in React. Just as a recap, here’s the different methods we’ve covered:

  1. Passing data from parent to child class components
  2. Passing data from parent to child function components
  3. Passing data from child to parent

JavaScript Functions as JavaScript Variables

In Javascript instead of declaring and executing a function in two different steps. for example step 1 -  function add(a,b){return a+b;} ste...