Skip to content

Instantly share code, notes, and snippets.

View hphuocthanh's full-sized avatar
🐟
Hi

Tom Thanh hphuocthanh

🐟
Hi
View GitHub Profile
@sand97
sand97 / _app.js
Last active September 27, 2022 10:12
Example of Nextjs Splash screen _app.js
function MyApp({ Component, pageProps }) {
// Hide splash screen shen we are server side
useEffect(() => {
if (typeof window !== 'undefined') {
const loader = document.getElementById('globalLoader');
if (loader)
loader.style.display = 'none';
}
}, []);
@FbN
FbN / vite.config.js
Last active April 6, 2025 13:31
vite.config.js node built-in polyfills
// yarn add --dev @esbuild-plugins/node-globals-polyfill
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill'
// yarn add --dev @esbuild-plugins/node-modules-polyfill
import { NodeModulesPolyfillPlugin } from '@esbuild-plugins/node-modules-polyfill'
// You don't need to add this to deps, it's included by @esbuild-plugins/node-modules-polyfill
import rollupNodePolyFill from 'rollup-plugin-node-polyfills'
export default {
resolve: {
alias: {
export default class EventEmitter
{
constructor()
{
this.callbacks = {}
this.callbacks.base = {}
}
on(_names, callback)
{
@tykurtz
tykurtz / grokking_to_leetcode.md
Last active April 23, 2025 01:57
Grokking the coding interview equivalent leetcode problems

GROKKING NOTES

I liked the way Grokking the coding interview organized problems into learnable patterns. However, the course is expensive and the majority of the time the problems are copy-pasted from leetcode. As the explanations on leetcode are usually just as good, the course really boils down to being a glorified curated list of leetcode problems.

So below I made a list of leetcode problems that are as close to grokking problems as possible.

Pattern: Sliding Window

@bradtraversy
bradtraversy / mongodb_cheat_sheet.md
Last active April 22, 2025 11:58
MongoDB Cheat Sheet

MongoDB Cheat Sheet

Show All Databases

show dbs

Show Current Database

@iambudi
iambudi / Hadoop_install_osx.md
Last active December 22, 2024 03:22 — forked from viecode09/Hadoop_install_osx.md
This is how to install hadoop on Mac OS

STEP 1: First Install HomeBrew, download it from http://brew.sh

$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

STEP 2: Install Hadoop

$ brew search hadoop
$ brew install hadoop
@tungvn
tungvn / regex-vietnamese-phone-number-updated-2018.js
Last active April 17, 2025 10:01
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);
}
@aprilmintacpineda
aprilmintacpineda / Using Multiple SSH keys - Beginner Friendly.md
Last active March 21, 2025 11:13
Beginner Friendly: Using Multiple SSH keys

How to follow this guide

The problem

I have one computer and two different github accounts. One is for work, the other is for my personal stuff. I can't use the same ssh key twice, so I have to use different ssh key for each of my accounts. How do I do that? How do I switch between these ssh keys?

@hu2di
hu2di / ConvertVie.js
Last active March 1, 2025 13:15
JavaScript: Chuyển tiếng Việt có dấu sang không dấu
function removeVietnameseTones(str) {
str = str.replace(/à|á|||ã|â||||||ă|||||/g,"a");
str = str.replace(/è|é||||ê||ế|||/g,"e");
str = str.replace(/ì|í|||ĩ/g,"i");
str = str.replace(/ò|ó|||õ|ô||||||ơ|||||/g,"o");
str = str.replace(/ù|ú|||ũ|ư|||||/g,"u");
str = str.replace(/|ý|||/g,"y");
str = str.replace(/đ/g,"d");
str = str.replace(/À|Á|||Ã|Â||||||Ă|||||/g, "A");
str = str.replace(/È|É||||Ê|||||/g, "E");
@kottenator
kottenator / simple-pagination.js
Created July 13, 2015 20:44
Simple pagination algorithm
// Implementation in ES6
function pagination(c, m) {
var current = c,
last = m,
delta = 2,
left = current - delta,
right = current + delta + 1,
range = [],
rangeWithDots = [],
l;