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 / dockerize_react_app.md
Last active May 27, 2025 08:01
Dockerizing React Apps with Dynamic Environment Variables

Dockerizing React Apps with Dynamic Environment Variables

Introduction

When deploying React applications in different environments (development, QA, staging, production), managing environment variables becomes crucial. Unlike server-side applications where environment variables can be injected at runtime, React applications are built into static files where environment variables are embedded during the build process.

This guide demonstrates how to create a Docker setup for React applications that allows dynamic environment variable injection at container runtime rather than build time.

Implementation Overview

@nurmdrafi
nurmdrafi / infisical_docker.md
Last active May 25, 2025 19:56
Infisical Integration with Docker

Infisical Integration with Docker

This guide explains how to integrate Infisical, a secrets management platform, with a Dockerized application to securely fetch and inject secrets at runtime. It covers setting up the Infisical CLI, configuring environment variables, retrieving credentials, and integrating with Docker.

Prerequisites

Setup Instructions

@nurmdrafi
nurmdrafi / cursor.md
Created April 9, 2025 14:59
Install Cursor AI editor on Ubuntu 24.04

Install Cursor AI editor on Ubuntu 24.04

  1. Use the Download button on www.cursor.com web site. It will download the NAME.AppImage file.

  2. Move the File:

sudo mv ~/Downloads/NAME.AppImage /opt/cursor.appimage
@nurmdrafi
nurmdrafi / secure-localstorage.md
Last active April 7, 2025 04:29
Building a Secure LocalStorage Utility with crypto-js

Building a Secure LocalStorage Utility with crypto-js

Browser's LocalStorage is convenient but stores data in plaintext, creating security risks. Let's build a TypeScript utility that adds encryption using crypto-js to better protect client-side data.

The Problem with Default LocalStorage

LocalStorage has three key security issues:

  • Stores everything as plaintext
  • Vulnerable to XSS attacks
  • No built-in expiration mechanism
@nurmdrafi
nurmdrafi / prompts.md
Last active March 26, 2025 20:19
Unit Test Prompts

Vitest setup

MOCK SETUP CONFIGURATION WORKFLOW

PHASE 1: PROJECT STRUCTURE ANALYSIS
1. Redux: Located in redux/, with feature-specific logic in redux/features/
2. API Responses: Used in pages/ and hooks/
3. LocalStorage/SecureLocalStorage: Used in utils/ or directly in components
4. Tests: Stored in __tests__/ with mocks designed for testing
@nurmdrafi
nurmdrafi / test-coverage.md
Created March 5, 2025 07:42
Test Coverage Integration with SonarQube and GitHub Actions

Test Coverage Integration with SonarQube and GitHub Actions

This document outlines the steps taken to integrate test coverage reporting into SonarQube using GitHub Actions for the Laboni Express project.

Overview

The goal was to ensure that test coverage data (generated by Vitest) is correctly reported to SonarQube during the CI/CD pipeline. This involved:

  1. Generating test coverage files in GitHub Actions.
  2. Configuring Vitest to generate coverage files.
@nurmdrafi
nurmdrafi / template.md
Created March 3, 2025 15:45
Folder Structure
src/
├── app/                          # Next.js app router
│   ├── (marketing)/              # Public pages (e.g., home, about)
│   ├── (shop)/                   # Shop-related pages
│   ├── (product)/                # Product-related pages
│   ├── (admin)/                  # Admin-related pages
│   ├── layout.tsx                # Root layout
│   └── page.tsx                  # Home page
├── components/                   # Reusable components
@nurmdrafi
nurmdrafi / template.md
Last active January 26, 2025 15:14
Frontend Documentation Template

[Project Title]

1. Project Overview

Description

Insert a brief and concise description of the project. For example: "A web application for [briefly state the main purpose, e.g., tracking expenses, managing tasks, creating a portfolio]."

Purpose