Skip to content

Instantly share code, notes, and snippets.

@mkrause
mkrause / schemaFromPropertySignature.ts
Created November 13, 2024 17:16
A function to get a Schema from a PropertySignature in Effect Schema
import { Effect, Option } from 'effect';
import { Schema as S, AST, ParseResult } from '@effect/schema';
const assertUnreachable = (x: never): never => {
throw new Error('Unexpected case');
};
// Similar to built-in `NonNullable`, but only for `undefined`
type NonUndefined<T> = T extends undefined ? never : T;
@mkrause
mkrause / plopfile.ts
Created November 12, 2024 16:56
Plop helper for generating relative import paths
import * as path from 'node:path';
import { type HelperOptions } from 'handlebars';
import { type NodePlopAPI } from 'plop';
export default (plop: NodePlopAPI) => {
// Compute the relative path from the component file to the given target path.
plop.setHelper('relative-path', (pathTargetFromCwd, options: HelperOptions) => {
if (typeof pathTargetFromCwd !== 'string') { throw new Error(`Missing argument to 'relative-path' helper`); }
This file has been truncated, but you can view the full file.
/* Generated on 2024-06-27T21:23:30.914Z from OpenSearch API Specification version 1.0.0 */
import { pipe, Option } from 'effect';
import { Schema as S } from '@effect/schema';
/* transforms_commonTermsGroup */
export const transforms_commonTermsGroup = S.Struct({
source_field: S.optional(S.String),
@mkrause
mkrause / spectacular_spiders.js
Created August 11, 2018 18:20
Spectacular Spiders puzzle
/*
"Spectacular Spiders" puzzle.
*/
"use strict";
/*
piece: particular puzzle piece (physical object)
placement: a piece in a certain orientation (placed on a tile)
@mkrause
mkrause / .babelrc
Last active August 18, 2017 10:58
Basic webpack setup
{
presets: [
'react',
['env', {
// Support last 2 browser versions, plus IE 11+
// Cf. http://2ality.com/2017/02/babel-preset-env.html
targets: { browsers: ["last 2 versions", "ie >= 11"] },
// https://github.com/babel/babel-preset-env/issues/203
useBuiltIns: true,