Skip to content

Instantly share code, notes, and snippets.

View joshnuss's full-sized avatar
🤘

Joshua Nussbaum joshnuss

🤘
View GitHub Profile
@joshnuss
joshnuss / setup.js
Last active February 5, 2024 07:01
Vitest matchers for SvelteKit errors and redirections
import { expect } from 'vitest'
expect.extend({
async toError(promise, status, message=null) {
try {
await promise
return { pass: false, message: () => 'Expected an error to be raised.'}
} catch (actual) {
if (actual?.constructor?.name !== 'HttpError') {
@joshnuss
joshnuss / README.md
Last active November 18, 2023 06:02
Excellon drill format
<script>
import * as THREE from 'three'
import { SVGLoader } from 'three/examples/jsm/loaders/SVGLoader.js'
import { T, useThrelte } from '@threlte/core'
import { onMount } from 'svelte'
const { invalidate } = useThrelte()
const loader = new SVGLoader()
let wrapper
@joshnuss
joshnuss / .projections.json
Created May 5, 2023 21:48
vim-projectionist example for SvelteKit
{
"src/routes/*page.svelte": {
"alternate": [
"src/routes/{}page.js",
"src/routes/{}page.server.js"
],
"template": [
"<script>",
" export let data",
"</script>"
@joshnuss
joshnuss / README.md
Last active April 12, 2023 09:46
Prisma snippets

Prisma Snippets

For ViM and VSCode.

Commands

  • model<tab>: defines a model
  • field<tab>: defines a field
  • index<tab>: defines an index
  • unique: defines a unique index
@joshnuss
joshnuss / .bash_aliases
Last active March 24, 2023 14:45
Bash aliases for creating a SvelteKit project with Prisma
# Create a vanilla SvelteKit project
# usage: sk <folder-name>
sk() {
pnpm create svelte@latest $1 \
&& cd $1 \
&& pnpm install \
&& git init \
&& git add . \
&& git commit -m 'Initial commit'
}
@joshnuss
joshnuss / BUILD_LOG.md
Last active January 13, 2023 19:19
Build progress for 24-hour startup

The idea

A way to create physical signage for a business by uploading the company's logo. The app will use a 3rd party to 3D print or laser cut the sign.

Main flow

  1. Upload a logo in SVG format
  2. Choose fabrication style (3d print, laser cut) and colors
  3. Place the order
snippet model "define a model"
model ${1:Name} {
id Int @id @default(autoincrement())
${2}
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
snippet enum "define an enum"
@joshnuss
joshnuss / etl-example.js
Last active September 21, 2022 02:53
Cloud-native ETL
/*
data can enter the pipeline via push or pull.
the result of each intermediate step is stored (so errors can be retried)
at the end of the pipeline data is put into a document store
optionally, event handlers can listen to create/update/delete events and fan data out to other systems
*/
// example of a push handler (aka webhooks)
// src/push/shopify/order/created.js
// receive events, and returned data is stored in ClickHouse (OLAP) by the framework.
@joshnuss
joshnuss / neuron.js
Last active August 5, 2022 04:22
Simple neuron
/* activation functions */
// linear activation (no-op)
function linear(value) { return value }
// threshold activation
function threshold(x = 0) {
return (value) => value >= x ? 1 : 0
}