Skip to content

Instantly share code, notes, and snippets.

View huynhducduy's full-sized avatar
😍
I'm in love with js <3

Huynh Duc Duy huynhducduy

😍
I'm in love with js <3
View GitHub Profile
@huynhducduy
huynhducduy / tmux-cheatsheet.markdown
Created October 18, 2016 10:21 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@huynhducduy
huynhducduy / AutoConnectLinkedIn.js
Last active March 28, 2022 06:45 — forked from thealphadollar/AutoConnectLinkedIn.js
JS script to send connection requests to your LinkedIn search results with customisation options, accept all received connection requests, and withdraw pending sent connection requests.
// If the script does not work, you may need to allow same site scripting https://stackoverflow.com/a/50902950
Linkedin = {
config: {
scrollDelay: 3000,
actionDelay: 200,
nextPageDelay: 5000,
// set to -1 for no limit
maxRequests: 190,
totalRequestsSent: 0,
@huynhducduy
huynhducduy / latency.txt
Created June 12, 2022 08:45 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
import * as React from "react";
import { useMousePosition } from "~/hooks/useMousePosition";
/** Component to cover the area between the mouse cursor and the sub-menu, to allow moving cursor to lower parts of sub-menu without the sub-menu disappearing. */
export function MouseSafeArea(props: { parentRef: React.RefObject<HTMLDivElement> }) {
const { x = 0, y = 0, height: h = 0, width: w = 0 } = props.parentRef.current?.getBoundingClientRect() || {};
const [mouseX, mouseY] = useMousePosition();
const positions = { x, y, h, w, mouseX, mouseY };
return (
<div
@huynhducduy
huynhducduy / useGlobalMemo.js
Created May 19, 2024 12:51 — forked from tannerlinsley/useGlobalMemo.js
useGlobalMemo is a React hook that lets you share memoizations across an entire app using a unique key.
const cache = {}
export default function useGlobalMemo (key, fn, deps) {
if (!cache[key]) {
cache[key] = {
subs: 0,
deps,
value: fn(),
}