This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///// Example usage of inheritance using class functions | |
///// Demonstrates how object-oriented programming | |
///// can be achieved through clever use of functional | |
///// programming patterns. | |
type Ty = { symbol: symbol; parent?: Ty }; | |
type Class = { __ty: Ty }; | |
type Constructor = (...args: any) => Record<string, any>; | |
type ClassInterface<C extends Constructor> = ((...args: Parameters<C>) => ReturnType<C> & Class) & { | |
isInstance(obj: Class): obj is ReturnType<C> & Class; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import type { Prettify } from 'ts-essentials'; | |
export type Result<T = unknown, E = unknown> = Success<T> | Failure<E>; | |
export interface Success<T> { | |
kind: 'success'; | |
value: T; | |
} | |
export interface Failure<E> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from http.server import BaseHTTPRequestHandler, HTTPServer | |
import ssl | |
import base64 | |
# Test of the docker login authentication mechanism for building an authentication proxy. | |
# NB: you may want to remove the SSL configuration below or generate certificate using: | |
# openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout ./server.key -out ./server.crt | |
# | |
# USAGE: | |
# python server.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ pkgs ? import <nixpkgs> {} }: | |
let | |
version = "1.0.5"; | |
src = pkgs.fetchurl { | |
url = "https://github.com/localstack/localstack-desktop/releases/download/${version}/LocalStack-Desktop-community-${version}.AppImage"; | |
sha256 = "sha256-Q6lnv8OGGztqMVVisLhU/lh5qmsG2FqH21lhKupwzys="; | |
}; | |
in | |
pkgs.buildFHSUserEnv { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type ObjectPick< | |
T extends Record<string, unknown>, | |
K extends keyof T, | |
V extends T[K], | |
> = T extends Record<K, infer U> ? ([U] extends [V] ? T : never) : never; | |
type ObjectOmit< | |
T extends Record<string, unknown>, | |
K extends keyof T, | |
V extends T[K], |