Skip to content

Instantly share code, notes, and snippets.

View kentcdodds's full-sized 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 March 30, 2024 11:39
user-package-stats

user-package-stats

I was poking around trying to figure out all the packages I have access to publish and got curious. So I write this little script to determine the download stats for all the packages I have publish access to.

Feel free to try it yourself. Just change the username passed to getUserDownloadStats.

By default, the stats are sorted by their average daily downloads (descending). That should give you an idea of the most "popular" package of a given user relative to how long that package has been around.

You can use it with npx like so:

@kentcdodds
kentcdodds / README.md
Last active October 30, 2020 19:03
imagemin-in-place

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 October 28, 2020 22:12
Test Blog Post for a Remix Blog
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 November 8, 2024 02:48
Book Stitcher. Combine multiple mp3 files into a single MP3 file with metadata (for chapters etc.). It's great for audiobooks.

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 August 21, 2021 16:29
An example of how you can add a role to a user with discord.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
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} = {}) {
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 December 3, 2020 20:43
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)
@kentcdodds
kentcdodds / index.js
Last active March 23, 2020 22:29
test npx gist
#!/usr/bin/env node
console.log('hello world')
@kentcdodds
kentcdodds / fix-links.js
Last active April 19, 2021 17:05
I use this to automatically fix links in my react workshops