Skip to content

Instantly share code, notes, and snippets.

Avatar

Adam Kreczko-Lenner adamkl

View GitHub Profile
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@adamkl
adamkl / example.ts
Last active Aug 4, 2020
Helpers for json-rule-engine
View example.ts
import { processRules, RuleEngineError } from "./ruleEngineHelpers.ts";
const rules = [ruleA, ruleB, ruleC];
const facts = {
fact1: "Some data",
fact2: "Some other data",
fact3: 42
};
View AppContextProvider.tsx
import React from "react";
import { createUserSessionService } from "services/UserSessionService";
import { createNavService } from "services/NavService";
// Wiring up our "IOC container"
const userSessionService = createUserSessionService();
// NavService depends on UserSessionService
const navService = createNavService(userSessionService);
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
@adamkl
adamkl / resolverChaining.ts
Last active Oct 19, 2021
An example of how to chain together local and remote GraphQL resolvers.
View resolverChaining.ts
import {
fetchRemoteSchema,
authLink
} from "@private/graphql-proxy";
import { startGraphQLService } from "@private/graphql-scripts";
import { graphql, printSchema, print, parse } from "graphql";
import {
mergeSchemas,
makeRemoteExecutableSchema,
makeExecutableSchema
@adamkl
adamkl / regen-domain-types.js
Last active Sep 28, 2022
Generating typescript definitions from .graphql files using apollo-codegen and graphql-code-generator
View regen-domain-types.js
const { introspectSchema } = require("apollo-codegen");
const { executeWithOptions } = require("graphql-code-generator/dist/cli");
const fs = require("fs");
const path = require("path");
const graphqlPath = "./src/graphql/";
const schemaInput = "./src/graphql/temp.graphql";
const jsonOutput = "./src/graphql/temp.json";
const dtsOutput = "./src/graphql/domain.d.ts";
View ObjectPooling.cs
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
namespace Pooling
{
public enum LoadingMode { Eager, Lazy, LazyExpanding };