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 / shadcn.config.md
Last active November 14, 2024 11:17
typescript eslint config for shadcn UI

tsconfig.json

{
{
	"compilerOptions": {
		"target": "es2022",
		"lib": ["dom", "dom.iterable", "esnext"],
		"allowJs": true,
		"skipLibCheck": true,
@nurmdrafi
nurmdrafi / package.md
Last active February 18, 2025 19:48
How to Build and Publish NPM Package Using Rollup, Babel, TypeScript, ESLint, and Jest

🚀 How to Build and Publish NPM Package Using Rollup, Babel, TypeScript, ESLint, and Jest

1. Setup the Project

Create a new directory for your project and initialize it with npm:

mkdir my-package
cd my-package
npm init -y
@nurmdrafi
nurmdrafi / Update docker image tags with dynamic version.md
Last active July 9, 2024 11:15
Update docker image tags with dynamic version
name: Docker Image CI/CD for Staging

on:
  push:
    branches: ["staging"]

env: 
  DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
  DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
@nurmdrafi
nurmdrafi / secret.md
Created June 11, 2024 10:56
Hello Raju
@nurmdrafi
nurmdrafi / Socket.IO.md
Last active June 14, 2024 15:49
Socket.IO Handbook

https://shav.dev/blog/socket-io-and-redux-middleware

What is Socket.io?

Socket.IO is a Javascript lirary that enables real-time, bidirectional communication between web clients (browsers) and servers. It simplifies the process of bulding interactive web applications by allowing data to be transmitted instantly and continuously between the client and server, facilitating features like chat applications, live updates, and multiplayer gamimg.

What is Bidirectional Communication?

Bidirectional communication means that information can flow in two directions, both the web client(browser) and the server can send and receive data to and from each other in real-time. So if something changes on the server, it can immediately notify the client, and vice versa, without the client needing to constantly ask the server if there's new information available.

Analogy

Think of bidirectional communication like a phone call. When you're talking on the phone with someone, you can both speak and listen at the same t

@nurmdrafi
nurmdrafi / notification.md
Created May 4, 2024 16:33
Push Notification R&D

// Sending and receiving push messages

  1. if user grant notification permission, the user subscribes to the push service
  2. the push service returns a subscription object, which includes a public key to enable messages to be encrypted and an endpoint URL for the browser's push service, which is unique for each user
  3. send push messages from this URL from server, encrypted with the public key and the push service forward this message to the right client, device and browser
  4. service worker handle the push messages, when a push event is fired shows up message

// subscribe to the push service

navigator.serviceWorker.getRegistration().then(reg => {

@nurmdrafi
nurmdrafi / Render Customize Map Styles Using Hooks.md
Created April 29, 2024 05:58
Render Customize Map Styles Using Hooks

useCustomMapStyles.ts

import { useState, useEffect } from 'react'
import { MAP_API_ACCESS_TOKEN } from '../app.config'

const useCustomMapStyles = () => {
  // States
  const [mapStyles, setMapStyles] = useState<any>([])

  // On Load Fetch Map Styles
@nurmdrafi
nurmdrafi / Update software version with time using script.md
Created April 28, 2024 05:12
Update software version with time using script

add this update-version.js file inside utils folder

const fs = require('fs')
let packageJson = require('../package.json')

// Current Time
const now = new Date()
@nurmdrafi
nurmdrafi / Basic NGINX Config.md
Last active February 23, 2025 16:05
Basic NGINX Config

Create File

sudo nano /etc/nginx/sites-available/test

Basic Config

If project running on server using docker or pm2
server {
 listen 80;
@nurmdrafi
nurmdrafi / Building a Progressive Web App (PWA) in Next.js.md
Last active May 4, 2024 16:33
Building a Progressive Web App (PWA) in Next.js

Related Docs

Benefits of Progressive Web App (PWA)

  1. Offline Functionality: PWAs can operate seamlessly offline, providing users with uninterrupted access to content and functionality even in low or no connectivity environments. This is achieved through service workers, enabling cached content to be served when the network is unavailable.