Skip to content

Instantly share code, notes, and snippets.

View gpoole's full-sized avatar

Greg Poole gpoole

  • Sydney, AU
View GitHub Profile
import Benchmark from "benchmark";
import SMath from "smath";
const suite = new Benchmark.Suite();
const smath = new SMath();
let result1 = 0;
suite.add('SMath.sin', () => {
result1 += smath.sin(Math.random());
@gpoole
gpoole / reset-virtualdub-settings.md
Created August 12, 2022 05:25
Delete or reset all VirtualDub user preferences to the defaults

How to reset VirtualDub settings to default

auxsetup.exe claims to have a button to delete settings from the registry but the version I had deletes settings under a different (HKEY_USERS\*\Software\Freeware\VirtualDub\) which I think might be out of date.

The settings live under this key: Computer\HKEY_USERS\<UID>\SOFTWARE\VirtualDub.org

Deleting that key and restarting VirtualDub will reset everything to defaults.

@gpoole
gpoole / container-export.sh
Last active November 13, 2022 00:53
Tool to help backup the contents of Docker volumes to a tar file on the Docker host
#!/bin/bash
# based on https://docs.docker.com/storage/volumes/#back-up-restore-or-migrate-data-volumes
container_name="$1"
volume_path="$2"
backup_path="$3"
function usage() {
echo "container-export.sh container_name container_path backup_path"
@gpoole
gpoole / MinimalPortableRichText.tsx
Created January 10, 2023 21:45
Minimal implementation of @portabletext/react in TypeScript
import { PortableText, PortableTextMarkComponent, PortableTextBlockComponent, PortableTextListComponent, PortableTextListItemComponent } from '@portabletext/react'
import { PortableTextBlock, TypedObject } from '@portabletext/types'
import { FC } from 'react'
interface LinkProps extends TypedObject {
href: string
openInNewTab: boolean
}
const Link: PortableTextMarkComponent<LinkProps> = ({ value, children }) => {
@gpoole
gpoole / isAssetUploading.ts
Created September 5, 2023 01:19
Detecting a Sanity asset that's currently being uploaded
// Doesn't seem to be officially documented so I had to borrow this from Sanity:
// https://github.com/sanity-io/sanity/blob/30ab832179f8c8dfc6e1e61938ee784c0709cb25/packages/sanity/src/core/preview/components/_extractUploadState.ts#L4
const isAssetUploading = (asset: any) => asset?._upload?.progress != null;