Friday 21 August 2020

How to install google-chrome in redhat without redhat subscription

Install google-chrome in redhat 


Download the .rpm file of chrome

https://www.google.com/chrome/thank-you.html?installdataindex=empty&statcb=0&defaultbrowser=0&brand=CHBD

Execute the following commands 


 wget http://mirror.centos.org/centos/7/os/x86_64/Packages/liberation-fonts-1.07.2-16.el7.noarch.rpm

wget http://mirror.centos.org/centos/7/os/x86_64/Packages/liberation-fonts-1.07.2-16.el7.noarch.rpm

wget http://mirror.centos.org/altarch/7/os/aarch64/Packages/liberation-mono-fonts-1.07.2-16.el7.noarch.rpm

wget http://mirror.centos.org/centos/7/os/x86_64/Packages/liberation-fonts-common-1.07.2-16.el7.noarch.rpm

wget http://mirror.centos.org/centos/7/os/x86_64/Packages/liberation-mono-fonts-1.07.2-16.el7.noarch.rpm

wget http://mirror.centos.org/centos/7/os/x86_64/Packages/liberation-narrow-fonts-1.07.2-16.el7.noarch.rpm

wget http://mirror.centos.org/centos/7/os/x86_64/Packages/liberation-sans-fonts-1.07.2-16.el7.noarch.rpm

wget http://mirror.centos.org/centos/7/os/x86_64/Packages/liberation-serif-fonts-1.07.2-16.el7.noarch.rpm

yum install liberation* google-chrome*

Friday 1 May 2020

Optical telescope - All you need to know

The latest one technology-wise -

 The last three-mirror anastigmat [LTA]

three-mirror anastigmat is an anastigmat telescope built with three curved mirrors, enabling it to minimize all three main optical aberrations – spherical aberrationcoma, and astigmatism. This is primarily used to enable wide fields of view, much larger than possible with telescopes with just one or two curved surfaces.
A telescope with only one curved mirror, such as a Newtonian telescope, will always have aberrations. If the mirror is spherical, it will suffer from spherical aberration. If the mirror is made parabolic, to correct the spherical aberration, then it must necessarily suffer from coma and off-axis astigmatism. With two curved mirrors, such as the Ritchey–Chrétien telescope, coma can be eliminated as well. This allows a larger useful field of view, and the remaining astigmatism is symmetrical around the distorted objects, allowing astrometry across the wide field of view. However, the astigmatism can be cancelled by including a third curved optical element. When this element is a mirror, the result is a three-mirror anastigmat. In practice, the design may also include any number of flat fold mirrors, used to bend the optical path into more convenient configurations.

Three-mirror anastigmat of Paul or Paul-Baker form. A Paul design has a parabolic primary with spherical secondary and tertiary mirrors; A Paul-Baker design modifies the secondary slightly to achieve a flat focal plane.


The latest one was followed by RC telescope 

Ritchey–Chrétien telescope


Ritchey-Chrétien telescope (RCT or simply RC) is a specialized variant of the Cassegrain telescope that has a hyperbolic primary mirror and a hyperbolic secondary mirror designed to eliminate off-axis optical errors (coma). The RCT has a wider field of view free of optical errors compared to a more traditional reflecting telescope configuration. Since the mid 20th century, a majority of large professional research telescopes have been Ritchey-Chrétien configurations; some well-known examples are the Hubble Space Telescope, the Keck telescopes and the ESO Very Large Telescope.

A George Ritchey's 24-inch (0.6 m) reflecting telescope, the first RCT to be built, later on, display at the Chabot Space and Science Center in 2004.

The RC telescope was followed by 

Cassegrain reflector


The Cassegrain reflector is a combination of a primary concave mirror and a secondary convex mirror, often used in optical telescopes and radio antennas, the main characteristic being that the optical path folds back onto itself, relative to the optical system's primary mirror entrance aperture. This design puts the focal point at a convenient location behind the primary mirror and the convex secondary adds a telephoto effect creating a much longer focal length in a mechanically short system.[1]
In a symmetrical Cassegrain both mirrors are aligned about the optical axis, and the primary mirror usually contains a hole in the centre, thus permitting the light to reach an eyepiece, a camera, or an image sensor. Alternatively, as in many radio telescopes, the final focus may be in front of the primary. In an asymmetrical Cassegrain, the mirror(s) may be tilted to avoid obscuration of the primary or to avoid the need for a hole in the primary mirror (or both).
The classic Cassegrain configuration uses a parabolic reflector as the primary while the secondary mirror is hyperbolic.[2] Modern variants may have a hyperbolic primary for increased performance (for example, the Ritchey–Chrétien design); and either or both mirrors may be spherical or elliptical for ease of manufacturing.
The Cassegrain reflector is named after a published reflecting telescope design that appeared in the April 25, 1672 Journal des sçavans which has been attributed to Laurent Cassegrain.[3] Similar designs using convex secondaries have been found in the Bonaventura Cavalieri's 1632 writings describing burning mirrors[4][5] and Marin Mersenne's 1636 writings describing telescope designs.[6] James Gregory's 1662 attempts to create a reflecting telescope included a Cassegrain configuration, judging by a convex secondary mirror found among his experiments.[7]
Light path in a Cassegrain reflecting telescope

