apt-get install -y podman
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
| # This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node | |
| # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs | |
| name: Node.js CI | |
| on: | |
| push: | |
| branches: ["main"] | |
| pull_request: | |
| branches: ["main"] |
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
| #!/usr/bin/env node | |
| /** | |
| * Generate a module.d.ts types from the config file using json-ts. | |
| * | |
| * Using a rollup plugin to generate a "virtual:config" we now have | |
| * access to type-safe runtime configuration: | |
| * | |
| * import { config } from "config"; | |
| */ |
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 Papa from "papaparse"; | |
| import fs from "node:fs"; | |
| const currencies = () => { | |
| const data = fs.readFileSync("./currency.csv").toString(); | |
| const result = Papa.parse(data); | |
| const currencies = Array.from( | |
| new Set( | |
| result.data |
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 { DynamoDBClient, GetItemCommand } from "@aws-sdk/client-dynamodb"; | |
| import { | |
| DynamoDBDocumentClient, | |
| QueryCommand, | |
| GetCommand, | |
| PutCommand, | |
| PutCommandOutput, | |
| } from "@aws-sdk/lib-dynamodb"; | |
| type PathToType<T> = T extends `:${infer N}` |
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
| type RequiredDefined<T extends Record<string, unknown>> = { | |
| [key in keyof T]-?:NonNullable<T[key]> | |
| } | |
| export function assertOptions<Options extends Record<string, unknown>, Keys extends keyof Options, Result extends Pick<Options, Keys>>(options:Options, ...keys:Keys[]):RequiredDefined<Result> { | |
| const result = {} as Record<string, unknown> | |
| for (let key of keys as string[]) { | |
| if (options[key] === undefined) { | |
| throw new TypeError(`Expected ${String(key)} to be defined`); |
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 { useState } from "react"; | |
| type ValidationValues = Record<string, unknown>; | |
| type ValidationFunction<T> = (v: T) => string | void; | |
| export type ValidationErrors = Record<string, string[]>; | |
| function runValidation( | |
| key: string, | |
| validators: ValidationFunction<unknown>[], |
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
| INPUT_FILE=yourfilehiere.mov | |
| OUTPUT_FILE=outputname.gif | |
| ffmpeg -i $INPUT_FILE -vf "fps=16,scale=960:-1:flags=lanczos,split[s0][s1];[s0]palettegen=max_colors=32:reserve_transparent=0[p];[s1][p]paletteuse" $OUTPUT_FILE |
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 { suite, test, TestContext } from "./mtap"; | |
| suite("test label", ({ test }) => { | |
| test("another test", (t:TestContext) => { | |
| t.assert("OK computer"); | |
| t.assert(false, "intentionally failed"); | |
| }); | |
| test("hula hoop", (t:TestContext) => { | |
| t.assert(true, "juhu"); |
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 { set, get, createStore, UseStore, values, clear } from 'idb-keyval'; | |
| export abstract class Ministor<ItemType> { | |
| private db: UseStore; | |
| constructor() { | |
| const ns = this.constructor.name; | |
| this.db = createStore(ns, [ns, "items"].join(":")); | |
| } |