Skip to content

Instantly share code, notes, and snippets.

View audionerd's full-sized avatar

Eric Skogen audionerd

View GitHub Profile
@audionerd
audionerd / opencode-session-completion.zsh
Created February 24, 2026 17:31
opencode session fzf completion for zsh
# requires fzf and jq
# fzf-powered completion for: opencode -s / --session
_opencode_session_ids_fzf() {
local selected id
selected="$(
opencode session list --format json 2>/dev/null \
| jq -r '
def fmt($ms):
($ms / 1000 | floor | strflocaltime("%-I:%M %p · %-m/%-d/%Y"));
.[]
@audionerd
audionerd / import_map.json
Last active March 10, 2023 07:24
using @xstate/react v2.0.1 in a deno fresh app
{
"react": "https://esm.sh/@preact/compat",
"use-isomorphic-layout-effect": "https://esm.sh/*use-isomorphic-layout-effect?alias=react:preact/compat&deps=react",
"use-sync-external-store/": "https://esm.sh/*use-sync-external-store/",
"use-subscription": "https://esm.sh/*use-subscription?alias=react:preact/compat&deps=react",
"xstate": "https://esm.sh/*xstate@4.37.0?alias=react:preact/compat&deps=react",
"@xstate/react": "https://esm.sh/*@xstate/react@2.0.1?alias=react:preact/compat&deps=react"
}
@audionerd
audionerd / m5stack-rca-module.ino
Last active January 6, 2023 02:48
Playing Audio from the M5Stack RCA Module 13.2
// M5Stack Core Basic + RCA Module 13.2 (PCM5102)
// based on https://github.com/m5stack/M5Stack/blob/b3e801f/examples/Unit/RCA/RCA.ino
#include <M5Unified.h>
void setup() {
auto cfg = M5.config();
cfg.external_spk = true;
cfg.internal_spk = false;
@audionerd
audionerd / atom-script-babel-upgrade.md
Created February 5, 2019 18:38
Using rgbkrk/atom-script and the latest version of Babel

Using the latest version of Babel with rgbkrk/atom-script

Update Babel CLI

cd ~/.atom/packages/script
npm uninstall --save-optional babel-cli
npm install --save-optional @babel/cli@latest
npm install --save-dev @babel/preset-env@latest
npm install --save-dev @babel/core@latest
@audionerd
audionerd / supersaw-shooter.scd
Last active May 5, 2025 17:33
SuperSaw (Roland JP-8000 and JP-8080) in SuperCollider
// via https://web.archive.org/web/20191104212834/https://www.nada.kth.se/utbildning/grukth/exjobb/rapportlistor/2010/rapporter10/szabo_adam_10131.pdf
(
{ | freq = 523.3572, mix=0.75, detune = 0.75 |
var detuneCurve = { |x|
(10028.7312891634*x.pow(11)) -
(50818.8652045924*x.pow(10)) +
(111363.4808729368*x.pow(9)) -
(138150.6761080548*x.pow(8)) +
(106649.6679158292*x.pow(7)) -
@audionerd
audionerd / xstate-react-hooks.js
Created October 31, 2018 20:01
using xstate with react hooks
import React, { useState, useEffect, useMemo } from 'react'
import { Machine } from 'xstate'
import { interpret } from 'xstate/lib/interpreter'
const toggleMachine = Machine({
id: 'toggle',
initial: 'inactive',
states: {
inactive: {
on: { TOGGLE: 'active' }
Idle
Artwork
Draw
Draw Idle
Draw Drawing
Marquee
Marquee Idle
Marquee Drawing Freeform
Marquee Drawing Line
Marquee Moving Artwork
Workspace
text focus -> Text Entry Mode
toolbar marquee tool -> Marquee Selection Mode
Drawing Mode
pointerdown -> Drawing
pointerup -> Drawing Idle
option key & pointerdown -> Erasing
Drawing Idle*
Drawing
-- via https://stackoverflow.com/questions/5723154/truncate-a-string-in-the-middle-with-javascript
-- https://stackoverflow.com/questions/831552/ellipsis-in-the-middle-of-a-text-mac-style/36470401#36470401
function truncateMiddle (str, maxLength, separator)
maxLength = maxLength or 30
separator = separator or "…"
if (maxLength < 1) then return str end
if (string.len(str) <= maxLength) then return str end
if (maxLength == 1) then return string.sub(str, 0, 1) .. separator end
@audionerd
audionerd / spout.lua
Created May 31, 2018 04:09
spout for norns
-- spout.
--
-- key2 = sample A
-- key3 = sample B
-- enc2 = tempo
-- enc3 = rate selection
--
engine.name = 'Ack'