Skip to content

Instantly share code, notes, and snippets.

Avatar
🤓
working hard to make the world better with software

Kent C. Dodds kentcdodds

🤓
working hard to make the world better with software
View GitHub Profile
@kentcdodds
kentcdodds / README.md
Last active Oct 30, 2020
imagemin-in-place
View README.md

imagemin-in-place

Problem: You want to use imagemin-cli but it requires you provide an output directory. But you just want to override the existing file with the optimized version.

Solution: This uses imagemin with the plugins to support compressing png, jpg, gif, svg, and webp files and it overrides the existing file.

@kentcdodds
kentcdodds / remix-rocks.mdx
Last active Oct 28, 2020
Test Blog Post for a Remix Blog
View remix-rocks.mdx
meta headers
title description
Title of the page
A solid description of this document.
cache-control og:image
max-age=60, s-maxage=604800
/amazing-image.png
@kentcdodds
kentcdodds / README.md
Last active Nov 5, 2020
Book Stitcher. Combine multiple mp3 files into a single MP3 file with metadata (for chapters etc.). It's great for audiobooks.
View README.md

Book Stitcher

This is just something I hacked together to create an audiobook file out of CD audio files (complete with chapter marking metadata!)

Works great when used in combination with https://github.com/kentcdodds/podcastify-dir

npx https://gist.github.com/kentcdodds/e07f9106c63cc13a75adb0157700eb5b ./path-to-sorted-mp3s
@kentcdodds
kentcdodds / add-discord-role.js
Last active Jul 30, 2020
An example of how you can add a role to a user with discord.js
View add-discord-role.js
const Discord = require('discord.js')
// your bot token
const token = 'NzM4MDk2NjA4NDQwNDgzODcw.XyG8CA.RbwIBFnAbrRDYOlTdLYgG_T4CMk'
const discordUsername = 'example#1234'
const roleToAdd = 'Cool Person'
const guildName = 'Your Guild Name'
function deferred() {
let resolve, reject
View thing.js
import React from 'react'
import {client} from 'utils/api-client'
import {render, screen, loginAsUser} from 'test/app-test-utils'
import {buildBook, buildListItem} from 'test/generate'
import * as booksDB from 'test/data/books'
import * as listItemsDB from 'test/data/list-items'
import {App} from 'app'
async function renderBookScreen({book, listItem} = {}) {
View abort-controller.js
function useAbortController() {
const abortControllerRef = React.useRef()
const getAbortController = React.useCallback(() => {
if (!abortControllerRef.current) {
abortControllerRef.current = new AbortController()
}
return abortControllerRef.current
}, [])
React.useEffect(() => {
@kentcdodds
kentcdodds / fix-feedback-links.js
Last active Jun 16, 2020
I use this to automatically fix links in my react workshops. (This one's only for the testing-react-apps repo because those markdown files aren't rendered in a UI, the normal one is at https://gist.github.com/kentcdodds/436a77ff8977269e5fee39d9d89956de)
View fix-feedback-links.js
@kentcdodds
kentcdodds / index.js
Last active Mar 23, 2020
test npx gist
View index.js
#!/usr/bin/env node
console.log('hello world')
@kentcdodds
kentcdodds / fix-links.js
Last active Nov 20, 2020
I use this to automatically fix links in my react workshops
View fix-links.js
@kentcdodds
kentcdodds / package.json
Last active Nov 22, 2020
setup script for my workshops
View package.json
{
"name": "workshop-setup",
"version": "1.0.0",
"description": "This is the common setup script for most of my workshops",
"bin": "./setup.js"
}
You can’t perform that action at this time.