This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useCallback, useRef, useState } from "react"; | |
const useMousePosition = () => { | |
const [mousePosition, setMousePosition] = useState({ | |
left: 0, | |
top: 0, | |
}); | |
const handleMouseMove = useCallback( | |
(e) => |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @name debounce | |
* @summary Debounces "func" within "wait". | |
* @see {@link https://davidwalsh.name/javascript-debounce-function} | |
* @see {@link https://www.freecodecamp.org/news/javascript-debounce-example/} | |
* @example <button onClick={debounce(() => console.log("1s"), 1000)}>Debounce</button> | |
* @param {Function} func | |
* @param {number} [wait] | |
* @returns {Function} | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Encode | |
echo -n 'username:password' | openssl base64 | |
// dXNlcm5hbWU6cGFzc3dvcmQ= | |
// Decode | |
echo `echo dXNlcm5hbWU6cGFzc3dvcmQ= | base64 --decode` | |
// username:password |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener('keyup', function(e) { | |
9 != e.keyCode || e.metaKey || e.ctrlKey || console.log(document.activeElement) | |
}, false) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* var person = { firstName: 'bill', lastName: 'johnson' } | |
* | |
* person = _.rename(person, 'firstName', 'first') | |
* person = _.rename(person, 'lastName', 'last') | |
* | |
* console.log(person) // { first: 'bill', last: 'johnson' } | |
*/ | |
_.rename = (obj, key, newKey) => { |