This file contains 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
["click", "submit"].forEach((eventType) => { | |
window.addEventListener(eventType, (ev) => { | |
// Initialize variables from element that triggered the event | |
const { | |
target, action, href = action, method = ev.target._method?.value, ...data | |
} = Object.fromEntries([...ev.target.attributes].map((attr) => [ | |
attr.name.replace(/^data-/, ""), attr.value | |
])); | |
// Default behavior if target is not defined or is not a selector |
This file contains 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
export function useDebounce(handler: (value: string) => void, millisec: number = 500) { | |
const [value, setValue] = useState(''); | |
useEffect(() => { | |
const timeoutId = setTimeout(() => handler(value), millisec); | |
return () => clearTimeout(timeoutId); | |
}, [value, handler, millisec]); | |
return setValue; | |
} |
This file contains 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
// Syntax highliter | |
// License: MIT | |
// Author: henriquegogo | |
// Description: A small generic highlighter easy to plug and use in any code sample. | |
// Works better with JavaScript, C, Python and HTML | |
function highlight(selector) { | |
document.body.innerHTML += ` | |
<style>${selector} span * { color: inherit !important }</style> | |
`; | |
document.querySelectorAll(selector).forEach((element) => { |
This file contains 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
-- takes all | |
love = { | |
audio = { | |
getActiveEffects = function(...) end, --Gets a list of the names of the currently enabled effects. | |
getActiveSourceCount = function(...) end, --Gets the current number of simultaneously playing sources. | |
getDistanceModel = function(...) end, --Returns the distance attenuation model. | |
getDopplerScale = function(...) end, --Gets the global scale factor for doppler effects. | |
getEffect = function(...) end, --Gets the settings associated with an effect. | |
getMaxSceneEffects = function(...) end, --Gets the maximum number of active effects. | |
getMaxSourceEffects = function(...) end, --Gets the maximum number of active Effects for each Source. |
This file contains 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
xmodmap -e "keycode 49 = apostrophe quotedbl bar bar bar" |
This file contains 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
#!/bin/bash | |
# Add these lines in .bashrc and set Raspberry Pi to auto login | |
if [ ! -f /tmp/fluidsynth-bootloaded ]; then | |
touch /tmp/fluidsynth-bootloaded | |
killall fluidsynth | |
fluidsynth -a alsa -g 1 /usr/share/sounds/sf2/default-GM.sf2 -o midi.autoconnect=1 -c 4 | |
fi |
This file contains 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
// Constant Amortization System for HP12C (Platinum) | |
// Author: Henrique Gogó (henriquegogo@gmail.com) | |
// | |
// Instructions: enter n, i and PV values and set FV as 0. | |
// Set register 9 if you want to get an specific payment number. | |
// | |
// After program ends, the result saved in registers will be: | |
// X: current payment value | |
// FV: remaining amount to pay | |
// PMT: amortization value (fixed) |
This file contains 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
qemu-img create -f qcow2 "$@" 80G |
This file contains 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
let recognition = new webkitSpeechRecognition(); | |
recognition.lang = 'pt-BR'; | |
recognition.onresult = ({ results }) => { | |
const transcript = results[0][0].transcript; | |
speechSynthesis.speak(new SpeechSynthesisUtterance(transcript)); | |
} | |
recognition.start(); |
This file contains 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
Show hidden characters
{ | |
"env": { | |
"browser": true, | |
"commonjs": true, | |
"es6": true, | |
"node": true | |
}, | |
"extends": [ | |
"eslint:recommended", | |
"plugin:jest/recommended", |
NewerOlder