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
@schickling
schickling / fix-lock-file.yml
Created November 9, 2024 16:34
GitHub action fix pnpm lock file
name: Fix Lock File and Create PR
on:
push:
branches:
- '**' # Run on every branch push
permissions:
contents: write
pull-requests: write
{ lib, stdenv, fetchurl, unzip }:
let
# https://docs.dagger.io/install
version = "0.12.5"; # Replace with the actual version you want to install
system = stdenv.hostPlatform.system;
# Map Nix system to Dagger's OS and architecture naming
systemMap = {
"x86_64-linux" = { os = "linux_amd64"; sha256 = ""; };
@schickling
schickling / Uint8ArrayList.ts
Created August 12, 2024 13:46
Effect schema Uint8ArrayList
import { Schema } from '@effect/schema'
/**
* The encoded structure is alternating 4 bytes to represent the length of the following Uint8Array,
* followed by the Uint8Array itself, repeated.
*/
export const Uint8ArrayList = Schema.transform(Schema.Uint8ArrayFromSelf, Schema.Array(Schema.Uint8ArrayFromSelf), {
decode: (encodedArrayList) => {
const arrayList: Uint8Array[] = []
@schickling
schickling / flake.nix
Created January 18, 2024 15:15
Node.js 16 Nix
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/release-23.11";
nixpkgsOld.url = "github:NixOS/nixpkgs/release-23.05";
nixpkgsUnstable.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, nixpkgsOld, nixpkgsUnstable, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
import { describe, expect, it } from 'vitest'
import { Equal } from '../index.js'
import * as Schema from './index.js'
import { JsonWrapper, jsonWrapper } from './SchemaJsonWrapper.js'
describe('wrapper', () => {
it('wrapper', () => {
const wrapped = jsonWrapper(Schema.number)
const decoded = Schema.parseSync(wrapped)(10)
/* 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,