Skip to content

Instantly share code, notes, and snippets.

View tungvn's full-sized avatar
🎯
Focusing

Tung Vu Ngoc (Frank) tungvn

🎯
Focusing
  • DCODE
  • Ha Noi, Viet Nam
  • 12:58 (UTC +07:00)
View GitHub Profile
@tungvn
tungvn / README.md
Last active January 21, 2026 03:05
d3 Timeline - Typescript version (AI generated, human double check, use with careful test)

D3 Timeline - Usage Guide

A TypeScript-compatible timeline visualization library for D3 v7, upgraded from the original D3 v3 implementation.

Installation

The library is already set up in this project with D3 v7.9.0. No additional installation required.

Usage

@tungvn
tungvn / HelloWorld.tsx
Created December 26, 2025 04:22
How to use React.useCallback with debounce/throttle?
import React from 'react'
import debounce from 'lodash/debounce' // Or throttle
export const HelloWorld: React.FC = () => {
// Example for a state can change quickly in a bit of time
const [innerParams, setInnerParams] = React.useState<string>('')
// Use ref to create a freeze debounce function to make sure it's not rerender
// Need to pass the changing parameters here
const fetch = React.useRef(debounce((params: any) => {
@tungvn
tungvn / regex-vietnamese-phone-number-updated-2018.js
Last active November 24, 2025 09:45
Vietnamese phone number Regex validation
/*
Before Septemper 15 2018, Vietnam has phone number start with 09*, 01(2|6|8|9).
After that, the phone number can start with 03, 05, 07 or 08.
So this function provide a way to validate the input number is a Vietnamese phone number
*/
function isVietnamesePhoneNumber(number) {
return /(03|05|07|08|09|01[2|6|8|9])+([0-9]{8})\b/.test(number);
}