Skip to content

Instantly share code, notes, and snippets.

View farhad0085's full-sized avatar
🏠
Working from home

Farhad Hossain farhad0085

🏠
Working from home
  • Varsity Gate, Akhalia, Sylhet Sadar, Sylhet, Bangladesh
View GitHub Profile
@farhad0085
farhad0085 / Setup Replication in PostgreSQL.md
Last active November 4, 2025 09:43
Setting up PostgreSQL streaming replication on Ubuntu

This guide walks you through setting up PostgreSQL streaming replication on Ubuntu 22.04, either on a single machine (for testing) or across two separate servers (for production). By following this tutorial, you will:

  • Understand how primary and replica databases interact.
  • Set up a replication user and configure WAL streaming.
  • Verify that the replica automatically receives updates from the primary.
  • Test read/write behavior and monitor replication lag in real time.

After completing this guide, the replica database will be read-only and asynchronously follow the primary. Any inserts, updates, or deletes on the primary will appear on the replica within seconds.

Key Concepts & FAQs

@farhad0085
farhad0085 / Setup PgBouncer in GCP Ubuntu for Scaling Your Django App.md
Last active October 19, 2025 16:23
Setup PgBouncer in GCP Ubuntu for Scaling Your Django App

Setup PgBouncer in GCP Ubuntu for Scaling Your Django App

Presumptions

You've a server of following configuration

  1. 16GB RAM
  2. 12vCPU
  3. Ubuntu >= 20.04
  4. Knowledge of nano editor

Step 1: Installing PgBouncer

@farhad0085
farhad0085 / Disable default Sorting and Groupby.md
Last active February 28, 2025 06:50
Disable default Sorting and Groupby in windows explorer

Run the following in powershell.

# This script will remove grouping from all possible views of the Downloads folder. 
# The change is applied to the current user's profile only. 
# Warning: ALL folder views (except Downloads grouping) will revert to Windows defaults! 
# This is a minimal solution. To set ALL default folder views, use the free tool WinSetView. 
 
$RegExe = "$env:SystemRoot\System32\Reg.exe" 
$File = "$env:Temp\Temp.reg" 
@farhad0085
farhad0085 / Merge two Git repositories.md
Created August 30, 2024 19:57
Merge two Git repositories

If you want to merge branch branchX from projectA into projectB:

cd path/to/projectA
git checkout branchX
cd path/to/projectB
git remote add projectA /path/to/projectA
@farhad0085
farhad0085 / Tailwind with Django.md
Created April 19, 2024 08:02
Tailwind with Django

Setup TailwindCSS

  1. Install tailwindcss via npm, and create your tailwind.config.js file.

    npm install -D tailwindcss
    npx tailwindcss init
  2. Add the paths to all of your template files in your tailwind.config.js file.

    /** @type {import('tailwindcss').Config} */
@farhad0085
farhad0085 / download file from google drive.md
Last active February 22, 2024 17:38
download file from google drive

download file from google drive

In this tutorial we're gonna use gdown to download file from google drive. Consider visiting that page for full instructions; this is just a summary and the source repo may have more up-to-date instructions.

Instructions

  1. Install it with the following command:

    pip install gdown
@farhad0085
farhad0085 / Resetting github access token when it expires.md
Created January 2, 2024 13:19
Resetting github access token when it expires

Run these commands in your terminal.

Make sure you replace tokenXYZ with your actual token.

sudo git remote remove origin
sudo git remote add origin https://tokenXYZ@github.com/Assiduus-Global/Assiduus-Dashboard-BE.git
sudo git pull
sudo git branch --set-upstream-to=origin/master
@farhad0085
farhad0085 / Automate postgresql database backup to google drive.md
Created August 16, 2023 07:37
Automate postgresql database backup to google drive

Automate postgresql database backup to google drive

  1. Install and setup google-drive-upload

    To install google-drive-upload in your system, you can run the below command:

    curl --compressed -Ls https://github.com/labbots/google-drive-upload/raw/master/install.sh | sh -s
    

For more information on installation and setup, please follow this: https://labbots.github.io/google-drive-upload/setup/install/

@farhad0085
farhad0085 / Python Decorator for Function Result Caching.md
Last active August 1, 2023 20:28
Python Decorator for Function Result Caching

Python Decorator for Function Result Caching

# Import necessary modules
import time
import hashlib

# Function to add any number of arguments and simulate a long computation time
def add(*x):
    time.sleep(5)  # Simulate a delay of 5 seconds (Long computation time)

SSH to server

generate ssh key

Run following command in your terminal (for windows, use git bash)

ssh-keygen -o

Enter a path to save the ssh key