Skip to content

Instantly share code, notes, and snippets.

View titouancreach's full-sized avatar

Titouan CREACH titouancreach

  • Lorient, France
  • 11:26 (UTC +02:00)
View GitHub Profile
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; }
let ( |> ) x f = f x;;
let printarray a =
let rec printlist = function
| head :: rest -> print_char head; printlist rest;
| [] -> print_newline () in
printlist (Array.to_list a);;
@titouancreach
titouancreach / what-forces-layout.md
Created October 19, 2018 08:14 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
const matchString = (s, patterns) => {
if (patterns.length === 0) {
throw new Error('Not exhaustive string matching');
}
const [matching, ...rest] = patterns;
const [re, fn] = matching;
if (re.test(s)) {
const matches = re.exec(s);
return matches ? fn(...matches) : fn();
}