Skip to content

Instantly share code, notes, and snippets.

View jessekelly881's full-sized avatar
๐Ÿ˜Ž
Probably Programming

Jesse Kelly jessekelly881

๐Ÿ˜Ž
Probably Programming
View GitHub Profile
@jessekelly881
jessekelly881 / effect-ddd.ts
Created July 21, 2025 17:23
Example of Domain Driven Design using Effect
import { Context, DateTime, Effect, Schema, PubSub } from "effect";
export const OrderId = Schema.String.pipe(Schema.brand("OrderId"));
export type OrderId = typeof OrderId.Type;
export class Order extends Schema.Class<Order>("Order")({
id: OrderId,
}) {}
export class OrderPlacedEvent extends Schema.Class<OrderPlacedEvent>(
@jessekelly881
jessekelly881 / email.ts
Created February 11, 2025 18:46
Email service
import { Config, Context, Effect, Option, Schedule, Schema } from "effect";
import { Resend } from "resend";
import { EmailRepo } from "../../modules/email/repo";
import { HashId } from "../hashId";
import { EmailAddress, Event, OneTimeCode, User } from "@eventmind/domain";
import type { Mjml2HtmlOptions } from "mjml-react";
import { EventRepo } from "../../modules/event/repo";
import { UserRepo } from "../../modules/user/repo";
import * as EventCancelledEmail from "./emails/eventCancelled";
@jessekelly881
jessekelly881 / HashedId.ts
Created September 6, 2024 02:59
Encodes a number to a string using `hashids`. Provides a HashedIdConfig Tag to configure salt, etc.
import { Schema } from "@effect/schema";
import { Context, Effect, Option } from "effect";
import Hashids from 'hashids';
// const hashids = new Hashids()
/**
* Configuration for `hashids`. Default is `new Hashids()`.
*
* @since 1.0.0
@jessekelly881
jessekelly881 / effect-tanstack-form.ts
Last active November 5, 2025 21:24
Effect adaptor for tanstack form
import { ArrayFormatter, Schema } from "@effect/schema";
import { ValidationError } from "@tanstack/react-form";
import { Effect, Either, Exit, ManagedRuntime, Layer } from "effect";
export const createValidator = <R, E>(layer: Layer.Layer<R, E, never>) => {
const runtime = ManagedRuntime.make(layer);
return {
effectValidator: () => ({
validate(
@jessekelly881
jessekelly881 / optionalTextProp.test.ts
Last active May 17, 2024 13:11
Schema optionalTextProp
it("optionalTextProp", (ctx) => {
const schema = Schema.Struct({
text: SchemaUtils.optionalTextProp(Schema.String)
});
const decode = Schema.decodeSync(schema);
const encode = Schema.encodeSync(schema);
ctx.expect(decode({})).toEqual({ text: Option.none() });
ctx.expect(decode({ text: "" })).toEqual({ text: Option.none() });
ctx.expect(decode({ text: " " })).toEqual({ text: Option.none() });
@jessekelly881
jessekelly881 / effect-yaml.ts
Created November 6, 2023 03:34
Effect helpers for yaml
import { ParseResult, Schema } from "@effect/schema";
import YAML from "yaml";
export const parseYaml = <I, A extends string>(self: Schema.Schema<I, A>) =>
Schema.transformOrFail(
self,
Schema.unknown,
(s, _, ast) => {
try {
return ParseResult.success<unknown>(YAML.parse(s));
@jessekelly881
jessekelly881 / carbon.json
Last active November 7, 2022 15:50
PD Carbon Theme
[
{
"id": "theme:pd-dark",
"name": "ProjectDiscovery Dark Theme",
"highlights": {
"background": "#27272A",
"text": "#71717A",
"variable": "#FFF",
"variable2": "white",
"variable3": "white",
@jessekelly881
jessekelly881 / DOB.ts
Last active April 19, 2021 18:53
human-ts
interface DOB {
dob: Date;
}
const age = (dob: DOB) => 0;
const colors = require("tailwindcss/colors");
module.exports = {
theme: {
spacing: {
sm: "1rem",
md: "2rem",
lg: "4rem",
xl: "8rem",
},