Skip to content

Instantly share code, notes, and snippets.

View lucas-barake's full-sized avatar

Lucas Barake lucas-barake

View GitHub Profile
@lucas-barake
lucas-barake / .md
Created January 18, 2025 17:59
Refresh Token Strategy w/ Effect

Code

import { HttpBody, HttpClient, HttpClientRequest, HttpClientResponse } from "@effect/platform"
import { Data, DateTime, Effect, Function, Option, Ref, Schedule, Schema, SubscriptionRef } from "effect"

class AuthTokens extends Schema.Class<AuthTokens>("AuthTokens")({
  accessToken: Schema.String.pipe(Schema.Redacted),
@lucas-barake
lucas-barake / event-handler.ts
Last active August 10, 2025 08:05
How I Handle WebSockets in Web Apps
import { Effect, type Schema } from "effect";
export type EventHandler<A, I, X> = {
readonly channel: `/${string}/`;
readonly schema: Schema.Schema<A, I>;
readonly handle: (data: A) => Effect.Effect<void, X, never>;
};
export type InfallibleEventHandler<A, I> = {
[K in keyof EventHandler<A, I, never>]: EventHandler<A, I, never>[K];
@lucas-barake
lucas-barake / .md
Last active August 1, 2025 16:24
i18n with Zod Example

Input schema:

import { z } from "zod";
import { DateTime } from "luxon";
import { type TranslationValues } from "next-intl";

export const createDebtRecurrentOptions = ["WEEKLY", "BIWEEKLY", "MONTHLY"] as const;
export const createDebtTypeOptions = ["SINGLE", "RECURRENT"] as const;
@lucas-barake
lucas-barake / methods.md
Last active August 26, 2023 13:13
JavaScript: When to use array methods

.forEach()

The .forEach() method is used to execute a function for each element in the array.

["๐Ÿ", "๐ŸŽ", "๐Ÿ", "๐ŸŽ", "๐ŸŽ"].forEach((fruit) => console.log(fruit)) -> ๐Ÿ, ๐ŸŽ, ๐Ÿ, ๐ŸŽ, ๐ŸŽ

@lucas-barake
lucas-barake / setup-express-typescript.md
Last active May 20, 2025 15:19
Setting up a TypeScript Express Project

1. Initialize the TypeScript Environment

To get started, install TypeScript as a development dependency:

npm i -D typescript ts-node

Next, initialize the TypeScript configuration file:

@lucas-barake
lucas-barake / .md
Last active April 20, 2023 20:41
Multiple Git Accounts in Windows

1. Start OpenSSH Authentication Agent Service

Start by enabling OpenSSH Authentication Agent.

Open Services, right click OpenSSH Authentication Agent, click Properties, change Startup type to Automatic, hit Apply, then right click once again, and click Start.

2. Generate the SSH Key Pairs

Go over to the .ssh folder in your user, and type the following command in PowerShell:

@lucas-barake
lucas-barake / .md
Last active February 18, 2025 09:07
Multiple Git Accounts in WSL2

Step 1

Create the .ssh folder

Run these commands to create a new .ssh folder if you don't already have one:

mkdir ~/.ssh
chmod 700 ~/.ssh
@lucas-barake
lucas-barake / .json
Created August 24, 2022 23:32
Warning ESLint Rules
"rules": {
"indent": [1, 2],
"quotes": [1, "double"],
"semi": [1, "always"],
"jsx-quotes": [1, "prefer-double"],
"react/react-in-jsx-scope": "off",
"react/button-has-type": [1],
"react/prop-types": [1],
"react/jsx-key": [1],
"react/no-array-index-key": [1],