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 / MapGL Snippet.md
Created January 25, 2023 17:11
MapGL Snippet

Index

import React, { useState } from 'react';
import {Form, Row, Col, Input, Button, Switch, } from 'antd'
const { TextArea } = Input;
const DynamicCheckbox = () => {

    // States
    const [form] = Form.useForm()
    const [selectedBox, setSelectedBox] = useState(null)
    const PaymentInfo = Form.useWatch('payment_information', form);

usePagination.js

export const usePagination = ({
  totalCount,
  pageSize,
  siblingCount = 1,
  currentPage
}) => {
  const paginationRange = useMemo(() => {
    const totalPageCount = Math.ceil(totalCount / pageSize);

modalReducers.js

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

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

const modalSlice = createSlice({
@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({
@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 / 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 / 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