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
pnpm add next@canary react@beta react-dom@beta | |
pnpm add -D babel-plugin-react-compiler | |
echo "module.exports = { | |
experimental: { | |
reactCompiler: true | |
}, | |
}" > next.config.js |
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
#!/usr/bin/env node | |
import * as core from '@arethetypeswrong/core' | |
import { groupProblemsByKind } from '@arethetypeswrong/core/utils' | |
import { execSync } from 'child_process' | |
import { readFile, stat, unlink } from 'fs/promises' | |
import path from 'path' | |
const problemFlags = { | |
NoResolution: 'no-resolution', | |
UntypedResolution: 'untyped-resolution', |
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 linearGradientText = ( | |
text: string, | |
startColor: number[], | |
endColor: number[] | |
) => { | |
let gradient = '' | |
for (let i = 0; i < text.length; i++) { | |
const r = Math.floor( | |
startColor[0] + (i / (text.length - 1)) * (endColor[0] - startColor[0]) |
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 KeysOfUnion<T> = T extends T ? keyof T : never |
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://stackoverflow.com/questions/61546603/bash-find-file-and-insert-text-in-beginning-of-empty-and-non-empty-files | |
# insert `'client'\n` to all .client.tsx files | |
find . -type f -name '*.client.tsx' -print0 | while IFS= read -rd '' file; do ed -s "$file" <<< $'0a\n\'client\'\n\n.\nw\nq'; done | |
# rename files | |
ls | grep \.png$ | sed 'p;s/\.png/\.jpg/' | xargs -n2 mv |
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
git rev-list --objects --all \ | |
| grep "$(git verify-pack -v .git/objects/pack/*.idx \ | |
| sort -k 3 -n \ | |
| tail -10 \ | |
| awk '{print$1}')" |
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 path = require('path'); | |
const webpack = require('webpack'); | |
const fs = require('fs'); | |
// Based on the NodeWatchFileSystem class at: | |
// - https://github.com/webpack/webpack/blob/master/lib/node/NodeWatchFileSystem.js | |
// which in turn exposes: | |
// - https://www.npmjs.com/package/watchpack | |
class CustomWatchFileSystem { |
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 mouseEventOf = (eventType) => (element, x, y) => { | |
const rect = element.getBoundingClientRect() | |
const event = new MouseEvent(eventType, { | |
view: window, | |
bubbles: true, | |
cancelable: true, | |
clientX: rect.left + x, | |
clientY: rect.top + y, | |
}) |
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 readOnDrop = (element, onRead) => { | |
element.addEventListener('dragover', ev => ev.preventDefault()) | |
element.addEventListener('drop', ev => { | |
ev.preventDefault() | |
const dt = ev.dataTransfer | |
const file = dt.files[0] | |
const reader = new FileReader() | |
reader.onload = event => onRead(event.target.result) | |
reader.readAsText(file) | |
}) |
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
openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pem | |
# only enter the Common Name: your ip address or your domain name |
NewerOlder