Skip to content

Instantly share code, notes, and snippets.

View truongluu's full-sized avatar
🏠
Working from home

Lưu Xuân Trường truongluu

🏠
Working from home
View GitHub Profile
@truongluu
truongluu / docker-compose.nextjs.yml
Created December 21, 2025 13:37
Docker compose NextJS
services:
app:
build:
context: .
dockerfile: Dockerfile
args:
- NEXT_PUBLIC_APP_URL=${NEXT_PUBLIC_APP_URL:-http://localhost:3000}
container_name: ranking-sys-app
ports:
- "3000:3000"
@truongluu
truongluu / Dockerfile
Created December 21, 2025 13:36
Dockerfile NextJS
# Stage 1: Dependencies
FROM node:20-alpine AS deps
RUN apk add --no-cache libc6-compat openssl
WORKDIR /app
# Install pnpm
RUN corepack enable && corepack prepare pnpm@9 --activate
# Copy package files
COPY package.json pnpm-lock.yaml ./
@truongluu
truongluu / Calendar.php
Created August 28, 2025 04:15 — forked from yelocode/Calendar.php
Full Calendar JS Livewire example
<?php
namespace App\Livewire;
use App\Models\Event;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Validator;
use Livewire\Attributes\Rule;
use Livewire\Component;
@truongluu
truongluu / Laravel Alpine JS Modal
Created August 27, 2025 12:19 — forked from MatinMN/Laravel Alpine JS Modal
Laravel Modal Component
// open modal from livewire component
$this->dispatch('open-modal', name: 'user-details');
// close modal
$this->dispatch('close-modal');
@truongluu
truongluu / file-reader-inversity.ts
Created December 26, 2024 08:50
Example Using Inversityjs lib
import { Container, inject, injectable, named } from "inversify";
import { readFile } from "node:fs/promises";
import * as path from "node:path";
interface IParser<T = string> {
parse(data: string): T;
}
@injectable()
class JsonParser implements IParser<JSONType> {
@truongluu
truongluu / memory-router-testing.ts
Created November 2, 2024 06:27
Memory Router Testing
// src/test/test-utils.tsx
import { render } from '@testing-library/react'
import { MemoryRouter, Routes, Route } from 'react-router-dom'
// Enhanced render utility that accepts route configuration
interface RenderWithRouterOptions {
route?: string
initialEntries?: string[]
initialIndex?: number
}
@truongluu
truongluu / mock-csv.test.ts
Last active September 23, 2024 13:55
Mock CSV file in Vitest
import { vi, describe, test, expect } from 'vitest';
// Mock CSV content
const mockCSVContent = `id,name,age
1,John Doe,30
2,Jane Smith,25
3,Bob Johnson,45`;
describe('CSV File Object Creation', () => {
test('creates a File object with CSV content', () => {
@truongluu
truongluu / usePostsStore.test.ts
Created July 24, 2024 09:45 — forked from mustafadalga/usePostsStore.test.ts
Writing unit tests of zustand state management store with vitest and testing-library
import { act, renderHook } from '@testing-library/react';
import { describe, it, expect, beforeEach } from "vitest";
import { usePostsStore } from "@/_store/usePostsStore";
describe('usePostsStore', () => {
beforeEach(() => {
usePostsStore.getState().reset()
});
it('should return the initial state', () => {
@truongluu
truongluu / App.test.ts
Created July 23, 2024 02:31 — forked from mustafadalga/App.test.ts
Mocking localstorage in vitest
import { createStore, Store } from 'vuex';
import { afterAll, beforeAll, describe, expect, it } from "vitest";
import { key, store } from "@/store";
import type { User } from "@/types/types";
import App from "@/App.vue";
import { DOMWrapper, mount, VueWrapper } from "@vue/test-utils";
import type { State } from "@/store"
const localStorageMock: Storage = (() => {
let store: Record<string, string> = {};
@truongluu
truongluu / docker-compose.yml
Created May 15, 2024 15:27 — forked from drdogbot7/docker-compose.yml
Wordpress Docker Compose with CLI - official images
version: '2'
services:
db:
image: mysql:5.7
volumes:
- "./.data/db:/var/lib/mysql"
ports:
- "[YOUR_DESIRED_SQL_PORT]:3306"
environment:
MYSQL_ROOT_PASSWORD: wordpress