Skip to content

Instantly share code, notes, and snippets.

View tom-sherman's full-sized avatar

Tom Sherman tom-sherman

View GitHub Profile
<?xml version="1.0" encoding="utf-8"?>
<rbl:kb xmlns:rbl="http://rbl.io/schema/RBLang">
<concept name="person" type="string" />
<concept name="language" type="string" />
<concept name="country" type="string" />
<rel name="speaks" subject="person" object="language" plural="true">
<firstForm>Does %S speak %O</firstForm>
<secondFormSubject>Who speaks %O?</secondFormSubject>
<secondFormObject>What language does %S speak?</secondFormObject>
@tom-sherman
tom-sherman / rb-xq-cookbook.md
Last active March 6, 2019 16:27
Rainbird xq / jq cookbook

Rainbird xq Cookbook

Installation

  1. Follow this guide to install jq
  2. Install Python and pip if you haven't already
  3. Install yq via pip by running pip install yq

Recipes

@tom-sherman
tom-sherman / machine.js
Last active May 4, 2020 13:45
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
const saleStatusMachine = Machine({
id: 'saleSatus',
initial: 'in_progress',
states: {
in_progress: {
on: {
HOLD: 'held',
COMPLETE: {
target: 'completed',
cond: 'isFullyPaid'
module FetchMachine = Machine({
type state = [#idle | #loading | #success | #failure]
type event = [#FETCH | #RESOLVE | #REJECT | #RETRY]
type context = {retries: int}
let id = "fetch"
let initial = #idle
let states = [
State({
@tom-sherman
tom-sherman / machine.js
Created August 5, 2021 13:00
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@tom-sherman
tom-sherman / assertEventType.ts
Created December 23, 2021 08:09
XState Event Type Invariant
import { EventObject } from 'xstate';
export function assertEventType<
TEvent extends EventObject,
TType extends TEvent['type']
>(
event: TEvent,
type: TType
): asserts event is Extract<TEvent, { type: TType }>;
export function assertEventType<
@tom-sherman
tom-sherman / App.res
Created June 12, 2022 08:38
WIP - use-effect-reducer in ReScript
type effect
@module("use-effect-reducer")
external useEffectReducer: (
@uncurry (
'state,
'action,
@uncurry ((('state, unit, @uncurry ('action => unit)) => option<unit => unit>) => effect),
) => 'state,
'state,
@tom-sherman
tom-sherman / dynamoDbSessionStorage.ts
Created August 3, 2022 13:56
Remix session storage implementation using DynamoDB
import * as crypto from "node:crypto";
import type {
SessionIdStorageStrategy,
SessionStorage,
} from "@remix-run/server-runtime";
import { createSessionStorage } from "@remix-run/node";
import { DynamoDB } from "aws-sdk";
interface DynamoDbSessionStorageOptions {
/**
import * as React from "react";
import { ImageResponse } from "workers-og";
interface Env {}
export default {
async fetch(
request: Request,
env: Env,
ctx: ExecutionContext