Skip to content

Instantly share code, notes, and snippets.

@subtleGradient
subtleGradient / hotness.ts
Last active May 11, 2024 03:49
Hot reloading disposal events
/*
MIT No Attribution
Copyright 2024 Thomas Aylott
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so.
/* eslint-disable @typescript-eslint/no-unused-vars */
"use client"
import { Suspense, use, useMemo } from "react"
import { Text } from "react-native"
import { waitForTransactionReceipt } from "src/lib/viem"
import { PromisedValue } from "src/utils/type-helpers"
import { Address } from "viem"
type TransactionReceipt = PromisedValue<ReturnType<typeof waitForTransactionReceipt>>
@subtleGradient
subtleGradient / CurrentServerTime.server.tsx
Last active March 21, 2024 01:30
example of what a re-renderable React server component could maybe look like?
"use server"
import { $ } from "bun"
export async function* CurrentServerTime() {
while (true) {
yield <html.input key="ONLY ME!" readOnly value={await $`time`.text()} />
await sleep(1_234)
}
}
@subtleGradient
subtleGradient / TCR.sh.command
Last active December 27, 2023 01:21
Test && Commit || Revert
#!/bin/bash
set -e # exit on error
set -u # exit on undefined variable
# set -o pipefail # exit on failure in pipe
# set -x # print commands as they are run
# if DEBUG is set, print commands as they are run
set +u # allow undefined variables for this check
if [ ! -z "$DEBUG" ]; then
set -x
@subtleGradient
subtleGradient / GenAI.js
Created November 4, 2023 18:37
playing with ollama
class GenAI {
static INJECT = "<{([ INJECT ])}>"
static PRE = "<PRE>"
static SUF = " <SUF>"
static MID = " <MID>"
static END = " <EOT>"
#apiUrl
#model
@subtleGradient
subtleGradient / Bad.txt
Created November 3, 2023 15:23
TLDs that get linkified automatically by Apple Notes
These TLDs are NOT linkified automatically by Apple Notes
example.ac
example.actor
example.adult
example.ae
example.am
example.app
example.archi
example.army
@subtleGradient
subtleGradient / getter.py
Last active December 2, 2022 23:51
hack pyannote to work on M1/M2 macOS with arm64 with MPS
def get_devices(needs: int = None):
"""Get devices that can be used by the pipeline
Parameters
----------
needs : int, optional
Number of devices needed by the pipeline
Returns
-------
@subtleGradient
subtleGradient / search_youtube.py
Last active September 30, 2022 23:13
Command line python script to search YouTube
#!/usr/bin/env python3
import json
import os
def install():
os.environ['PYPPETEER_CHROMIUM_REVISION'] = '1052357'
os.system('python3 -m pip install -q pyppeteer pyppeteer_stealth')
os.system('pyppeteer-install')
import useSize, { UseSizeOptions } from "@react-hook/size";
import {
Fragment,
ReactNode,
RefObject,
useCallback,
useEffect,
useLayoutEffect,
useRef
} from "react";
@subtleGradient
subtleGradient / 42_hand-sketch-97.info.markdown
Last active September 6, 2021 14:35
42_hand-sketch-97.jpg Info

This was drawn by the textmode artist agent_42 (member of the CiA art group) It was sketched in 1997 after the artist graduated from vocational school for Desktop Publishing, his mom forced him to take a drawing class.

This was the first thing he ever drew in class. Not too shabby right?

42_hand-sketch-97