Skip to content

Instantly share code, notes, and snippets.

@everdimension
everdimension / Input.tsx
Last active April 29, 2025 07:12
React Input element with support for customValidity props
/**
* Usage:
* <Input customValidity="your validation message" /> // add constraint
* or
* <Input customValidity="" /> // remove constraint
* or
* <Input defaultCustomValidity="you message" /> // initial validationMessage
*/
export function Input({
defaultCustomValidity,
@igodorogea
igodorogea / .0 win-setup.md
Last active August 26, 2024 15:25
Windows PC Setup
@mitchellh
mitchellh / merge_vs_rebase_vs_squash.md
Last active December 26, 2025 00:21
Merge vs. Rebase vs. Squash

I get asked pretty regularly what my opinion is on merge commits vs rebasing vs squashing. I've typed up this response so many times that I've decided to just put it in a gist so I can reference it whenever it comes up again.

I use merge, squash, rebase all situationally. I believe they all have their merits but their usage depends on the context. I think anyone who says any particular strategy is the right answer 100% of the time is wrong, but I think there is considerable acceptable leeway in when you use each. What follows is my personal and professional opinion:

@khalidx
khalidx / node-typescript-esm.md
Last active December 26, 2025 00:21
A Node + TypeScript + ts-node + ESM experience that works.

The experience of using Node.JS with TypeScript, ts-node, and ESM is horrible.

There are countless guides of how to integrate them, but none of them seem to work.

Here's what worked for me.

Just add the following files and run npm run dev. You'll be good to go!

package.json

@shoelaced
shoelaced / auto-delete-old-google-drive-files.gs
Last active December 24, 2025 10:36
Google Script: Auto-deletes old files in Google Drive
/**
* Google Apps Script to delete old files and optionally empty folders in Google Drive.
*
* Settings:
* - cutOffDays: Number of days before the current date to consider for file deletion.
* - deleteEmptyFolders: Set to true to delete empty directories, false to keep them.
*
* Instructions:
* 1. Ensure "Drive" advanced service is enabled:
* - In the Google Apps Script dashboard, click "+ Services" in the sidebar.
@unrevised6419
unrevised6419 / README.md
Last active September 5, 2023 21:16
curs.md google function

Can you convert a Value Object (i.e. JSON) to YAML?

My Expectation

My expectation is that a mid-senior level developer should be able to accomplish this task in under 4 hours:

  • write a basic solution in 30-60 minutes
  • debug / test / fine-tune for another 60-90 minutes
  • document, package, and publish within the remaining time

I could see it reasonable even if a developer takes 2 days to solve this for the first time - possibly because they needed to take a break but didn't, such as feeling pressure and getting brain freeze, taking an initial wrong approach, over-thinking the problem, and then just keeping beating the dead horse, etc - especially if they've never had to work independently before.

@mjackson
mjackson / redirects-in-react-router-v6.md
Last active November 18, 2025 19:38
Notes on handling redirects in React Router v6, including a detailed explanation of how this improves on what we used to do in v4/5

Redirects in React Router v6

An important part of "routing" is handling redirects. Redirects usually happen when you want to preserve an old link and send all the traffic bound for that destination to some new URL so you don't end up with broken links.

The way we recommend handling redirects has changed in React Router v6. This document explains why.

Background

In React Router v4/5 (they have the same API, you can read about why we had to bump the major version here) we had a <Redirect> component that you could use to tell the router when to automatically redirect to another URL. You might have used it like this:

@DavidWells
DavidWells / persist-page-views.js
Created October 10, 2021 01:21
Example of persisting page views via analytics package
import Analytics from 'analytics'
import onRouteChange from '@analytics/router-utils'
const persistPageViewsPlugin = {
name: 'persist-page-data-plugin',
page: ({ payload }) => {
const { properties } = payload
const pageView = {
path: properties.path,
title: properties.title,
@jonathantneal
jonathantneal / command.js
Last active October 26, 2022 07:20
Executable JavaScript Modules
":" //#;exec /usr/bin/env node --input-type=module - $@<$0
import process from 'process'
const { argv } = process
console.log(argv)