Skip to content

Instantly share code, notes, and snippets.

View tomredman's full-sized avatar

Tom Redman tomredman

View GitHub Profile
@tomredman
tomredman / CLAUDE.md
Created September 2, 2026 14:05
Fix Claude Communication Style for Fable 5.1

For Fable 5.1

Communication style

Mannered prose substitutes metaphor and flourish for direct statement. Instead of "a parameter worth varying," the mannered writer produces "a dial worth turning." Instead of "this point still matters," they write "this point earns its keep." The phrases exist to display the writer, not to convey the idea, and readers can tell. That is why mannered prose irritates: it makes the reader work harder so the writer can perform. It is also imprecise. Metaphors drag in connotations the writer did not choose and cannot control. The fix is to say what you mean. When a literal phrase is available, use it.

Please remove all mannered prose.

Completing work

@tomredman
tomredman / Convex and Cloudflare Example.md
Created March 13, 2026 17:17
Example of using Convex and Cloudflare workers/queues

I create public functions for workers to consume, authenticated by a shared token you generate and store on Convex & Cloudflare:

// convex/fub/worker/api.ts
// consumable by a CF worker
export const getSyncProgress = query({
  args: {
    ...secretArg,
    progressId: v.string(),
  },
@tomredman
tomredman / convex-automation-buildEmailPayload.ts
Created August 13, 2025 23:11
Sending batch emails with Convex & Resend
/**
* Builds an email payload for sending campaign emails through an email service provider.
*
* This function takes campaign details and recipient information to construct a complete
* email payload that includes:
* - Sender information (from name and email)
* - Recipient email
* - Subject line
* - Reply-to address
* - Unsubscribe URL (merged into both HTML and plain text content)
@tomredman
tomredman / .cursorrules
Created January 22, 2025 22:12
.cursorrules for project using Convex, Typescript, React 19, shadcn, TanStack *, etc.
{
"recommendations": {
"convex": {
"fileStructure": {
"queries": "convex/{feature}/queries.ts",
"mutations": "convex/{feature}/mutations.ts",
"actions": "convex/{feature}/actions.ts"
},
"rules": [
"Actions must include 'use node' when using Node.js packages",
@tomredman
tomredman / webhooks.ts
Created February 16, 2024 17:37
Accepting & verifying Facebook webhooks in NextJS
import crypto from "crypto";
import type { NextApiRequest, NextApiResponse } from "next";
import { buffer } from "micro";
export const config = {
api: {
bodyParser: false,
},
};
@tomredman
tomredman / tailwind-colors.js
Last active April 3, 2022 14:57
Index of all possible TailwindCSS 3.0.23 color variables
/**
* Importing this file and applying this string to `className` on a hidden div
* will allow you to dynamically create tailwind components with any color you
* want, because Tailwind will compile and include all the colors it sees in your
* final CSS.
*
* BE WARNED this will increase the size of your compiled CSS file, which negates
* one of Tailwind's killer features: smallest CSS file based on just-what-you-use.
*/
@tomredman
tomredman / CreateNewUser.php
Created November 22, 2020 01:01
CreateNewUser.php
<?php
namespace App\Actions\Fortify;
use App\Models\User;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Laravel\Fortify\Contracts\CreatesNewUsers;
class CreateNewUser implements CreatesNewUsers
@tomredman
tomredman / api.php
Created November 22, 2020 00:59
api-routes.php
/*
|--------------------------------------------------------------------------
| Authentication
|--------------------------------------------------------------------------
*/
Route::post('/register', [UserController::class, 'register']);
Route::post('/login', [UserController::class, 'login']);
Route::post('/logout', [UserController::class, 'logout']);
@tomredman
tomredman / AuthController.php
Created November 22, 2020 00:47
Simple Laravel Sanctum API auth controller for 3rd party/mobile register, login and logout
<?php
namespace App\Http\Controllers\Api;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Auth;
use Illuminate\Auth\Events\Registered;
use App\Actions\Fortify\CreateNewUser;
use Illuminate\Validation\ValidationException;
@tomredman
tomredman / explicit.java
Last active April 13, 2016 13:56
Code Principle Example: "Explicit is better than Implicit"
/**
* You've probably heard it before, "explicit is better than implicit". Here's a simple
* example of that principle in action.
*
* In this example, our app has only two Fragments that can be visible at any given
* moment: CreateFragment and TrendingFragment. Both examples achieve the same result
* when everything is working as expected, however...
*
* In the explicit example, a final else{} branch would indiciate something's not
* quite right with our code somewhere since we know there are only two possible