The major difference between all three generation of telescope is error correction 

Mainly, errors are consisting of different type of abberation i.e.  Astigmatism(Spherical, parabolic, etc.), Coma, etc.
We will see type of error as well, here.

Spherical aberration

Spherical aberration is a type of aberration found in optical systems that use elements with spherical surfaces. Lenses and curved mirrors are most often made with surfaces that are spherical, because this shape is easier to form than non-spherical curved surfaces. Light rays that strike a spherical surface off-centre are refracted or reflected more or less than those that strike close to the centre. This deviation reduces the quality of images produced by optical systems.
Out-of-focus image of a spoke target..svg Defocus
Hyperion Telescopes

GSAT-29, Indian satellite launched in December 2018, is consisting of imaging payload which is known as GHRC- GEO High-resolution camera, is using RC type telescope for imaging.





Source: 
Wikipedia

Monday 3 February 2020

Programmin challenge : 1

1. Two Sum
Easy
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,

Because nums[0] + nums[1] = 2 + 7 = 9,
return [0, 1].
Solution :

Approach 1: Brute Force

The brute force approach is simple. Loop through each element x and find if there is another value that equals to target - x.
Complexity Analysis
  • Time complexity : O(n^2). For each element, we try to find its complement by looping through the rest of array which takes O(n) time. Therefore, the time complexity is O(n^2).
  • Space complexity : O(1).

Approach 2: Two-pass Hash Table

To improve our run time complexity, we need a more efficient way to check if the complement exists in the array. If the complement exists, we need to look up its index. What is the best way to maintain a mapping of each element in the array to its index? A hash table.
We reduce the look up time from O(n) to O(1) by trading space for speed. A hash table is built exactly for this purpose, it supports fast look up in near constant time. I say "near" because if a collision occurred, a look up could degenerate to O(n) time. But look up in hash table should be amortized O(1) time as long as the hash function was chosen carefully.
A simple implementation uses two iterations. In the first iteration, we add each element's value and its index to the table. Then, in the second iteration we check if each element's complement (target - nums[i]) exists in the table. Beware that the complement must not be nums[i] itself!
Complexity Analysis:
  • Time complexity : O(n). We traverse the list containing n elements exactly twice. Since the hash table reduces the look up time to O(1), the time complexity is O(n).
  • Space complexity : O(n). The extra space required depends on the number of items stored in the hash table, which stores exactly n elements.

Approach 3: One-pass Hash Table

It turns out we can do it in one-pass. While we iterate and inserting elements into the table, we also look back to check if current element's complement already exists in the table. If it exists, we have found a solution and return immediately.
Complexity Analysis:
  • Time complexity : O(n). We traverse the list containing n elements only once. Each look up in the table costs only O(1) time.
  • Space complexity : O(n). The extra space required depends on the number of items stored in the hash table, which stores at most n elements.

Friday 3 January 2020

What is C++ standard template library ?






When you want to start competitive coding, one cannot go on writing each and every commonly used function scratch, rather smart idea is to use a library which includes standard functions.
One of such library is string.h  where one can find many useful string related operations.
Similarly, standard template library contains

  • Standard data structure, such as list, stack, queue , linked list etc 
  • Standard sorting algorithms 
  • Standard searching algorithms etc 
Reference Link:

Friday 15 November 2019

How to host secure/non-secure Static Website on S3 using Terraform

Most of us know how AWS is growing and with it's growth, It is making developer's lives easier to develop and deploy live applications. Most of us definitely have a use case where we want to deploy a static website for product marketing or maybe for personal profile showcase or maybe because of client's requirement

