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 | |
files=$(git diff --cached --name-only | grep '\.jsx\?$') | |
# Prevent ESLint help message if no files matched | |
if [[ $files = "" ]] ; then | |
exit 0 | |
fi | |
failed=0 | |
for file in ${files}; do |
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
// deno run --allow-net --allow-write download-shows.ts | |
import { download } from "https://deno.land/x/download/mod.ts"; | |
const showList = 'https://syntax.fm/api/shows'; | |
async function getShowList(): Promise<Show[]> { | |
const list = await (await fetch(showList)).json(); | |
return list; | |
} |
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 dotenv from "dotenv"; | |
import { readFile, writeFile } from 'fs/promises'; | |
dotenv.config(); | |
import { Configuration, OpenAIApi } from "openai"; | |
const configuration = new Configuration({ | |
apiKey: process.env.OPENAI_API_KEY, | |
}); | |
export const openai = new OpenAIApi(configuration); |
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
// 1. Visit a news website like cnn.com | |
// 2. paste this into your console | |
setInterval(() => | |
document.querySelectorAll('p,img,a,button,h1,h2,h3,span') | |
.forEach(x=>x.style=`transform:rotate(${Math.random()*777}deg) scale(${Math.random()* 3}); transition:all .5s`) | |
, 500); | |
// 3. feel a lil bit better 😘 |
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
{ | |
"editor.tokenColorCustomizations": { | |
// just one | |
"comments": { | |
"fontStyle": "italic", | |
}, | |
// multiple scopes | |
"textMateRules": [ | |
{ | |
"scope": [ |
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
// Here we check if our custom type "Stringy" extends a narrow type of '' | |
// If it does, the type is never | |
// If it doesnt, the type is "Strinfy", which is just a string type | |
function getItem<Stringy extends string>( | |
id: Stringy extends '' ? never : Stringy | |
) { | |
// code here | |
} | |
// works: | |
getItem('abc123'); // No error |
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
// paste in your console | |
speechSynthesis.onvoiceschanged = function() { | |
var msg = new SpeechSynthesisUtterance(); | |
msg.voice = this.getVoices().filter(v => v.name == 'Cellos')[0]; | |
msg.text = Object.keys(window).join(' '); | |
this.speak(msg); | |
}; |
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
function update(cache, payload) { | |
cache.evict(cache.identify(payload.data.deleteCartItem)); | |
} | |
const [removeFromCart, { loading }] = useMutation(REMOVE_FROM_CART_MUTATION, { | |
variables: { id }, | |
update, | |
// When the optimistic response comes back, it seems to re-fetch every single query on the page, leaving `data` from queries undefined (and loading and error undefined as well), causing the layout to break. | |
// // The error itself comes from next.js, and it does seem that the item is evicted from the cache before that happens... | |
// optimisticResponse: { |
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
function fixNotionPadding() { | |
Array.from(document.querySelectorAll(`[style*="padding-left: 96px"]`)).forEach(el => el.style.padding = 0); | |
requestAnimationFrame(fixNotionPadding); | |
} | |
fixNotionPadding(); |