Skip to content

Instantly share code, notes, and snippets.

@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",
@whoisryosuke
whoisryosuke / render-frames-and-sleep.js
Created November 7, 2023 20:10
Blender Flamenco - Render Frames and Sleep - Select a series of frames and a sleep duration and it'll render all frames then sleep after. Good for chunking renders and letting PC rest between segments.
// SPDX-License-Identifier: GPL-3.0-or-later
const JOB_TYPE = {
label: "Render and Sleep",
settings: [
// Settings for artists to determine:
{
key: "frames",
type: "string",
required: true,
@adactio
adactio / updateDateTimes.js
Last active September 11, 2023 05:10
Periodically update the text of `datetime` elements with the relative time elapsed.
(function (win, doc) {
'use strict';
if (!doc.querySelectorAll || !win.Intl || !win.Intl.RelativeTimeFormat) {
// doesn't cut the mustard.
return;
}
var rtf = new Intl.RelativeTimeFormat('en', {
localeMatcher: 'best fit',
numeric: 'always',
style: 'long'
@dkun7944
dkun7944 / CDView.swift
Last active March 24, 2025 13:17
SwiftUI + Swift.Shader CD
//
// CDView.swift
// CD
//
// Created by Daniel Kuntz on 7/3/23.
//
import SwiftUI
struct ShapeWithHole: Shape {
@JLarky
JLarky / 00_README.md
Last active April 5, 2025 13:02
useChildFormStatus

Why is useFormStatus always returning pending false?

So you are trying out that new fangled useFormStatus hook but it doesn't actually react to the status of your form?

Now you tried to Google it and all you get is RTFM "go read docs again". Because hook useFormStatus shows you the status of parent form, not a sibling one.

Let's explain that in English.

  • <form><Spinner></form> works
  • `` doesn't
@kconner
kconner / macOS Internals.md
Last active April 24, 2025 10:08
macOS Internals

macOS Internals

Understand your Mac and iPhone more deeply by tracing the evolution of Mac OS X from prelease to Swift. John Siracusa delivers the details.

Starting Points

How to use this gist

You've got two main options:

@alexanderson1993
alexanderson1993 / README.md
Last active March 1, 2025 14:51
Prisma-like Migrations and type safety with Kysely
OBJS := lol.o b64.o
lol: $(OBJS)
cc -o $@ $(OBJS)
%.o: %.c
cc -c $< -o $@
@noamr
noamr / script-parsing.js
Last active August 23, 2023 16:34
A polyfill for script element loading (for illustration purposes)
function parseHTML(getNextElement) {
let doneParsing = null;
const whenDoneParsing = new Promise(resolve => { doneParsing = resolve; });
while (const element = getNextElement()) {
if (element.tagName !== "SCRIPT") {
// parse everything else...
continue;
}
@jerelmiller
jerelmiller / index.tsx
Last active February 23, 2023 04:30
Apollo Client Suspense
// Our encouraged use of suspense in Apollo will comprise of 2 hooks: useBackgroundQuery and useReadQuery (final names TBD).
// Using these 2 together encourage the use of the render-as-you-fetch pattern to start fetching as soon as possible:
// https://17.reactjs.org/docs/concurrent-mode-suspense.html#approach-3-render-as-you-fetch-using-suspense
const Parent = () => {
// This hook provides no access to data. It's meant purely as a fetching mechanism
const { promise } = useBackgroundQuery(QUERY);
return (
<Suspense fallback="Loading...">