Skip to content

Instantly share code, notes, and snippets.

View adarsh-chakraborty's full-sized avatar
💻
I'm probably learning something right now. wbu?

Adarsh Chakraborty adarsh-chakraborty

💻
I'm probably learning something right now. wbu?
  • Bilaspur, Chhattisgarh.
  • 07:12 (UTC +05:30)
  • X @adarshgq
View GitHub Profile
@adarsh-chakraborty
adarsh-chakraborty / Enforce HTTPS.md
Created May 14, 2022 18:02
Force all traffic to use HTTPS protocol using .htaccess file

How to force all traffic to HTTPS using .htaccess

Probably the most common way to force traffic to https is by redirecting requests using .htaccess. The .htaccess is a simple text file simply called ‘.htaccess’ which contains additional settings passed to the web server to support some more complicated functionality. If you are using a script created by other people (including CMS like Wordpress), you can probably find a .htaccess file already in the htdocs folder of your website. If you don’t have a .htaccess file yet, you can create a file using the File Manager with the file name .htaccess. Using the File Manager is recommended, some systems (especially Windows) don’t work well with .htaccess files.

After you’ve found or created your .htaccess file, you can edit it in the File Manager or using any text editor (like Notepad). You need to add the following lines to the file:

RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
@adarsh-chakraborty
adarsh-chakraborty / Commig Signing GPG.md
Created April 22, 2022 14:46
Make verified commits on github.

Get your commits verified on github!

Step 1: Check if gpg installed

gpg --version

Step 2: Generate a key

gpg --full-gen-key

To view a Pull request locally on your machine,

git fetch origin pull/##/head:temp_PR

Here,

  • origin is the name of the remote to fetch pull from.
  • ## should be replaced with the Pull Request Id.
  • temp_PR is the name of the branch that will be created for this PR on your machine.
@adarsh-chakraborty
adarsh-chakraborty / colors.js.md
Created January 1, 2022 18:14
Add Colors to your console!

Install the npm package

npm i colors

Use colors in your project:

  • Import color js package
@adarsh-chakraborty
adarsh-chakraborty / Run servers Concurrently.md
Created January 1, 2022 08:32
Start Front-End and Back-end Server Concurrnetly.

Running both Client & Backend server concurrently

Often we have to open 2 terminals, one for front-end and another for back-end while development, It's cumbersome to keep managing both the servers, if one server stops the other one keeps running for no reason.

We can make use of a cli-tool called concurrently available on npm. As the name implies it enables us to run multiple Instances of servers on one terminal and we can start and stop all the servers at same time with just one command.

Let's see how to set it up for our project.

Install

@adarsh-chakraborty
adarsh-chakraborty / clear npx cache.md
Created December 25, 2021 14:11
Clear npx cache using this command.

To clear npx cache

npx clear-npx-cache

It might fix all the errors related to npx you can face, ex. you are installing an old version of react using CRA etc.

@adarsh-chakraborty
adarsh-chakraborty / MySQL Login CMD.md
Created December 23, 2021 15:30
Command to login to local MySQL server.

To login to local mySQL server as root, type the following command

mysql -u root -p

then, It would ask for password, enter the password and login.

To login to a different account,

@adarsh-chakraborty
adarsh-chakraborty / promise_all.js
Created December 9, 2021 09:54
Fetch data with Promise concurrently
let fetchData = async () => {
const res = await fetch('https://bookshelf.gq/api/books');
const data = await res.json();
console.log('data is ready', data);
const res2 = await fetch('https://dikz.herokuapp.com/api/latest');
const data2 = await res2.json();
console.log('data2 is ready!', data2);
@adarsh-chakraborty
adarsh-chakraborty / spinner.css
Created December 9, 2021 05:34
Loading spinner in css
.spinner {
display: inline-block;
width: 80px;
height: 80px;
}
.spinner:after {
content: ' ';
display: block;
width: 64px;
height: 64px;
@adarsh-chakraborty
adarsh-chakraborty / email validation regex.md
Last active December 6, 2021 11:48
Regex for e-mail validation

Function to check if a string is valid email address

function isValidEmail(email) {
	if (!email) {
		return false;
	}
	const emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
	return emailPattern.test(email);
}