Skip to content

Instantly share code, notes, and snippets.

View dipanshuchaubey's full-sized avatar
:octocat:

Dipanshu Chaubey dipanshuchaubey

:octocat:
View GitHub Profile
@dipanshuchaubey
dipanshuchaubey / alias_imports_nextjs.md
Created July 18, 2022 08:11
How to add alias in `Next.js` imports

Add Alias in Next.js Imports

Update your tsconfig.json or jsconfig.json

"compilerOptions": {
  ...
  "baseUrl": ".",
  "paths": {
 "@alias": ["components"],
@dipanshuchaubey
dipanshuchaubey / consumer.js
Created May 2, 2022 13:06
RabbitMQ Pub-Sub
const amqp = require('amqplib')
const connect = async () => {
try {
const connection = await amqp.connect('amqp://localhost:5672')
const channel = await connection.createChannel()
const result = await channel.assertQueue('jobs')
channel.consume('jobs', (message) => {
@dipanshuchaubey
dipanshuchaubey / fail2ban.md
Created February 7, 2022 11:42
Installing Fail2Ban on Debian Systems

Installing fail2ban on Debian Based Systems

Fail2Ban prevents linux server from brute force ssh attacks. It bans the IP Address from where multiple failed login attemps are made withing short duration of time.

How does it work

fail2ban reads /var/log/auth.log file to gether all the IP Addresses which have made failed login attemps to the server. Based on this data fail2ban creates a ban list.

Adding New Network Interface in Ubuntu

1. Check if the network adapter is connected

$ ifconfig -a
ens00: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.1  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::20c:29ff:feb8:214e  prefixlen 64  scopeid 0x20<link>

ens01: flags=4163 mtu 1500
@dipanshuchaubey
dipanshuchaubey / mysql_remote_access.md
Created July 16, 2021 17:59
Allow Remote Access to MySQL

Allow Remote Access to MySQL

Edit Configurations

First thing that needs to be done is to allow connections from all hosts to MySQL. mysqld.cnf file needs to updated as follows.

$ sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
/**
* This script will traverse your filesystem and convert all
* Images to desired format.
*
* REQUIRED PARAMETERS
* 1. Source directory path.
* (This is the path from where images will be converted)
* 2. Output format. 'default = .jpg'
**/
@dipanshuchaubey
dipanshuchaubey / github_webhooks.js
Last active May 18, 2021 17:06
How to setup Github Webhooks using Node.js
const crypto = require('crypto')
const express = require('express')
const bodyParser = require('body-parser')
const app = express()
// To include rawBody in req parameter
app.use(bodyParser.json({
verify: (req, res, buf) => {
req.rawBody = buf

INSTALL DOCKER CE ON LINUX

Install Prerequisite Packages (optional)

$ sudo apt install apt-transport-https ca-certificates curl software-properties-common

Add Docker GPG Key

@dipanshuchaubey
dipanshuchaubey / reverse_proxy.md
Created March 5, 2020 14:50
Nginx Reverse Proxy

Nginx Reverse Proxy

Unlink default configs

First, unlink the default configuration which shows Nginx Welcome page on port 80 using the command

path /etc/nginx/sites-enabled

$ sudo unlink default
@dipanshuchaubey
dipanshuchaubey / phpMyAdmin_on_custom_port.md
Created February 3, 2020 16:34
Run phpMyAdmin on a custom port

Run phpMyAdmin On Custom Port

1. Make a virtual host for phpmyadmin

In /etc/apache2/sites-available/ directory create a new file named phpmyadmin.conf

$ sudo nano phpmyadmin.conf