Skip to content

Instantly share code, notes, and snippets.

View joshnuss's full-sized avatar
🤘

Joshua Nussbaum joshnuss

🤘
View GitHub Profile
@joshnuss
joshnuss / setup.sh
Last active December 6, 2025 06:10
SvelteKit & Postgres on AWS LightSail
export ASDF_VERSION=0.18.0
export NODE_VERSION=25.2.1
# make sure we're up to date
sudo apt update --yes
# add dependencies for asdf and nodejs
sudo apt install --yes git bash rsync libatomic1
# add asdf
@joshnuss
joshnuss / debug.svelte
Last active November 23, 2025 23:08
Debug view for Rapier2D engine with Svelte
<!--
Usage:
<Debug bind:this={debug} {world} width=800 height=600 scale=10 />
Then during game loop call:
debug.render()
-->
<script lang="ts">
@joshnuss
joshnuss / proxy_function.ts
Created October 9, 2025 16:05
An example of a proxy function
function add(a: number, b: number) {
return a + b
}
function multiply(a: number, b: number) {
return a * b
}
function doubler<T extends Function>(fn: T): T {
return new Proxy(fn, {
apply(target, self, args) {
@joshnuss
joshnuss / perf_proxy.ts
Created October 7, 2025 10:53
Measure performance of functions with a Proxy
function perf<T extends object>(target: T, methods: string[]): T {
return new Proxy(target, {
get(target, key) {
const item = Reflect.get(target, key)
if (!methods.includes(key.toString())) {
return item
}
return (...args: any[]) => {
@joshnuss
joshnuss / logger.ts
Created October 7, 2025 10:40
Function logger using a Proxy
function logger<T extends object>(target: T, methods: string[]): T {
return new Proxy(target, {
get(target, key) {
const item = Reflect.get(target, key)
if (!methods.includes(key.toString())) {
return item
}
return (...args: any[]) => {
@joshnuss
joshnuss / default_snippet.lua
Created September 20, 2025 04:06
Custom Neovim workflows using vim.ui
-- insert a default snippet when file is first opened
local luasnip = require('luasnip')
local collection = require('luasnip.session.snippet_collection')
local util = require('luasnip.util.util')
local default_snippets = {
{ pattern = "/[+]page.svelte$", snippet = "page" },
{ pattern = "/[+]page.js$", snippet = "page" },
{ pattern = "/[+]page.ts$", snippet = "page" },
{ pattern = "/[+]page.server.js$", snippet = "page.server" },
@joshnuss
joshnuss / snippets.lua
Last active September 7, 2025 03:43
neovim snippets from scratch
-- neovim snippets from scratch
local api = vim.api
local Snippets = {
list = {
lua = {
["if"] = "if $ then\nend",
p = "print($)",
func = "function $()\nend"
},
javascript = {
@joshnuss
joshnuss / remark.ts
Last active July 20, 2025 00:46
Unified with Remark, FrontMatter and Shiki
/*
* usage:
*
* // parse markdown
* const file = await parseMarkdown('posts/foo.md')
*
* // extract front matter
* const { title, summary, date, author, tags } = file.data.matter
*
* // access html
@joshnuss
joshnuss / index.html
Last active January 7, 2025 03:13
Signals experiment
<html>
<body>
<h1></h1>
<button onclick="decrement()">-</button>
<button onclick="increment()">+</button>
<script>
function signal(initial, callback = null) {
let value = initial
@joshnuss
joshnuss / epd1in54_V2.py
Created November 27, 2024 13:04
MicroPython driver for WaveShare 1.54" V2
from time import sleep_ms
from machine import SPI, Pin
from framebuf import FrameBuffer, MONO_HLSB
'''
Driver for Waveshare e-Paper 1.54in V2
Note: This is for V2, check for V2 sticker on back of module.
Datasheet: https://files.waveshare.com/upload/e/e5/1.54inch_e-paper_V2_Datasheet.pdf