Skip to content

Instantly share code, notes, and snippets.

@stenuto
stenuto / timelapse.sh
Created June 18, 2024 20:56
Timelapse script
#!/bin/bash
# Check if interval argument is provided
if [ -z "$1" ]; then
echo "Usage: $0 -int <interval_in_seconds>"
exit 1
fi
# Extract the interval value
interval=$2
@rsms
rsms / macos-distribution.md
Last active July 16, 2024 05:25
macOS distribution — code signing, notarization, quarantine, distribution vehicles
@AndrewIngram
AndrewIngram / CurrentTime.tsx
Created November 21, 2023 00:04
Current time in React without hydration errors
import { Suspense } from "react";
import CurrentTimeClient from "./CurrentTimeClient";
export default function CurrentTime() {
const locale = "en-GB";
const dateConfig = {
hour: "numeric",
minute: "numeric",
second: "numeric",
@Andarist
Andarist / gist:0294519c570a52fb14f4cdd3d589c880
Created February 23, 2023 08:49
Reverse mapped types brain dump
mapped types syntax and intro
https://www.typescriptlang.org/play?#code/C4TwDgpgBA8gRgKygXigbwFBW1AZge3wC4oBnYAJwEsA7AcwBosc4BDCkmgVwFs4IKGAL4YMoSFACSAEwg1gVUAB4AKgD4U6ZtgDaAaSi0oAawgh8uKCoC6JFfuvDR46AGVWPaKhlyFy+AhqGAD0wTgAegD8omLg0AAKFPg8VKRUuCCqGqiYOFD6hjQmZhZWtlAAFACUKBqJyakQqg5BIrES9SlpuFQQ0pqdqemZAUGhEdEYsgDGADbs0NP4NORQFGDTJIPdvdKiSyvAeFzAXBReaxsAdGwU1SFheU-PUFGiuCdnEFfAABZyFQqADdWLMasgNLkcCDZtooOM3kIqkA
a tweet that prompted the idea for the talk
https://twitter.com/kentcdodds/status/1608187990215655424
but since this isn't possible with satisfies (it doesn't participate in inference, in an example like that it only provides contextual types) the answer was to use a function with a reverse mapped type
@RobertAKARobin
RobertAKARobin / safari.md
Last active July 8, 2024 11:29
Safari's date-picker is the cause of 1/3 of our customer support issues

Safari's date-picker is the cause of 1/3 of our customer support issues

...and obviously we're building a workaround. But I'm absolutely flabbergasted that a standard <input type="date"> HTML field, in a standard browser, from a company that bases its reputation good design, could be so dreadful.

The context

I'm the developer for a startup that sells a genetic test to recommend medications for high blood pressure. For medical reasons we need to know our customers' birth date. Most of our customers are in their 60s or older. We've found that many of them use iPads or iPhones. And they're the ones who complain to our customer support that our site is unusable.

The problem

@mjackson
mjackson / download-counts.mjs
Last active November 11, 2022 05:43
Download counts for react-router
const npmApiUrl = "https://api.npmjs.org/downloads/point";
async function fetchDownloadCounts(packageName, year) {
let range = `${year}-01-01:${year}-12-31`;
let response = await fetch(`${npmApiUrl}/${range}/${packageName}`);
return (await response.json()).downloads;
}
async function getDownloads(startYear, endYear = startYear) {
if (endYear < startYear) {
@mrdoob
mrdoob / WebAudio.js
Last active February 14, 2024 05:02
HTMLAudioElement polyfill using the WebAudio API with seamless loop support in Safari.
/**
* @author mrdoob / http://mrdoob.com/
*/
function WebAudio( context ) {
if ( context === undefined ) {
context = WebAudio.context;
@steveruizok
steveruizok / cache.ts
Last active March 31, 2023 14:43
weak map gist
export class Cache<T extends object, K> {
items = new WeakMap<T, K>()
get<P extends T>(item: P, cb: (item: P) => K) {
if (!this.items.has(item)) {
this.items.set(item, cb(item))
}
return this.items.get(item)!
}
@grabbou
grabbou / tasks.json
Last active June 30, 2023 13:29
A simple example of launching two long-running processes within Visual Studio Code to make working in monorepo easier
{
"version": "2.0.0",
"tasks": [
{
"label": "Start Expo dev server",
"type": "shell",
"command": "cd ./apps/mobile && yarn start",
"presentation": {
"reveal": "always",
"panel": "new",
import * as React from 'react'
import { SpringValue, easings, useSpring } from 'react-spring'
/**
* Hook that animates height when args.animationKey changes
*
* Ex:
* const animatedBlock = useAnimatedHeight({
* animationKey: key,
* })