Skip to content

Instantly share code, notes, and snippets.

View nurmdrafi's full-sized avatar
:octocat:
Focusing

Nur Mohamod Rafi nurmdrafi

:octocat:
Focusing
View GitHub Profile
@nurmdrafi
nurmdrafi / NextJS Content Security Policy.md
Last active April 22, 2024 11:19
NextJS Content Security Policy
@nurmdrafi
nurmdrafi / swapfile.md
Created April 9, 2024 06:19
Create, Resize, or Extend a Linux Swap File
# check memory
$ free

# check swap file location, (default location - '/')
$ swapon

# turn off swap using swapfile location
$ sudo swapoff /swapfile
@nurmdrafi
nurmdrafi / Github Actions Workflow Example.md
Last active April 22, 2024 11:06
Github Actions Workflow Example

NextJS Deploy with Docker

name: Docker Image CI/CD for Staging

on:
  push:
    branches: ["staging"]

env: 
  DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
@nurmdrafi
nurmdrafi / npm config.md
Last active December 15, 2023 13:44
npm config for slow internet issue

Metrics

npm config for slow internet issue

# list of npm config
npm config ls -l

# faster download
npm install --prefer-offline --no-audit --progress=false

# extend timelimit
@nurmdrafi
nurmdrafi / Optimized Dockerfile For Next.js.md
Last active September 4, 2024 06:18
Optimized Dockerfile For Next.js

Using ubuntu base image + NVM (secure)

# Stage 1: Setup Node.js with NVM ===>
FROM ubuntu:24.10 AS base

# Set working directory
WORKDIR /app

# Install dependencies
RUN apt-get update && \
@nurmdrafi
nurmdrafi / Next.js Project Setup with ESLint, TypeScript, AirBnb, Conventional Commit, Lint Staged and Husky.md
Last active March 1, 2025 12:27
Next.js Project Setup with ESLint, TypeScript, AirBnb, Conventional Commit, Lint Staged and Husky

[https://www.npmjs.com/package/@commitlint/config-conventional]

Install

npm i --save-dev eslint-config-airbnb eslint-config-airbnb-typescript eslint-config-next @typescript-eslint/eslint-plugin@latest @typescript-eslint/parser@latest @commitlint/config-conventional @commitlint/cli husky

// init husky
npx husky init

Skip Git commit hooks

@nurmdrafi
nurmdrafi / Authentication with Redux, Next.js + TypeScript.md
Last active March 12, 2025 01:14
Authentication with Redux, Next.js + TypeScript

store.ts

import { configureStore } from '@reduxjs/toolkit'
import type { TypedUseSelectorHook } from 'react-redux'
import { useDispatch, useSelector } from 'react-redux'

// Import Reducers
import authReducer from './reducers/authReducer'

const store = configureStore({

modalReducers.js

import { createSlice } from "@reduxjs/toolkit";

const initialState = {
  isModalOpen: false,
  currentModal: ''
};

const modalSlice = createSlice({