Skip to content

Instantly share code, notes, and snippets.

import { useState, useEffect } from "react";
export type AsyncState<T> =
| { loading: false; error?: undefined; value?: undefined }
| { loading: true; error?: undefined; value?: undefined }
| { loading: false; error: Error; value?: undefined }
| { loading: false; error?: undefined; value: T };
export type AsyncUtils<C extends {}, A extends any[]> = {
setArgs: (args: A | undefined) => void;
# An example of using SQLAlchemy / PSQL for PubSub with asyncio
# Rather than using `select.select` to watch for messages, we use
# `loop.add_reader`.
# Inspired by: https://gist.github.com/dtheodor/3862093af36a1aeb8104
#
# One example of use is with aiopyramid.
#
# For an additional consideration, read about case folding here:
# http://stackoverflow.com/a/5173993/465164
@lstude
lstude / 0-README.md
Last active December 2, 2023 15:41
Add Indent / Outdent Functionality to Google Spreadsheets

This tutorial demonstrates how to add an "Indent Text" menu item to a Google spreadsheet so you can indent/outdent text.

  • When the "Indent Text" menu item is selected, any cells within a single column selection will be indented by 5 spaces.

  • You can increase or decrease the number of spaces the text is indented by changing the line below so that the "5" is changed to a larger or smaller number (depending on your preference):

newValues.push(['=CONCAT(REPT( CHAR( 160 ), 5),"' + values[i][0] + '")']);

Folder Structure

Please note

While this gist has been shared and followed for years, I regret not giving more background. It was originally a gist for the engineering org I was in, not a "general suggestion" for any React app.

Typically I avoid folders altogether. Heck, I even avoid new files. If I can build an app with one 2000 line file I will. New files and folders are a pain.