AWS S3 provides a feature to host static websites (by static it means content is never dynamic) on S3 buckets and gives you an endpoint through which you can access the website. However, we need to consider the fact that we cannot make the site secure(with ssl, which is certainly a corner case because making a static site secure doesn't make sense to me at least) directly but indirectly it is definitely possible. This is where CloudFront comes into the picture and turns the table around for some developers because configuring the cloud front adds a bit of complexity.

Additionally, What if you have a case where you need to host multiple website. You need to go through the entire process multiple times.

  • Making an S3 bucket
  • Uploading files to the bucket
  • Configuring the static website
  • Configuring cloud front
  • Create a Domain name and map it to the CloudFront domain and create a record set. fuhhh 😓 -->You can skip this step if you don't want your site to be secured on SSL.
If you are going through the same feeling let's automate it with a tool called "Terraform".

main.tf

provider "aws"{
region = "us-east-1"
}
resource "aws_s3_bucket" "website_bucket" {
  bucket = "${var.name_domain}.${var.root_domain}"
  acl    = "private"
  website {
    index_document = "index.html"
    error_document = "error.html"
  }
  tags = {
    Name        = "${var.Customer}"
    Environment = "${var.Environment}"
  }
region = "us-east-1"
}
data "aws_s3_bucket" "get_s3_zone" {
  bucket = "${var.name_domain}.${var.root_domain}"
  depends_on = ["aws_s3_bucket.website_bucket"]
}
data "aws_route53_zone" "getZone" {
  count = "${var.hostedZone == "yes" ? 1 : 0}"
  name         = "${var.root_domain}"
  private_zone = false
}
resource "aws_route53_zone" "website_zone" {
  count = "${var.hostedZone == "yes" ? 0 : 1}"
  name = "${var.root_domain}"
    tags = {
    Name        = "${var.Customer}"
    Environment = "${var.Environment}"
  }
}
data "aws_acm_certificate" "fetch_certificate_arn" {
  domain   = "${var.certificate}"
  statuses = ["ISSUED"]
  most_recent = true
}
resource "aws_cloudfront_distribution" "website_cloudfront" {
  origin {
    domain_name = "${aws_s3_bucket.website_bucket.website_endpoint}"
    origin_id = "${var.Customer}_S3_origin"
    custom_origin_config {
        origin_protocol_policy = "http-only"
        https_port = 443
        http_port = 80
        origin_ssl_protocols = ["TLSv1", "SSLv3"]
        }   
 }
  enabled = true
  aliases = ["${var.name_domain}.${var.root_domain}"]
  price_class = "PriceClass_200"
  retain_on_delete = true
  default_cache_behavior {
    allowed_methods = [ "GET", "HEAD"]
    cached_methods = [ "GET", "HEAD" ]
    target_origin_id = "${var.Customer}_S3_origin"
    forwarded_values {
      query_string = false
      cookies {
        forward = "none"
      }
    }
    viewer_protocol_policy = "redirect-to-https"
    min_ttl = 0
    default_ttl = 3600
    max_ttl = 86400
  }
  viewer_certificate {
    acm_certificate_arn = "${data.aws_acm_certificate.fetch_certificate_arn.arn}"
    ssl_support_method = "sni-only"
    minimum_protocol_version = "TLSv1.1_2016"
  }
  restrictions {
    geo_restriction {
      restriction_type = "none"
    }
  }
depends_on = ["aws_s3_bucket.website_bucket"]
}
resource "aws_route53_record" "www"{
 zone_id = "${var.hostedZone == "no" ? join("", aws_route53_zone.website_zone.*.zone_id) : join ("",data.aws_route53_zone.getZone.*.zone_id)}"
  name    = "${var.name_domain}.${var.root_domain}"
  type    = "A"
  alias {
    name                   = "${aws_cloudfront_distribution.website_cloudfront.domain_name}"
    zone_id                = "${aws_cloudfront_distribution.website_cloudfront.hosted_zone_id}"
    evaluate_target_health = "false"
  }
depends_on = [aws_route53_zone.website_zone]
}
output "website_endpoint" {
value = aws_s3_bucket.website_bucket.website_endpoint
}

inputs.tf

variable "hostedZone"{
description = "'yes': if 'PUBLIC' hosted zone for the root domain is present , else 'no' NOTE: Make sure the hosted zone is public and not private. If the hosted zone is present but is private enter 'no'"
}
variable "root_domain"{
description = "Root domain of the website eg. If Website is xyz.example.com, root_domain is example.com"
}
variable "name_domain"{
description = "If Website is xyz.example.com, name_domain is xyz"
}
variable "Customer"{
description = "Name of the customer"
}
variable "Environment"{
description = "Customer's Environment"
}
variable "certificate"{
description = "Enter the certificate to use eg. if you have the root domain as example.com enter '*.example.com' to use wildcard cert else enter whole domain of the website to use a custom cert"
}

terraform.tfvars

Customer = "Quicktrixx"
Environment = "prod"
root_domain  = "" #example: quicktrixx.com or quicktrixx.qa
name_domain = "" #example:example, So if your whole domain is hello.example.com enter 'hello' in the name domain and 'example.com' in root domain


If you are facing any issues let me know in the comments section.

Regards,
Quicktrixx👻

How to install google-chrome in redhat without redhat subscription

Install google-chrome in redhat  Download the .rpm file of chrome https://www.google.com/chrome/thank-you.html?installdataindex=empty&st...