Skip to content

Instantly share code, notes, and snippets.

/**
* Utility functions for creating `PromiseSettledResult` instances.
*
* Provides methods to construct fulfilled and rejected promise results,
* ensuring they resolve asynchronously.
*/
const PromiseSettledResult = {
/**
* Creates a fulfilled `PromiseSettledResult`.
*
import { Effect, Layer, Stream } from "effect";
import { handleOntraportCreateContact } from "./handle-ontraport-create-contact";
import { handleProccesMetricsUpload } from "./handle-process-metrics-upload";
import { handleSendVerificationEmail } from "./handle-send-verification-email";
import { Message } from "./message";
import { Postgres } from "./postgres";
import { RetryPolicy } from "./retry-policy";
import { flatten } from "flat";
export type JobStatus = "new" | "locked" | "completed" | "error";
import { Schedule } from 'effect';
import type { Duration, DurationInput } from 'effect/Duration';
/**
* Configuration options for exponential backoff retry strategy
*
* Defines the parameters for configuring a retry mechanism with exponential backoff
*
* @property {DurationInput} delay - Initial delay between retry attempts. Defaults to 100ms.
* @property {number} [growthFactor=2.0] - Factor by which the delay increases exponentially.
/**
* Utility functions for creating `PromiseSettledResult` instances.
*
* Provides methods to construct fulfilled and rejected promise results,
* ensuring they resolve asynchronously.
*/
const PromiseSettledResult = {
/**
* Creates a fulfilled `PromiseSettledResult`.
*
import { Data } from 'effect';
import type { StandardSchemaV1 } from '@standard-schema/spec';
import { type ResultAsync, errAsync, okAsync } from 'neverthrow';
export class ParseError extends Data.TaggedError('ParseError')<{
response: Response;
issues: ReadonlyArray<StandardSchemaV1.Issue>;
}> {}
export class UnexpectedError extends Data.TaggedError('UnexpectedError')<{
# glitch_eventsub.gleam
websocket_message.NotificationMessage(metadata, payload) -> {
// process.send(state.websocket_message_mailbox, message)
io.println("")
io.println("eventsub client - notification message")
io.debug(payload)
io.println("")
let assert Ok(subject) =
export function mockFromArbitrary<T>(arbitrary: Arbitrary<T>): T {
return fc.sample(arbitrary, 1)[0];
}
export function mockArrayFromArbitrary<T>(
arbitrary: Arbitrary<T>,
count?: number,
): T[] {
return fc.sample(arbitrary, count);
}
return {
{
"rcarriga/nvim-notify",
keys = {
{
"<leader>un",
function()
require("notify").dismiss({ silent = true, pending = true })
end,
desc = "Dismiss All Notifications",
@dmmulroy
dmmulroy / foobar.ts
Last active March 22, 2024 21:04
pure ts module based programming example
// Your module (i.e. file is for providing and working with one main type)
export type FooBar = {
foo: string;
bar: number;
then: (fn: (foobar: FooBar) => FooBar) => FooBar;
map: <T>(fn: (foobar: FooBar) => T) => T;
};
function make({ foo = "", bar = 0 }: Readonly<{ foo?: string; bar?: number }>) {
const foobar: FooBar = {
@dmmulroy
dmmulroy / gleam_ts_gen.d.ts
Created March 14, 2024 01:05
Generating TypeScript declaration files with Gleam
import type * as $io from "../gleam_stdlib/gleam/io.d.mts";
import type * as _ from "./gleam.d.mts";
export class User extends _.CustomType {
constructor(id: string, username: string, role: Role$);
id: string;
username: string;
role: Role$;
}