Skip to content

Instantly share code, notes, and snippets.

@rmarscher
rmarscher / vite-plugin-deploy-cloudflare-pages.ts
Last active April 7, 2025 17:28
Cloudflare Pages Vite deploy plugin for Waku
import { randomBytes } from "node:crypto";
import {
copyFileSync,
existsSync,
mkdirSync,
readdirSync,
renameSync,
rmSync,
writeFileSync,
} from "node:fs";
@rmarscher
rmarscher / use-hash-scroll.ts
Last active February 19, 2025 22:06
Waku useHashScroll hook
import { useEffect, useRef } from "react";
import { useRouter_UNSTABLE as useRouter } from "waku/router/client";
function scrollIntoView(hash: string) {
const elementId = hash.slice(1);
const element = document.getElementById(elementId);
if (!element) {
return false;
}
element.scrollIntoView({ behavior: "auto", block: "start" });
@rmarscher
rmarscher / atomWithActorLogic.ts
Last active October 31, 2024 02:03
atomWithActorLogic.ts - derived atom example to integrate jotai and xstate
import { type Getter, atom, useAtom } from "jotai";
import { useCallback } from "react";
import { useSyncExternalStoreWithSelector } from "use-sync-external-store/shim/with-selector";
import type {
Actor,
ActorOptions,
ActorRefFromLogic,
AnyActorLogic,
AnyActorRef,
} from "xstate";
@rmarscher
rmarscher / ErrorBoundary.tsx
Last active October 24, 2024 21:11
React 19 / Waku Error Boundary
"use client";
// import { isDevelopment } from "#is-development";
import type {
ComponentType,
ErrorInfo,
PropsWithChildren,
ReactNode,
} from "react";
import { Component, createContext, createElement } from "react";
@rmarscher
rmarscher / waku.ts
Last active October 4, 2024 20:59
Waku SST AWS Component
import {
type ComponentResourceOptions,
type Output,
Unwrap,
all,
output,
} from "@pulumi/pulumi";
import * as fs from "node:fs";
import * as path from "node:path";
import type { Bucket } from "../../.sst/platform/src/components/aws/bucket.js";
@rmarscher
rmarscher / vite-plugin-deploy-aws-lambda-sst.patch
Last active September 19, 2024 15:49
Waku AWS Deploy Plugin Patch
diff --git a/packages/waku/src/lib/plugins/vite-plugin-deploy-aws-lambda.ts b/packages/waku/src/lib/plugins/vite-plugin-deploy-aws-lambda.ts
index 09a09d2..452efc7 100644
--- a/packages/waku/src/lib/plugins/vite-plugin-deploy-aws-lambda.ts
+++ b/packages/waku/src/lib/plugins/vite-plugin-deploy-aws-lambda.ts
@@ -1,10 +1,22 @@
import path from 'node:path';
-import { writeFileSync } from 'node:fs';
+import {
+ appendFileSync,
+ cpSync,
@rmarscher
rmarscher / example.html
Created August 1, 2024 04:54
Functions for building a webvtt preview thumbnail file generated by AWS MediaConvert - compatible with media chrome, plyr and other players
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style>
html,
body {
margin: 0;
padding: 0;
@rmarscher
rmarscher / README.md
Last active October 4, 2024 20:53
Waku Cloudflare Pages Dev Server Middleware
@rmarscher
rmarscher / fetch-graphql-schema.js
Created September 16, 2016 21:04
fetch-graphql-schema.js
// A script that can pull down the result of the introspection query
// from a running graphql server.
// Dependencies:
// npm i -S isomorphic-fetch graphql-tag graphql apollo-client
// Usage:
// node fetch-graphql-schema [graphql url]
// Example:
@rmarscher
rmarscher / openbr.rb
Created July 21, 2016 03:48
Homebrew formula for OpenBR with pull #486
class Openbr < Formula
# This should just temporarily override the official homebrew formula
# until the next release. And it is pointing to a commit on the
# master git branch, so use at your own risk. It does seem
# to get things working with the latest Qt version on homebrew.
# See https://github.com/biometrics/openbr/pull/486
# Copy the contents of this file to
# /usr/local/Library/Taps/homebrew/homebrew-science/openbr.rb
desc "Open Source Biometric Recognition"