Skip to content

Instantly share code, notes, and snippets.

View edwilliams's full-sized avatar

Ed Williams edwilliams

View GitHub Profile
@edwilliams
edwilliams / spacegray.json
Created May 2, 2026 11:49
Spacegray for Zed by Claude (~/.config/zed/themes/spacegray.json)
{
"$schema": "https://zed.dev/schema/themes/v0.2.0.json",
"author": "Spacegray (ported to Zed)",
"name": "Spacegray",
"themes": [
{
"name": "Spacegray",
"appearance": "dark",
"style": {
"background": "#2b303bff",
@edwilliams
edwilliams / chat-app.js
Created September 17, 2024 12:53
FlatFile DB - cheeky 1 hour experiment
var createError = require('http-errors')
var express = require('express')
var path = require('path')
var cookieParser = require('cookie-parser')
var logger = require('morgan')
var getMsgs = require('./routes/get')
var setMsgs = require('./routes/set')
var app = express()
@edwilliams
edwilliams / app.mjs
Created April 3, 2024 06:52
Minimal no-framework reducer example
import { Main } from "./templates/main.mjs"
let state = { counter: 0 }
const render = () => (document.body.innerHTML = Main({ state }))
const reducer = (e) => {
const { action } = e.target.dataset
const actions = {
@edwilliams
edwilliams / index.html
Created July 12, 2023 08:48
GraphQL Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>GraphQL</title>
</head>
<pre></pre>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>HTMX Demo</title>
</head>
<body>
<button hx-get="/unauthed" hx-swap="outerHTML">unauthed test</button>
@edwilliams
edwilliams / tictactoe.mjs
Last active May 4, 2023 09:47
Noughts and Crosses (TicTacToe) in Rust and Node for comparison
import prompts from 'prompts'
const grid = [0, 0, 0, 0, 0, 0, 0, 0, 0]
/**
* Semantic wrapper for console.log
*/
const render = (val) => console.log(val)
/**
@edwilliams
edwilliams / nextjs-api.ts
Created May 4, 2022 09:36
NextJS API boilerplate
import { verify } from 'utils'
import _create from 'api/app/create'
import _read from 'api/app/read'
import _update from 'api/app/update'
import _delete from 'api/app/delete'
// e.g. /some/endpoint
const ApiApp = async (req, res) => {
const auth = await verify(req.headers.authorization)
if (!auth.success) {
// fixed version of https://javascript.plainenglish.io/introduction-to-redis-and-caching-with-node-js-using-upstash-88efbe39eea2
import express from 'express'
import mongoose from 'mongoose'
import bodyParser from 'body-parser'
import { createClient } from 'redis'
import { v4 as uuidv4 } from 'uuid'

Docker

Create folder with...

  • server.js
const http = require('http')

const server = http.createServer((req, res) => {