Skip to content

Instantly share code, notes, and snippets.

View hastebrot's full-sized avatar

Benjamin Gudehus hastebrot

  • Freiheit.com
  • Hamburg, Germany
  • 09:07 (UTC +02:00)
View GitHub Profile

What is a Workflow?

In digital commerce you typically have many systems involved in your operations. For example, you may have an ERP system that holds product master data and accounting reports, a CMS system for content, a CRM system for managing customer campaigns, a payment service to process credit cards, and so on. Sometimes you may even have custom built applications that need to participate in the commerce stack. One of the biggest challenges when operating a stack like this is ensuring consistency in the data spread across systems.

import { cleanup, render, waitFor } from "@testing-library/react";
import { userEvent } from "@testing-library/user-event";
import { ColumnDataType, Compilable, Kysely } from "kysely";
import { action, observable } from "mobx";
import { observer } from "mobx-react-lite";
import { useEffect, useState } from "react";
import { beforeEach, expect, describe as suite, test } from "vitest";
import { z } from "zod/v4";
import { throwError } from "../../src/helpers/error";
import { createDatabaseWithSqlocal } from "../../src/helpers/sqlocal";
type NonEmptyArray<T> = [T, ...T[]];
const okay: NonEmptyArray<number> = [1, 2];
const alsoOkay: NonEmptyArray<number> = [1];
const err: NonEmptyArray<number> = []; // error!
import { z } from "zod/v4";
const Foo = z.string().array().nonempty();
type Foo = z.infer<typeof Foo>;
const NonEmpty = z.tuple([z.string()], z.string());
// ❯ bun add -d [email protected] vitest zod
// ❯ bun run test --watch signia.test.tsx
import { atom, computed, type Atom, type Computed, type Signal } from "signia";
import { expect, test } from "vitest";
import { z } from "zod";
// repo for "signia" package: https://github.com/tldraw/signia
test("signia condition with atom() and computed()", () => {
// ❯ bun add -d signia vitest zod
// ❯ bun run test --watch graph.test.ts
import { atom, computed, type Atom, type Computed, type Signal } from "signia";
import { expect, test } from "vitest";
import { z } from "zod";
test("signal graph", () => {
const BlockProps = z.object({
field1Input: zodAtom<number>(),
@font-face {
font-family: 'JetBrains Mono';
font-style: normal;
font-weight: 100;
src: local("JetBrains Mono Thin"), local("JetBrainsMono-Thin"), url("../fonts/webfonts/JetBrainsMono-Thin.woff2") format("woff2");
font-display: swap; }
@font-face {
font-family: 'JetBrains Mono';
font-style: italic;
@hastebrot
hastebrot / isogit.ts
Last active May 27, 2022 16:51
isomorphic-git in deno
#!/usr/bin/env -S deno run --no-check --allow-env --allow-read --allow-write --allow-net isogit.ts
import fs from "https://deno.land/[email protected]/node/fs.ts";
import path from "https://deno.land/[email protected]/node/path.ts";
import git from "https://esm.sh/[email protected]";
import http from "https://esm.sh/[email protected]/http/node.js";
const repositoryDir = path.join(Deno.cwd(), "/../test-repository");
const repositoryUrl = "https://github.com/isomorphic-git/lightning-fs";
await git.clone({
// https://stackoverflow.com/questions/7487917/convert-byte-array-to-escaped-string
fun encodeToEscapedString(bytes: ByteArray): String {
// 0x00..0x1f = non-printing characters
// 0x20 = SPACE
// 0x21..0x7e = printing characters
// 0x7f = DELETE
val string = StringBuilder()
val intSize = 0xff
val byteRange = 0x20..0x7e
for (byte in bytes) {
text = """Text attributes _italic_, **bold**, `monospace`. Some implementations may use *single-asterisks* for italic text."""
expected = """<p>Text attributes <em>italic</em>, <strong>bold</strong>, <code>monospace</code>. Some implementations may use <i>single-asterisks</i> for italic text.</p>"""
def lookup(text, start, size):
return text[start:start+size]
token_italic = "_"
token_italic_alt = "*"
token_strong = "**"

From SQL to Neo4j: Northwind

SQL Model

Neo4j Model

Get the SQL Dump

The SQL dump was stolen from here and imported into MySQL.