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
@jh3y
jh3y / magnify-this.js
Last active July 20, 2024 18:15
Magnify This. Bookmarklet code for magnifying a website.
javascript:(function () {
var active;
var magnifier;
var config = {
scale: 75,
size: 160,
image:
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAOtMSURBVHgBrL2JmuS4zQQYyK/e/42b2EkRcUDVY/vf3bKnK0spkSCOwMFDdep0F9D9z3/8jfjvfe379/nnn8/8ffqfazXfNY7a+V77XsXz/fk2gn9+8+o//3yb+efSP9fm7+jj+89zb+G2Md9/H2A/35/nmtqfNqfvnr+zv2Yb/9x/YpykjW3c5jyuZzxFOmYMddvxdQQN7/H85fr7+3m+a9N3ya+hA+r7PG1eWmroJy+f+5//7ee+f3+fAeV0QgY1fOiQpfofum9nz7OHn3vz6bY/8v/S+X2W8unh29CdfFMfKY/gbS/5//MF9eBLy/eGD/XYcmGf5PXhtTN8Hxm7r9Ad9pn2Eboj+SPtZNp7Pv/zz+efcZwWzzrsY/X5Hcsaw9D7JbggmtIeT8hC16RD2LpyIJ6fe+n5/WP1ug8UB3a16FGs5pejI50KNMTRqJ4nxuKevz/Tfl0lGF1/nqsYxHQ7mvXPr88/9zbBokJF2ko49J1/tLhG4fkbYRjdVOPnMvzXvf/5xDYevRrg4p2PUpzhHHlgnpAy0TAGUexsjKLMaff7vX42P9hvVQ1wmGgaVdOcef3Lqw9u3xLkUEY6SXNodX1GBqAy9+0XIbfRmOJjyLF/CT+3WdLesAH2lVd9an7jkZdQ76UHNbI+//yvKq+HBoweSZ/68orGGMwaJ1OPo/oa42DT0+B95ozkpt1nvE1lhMVMhQs7CF0cxbnjnRs+dXXz80+/f1IGo4hz+9MV++4BSOp5fVq8fcBhQ
@kconner
kconner / macOS Internals.md
Last active July 7, 2024 19:42
macOS Internals

macOS Internals

Understand your Mac and iPhone more deeply by tracing the evolution of Mac OS X from prelease to Swift. John Siracusa delivers the details.

Starting Points

How to use this gist

You've got two main options:

@huynhducduy
huynhducduy / question.md
Last active July 28, 2022 11:00
Javascript worker queue problem.
new Worker().eat().sleep(2).work().sleep(2).eat().work()

Get this to print

eat
// wait for 2 seconds
work
// wait for 2 seconds
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
@tannerlinsley
tannerlinsley / useGlobalMemo.js
Created August 28, 2020 23:45
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(),
}
@aleclarson
aleclarson / rollup-typescript.md
Last active June 21, 2024 03:25
The best Rollup config for TypeScript libraries

Features

🔥 Blazing fast builds
😇 CommonJS bundle
🌲 .mjs bundle
.d.ts bundle + type-checking
🧐 Source maps

Install

@thealphadollar
thealphadollar / AutoConnectLinkedIn.js
Last active June 25, 2024 13:41
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: 5000,
nextPageDelay: 5000,
// set to -1 for no limit
maxRequests: -1,
totalRequestsSent: 0,
@huynhducduy
huynhducduy / coinChange.js
Last active June 14, 2020 16:03
Dynamic Programming Solution in JS
// Coin Change - Minimum number of coins
function coinChange(coins, W) {
let cache = [0];
for (let j = 1; j <= W; j++) {
cache[j] = Number.MAX_VALUE;
}
for (let i = 0; i < coins.length; i++) {
for (let j = coins[i]; j <= W; j++) {
@huynhducduy
huynhducduy / binarySearch.js
Last active June 6, 2020 06:39
Algorithms & Data Structure
function binarySearch(arr, x) {
let start = 0, end = arr.length-1;
while (start <= end){
const mid = Math.floor((start + end)/2);
if (arr[mid] === x) return mid;
else if (x > arr[mid])
start = mid + 1;