Skip to content

Instantly share code, notes, and snippets.

View adamkl's full-sized avatar

Adam Kreczko-Lenner adamkl

View GitHub Profile
@adamkl
adamkl / ObjectPooling.cs
Created June 17, 2016 19:02
Object pooling
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
namespace Pooling
{
public enum LoadingMode { Eager, Lazy, LazyExpanding };
@adamkl
adamkl / example.ts
Last active August 4, 2020 04:29
Helpers for json-rule-engine
import { processRules, RuleEngineError } from "./ruleEngineHelpers.ts";
const rules = [ruleA, ruleB, ruleC];
const facts = {
fact1: "Some data",
fact2: "Some other data",
fact3: 42
};
@adamkl
adamkl / machine.js
Created December 4, 2019 17:06
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
@adamkl
adamkl / machine.js
Last active August 4, 2020 04:37
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
@adamkl
adamkl / machine.js
Last active October 8, 2020 20:28
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@adamkl
adamkl / resolverChaining.ts
Last active October 19, 2021 12:46
An example of how to chain together local and remote GraphQL resolvers.
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 / AppContextProvider.tsx
Created February 10, 2020 22:20
xState service layer
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);
@adamkl
adamkl / regen-domain-types.js
Last active September 28, 2022 15:04
Generating typescript definitions from .graphql files using apollo-codegen and graphql-code-generator
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";