Skip to content

Instantly share code, notes, and snippets.

View IvanRadchenko's full-sized avatar

DanseMacabre IvanRadchenko

  • Berlin
View GitHub Profile
@acorn1010
acorn1010 / generate_images.sh
Created March 24, 2023 17:56
generate_images
#!/usr/bin/env bash
set -e
# Creates webp / avif images for images that don't already exist and places them in the public folder
# This script can take a while to run
# Install deps
# sudo apt-get install -f webp ffmpeg opusenc
# MacOS deps
@acorn1010
acorn1010 / createContainer.ts
Created June 5, 2022 10:26
createGlobalState
import {
Dispatch,
SetStateAction,
useCallback,
useEffect,
useState,
} from 'react';
const isFunction = (fn: unknown): fn is Function => (typeof fn === 'function');
@kyleshevlin
kyleshevlin / memoizedHandlers.js
Created January 22, 2021 00:26
Using React.useMemo to create a `handlers` object
// One of my new favorite React Hook patternms is to create handler
// functions for a custom hook using `React.useMemo` instead of
// `React.useCallback`, like so:
function useBool(initialState = false) {
const [state, setState] = React.useState(initialState)
// Instead of individual React.useCallbacks gathered into an object
// Let's memoize the whole object. Then, we can destructure the
// methods we need in our consuming component.
@unruthless
unruthless / CSS for <sup> and <sub>
Created May 26, 2010 01:31
CSS for <sub> and <sup>
sub, sup {
/* Specified in % so that the sup/sup is the
right size relative to the surrounding text */
font-size: 75%;
/* Zero out the line-height so that it doesn't
interfere with the positioning that follows */
line-height: 0;
/* Where the magic happens: makes all browsers position