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 / 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://[email protected]/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

@farhad0085
farhad0085 / postgresql scaling - master-slave replication.md
Last active August 20, 2024 17:33
Set up master-slave replication in PostgreSQL, including all the necessary configuration files and settings.

Set up master-slave replication in PostgreSQL, including all the necessary configuration files and settings.

Assuming that you already have two servers with PostgreSQL installed, one of which will be designated as the master and the other as the slave, here are the steps to set up master-slave replication:

On the master server:

  1. Open the postgresql.conf file (usually located in /etc/postgresql/<version>/main/) and modify the following settings:
listen_addresses = '*'
@farhad0085
farhad0085 / How to dump and restore database in postgresql.md
Last active May 25, 2023 17:52
Postgresql database dump and restore

Dump Your PostgreSQL Database

Login to your server and run this command. This will dump your database in compressed format in current directory.

pg_dump database_name -U db_username -h localhost -F c > db_dump_compressed.sql

It will ask you for db_username's password. After taking some time, it'll save the db dump in a file called db_dump_compressed.sql

If you don't want it to be compressed, just remove -F c from the above command.