This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import net from 'net'; | |
| import { BSON } from 'bson'; | |
| // Tạo kết nối TCP tới MongoDB server chạy ở localhost:27019. | |
| const socket = net.connect(27019, 'localhost', () => { | |
| // Callback này chạy khi TCP connect thành công. | |
| // Bên trong, ta tự đóng gói gói tin theo MongoDB Wire Protocol (OP_MSG). | |
| // Lệnh find tương đương: db.users.find({ age: 18 }) trên database "mysql". | |
| // BSON.serialize biến object JS thành Buffer BSON để gửi qua mạng. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 ./ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // open modal from livewire component | |
| $this->dispatch('open-modal', name: 'user-details'); | |
| // close modal | |
| $this->dispatch('close-modal'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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', () => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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', () => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> = {}; |
NewerOlder