Skip to content

Instantly share code, notes, and snippets.

/* 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 / setWindow.cypress.js
Last active September 29, 2023 20:23
Test multiple popup windows and iframes with Cypress, including window.open
/*
The MIT License
Copyright 2020 Thomas Aylott <oblivious@subtlegradient.com>
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, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF O
@subtleGradient
subtleGradient / appify
Created November 11, 2010 16:03
appify. Create the simplest possible mac app from a shell script
#!/usr/bin/env bash
#
# url : https://gist.github.com/672684
# version : 2.0.2
# name : appify
# description : Create the simplest possible mac app from a shell script.
# usage : cat my-script.sh | appify MyApp
# platform : Mac OS X
# author : Thomas Aylott <oblivious@subtlegradient.com>
@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 / Info.plist
Last active November 28, 2022 02:54
Add support for the BCM20702A0 USB Bluetooth dongle by editing /System/Library/Extensions/IOBluetoothFamily.kext/Contents/PlugIns/BroadcomBluetoothHostControllerUSBTransport.kext/Contents/Info.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>16B2657</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>BroadcomBluetoothHostControllerUSBTransport</string>
@subtleGradient
subtleGradient / 512-op-whatever.js
Last active November 15, 2022 12:51
All 512 types! OP --
[...document.querySelectorAll('td img')]
.map((img) => [img, img.closest('td')])
.map(([img, td]) => [img, td.innerText || td.parentElement.nextElementSibling.cells[td.cellIndex].innerText])
.map(([img, text]) => [img.src, ...text.split(/\s+/).reverse()])
.map(([src, type, ...name]) => [type, name.reverse().join(' '), src])