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
if (! function_exists('old_helper')) { | |
/** | |
* Retrieve an old input item and set a | |
* default value with helper | |
* | |
* @param $oldKey | |
* @param null $target | |
* @param null $targetKey | |
* @param callable|null $callback |
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
exports.foo = (req, res) => { | |
const isSuccess = Math.random() < 0.5; | |
setTimeout(() => { | |
if (isSuccess) { | |
return res.send(201); | |
} | |
res.send(403); | |
}, 3000); |
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
import { renderHook } from '@testing-library/react-hooks'; | |
import { useWindowResize } from './useWindowResize'; | |
jest.useFakeTimers(); | |
describe('useWindowResize', () => { | |
it('should run the callback when the window is resized', () => { | |
const mock = jest.fn(); | |
renderHook(() => useWindowResize(mock)); |
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
import styled from 'styled-components'; | |
import { Typography } from '@/fairplay'; | |
import { useCart } from './services/carrinho'; | |
const StyledHeader = styled.div` | |
width: 100%; | |
height: 80rem; | |
background: red; | |
display: grid; | |
place-items: center; |
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
$("document").ready(() => { | |
$("body").append(` | |
<div style='width: 100%; background: red; position: absolute; bottom: 0; z-index: 9999; padding: 0; font-size: 14px; color: white; font-weight: bold; text-align: center;'> | |
Overrides ON | |
</div> | |
`); | |
}); |
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
const MyComponent = () => { | |
const callbackWithThrottle = useThrottle(() => { | |
console.log("this fires after 3 seconds after last click") | |
}, 3000); | |
return <button onClick={callbackWithThrottle}>Click me</button> | |
} | |
``` |
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
import { debounce } from './debounce'; | |
describe('debounce', () => { | |
test('should debounce function calls', () => { | |
jest.useFakeTimers(); | |
const mockFunction = jest.fn(); | |
const delay = 500; | |
const debouncedFunction = debounce(mockFunction, delay); |
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
/** | |
* @see https://stackoverflow.com/questions/49092423/how-to-break-on-localstorage-changes | |
*/ | |
Object.defineProperty(window, 'localStorage', { | |
configurable: true, | |
enumerable: true, | |
value: new Proxy(localStorage, { | |
set: function (ls, prop, value) { | |
console.log(`direct assignment: ${prop} = ${value}`); | |
debugger; |