Skip to content

Instantly share code, notes, and snippets.

View schickling's full-sized avatar
Making the web better

Johannes Schickling schickling

Making the web better
View GitHub Profile
/* eslint-disable prefer-arrow/prefer-arrow-functions */
/// <reference no-default-lib="true" />
/// <reference lib="esnext" />
/// <reference lib="dom" />
import type { RuntimeFiber } from '@effect/io/Fiber'
import * as FiberRef from '@effect/io/FiberRef'
import * as Scheduler from '@effect/io/Scheduler'
@schickling
schickling / flake.nix
Created September 28, 2023 13:00
Node.js 16 Nix flake
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/release-23.05";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
import type { Otel, Scope } from '@overtone/utils/effect'
import { Duration, Effect, Either, pipe, Request, RequestResolver } from '@overtone/utils/effect'
export type MakeArgs<TTag extends string, C, E, A, E2, A2> = {
tag: TTag
fetchResources: (resourceIds: ReadonlyArray<string>) => Effect.Effect<C, E, A[]>
mapResult?: (fetchedResources: A) => Either.Either<E2, A2>
batchTimeoutMs?: number
batchCapacity: number
cache?: {
import * as Context from '@effect/data/Context'
import * as Duration from '@effect/data/Duration'
import type * as Either from '@effect/data/Either'
import { pipe } from '@effect/data/Function'
import * as Deferred from '@effect/io/Deferred'
import * as FiberRefs from '@effect/io/FiberRefs'
import * as Queue from '@effect/io/Queue'
import * as Effect from './Effect.js'
import * as Otel from './Otel/index.js'
import * as Data from '@effect/data/Data'
import { pipe } from '@effect/data/Function'
import * as Effect from '@effect/io/Effect'
import * as msgpack from 'msgpackr'
import * as Otel from './Otel/index.js'
export const fetchHead = (
url: string | URL,
headers?: HeadersInit,
@schickling
schickling / flake.nix
Last active August 7, 2023 14:20
Random Node Effect image utils
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/master";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
import * as Data from '@effect/data/Data'
import { pipe } from '@effect/data/Function'
import * as Effect from '@effect/io/Effect'
import * as msgpack from 'msgpackr'
import * as Otel from './Otel/index.js'
export const fetchHead = (
url: string | URL,
headers?: HeadersInit,
/* eslint-disable prefer-arrow/prefer-arrow-functions */
export * from '@effect/io/Scheduler'
import * as Scheduler from '@effect/io/Scheduler'
// Based on https://github.com/Effect-TS/io/blob/main/src/Scheduler.ts#L63
export class ReactAwareScheduler implements Scheduler.Scheduler {
private running = false
private tasks = new Array<Scheduler.Task>()
/* eslint-disable prefer-arrow/prefer-arrow-functions */
/**
* fork of https://github.com/astoilkov/main-thread-scheduling
*
* node compatibility
* removal of visible priority
* reversal of task order
*/
import * as Effect from '@effect/io/Effect'
import React from 'react'
const PR = Math.round(window.devicePixelRatio || 1)
const FRAME_BAR_WIDTH = 2
export type FPSMeterProps = {
width?: number
height?: number
systemFps?: number