Skip to content

Instantly share code, notes, and snippets.

View thuykaka's full-sized avatar
🎯
Focusing

Thuy Le thuykaka

🎯
Focusing
View GitHub Profile
@thuykaka
thuykaka / docker-compose.yml
Created August 15, 2025 13:09
Docker compose for kafka kraft
services:
kafka:
image: apache/kafka:3.9.1
container_name: kafka
restart: unless-stopped
ports:
- "9092:9092"
environment:
KAFKA_NODE_ID: 1
KAFKA_PROCESS_ROLES: broker,controller
@thuykaka
thuykaka / example.tsx
Created July 17, 2025 05:02
Shadcn InputDebounce
// ref
const inputRef = useRef<HTMLInputElement>(null);
<InputDebounce
ref={inputRef}
onChange={handleSearch}
placeholder="Tìm kiếm..."
delay={300}
/>
// Controlled component
@thuykaka
thuykaka / meta-ad-library.js
Created June 6, 2025 02:22
Crawl meta ad library
var session_id = self.crypto.randomUUID();
var lsd = require("LSD").token;
var dtsg = require("DTSGInitialData").token;
var uid = require("CurrentUserInitialData").USER_ID;
var params = {
"q":"loose weight",
"countries[0]":"US",
"count":30,
"session_id":session_id,
// Telegram Bot API base URL
const TELEGRAM_API_BASE = 'https://api.telegram.org';
async function handleRequest(request) {
const url = new URL(request.url);
// Reconstruct the Telegram API URL
const telegramUrl = `${TELEGRAM_API_BASE}${url.pathname}${url.search}`;
@thuykaka
thuykaka / 2fa.ts
Created May 29, 2025 08:23
2FA Generate & Verify
import speakeasy from 'speakeasy';
import qrcode from 'qrcode';
/*
Steps:
1. Generate a secret
2. Show a QR code for the user to scan in
3. Authenticate the token for the first time
*/
const generateSecret = (name?: string, issuer?: string) => {
@thuykaka
thuykaka / bank-qr.ts
Last active June 3, 2025 13:50
Tạo Bank QR (giống VietQR)
import qrcode, { type QRCodeToBufferOptions, type QRCodeToDataURLOptions } from 'qrcode';
import { z } from 'zod';
import { Jimp } from 'jimp';
type PointOfInitMethod = 'static' | 'dynamic';
type QrCodeLogoOptions = {
src: string;
text?: string;
backgroundColor?: string;
@thuykaka
thuykaka / token-generator.js
Created February 22, 2023 08:24 — forked from ziluvatar/token-generator.js
Example of refreshing tokens with jwt
/**
* Example to refresh tokens using https://github.com/auth0/node-jsonwebtoken
* It was requested to be introduced at as part of the jsonwebtoken library,
* since we feel it does not add too much value but it will add code to mantain
* we won't include it.
*
* I create this gist just to help those who want to auto-refresh JWTs.
*/
const jwt = require('jsonwebtoken');