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 { useEffect } from 'react'; | |
import isEqual from 'lodash-es/isEqual'; | |
export const usePrevious = <T>(value: T) => { | |
const ref = useRef<T>(); | |
useEffect(() => { | |
ref.current = value; | |
}); | |
return ref.current; | |
}; |
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 | |
id=c6cde936-ae71-4c3e-9ed6-9f65e225f001 | |
sizes=( 285 700 1000 1200 1500 2000 ) | |
formats=( "jpg" "webp" "avif" ) | |
datafile="$id.csv" | |
echo "Creating $id.csv" | |
echo "width,quality,jpg,webp,avif" > $datafile | |
for w in "${sizes[@]}" |
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
type Foo = | |
| "Nope" | |
| ["a", "b", "c", "d", 'e', { x: string }] | |
function fn(foo: Foo) { | |
return match<Foo, string>(foo) | |
.with('Nope', () => 'no') | |
.with(['a', 'b', 'c', 'd', 'e', __], () => 'yes') | |
.exhaustive() | |
} |
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
Based on https://stackoverflow.com/a/44494345/1355416 | |
echo "Branch | Message | Author | Date" | |
git for-each-ref \ | |
--sort=committerdate refs/heads/ \ | |
--format='%(HEAD) %(refname:short) | %(contents:subject) | %(authorname) | %(committerdate:short)' \ | |
| grep "Mikel Arnaiz | 2022-04-06" |
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
Array | |
.from(document.querySelectorAll('.tabulator-row')) | |
.map(row => { | |
return Array | |
.from(row.querySelectorAll('.tabulator-cell')) | |
.slice(0, 3) | |
.map(cell => cell.innerText ) | |
.join(',') | |
}) | |
.join('\n') |
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 fs = require('fs'); | |
const sizeLimitIncreaseRate = 1.05 | |
const chunkKBThreshold = 5 | |
// Copy & paste data from "ANALYZE=true yarn build:prod" sidebar | |
const data = | |
[ | |
"js/vendor1.d65be6d62f367668194a.chunk.js (145.48 KB)", | |
"js/vendor2.4421506493bc269f1ec0.chunk.js (69.44 KB)", |
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
// https://github.com/facebook/jest/issues/2234#issuecomment-731451275 | |
beforeAll(() => { | |
jest.useFakeTimers('modern'); // tell Jest to use a different timer implementation. | |
jest.setSystemTime(new Date('2022-02-15T22:30:00.000+01:00').getTime()); | |
}); | |
afterAll(() => { | |
// Back to reality... | |
jest.useRealTimers(); | |
}); |
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
@mixin byPlatform($type) { | |
@if $type == 'mobile' { | |
font-size: 8px; | |
line-height: 10px; | |
} | |
@if $type == 'table' { | |
font-size: 12x; | |
line-height: 15px; | |
} |
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
@mixin byPlatform($type) { | |
@if $type == 'mobile' { | |
font-size: 8px; | |
line-height: 10px; | |
} | |
@if $type == 'table' { | |
font-size: 12x; | |
line-height: 15px; | |
} |
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
@mixin byPlatform($type) { | |
@if $type == 'mobile' { | |
font-size: 8px; | |
line-height: 10px; | |
} | |
@if $type == 'table' { | |
font-size: 12x; | |
line-height: 15px; | |
} |
NewerOlder