Skip to content

Instantly share code, notes, and snippets.

View titouancreach's full-sized avatar

Titouan CREACH titouancreach

  • Lorient, France
  • 09:42 (UTC +02:00)
View GitHub Profile
const useMediaRecorder = () => {
const [mediaRecorder, setMediaRecorder] = useState<
Option.Option<Either.Either<MediaRecorder, UnknownException>>
>(Option.none());
const [queue] = useState(() => Effect.runSync(Queue.unbounded<BlobEvent>()));
const cbRef = useRef(Option.none());
useEffect(() => {
type StateMachine = Data.TaggedEnum<{
Recording: {
stream: Stream.Stream<BlobEvent>,
mediaRecorder: MediaRecorder
};
Stoped: {};
}>;
export function TranscribeWhisper({ className }: { className?: string }) {
const { Stoped, Recording, $match, $is } = Data.taggedEnum<StateMachine>();

hook-form / effect-ts resolver thread

Hello, When we use a schema with a non-symmetrical transformation like this one

const Schema = S.Struct({
  createdAt: S.DateFromString
})
port { Chunk, Console, Context, Effect, Layer, Stream } from "effect";
import amqp from "amqplib";
import { NodeRuntime } from "@effect/platform-node";
const make = Effect.gen(function* () {
const connection = yield* Effect.tryPromise(() =>
amqp.connect(
"amqps://***",
),
);
return yield* pipe(
// out
Stream.fromQueue(queue),
Stream.ensuring(Effect.zip(Queue.shutdown(queue), Console.log("Ending")), // Here I would be able to remove the "current" client from the current map of client
Stream.pipeThroughChannel(Socket.toChannel(socket)),
// in
Stream.decodeText(),
Stream.runForEach((message) =>
Effect.gen(function* () {
import { NodeRuntime } from "@effect/platform-node";
import { Schema } from "@effect/schema";
import { startConsumer } from "consumer";
import { Console, Effect, LogLevel, Logger, pipe } from "effect";
const consumer = startConsumer({
queueName: "QueueName",
processFunc: (message) => {
return Console.log("Treated !!", message);
},
import {
DeleteMessageCommand,
ReceiveMessageCommand,
} from "@aws-sdk/client-sqs";
import { Schema } from "@effect/schema";
import { SqsLive, SqsService, getSqslient } from "@repo/shared/src/Sqs";
import { Array, Effect, Option, Schedule, pipe } from "effect";
import { logDebug, logError, logWarning } from "effect/Effect";
function takeFromSqs({ queueUrl }: { queueUrl: string }) {
import { NodeRuntime } from "@effect/platform-node";
import { Schema } from "@effect/schema";
import { SqsLive, SqsService } from "@repo/shared/src/Sqs";
import { Chunk, Console, Effect, Option, Stream, pipe } from "effect";
import { logError, logInfo } from "effect/Effect";
import { Consumer } from "sqs-consumer";
function makeStream<T, U>({
queueName,
@titouancreach
titouancreach / interpolated.lua
Created September 6, 2023 12:35
interpolated string C#
{
"InsertCharPre",
{
pattern = { "*.cs" },
--- @param opts AutoCmdCallbackOpts
--- @return nil
callback = function(opts)
-- Only run if f-string escape character is typed
if vim.v.char ~= "{" then return end
using System;
using System.Text;
using Microsoft.AspNetCore.WebUtilities;
namespace LiveBoat.Web.Services
{
public class ImageProxyOptions
{
public int? Width { get; set; }
public int? Height { get; set; }