Skip to content

Instantly share code, notes, and snippets.

View mhimanshu0101's full-sized avatar
🎯
Focusing

Martial Himanshu mhimanshu0101

🎯
Focusing
View GitHub Profile
@mhimanshu0101
mhimanshu0101 / dockerNotes.md
Last active January 29, 2022 13:03
List of help full docker command and its usage with short notes

Writing Dockerfile, docker-compose.yml and its application with nodeJs.

| Dockerfile

Dockerfile is set of some instruction which helps to create custom image which Docker is going to run. To create a Dockerfile, write below 7 mentioned commands in Dockerfile.

  1. Docker image of basic dependencies from docker-hub, here node@17 used to setup
    FROM node:17
  2. Working/project directory relative (or absolute) path inside container, will be created if it does not exist
    WORKDIR /app
  3. Will copy package.json to project directory, it can be "." or /app
@mhimanshu0101
mhimanshu0101 / SetupForSSH.md
Created January 29, 2022 12:59
Access AWS EC2 instance using SSH with .pem file

Access AWS EC2 SSH with your .pem file

For linux distribution

  1. Generate keygen for your local system
    ssh-keygen -t rsa -C '<email>'

  2. change permission of ssh key file to read only
    chmod 400 ~/.ssh/id_rsa

For WSL distribution

  1. Copy .pem file too .ssh directory
@mhimanshu0101
mhimanshu0101 / secureServerMachine.md
Last active January 30, 2022 20:09
Learn how to secure server machine to reduce unwanted attacks and follow best practices

Secure linux server machine to reduce unwanted attacks

This can be achieved by using different strategies for valid case, let see few of them as following:

  1. Restrict server users to a specific directory in Linux with limiting access protocol. Normally developer access their server machines using ssh connection, which is normally targeted by attacker bots. So limiting your users on server to access maching to only with sftp method, after which user can land into thier home page and then navigate to other folder with thier password to perform other tasks. Read blog for more details

  2. Use non-standard path to store your webserver file which is not easy to guess by any attacker bots or other attacker. Using non-standard path such as /MyData/WebSites/sitename01, /MyData/WebSites/sitename02 and so on can save you from various kind of vulnerability attacks that try to run or read some files using a re

@mhimanshu0101
mhimanshu0101 / htmlcheatsheet.md
Last active February 3, 2022 05:23
HTML cheat sheet which improved my html responsive elements development skills.

HTML Cheat sheet

  1. Basic HTML structure
<html>
 <head>
  <title>Title</title>
 </head>
 <body>
  Content (Hello World!)
 
@mhimanshu0101
mhimanshu0101 / gitpull.md
Last active February 9, 2022 20:19
Internal working of git pull and fasten up the process

Why cloning a new Git repo is so slow?

If you are cloning a 100MB repo, it will take around 5-10min to clone the repo even at 100MB/sec.

To understand why, we need to take a look at how git stores file changes and how it fetches repo over the network.

Git stores snapshot of each files you have changed in each commit.

Suppose your repo has 2,000 commits and 20 files changed in each commit then there will be 40,000 snapshots (+ number of files in repo).

@mhimanshu0101
mhimanshu0101 / asyncPython.md
Last active February 18, 2022 05:24
Performance testing of Python code using cProfile library with sankeviz to generate report as webpage
import httpx
import asyncio

async def count_https_in_web_pages():
  with open('towebsite.txt', 'r', encoding='utf-8') as f:
    urls = [line.strip() for line in f.readlines()]
    
  async with httpx.AsyncClient() as client:
 tasks = (client.get(url) for url in urls)
@mhimanshu0101
mhimanshu0101 / securingRequest.md
Created March 7, 2022 07:24
Securing Request response with security implementation - Use of Tokens

Steps to be followed to implement security in request - response cycle

  • Instead of doing encription and then decription in your frontend side. You can handle it by your backend

  • Simple and secure way is like you just need to pass username and password from your front end.

  • Then check both vaule are not empty.if you get any field empty then return error 402 with error message

@mhimanshu0101
mhimanshu0101 / ElementRevealer.md
Created April 21, 2022 10:01
Frontend element revealer by adding `Red` border

Reveal UI html and CSS elements of your website

To do this, open console of browser and run following code

document.head.insertAdjacentHTML("beforeend", "<style>* { outline: 1px solid red; }</style>");